Cleanup: ensure types signatures match for all custom RNA functions
Assign typed function variables to ensure the function signatures always match. This avoids ambiguity when types don't match and ensures any discrepancies are caught early. It also helps when changing types to ensure all callbacks have been updated.
This commit is contained in:
parent
4855f8cd9c
commit
aa308e166a
|
@ -788,7 +788,8 @@ static char *rna_def_property_get_func(
|
|||
fprintf(f, "RNA_EXTERN_C void %s(PointerRNA *ptr, char *value)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
if (manualfunc) {
|
||||
fprintf(f, " %s(ptr, value);\n", manualfunc);
|
||||
fprintf(f, " PropStringGetFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " fn(ptr, value);\n");
|
||||
}
|
||||
else {
|
||||
rna_print_data_get(f, dp);
|
||||
|
@ -826,7 +827,8 @@ static char *rna_def_property_get_func(
|
|||
fprintf(f, "RNA_EXTERN_C PointerRNA %s(PointerRNA *ptr)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
if (manualfunc) {
|
||||
fprintf(f, " return %s(ptr);\n", manualfunc);
|
||||
fprintf(f, " PropPointerGetFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " return fn(ptr);\n");
|
||||
}
|
||||
else {
|
||||
PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
|
||||
|
@ -864,7 +866,8 @@ static char *rna_def_property_get_func(
|
|||
manualfunc);
|
||||
}
|
||||
else {
|
||||
fprintf(f, " return %s(iter);\n", manualfunc);
|
||||
fprintf(f, " PropCollectionGetFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " return fn(iter);\n");
|
||||
}
|
||||
}
|
||||
fprintf(f, "}\n\n");
|
||||
|
@ -1172,7 +1175,8 @@ static char *rna_def_property_search_func(
|
|||
"blender::FunctionRef<void(StringPropertySearchVisitParams)> visit_fn)\n",
|
||||
func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, "\n %s(C, ptr, prop, edit_text, visit_fn);\n", manualfunc);
|
||||
fprintf(f, "\n StringPropertySearchFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, "\n fn(C, ptr, prop, edit_text, visit_fn);\n");
|
||||
fprintf(f, "}\n\n");
|
||||
return func;
|
||||
}
|
||||
|
@ -1207,7 +1211,8 @@ static char *rna_def_property_set_func(
|
|||
fprintf(f, "RNA_EXTERN_C void %s(PointerRNA *ptr, const char *value)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
if (manualfunc) {
|
||||
fprintf(f, " %s(ptr, value);\n", manualfunc);
|
||||
fprintf(f, " PropStringSetFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " fn(ptr, value);\n");
|
||||
}
|
||||
else {
|
||||
const PropertySubType subtype = prop->subtype;
|
||||
|
@ -1258,7 +1263,8 @@ static char *rna_def_property_set_func(
|
|||
func);
|
||||
fprintf(f, "{\n");
|
||||
if (manualfunc) {
|
||||
fprintf(f, " %s(ptr, value, reports);\n", manualfunc);
|
||||
fprintf(f, " PropPointerSetFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " fn(ptr, value, reports);\n");
|
||||
}
|
||||
else {
|
||||
rna_print_data_get(f, dp);
|
||||
|
@ -1517,7 +1523,8 @@ static char *rna_def_property_length_func(
|
|||
fprintf(f, "RNA_EXTERN_C int %s(PointerRNA *ptr)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
if (manualfunc) {
|
||||
fprintf(f, " return %s(ptr);\n", manualfunc);
|
||||
fprintf(f, " PropStringLengthFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " return fn(ptr);\n");
|
||||
}
|
||||
else {
|
||||
rna_print_data_get(f, dp);
|
||||
|
@ -1551,7 +1558,8 @@ static char *rna_def_property_length_func(
|
|||
fprintf(f, "RNA_EXTERN_C int %s(PointerRNA *ptr)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
if (manualfunc) {
|
||||
fprintf(f, " return %s(ptr);\n", manualfunc);
|
||||
fprintf(f, " PropCollectionLengthFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " return fn(ptr);\n");
|
||||
}
|
||||
else {
|
||||
if (dp->dnaarraylength <= 1 || dp->dnalengthname) {
|
||||
|
@ -1610,7 +1618,8 @@ static char *rna_def_property_begin_func(
|
|||
|
||||
if (dp->dnalengthname || dp->dnalengthfixed) {
|
||||
if (manualfunc) {
|
||||
fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
|
||||
fprintf(f, "\n PropCollectionBeginFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " fn(iter, ptr);\n");
|
||||
}
|
||||
else {
|
||||
if (dp->dnalengthname) {
|
||||
|
@ -1633,7 +1642,8 @@ static char *rna_def_property_begin_func(
|
|||
}
|
||||
else {
|
||||
if (manualfunc) {
|
||||
fprintf(f, "\n %s(iter, ptr);\n", manualfunc);
|
||||
fprintf(f, "\n PropCollectionBeginFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " fn(iter, ptr);\n");
|
||||
}
|
||||
else if (dp->dnapointerlevel == 0) {
|
||||
fprintf(f, "\n rna_iterator_listbase_begin(iter, &data->%s, nullptr);\n", dp->dnaname);
|
||||
|
@ -1690,7 +1700,8 @@ static char *rna_def_property_lookup_int_func(FILE *f,
|
|||
fprintf(f, "{\n");
|
||||
|
||||
if (manualfunc) {
|
||||
fprintf(f, "\n return %s(ptr, index, r_ptr);\n", manualfunc);
|
||||
fprintf(f, "\n PropCollectionLookupIntFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " return fn(ptr, index, r_ptr);\n");
|
||||
fprintf(f, "}\n\n");
|
||||
return func;
|
||||
}
|
||||
|
@ -1848,7 +1859,8 @@ static char *rna_def_property_lookup_string_func(FILE *f,
|
|||
fprintf(f, "{\n");
|
||||
|
||||
if (manualfunc) {
|
||||
fprintf(f, " return %s(ptr, key, r_ptr);\n", manualfunc);
|
||||
fprintf(f, " PropCollectionLookupStringFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " return fn(ptr, key, r_ptr);\n");
|
||||
fprintf(f, "}\n\n");
|
||||
return func;
|
||||
}
|
||||
|
@ -1921,7 +1933,8 @@ static char *rna_def_property_next_func(
|
|||
|
||||
fprintf(f, "RNA_EXTERN_C void %s(CollectionPropertyIterator *iter)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
fprintf(f, " %s(iter);\n", manualfunc);
|
||||
fprintf(f, " PropCollectionNextFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " fn(iter);\n");
|
||||
|
||||
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
|
||||
|
||||
|
@ -1948,7 +1961,8 @@ static char *rna_def_property_end_func(
|
|||
fprintf(f, "RNA_EXTERN_C void %s(CollectionPropertyIterator *iter)\n", func);
|
||||
fprintf(f, "{\n");
|
||||
if (manualfunc) {
|
||||
fprintf(f, " %s(iter);\n", manualfunc);
|
||||
fprintf(f, " PropCollectionEndFunc fn = %s;\n", manualfunc);
|
||||
fprintf(f, " fn(iter);\n");
|
||||
}
|
||||
fprintf(f, "}\n\n");
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ void rna_LayerCollection_children_begin(CollectionPropertyIterator *iter, Pointe
|
|||
rna_iterator_listbase_begin(iter, &lc->layer_collections, nullptr);
|
||||
}
|
||||
|
||||
static bool rna_LayerCollection_children_lookupint(PointerRNA *ptr, int key, PointerRNA *r_ptr)
|
||||
static int rna_LayerCollection_children_lookupint(PointerRNA *ptr, int key, PointerRNA *r_ptr)
|
||||
{
|
||||
Scene *scene = (Scene *)ptr->owner_id;
|
||||
LayerCollection *lc = (LayerCollection *)ptr->data;
|
||||
|
@ -402,9 +402,9 @@ static bool rna_LayerCollection_children_lookupint(PointerRNA *ptr, int key, Poi
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool rna_LayerCollection_children_lookupstring(PointerRNA *ptr,
|
||||
const char *key,
|
||||
PointerRNA *r_ptr)
|
||||
static int rna_LayerCollection_children_lookupstring(PointerRNA *ptr,
|
||||
const char *key,
|
||||
PointerRNA *r_ptr)
|
||||
{
|
||||
Scene *scene = (Scene *)ptr->owner_id;
|
||||
LayerCollection *lc = (LayerCollection *)ptr->data;
|
||||
|
|
|
@ -2847,7 +2847,7 @@ static PointerRNA rna_FileAssetSelectParams_filter_id_get(PointerRNA *ptr)
|
|||
return rna_pointer_inherit_refine(ptr, &RNA_FileAssetSelectIDFilter, ptr->data);
|
||||
}
|
||||
|
||||
static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(const PointerRNA *ptr)
|
||||
static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get_impl(const PointerRNA *ptr)
|
||||
{
|
||||
const FileDirEntry *entry = static_cast<const FileDirEntry *>(ptr->data);
|
||||
|
||||
|
@ -2879,7 +2879,7 @@ static int rna_FileBrowser_FileSelectEntry_name_editable(const PointerRNA *ptr,
|
|||
* message returned to `r_info` in some cases. */
|
||||
|
||||
if (entry->asset) {
|
||||
PointerRNA asset_data_ptr = rna_FileBrowser_FileSelectEntry_asset_data_get(ptr);
|
||||
PointerRNA asset_data_ptr = rna_FileBrowser_FileSelectEntry_asset_data_get_impl(ptr);
|
||||
/* Get disabled hint from asset metadata polling. */
|
||||
rna_AssetMetaData_editable(&asset_data_ptr, r_info);
|
||||
}
|
||||
|
@ -2887,6 +2887,11 @@ static int rna_FileBrowser_FileSelectEntry_name_editable(const PointerRNA *ptr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(PointerRNA *ptr)
|
||||
{
|
||||
return rna_FileBrowser_FileSelectEntry_asset_data_get_impl(ptr);
|
||||
}
|
||||
|
||||
static void rna_FileBrowser_FileSelectEntry_name_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
const FileDirEntry *entry = static_cast<const FileDirEntry *>(ptr->data);
|
||||
|
|
Loading…
Reference in New Issue