2011-02-17 05:57:18 +00:00
|
|
|
/*
|
2008-10-31 23:50:02 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-10-31 23:50:02 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup RNA
|
2011-02-27 20:20:01 +00:00
|
|
|
*/
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#include <float.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-12-19 12:32:33 +00:00
|
|
|
#include <errno.h>
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "RNA_define.h"
|
2010-04-15 10:28:32 +00:00
|
|
|
#include "RNA_types.h"
|
2019-03-13 09:06:44 +11:00
|
|
|
#include "RNA_enum_types.h"
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
#include "rna_internal.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2012-01-01 10:27:53 +00:00
|
|
|
# ifndef snprintf
|
|
|
|
# define snprintf _snprintf
|
|
|
|
# endif
|
2008-10-31 23:50:02 +00:00
|
|
|
#endif
|
2012-01-01 10:27:53 +00:00
|
|
|
|
2019-02-18 09:32:15 +11:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
|
|
|
static CLG_LogRef LOG = {"makesrna"};
|
|
|
|
|
2017-11-28 20:27:40 +11:00
|
|
|
/**
|
|
|
|
* Variable to control debug output of makesrna.
|
|
|
|
* debugSRNA:
|
2018-11-14 12:53:15 +11:00
|
|
|
* - 0 = no output, except errors
|
|
|
|
* - 1 = detail actions
|
2017-11-28 20:27:40 +11:00
|
|
|
*/
|
|
|
|
static int debugSRNA = 0;
|
|
|
|
|
2014-11-18 00:20:56 +01:00
|
|
|
/* stub for BLI_abort() */
|
|
|
|
#ifndef NDEBUG
|
|
|
|
void BLI_system_backtrace(FILE *fp)
|
|
|
|
{
|
2016-08-16 14:57:56 +02:00
|
|
|
(void)fp;
|
2014-11-18 00:20:56 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-17 14:04:40 +00:00
|
|
|
/* Replace if different */
|
|
|
|
#define TMP_EXT ".tmp"
|
|
|
|
|
2010-12-18 09:27:08 +00:00
|
|
|
/* copied from BLI_file_older */
|
|
|
|
#include <sys/stat.h>
|
|
|
|
static int file_older(const char *file1, const char *file2)
|
|
|
|
{
|
|
|
|
struct stat st1, st2;
|
2017-11-28 20:27:40 +11:00
|
|
|
if (debugSRNA > 0) {
|
|
|
|
printf("compare: %s %s\n", file1, file2);
|
|
|
|
}
|
2010-12-18 09:27:08 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (stat(file1, &st1)) return 0;
|
|
|
|
if (stat(file2, &st2)) return 0;
|
2010-12-18 09:27:08 +00:00
|
|
|
|
|
|
|
return (st1.st_mtime < st2.st_mtime);
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
static const char *makesrna_path = NULL;
|
2010-12-18 09:27:08 +00:00
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
/* forward declarations */
|
|
|
|
static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc,
|
|
|
|
const char *name_override, int close_prototype);
|
|
|
|
|
|
|
|
/* helpers */
|
2012-11-09 09:33:28 +00:00
|
|
|
#define WRITE_COMMA \
|
|
|
|
{ \
|
2012-10-22 17:34:16 +00:00
|
|
|
if (!first) \
|
|
|
|
fprintf(f, ", "); \
|
|
|
|
first = 0; \
|
|
|
|
} (void)0
|
|
|
|
|
2012-11-09 09:33:28 +00:00
|
|
|
#define WRITE_PARAM(param) \
|
|
|
|
{ \
|
2012-10-22 17:34:16 +00:00
|
|
|
WRITE_COMMA; \
|
|
|
|
fprintf(f, param); \
|
2012-12-16 10:28:52 +00:00
|
|
|
} (void)0
|
2012-10-22 17:34:16 +00:00
|
|
|
|
2013-10-12 22:31:02 +00:00
|
|
|
static int replace_if_different(const char *tmpfile, const char *dep_files[])
|
2010-01-17 14:04:40 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
/* return 0; *//* use for testing had edited rna */
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2011-11-05 05:44:52 +00:00
|
|
|
#define REN_IF_DIFF \
|
|
|
|
{ \
|
2012-03-18 09:27:36 +00:00
|
|
|
FILE *file_test = fopen(orgfile, "rb"); \
|
|
|
|
if (file_test) { \
|
2011-11-05 05:44:52 +00:00
|
|
|
fclose(file_test); \
|
2012-03-18 09:27:36 +00:00
|
|
|
if (fp_org) fclose(fp_org); \
|
|
|
|
if (fp_new) fclose(fp_new); \
|
|
|
|
if (remove(orgfile) != 0) { \
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "remove error (%s): \"%s\"", \
|
|
|
|
strerror(errno), orgfile); \
|
2011-11-05 05:44:52 +00:00
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
2012-03-18 09:27:36 +00:00
|
|
|
if (rename(tmpfile, orgfile) != 0) { \
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "rename error (%s): \"%s\" -> \"%s\"", \
|
|
|
|
strerror(errno), tmpfile, orgfile); \
|
2011-11-05 05:44:52 +00:00
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
remove(tmpfile); \
|
2012-04-02 02:41:28 +00:00
|
|
|
return 1 \
|
2011-11-05 05:44:52 +00:00
|
|
|
|
2010-01-22 14:59:01 +00:00
|
|
|
/* end REN_IF_DIFF */
|
2010-01-17 14:04:40 +00:00
|
|
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
FILE *fp_new = NULL, *fp_org = NULL;
|
2010-01-17 14:04:40 +00:00
|
|
|
int len_new, len_org;
|
|
|
|
char *arr_new, *arr_org;
|
|
|
|
int cmp;
|
|
|
|
|
|
|
|
char orgfile[4096];
|
|
|
|
|
|
|
|
strcpy(orgfile, tmpfile);
|
|
|
|
orgfile[strlen(orgfile) - strlen(TMP_EXT)] = '\0'; /* strip '.tmp' */
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
fp_org = fopen(orgfile, "rb");
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (fp_org == NULL) {
|
2010-01-17 14:04:40 +00:00
|
|
|
REN_IF_DIFF;
|
|
|
|
}
|
|
|
|
|
2010-12-18 09:27:08 +00:00
|
|
|
|
2012-03-01 12:20:18 +00:00
|
|
|
/* XXX, trick to work around dependency problem
|
2010-12-18 09:27:08 +00:00
|
|
|
* assumes dep_files is in the same dir as makesrna.c, which is true for now. */
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (1) {
|
2010-12-18 09:27:08 +00:00
|
|
|
/* first check if makesrna.c is newer then generated files
|
|
|
|
* for development on makesrna.c you may want to disable this */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (file_older(orgfile, __FILE__)) {
|
2010-12-18 09:27:08 +00:00
|
|
|
REN_IF_DIFF;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (file_older(orgfile, makesrna_path)) {
|
2010-12-19 08:48:15 +00:00
|
|
|
REN_IF_DIFF;
|
|
|
|
}
|
|
|
|
|
2010-12-18 09:27:08 +00:00
|
|
|
/* now check if any files we depend on are newer then any generated files */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dep_files) {
|
2010-12-18 09:27:08 +00:00
|
|
|
int pass;
|
2012-03-05 23:30:41 +00:00
|
|
|
for (pass = 0; dep_files[pass]; pass++) {
|
|
|
|
char from_path[4096] = __FILE__;
|
2010-12-18 09:27:08 +00:00
|
|
|
char *p1, *p2;
|
|
|
|
|
|
|
|
/* dir only */
|
2012-03-05 23:30:41 +00:00
|
|
|
p1 = strrchr(from_path, '/');
|
|
|
|
p2 = strrchr(from_path, '\\');
|
2012-05-12 11:01:29 +00:00
|
|
|
strcpy((p1 > p2 ? p1 : p2) + 1, dep_files[pass]);
|
2010-12-18 09:27:08 +00:00
|
|
|
/* account for build deps, if makesrna.c (this file) is newer */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (file_older(orgfile, from_path)) {
|
2010-12-18 09:27:08 +00:00
|
|
|
REN_IF_DIFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* XXX end dep trick */
|
|
|
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
fp_new = fopen(tmpfile, "rb");
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (fp_new == NULL) {
|
2010-01-17 14:04:40 +00:00
|
|
|
/* shouldn't happen, just to be safe */
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "open error: \"%s\"", tmpfile);
|
2010-04-18 09:12:18 +00:00
|
|
|
fclose(fp_org);
|
2010-01-17 14:04:40 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fseek(fp_new, 0L, SEEK_END); len_new = ftell(fp_new); fseek(fp_new, 0L, SEEK_SET);
|
|
|
|
fseek(fp_org, 0L, SEEK_END); len_org = ftell(fp_org); fseek(fp_org, 0L, SEEK_SET);
|
|
|
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (len_new != len_org) {
|
2013-07-29 08:01:12 +00:00
|
|
|
fclose(fp_new); fp_new = NULL;
|
|
|
|
fclose(fp_org); fp_org = NULL;
|
2010-01-17 14:04:40 +00:00
|
|
|
REN_IF_DIFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now compare the files... */
|
2012-05-12 11:01:29 +00:00
|
|
|
arr_new = MEM_mallocN(sizeof(char) * len_new, "rna_cmp_file_new");
|
|
|
|
arr_org = MEM_mallocN(sizeof(char) * len_org, "rna_cmp_file_org");
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2019-02-18 09:32:15 +11:00
|
|
|
if (fread(arr_new, sizeof(char), len_new, fp_new) != len_new) {
|
|
|
|
CLOG_ERROR(&LOG, "unable to read file %s for comparison.", tmpfile);
|
|
|
|
}
|
|
|
|
if (fread(arr_org, sizeof(char), len_org, fp_org) != len_org) {
|
|
|
|
CLOG_ERROR(&LOG, "unable to read file %s for comparison.", orgfile);
|
|
|
|
}
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2013-07-29 08:01:12 +00:00
|
|
|
fclose(fp_new); fp_new = NULL;
|
|
|
|
fclose(fp_org); fp_org = NULL;
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
cmp = memcmp(arr_new, arr_org, len_new);
|
2010-01-17 14:04:40 +00:00
|
|
|
|
|
|
|
MEM_freeN(arr_new);
|
|
|
|
MEM_freeN(arr_org);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (cmp) {
|
2010-01-17 14:04:40 +00:00
|
|
|
REN_IF_DIFF;
|
|
|
|
}
|
|
|
|
else {
|
2010-01-22 14:59:01 +00:00
|
|
|
remove(tmpfile);
|
2010-01-17 14:04:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef REN_IF_DIFF
|
|
|
|
}
|
|
|
|
|
2011-05-18 12:56:58 +00:00
|
|
|
/* Helper to solve keyword problems with C/C++ */
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2011-05-18 12:56:58 +00:00
|
|
|
static const char *rna_safe_id(const char *id)
|
|
|
|
{
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(id, "default"))
|
2011-05-18 12:56:58 +00:00
|
|
|
return "default_value";
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(id, "operator"))
|
2011-05-18 12:56:58 +00:00
|
|
|
return "operator_value";
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(id, "new"))
|
2012-10-22 17:34:16 +00:00
|
|
|
return "create";
|
2016-06-28 08:31:52 +10:00
|
|
|
else if (STREQ(id, "co_return")) {
|
|
|
|
/* MSVC2015, C++ uses for coroutines */
|
|
|
|
return "coord_return";
|
|
|
|
}
|
2011-05-18 12:56:58 +00:00
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2008-11-26 22:52:01 +00:00
|
|
|
/* Sorting */
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static int cmp_struct(const void *a, const void *b)
|
2008-11-26 22:24:26 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
const StructRNA *structa = *(const StructRNA **)a;
|
|
|
|
const StructRNA *structb = *(const StructRNA **)b;
|
2008-11-26 22:24:26 +00:00
|
|
|
|
|
|
|
return strcmp(structa->identifier, structb->identifier);
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static int cmp_property(const void *a, const void *b)
|
2008-11-26 22:24:26 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
const PropertyRNA *propa = *(const PropertyRNA **)a;
|
|
|
|
const PropertyRNA *propb = *(const PropertyRNA **)b;
|
2008-11-26 22:24:26 +00:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(propa->identifier, "rna_type")) return -1;
|
|
|
|
else if (STREQ(propb->identifier, "rna_type")) return 1;
|
2008-11-26 22:24:26 +00:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(propa->identifier, "name")) return -1;
|
|
|
|
else if (STREQ(propb->identifier, "name")) return 1;
|
2008-11-26 22:24:26 +00:00
|
|
|
|
|
|
|
return strcmp(propa->name, propb->name);
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static int cmp_def_struct(const void *a, const void *b)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
const StructDefRNA *dsa = *(const StructDefRNA **)a;
|
|
|
|
const StructDefRNA *dsb = *(const StructDefRNA **)b;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
return cmp_struct(&dsa->srna, &dsb->srna);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cmp_def_property(const void *a, const void *b)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
const PropertyDefRNA *dpa = *(const PropertyDefRNA **)a;
|
|
|
|
const PropertyDefRNA *dpb = *(const PropertyDefRNA **)b;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
return cmp_property(&dpa->prop, &dpb->prop);
|
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
static void rna_sortlist(ListBase *listbase, int (*cmp)(const void *, const void *))
|
2008-11-26 22:24:26 +00:00
|
|
|
{
|
|
|
|
Link *link;
|
|
|
|
void **array;
|
|
|
|
int a, size;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (listbase->first == listbase->last)
|
2008-11-26 22:24:26 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (size = 0, link = listbase->first; link; link = link->next)
|
2008-11-26 22:24:26 +00:00
|
|
|
size++;
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
array = MEM_mallocN(sizeof(void *) * size, "rna_sortlist");
|
2012-03-05 23:30:41 +00:00
|
|
|
for (a = 0, link = listbase->first; link; link = link->next, a++)
|
|
|
|
array[a] = link;
|
2008-11-26 22:24:26 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
qsort(array, size, sizeof(void *), cmp);
|
2008-11-26 22:24:26 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
listbase->first = listbase->last = NULL;
|
2012-05-12 11:01:29 +00:00
|
|
|
for (a = 0; a < size; a++) {
|
2012-03-05 23:30:41 +00:00
|
|
|
link = array[a];
|
|
|
|
link->next = link->prev = NULL;
|
2008-11-26 22:24:26 +00:00
|
|
|
rna_addtail(listbase, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(array);
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
/* Preprocessing */
|
|
|
|
|
|
|
|
static void rna_print_c_string(FILE *f, const char *str)
|
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
static const char *escape[] = {"\''", "\"\"", "\??", "\\\\", "\aa", "\bb", "\ff", "\nn", "\rr", "\tt", "\vv", NULL};
|
2008-10-31 23:50:02 +00:00
|
|
|
int i, j;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!str) {
|
2009-07-10 11:36:02 +00:00
|
|
|
fprintf(f, "NULL");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "\"");
|
2012-03-05 23:30:41 +00:00
|
|
|
for (i = 0; str[i]; i++) {
|
|
|
|
for (j = 0; escape[j]; j++)
|
|
|
|
if (str[i] == escape[j][0])
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (escape[j]) fprintf(f, "\\%c", escape[j][1]);
|
2008-10-31 23:50:02 +00:00
|
|
|
else fprintf(f, "%c", str[i]);
|
|
|
|
}
|
|
|
|
fprintf(f, "\"");
|
|
|
|
}
|
|
|
|
|
2008-12-02 23:45:11 +00:00
|
|
|
static void rna_print_data_get(FILE *f, PropertyDefRNA *dp)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnastructfromname && dp->dnastructfromprop)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s *data = (%s *)(((%s *)ptr->data)->%s);\n", dp->dnastructname, dp->dnastructname,
|
2012-03-18 09:27:36 +00:00
|
|
|
dp->dnastructfromname, dp->dnastructfromprop);
|
2008-12-02 23:45:11 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s *data = (%s *)(ptr->data);\n", dp->dnastructname, dp->dnastructname);
|
2008-12-02 23:45:11 +00:00
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp))
|
2009-10-14 13:20:20 +00:00
|
|
|
{
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " ID *id = ptr->id.data;\n");
|
2009-10-14 13:20:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
static void rna_construct_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type)
|
|
|
|
{
|
|
|
|
snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_construct_wrapper_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type)
|
|
|
|
{
|
|
|
|
if (type == NULL || type[0] == '\0')
|
|
|
|
snprintf(buffer, size, "%s_%s", structname, propname);
|
|
|
|
else
|
|
|
|
snprintf(buffer, size, "%s_%s_%s", structname, propname, type);
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
static char *rna_alloc_function_name(const char *structname, const char *propname, const char *type)
|
|
|
|
{
|
|
|
|
AllocDefRNA *alloc;
|
|
|
|
char buffer[2048];
|
|
|
|
char *result;
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
rna_construct_function_name(buffer, sizeof(buffer), structname, propname, type);
|
2012-05-12 11:01:29 +00:00
|
|
|
result = MEM_callocN(sizeof(char) * strlen(buffer) + 1, "rna_alloc_function_name");
|
2008-10-31 23:50:02 +00:00
|
|
|
strcpy(result, buffer);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
alloc = MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
|
|
|
|
alloc->mem = result;
|
2008-10-31 23:50:02 +00:00
|
|
|
rna_addtail(&DefRNA.allocs, alloc);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-05-28 23:23:47 +00:00
|
|
|
static StructRNA *rna_find_struct(const char *identifier)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(ds->srna->identifier, identifier))
|
2009-05-28 23:23:47 +00:00
|
|
|
return ds->srna;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static const char *rna_find_type(const char *type)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
2015-01-26 16:03:11 +01:00
|
|
|
if (ds->dnaname && STREQ(ds->dnaname, type))
|
2009-04-07 00:49:39 +00:00
|
|
|
return ds->srna->identifier;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *rna_find_dna_type(const char *type)
|
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(ds->srna->identifier, type))
|
2009-04-07 00:49:39 +00:00
|
|
|
return ds->dnaname;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *rna_type_type_name(PropertyRNA *prop)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_BOOLEAN:
|
2018-07-01 15:47:09 +02:00
|
|
|
return "bool";
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_INT:
|
|
|
|
case PROP_ENUM:
|
|
|
|
return "int";
|
|
|
|
case PROP_FLOAT:
|
|
|
|
return "float";
|
|
|
|
case PROP_STRING:
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_THICK_WRAP) {
|
2012-12-28 14:19:05 +00:00
|
|
|
return "char *";
|
2010-11-17 09:45:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-12-28 14:19:05 +00:00
|
|
|
return "const char *";
|
2010-11-17 09:45:45 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
default:
|
2009-04-07 00:49:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *rna_type_type(PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
const char *type;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
type = rna_type_type_name(prop);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type)
|
2009-04-07 00:49:39 +00:00
|
|
|
return type;
|
|
|
|
|
|
|
|
return "PointerRNA";
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *rna_type_struct(PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
const char *type;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
type = rna_type_type_name(prop);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type)
|
2009-04-07 00:49:39 +00:00
|
|
|
return "";
|
|
|
|
|
|
|
|
return "struct ";
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *rna_parameter_type_name(PropertyRNA *parm)
|
|
|
|
{
|
|
|
|
const char *type;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
type = rna_type_type_name(parm);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type)
|
2009-04-07 00:49:39 +00:00
|
|
|
return type;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (parm->type) {
|
2012-05-20 19:49:27 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pparm = (PointerPropertyRNA *)parm;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (parm->flag_parameter & PARM_RNAPTR)
|
2009-04-07 00:49:39 +00:00
|
|
|
return "PointerRNA";
|
|
|
|
else
|
|
|
|
return rna_find_dna_type((const char *)pparm->type);
|
|
|
|
}
|
2012-05-20 19:49:27 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2016-06-22 18:04:04 +02:00
|
|
|
return "CollectionListBase";
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
return "<error, no type specified>";
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-26 22:52:01 +00:00
|
|
|
static int rna_enum_bitmask(PropertyRNA *prop)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
|
2012-03-05 23:30:41 +00:00
|
|
|
int a, mask = 0;
|
2008-11-26 22:52:01 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->item) {
|
2012-05-12 11:01:29 +00:00
|
|
|
for (a = 0; a < eprop->totitem; a++)
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->item[a].identifier[0])
|
2009-07-10 11:36:02 +00:00
|
|
|
mask |= eprop->item[a].value;
|
2009-05-28 23:23:47 +00:00
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2008-11-26 22:52:01 +00:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2009-01-07 21:05:51 +00:00
|
|
|
static int rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp)
|
|
|
|
{
|
2012-01-01 09:39:43 +00:00
|
|
|
return ( (prop->type == PROP_FLOAT) &&
|
2012-03-05 23:30:41 +00:00
|
|
|
(prop->subtype == PROP_COLOR || prop->subtype == PROP_COLOR_GAMMA) &&
|
2012-01-01 09:39:43 +00:00
|
|
|
(IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) );
|
2009-01-07 21:05:51 +00:00
|
|
|
}
|
|
|
|
|
2009-01-17 15:28:34 +00:00
|
|
|
static const char *rna_function_string(void *func)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
return (func) ? (const char *)func : "NULL";
|
2009-01-17 15:28:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_float_print(FILE *f, float num)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (num == -FLT_MAX) fprintf(f, "-FLT_MAX");
|
|
|
|
else if (num == FLT_MAX) fprintf(f, "FLT_MAX");
|
2017-04-11 11:48:00 +10:00
|
|
|
else if ((ABS(num) < INT64_MAX) && ((int64_t)num == num)) fprintf(f, "%.1ff", num);
|
2009-01-17 15:28:34 +00:00
|
|
|
else fprintf(f, "%.10ff", num);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_int_print(FILE *f, int num)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (num == INT_MIN) fprintf(f, "INT_MIN");
|
|
|
|
else if (num == INT_MAX) fprintf(f, "INT_MAX");
|
2009-01-17 15:28:34 +00:00
|
|
|
else fprintf(f, "%d", num);
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
|
|
|
|
const char *manualfunc)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
char *func;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return NULL;
|
2009-09-09 19:40:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!manualfunc) {
|
|
|
|
if (!dp->dnastructname || !dp->dnaname) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s has no valid dna info.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-02-02 19:57:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-12-31 04:12:20 +00:00
|
|
|
|
|
|
|
/* typecheck, */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnatype && *dp->dnatype) {
|
2010-12-31 04:12:20 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_FLOAT) {
|
|
|
|
if (IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) {
|
|
|
|
if (prop->subtype != PROP_COLOR_GAMMA) { /* colors are an exception. these get translated */
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s is a '%s' but wrapped as type '%s'.",
|
|
|
|
srna->identifier, prop->identifier, dp->dnatype,
|
|
|
|
RNA_property_typename(prop->type));
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2010-12-31 04:12:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->type == PROP_INT || prop->type == PROP_BOOLEAN || prop->type == PROP_ENUM) {
|
|
|
|
if (IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s is a '%s' but wrapped as type '%s'.",
|
|
|
|
srna->identifier, prop->identifier, dp->dnatype,
|
|
|
|
RNA_property_typename(prop->type));
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2010-12-31 04:12:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, char *value)\n", func);
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(ptr, value);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
const PropertySubType subtype = prop->subtype;
|
|
|
|
const char *string_copy_func = (subtype == PROP_FILEPATH ||
|
2012-05-12 11:01:29 +00:00
|
|
|
subtype == PROP_DIRPATH ||
|
|
|
|
subtype == PROP_FILENAME ||
|
|
|
|
subtype == PROP_BYTESTRING) ?
|
|
|
|
"BLI_strncpy" : "BLI_strncpy_utf8";
|
2011-09-15 11:49:36 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_print_data_get(f, dp);
|
2012-04-09 04:39:47 +00:00
|
|
|
|
|
|
|
if (!(prop->flag & PROP_NEVER_NULL)) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (data->%s == NULL) {\n", dp->dnaname);
|
|
|
|
fprintf(f, " *value = '\\0';\n");
|
|
|
|
fprintf(f, " return;\n");
|
|
|
|
fprintf(f, " }\n");
|
2012-04-09 04:39:47 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (sprop->maxlength)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(value, data->%s, %d);\n", string_copy_func, dp->dnaname, sprop->maxlength);
|
2009-04-19 17:12:16 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(value, data->%s, sizeof(data->%s));\n", string_copy_func,
|
2012-03-18 09:27:36 +00:00
|
|
|
dp->dnaname, dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "PointerRNA %s(PointerRNA *ptr)\n", func);
|
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return %s(ptr);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_print_data_get(f, dp);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnapointerlevel == 0)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return rna_pointer_inherit_refine(ptr, &RNA_%s, &data->%s);\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
(const char *)pprop->type, dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return rna_pointer_inherit_refine(ptr, &RNA_%s, data->%s);\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
(const char *)pprop->type, dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "static PointerRNA %s(CollectionPropertyIterator *iter)\n", func);
|
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(manualfunc, "rna_iterator_listbase_get") ||
|
|
|
|
STREQ(manualfunc, "rna_iterator_array_get") ||
|
|
|
|
STREQ(manualfunc, "rna_iterator_array_dereference_get"))
|
2012-03-12 06:07:16 +00:00
|
|
|
{
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
(cprop->item_type) ? (const char *)cprop->item_type : "UnknownType", manualfunc);
|
2012-03-12 06:07:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return %s(iter);\n", manualfunc);
|
2012-03-12 06:07:16 +00:00
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->arraydimension) {
|
|
|
|
if (prop->flag & PROP_DYNAMIC)
|
2009-09-09 19:40:46 +00:00
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, %s values[])\n", func, rna_type_type(prop));
|
|
|
|
else
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, %s values[%u])\n", func, rna_type_type(prop),
|
|
|
|
prop->totarraylength);
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "{\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(ptr, values);\n", manualfunc);
|
2008-11-18 10:57:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_print_data_get(f, dp);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_DYNAMIC) {
|
2012-03-18 09:27:36 +00:00
|
|
|
char *lenfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier),
|
|
|
|
"get_length");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " unsigned int arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
|
|
|
|
fprintf(f, " unsigned int i;\n");
|
|
|
|
fprintf(f, " unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
|
|
|
|
fprintf(f, " for (i = 0; i < len; i++) {\n");
|
2009-09-09 19:40:46 +00:00
|
|
|
MEM_freeN(lenfunc);
|
|
|
|
}
|
|
|
|
else {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " unsigned int i;\n\n");
|
|
|
|
fprintf(f, " for (i = 0; i < %u; i++) {\n", prop->totarraylength);
|
2009-09-09 19:40:46 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnaarraylength == 1) {
|
2012-03-12 06:07:16 +00:00
|
|
|
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " values[i] = %s((data->%s & (%du << i)) != 0);\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
(dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
|
2012-03-12 06:07:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " values[i] = (%s)%s((&data->%s)[i]);\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_type_type(prop), (dp->booleannegative) ? "!" : "", dp->dnaname);
|
2012-03-12 06:07:16 +00:00
|
|
|
}
|
2009-09-09 19:40:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " values[i] = %s((data->%s[i] & ", (dp->booleannegative) ? "!" : "",
|
2012-03-18 09:27:36 +00:00
|
|
|
dp->dnaname);
|
2009-09-09 19:40:46 +00:00
|
|
|
rna_int_print(f, dp->booleanbit);
|
|
|
|
fprintf(f, ") != 0);\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2012-03-12 06:07:16 +00:00
|
|
|
else if (rna_color_quantize(prop, dp)) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " values[i] = (%s)(data->%s[i] * (1.0f / 255.0f));\n",
|
2012-03-12 06:07:16 +00:00
|
|
|
rna_type_type(prop), dp->dnaname);
|
|
|
|
}
|
|
|
|
else if (dp->dnatype) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " values[i] = (%s)%s(((%s *)data->%s)[i]);\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_type_type(prop), (dp->booleannegative) ? "!" : "", dp->dnatype, dp->dnaname);
|
2012-03-12 06:07:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " values[i] = (%s)%s((data->%s)[i]);\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_type_type(prop), (dp->booleannegative) ? "!" : "", dp->dnaname);
|
2012-03-12 06:07:16 +00:00
|
|
|
}
|
2009-01-17 15:28:34 +00:00
|
|
|
}
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " }\n");
|
2008-11-18 10:57:06 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
}
|
|
|
|
else {
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "%s %s(PointerRNA *ptr)\n", rna_type_type(prop), func);
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "{\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return %s(ptr);\n", manualfunc);
|
2009-01-17 15:28:34 +00:00
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
else {
|
|
|
|
rna_print_data_get(f, dp);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return %s(((data->%s) & ", (dp->booleannegative) ? "!" : "", dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_int_print(f, dp->booleanbit);
|
|
|
|
fprintf(f, ") != 0);\n");
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->type == PROP_ENUM && dp->enumbitflags) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return ((data->%s) & ", dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_int_print(f, rna_enum_bitmask(prop));
|
|
|
|
fprintf(f, ");\n");
|
|
|
|
}
|
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return (%s)%s(data->%s);\n", rna_type_type(prop),
|
2012-05-12 11:01:29 +00:00
|
|
|
(dp->booleannegative) ? "!" : "", dp->dnaname);
|
2009-01-17 15:28:34 +00:00
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2011-06-23 05:58:44 +00:00
|
|
|
/* defined min/max variables to be used by rna_clamp_value() */
|
|
|
|
static void rna_clamp_value_range(FILE *f, PropertyRNA *prop)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_FLOAT) {
|
2012-05-12 11:01:29 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (fprop->range) {
|
2012-04-15 13:41:07 +00:00
|
|
|
fprintf(f,
|
2019-01-28 23:06:37 +11:00
|
|
|
" float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;\n");
|
|
|
|
fprintf(f, " %s(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);\n",
|
2012-04-15 13:41:07 +00:00
|
|
|
rna_function_string(fprop->range));
|
2011-06-23 05:58:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->type == PROP_INT) {
|
2012-05-12 11:01:29 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (iprop->range) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " int prop_clamp_min = INT_MIN, prop_clamp_max = INT_MAX, prop_soft_min, prop_soft_max;\n");
|
|
|
|
fprintf(f, " %s(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);\n",
|
2012-04-15 13:41:07 +00:00
|
|
|
rna_function_string(iprop->range));
|
2011-06-23 05:58:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-28 20:00:33 +10:00
|
|
|
#ifdef USE_RNA_RANGE_CHECK
|
|
|
|
static void rna_clamp_value_range_check(
|
|
|
|
FILE *f, PropertyRNA *prop,
|
|
|
|
const char *dnaname_prefix, const char *dnaname)
|
|
|
|
{
|
|
|
|
if (prop->type == PROP_INT) {
|
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
|
|
|
|
fprintf(f,
|
2019-01-28 23:06:37 +11:00
|
|
|
" { BLI_STATIC_ASSERT("
|
2014-07-28 20:00:33 +10:00
|
|
|
"(TYPEOF_MAX(%s%s) >= %d) && "
|
|
|
|
"(TYPEOF_MIN(%s%s) <= %d), "
|
|
|
|
"\"invalid limits\"); }\n",
|
|
|
|
dnaname_prefix, dnaname, iprop->hardmax,
|
|
|
|
dnaname_prefix, dnaname, iprop->hardmin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* USE_RNA_RANGE_CHECK */
|
|
|
|
|
2009-09-09 19:40:46 +00:00
|
|
|
static void rna_clamp_value(FILE *f, PropertyRNA *prop, int array)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_INT) {
|
2012-05-12 11:01:29 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-12-12 17:50:35 +00:00
|
|
|
if (iprop->hardmin != INT_MIN || iprop->hardmax != INT_MAX || iprop->range) {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (array) fprintf(f, "CLAMPIS(values[i], ");
|
2009-02-02 19:57:57 +00:00
|
|
|
else fprintf(f, "CLAMPIS(value, ");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (iprop->range) {
|
2011-06-23 05:58:44 +00:00
|
|
|
fprintf(f, "prop_clamp_min, prop_clamp_max);");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_int_print(f, iprop->hardmin); fprintf(f, ", ");
|
|
|
|
rna_int_print(f, iprop->hardmax); fprintf(f, ");\n");
|
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
return;
|
2008-11-29 14:35:50 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->type == PROP_FLOAT) {
|
2012-05-12 11:01:29 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-12-12 17:50:35 +00:00
|
|
|
if (fprop->hardmin != -FLT_MAX || fprop->hardmax != FLT_MAX || fprop->range) {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (array) fprintf(f, "CLAMPIS(values[i], ");
|
2009-02-02 19:57:57 +00:00
|
|
|
else fprintf(f, "CLAMPIS(value, ");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (fprop->range) {
|
2011-06-23 05:58:44 +00:00
|
|
|
fprintf(f, "prop_clamp_min, prop_clamp_max);");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_float_print(f, fprop->hardmin); fprintf(f, ", ");
|
|
|
|
rna_float_print(f, fprop->hardmax); fprintf(f, ");\n");
|
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
return;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (array)
|
2009-09-09 19:40:46 +00:00
|
|
|
fprintf(f, "values[i];\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
else
|
|
|
|
fprintf(f, "value;\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
|
|
|
|
const char *manualfunc)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
char *func;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!(prop->flag & PROP_EDITABLE))
|
2009-03-23 13:24:48 +00:00
|
|
|
return NULL;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!manualfunc) {
|
|
|
|
if (!dp->dnastructname || !dp->dnaname) {
|
|
|
|
if (prop->flag & PROP_EDITABLE) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s has no valid dna info.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2008-11-14 14:34:19 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "set");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, const char *value)\n", func);
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(ptr, value);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
const PropertySubType subtype = prop->subtype;
|
|
|
|
const char *string_copy_func = (subtype == PROP_FILEPATH ||
|
2012-05-12 11:01:29 +00:00
|
|
|
subtype == PROP_DIRPATH ||
|
|
|
|
subtype == PROP_FILENAME ||
|
|
|
|
subtype == PROP_BYTESTRING) ?
|
|
|
|
"BLI_strncpy" : "BLI_strncpy_utf8";
|
2011-09-15 11:49:36 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_print_data_get(f, dp);
|
2012-04-09 04:39:47 +00:00
|
|
|
|
|
|
|
if (!(prop->flag & PROP_NEVER_NULL)) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (data->%s == NULL) {\n", dp->dnaname);
|
|
|
|
fprintf(f, " return;\n");
|
|
|
|
fprintf(f, " }\n");
|
2012-04-09 04:39:47 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (sprop->maxlength)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(data->%s, value, %d);\n", string_copy_func, dp->dnaname, sprop->maxlength);
|
2009-04-19 17:12:16 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(data->%s, value, sizeof(data->%s));\n", string_copy_func,
|
2012-03-18 09:27:36 +00:00
|
|
|
dp->dnaname, dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, PointerRNA value)\n", func);
|
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(ptr, value);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_print_data_get(f, dp);
|
2009-05-28 23:23:47 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_ID_SELF_CHECK) {
|
2009-10-14 13:20:20 +00:00
|
|
|
rna_print_id_get(f, dp);
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (id == value.data) return;\n\n");
|
2009-10-14 13:20:20 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_ID_REFCOUNT) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n if (data->%s)\n", dp->dnaname);
|
|
|
|
fprintf(f, " id_us_min((ID *)data->%s);\n", dp->dnaname);
|
|
|
|
fprintf(f, " if (value.data)\n");
|
|
|
|
fprintf(f, " id_us_plus((ID *)value.data);\n\n");
|
2009-05-28 23:23:47 +00:00
|
|
|
}
|
2010-07-20 19:39:07 +00:00
|
|
|
else {
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
StructRNA *type = (pprop->type) ? rna_find_struct((const char *)pprop->type) : NULL;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type && (type->flag & STRUCT_ID)) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (value.data)\n");
|
|
|
|
fprintf(f, " id_lib_extern((ID *)value.data);\n\n");
|
2010-07-20 19:39:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-29 15:12:31 +00:00
|
|
|
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " data->%s = value.data;\n", dp->dnaname);
|
2009-05-28 23:23:47 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->arraydimension) {
|
|
|
|
if (prop->flag & PROP_DYNAMIC)
|
2009-09-09 19:40:46 +00:00
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, const %s values[])\n", func, rna_type_type(prop));
|
|
|
|
else
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, const %s values[%u])\n", func,
|
|
|
|
rna_type_type(prop), prop->totarraylength);
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "{\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(ptr, values);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_print_data_get(f, dp);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_DYNAMIC) {
|
2012-03-18 09:27:36 +00:00
|
|
|
char *lenfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier),
|
|
|
|
"set_length");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " unsigned int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
|
|
|
|
fprintf(f, " unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
|
2011-06-23 07:50:28 +00:00
|
|
|
rna_clamp_value_range(f, prop);
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " for (i = 0; i < len; i++) {\n");
|
2009-09-09 19:40:46 +00:00
|
|
|
MEM_freeN(lenfunc);
|
|
|
|
}
|
|
|
|
else {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " unsigned int i;\n\n");
|
2011-06-23 07:50:28 +00:00
|
|
|
rna_clamp_value_range(f, prop);
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " for (i = 0; i < %u; i++) {\n", prop->totarraylength);
|
2009-09-09 19:40:46 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnaarraylength == 1) {
|
|
|
|
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (%svalues[i]) data->%s |= (%du << i);\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
(dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit);
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " else data->%s &= ~(%du << i);\n", dp->dnaname, dp->booleanbit);
|
2009-09-09 19:40:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
|
2009-09-09 19:40:46 +00:00
|
|
|
rna_clamp_value(f, prop, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (%svalues[i]) data->%s[i] |= ", (dp->booleannegative) ? "!" : "",
|
2012-03-18 09:27:36 +00:00
|
|
|
dp->dnaname);
|
2009-09-09 19:40:46 +00:00
|
|
|
rna_int_print(f, dp->booleanbit);
|
|
|
|
fprintf(f, ";\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " else data->%s[i] &= ~", dp->dnaname);
|
2009-09-09 19:40:46 +00:00
|
|
|
rna_int_print(f, dp->booleanbit);
|
|
|
|
fprintf(f, ";\n");
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (rna_color_quantize(prop, dp)) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " data->%s[i] = unit_float_to_uchar_clamp(values[i]);\n", dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnatype)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " ((%s *)data->%s)[i] = %s", dp->dnatype, dp->dnaname,
|
2012-03-18 09:27:36 +00:00
|
|
|
(dp->booleannegative) ? "!" : "");
|
2009-09-09 19:40:46 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " (data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
|
2009-09-09 19:40:46 +00:00
|
|
|
rna_clamp_value(f, prop, 1);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-11-18 10:57:06 +00:00
|
|
|
}
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " }\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2014-07-28 20:00:33 +10:00
|
|
|
|
|
|
|
#ifdef USE_RNA_RANGE_CHECK
|
|
|
|
if (dp->dnaname && manualfunc == NULL) {
|
|
|
|
if (dp->dnaarraylength == 1) {
|
|
|
|
rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_clamp_value_range_check(f, prop, "*data->", dp->dnaname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(f, "void %s(PointerRNA *ptr, %s value)\n", func, rna_type_type(prop));
|
|
|
|
fprintf(f, "{\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(ptr, value);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
else {
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_print_data_get(f, dp);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (%svalue) data->%s |= ", (dp->booleannegative) ? "!" : "", dp->dnaname);
|
2009-01-17 15:28:34 +00:00
|
|
|
rna_int_print(f, dp->booleanbit);
|
|
|
|
fprintf(f, ";\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " else data->%s &= ~", dp->dnaname);
|
2009-01-17 15:28:34 +00:00
|
|
|
rna_int_print(f, dp->booleanbit);
|
|
|
|
fprintf(f, ";\n");
|
2008-11-18 10:57:06 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->type == PROP_ENUM && dp->enumbitflags) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " data->%s &= ~", dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_int_print(f, rna_enum_bitmask(prop));
|
|
|
|
fprintf(f, ";\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " data->%s |= value;\n", dp->dnaname);
|
2009-01-07 21:05:51 +00:00
|
|
|
}
|
2008-11-18 10:57:06 +00:00
|
|
|
else {
|
2011-06-23 05:58:44 +00:00
|
|
|
rna_clamp_value_range(f, prop);
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " data->%s = %s", dp->dnaname, (dp->booleannegative) ? "!" : "");
|
2009-09-09 19:40:46 +00:00
|
|
|
rna_clamp_value(f, prop, 0);
|
2008-11-18 10:57:06 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2014-07-28 20:00:33 +10:00
|
|
|
|
|
|
|
#ifdef USE_RNA_RANGE_CHECK
|
|
|
|
if (dp->dnaname && manualfunc == NULL) {
|
|
|
|
rna_clamp_value_range_check(f, prop, "data->", dp->dnaname);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
|
|
|
|
const char *manualfunc)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
char *func = NULL;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->type == PROP_STRING) {
|
|
|
|
if (!manualfunc) {
|
|
|
|
if (!dp->dnastructname || !dp->dnaname) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s has no valid dna info.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-02-02 19:57:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "int %s(PointerRNA *ptr)\n", func);
|
2008-11-07 02:58:25 +00:00
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return %s(ptr);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_print_data_get(f, dp);
|
2012-04-09 04:39:47 +00:00
|
|
|
if (!(prop->flag & PROP_NEVER_NULL)) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " if (data->%s == NULL) return 0;\n", dp->dnaname);
|
2012-04-09 04:39:47 +00:00
|
|
|
}
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return strlen(data->%s);\n", dp->dnaname);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
fprintf(f, "}\n\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->type == PROP_COLLECTION) {
|
|
|
|
if (!manualfunc) {
|
2012-05-12 11:01:29 +00:00
|
|
|
if (prop->type == PROP_COLLECTION && (!(dp->dnalengthname || dp->dnalengthfixed) || !dp->dnaname)) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s has no valid dna info.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-02-02 19:57:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "length");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "int %s(PointerRNA *ptr)\n", func);
|
2008-11-07 02:58:25 +00:00
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return %s(ptr);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-08-12 22:17:27 +02:00
|
|
|
if (dp->dnaarraylength <= 1 || dp->dnalengthname)
|
|
|
|
rna_print_data_get(f, dp);
|
|
|
|
|
|
|
|
if (dp->dnaarraylength > 1)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return ");
|
2015-08-12 22:17:27 +02:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return (data->%s == NULL) ? 0 : ", dp->dnaname);
|
2015-08-12 22:17:27 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnalengthname)
|
2015-08-12 22:17:27 +02:00
|
|
|
fprintf(f, "data->%s;\n", dp->dnalengthname);
|
2009-02-02 19:57:57 +00:00
|
|
|
else
|
2015-08-12 22:17:27 +02:00
|
|
|
fprintf(f, "%d;\n", dp->dnalengthfixed);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
|
|
|
|
const char *manualfunc)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
char *func, *getfunc;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!manualfunc) {
|
|
|
|
if (!dp->dnastructname || !dp->dnaname) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s has no valid dna info.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-02-02 19:57:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "begin");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
|
|
|
|
fprintf(f, "{\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!manualfunc)
|
2008-12-02 23:45:11 +00:00
|
|
|
rna_print_data_get(f, dp);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n memset(iter, 0, sizeof(*iter));\n");
|
|
|
|
fprintf(f, " iter->parent = *ptr;\n");
|
|
|
|
fprintf(f, " iter->prop = (PropertyRNA *)&rna_%s_%s;\n", srna->identifier, prop->identifier);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnalengthname || dp->dnalengthfixed) {
|
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnalengthname)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), data->%s, 0, NULL);\n",
|
2012-03-18 09:27:36 +00:00
|
|
|
dp->dnaname, dp->dnaname, dp->dnalengthname);
|
2009-02-02 19:57:57 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), %d, 0, NULL);\n",
|
2012-03-18 09:27:36 +00:00
|
|
|
dp->dnaname, dp->dnaname, dp->dnalengthfixed);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (dp->dnapointerlevel == 0)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n rna_iterator_listbase_begin(iter, &data->%s, NULL);\n", dp->dnaname);
|
2009-06-19 14:56:49 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n rna_iterator_listbase_begin(iter, data->%s, NULL);\n", dp->dnaname);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n if (iter->valid)\n");
|
|
|
|
fprintf(f, " iter->ptr = %s(iter);\n", getfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
|
|
|
|
const char *manualfunc, const char *nextfunc)
|
2010-03-14 22:30:57 +00:00
|
|
|
{
|
2011-01-18 01:58:19 +00:00
|
|
|
/* note on indices, this is for external functions and ignores skipped values.
|
2014-10-29 14:11:19 +01:00
|
|
|
* so the index can only be checked against the length when there is no 'skip' function. */
|
2010-03-14 22:30:57 +00:00
|
|
|
char *func;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
2010-03-14 22:30:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!manualfunc) {
|
|
|
|
if (!dp->dnastructname || !dp->dnaname)
|
2010-03-14 22:30:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* only supported in case of standard next functions */
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(nextfunc, "rna_iterator_array_next")) {}
|
|
|
|
else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {}
|
2010-03-14 22:30:57 +00:00
|
|
|
else return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_int");
|
2010-03-14 22:30:57 +00:00
|
|
|
|
2011-01-05 14:49:08 +00:00
|
|
|
fprintf(f, "int %s(PointerRNA *ptr, int index, PointerRNA *r_ptr)\n", func);
|
2010-03-14 22:30:57 +00:00
|
|
|
fprintf(f, "{\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n return %s(ptr, index, r_ptr);\n", manualfunc);
|
2010-03-14 22:30:57 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " int found = 0;\n");
|
|
|
|
fprintf(f, " CollectionPropertyIterator iter;\n\n");
|
2010-03-14 22:30:57 +00:00
|
|
|
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, " if (iter.valid) {\n");
|
2010-03-14 22:30:57 +00:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(nextfunc, "rna_iterator_array_next")) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " ArrayIterator *internal = &iter.internal.array;\n");
|
|
|
|
fprintf(f, " if (index < 0 || index >= internal->length) {\n");
|
2011-01-01 15:49:25 +00:00
|
|
|
fprintf(f, "#ifdef __GNUC__\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " printf(\"Array iterator out of range: %%s (index %%d)\\n\", __func__, index);\n");
|
2011-01-01 15:49:25 +00:00
|
|
|
fprintf(f, "#else\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " printf(\"Array iterator out of range: (index %%d)\\n\", index);\n");
|
2011-01-01 15:49:25 +00:00
|
|
|
fprintf(f, "#endif\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " else if (internal->skip) {\n");
|
|
|
|
fprintf(f, " while (index-- > 0 && iter.valid) {\n");
|
|
|
|
fprintf(f, " rna_iterator_array_next(&iter);\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " found = (index == -1 && iter.valid);\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " else {\n");
|
|
|
|
fprintf(f, " internal->ptr += internal->itemsize * index;\n");
|
|
|
|
fprintf(f, " found = 1;\n");
|
|
|
|
fprintf(f, " }\n");
|
2010-03-14 22:30:57 +00:00
|
|
|
}
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " ListBaseIterator *internal = &iter.internal.listbase;\n");
|
|
|
|
fprintf(f, " if (internal->skip) {\n");
|
|
|
|
fprintf(f, " while (index-- > 0 && iter.valid) {\n");
|
|
|
|
fprintf(f, " rna_iterator_listbase_next(&iter);\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " found = (index == -1 && iter.valid);\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " else {\n");
|
|
|
|
fprintf(f, " while (index-- > 0 && internal->link)\n");
|
|
|
|
fprintf(f, " internal->link = internal->link->next;\n");
|
|
|
|
fprintf(f, " found = (index == -1 && internal->link);\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, " if (found) *r_ptr = %s_%s_get(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, " }\n\n");
|
|
|
|
fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
|
|
|
|
|
|
|
|
fprintf(f, " return found;\n");
|
2010-03-14 22:30:57 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
rna_print_data_get(f, dp);
|
2012-05-12 11:01:29 +00:00
|
|
|
item_type = (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType";
|
2010-03-14 22:30:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnalengthname || dp->dnalengthfixed) {
|
|
|
|
if (dp->dnalengthname)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), data->%s, index);\n",
|
2012-03-18 09:27:36 +00:00
|
|
|
item_type, dp->dnaname, dp->dnaname, dp->dnalengthname);
|
2010-03-14 22:30:57 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n rna_array_lookup_int(ptr, &RNA_%s, data->%s, sizeof(data->%s[0]), %d, index);\n",
|
2012-03-18 09:27:36 +00:00
|
|
|
item_type, dp->dnaname, dp->dnaname, dp->dnalengthfixed);
|
2010-03-14 22:30:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnapointerlevel == 0)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, &data->%s, index);\n",
|
2012-03-18 09:27:36 +00:00
|
|
|
item_type, dp->dnaname);
|
2010-03-14 22:30:57 +00:00
|
|
|
else
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n return rna_listbase_lookup_int(ptr, &RNA_%s, data->%s, index);\n", item_type, dp->dnaname);
|
2010-03-14 22:30:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-11-19 15:18:08 +00:00
|
|
|
static char *rna_def_property_lookup_string_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp,
|
|
|
|
const char *manualfunc, const char *item_type)
|
|
|
|
{
|
|
|
|
char *func;
|
|
|
|
StructRNA *item_srna, *item_name_base;
|
|
|
|
PropertyRNA *item_name_prop;
|
|
|
|
const int namebuflen = 1024;
|
|
|
|
|
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!manualfunc) {
|
|
|
|
if (!dp->dnastructname || !dp->dnaname)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* only supported for collection items with name properties */
|
|
|
|
item_srna = rna_find_struct(item_type);
|
|
|
|
if (item_srna && item_srna->nameproperty) {
|
|
|
|
item_name_prop = item_srna->nameproperty;
|
|
|
|
item_name_base = item_srna;
|
|
|
|
while (item_name_base->base && item_name_base->base->nameproperty == item_name_prop)
|
|
|
|
item_name_base = item_name_base->base;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "lookup_string");
|
|
|
|
|
|
|
|
fprintf(f, "int %s(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)\n", func);
|
|
|
|
fprintf(f, "{\n");
|
|
|
|
|
|
|
|
if (manualfunc) {
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " return %s(ptr, key, r_ptr);\n", manualfunc);
|
2012-11-19 15:18:08 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX extern declaration could be avoid by including RNA_blender.h, but this has lots of unknown
|
|
|
|
* DNA types in functions, leading to conflicting function signatures.
|
|
|
|
*/
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " extern int %s_%s_length(PointerRNA *);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
|
|
|
|
fprintf(f, " extern void %s_%s_get(PointerRNA *, char *);\n\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
|
|
|
|
|
|
|
|
fprintf(f, " bool found = false;\n");
|
|
|
|
fprintf(f, " CollectionPropertyIterator iter;\n");
|
|
|
|
fprintf(f, " char namebuf[%d];\n", namebuflen);
|
|
|
|
fprintf(f, " char *name;\n\n");
|
|
|
|
|
|
|
|
fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
|
|
|
|
|
|
|
|
fprintf(f, " while (iter.valid) {\n");
|
|
|
|
fprintf(f, " if (iter.ptr.data) {\n");
|
|
|
|
fprintf(f, " int namelen = %s_%s_length(&iter.ptr);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
|
|
|
|
fprintf(f, " if (namelen < %d) {\n", namebuflen);
|
|
|
|
fprintf(f, " %s_%s_get(&iter.ptr, namebuf);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
|
|
|
|
fprintf(f, " if (strcmp(namebuf, key) == 0) {\n");
|
|
|
|
fprintf(f, " found = true;\n");
|
|
|
|
fprintf(f, " *r_ptr = iter.ptr;\n");
|
|
|
|
fprintf(f, " break;\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " else {\n");
|
|
|
|
fprintf(f, " name = MEM_mallocN(namelen+1, \"name string\");\n");
|
|
|
|
fprintf(f, " %s_%s_get(&iter.ptr, name);\n", item_name_base->identifier, rna_safe_id(item_name_prop->identifier));
|
|
|
|
fprintf(f, " if (strcmp(name, key) == 0) {\n");
|
|
|
|
fprintf(f, " MEM_freeN(name);\n\n");
|
|
|
|
fprintf(f, " found = true;\n");
|
|
|
|
fprintf(f, " *r_ptr = iter.ptr;\n");
|
|
|
|
fprintf(f, " break;\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " else {\n");
|
|
|
|
fprintf(f, " MEM_freeN(name);\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " %s_%s_next(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, " }\n");
|
|
|
|
fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
|
|
|
|
|
|
|
|
fprintf(f, " return found;\n");
|
2012-11-19 15:18:08 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp),
|
2012-03-18 09:27:36 +00:00
|
|
|
const char *manualfunc)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
char *func, *getfunc;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
2009-02-02 19:57:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!manualfunc)
|
2009-02-02 19:57:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "next");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "void %s(CollectionPropertyIterator *iter)\n", func);
|
|
|
|
fprintf(f, "{\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(iter);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, "\n if (iter->valid)\n");
|
|
|
|
fprintf(f, " iter->ptr = %s(iter);\n", getfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
|
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp),
|
2012-03-18 09:27:36 +00:00
|
|
|
const char *manualfunc)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
char *func;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->flag & PROP_IDPROPERTY && manualfunc == NULL)
|
2009-02-02 19:57:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "end");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "void %s(CollectionPropertyIterator *iter)\n", func);
|
|
|
|
fprintf(f, "{\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (manualfunc)
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " %s(iter);\n", manualfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
return func;
|
|
|
|
}
|
|
|
|
|
2009-07-02 03:32:57 +00:00
|
|
|
static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnapointerlevel != 0)
|
2009-07-02 03:32:57 +00:00
|
|
|
return;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!dp->dnatype || !dp->dnaname || !dp->dnastructname)
|
2009-07-02 03:32:57 +00:00
|
|
|
return;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(dp->dnatype, "char")) {
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->rawtype = PROP_RAW_CHAR;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(dp->dnatype, "short")) {
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->rawtype = PROP_RAW_SHORT;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(dp->dnatype, "int")) {
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->rawtype = PROP_RAW_INT;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(dp->dnatype, "float")) {
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->rawtype = PROP_RAW_FLOAT;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2015-01-26 16:03:11 +01:00
|
|
|
else if (STREQ(dp->dnatype, "double")) {
|
2012-03-05 23:30:41 +00:00
|
|
|
prop->rawtype = PROP_RAW_DOUBLE;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
prop->flag_internal |= PROP_INTERN_RAW_ACCESS;
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_set_raw_offset(FILE *f, StructRNA *srna, PropertyRNA *prop)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
PropertyDefRNA *dp = rna_find_struct_property_def(srna, prop);
|
2009-07-02 03:32:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "\toffsetof(%s, %s), %d", dp->dnastructname, dp->dnaname, prop->rawtype);
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = dp->prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension) {
|
|
|
|
if (!bprop->get && !bprop->set && !dp->booleanbit)
|
2009-07-02 03:32:57 +00:00
|
|
|
rna_set_raw_property(dp, prop);
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
bprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)bprop->get);
|
|
|
|
bprop->set = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)bprop->set);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-12 11:01:29 +00:00
|
|
|
bprop->getarray = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)bprop->getarray);
|
|
|
|
bprop->setarray = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)bprop->setarray);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_INT:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension) {
|
|
|
|
if (!iprop->get && !iprop->set)
|
2009-07-02 03:32:57 +00:00
|
|
|
rna_set_raw_property(dp, prop);
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
iprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)iprop->get);
|
|
|
|
iprop->set = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)iprop->set);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!iprop->getarray && !iprop->setarray)
|
2009-07-02 03:32:57 +00:00
|
|
|
rna_set_raw_property(dp, prop);
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
iprop->getarray = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)iprop->getarray);
|
|
|
|
iprop->setarray = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)iprop->setarray);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension) {
|
|
|
|
if (!fprop->get && !fprop->set)
|
2009-07-02 03:32:57 +00:00
|
|
|
rna_set_raw_property(dp, prop);
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
fprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)fprop->get);
|
|
|
|
fprop->set = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)fprop->set);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!fprop->getarray && !fprop->setarray)
|
2009-07-02 03:32:57 +00:00
|
|
|
rna_set_raw_property(dp, prop);
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
fprop->getarray = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)fprop->getarray);
|
|
|
|
fprop->setarray = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)fprop->setarray);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
eprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)eprop->get);
|
|
|
|
eprop->set = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)eprop->set);
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
sprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)sprop->get);
|
|
|
|
sprop->length = (void *)rna_def_property_length_func(f, srna, prop, dp, (const char *)sprop->length);
|
|
|
|
sprop->set = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)sprop->set);
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
pprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)pprop->get);
|
|
|
|
pprop->set = (void *)rna_def_property_set_func(f, srna, prop, dp, (const char *)pprop->set);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!pprop->type) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s, pointer must have a struct type.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
|
|
|
|
const char *nextfunc = (const char *)cprop->next;
|
2012-11-19 15:18:08 +00:00
|
|
|
const char *item_type = (const char *)cprop->item_type;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2016-11-20 17:46:29 +01:00
|
|
|
if (cprop->length) {
|
|
|
|
/* always generate if we have a manual implementation */
|
|
|
|
cprop->length = (void *)rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length);
|
|
|
|
}
|
|
|
|
else if (dp->dnatype && STREQ(dp->dnatype, "ListBase")) {
|
2012-10-14 13:08:19 +00:00
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if (dp->dnalengthname || dp->dnalengthfixed) {
|
2012-05-12 11:01:29 +00:00
|
|
|
cprop->length = (void *)rna_def_property_length_func(f, srna, prop, dp, (const char *)cprop->length);
|
2012-10-14 13:08:19 +00:00
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2009-07-02 03:32:57 +00:00
|
|
|
/* test if we can allow raw array access, if it is using our standard
|
|
|
|
* array get/next function, we can be sure it is an actual array */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (cprop->next && cprop->get)
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ((const char *)cprop->next, "rna_iterator_array_next") &&
|
|
|
|
STREQ((const char *)cprop->get, "rna_iterator_array_get"))
|
2012-04-28 06:31:57 +00:00
|
|
|
{
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
prop->flag_internal |= PROP_INTERN_RAW_ARRAY;
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
2009-07-02 03:32:57 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
cprop->get = (void *)rna_def_property_get_func(f, srna, prop, dp, (const char *)cprop->get);
|
|
|
|
cprop->begin = (void *)rna_def_property_begin_func(f, srna, prop, dp, (const char *)cprop->begin);
|
|
|
|
cprop->next = (void *)rna_def_property_next_func(f, srna, prop, dp, (const char *)cprop->next);
|
|
|
|
cprop->end = (void *)rna_def_property_end_func(f, srna, prop, dp, (const char *)cprop->end);
|
|
|
|
cprop->lookupint = (void *)rna_def_property_lookup_int_func(f, srna, prop, dp,
|
|
|
|
(const char *)cprop->lookupint, nextfunc);
|
2012-11-19 15:18:08 +00:00
|
|
|
cprop->lookupstring = (void *)rna_def_property_lookup_string_func(f, srna, prop, dp,
|
|
|
|
(const char *)cprop->lookupstring, item_type);
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!(prop->flag & PROP_IDPROPERTY)) {
|
|
|
|
if (!cprop->begin) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s, collection must have a begin function.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!cprop->next) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s, collection must have a next function.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!cprop->get) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s, collection must have a get function.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
}
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!cprop->item_type) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s.%s, collection must have a struct type.",
|
|
|
|
srna->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
2014-04-27 00:24:11 +10:00
|
|
|
const char *func;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = dp->prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
|
2009-02-02 19:57:57 +00:00
|
|
|
return;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2009-02-02 19:57:57 +00:00
|
|
|
case PROP_BOOLEAN:
|
2018-07-01 15:47:09 +02:00
|
|
|
{
|
|
|
|
if (!prop->arraydimension) {
|
|
|
|
fprintf(f, "bool %sget(PointerRNA *ptr);\n", func);
|
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, bool value);\n", func);
|
|
|
|
}
|
|
|
|
else if (prop->arraydimension && prop->totarraylength) {
|
|
|
|
fprintf(f, "void %sget(PointerRNA *ptr, bool values[%u]);\n", func, prop->totarraylength);
|
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, const bool values[%u]);\n", func, prop->totarraylength);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(f, "void %sget(PointerRNA *ptr, bool values[]);\n", func);
|
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, const bool values[]);\n", func);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_INT:
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension) {
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->arraydimension && prop->totarraylength) {
|
2011-08-27 03:25:02 +00:00
|
|
|
fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength);
|
2013-10-14 08:23:57 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, const int values[%u]);\n", func, prop->totarraylength);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2011-05-18 12:56:58 +00:00
|
|
|
else {
|
|
|
|
fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func);
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func);
|
2011-05-18 12:56:58 +00:00
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension) {
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "float %sget(PointerRNA *ptr);\n", func);
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->arraydimension && prop->totarraylength) {
|
2011-08-27 03:25:02 +00:00
|
|
|
fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength);
|
2013-10-14 08:23:57 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, const float values[%u]);\n", func, prop->totarraylength);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2011-05-18 12:56:58 +00:00
|
|
|
else {
|
|
|
|
fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func);
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);", func);
|
2011-05-18 12:56:58 +00:00
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
int i;
|
|
|
|
|
2015-01-14 05:10:18 +11:00
|
|
|
if (eprop->item && eprop->totitem) {
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "enum {\n");
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
for (i = 0; i < eprop->totitem; i++)
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->item[i].identifier[0])
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier,
|
|
|
|
eprop->item[i].identifier, eprop->item[i].value);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "};\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "int %sget(PointerRNA *ptr);\n", func);
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
|
2009-02-03 10:14:29 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (sprop->maxlength) {
|
2009-02-03 10:14:29 +00:00
|
|
|
fprintf(f, "#define %s_%s_MAX %d\n\n", srna->identifier, prop->identifier, sprop->maxlength);
|
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func);
|
|
|
|
fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "PointerRNA %sget(PointerRNA *ptr);\n", func);
|
2012-03-05 23:30:41 +00:00
|
|
|
/*fprintf(f, "void %sset(PointerRNA *ptr, PointerRNA value);\n", func); */
|
2009-02-02 19:57:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2012-10-25 15:42:36 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func);
|
|
|
|
fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func);
|
|
|
|
fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func);
|
2012-10-25 15:42:36 +00:00
|
|
|
if (cprop->length)
|
|
|
|
fprintf(f, "int %slength(PointerRNA *ptr);\n", func);
|
|
|
|
if (cprop->lookupint)
|
|
|
|
fprintf(f, "int %slookup_int(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n", func);
|
|
|
|
if (cprop->lookupstring)
|
|
|
|
fprintf(f, "int %slookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n", func);
|
2009-02-02 19:57:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
if (prop->getlength) {
|
|
|
|
char funcname[2048];
|
|
|
|
rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, prop->identifier, "get_length");
|
|
|
|
fprintf(f, "int %s(PointerRNA *ptr, int *arraylen);\n", funcname);
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
static void rna_def_function_funcs_header(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
|
|
|
|
{
|
|
|
|
FunctionRNA *func = dfunc->func;
|
|
|
|
char funcname[2048];
|
|
|
|
|
|
|
|
rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL);
|
|
|
|
rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 1);
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
|
2009-03-14 23:17:55 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = dp->prop;
|
2009-03-14 23:17:55 +00:00
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
|
2009-03-14 23:17:55 +00:00
|
|
|
return;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2013-06-23 13:59:06 +00:00
|
|
|
/* disabled for now to avoid msvc compiler error due to large file size */
|
|
|
|
#if 0
|
2012-03-05 23:30:41 +00:00
|
|
|
if (prop->name && prop->description && prop->description[0] != '\0')
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "\t/* %s: %s */\n", prop->name, prop->description);
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->name)
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "\t/* %s */\n", prop->name);
|
|
|
|
else
|
|
|
|
fprintf(f, "\t/* */\n");
|
2013-06-23 13:59:06 +00:00
|
|
|
#endif
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
{
|
2012-10-22 17:34:16 +00:00
|
|
|
if (!prop->arraydimension) {
|
|
|
|
fprintf(f, "\tinline bool %s(void);\n", rna_safe_id(prop->identifier));
|
2018-07-01 15:47:09 +02:00
|
|
|
fprintf(f, "\tinline void %s(bool value);", rna_safe_id(prop->identifier));
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
|
|
|
else if (prop->totarraylength) {
|
2018-07-01 15:47:09 +02:00
|
|
|
fprintf(f, "\tinline Array<bool, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(bool values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength);
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
|
|
|
else if (prop->getlength) {
|
2018-07-01 15:47:09 +02:00
|
|
|
fprintf(f, "\tinline DynamicArray<bool> %s(void);\n", rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(bool values[]);", rna_safe_id(prop->identifier));
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_INT:
|
|
|
|
{
|
2012-10-22 17:34:16 +00:00
|
|
|
if (!prop->arraydimension) {
|
|
|
|
fprintf(f, "\tinline int %s(void);\n", rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier));
|
|
|
|
}
|
|
|
|
else if (prop->totarraylength) {
|
|
|
|
fprintf(f, "\tinline Array<int, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(int values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength);
|
|
|
|
}
|
|
|
|
else if (prop->getlength) {
|
|
|
|
fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier));
|
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
2012-10-22 17:34:16 +00:00
|
|
|
if (!prop->arraydimension) {
|
|
|
|
fprintf(f, "\tinline float %s(void);\n", rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(float value);", rna_safe_id(prop->identifier));
|
|
|
|
}
|
|
|
|
else if (prop->totarraylength) {
|
|
|
|
fprintf(f, "\tinline Array<float, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(float values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength);
|
|
|
|
}
|
|
|
|
else if (prop->getlength) {
|
|
|
|
fprintf(f, "\tinline DynamicArray<float> %s(void);\n", rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(float values[]);", rna_safe_id(prop->identifier));
|
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
|
2009-03-14 23:17:55 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->item) {
|
2011-05-18 12:56:58 +00:00
|
|
|
fprintf(f, "\tenum %s_enum {\n", rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
for (i = 0; i < eprop->totitem; i++)
|
2012-03-05 23:30:41 +00:00
|
|
|
if (eprop->item[i].identifier[0])
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\t\t%s_%s = %d,\n", rna_safe_id(prop->identifier), eprop->item[i].identifier,
|
|
|
|
eprop->item[i].value);
|
2009-03-14 23:17:55 +00:00
|
|
|
|
|
|
|
fprintf(f, "\t};\n");
|
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "\tinline %s_enum %s(void);\n", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier));
|
|
|
|
fprintf(f, "\tinline void %s(%s_enum value);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2015-10-27 22:11:14 +01:00
|
|
|
fprintf(f, "\tinline std::string %s(void);\n", rna_safe_id(prop->identifier));
|
2012-11-03 14:31:55 +00:00
|
|
|
fprintf(f, "\tinline void %s(const std::string& value);", rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (pprop->type)
|
2012-05-12 11:01:29 +00:00
|
|
|
fprintf(f, "\tinline %s %s(void);", (const char *)pprop->type, rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
else
|
2011-05-18 12:56:58 +00:00
|
|
|
fprintf(f, "\tinline %s %s(void);", "UnknownType", rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
|
2012-11-03 15:35:43 +00:00
|
|
|
const char *collection_funcs = "DefaultCollectionFunctions";
|
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (!(dp->prop->flag & PROP_IDPROPERTY || dp->prop->flag_internal & PROP_INTERN_BUILTIN) && cprop->property.srna) {
|
2012-12-28 14:19:05 +00:00
|
|
|
collection_funcs = (char *)cprop->property.srna;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (cprop->item_type)
|
2012-11-03 15:35:43 +00:00
|
|
|
fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, (const char *)cprop->item_type, srna->identifier,
|
2014-04-01 11:34:00 +11:00
|
|
|
rna_safe_id(prop->identifier), (cprop->length ? "true" : "false"),
|
|
|
|
(cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
|
2009-03-14 23:17:55 +00:00
|
|
|
else
|
2012-11-03 15:35:43 +00:00
|
|
|
fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s, %s)", collection_funcs, "UnknownType", srna->identifier,
|
2014-04-01 11:34:00 +11:00
|
|
|
rna_safe_id(prop->identifier), (cprop->length ? "true" : "false"),
|
|
|
|
(cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
static const char *rna_parameter_type_cpp_name(PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
if (prop->type == PROP_POINTER) {
|
|
|
|
/* for cpp api we need to use RNA structures names for pointers */
|
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *) prop;
|
|
|
|
|
|
|
|
return (const char *) pprop->type;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return rna_parameter_type_name(prop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-17 05:16:48 +00:00
|
|
|
static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *UNUSED(srna), FunctionDefRNA *dfunc,
|
2012-10-22 17:34:16 +00:00
|
|
|
const char *namespace, int close_prototype)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
FunctionRNA *func = dfunc->func;
|
|
|
|
|
|
|
|
int first = 1;
|
|
|
|
const char *retval_type = "void";
|
|
|
|
|
|
|
|
if (func->c_ret) {
|
|
|
|
dp = rna_find_parameter_def(func->c_ret);
|
|
|
|
retval_type = rna_parameter_type_cpp_name(dp->prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (namespace && namespace[0])
|
|
|
|
fprintf(f, "\tinline %s %s::%s(", retval_type, namespace, rna_safe_id(func->identifier));
|
|
|
|
else
|
|
|
|
fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier));
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_MAIN)
|
|
|
|
WRITE_PARAM("void *main");
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_CONTEXT)
|
|
|
|
WRITE_PARAM("Context C");
|
|
|
|
|
|
|
|
for (dp = dfunc->cont.properties.first; dp; dp = dp->next) {
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
int type, flag, flag_parameter, pout;
|
2012-10-22 17:34:16 +00:00
|
|
|
const char *ptrstr;
|
|
|
|
|
|
|
|
if (dp->prop == func->c_ret)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
type = dp->prop->type;
|
|
|
|
flag = dp->prop->flag;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
flag_parameter = dp->prop->flag_parameter;
|
|
|
|
pout = (flag_parameter & PARM_OUTPUT);
|
2012-10-22 17:34:16 +00:00
|
|
|
|
2013-06-14 14:57:35 +00:00
|
|
|
if (flag & PROP_DYNAMIC)
|
|
|
|
ptrstr = pout ? "**" : "*";
|
|
|
|
else if (type == PROP_POINTER)
|
2014-01-12 22:27:55 +11:00
|
|
|
ptrstr = pout ? "*" : "";
|
2013-04-24 19:21:18 +00:00
|
|
|
else if (dp->prop->arraydimension)
|
2012-10-22 17:34:16 +00:00
|
|
|
ptrstr = "*";
|
|
|
|
else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
|
|
|
|
ptrstr = "";
|
|
|
|
else
|
|
|
|
ptrstr = pout ? "*" : "";
|
|
|
|
|
|
|
|
WRITE_COMMA;
|
|
|
|
|
|
|
|
if (flag & PROP_DYNAMIC)
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
fprintf(f, "int %s%s_len, ", (flag_parameter & PARM_OUTPUT) ? "*" : "", dp->prop->identifier);
|
2012-10-22 17:34:16 +00:00
|
|
|
|
|
|
|
if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension)
|
|
|
|
fprintf(f, "%s %s[%u]", rna_parameter_type_cpp_name(dp->prop),
|
|
|
|
rna_safe_id(dp->prop->identifier), dp->prop->totarraylength);
|
2015-11-28 21:20:30 +05:00
|
|
|
else {
|
|
|
|
fprintf(f, "%s%s%s%s",
|
|
|
|
rna_parameter_type_cpp_name(dp->prop),
|
|
|
|
(dp->prop->type == PROP_POINTER && ptrstr[0] == '\0') ? "& " : " ",
|
|
|
|
ptrstr,
|
|
|
|
rna_safe_id(dp->prop->identifier));
|
|
|
|
}
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, ")");
|
|
|
|
if (close_prototype)
|
|
|
|
fprintf(f, ";\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
|
|
|
|
{
|
2013-06-23 13:59:06 +00:00
|
|
|
if (dfunc->call) {
|
|
|
|
/* disabled for now to avoid msvc compiler error due to large file size */
|
|
|
|
#if 0
|
|
|
|
FunctionRNA *func = dfunc->func;
|
|
|
|
fprintf(f, "\n\t/* %s */\n", func->description);
|
|
|
|
#endif
|
2012-10-22 17:34:16 +00:00
|
|
|
|
2013-06-23 13:59:06 +00:00
|
|
|
rna_def_struct_function_prototype_cpp(f, srna, dfunc, NULL, 1);
|
|
|
|
}
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
|
2009-03-14 23:17:55 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = dp->prop;
|
2009-03-14 23:17:55 +00:00
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN) {
|
2009-03-14 23:17:55 +00:00
|
|
|
return;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension)
|
2011-05-18 12:56:58 +00:00
|
|
|
fprintf(f, "\tBOOLEAN_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->totarraylength)
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength,
|
|
|
|
rna_safe_id(prop->identifier));
|
2012-10-22 17:34:16 +00:00
|
|
|
else if (prop->getlength)
|
|
|
|
fprintf(f, "\tBOOLEAN_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier,
|
|
|
|
rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_INT:
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension)
|
2011-05-18 12:56:58 +00:00
|
|
|
fprintf(f, "\tINT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->totarraylength)
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength,
|
|
|
|
rna_safe_id(prop->identifier));
|
2012-10-22 17:34:16 +00:00
|
|
|
else if (prop->getlength)
|
|
|
|
fprintf(f, "\tINT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier,
|
|
|
|
rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!prop->arraydimension)
|
2011-05-18 12:56:58 +00:00
|
|
|
fprintf(f, "\tFLOAT_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (prop->totarraylength)
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength,
|
|
|
|
rna_safe_id(prop->identifier));
|
2012-10-22 17:34:16 +00:00
|
|
|
else if (prop->getlength)
|
|
|
|
fprintf(f, "\tFLOAT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier,
|
|
|
|
rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\tENUM_PROPERTY(%s_enum, %s, %s)", rna_safe_id(prop->identifier), srna->identifier,
|
|
|
|
rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2011-05-18 12:56:58 +00:00
|
|
|
fprintf(f, "\tSTRING_PROPERTY(%s, %s)", srna->identifier, rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (pprop->type)
|
2012-05-12 11:01:29 +00:00
|
|
|
fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", (const char *)pprop->type, srna->identifier,
|
2012-03-18 09:27:36 +00:00
|
|
|
rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
else
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\tPOINTER_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier,
|
|
|
|
rna_safe_id(prop->identifier));
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2012-03-09 18:28:30 +00:00
|
|
|
#if 0
|
2012-05-12 11:01:29 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
if (cprop->type)
|
2012-10-25 15:42:36 +00:00
|
|
|
fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->type, srna->identifier,
|
2014-04-01 11:34:00 +11:00
|
|
|
prop->identifier, (cprop->length ? "true" : "false"),
|
|
|
|
(cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
|
2009-03-14 23:17:55 +00:00
|
|
|
else
|
2012-10-25 15:42:36 +00:00
|
|
|
fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", srna->identifier,
|
2014-04-01 11:34:00 +11:00
|
|
|
prop->identifier, (cprop->length ? "true" : "false"),
|
|
|
|
(cprop->lookupint ? "true" : "false"), (cprop->lookupstring ? "true" : "false"));
|
2012-03-09 18:28:30 +00:00
|
|
|
#endif
|
2009-03-14 23:17:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
StructDefRNA *dsrna;
|
|
|
|
FunctionRNA *func = dfunc->func;
|
|
|
|
char funcname[2048];
|
|
|
|
|
|
|
|
int first = 1;
|
|
|
|
|
|
|
|
rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL);
|
|
|
|
|
|
|
|
fprintf(f, "%s(", funcname);
|
|
|
|
|
|
|
|
dsrna = rna_find_struct_def(srna);
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_SELF_ID)
|
|
|
|
WRITE_PARAM("(::ID *) ptr.id.data");
|
|
|
|
|
|
|
|
if ((func->flag & FUNC_NO_SELF) == 0) {
|
|
|
|
WRITE_COMMA;
|
2015-03-27 18:44:11 +05:00
|
|
|
if (dsrna->dnafromprop) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnafromname);
|
|
|
|
else if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
|
2012-10-22 17:34:16 +00:00
|
|
|
else fprintf(f, "(::%s *) this->ptr.data", srna->identifier);
|
|
|
|
}
|
2012-12-20 09:33:12 +00:00
|
|
|
else if (func->flag & FUNC_USE_SELF_TYPE) {
|
|
|
|
WRITE_COMMA;
|
|
|
|
fprintf(f, "this->ptr.type");
|
|
|
|
}
|
2012-10-22 17:34:16 +00:00
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_MAIN)
|
|
|
|
WRITE_PARAM("(::Main *) main");
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_CONTEXT)
|
|
|
|
WRITE_PARAM("(::bContext *) C.ptr.data");
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_REPORTS)
|
2012-11-02 13:36:20 +00:00
|
|
|
WRITE_PARAM("NULL");
|
2012-10-22 17:34:16 +00:00
|
|
|
|
|
|
|
dp = dfunc->cont.properties.first;
|
|
|
|
for (; dp; dp = dp->next) {
|
|
|
|
if (dp->prop == func->c_ret)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
WRITE_COMMA;
|
|
|
|
|
|
|
|
if (dp->prop->flag & PROP_DYNAMIC)
|
|
|
|
fprintf(f, "%s_len, ", dp->prop->identifier);
|
|
|
|
|
|
|
|
if (dp->prop->type == PROP_POINTER)
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if ((dp->prop->flag_parameter & PARM_RNAPTR) && !(dp->prop->flag & PROP_THICK_WRAP))
|
2012-11-02 10:37:33 +00:00
|
|
|
fprintf(f, "(::%s *) &%s.ptr", rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier));
|
2018-05-21 12:34:11 +02:00
|
|
|
else if (dp->prop->flag_parameter & PARM_OUTPUT) {
|
|
|
|
if (dp->prop->flag_parameter & PARM_RNAPTR) {
|
|
|
|
fprintf(f, "&%s->ptr",
|
|
|
|
rna_safe_id(dp->prop->identifier));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(f, "(::%s **) &%s->ptr.data",
|
|
|
|
rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier));
|
|
|
|
}
|
|
|
|
}
|
2012-11-02 10:37:33 +00:00
|
|
|
else
|
|
|
|
fprintf(f, "(::%s *) %s.ptr.data", rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier));
|
2012-10-22 17:34:16 +00:00
|
|
|
else
|
|
|
|
fprintf(f, "%s", rna_safe_id(dp->prop->identifier));
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, ");\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc)
|
|
|
|
{
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
PointerPropertyRNA *pprop;
|
|
|
|
|
|
|
|
FunctionRNA *func = dfunc->func;
|
|
|
|
|
|
|
|
if (!dfunc->call)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rna_def_struct_function_prototype_cpp(f, srna, dfunc, srna->identifier, 0);
|
|
|
|
|
|
|
|
fprintf(f, " {\n");
|
|
|
|
|
|
|
|
if (func->c_ret) {
|
|
|
|
dp = rna_find_parameter_def(func->c_ret);
|
|
|
|
|
|
|
|
if (dp->prop->type == PROP_POINTER) {
|
|
|
|
pprop = (PointerPropertyRNA *) dp->prop;
|
|
|
|
|
2012-11-03 14:31:55 +00:00
|
|
|
fprintf(f, "\t\tPointerRNA result;\n");
|
2012-10-22 17:34:16 +00:00
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if ((dp->prop->flag_parameter & PARM_RNAPTR) == 0) {
|
2012-10-22 17:34:16 +00:00
|
|
|
StructRNA *ret_srna = rna_find_struct((const char *) pprop->type);
|
|
|
|
fprintf(f, "\t\t::%s *retdata = ", rna_parameter_type_name(dp->prop));
|
|
|
|
rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
|
|
|
|
if (ret_srna->flag & STRUCT_ID)
|
2012-11-03 14:31:55 +00:00
|
|
|
fprintf(f, "\t\tRNA_id_pointer_create((::ID *) retdata, &result);\n");
|
2012-10-22 17:34:16 +00:00
|
|
|
else
|
2012-11-03 14:31:55 +00:00
|
|
|
fprintf(f, "\t\tRNA_pointer_create((::ID *) ptr.id.data, &RNA_%s, retdata, &result);\n", (const char *) pprop->type);
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-11-03 14:31:55 +00:00
|
|
|
fprintf(f, "\t\tresult = ");
|
2012-10-22 17:34:16 +00:00
|
|
|
rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
|
|
|
|
}
|
|
|
|
|
2012-11-03 14:31:55 +00:00
|
|
|
fprintf(f, "\t\treturn %s(result);\n", (const char *) pprop->type);
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(f, "\t\treturn ");
|
|
|
|
rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(f, "\t\t");
|
|
|
|
rna_def_struct_function_call_impl_cpp(f, srna, dfunc);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "\t}\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_property_wrapper_funcs(FILE *f, StructDefRNA *dsrna, PropertyDefRNA *dp)
|
|
|
|
{
|
|
|
|
if (dp->prop->getlength) {
|
|
|
|
char funcname[2048];
|
|
|
|
rna_construct_wrapper_function_name(funcname, sizeof(funcname), dsrna->srna->identifier, dp->prop->identifier, "get_length");
|
|
|
|
fprintf(f, "int %s(PointerRNA *ptr, int *arraylen)\n", funcname);
|
|
|
|
fprintf(f, "{\n");
|
|
|
|
fprintf(f, "\treturn %s(ptr, arraylen);\n", rna_function_string(dp->prop->getlength));
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
|
|
|
|
{
|
|
|
|
StructRNA *srna = dsrna->srna;
|
|
|
|
FunctionRNA *func = dfunc->func;
|
|
|
|
PropertyDefRNA *dparm;
|
|
|
|
|
|
|
|
int first;
|
|
|
|
char funcname[2048];
|
|
|
|
|
|
|
|
if (!dfunc->call)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL);
|
|
|
|
|
|
|
|
rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 0);
|
|
|
|
|
|
|
|
fprintf(f, "\n{\n");
|
|
|
|
|
|
|
|
if (func->c_ret)
|
|
|
|
fprintf(f, "\treturn %s(", dfunc->call);
|
|
|
|
else
|
|
|
|
fprintf(f, "\t%s(", dfunc->call);
|
|
|
|
|
|
|
|
first = 1;
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_SELF_ID)
|
|
|
|
WRITE_PARAM("_selfid");
|
|
|
|
|
2012-12-20 09:33:12 +00:00
|
|
|
if ((func->flag & FUNC_NO_SELF) == 0) {
|
2012-10-22 17:34:16 +00:00
|
|
|
WRITE_PARAM("_self");
|
2012-12-20 09:33:12 +00:00
|
|
|
}
|
|
|
|
else if (func->flag & FUNC_USE_SELF_TYPE) {
|
|
|
|
WRITE_PARAM("_type");
|
|
|
|
}
|
2012-10-22 17:34:16 +00:00
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_MAIN)
|
|
|
|
WRITE_PARAM("bmain");
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_CONTEXT)
|
|
|
|
WRITE_PARAM("C");
|
|
|
|
|
|
|
|
if (func->flag & FUNC_USE_REPORTS)
|
|
|
|
WRITE_PARAM("reports");
|
|
|
|
|
|
|
|
dparm = dfunc->cont.properties.first;
|
|
|
|
for (; dparm; dparm = dparm->next) {
|
|
|
|
if (dparm->prop == func->c_ret)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
WRITE_COMMA;
|
|
|
|
|
|
|
|
if (dparm->prop->flag & PROP_DYNAMIC)
|
|
|
|
fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier);
|
|
|
|
else
|
|
|
|
fprintf(f, "%s", rna_safe_id(dparm->prop->identifier));
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, ");\n");
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
}
|
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
FunctionRNA *func;
|
|
|
|
PropertyDefRNA *dparm;
|
2010-01-24 10:51:59 +00:00
|
|
|
PropertyType type;
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *funcname, *valstr;
|
|
|
|
const char *ptrstr;
|
2014-04-11 11:25:41 +10:00
|
|
|
const bool has_data = (dfunc->cont.properties.first != NULL);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
int flag, flag_parameter, pout, cptr, first;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = dsrna->srna;
|
|
|
|
func = dfunc->func;
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!dfunc->call)
|
2009-04-19 13:37:59 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
funcname = rna_alloc_function_name(srna->identifier, func->identifier, "call");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* function definition */
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "void %s(bContext *C, ReportList *reports, PointerRNA *_ptr, ParameterList *_parms)", funcname);
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "\n{\n");
|
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* variable definitions */
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_SELF_ID) {
|
2010-09-03 14:53:54 +00:00
|
|
|
fprintf(f, "\tstruct ID *_selfid;\n");
|
|
|
|
}
|
2010-01-22 10:58:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((func->flag & FUNC_NO_SELF) == 0) {
|
2015-03-27 18:44:11 +05:00
|
|
|
if (dsrna->dnafromprop) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnafromname);
|
|
|
|
else if (dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "\tstruct %s *_self;\n", srna->identifier);
|
|
|
|
}
|
2012-12-20 09:33:12 +00:00
|
|
|
else if (func->flag & FUNC_USE_SELF_TYPE) {
|
|
|
|
fprintf(f, "\tstruct StructRNA *_type;\n");
|
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dparm = dfunc->cont.properties.first;
|
|
|
|
for (; dparm; dparm = dparm->next) {
|
2010-01-24 10:51:59 +00:00
|
|
|
type = dparm->prop->type;
|
|
|
|
flag = dparm->prop->flag;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
flag_parameter = dparm->prop->flag_parameter;
|
|
|
|
pout = (flag_parameter & PARM_OUTPUT);
|
|
|
|
cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
|
2010-01-24 10:51:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dparm->prop == func->c_ret)
|
|
|
|
ptrstr = cptr || dparm->prop->arraydimension ? "*" : "";
|
2010-01-24 10:51:59 +00:00
|
|
|
/* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
|
|
|
|
else if (cptr || (flag & PROP_DYNAMIC))
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = pout ? "**" : "*";
|
2010-01-24 10:51:59 +00:00
|
|
|
/* fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack, pass a pointer to it */
|
|
|
|
else if (type == PROP_POINTER || dparm->prop->arraydimension)
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "*";
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
else if ((type == PROP_POINTER) && (flag_parameter & PARM_RNAPTR) && !(flag & PROP_THICK_WRAP))
|
2012-11-01 15:56:42 +00:00
|
|
|
ptrstr = "*";
|
2012-03-18 09:27:36 +00:00
|
|
|
/* PROP_THICK_WRAP strings are pre-allocated on the ParameterList stack,
|
2013-07-29 04:18:01 +00:00
|
|
|
* but type name for string props is already (char *), so leave empty */
|
2010-01-24 10:51:59 +00:00
|
|
|
else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "";
|
2010-01-24 10:51:59 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = pout ? "*" : "";
|
2010-01-02 10:42:38 +00:00
|
|
|
|
2010-01-24 10:51:59 +00:00
|
|
|
/* for dynamic parameters we pass an additional int for the length of the parameter */
|
|
|
|
if (flag & PROP_DYNAMIC)
|
|
|
|
fprintf(f, "\tint %s%s_len;\n", pout ? "*" : "", dparm->prop->identifier);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "\t%s%s %s%s;\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
|
|
|
|
ptrstr, dparm->prop->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (has_data) {
|
2011-01-09 01:17:56 +00:00
|
|
|
fprintf(f, "\tchar *_data");
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->c_ret) fprintf(f, ", *_retdata");
|
2011-01-09 01:17:56 +00:00
|
|
|
fprintf(f, ";\n");
|
|
|
|
fprintf(f, "\t\n");
|
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* assign self */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_SELF_ID) {
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, "\t_selfid = (struct ID *)_ptr->id.data;\n");
|
2010-09-03 14:53:54 +00:00
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((func->flag & FUNC_NO_SELF) == 0) {
|
2015-03-27 18:44:11 +05:00
|
|
|
if (dsrna->dnafromprop) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnafromname);
|
|
|
|
else if (dsrna->dnaname) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
|
2013-07-29 04:18:01 +00:00
|
|
|
else fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", srna->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
2012-12-20 09:33:12 +00:00
|
|
|
else if (func->flag & FUNC_USE_SELF_TYPE) {
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, "\t_type = _ptr->type;\n");
|
2012-12-20 09:33:12 +00:00
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (has_data) {
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, "\t_data = (char *)_parms->data;\n");
|
2011-01-09 01:17:56 +00:00
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dparm = dfunc->cont.properties.first;
|
|
|
|
for (; dparm; dparm = dparm->next) {
|
2010-01-24 10:51:59 +00:00
|
|
|
type = dparm->prop->type;
|
|
|
|
flag = dparm->prop->flag;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
flag_parameter = dparm->prop->flag_parameter;
|
|
|
|
pout = (flag_parameter & PARM_OUTPUT);
|
|
|
|
cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
|
2010-01-02 10:42:38 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dparm->prop == func->c_ret)
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, "\t_retdata = _data;\n");
|
2012-04-21 12:51:47 +00:00
|
|
|
else {
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *data_str;
|
2010-01-24 10:51:59 +00:00
|
|
|
if (cptr || (flag & PROP_DYNAMIC)) {
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "**";
|
|
|
|
valstr = "*";
|
2010-01-24 10:51:59 +00:00
|
|
|
}
|
2012-11-01 15:56:42 +00:00
|
|
|
else if ((type == PROP_POINTER) && !(flag & PROP_THICK_WRAP)) {
|
|
|
|
ptrstr = "**";
|
|
|
|
valstr = "*";
|
|
|
|
}
|
2010-01-24 10:51:59 +00:00
|
|
|
else if (type == PROP_POINTER || dparm->prop->arraydimension) {
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "*";
|
|
|
|
valstr = "";
|
2010-01-24 10:51:59 +00:00
|
|
|
}
|
|
|
|
else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) {
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "";
|
|
|
|
valstr = "";
|
2010-01-24 10:51:59 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "*";
|
|
|
|
valstr = "*";
|
2010-01-24 10:51:59 +00:00
|
|
|
}
|
|
|
|
|
2013-08-26 16:08:03 +00:00
|
|
|
/* this must be kept in sync with RNA_parameter_dynamic_length_get_data and RNA_parameter_get,
|
2012-03-18 09:27:36 +00:00
|
|
|
* we could just call the function directly, but this is faster */
|
2010-08-31 11:31:21 +00:00
|
|
|
if (flag & PROP_DYNAMIC) {
|
2013-08-26 16:08:03 +00:00
|
|
|
fprintf(f, "\t%s_len = %s((ParameterDynAlloc *)_data)->array_tot;\n", dparm->prop->identifier,
|
|
|
|
pout ? "(int *)&" : "(int)");
|
|
|
|
data_str = "(&(((ParameterDynAlloc *)_data)->array))";
|
2010-08-31 11:31:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
data_str = "_data";
|
2010-08-31 11:31:21 +00:00
|
|
|
}
|
2012-05-27 19:40:36 +00:00
|
|
|
fprintf(f, "\t%s = ", dparm->prop->identifier);
|
2010-01-24 10:51:59 +00:00
|
|
|
|
|
|
|
if (!pout)
|
|
|
|
fprintf(f, "%s", valstr);
|
|
|
|
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, "((%s%s %s)%s);\n", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
|
2012-03-18 09:27:36 +00:00
|
|
|
ptrstr, data_str);
|
2010-01-08 13:52:38 +00:00
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dparm->next)
|
2013-08-11 15:49:27 +00:00
|
|
|
fprintf(f, "\t_data += %d;\n", rna_parameter_size(dparm->prop));
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dfunc->call) {
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "\t\n");
|
|
|
|
fprintf(f, "\t");
|
2012-05-27 19:40:36 +00:00
|
|
|
if (func->c_ret) fprintf(f, "%s = ", func->c_ret->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "%s(", dfunc->call);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
first = 1;
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_SELF_ID) {
|
2010-09-03 14:53:54 +00:00
|
|
|
fprintf(f, "_selfid");
|
2012-03-05 23:30:41 +00:00
|
|
|
first = 0;
|
2010-09-03 14:53:54 +00:00
|
|
|
}
|
2010-01-22 10:58:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((func->flag & FUNC_NO_SELF) == 0) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "_self");
|
2012-03-05 23:30:41 +00:00
|
|
|
first = 0;
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
2012-12-20 09:33:12 +00:00
|
|
|
else if (func->flag & FUNC_USE_SELF_TYPE) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
fprintf(f, "_type");
|
|
|
|
first = 0;
|
|
|
|
}
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_MAIN) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2011-11-17 18:41:37 +00:00
|
|
|
fprintf(f, "CTX_data_main(C)"); /* may have direct access later */
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_CONTEXT) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "C");
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_REPORTS) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "reports");
|
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dparm = dfunc->cont.properties.first;
|
|
|
|
for (; dparm; dparm = dparm->next) {
|
|
|
|
if (dparm->prop == func->c_ret)
|
2009-04-07 00:49:39 +00:00
|
|
|
continue;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2010-01-24 10:51:59 +00:00
|
|
|
if (dparm->prop->flag & PROP_DYNAMIC)
|
2010-08-31 11:31:21 +00:00
|
|
|
fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier);
|
|
|
|
else
|
|
|
|
fprintf(f, "%s", dparm->prop->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, ");\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->c_ret) {
|
|
|
|
dparm = rna_find_parameter_def(func->c_ret);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
ptrstr = (((dparm->prop->type == PROP_POINTER) && !(dparm->prop->flag_parameter & PARM_RNAPTR)) ||
|
2012-03-18 09:27:36 +00:00
|
|
|
(dparm->prop->arraydimension)) ? "*" : "";
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, "\t*((%s%s %s*)_retdata) = %s;\n", rna_type_struct(dparm->prop),
|
2012-03-18 09:27:36 +00:00
|
|
|
rna_parameter_type_name(dparm->prop), ptrstr, func->c_ret->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dfunc->gencall = funcname;
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2011-02-13 15:02:21 +00:00
|
|
|
static void rna_auto_types(void)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
2009-01-15 04:22:23 +00:00
|
|
|
/* DNA name for Screen is patched in 2.5, we do the reverse here .. */
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
if (ds->dnaname) {
|
|
|
|
if (STREQ(ds->dnaname, "Screen"))
|
|
|
|
ds->dnaname = "bScreen";
|
|
|
|
if (STREQ(ds->dnaname, "Group"))
|
|
|
|
ds->dnaname = "Collection";
|
|
|
|
if (STREQ(ds->dnaname, "GroupObject"))
|
|
|
|
ds->dnaname = "CollectionObject";
|
|
|
|
}
|
2009-01-15 04:22:23 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next) {
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
if (dp->dnastructname) {
|
|
|
|
if (STREQ(dp->dnastructname, "Screen"))
|
|
|
|
dp->dnastructname = "bScreen";
|
|
|
|
if (STREQ(dp->dnastructname, "Group"))
|
|
|
|
dp->dnastructname = "Collection";
|
|
|
|
if (STREQ(dp->dnastructname, "GroupObject"))
|
|
|
|
dp->dnastructname = "CollectionObject";
|
|
|
|
}
|
2009-01-15 04:22:23 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dp->dnatype) {
|
|
|
|
if (dp->prop->type == PROP_POINTER) {
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)dp->prop;
|
2009-05-29 15:12:31 +00:00
|
|
|
StructRNA *type;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!pprop->type && !pprop->get)
|
2012-05-12 11:01:29 +00:00
|
|
|
pprop->type = (StructRNA *)rna_find_type(dp->dnatype);
|
2009-05-29 15:12:31 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (pprop->type) {
|
2012-05-12 11:01:29 +00:00
|
|
|
type = rna_find_struct((const char *)pprop->type);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (type && (type->flag & STRUCT_ID_REFCOUNT))
|
2009-05-29 15:12:31 +00:00
|
|
|
pprop->property.flag |= PROP_ID_REFCOUNT;
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (dp->prop->type == PROP_COLLECTION) {
|
2012-05-12 11:01:29 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (!cprop->item_type && !cprop->get && STREQ(dp->dnatype, "ListBase"))
|
2012-05-12 11:01:29 +00:00
|
|
|
cprop->item_type = (StructRNA *)rna_find_type(dp->dnatype);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-26 22:24:26 +00:00
|
|
|
static void rna_sort(BlenderRNA *brna)
|
|
|
|
{
|
2009-02-02 19:57:57 +00:00
|
|
|
StructDefRNA *ds;
|
2008-11-26 22:24:26 +00:00
|
|
|
StructRNA *srna;
|
|
|
|
|
|
|
|
rna_sortlist(&brna->structs, cmp_struct);
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_sortlist(&DefRNA.structs, cmp_def_struct);
|
2008-11-26 22:24:26 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (srna = brna->structs.first; srna; srna = srna->cont.next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_sortlist(&srna->cont.properties, cmp_property);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_sortlist(&ds->cont.properties, cmp_def_property);
|
2008-11-26 22:24:26 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
static const char *rna_property_structname(PropertyType type)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (type) {
|
2011-12-01 22:08:42 +00:00
|
|
|
case PROP_BOOLEAN: return "BoolPropertyRNA";
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_INT: return "IntPropertyRNA";
|
|
|
|
case PROP_FLOAT: return "FloatPropertyRNA";
|
|
|
|
case PROP_STRING: return "StringPropertyRNA";
|
|
|
|
case PROP_ENUM: return "EnumPropertyRNA";
|
|
|
|
case PROP_POINTER: return "PointerPropertyRNA";
|
|
|
|
case PROP_COLLECTION: return "CollectionPropertyRNA";
|
|
|
|
default: return "UnknownPropertyRNA";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-17 15:47:00 +00:00
|
|
|
static const char *rna_property_subtypename(PropertySubType type)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (type) {
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_NONE: return "PROP_NONE";
|
|
|
|
case PROP_FILEPATH: return "PROP_FILEPATH";
|
2010-02-28 11:17:55 +00:00
|
|
|
case PROP_FILENAME: return "PROP_FILENAME";
|
2008-12-15 10:48:04 +00:00
|
|
|
case PROP_DIRPATH: return "PROP_DIRPATH";
|
2013-12-13 04:39:15 +11:00
|
|
|
case PROP_PIXEL: return "PROP_PIXEL";
|
2011-11-15 07:09:41 +00:00
|
|
|
case PROP_BYTESTRING: return "PROP_BYTESTRING";
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
case PROP_UNSIGNED: return "PROP_UNSIGNED";
|
|
|
|
case PROP_PERCENTAGE: return "PROP_PERCENTAGE";
|
2009-09-21 21:19:58 +00:00
|
|
|
case PROP_FACTOR: return "PROP_FACTOR";
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
case PROP_ANGLE: return "PROP_ANGLE";
|
|
|
|
case PROP_TIME: return "PROP_TIME";
|
|
|
|
case PROP_DISTANCE: return "PROP_DISTANCE";
|
2013-03-13 17:16:49 +00:00
|
|
|
case PROP_DISTANCE_CAMERA: return "PROP_DISTANCE_CAMERA";
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_COLOR: return "PROP_COLOR";
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
case PROP_TRANSLATION: return "PROP_TRANSLATION";
|
|
|
|
case PROP_DIRECTION: return "PROP_DIRECTION";
|
2008-10-31 23:50:02 +00:00
|
|
|
case PROP_MATRIX: return "PROP_MATRIX";
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
case PROP_EULER: return "PROP_EULER";
|
|
|
|
case PROP_QUATERNION: return "PROP_QUATERNION";
|
2009-09-28 10:19:20 +00:00
|
|
|
case PROP_AXISANGLE: return "PROP_AXISANGLE";
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
case PROP_VELOCITY: return "PROP_VELOCITY";
|
|
|
|
case PROP_ACCELERATION: return "PROP_ACCELERATION";
|
|
|
|
case PROP_XYZ: return "PROP_XYZ";
|
Changes to Color Management
After testing and feedback, I've decided to slightly modify the way color
management works internally. While the previous method worked well for
rendering, was a smaller transition and had some advantages over this
new method, it was a bit more ambiguous, and was making things difficult
for other areas such as compositing.
This implementation now considers all color data (with only a couple of
exceptions such as brush colors) to be stored in linear RGB color space,
rather than sRGB as previously. This brings it in line with Nuke, which also
operates this way, quite successfully. Color swatches, pickers, color ramp
display are now gamma corrected to display gamma so you can see what
you're doing, but the numbers themselves are considered linear. This
makes understanding blending modes more clear (a 0.5 value on overlay
will not change the result now) as well as making color swatches act more
predictably in the compositor, however bringing over color values from
applications like photoshop or gimp, that operate in a gamma space,
will give identical results.
This commit will convert over existing files saved by earlier 2.5 versions to
work generally the same, though there may be some slight differences with
things like textures. Now that we're set on changing other areas of shading,
this won't be too disruptive overall.
I've made a diagram explaining the pipeline here:
http://mke3.net/blender/devel/2.5/25_linear_workflow_pipeline.png
and some docs here:
http://www.blender.org/development/release-logs/blender-250/color-management/
2009-12-02 07:56:34 +00:00
|
|
|
case PROP_COLOR_GAMMA: return "PROP_COLOR_GAMMA";
|
2011-04-08 13:32:56 +00:00
|
|
|
case PROP_COORDS: return "PROP_COORDS";
|
2009-09-09 17:39:19 +00:00
|
|
|
case PROP_LAYER: return "PROP_LAYER";
|
|
|
|
case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER";
|
* New string property subtype: PASSWORD
When this new subtypes is used, then string of property is hidden using
asterisks, e.g.: mysecretpassword -> ****************
This code was reviewed and modified by Brecht. Thanks very much:
- https://codereview.appspot.com/6713044/
This new subtype of string property is intended mostly for Add-on developers
writing Add-on which communicates with some server (http, sql, ftp, verse,
etc.). When this server requires user authentication and user has to type
username and password, then current API didn't allow to type 'hidden' password,
e.g. when you want to demonstrate this script, then everybody can see this
security password. Some examples of Add-on which could use this new subtype:
- On-line database of textures
- Integration of render farm
- Integration of Verse
Security Notes:
- You can copy paste hiddent string of property from text input using (Ctrl-C, Ctrl-V),
but you can do this in other GUI toolkits too (this behavior it is widely used).
- Text of string property is stored in plain text, but it is widely used in other
GUI toolkits (Qt, Gtk, etc.).
Simple examples:
- https://dl.dropbox.com/u/369894/draw_op_passwd.py
- https://dl.dropbox.com/u/369894/blender-password.png
2012-10-26 12:58:54 +00:00
|
|
|
case PROP_PASSWORD: return "PROP_PASSWORD";
|
2019-02-08 12:31:28 +01:00
|
|
|
case PROP_POWER: return "PROP_POWER";
|
2013-01-15 23:45:41 +00:00
|
|
|
default:
|
|
|
|
{
|
2012-03-18 07:38:51 +00:00
|
|
|
/* in case we don't have a type preset that includes the subtype */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (RNA_SUBTYPE_UNIT(type)) {
|
2009-08-11 11:50:40 +00:00
|
|
|
return rna_property_subtypename(type & ~RNA_SUBTYPE_UNIT(type));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "PROP_SUBTYPE_UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-04 17:01:33 +00:00
|
|
|
static const char *rna_property_subtype_unit(PropertySubType type)
|
2009-08-11 11:50:40 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (RNA_SUBTYPE_UNIT(type)) {
|
2012-05-12 11:01:29 +00:00
|
|
|
case PROP_UNIT_NONE: return "PROP_UNIT_NONE";
|
|
|
|
case PROP_UNIT_LENGTH: return "PROP_UNIT_LENGTH";
|
|
|
|
case PROP_UNIT_AREA: return "PROP_UNIT_AREA";
|
|
|
|
case PROP_UNIT_VOLUME: return "PROP_UNIT_VOLUME";
|
|
|
|
case PROP_UNIT_MASS: return "PROP_UNIT_MASS";
|
|
|
|
case PROP_UNIT_ROTATION: return "PROP_UNIT_ROTATION";
|
|
|
|
case PROP_UNIT_TIME: return "PROP_UNIT_TIME";
|
|
|
|
case PROP_UNIT_VELOCITY: return "PROP_UNIT_VELOCITY";
|
|
|
|
case PROP_UNIT_ACCELERATION: return "PROP_UNIT_ACCELERATION";
|
2013-03-13 17:16:49 +00:00
|
|
|
case PROP_UNIT_CAMERA: return "PROP_UNIT_CAMERA";
|
2019-02-08 12:31:28 +01:00
|
|
|
case PROP_UNIT_POWER: return "PROP_UNIT_POWER";
|
2012-05-12 11:01:29 +00:00
|
|
|
default: return "PROP_UNIT_UNKNOWN";
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_generate_prototypes(BlenderRNA *brna, FILE *f)
|
|
|
|
{
|
2008-11-07 02:58:25 +00:00
|
|
|
StructRNA *srna;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (srna = brna->structs.first; srna; srna = srna->cont.next)
|
2009-01-08 13:57:29 +00:00
|
|
|
fprintf(f, "extern StructRNA RNA_%s;\n", srna->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "\n");
|
2009-01-08 13:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_generate_blender(BlenderRNA *brna, FILE *f)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2017-08-11 17:51:38 +10:00
|
|
|
fprintf(f,
|
|
|
|
"BlenderRNA BLENDER_RNA = {\n"
|
|
|
|
"\t.structs = {"
|
|
|
|
);
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = brna->structs.first;
|
2017-08-11 17:51:38 +10:00
|
|
|
if (srna) fprintf(f, "&RNA_%s, ", srna->identifier);
|
|
|
|
else fprintf(f, "NULL, ");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = brna->structs.last;
|
2017-08-11 17:51:38 +10:00
|
|
|
if (srna) fprintf(f, "&RNA_%s},\n", srna->identifier);
|
|
|
|
else fprintf(f, "NULL},\n");
|
|
|
|
|
|
|
|
fprintf(f,
|
|
|
|
"\t.structs_map = NULL,\n"
|
|
|
|
"\t.structs_len = 0,\n"
|
|
|
|
"};\n\n"
|
|
|
|
);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
2009-02-02 19:57:57 +00:00
|
|
|
StructRNA *base;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
base = srna->base;
|
2009-02-02 19:57:57 +00:00
|
|
|
while (base) {
|
|
|
|
fprintf(f, "\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
for (prop = base->cont.properties.first; prop; prop = prop->next)
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "%s%s rna_%s_%s;\n", "extern ", rna_property_structname(prop->type),
|
|
|
|
base->identifier, prop->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
base = base->base;
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->cont.properties.first)
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (prop = srna->cont.properties.first; prop; prop = prop->next)
|
2018-10-29 16:19:03 +01:00
|
|
|
fprintf(f, "%s rna_%s_%s;\n", rna_property_structname(prop->type),
|
2012-03-18 09:27:36 +00:00
|
|
|
srna->identifier, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static void rna_generate_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionRNA *func, FILE *f)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
2009-04-07 00:49:39 +00:00
|
|
|
PropertyRNA *parm;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (parm = func->cont.properties.first; parm; parm = parm->next)
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "%s%s rna_%s_%s_%s;\n", "extern ", rna_property_structname(parm->type), srna->identifier,
|
|
|
|
func->identifier, parm->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->cont.properties.first)
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
2009-02-02 19:57:57 +00:00
|
|
|
StructRNA *base;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
base = srna->base;
|
2009-04-07 00:49:39 +00:00
|
|
|
while (base) {
|
2012-03-05 23:30:41 +00:00
|
|
|
for (func = base->functions.first; func; func = func->cont.next) {
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", base->identifier, func->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_generate_parameter_prototypes(brna, base, func, f);
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (base->functions.first)
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
base = base->base;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (func = srna->functions.first; func; func = func->cont.next) {
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", srna->identifier, func->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_generate_parameter_prototypes(brna, srna, func, f);
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->functions.first)
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, const char *name_override, int close_prototype)
|
2009-04-15 15:12:42 +00:00
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
PropertyDefRNA *dparm;
|
|
|
|
StructDefRNA *dsrna;
|
2010-01-24 10:51:59 +00:00
|
|
|
PropertyType type;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
int flag, flag_parameter, pout, cptr, first;
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *ptrstr;
|
2009-04-15 15:12:42 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dsrna = rna_find_struct_def(srna);
|
|
|
|
func = dfunc->func;
|
2009-04-15 15:12:42 +00:00
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* return type */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (dparm = dfunc->cont.properties.first; dparm; dparm = dparm->next) {
|
|
|
|
if (dparm->prop == func->c_ret) {
|
|
|
|
if (dparm->prop->arraydimension)
|
2012-05-12 11:01:29 +00:00
|
|
|
fprintf(f, "XXX no array return types yet"); /* XXX not supported */
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
else if (dparm->prop->type == PROP_POINTER && !(dparm->prop->flag_parameter & PARM_RNAPTR))
|
2009-04-15 15:12:42 +00:00
|
|
|
fprintf(f, "%s%s *", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
|
|
|
|
else
|
|
|
|
fprintf(f, "%s%s ", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* void if nothing to return */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!dparm)
|
2009-04-15 15:12:42 +00:00
|
|
|
fprintf(f, "void ");
|
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* function name */
|
2012-10-22 17:34:16 +00:00
|
|
|
if (name_override == NULL || name_override[0] == '\0')
|
|
|
|
fprintf(f, "%s(", dfunc->call);
|
|
|
|
else
|
|
|
|
fprintf(f, "%s(", name_override);
|
2009-04-15 15:12:42 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
first = 1;
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* self, context and reports parameters */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_SELF_ID) {
|
2010-09-03 14:53:54 +00:00
|
|
|
fprintf(f, "struct ID *_selfid");
|
2012-03-18 09:27:36 +00:00
|
|
|
first = 0;
|
2010-09-03 14:53:54 +00:00
|
|
|
}
|
2012-10-22 17:34:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if ((func->flag & FUNC_NO_SELF) == 0) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
2015-03-27 18:44:11 +05:00
|
|
|
if (dsrna->dnafromprop) fprintf(f, "struct %s *_self", dsrna->dnafromname);
|
|
|
|
else if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
|
2009-06-18 19:48:55 +00:00
|
|
|
else fprintf(f, "struct %s *_self", srna->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
first = 0;
|
2009-06-18 19:48:55 +00:00
|
|
|
}
|
2012-12-20 09:33:12 +00:00
|
|
|
else if (func->flag & FUNC_USE_SELF_TYPE) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
fprintf(f, "struct StructRNA *_type");
|
|
|
|
first = 0;
|
|
|
|
}
|
2009-06-18 19:48:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_MAIN) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2011-11-17 18:41:37 +00:00
|
|
|
fprintf(f, "Main *bmain");
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_CONTEXT) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "bContext *C");
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (func->flag & FUNC_USE_REPORTS) {
|
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "ReportList *reports");
|
|
|
|
}
|
2009-04-15 15:12:42 +00:00
|
|
|
|
2009-06-27 01:10:39 +00:00
|
|
|
/* defined parameters */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (dparm = dfunc->cont.properties.first; dparm; dparm = dparm->next) {
|
2010-01-24 10:51:59 +00:00
|
|
|
type = dparm->prop->type;
|
|
|
|
flag = dparm->prop->flag;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
flag_parameter = dparm->prop->flag_parameter;
|
|
|
|
pout = (flag_parameter & PARM_OUTPUT);
|
|
|
|
cptr = ((type == PROP_POINTER) && !(flag_parameter & PARM_RNAPTR));
|
2010-01-24 10:51:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dparm->prop == func->c_ret)
|
2009-06-18 19:48:55 +00:00
|
|
|
continue;
|
|
|
|
|
2010-01-24 10:51:59 +00:00
|
|
|
if (cptr || (flag & PROP_DYNAMIC))
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = pout ? "**" : "*";
|
2010-01-24 10:51:59 +00:00
|
|
|
else if (type == PROP_POINTER || dparm->prop->arraydimension)
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "*";
|
2010-01-24 10:51:59 +00:00
|
|
|
else if (type == PROP_STRING && (flag & PROP_THICK_WRAP))
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = "";
|
2010-01-24 10:51:59 +00:00
|
|
|
else
|
2012-03-05 23:30:41 +00:00
|
|
|
ptrstr = pout ? "*" : "";
|
2010-01-02 10:42:38 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!first) fprintf(f, ", ");
|
|
|
|
first = 0;
|
2010-01-24 10:51:59 +00:00
|
|
|
|
2010-08-31 11:31:21 +00:00
|
|
|
if (flag & PROP_DYNAMIC)
|
|
|
|
fprintf(f, "int %s%s_len, ", pout ? "*" : "", dparm->prop->identifier);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension)
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "%s%s %s[%u]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
|
2012-10-22 17:34:16 +00:00
|
|
|
rna_safe_id(dparm->prop->identifier), dparm->prop->totarraylength);
|
2009-04-15 15:12:42 +00:00
|
|
|
else
|
2012-03-18 09:27:36 +00:00
|
|
|
fprintf(f, "%s%s %s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop),
|
2012-10-22 17:34:16 +00:00
|
|
|
ptrstr, rna_safe_id(dparm->prop->identifier));
|
2010-01-24 10:51:59 +00:00
|
|
|
|
2009-04-15 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
/* ensure func(void) if there are no args */
|
|
|
|
if (first) fprintf(f, "void");
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, ")");
|
2013-09-20 06:35:28 +00:00
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
if (close_prototype)
|
|
|
|
fprintf(f, ";\n");
|
2009-04-15 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
static void rna_generate_static_function_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
|
2009-04-15 15:12:42 +00:00
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
FunctionDefRNA *dfunc;
|
2012-03-05 23:30:41 +00:00
|
|
|
int first = 1;
|
2009-04-15 15:12:42 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (func = srna->functions.first; func; func = func->cont.next) {
|
|
|
|
dfunc = rna_find_function_def(func);
|
2010-01-22 10:58:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dfunc->call) {
|
|
|
|
if (first) {
|
2010-01-22 10:58:02 +00:00
|
|
|
fprintf(f, "/* Repeated prototypes to detect errors */\n\n");
|
2012-03-05 23:30:41 +00:00
|
|
|
first = 0;
|
2010-01-22 10:58:02 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
rna_generate_static_parameter_prototypes(f, srna, dfunc, NULL, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
2012-10-23 03:45:35 +00:00
|
|
|
static void rna_generate_struct_prototypes(FILE *f)
|
2012-10-22 17:34:16 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
const char *structures[2048];
|
|
|
|
int all_structures = 0;
|
|
|
|
|
|
|
|
/* structures definitions */
|
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
|
|
|
for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
|
|
|
|
if (dfunc->call) {
|
|
|
|
for (dp = dfunc->cont.properties.first; dp; dp = dp->next) {
|
|
|
|
if (dp->prop->type == PROP_POINTER) {
|
|
|
|
int a, found = 0;
|
|
|
|
const char *struct_name = rna_parameter_type_name(dp->prop);
|
2018-05-16 18:41:11 +02:00
|
|
|
if (struct_name == NULL) {
|
|
|
|
printf("No struct found for property '%s'\n", dp->prop->identifier);
|
|
|
|
exit(1);
|
|
|
|
}
|
2012-10-22 17:34:16 +00:00
|
|
|
|
|
|
|
for (a = 0; a < all_structures; a++) {
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(struct_name, structures[a])) {
|
2012-10-22 17:34:16 +00:00
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found == 0) {
|
|
|
|
fprintf(f, "struct %s;\n", struct_name);
|
|
|
|
|
|
|
|
if (all_structures >= sizeof(structures) / sizeof(structures[0])) {
|
|
|
|
printf("Array size to store all structures names is too small\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
structures[all_structures++] = struct_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-22 10:58:02 +00:00
|
|
|
}
|
2009-04-15 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, PropertyRNA *prop)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
2013-09-20 06:35:28 +00:00
|
|
|
char *strnest = (char *)"", *errnest = (char *)"";
|
2012-03-05 23:30:41 +00:00
|
|
|
int len, freenest = 0;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (nest != NULL) {
|
|
|
|
len = strlen(nest);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
strnest = MEM_mallocN(sizeof(char) * (len + 2), "rna_generate_property -> strnest");
|
|
|
|
errnest = MEM_mallocN(sizeof(char) * (len + 2), "rna_generate_property -> errnest");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
strcpy(strnest, "_"); strcat(strnest, nest);
|
|
|
|
strcpy(errnest, "."); strcat(errnest, nest);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
freenest = 1;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
|
|
|
|
int i, defaultfound = 0, totflag = 0;
|
|
|
|
|
|
|
|
if (eprop->item) {
|
2017-10-18 15:07:26 +11:00
|
|
|
fprintf(f, "static const EnumPropertyItem rna_%s%s_%s_items[%d] = {\n\t", srna->identifier,
|
2012-05-12 11:01:29 +00:00
|
|
|
strnest, prop->identifier, eprop->totitem + 1);
|
|
|
|
|
|
|
|
for (i = 0; i < eprop->totitem; i++) {
|
|
|
|
fprintf(f, "{%d, ", eprop->item[i].value);
|
|
|
|
rna_print_c_string(f, eprop->item[i].identifier); fprintf(f, ", ");
|
|
|
|
fprintf(f, "%d, ", eprop->item[i].icon);
|
|
|
|
rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", ");
|
|
|
|
rna_print_c_string(f, eprop->item[i].description); fprintf(f, "},\n\t");
|
|
|
|
|
|
|
|
if (eprop->item[i].identifier[0]) {
|
|
|
|
if (prop->flag & PROP_ENUM_FLAG) {
|
|
|
|
totflag |= eprop->item[i].value;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (eprop->defaultvalue == eprop->item[i].value) {
|
|
|
|
defaultfound = 1;
|
2011-01-13 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
fprintf(f, "{0, NULL, 0, NULL, NULL}\n};\n\n");
|
2009-03-06 10:22:12 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
if (prop->flag & PROP_ENUM_FLAG) {
|
|
|
|
if (eprop->defaultvalue & ~totflag) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s%s.%s, enum default includes unused bits (%d).",
|
|
|
|
srna->identifier, errnest, prop->identifier,
|
2012-05-12 11:01:29 +00:00
|
|
|
eprop->defaultvalue & ~totflag);
|
|
|
|
DefRNA.error = 1;
|
2009-03-06 10:22:12 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2008-11-14 11:15:53 +00:00
|
|
|
else {
|
2019-03-13 09:06:44 +11:00
|
|
|
if (!defaultfound &&
|
|
|
|
!(eprop->itemf && eprop->item == DummyRNA_NULL_items))
|
|
|
|
{
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s%s.%s, enum default is not in items.",
|
|
|
|
srna->identifier, errnest, prop->identifier);
|
2012-05-12 11:01:29 +00:00
|
|
|
DefRNA.error = 1;
|
|
|
|
}
|
2008-11-14 11:15:53 +00:00
|
|
|
}
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
else {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s%s.%s, enum must have items defined.",
|
|
|
|
srna->identifier, errnest, prop->identifier);
|
2012-05-12 11:01:29 +00:00
|
|
|
DefRNA.error = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
|
|
|
|
unsigned int i;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
if (prop->arraydimension && prop->totarraylength) {
|
2018-07-01 15:47:09 +02:00
|
|
|
fprintf(f, "static bool rna_%s%s_%s_default[%u] = {\n\t", srna->identifier, strnest,
|
2012-05-12 11:01:29 +00:00
|
|
|
prop->identifier, prop->totarraylength);
|
|
|
|
|
|
|
|
for (i = 0; i < prop->totarraylength; i++) {
|
|
|
|
if (bprop->defaultarray)
|
|
|
|
fprintf(f, "%d", bprop->defaultarray[i]);
|
|
|
|
else
|
|
|
|
fprintf(f, "%d", bprop->defaultvalue);
|
|
|
|
if (i != prop->totarraylength - 1)
|
|
|
|
fprintf(f, ",\n\t");
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
|
|
|
|
fprintf(f, "\n};\n\n");
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_INT:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (prop->arraydimension && prop->totarraylength) {
|
|
|
|
fprintf(f, "static int rna_%s%s_%s_default[%u] = {\n\t", srna->identifier, strnest,
|
|
|
|
prop->identifier, prop->totarraylength);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
for (i = 0; i < prop->totarraylength; i++) {
|
|
|
|
if (iprop->defaultarray)
|
|
|
|
fprintf(f, "%d", iprop->defaultarray[i]);
|
|
|
|
else
|
|
|
|
fprintf(f, "%d", iprop->defaultvalue);
|
|
|
|
if (i != prop->totarraylength - 1)
|
|
|
|
fprintf(f, ",\n\t");
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
|
|
|
|
fprintf(f, "\n};\n\n");
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (prop->arraydimension && prop->totarraylength) {
|
|
|
|
fprintf(f, "static float rna_%s%s_%s_default[%u] = {\n\t", srna->identifier, strnest,
|
|
|
|
prop->identifier, prop->totarraylength);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
for (i = 0; i < prop->totarraylength; i++) {
|
|
|
|
if (fprop->defaultarray)
|
|
|
|
rna_float_print(f, fprop->defaultarray[i]);
|
|
|
|
else
|
|
|
|
rna_float_print(f, fprop->defaultvalue);
|
|
|
|
if (i != prop->totarraylength - 1)
|
|
|
|
fprintf(f, ",\n\t");
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
|
|
|
|
fprintf(f, "\n};\n\n");
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-12-18 10:08:22 +01:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
|
|
|
|
|
|
|
|
/* XXX This systematically enforces that flag on ID pointers... we'll probably have to revisit. :/ */
|
|
|
|
StructRNA *type = rna_find_struct((const char *)pprop->type);
|
|
|
|
if (type && (type->flag & STRUCT_ID)) {
|
|
|
|
prop->flag |= PROP_PTR_NO_OWNERSHIP;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
|
|
|
|
|
|
|
|
/* XXX This systematically enforces that flag on ID pointers... we'll probably have to revisit. :/ */
|
|
|
|
StructRNA *type = rna_find_struct((const char *)cprop->item_type);
|
|
|
|
if (type && (type->flag & STRUCT_ID)) {
|
|
|
|
prop->flag |= PROP_PTR_NO_OWNERSHIP;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-05-12 11:01:29 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2018-10-29 16:19:03 +01:00
|
|
|
fprintf(f, "%s rna_%s%s_%s = {\n",
|
2012-03-12 06:07:16 +00:00
|
|
|
rna_property_structname(prop->type),
|
|
|
|
srna->identifier, strnest, prop->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-12-28 14:19:05 +00:00
|
|
|
if (prop->next) fprintf(f, "\t{(PropertyRNA *)&rna_%s%s_%s, ", srna->identifier, strnest, prop->next->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "\t{NULL, ");
|
2012-12-28 14:19:05 +00:00
|
|
|
if (prop->prev) fprintf(f, "(PropertyRNA *)&rna_%s%s_%s,\n", srna->identifier, strnest, prop->prev->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "NULL,\n");
|
|
|
|
fprintf(f, "\t%d, ", prop->magic);
|
|
|
|
rna_print_c_string(f, prop->identifier);
|
2018-06-05 11:10:05 +02:00
|
|
|
fprintf(f, ", %d, %d, %d, %d, %d, ", prop->flag, prop->flag_override, prop->flag_parameter, prop->flag_internal, prop->tags);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
|
2009-07-02 03:32:57 +00:00
|
|
|
rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, "%d, ", prop->icon);
|
|
|
|
rna_print_c_string(f, prop->translation_context); fprintf(f, ",\n");
|
|
|
|
fprintf(f, "\t%s, %s | %s, %s, %u, {%u, %u, %u}, %u,\n",
|
2012-03-12 06:07:16 +00:00
|
|
|
RNA_property_typename(prop->type),
|
|
|
|
rna_property_subtypename(prop->subtype),
|
|
|
|
rna_property_subtype_unit(prop->subtype),
|
|
|
|
rna_function_string(prop->getlength),
|
|
|
|
prop->arraydimension,
|
|
|
|
prop->arraylength[0],
|
|
|
|
prop->arraylength[1],
|
|
|
|
prop->arraylength[2],
|
|
|
|
prop->totarraylength);
|
2017-11-29 15:31:31 +01:00
|
|
|
fprintf(f, "\t%s%s, %d, %s, %s, %s, %s, %s,\n",
|
2012-05-12 11:01:29 +00:00
|
|
|
(prop->flag & PROP_CONTEXT_UPDATE) ? "(UpdateFunc)" : "",
|
2012-03-12 06:07:16 +00:00
|
|
|
rna_function_string(prop->update),
|
|
|
|
prop->noteflag,
|
|
|
|
rna_function_string(prop->editable),
|
2017-11-29 15:31:31 +01:00
|
|
|
rna_function_string(prop->itemeditable),
|
|
|
|
rna_function_string(prop->override_diff),
|
|
|
|
rna_function_string(prop->override_store),
|
|
|
|
rna_function_string(prop->override_apply));
|
2009-07-02 03:32:57 +00:00
|
|
|
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (prop->flag_internal & PROP_INTERN_RAW_ACCESS) rna_set_raw_offset(f, srna, prop);
|
2010-01-04 22:30:09 +00:00
|
|
|
else fprintf(f, "\t0, -1");
|
2009-11-13 16:08:03 +00:00
|
|
|
|
|
|
|
/* our own type - collections/arrays only */
|
2012-05-12 11:01:29 +00:00
|
|
|
if (prop->srna) fprintf(f, ", &RNA_%s", (const char *)prop->srna);
|
2009-11-13 16:08:03 +00:00
|
|
|
else fprintf(f, ", NULL");
|
|
|
|
|
2009-07-02 03:32:57 +00:00
|
|
|
fprintf(f, "},\n");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (prop->type) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
BoolPropertyRNA *bprop = (BoolPropertyRNA *)prop;
|
2013-01-05 14:56:37 +00:00
|
|
|
fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, %s, %d, ",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_function_string(bprop->get),
|
|
|
|
rna_function_string(bprop->set),
|
|
|
|
rna_function_string(bprop->getarray),
|
|
|
|
rna_function_string(bprop->setarray),
|
2013-01-05 14:56:37 +00:00
|
|
|
rna_function_string(bprop->get_ex),
|
|
|
|
rna_function_string(bprop->set_ex),
|
|
|
|
rna_function_string(bprop->getarray_ex),
|
|
|
|
rna_function_string(bprop->setarray_ex),
|
2012-05-12 11:01:29 +00:00
|
|
|
bprop->defaultvalue);
|
|
|
|
if (prop->arraydimension && prop->totarraylength)
|
|
|
|
fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
|
|
|
|
else fprintf(f, "NULL\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_INT:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
IntPropertyRNA *iprop = (IntPropertyRNA *)prop;
|
2013-01-05 14:56:37 +00:00
|
|
|
fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,\n\t",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_function_string(iprop->get),
|
|
|
|
rna_function_string(iprop->set),
|
|
|
|
rna_function_string(iprop->getarray),
|
|
|
|
rna_function_string(iprop->setarray),
|
2013-01-05 14:56:37 +00:00
|
|
|
rna_function_string(iprop->range),
|
|
|
|
rna_function_string(iprop->get_ex),
|
|
|
|
rna_function_string(iprop->set_ex),
|
|
|
|
rna_function_string(iprop->getarray_ex),
|
|
|
|
rna_function_string(iprop->setarray_ex),
|
|
|
|
rna_function_string(iprop->range_ex));
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_int_print(f, iprop->softmin); fprintf(f, ", ");
|
|
|
|
rna_int_print(f, iprop->softmax); fprintf(f, ", ");
|
|
|
|
rna_int_print(f, iprop->hardmin); fprintf(f, ", ");
|
|
|
|
rna_int_print(f, iprop->hardmax); fprintf(f, ", ");
|
|
|
|
rna_int_print(f, iprop->step); fprintf(f, ", ");
|
|
|
|
rna_int_print(f, iprop->defaultvalue); fprintf(f, ", ");
|
|
|
|
if (prop->arraydimension && prop->totarraylength)
|
|
|
|
fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
|
|
|
|
else fprintf(f, "NULL\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_FLOAT:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
FloatPropertyRNA *fprop = (FloatPropertyRNA *)prop;
|
2013-01-05 14:56:37 +00:00
|
|
|
fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, ",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_function_string(fprop->get),
|
|
|
|
rna_function_string(fprop->set),
|
|
|
|
rna_function_string(fprop->getarray),
|
|
|
|
rna_function_string(fprop->setarray),
|
2013-01-05 14:56:37 +00:00
|
|
|
rna_function_string(fprop->range),
|
|
|
|
rna_function_string(fprop->get_ex),
|
|
|
|
rna_function_string(fprop->set_ex),
|
|
|
|
rna_function_string(fprop->getarray_ex),
|
|
|
|
rna_function_string(fprop->setarray_ex),
|
|
|
|
rna_function_string(fprop->range_ex));
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_float_print(f, fprop->softmin); fprintf(f, ", ");
|
|
|
|
rna_float_print(f, fprop->softmax); fprintf(f, ", ");
|
|
|
|
rna_float_print(f, fprop->hardmin); fprintf(f, ", ");
|
|
|
|
rna_float_print(f, fprop->hardmax); fprintf(f, ", ");
|
|
|
|
rna_float_print(f, fprop->step); fprintf(f, ", ");
|
|
|
|
rna_int_print(f, (int)fprop->precision); fprintf(f, ", ");
|
|
|
|
rna_float_print(f, fprop->defaultvalue); fprintf(f, ", ");
|
|
|
|
if (prop->arraydimension && prop->totarraylength)
|
|
|
|
fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier);
|
|
|
|
else fprintf(f, "NULL\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_STRING:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
StringPropertyRNA *sprop = (StringPropertyRNA *)prop;
|
2013-01-05 14:56:37 +00:00
|
|
|
fprintf(f, "\t%s, %s, %s, %s, %s, %s, %d, ",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_function_string(sprop->get),
|
|
|
|
rna_function_string(sprop->length),
|
|
|
|
rna_function_string(sprop->set),
|
2013-01-05 14:56:37 +00:00
|
|
|
rna_function_string(sprop->get_ex),
|
|
|
|
rna_function_string(sprop->length_ex),
|
|
|
|
rna_function_string(sprop->set_ex),
|
2012-05-12 11:01:29 +00:00
|
|
|
sprop->maxlength);
|
|
|
|
rna_print_c_string(f, sprop->defaultvalue); fprintf(f, "\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_ENUM:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
EnumPropertyRNA *eprop = (EnumPropertyRNA *)prop;
|
2013-01-05 14:56:37 +00:00
|
|
|
fprintf(f, "\t%s, %s, %s, %s, %s, NULL, ",
|
2012-05-12 11:01:29 +00:00
|
|
|
rna_function_string(eprop->get),
|
|
|
|
rna_function_string(eprop->set),
|
2013-01-05 14:56:37 +00:00
|
|
|
rna_function_string(eprop->itemf),
|
|
|
|
rna_function_string(eprop->get_ex),
|
|
|
|
rna_function_string(eprop->set_ex));
|
2012-05-12 11:01:29 +00:00
|
|
|
if (eprop->item)
|
|
|
|
fprintf(f, "rna_%s%s_%s_items, ", srna->identifier, strnest, prop->identifier);
|
|
|
|
else
|
|
|
|
fprintf(f, "NULL, ");
|
|
|
|
fprintf(f, "%d, %d\n", eprop->totitem, eprop->defaultvalue);
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
|
|
|
|
fprintf(f, "\t%s, %s, %s, %s,", rna_function_string(pprop->get),
|
|
|
|
rna_function_string(pprop->set),
|
|
|
|
rna_function_string(pprop->typef),
|
|
|
|
rna_function_string(pprop->poll));
|
|
|
|
if (pprop->type) fprintf(f, "&RNA_%s\n", (const char *)pprop->type);
|
|
|
|
else fprintf(f, "NULL\n");
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop;
|
|
|
|
fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, %s, ",
|
|
|
|
rna_function_string(cprop->begin),
|
|
|
|
rna_function_string(cprop->next),
|
|
|
|
rna_function_string(cprop->end),
|
|
|
|
rna_function_string(cprop->get),
|
|
|
|
rna_function_string(cprop->length),
|
|
|
|
rna_function_string(cprop->lookupint),
|
|
|
|
rna_function_string(cprop->lookupstring),
|
|
|
|
rna_function_string(cprop->assignint));
|
|
|
|
if (cprop->item_type) fprintf(f, "&RNA_%s\n", (const char *)cprop->item_type);
|
|
|
|
else fprintf(f, "NULL\n");
|
|
|
|
break;
|
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-04-07 00:49:39 +00:00
|
|
|
fprintf(f, "};\n\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (freenest) {
|
2009-04-07 00:49:39 +00:00
|
|
|
MEM_freeN(strnest);
|
|
|
|
MEM_freeN(errnest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
PropertyRNA *prop, *parm;
|
|
|
|
StructRNA *base;
|
|
|
|
|
|
|
|
fprintf(f, "/* %s */\n", srna->name);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (prop = srna->cont.properties.first; prop; prop = prop->next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_generate_property(f, srna, NULL, prop);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (func = srna->functions.first; func; func = func->cont.next) {
|
|
|
|
for (parm = func->cont.properties.first; parm; parm = parm->next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_generate_property(f, srna, func->identifier, parm);
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "%s%s rna_%s_%s_func = {\n", "", "FunctionRNA", srna->identifier, func->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
if (func->cont.next)
|
2012-12-28 14:19:05 +00:00
|
|
|
fprintf(f, "\t{(FunctionRNA *)&rna_%s_%s_func, ", srna->identifier,
|
2012-05-12 11:01:29 +00:00
|
|
|
((FunctionRNA *)func->cont.next)->identifier);
|
2012-03-18 09:27:36 +00:00
|
|
|
else
|
|
|
|
fprintf(f, "\t{NULL, ");
|
|
|
|
if (func->cont.prev)
|
2012-12-28 14:19:05 +00:00
|
|
|
fprintf(f, "(FunctionRNA *)&rna_%s_%s_func,\n", srna->identifier,
|
2012-05-12 11:01:29 +00:00
|
|
|
((FunctionRNA *)func->cont.prev)->identifier);
|
2012-03-18 09:27:36 +00:00
|
|
|
else
|
|
|
|
fprintf(f, "NULL,\n");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2009-06-19 23:05:21 +00:00
|
|
|
fprintf(f, "\tNULL,\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = func->cont.properties.first;
|
2012-12-28 14:19:05 +00:00
|
|
|
if (parm) fprintf(f, "\t{(PropertyRNA *)&rna_%s_%s_%s, ", srna->identifier, func->identifier, parm->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "\t{NULL, ");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = func->cont.properties.last;
|
2012-12-28 14:19:05 +00:00
|
|
|
if (parm) fprintf(f, "(PropertyRNA *)&rna_%s_%s_%s}},\n", srna->identifier, func->identifier, parm->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "NULL}},\n");
|
|
|
|
|
|
|
|
fprintf(f, "\t");
|
|
|
|
rna_print_c_string(f, func->identifier);
|
|
|
|
fprintf(f, ", %d, ", func->flag);
|
|
|
|
rna_print_c_string(f, func->description); fprintf(f, ",\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
dfunc = rna_find_function_def(func);
|
|
|
|
if (dfunc->gencall) fprintf(f, "\t%s,\n", dfunc->gencall);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "\tNULL,\n");
|
2010-01-02 10:42:38 +00:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
if (func->c_ret)
|
2012-12-28 14:19:05 +00:00
|
|
|
fprintf(f, "\t(PropertyRNA *)&rna_%s_%s_%s\n", srna->identifier, func->identifier, func->c_ret->identifier);
|
2012-03-18 09:27:36 +00:00
|
|
|
else
|
|
|
|
fprintf(f, "\tNULL\n");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
|
|
|
fprintf(f, "};\n");
|
|
|
|
fprintf(f, "\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-14 18:46:57 +00:00
|
|
|
fprintf(f, "StructRNA RNA_%s = {\n", srna->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
if (srna->cont.next) fprintf(f, "\t{(ContainerRNA *)&RNA_%s, ", ((StructRNA *)srna->cont.next)->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "\t{NULL, ");
|
2012-05-12 11:01:29 +00:00
|
|
|
if (srna->cont.prev) fprintf(f, "(ContainerRNA *)&RNA_%s,\n", ((StructRNA *)srna->cont.prev)->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
else fprintf(f, "NULL,\n");
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2009-06-19 23:05:21 +00:00
|
|
|
fprintf(f, "\tNULL,\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = srna->cont.properties.first;
|
2012-12-28 14:19:05 +00:00
|
|
|
if (prop) fprintf(f, "\t{(PropertyRNA *)&rna_%s_%s, ", srna->identifier, prop->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "\t{NULL, ");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = srna->cont.properties.last;
|
2012-12-28 14:19:05 +00:00
|
|
|
if (prop) fprintf(f, "(PropertyRNA *)&rna_%s_%s}},\n", srna->identifier, prop->identifier);
|
2009-04-07 00:49:39 +00:00
|
|
|
else fprintf(f, "NULL}},\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "\t");
|
2008-11-14 18:46:57 +00:00
|
|
|
rna_print_c_string(f, srna->identifier);
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, ", NULL, NULL"); /* PyType - Cant initialize here */
|
2017-11-23 13:41:07 +01:00
|
|
|
fprintf(f, ", %d, NULL, ", srna->flag);
|
2008-11-07 02:58:25 +00:00
|
|
|
rna_print_c_string(f, srna->name);
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, ",\n\t");
|
2008-12-19 04:06:24 +00:00
|
|
|
rna_print_c_string(f, srna->description);
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, ",\n\t");
|
2012-03-16 15:39:25 +00:00
|
|
|
rna_print_c_string(f, srna->translation_context);
|
2013-07-29 04:18:01 +00:00
|
|
|
fprintf(f, ", %d,\n", srna->icon);
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = srna->nameproperty;
|
|
|
|
if (prop) {
|
|
|
|
base = srna;
|
|
|
|
while (base->base && base->base->nameproperty == prop)
|
|
|
|
base = base->base;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-12-28 14:19:05 +00:00
|
|
|
fprintf(f, "\t(PropertyRNA *)&rna_%s_%s, ", base->identifier, prop->identifier);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
fprintf(f, "\tNULL, ");
|
|
|
|
}
|
2008-11-14 14:34:19 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = srna->iteratorproperty;
|
|
|
|
base = srna;
|
|
|
|
while (base->base && base->base->iteratorproperty == prop)
|
|
|
|
base = base->base;
|
2012-12-28 14:19:05 +00:00
|
|
|
fprintf(f, "(PropertyRNA *)&rna_%s_rna_properties,\n", base->identifier);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->base) fprintf(f, "\t&RNA_%s,\n", srna->base->identifier);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
else fprintf(f, "\tNULL,\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->nested) fprintf(f, "\t&RNA_%s,\n", srna->nested->identifier);
|
2009-01-09 16:08:47 +00:00
|
|
|
else fprintf(f, "\tNULL,\n");
|
|
|
|
|
2009-01-01 15:52:51 +00:00
|
|
|
fprintf(f, "\t%s,\n", rna_function_string(srna->refine));
|
2009-03-25 20:29:01 +00:00
|
|
|
fprintf(f, "\t%s,\n", rna_function_string(srna->path));
|
2009-04-19 13:37:59 +00:00
|
|
|
fprintf(f, "\t%s,\n", rna_function_string(srna->reg));
|
|
|
|
fprintf(f, "\t%s,\n", rna_function_string(srna->unreg));
|
2011-05-18 11:21:10 +00:00
|
|
|
fprintf(f, "\t%s,\n", rna_function_string(srna->instance));
|
2009-05-20 09:52:02 +00:00
|
|
|
fprintf(f, "\t%s,\n", rna_function_string(srna->idproperties));
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (srna->reg && !srna->refine) {
|
2019-02-18 09:32:15 +11:00
|
|
|
CLOG_ERROR(&LOG, "%s has a register function, must also have refine function.",
|
|
|
|
srna->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
DefRNA.error = 1;
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = srna->functions.first;
|
2012-12-28 14:19:05 +00:00
|
|
|
if (func) fprintf(f, "\t{(FunctionRNA *)&rna_%s_%s_func, ", srna->identifier, func->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
else fprintf(f, "\t{NULL, ");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = srna->functions.last;
|
2012-12-28 14:19:05 +00:00
|
|
|
if (func) fprintf(f, "(FunctionRNA *)&rna_%s_%s_func}\n", srna->identifier, func->identifier);
|
2008-10-31 23:50:02 +00:00
|
|
|
else fprintf(f, "NULL}\n");
|
|
|
|
|
|
|
|
fprintf(f, "};\n");
|
|
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct RNAProcessItem {
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *filename;
|
|
|
|
const char *api_filename;
|
2008-10-31 23:50:02 +00:00
|
|
|
void (*define)(BlenderRNA *brna);
|
|
|
|
} RNAProcessItem;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
static RNAProcessItem PROCESS_ITEMS[] = {
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_rna.c", NULL, RNA_def_rna},
|
|
|
|
{"rna_ID.c", NULL, RNA_def_ID},
|
2011-08-28 23:24:34 +00:00
|
|
|
{"rna_texture.c", "rna_texture_api.c", RNA_def_texture},
|
2009-07-11 11:58:50 +00:00
|
|
|
{"rna_action.c", "rna_action_api.c", RNA_def_action},
|
2009-08-25 04:05:37 +00:00
|
|
|
{"rna_animation.c", "rna_animation_api.c", RNA_def_animation},
|
2010-01-07 22:54:05 +00:00
|
|
|
{"rna_animviz.c", NULL, RNA_def_animviz},
|
2009-12-04 02:32:34 +00:00
|
|
|
{"rna_armature.c", "rna_armature_api.c", RNA_def_armature},
|
2009-07-20 23:52:53 +00:00
|
|
|
{"rna_boid.c", NULL, RNA_def_boid},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_brush.c", NULL, RNA_def_brush},
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
{"rna_cachefile.c", NULL, RNA_def_cachefile},
|
2011-09-29 08:23:52 +00:00
|
|
|
{"rna_camera.c", "rna_camera_api.c", RNA_def_camera},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_cloth.c", NULL, RNA_def_cloth},
|
2018-08-29 15:32:50 +02:00
|
|
|
{"rna_collection.c", NULL, RNA_def_collections},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_color.c", NULL, RNA_def_color},
|
|
|
|
{"rna_constraint.c", NULL, RNA_def_constraint},
|
|
|
|
{"rna_context.c", NULL, RNA_def_context},
|
2013-12-17 22:13:15 +11:00
|
|
|
{"rna_curve.c", "rna_curve_api.c", RNA_def_curve},
|
2011-05-24 07:08:58 +00:00
|
|
|
{"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint},
|
2009-11-06 11:09:04 +00:00
|
|
|
{"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_fluidsim.c", NULL, RNA_def_fluidsim},
|
2009-08-27 06:03:41 +00:00
|
|
|
{"rna_gpencil.c", NULL, RNA_def_gpencil},
|
2009-07-23 12:55:26 +00:00
|
|
|
{"rna_image.c", "rna_image_api.c", RNA_def_image},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_key.c", NULL, RNA_def_key},
|
2019-02-27 12:34:56 +11:00
|
|
|
{"rna_light.c", NULL, RNA_def_light},
|
2013-12-17 22:13:15 +11:00
|
|
|
{"rna_lattice.c", "rna_lattice_api.c", RNA_def_lattice},
|
2017-11-22 10:52:39 -02:00
|
|
|
{"rna_layer.c", NULL, RNA_def_view_layer},
|
2010-06-25 22:45:42 +00:00
|
|
|
{"rna_linestyle.c", NULL, RNA_def_linestyle},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_main.c", "rna_main_api.c", RNA_def_main},
|
2009-07-02 20:46:35 +00:00
|
|
|
{"rna_material.c", "rna_material_api.c", RNA_def_material},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh},
|
2013-02-11 10:56:21 +00:00
|
|
|
{"rna_meta.c", "rna_meta_api.c", RNA_def_meta},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_modifier.c", NULL, RNA_def_modifier},
|
2018-07-31 10:22:19 +02:00
|
|
|
{"rna_gpencil_modifier.c", NULL, RNA_def_greasepencil_modifier},
|
|
|
|
{"rna_shader_fx.c", NULL, RNA_def_shader_fx },
|
2009-06-20 03:58:25 +00:00
|
|
|
{"rna_nla.c", NULL, RNA_def_nla},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_nodetree.c", NULL, RNA_def_nodetree},
|
|
|
|
{"rna_object.c", "rna_object_api.c", RNA_def_object},
|
|
|
|
{"rna_object_force.c", NULL, RNA_def_object_force},
|
2017-06-06 13:58:40 +02:00
|
|
|
{"rna_depsgraph.c", NULL, RNA_def_depsgraph},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_packedfile.c", NULL, RNA_def_packedfile},
|
2015-03-18 14:03:59 +11:00
|
|
|
{"rna_palette.c", NULL, RNA_def_palette},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_particle.c", NULL, RNA_def_particle},
|
2009-07-10 14:46:52 +00:00
|
|
|
{"rna_pose.c", "rna_pose_api.c", RNA_def_pose},
|
2017-06-12 20:59:54 +10:00
|
|
|
{"rna_lightprobe.c", NULL, RNA_def_lightprobe},
|
2009-07-21 14:11:51 +00:00
|
|
|
{"rna_render.c", NULL, RNA_def_render},
|
2013-01-23 05:56:22 +00:00
|
|
|
{"rna_rigidbody.c", NULL, RNA_def_rigidbody},
|
2009-08-25 04:05:37 +00:00
|
|
|
{"rna_scene.c", "rna_scene_api.c", RNA_def_scene},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_screen.c", NULL, RNA_def_screen},
|
2009-07-25 22:31:02 +00:00
|
|
|
{"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint},
|
2010-06-21 22:05:34 +00:00
|
|
|
{"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer},
|
2009-07-30 15:00:26 +00:00
|
|
|
{"rna_smoke.c", NULL, RNA_def_smoke},
|
2014-01-29 07:30:42 +11:00
|
|
|
{"rna_space.c", "rna_space_api.c", RNA_def_space},
|
2011-08-01 11:44:20 +00:00
|
|
|
{"rna_speaker.c", NULL, RNA_def_speaker},
|
2009-09-06 15:13:57 +00:00
|
|
|
{"rna_test.c", NULL, RNA_def_test},
|
2011-11-15 19:46:56 +00:00
|
|
|
{"rna_text.c", "rna_text_api.c", RNA_def_text},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_timeline.c", NULL, RNA_def_timeline_marker},
|
2015-02-07 22:31:00 +11:00
|
|
|
{"rna_sound.c", "rna_sound_api.c", RNA_def_sound},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_ui.c", "rna_ui_api.c", RNA_def_ui},
|
|
|
|
{"rna_userdef.c", NULL, RNA_def_userdef},
|
2015-02-07 22:31:00 +11:00
|
|
|
{"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont},
|
2009-06-18 19:48:55 +00:00
|
|
|
{"rna_wm.c", "rna_wm_api.c", RNA_def_wm},
|
2018-07-14 23:49:00 +02:00
|
|
|
{"rna_wm_gizmo.c", "rna_wm_gizmo_api.c", RNA_def_wm_gizmo},
|
2018-05-16 18:41:11 +02:00
|
|
|
{"rna_workspace.c", "rna_workspace_api.c", RNA_def_workspace},
|
2012-03-18 09:27:36 +00:00
|
|
|
{"rna_world.c", NULL, RNA_def_world},
|
2011-11-07 12:55:18 +00:00
|
|
|
{"rna_movieclip.c", NULL, RNA_def_movieclip},
|
|
|
|
{"rna_tracking.c", NULL, RNA_def_tracking},
|
2012-06-04 16:42:58 +00:00
|
|
|
{"rna_mask.c", NULL, RNA_def_mask},
|
2019-02-03 14:01:45 +11:00
|
|
|
{NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const char *api_filename)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2009-01-08 13:57:29 +00:00
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
2009-04-07 00:49:39 +00:00
|
|
|
FunctionDefRNA *dfunc;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-09 18:28:30 +00:00
|
|
|
fprintf(f,
|
|
|
|
"\n"
|
|
|
|
"/* Automatically generated struct definitions for the Data API.\n"
|
|
|
|
" * Do not edit manually, changes will be overwritten. */\n\n"
|
|
|
|
"#define RNA_RUNTIME\n\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
|
|
|
fprintf(f, "#include <float.h>\n");
|
2011-01-01 13:49:22 +00:00
|
|
|
fprintf(f, "#include <stdio.h>\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "#include <limits.h>\n");
|
|
|
|
fprintf(f, "#include <string.h>\n\n");
|
2009-07-02 03:32:57 +00:00
|
|
|
fprintf(f, "#include <stddef.h>\n\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-11-19 15:18:08 +00:00
|
|
|
fprintf(f, "#include \"MEM_guardedalloc.h\"\n\n");
|
|
|
|
|
2009-05-28 23:23:47 +00:00
|
|
|
fprintf(f, "#include \"DNA_ID.h\"\n");
|
2009-12-08 17:23:48 +00:00
|
|
|
fprintf(f, "#include \"DNA_scene_types.h\"\n");
|
2009-05-28 23:23:47 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "#include \"BLI_blenlib.h\"\n\n");
|
2011-01-07 19:18:31 +00:00
|
|
|
fprintf(f, "#include \"BLI_utildefines.h\"\n\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "#include \"BKE_context.h\"\n");
|
2009-05-28 23:23:47 +00:00
|
|
|
fprintf(f, "#include \"BKE_library.h\"\n");
|
2009-12-08 17:23:48 +00:00
|
|
|
fprintf(f, "#include \"BKE_main.h\"\n");
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "#include \"BKE_report.h\"\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2008-11-14 14:34:19 +00:00
|
|
|
fprintf(f, "#include \"RNA_define.h\"\n");
|
|
|
|
fprintf(f, "#include \"RNA_types.h\"\n");
|
2008-10-31 23:50:02 +00:00
|
|
|
fprintf(f, "#include \"rna_internal.h\"\n\n");
|
|
|
|
|
2015-03-13 00:03:01 +11:00
|
|
|
|
|
|
|
/* include the generated prototypes header */
|
|
|
|
fprintf(f, "#include \"rna_prototypes_gen.h\"\n\n");
|
2009-01-08 13:57:29 +00:00
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "#include \"%s\"\n", filename);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (api_filename)
|
2009-06-18 19:48:55 +00:00
|
|
|
fprintf(f, "#include \"%s\"\n", api_filename);
|
|
|
|
fprintf(f, "\n");
|
2009-01-08 13:57:29 +00:00
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
/* we want the included C files to have warnings enabled but for the generated code
|
|
|
|
* ignore unused-parameter warnings which are hard to prevent */
|
Windows: Add support for building with clang.
This commit contains the minimum to make clang build/work with blender, asan and ninja build support is forthcoming
Things to note:
1) Builds and runs, and is able to pass all tests (except for the freestyle_stroke_material.blend test which was broken at that time for all platforms by the looks of it)
2) It's slightly faster than msvc when using cycles. (time in seconds, on an i7-3370)
victor_cpu
msvc:3099.51
clang:2796.43
pavillon_barcelona_cpu
msvc:1872.05
clang:1827.72
koro_cpu
msvc:1097.58
clang:1006.51
fishy_cat_cpu
msvc:815.37
clang:722.2
classroom_cpu
msvc:1705.39
clang:1575.43
bmw27_cpu
msvc:552.38
clang:561.53
barbershop_interior_cpu
msvc:2134.93
clang:1922.33
3) clang on windows uses a drop in replacement for the Microsoft cl.exe (takes some of the Microsoft parameters, but not all, and takes some of the clang parameters but not all) and uses ms headers + libraries + linker, so you still need visual studio installed and will use our existing vc14 svn libs.
4) X64 only currently, X86 builds but crashes on startup.
5) Tested with llvm/clang 6.0.0
6) Requires visual studio integration, available at https://github.com/LazyDodo/llvm-vs2017-integration
7) The Microsoft compiler spawns a few copies of cl in parallel to get faster build times, clang doesn't, so the build time is 3-4x slower than with msvc.
8) No openmp support yet. Have not looked at this much, the binary distribution of clang doesn't seem to include it on windows.
9) No ASAN support yet, some of the sanitizers can be made to work, but it was decided to leave support out of this commit.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D3304
2018-05-28 14:34:47 -06:00
|
|
|
#if defined( __GNUC__) || defined(__clang__)
|
2013-09-20 06:35:28 +00:00
|
|
|
fprintf(f, "#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n\n");
|
|
|
|
#endif
|
|
|
|
|
2009-01-08 13:57:29 +00:00
|
|
|
fprintf(f, "/* Autogenerated Functions */\n\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
|
|
|
if (!filename || ds->filename == filename) {
|
2009-02-02 19:57:57 +00:00
|
|
|
rna_generate_property_prototypes(brna, ds->srna, f);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_generate_function_prototypes(brna, ds->srna, f);
|
|
|
|
}
|
|
|
|
}
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
|
|
|
if (!filename || ds->filename == filename)
|
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_def_property_funcs(f, ds->srna, dp);
|
2009-01-08 13:57:29 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
|
|
|
if (!filename || ds->filename == filename) {
|
2012-10-22 17:34:16 +00:00
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next)
|
|
|
|
rna_def_property_wrapper_funcs(f, ds, dp);
|
|
|
|
|
|
|
|
for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) {
|
|
|
|
rna_def_function_wrapper_funcs(f, ds, dfunc);
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_def_function_funcs(f, ds, dfunc);
|
2012-10-22 17:34:16 +00:00
|
|
|
}
|
2009-04-07 00:49:39 +00:00
|
|
|
|
2009-04-15 15:12:42 +00:00
|
|
|
rna_generate_static_function_prototypes(brna, ds->srna, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
|
|
|
if (!filename || ds->filename == filename)
|
2009-01-08 13:57:29 +00:00
|
|
|
rna_generate_struct(brna, ds->srna, f);
|
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(filename, "rna_ID.c")) {
|
2009-01-08 13:57:29 +00:00
|
|
|
/* this is ugly, but we cannot have c files compiled for both
|
|
|
|
* makesrna and blender with some build systems at the moment */
|
|
|
|
fprintf(f, "#include \"rna_define.c\"\n\n");
|
|
|
|
|
|
|
|
rna_generate_blender(brna, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f)
|
2009-02-02 19:57:57 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
StructRNA *srna;
|
2012-10-22 17:34:16 +00:00
|
|
|
FunctionDefRNA *dfunc;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2009-02-03 10:14:29 +00:00
|
|
|
fprintf(f, "\n#ifndef __RNA_BLENDER_H__\n");
|
|
|
|
fprintf(f, "#define __RNA_BLENDER_H__\n\n");
|
|
|
|
|
2012-03-09 18:28:30 +00:00
|
|
|
fprintf(f,
|
|
|
|
"/* Automatically generated function declarations for the Data API.\n"
|
|
|
|
" * Do not edit manually, changes will be overwritten. */\n\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "#include \"RNA_types.h\"\n\n");
|
|
|
|
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
|
|
|
|
|
2009-02-03 10:14:29 +00:00
|
|
|
fprintf(f, "#define FOREACH_BEGIN(property, sptr, itemptr) \\\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " { \\\n");
|
|
|
|
fprintf(f, " CollectionPropertyIterator rna_macro_iter; \\\n");
|
|
|
|
fprintf(f, " for (property##_begin(&rna_macro_iter, sptr); rna_macro_iter.valid; "
|
2012-05-12 11:01:29 +00:00
|
|
|
"property##_next(&rna_macro_iter)) { \\\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " itemptr = rna_macro_iter.ptr;\n\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2009-02-03 10:14:29 +00:00
|
|
|
fprintf(f, "#define FOREACH_END(property) \\\n");
|
2019-01-28 23:06:37 +11:00
|
|
|
fprintf(f, " } \\\n");
|
|
|
|
fprintf(f, " property##_end(&rna_macro_iter); \\\n");
|
|
|
|
fprintf(f, " }\n\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
|
|
|
srna = ds->srna;
|
2009-02-02 19:57:57 +00:00
|
|
|
|
|
|
|
fprintf(f, "/**************** %s ****************/\n\n", srna->name);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
while (srna) {
|
2009-02-02 19:57:57 +00:00
|
|
|
fprintf(f, "extern StructRNA RNA_%s;\n", srna->identifier);
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = srna->base;
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
fprintf(f, "\n");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_def_property_funcs_header(f, ds->srna, dp);
|
2012-10-22 17:34:16 +00:00
|
|
|
|
|
|
|
for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
|
|
|
|
rna_def_function_funcs_header(f, ds->srna, dfunc);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
2009-02-03 10:14:29 +00:00
|
|
|
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n");
|
|
|
|
|
|
|
|
fprintf(f, "#endif /* __RNA_BLENDER_H__ */\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *cpp_classes = ""
|
|
|
|
"\n"
|
2019-02-12 17:10:31 +01:00
|
|
|
"#include <stdlib.h> /* for malloc */\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"#include <string>\n"
|
2012-01-02 13:45:42 +00:00
|
|
|
"#include <string.h> /* for memcpy */\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
2011-05-18 12:56:58 +00:00
|
|
|
"namespace BL {\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define BOOLEAN_PROPERTY(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr) ? true: false; } \\\n"
|
|
|
|
" inline void sname::identifier(bool value) { sname##_##identifier##_set(&ptr, value); }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline Array<bool, size> sname::identifier(void) \\\n"
|
|
|
|
" { Array<bool, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
|
|
|
|
" inline void sname::identifier(bool values[size]) \\\n"
|
|
|
|
" { sname##_##identifier##_set(&ptr, values); } \\\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"\n"
|
|
|
|
"#define BOOLEAN_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline DynamicArray<bool> sname::identifier(void) { \\\n"
|
|
|
|
" int arraylen[3]; \\\n"
|
|
|
|
" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
|
|
|
|
" DynamicArray<bool> ar(len); \\\n"
|
|
|
|
" sname##_##identifier##_get(&ptr, ar.data); \\\n"
|
|
|
|
" return ar; } \\\n"
|
|
|
|
" inline void sname::identifier(bool values[]) \\\n"
|
|
|
|
" { sname##_##identifier##_set(&ptr, values); } \\\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define INT_PROPERTY(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
|
|
|
|
" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline Array<int, size> sname::identifier(void) \\\n"
|
|
|
|
" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
|
|
|
|
" inline void sname::identifier(int values[size]) \\\n"
|
|
|
|
" { sname##_##identifier##_set(&ptr, values); } \\\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"\n"
|
|
|
|
"#define INT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline DynamicArray<int> sname::identifier(void) { \\\n"
|
|
|
|
" int arraylen[3]; \\\n"
|
|
|
|
" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
|
|
|
|
" DynamicArray<int> ar(len); \\\n"
|
|
|
|
" sname##_##identifier##_get(&ptr, ar.data); \\\n"
|
|
|
|
" return ar; } \\\n"
|
|
|
|
" inline void sname::identifier(int values[]) \\\n"
|
|
|
|
" { sname##_##identifier##_set(&ptr, values); } \\\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define FLOAT_PROPERTY(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n"
|
|
|
|
" inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline Array<float, size> sname::identifier(void) \\\n"
|
|
|
|
" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n"
|
|
|
|
" inline void sname::identifier(float values[size]) \\\n"
|
|
|
|
" { sname##_##identifier##_set(&ptr, values); } \\\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"\n"
|
|
|
|
"#define FLOAT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline DynamicArray<float> sname::identifier(void) { \\\n"
|
|
|
|
" int arraylen[3]; \\\n"
|
|
|
|
" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n"
|
|
|
|
" DynamicArray<float> ar(len); \\\n"
|
|
|
|
" sname##_##identifier##_get(&ptr, ar.data); \\\n"
|
|
|
|
" return ar; } \\\n"
|
|
|
|
" inline void sname::identifier(float values[]) \\\n"
|
|
|
|
" { sname##_##identifier##_set(&ptr, values); } \\\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define ENUM_PROPERTY(type, sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); } \\\n"
|
|
|
|
" inline void sname::identifier(sname::type value) { sname##_##identifier##_set(&ptr, value); }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define STRING_PROPERTY(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline std::string sname::identifier(void) { \\\n"
|
|
|
|
" int len = sname##_##identifier##_length(&ptr); \\\n"
|
|
|
|
" std::string str; str.resize(len); \\\n"
|
|
|
|
" sname##_##identifier##_get(&ptr, &str[0]); return str; } \\\n"
|
|
|
|
" inline void sname::identifier(const std::string& value) { \\\n"
|
|
|
|
" sname##_##identifier##_set(&ptr, value.c_str()); } \\\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"#define POINTER_PROPERTY(type, sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
2014-04-01 16:46:38 +11:00
|
|
|
"#define COLLECTION_PROPERTY_LENGTH_false(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
|
|
|
|
" { \\\n"
|
|
|
|
" CollectionPropertyIterator iter; \\\n"
|
|
|
|
" int length = 0; \\\n"
|
|
|
|
" sname##_##identifier##_begin(&iter, ptr); \\\n"
|
|
|
|
" while (iter.valid) { \\\n"
|
|
|
|
" sname##_##identifier##_next(&iter); \\\n"
|
|
|
|
" ++length; \\\n"
|
|
|
|
" } \\\n"
|
|
|
|
" sname##_##identifier##_end(&iter); \\\n"
|
|
|
|
" return length; \\\n"
|
|
|
|
" } \n"
|
2014-04-01 16:46:38 +11:00
|
|
|
"#define COLLECTION_PROPERTY_LENGTH_true(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n"
|
|
|
|
" { return sname##_##identifier##_length(ptr); } \n"
|
2012-10-25 15:42:36 +00:00
|
|
|
"\n"
|
2014-04-01 16:46:38 +11:00
|
|
|
"#define COLLECTION_PROPERTY_LOOKUP_INT_false(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n"
|
|
|
|
" { \\\n"
|
|
|
|
" CollectionPropertyIterator iter; \\\n"
|
|
|
|
" int i = 0, found = 0; \\\n"
|
|
|
|
" sname##_##identifier##_begin(&iter, ptr); \\\n"
|
|
|
|
" while (iter.valid) { \\\n"
|
|
|
|
" if (i == key) { \\\n"
|
|
|
|
" *r_ptr = iter.ptr; \\\n"
|
|
|
|
" found = 1; \\\n"
|
|
|
|
" break; \\\n"
|
|
|
|
" } \\\n"
|
|
|
|
" sname##_##identifier##_next(&iter); \\\n"
|
|
|
|
" ++i; \\\n"
|
|
|
|
" } \\\n"
|
|
|
|
" sname##_##identifier##_end(&iter); \\\n"
|
|
|
|
" if (!found) \\\n"
|
|
|
|
" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
|
|
|
|
" return found; \\\n"
|
|
|
|
" } \n"
|
2014-04-01 16:46:38 +11:00
|
|
|
"#define COLLECTION_PROPERTY_LOOKUP_INT_true(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n"
|
|
|
|
" { \\\n"
|
|
|
|
" int found = sname##_##identifier##_lookup_int(ptr, key, r_ptr); \\\n"
|
|
|
|
" if (!found) \\\n"
|
|
|
|
" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
|
|
|
|
" return found; \\\n"
|
|
|
|
" } \n"
|
2014-04-01 16:46:38 +11:00
|
|
|
"#define COLLECTION_PROPERTY_LOOKUP_STRING_false(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n"
|
|
|
|
" { \\\n"
|
|
|
|
" CollectionPropertyIterator iter; \\\n"
|
|
|
|
" int found = 0; \\\n"
|
|
|
|
" PropertyRNA *item_name_prop = RNA_struct_name_property(ptr->type); \\\n"
|
|
|
|
" sname##_##identifier##_begin(&iter, ptr); \\\n"
|
|
|
|
" while (iter.valid && !found) { \\\n"
|
|
|
|
" char name_fixed[32]; \\\n"
|
|
|
|
" const char *name; \\\n"
|
|
|
|
" int name_length; \\\n"
|
|
|
|
" name = RNA_property_string_get_alloc(&iter.ptr, item_name_prop, name_fixed, sizeof(name_fixed), &name_length); \\\n"
|
|
|
|
" if (!strncmp(name, key, name_length)) { \\\n"
|
|
|
|
" *r_ptr = iter.ptr; \\\n"
|
|
|
|
" found = 1; \\\n"
|
|
|
|
" } \\\n"
|
|
|
|
" if (name_fixed != name) \\\n"
|
|
|
|
" MEM_freeN((void *) name); \\\n"
|
|
|
|
" sname##_##identifier##_next(&iter); \\\n"
|
|
|
|
" } \\\n"
|
|
|
|
" sname##_##identifier##_end(&iter); \\\n"
|
|
|
|
" if (!found) \\\n"
|
|
|
|
" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
|
|
|
|
" return found; \\\n"
|
|
|
|
" } \n"
|
2014-04-01 16:46:38 +11:00
|
|
|
"#define COLLECTION_PROPERTY_LOOKUP_STRING_true(sname, identifier) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n"
|
|
|
|
" { \\\n"
|
|
|
|
" int found = sname##_##identifier##_lookup_string(ptr, key, r_ptr); \\\n"
|
|
|
|
" if (!found) \\\n"
|
|
|
|
" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n"
|
|
|
|
" return found; \\\n"
|
|
|
|
" } \n"
|
2012-11-03 15:35:43 +00:00
|
|
|
"#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, has_lookup_int, has_lookup_string) \\\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n"
|
|
|
|
" sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n"
|
|
|
|
" COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n"
|
|
|
|
" COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n"
|
|
|
|
" COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n"
|
|
|
|
" CollectionRef<sname, type, sname##_##identifier##_begin, \\\n"
|
|
|
|
" sname##_##identifier##_next, sname##_##identifier##_end, \\\n"
|
|
|
|
" sname##_##identifier##_length_wrap, \\\n"
|
|
|
|
" sname##_##identifier##_lookup_int_wrap, sname##_##identifier##_lookup_string_wrap, collection_funcs> identifier;\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"class Pointer {\n"
|
|
|
|
"public:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" Pointer(const PointerRNA &p) : ptr(p) { }\n"
|
|
|
|
" operator const PointerRNA&() { return ptr; }\n"
|
|
|
|
" bool is_a(StructRNA *type) { return RNA_struct_is_a(ptr.type, type) ? true: false; }\n"
|
|
|
|
" operator void*() { return ptr.data; }\n"
|
|
|
|
" operator bool() { return ptr.data != NULL; }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" bool operator==(const Pointer &other) { return ptr.data == other.ptr.data; }\n"
|
|
|
|
" bool operator!=(const Pointer &other) { return ptr.data != other.ptr.data; }\n"
|
2017-11-15 07:11:01 -02:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" PointerRNA ptr;\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"};\n"
|
|
|
|
"\n"
|
|
|
|
"\n"
|
|
|
|
"template<typename T, int Tsize>\n"
|
|
|
|
"class Array {\n"
|
|
|
|
"public:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" T data[Tsize];\n"
|
2011-10-23 12:58:19 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" Array() {}\n"
|
|
|
|
" Array(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n"
|
|
|
|
" const Array<T, Tsize>& operator = (const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); "
|
2012-03-18 09:27:36 +00:00
|
|
|
"return *this; }\n"
|
2011-10-23 12:58:19 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" operator T*() { return data; }\n"
|
|
|
|
" operator const T*() const { return data; }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"};\n"
|
|
|
|
"\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"template<typename T>\n"
|
|
|
|
"class DynamicArray {\n"
|
|
|
|
"public:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" T *data;\n"
|
|
|
|
" int length;\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" DynamicArray() : data(NULL), length(0) {}\n"
|
|
|
|
" DynamicArray(int new_length) : data(NULL), length(new_length) { data = (T *)malloc(sizeof(T) * new_length); }\n"
|
|
|
|
" DynamicArray(const DynamicArray<T>& other) { copy_from(other); }\n"
|
|
|
|
" const DynamicArray<T>& operator = (const DynamicArray<T>& other) { copy_from(other); return *this; }\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" ~DynamicArray() { if (data) free(data); }\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" operator T*() { return data; }\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"\n"
|
|
|
|
"protected:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" void copy_from(const DynamicArray<T>& other) {\n"
|
|
|
|
" if (data) free(data);\n"
|
|
|
|
" data = (T *)malloc(sizeof(T) * other.length);\n"
|
|
|
|
" memcpy(data, other.data, sizeof(T) * other.length);\n"
|
|
|
|
" length = other.length;\n"
|
|
|
|
" }\n"
|
2012-10-22 17:34:16 +00:00
|
|
|
"};\n"
|
|
|
|
"\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"typedef void (*TBeginFunc)(CollectionPropertyIterator *iter, PointerRNA *ptr);\n"
|
|
|
|
"typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n"
|
|
|
|
"typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n"
|
2012-10-25 15:42:36 +00:00
|
|
|
"typedef int (*TLengthFunc)(PointerRNA *ptr);\n"
|
|
|
|
"typedef int (*TLookupIntFunc)(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n"
|
|
|
|
"typedef int (*TLookupStringFunc)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n"
|
|
|
|
"class CollectionIterator {\n"
|
|
|
|
"public:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" CollectionIterator() : iter(), t(iter.ptr), init(false) { iter.valid = false; }\n"
|
|
|
|
" ~CollectionIterator(void) { if (init) Tend(&iter); };\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" operator bool(void)\n"
|
|
|
|
" { return iter.valid != 0; }\n"
|
|
|
|
" const CollectionIterator<T, Tbegin, Tnext, Tend>& operator++() { Tnext(&iter); t = T(iter.ptr); return *this; }\n"
|
2011-05-18 12:56:58 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" T& operator*(void) { return t; }\n"
|
|
|
|
" T* operator->(void) { return &t; }\n"
|
|
|
|
" bool operator == (const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
|
2012-03-18 09:27:36 +00:00
|
|
|
"{ return iter.valid == other.iter.valid; }\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" bool operator!=(const CollectionIterator<T, Tbegin, Tnext, Tend>& other) "
|
2012-03-18 09:27:36 +00:00
|
|
|
"{ return iter.valid != other.iter.valid; }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" void begin(const Pointer &ptr)\n"
|
|
|
|
" { if (init) Tend(&iter); Tbegin(&iter, (PointerRNA *)&ptr.ptr); t = T(iter.ptr); init = true; }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"private:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" const CollectionIterator<T, Tbegin, Tnext, Tend>& operator = "
|
2016-12-20 10:23:55 +01:00
|
|
|
"(const CollectionIterator<T, Tbegin, Tnext, Tend>& /*copy*/) {}\n"
|
2011-10-23 12:58:19 +00:00
|
|
|
""
|
2019-01-28 23:06:37 +11:00
|
|
|
" CollectionPropertyIterator iter;\n"
|
|
|
|
" T t;\n"
|
|
|
|
" bool init;\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"};\n"
|
|
|
|
"\n"
|
2012-10-25 15:42:36 +00:00
|
|
|
"template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend,\n"
|
2012-11-03 15:35:43 +00:00
|
|
|
" TLengthFunc Tlength, TLookupIntFunc Tlookup_int, TLookupStringFunc Tlookup_string,\n"
|
|
|
|
" typename Tcollection_funcs>\n"
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
"class CollectionRef : public Tcollection_funcs {\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"public:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" CollectionRef(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" void begin(CollectionIterator<T, Tbegin, Tnext, Tend>& iter)\n"
|
|
|
|
" { iter.begin(ptr); }\n"
|
|
|
|
" CollectionIterator<T, Tbegin, Tnext, Tend> end()\n"
|
|
|
|
" { return CollectionIterator<T, Tbegin, Tnext, Tend>(); } /* test */ \n"
|
2012-10-25 15:42:36 +00:00
|
|
|
""
|
2019-01-28 23:06:37 +11:00
|
|
|
" int length()\n"
|
|
|
|
" { return Tlength(&ptr); }\n"
|
|
|
|
" T operator[](int key)\n"
|
|
|
|
" { PointerRNA r_ptr; Tlookup_int(&ptr, key, &r_ptr); return T(r_ptr); }\n"
|
|
|
|
" T operator[](const std::string &key)\n"
|
|
|
|
" { PointerRNA r_ptr; Tlookup_string(&ptr, key.c_str(), &r_ptr); return T(r_ptr); }\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n"
|
|
|
|
"private:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" PointerRNA ptr;\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"};\n"
|
2012-11-03 15:35:43 +00:00
|
|
|
"\n"
|
|
|
|
"class DefaultCollectionFunctions {\n"
|
|
|
|
"public:\n"
|
2019-01-28 23:06:37 +11:00
|
|
|
" DefaultCollectionFunctions(const PointerRNA & /*p*/) {}\n"
|
2012-11-03 15:35:43 +00:00
|
|
|
"};\n"
|
|
|
|
"\n"
|
2009-03-14 23:17:55 +00:00
|
|
|
"\n";
|
|
|
|
|
2012-11-03 15:35:43 +00:00
|
|
|
static int rna_is_collection_prop(PropertyRNA *prop)
|
|
|
|
{
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
if (!(prop->flag & PROP_IDPROPERTY || prop->flag_internal & PROP_INTERN_BUILTIN)) {
|
|
|
|
if (prop->type == PROP_COLLECTION) {
|
2012-11-03 15:35:43 +00:00
|
|
|
return 1;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
}
|
|
|
|
}
|
2012-11-03 15:35:43 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_is_collection_functions_struct(const char **collection_structs, const char *struct_name)
|
|
|
|
{
|
|
|
|
int a = 0, found = 0;
|
|
|
|
|
|
|
|
while (collection_structs[a]) {
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(collection_structs[a], struct_name)) {
|
2012-11-03 15:35:43 +00:00
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_generate_header_class_cpp(StructDefRNA *ds, FILE *f)
|
|
|
|
{
|
|
|
|
StructRNA *srna = ds->srna;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
FunctionDefRNA *dfunc;
|
|
|
|
|
|
|
|
fprintf(f, "/**************** %s ****************/\n\n", srna->name);
|
|
|
|
|
|
|
|
fprintf(f, "class %s : public %s {\n", srna->identifier, (srna->base) ? srna->base->identifier : "Pointer");
|
|
|
|
fprintf(f, "public:\n");
|
|
|
|
fprintf(f, "\t%s(const PointerRNA &ptr_arg) :\n\t\t%s(ptr_arg)", srna->identifier,
|
2012-11-09 09:33:28 +00:00
|
|
|
(srna->base) ? srna->base->identifier : "Pointer");
|
2012-11-03 15:35:43 +00:00
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next)
|
|
|
|
if (rna_is_collection_prop(dp->prop))
|
2012-11-09 09:33:28 +00:00
|
|
|
fprintf(f, ",\n\t\t%s(ptr_arg)", dp->prop->identifier);
|
2012-11-03 15:35:43 +00:00
|
|
|
fprintf(f, "\n\t\t{}\n\n");
|
|
|
|
|
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next)
|
|
|
|
rna_def_property_funcs_header_cpp(f, ds->srna, dp);
|
|
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
|
for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
|
|
|
|
rna_def_struct_function_header_cpp(f, srna, dfunc);
|
|
|
|
|
|
|
|
fprintf(f, "};\n\n");
|
|
|
|
}
|
|
|
|
|
2012-06-28 12:32:06 +00:00
|
|
|
static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f)
|
2009-03-14 23:17:55 +00:00
|
|
|
{
|
|
|
|
StructDefRNA *ds;
|
|
|
|
PropertyDefRNA *dp;
|
|
|
|
StructRNA *srna;
|
2012-10-22 17:34:16 +00:00
|
|
|
FunctionDefRNA *dfunc;
|
2012-11-03 15:35:43 +00:00
|
|
|
const char *first_collection_func_struct = NULL;
|
|
|
|
const char *collection_func_structs[256] = {NULL};
|
|
|
|
int all_collection_func_structs = 0;
|
|
|
|
int max_collection_func_structs = sizeof(collection_func_structs) / sizeof(collection_func_structs[0]) - 1;
|
2009-03-14 23:17:55 +00:00
|
|
|
|
|
|
|
fprintf(f, "\n#ifndef __RNA_BLENDER_CPP_H__\n");
|
|
|
|
fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n");
|
|
|
|
|
2012-03-09 18:28:30 +00:00
|
|
|
fprintf(f,
|
|
|
|
"/* Automatically generated classes for the Data API.\n"
|
|
|
|
" * Do not edit manually, changes will be overwritten. */\n\n");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "#include \"RNA_blender.h\"\n");
|
|
|
|
fprintf(f, "#include \"RNA_types.h\"\n");
|
2012-01-02 13:45:42 +00:00
|
|
|
fprintf(f, "#include \"RNA_access.h\"\n");
|
2009-03-14 23:17:55 +00:00
|
|
|
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
fprintf(f, "%s", cpp_classes);
|
2009-03-14 23:17:55 +00:00
|
|
|
|
|
|
|
fprintf(f, "/**************** Declarations ****************/\n\n");
|
|
|
|
|
2012-11-03 15:35:43 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "class %s;\n", ds->srna->identifier);
|
2012-11-03 15:35:43 +00:00
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "\n");
|
|
|
|
|
2012-11-03 15:35:43 +00:00
|
|
|
/* first get list of all structures used as collection functions, so they'll be declared first */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
2012-11-03 15:35:43 +00:00
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next) {
|
|
|
|
if (rna_is_collection_prop(dp->prop)) {
|
|
|
|
PropertyRNA *prop = dp->prop;
|
|
|
|
|
|
|
|
if (prop->srna) {
|
|
|
|
/* store name of structure which first uses custom functions for collections */
|
|
|
|
if (first_collection_func_struct == NULL)
|
|
|
|
first_collection_func_struct = ds->srna->identifier;
|
|
|
|
|
2012-12-28 14:19:05 +00:00
|
|
|
if (!rna_is_collection_functions_struct(collection_func_structs, (char *)prop->srna)) {
|
2012-11-03 15:35:43 +00:00
|
|
|
if (all_collection_func_structs >= max_collection_func_structs) {
|
|
|
|
printf("Array size to store all collection structures names is too small\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-12-28 14:19:05 +00:00
|
|
|
collection_func_structs[all_collection_func_structs++] = (char *)prop->srna;
|
2012-11-03 15:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-11-03 15:35:43 +00:00
|
|
|
/* declare all structures in such order:
|
|
|
|
* - first N structures which doesn't use custom functions for collections
|
|
|
|
* - all structures used for custom functions in collections
|
|
|
|
* - all the rest structures
|
|
|
|
* such an order prevents usage of non-declared classes
|
|
|
|
*/
|
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
|
|
|
srna = ds->srna;
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(srna->identifier, first_collection_func_struct)) {
|
2012-11-03 15:35:43 +00:00
|
|
|
StructDefRNA *ds2;
|
|
|
|
StructRNA *srna2;
|
2012-10-22 17:34:16 +00:00
|
|
|
|
2012-11-03 15:35:43 +00:00
|
|
|
for (ds2 = DefRNA.structs.first; ds2; ds2 = ds2->cont.next) {
|
|
|
|
srna2 = ds2->srna;
|
|
|
|
|
|
|
|
if (rna_is_collection_functions_struct(collection_func_structs, srna2->identifier)) {
|
|
|
|
rna_generate_header_class_cpp(ds2, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-22 17:34:16 +00:00
|
|
|
|
2012-11-03 15:35:43 +00:00
|
|
|
if (!rna_is_collection_functions_struct(collection_func_structs, srna->identifier))
|
|
|
|
rna_generate_header_class_cpp(ds, f);
|
2009-03-14 23:17:55 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "} /* namespace BL */\n");
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "\n");
|
2009-03-14 23:17:55 +00:00
|
|
|
fprintf(f, "/**************** Implementation ****************/\n");
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "\n");
|
|
|
|
|
|
|
|
fprintf(f, "/* Structure prototypes */\n\n");
|
|
|
|
fprintf(f, "extern \"C\" {\n");
|
2012-10-23 03:45:35 +00:00
|
|
|
rna_generate_struct_prototypes(f);
|
2012-10-22 17:34:16 +00:00
|
|
|
fprintf(f, "}\n\n");
|
|
|
|
|
|
|
|
fprintf(f, "namespace BL {\n");
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
|
2012-10-22 17:34:16 +00:00
|
|
|
srna = ds->srna;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (dp = ds->cont.properties.first; dp; dp = dp->next)
|
2009-04-07 00:49:39 +00:00
|
|
|
rna_def_property_funcs_impl_cpp(f, ds->srna, dp);
|
2009-03-14 23:17:55 +00:00
|
|
|
|
|
|
|
fprintf(f, "\n");
|
2012-10-22 17:34:16 +00:00
|
|
|
|
|
|
|
for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next)
|
|
|
|
rna_def_struct_function_impl_cpp(f, srna, dfunc);
|
|
|
|
|
|
|
|
fprintf(f, "\n");
|
2009-03-14 23:17:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n");
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2011-10-27 14:41:26 +00:00
|
|
|
static void make_bad_file(const char *file, int line)
|
2009-01-08 13:57:29 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
FILE *fp = fopen(file, "w");
|
2019-01-08 11:43:15 +01:00
|
|
|
fprintf(fp,
|
|
|
|
"#error \"Error! can't make correct RNA file from %s:%d, "
|
|
|
|
"check DNA properties.\"\n",
|
|
|
|
__FILE__, line);
|
2009-01-08 13:57:29 +00:00
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
2011-10-27 14:41:26 +00:00
|
|
|
static int rna_preprocess(const char *outfile)
|
2009-01-08 13:57:29 +00:00
|
|
|
{
|
|
|
|
BlenderRNA *brna;
|
|
|
|
StructDefRNA *ds;
|
|
|
|
FILE *file;
|
|
|
|
char deffile[4096];
|
2009-02-02 19:57:57 +00:00
|
|
|
int i, status;
|
2010-12-18 09:27:08 +00:00
|
|
|
const char *deps[3]; /* expand as needed */
|
2009-01-08 13:57:29 +00:00
|
|
|
|
|
|
|
/* define rna */
|
2012-03-05 23:30:41 +00:00
|
|
|
brna = RNA_create();
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (i = 0; PROCESS_ITEMS[i].filename; i++) {
|
|
|
|
if (PROCESS_ITEMS[i].define) {
|
2008-11-07 02:58:25 +00:00
|
|
|
PROCESS_ITEMS[i].define(brna);
|
2008-11-29 19:08:46 +00:00
|
|
|
|
2013-02-05 14:25:22 +00:00
|
|
|
/* sanity check */
|
|
|
|
if (!DefRNA.animate) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"Error: DefRNA.animate left disabled in %s\n",
|
|
|
|
PROCESS_ITEMS[i].filename);
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next)
|
|
|
|
if (!ds->filename)
|
|
|
|
ds->filename = PROCESS_ITEMS[i].filename;
|
2009-01-08 13:57:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
rna_auto_types();
|
2009-03-14 23:17:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
status = (DefRNA.error != 0);
|
2009-03-15 11:30:02 +00:00
|
|
|
|
2015-03-13 00:03:01 +11:00
|
|
|
/* create rna prototype header file */
|
|
|
|
strcpy(deffile, outfile);
|
|
|
|
strcat(deffile, "rna_prototypes_gen.h");
|
|
|
|
if (status) {
|
|
|
|
make_bad_file(deffile, __LINE__);
|
|
|
|
}
|
|
|
|
file = fopen(deffile, "w");
|
|
|
|
if (!file) {
|
|
|
|
fprintf(stderr, "Unable to open file: %s\n", deffile);
|
|
|
|
status = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(file,
|
|
|
|
"/* Automatically generated function declarations for the Data API.\n"
|
|
|
|
" * Do not edit manually, changes will be overwritten. */\n\n");
|
|
|
|
rna_generate_prototypes(brna, file);
|
|
|
|
fclose(file);
|
|
|
|
status = (DefRNA.error != 0);
|
|
|
|
}
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* create rna_gen_*.c files */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (i = 0; PROCESS_ITEMS[i].filename; i++) {
|
2009-01-08 13:57:29 +00:00
|
|
|
strcpy(deffile, outfile);
|
|
|
|
strcat(deffile, PROCESS_ITEMS[i].filename);
|
2012-05-12 11:01:29 +00:00
|
|
|
deffile[strlen(deffile) - 2] = '\0';
|
2010-01-17 14:04:40 +00:00
|
|
|
strcat(deffile, "_gen.c" TMP_EXT);
|
2009-01-08 13:57:29 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (status) {
|
2010-01-17 14:04:40 +00:00
|
|
|
make_bad_file(deffile, __LINE__);
|
2009-01-08 13:57:29 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
file = fopen(deffile, "w");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!file) {
|
2012-01-01 09:19:22 +00:00
|
|
|
fprintf(stderr, "Unable to open file: %s\n", deffile);
|
2009-01-08 13:57:29 +00:00
|
|
|
status = 1;
|
|
|
|
}
|
|
|
|
else {
|
2009-06-18 19:48:55 +00:00
|
|
|
rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename);
|
2009-01-08 13:57:29 +00:00
|
|
|
fclose(file);
|
2012-03-05 23:30:41 +00:00
|
|
|
status = (DefRNA.error != 0);
|
2009-01-08 13:57:29 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2010-12-18 09:27:08 +00:00
|
|
|
/* avoid unneeded rebuilds */
|
2012-03-05 23:30:41 +00:00
|
|
|
deps[0] = PROCESS_ITEMS[i].filename;
|
|
|
|
deps[1] = PROCESS_ITEMS[i].api_filename;
|
|
|
|
deps[2] = NULL;
|
2010-12-18 09:27:08 +00:00
|
|
|
|
|
|
|
replace_if_different(deffile, deps);
|
2009-01-08 13:57:29 +00:00
|
|
|
}
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2012-10-25 15:42:36 +00:00
|
|
|
/* create RNA_blender_cpp.h */
|
|
|
|
strcpy(deffile, outfile);
|
|
|
|
strcat(deffile, "RNA_blender_cpp.h" TMP_EXT);
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
make_bad_file(deffile, __LINE__);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
file = fopen(deffile, "w");
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
fprintf(stderr, "Unable to open file: %s\n", deffile);
|
|
|
|
status = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_generate_header_cpp(brna, file);
|
|
|
|
fclose(file);
|
|
|
|
status = (DefRNA.error != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
replace_if_different(deffile, NULL);
|
|
|
|
|
|
|
|
rna_sort(brna);
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* create RNA_blender.h */
|
|
|
|
strcpy(deffile, outfile);
|
2010-01-17 14:04:40 +00:00
|
|
|
strcat(deffile, "RNA_blender.h" TMP_EXT);
|
2009-02-02 19:57:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (status) {
|
2010-01-17 14:04:40 +00:00
|
|
|
make_bad_file(deffile, __LINE__);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
file = fopen(deffile, "w");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!file) {
|
2012-01-01 09:19:22 +00:00
|
|
|
fprintf(stderr, "Unable to open file: %s\n", deffile);
|
2009-02-02 19:57:57 +00:00
|
|
|
status = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rna_generate_header(brna, file);
|
|
|
|
fclose(file);
|
2012-03-05 23:30:41 +00:00
|
|
|
status = (DefRNA.error != 0);
|
2009-02-02 19:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-18 09:27:08 +00:00
|
|
|
replace_if_different(deffile, NULL);
|
2010-01-17 14:04:40 +00:00
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
/* free RNA */
|
2008-10-31 23:50:02 +00:00
|
|
|
RNA_define_free(brna);
|
|
|
|
RNA_free(brna);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2010-02-16 16:47:41 +00:00
|
|
|
static void mem_error_cb(const char *errorStr)
|
2009-04-07 00:49:39 +00:00
|
|
|
{
|
|
|
|
fprintf(stderr, "%s", errorStr);
|
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
2008-11-12 21:16:53 +00:00
|
|
|
int totblock, return_status = 0;
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2019-02-18 09:32:15 +11:00
|
|
|
CLG_init();
|
|
|
|
|
|
|
|
/* Some useful defaults since this runs standalone. */
|
|
|
|
CLG_output_use_basename_set(true);
|
|
|
|
CLG_level_set(debugSRNA);
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
if (argc < 2) {
|
2012-01-01 09:19:22 +00:00
|
|
|
fprintf(stderr, "Usage: %s outdirectory/\n", argv[0]);
|
2008-10-31 23:50:02 +00:00
|
|
|
return_status = 1;
|
|
|
|
}
|
|
|
|
else {
|
2017-11-28 20:27:40 +11:00
|
|
|
if (debugSRNA > 0) {
|
|
|
|
fprintf(stderr, "Running makesrna\n");
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
makesrna_path = argv[0];
|
|
|
|
return_status = rna_preprocess(argv[1]);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
|
|
|
|
2019-02-18 09:32:15 +11:00
|
|
|
CLG_exit();
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
totblock = MEM_get_memory_blocks_in_use();
|
|
|
|
if (totblock != 0) {
|
2012-04-29 15:47:02 +00:00
|
|
|
fprintf(stderr, "Error Totblock: %d\n", totblock);
|
2009-04-07 00:49:39 +00:00
|
|
|
MEM_set_error_callback(mem_error_cb);
|
2008-10-31 23:50:02 +00:00
|
|
|
MEM_printmemlist();
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_status;
|
|
|
|
}
|