Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-03-11 06:42:39 +0300
committerCampbell Barton <campbell@blender.org>2022-03-11 06:42:39 +0300
commit1032f111d087e7ba77c16a4af78704019714bd6a (patch)
tree7e633bae3a64e48a938d36d62901538592b105f4 /source/blender/makesrna/intern/makesrna.c
parentf527d6582b2998df1ed2f68772941b1638adbc53 (diff)
RNA: support functions returning allocated strings
Now it's possible for a C/RNA function to return a dynamic string, The PROP_NEVER_NULL flag is also supported so a NULL string returns None in Python.
Diffstat (limited to 'source/blender/makesrna/intern/makesrna.c')
-rw-r--r--source/blender/makesrna/intern/makesrna.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 20261fb9eeb..3ea7f8e0df6 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2362,7 +2362,12 @@ static void rna_def_struct_function_prototype_cpp(FILE *f,
pout = (flag_parameter & PARM_OUTPUT);
if (flag & PROP_DYNAMIC) {
- ptrstr = pout ? "**" : "*";
+ if (type == PROP_STRING) {
+ ptrstr = pout ? "*" : "";
+ }
+ else {
+ ptrstr = pout ? "**" : "*";
+ }
}
else if (type == PROP_POINTER) {
ptrstr = pout ? "*" : "";
@@ -2853,7 +2858,12 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
/* XXX only arrays and strings are allowed to be dynamic, is this checked anywhere? */
}
else if (cptr || (flag & PROP_DYNAMIC)) {
- ptrstr = pout ? "**" : "*";
+ if (type == PROP_STRING) {
+ ptrstr = pout ? "*" : "";
+ }
+ else {
+ ptrstr = pout ? "**" : "*";
+ }
/* Fixed size arrays and RNA pointers are pre-allocated on the ParameterList stack,
* pass a pointer to it. */
}
@@ -2933,8 +2943,14 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
else {
const char *data_str;
if (cptr || (flag & PROP_DYNAMIC)) {
- ptrstr = "**";
- valstr = "*";
+ if (type == PROP_STRING) {
+ ptrstr = "*";
+ valstr = "";
+ }
+ else {
+ ptrstr = "**";
+ valstr = "*";
+ }
}
else if ((type == PROP_POINTER) && !(flag & PROP_THICK_WRAP)) {
ptrstr = "**";
@@ -3531,7 +3547,12 @@ static void rna_generate_static_parameter_prototypes(FILE *f,
}
if (cptr || (flag & PROP_DYNAMIC)) {
- ptrstr = pout ? "**" : "*";
+ if (type == PROP_STRING) {
+ ptrstr = pout ? "*" : "";
+ }
+ else {
+ ptrstr = pout ? "**" : "*";
+ }
}
else if (type == PROP_POINTER || dparm->prop->arraydimension) {
ptrstr = "*";