RNA: Generate property declerations header, solving msg-bus C++ incompatibility

Lets `makesrna` generate a `RNA_prototypes.h` header with declarations for all
RNA properties. This can be included in regular source files when needing to
reference RNA properties statically.

This solves an issue on MSVC with adding such declarations in functions, like
we used to do. See 800fc17367. Removes any such declarations and the related
FIXME comments.

Reviewed By: campbellbarton, LazyDodo, brecht

Differential Revision: https://developer.blender.org/D13837
This commit is contained in:
Julian Eisel 2022-03-14 16:39:42 +01:00
parent cff6eb6580
commit 9b298cf3db
Notes: blender-bot 2023-02-14 05:12:59 +01:00
Referenced by commit a5578351c3, Auto-generate RNA-structs declarations in `RNA_prototypes.h`
42 changed files with 183 additions and 114 deletions

View File

@ -14,6 +14,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -73,3 +75,6 @@ endif()
blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_gpencil bf_rna)

View File

@ -20,6 +20,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -104,3 +106,6 @@ endif()
blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_interface bf_rna)

View File

@ -26,6 +26,7 @@
#include "BKE_context.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "UI_interface.h"
@ -98,7 +99,6 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op)
band = ptr.data;
/* Set this to a sub-member of the property to trigger an update. */
extern PropertyRNA rna_ColorRamp_color_mode;
rna_update_ptr = ptr;
rna_update_prop = &rna_ColorRamp_color_mode;
is_undo = RNA_struct_undo_check(ptr.type);

View File

@ -59,6 +59,7 @@
#include "interface_intern.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "WM_api.h"
#include "WM_types.h"
@ -922,10 +923,8 @@ static void ui_apply_but_undo(uiBut *but)
if (but->rnapoin.owner_id) {
/* Exception for renaming ID data, we always need undo pushes in this case,
* because undo systems track data by their ID, see: T67002. */
extern PropertyRNA rna_ID_name;
/* Exception for active shape-key, since changing this in edit-mode updates
* the shape key from object mode data. */
extern PropertyRNA rna_Object_active_shape_key_index;
if (ELEM(but->rnaprop, &rna_ID_name, &rna_Object_active_shape_key_index)) {
/* pass */
}

View File

@ -19,6 +19,8 @@ set(INC
../../../../intern/clog
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -77,3 +79,6 @@ endif()
blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_mesh bf_rna)

View File

@ -26,6 +26,8 @@ set(INC
# dna_type_offsets.h in BLO_read_write.h
${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -80,3 +82,5 @@ endif()
blender_add_lib(bf_editor_object "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_dependencies(bf_editor_object bf_dna)
# RNA_prototypes.h
add_dependencies(bf_editor_object bf_rna)

View File

@ -14,6 +14,8 @@ set(INC
../../../../intern/glew-mx
../../../../intern/guardedalloc
../../../../intern/mantaflow/extern
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -54,3 +56,6 @@ endif()
blender_add_lib(bf_editor_physics "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_physics bf_rna)

View File

@ -17,6 +17,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -44,3 +46,6 @@ set(LIB
blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_screen bf_rna)

View File

@ -22,6 +22,8 @@ set(INC
../../../../intern/eigen
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -92,3 +94,6 @@ if(WITH_TBB)
endif()
blender_add_lib(bf_editor_sculpt_paint "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_sculpt_paint bf_rna)

View File

@ -11,6 +11,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -32,3 +34,6 @@ set(LIB
blender_add_lib(bf_editor_space_action "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_action bf_rna)

View File

@ -478,12 +478,6 @@ static void saction_main_region_message_subscribe(const wmRegionMessageSubscribe
/* Timeline depends on scene properties. */
{
bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
extern PropertyRNA rna_Scene_frame_start;
extern PropertyRNA rna_Scene_frame_end;
extern PropertyRNA rna_Scene_frame_preview_start;
extern PropertyRNA rna_Scene_frame_preview_end;
extern PropertyRNA rna_Scene_use_preview_range;
extern PropertyRNA rna_Scene_frame_current;
const PropertyRNA *props[] = {
use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,

View File

@ -11,6 +11,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -37,3 +39,6 @@ if(WITH_EXPERIMENTAL_FEATURES)
endif()
blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_buttons bf_rna)

View File

@ -17,6 +17,8 @@ set(INC
../../../../intern/atomic
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -83,3 +85,6 @@ if(WITH_FREESTYLE)
endif()
blender_add_lib(bf_editor_space_file "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_file bf_rna)

View File

@ -12,6 +12,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -48,3 +50,6 @@ endif()
blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_graph bf_rna)

View File

@ -477,12 +477,6 @@ static void graph_region_message_subscribe(const wmRegionMessageSubscribeParams
/* Timeline depends on scene properties. */
{
bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
extern PropertyRNA rna_Scene_frame_start;
extern PropertyRNA rna_Scene_frame_end;
extern PropertyRNA rna_Scene_frame_preview_start;
extern PropertyRNA rna_Scene_frame_preview_end;
extern PropertyRNA rna_Scene_use_preview_range;
extern PropertyRNA rna_Scene_frame_current;
const PropertyRNA *props[] = {
use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,

View File

@ -16,6 +16,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -35,3 +37,6 @@ set(LIB
blender_add_lib(bf_editor_space_info "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_info bf_rna)

View File

@ -12,6 +12,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -34,3 +36,6 @@ set(LIB
blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_nla bf_rna)

View File

@ -424,12 +424,6 @@ static void nla_main_region_message_subscribe(const wmRegionMessageSubscribePara
/* Timeline depends on scene properties. */
{
bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
extern PropertyRNA rna_Scene_frame_start;
extern PropertyRNA rna_Scene_frame_end;
extern PropertyRNA rna_Scene_frame_preview_start;
extern PropertyRNA rna_Scene_frame_preview_end;
extern PropertyRNA rna_Scene_use_preview_range;
extern PropertyRNA rna_Scene_frame_current;
const PropertyRNA *props[] = {
use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,

View File

@ -15,6 +15,8 @@ set(INC
../../../../intern/clog
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -82,3 +84,6 @@ set(LIB
blender_add_lib(bf_editor_space_outliner "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_outliner bf_rna)

View File

@ -391,8 +391,6 @@ void outliner_collection_delete(
BLI_gset_free(data.collections_to_edit, nullptr);
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static int collection_hierarchy_delete_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@ -416,7 +414,6 @@ static int collection_hierarchy_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
}
void OUTLINER_OT_collection_hierarchy_delete(wmOperatorType *ot)
{

View File

@ -660,8 +660,6 @@ static void scenes__collection_set_flag_recursive_fn(bContext *C, void *poin, vo
outliner_collection_set_flag_recursive_fn(C, nullptr, collection, propname);
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static void namebutton_fn(bContext *C, void *tsep, char *oldname)
{
Main *bmain = CTX_data_main(C);
@ -859,7 +857,6 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
tselem->flag &= ~TSE_TEXTBUT;
}
}
}
struct RestrictProperties {
bool initialized;

View File

@ -1719,8 +1719,6 @@ static TreeTraversalAction outliner_find_objects_to_delete(TreeElement *te, void
return TRAVERSE_CONTINUE;
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static int outliner_delete_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@ -1780,7 +1778,6 @@ static int outliner_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
}
void OUTLINER_OT_delete(wmOperatorType *ot)
{

View File

@ -259,8 +259,6 @@ static void outliner_main_region_listener(const wmRegionListenerParams *params)
}
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static void outliner_main_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
struct wmMsgBus *mbus = params->message_bus;
@ -277,7 +275,6 @@ static void outliner_main_region_message_subscribe(const wmRegionMessageSubscrib
WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw);
}
}
}
/* ************************ header outliner area region *********************** */

View File

@ -17,6 +17,8 @@ set(INC
../../../../intern/atomic
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -57,3 +59,6 @@ endif()
blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_sequencer bf_rna)

View File

@ -690,12 +690,6 @@ static void sequencer_main_region_message_subscribe(const wmRegionMessageSubscri
/* Timeline depends on scene properties. */
{
bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
extern PropertyRNA rna_Scene_frame_start;
extern PropertyRNA rna_Scene_frame_end;
extern PropertyRNA rna_Scene_frame_preview_start;
extern PropertyRNA rna_Scene_frame_preview_end;
extern PropertyRNA rna_Scene_use_preview_range;
extern PropertyRNA rna_Scene_frame_current;
const PropertyRNA *props[] = {
use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,

View File

@ -12,6 +12,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -26,3 +28,6 @@ set(LIB
blender_add_lib(bf_editor_space_statusbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_statusbar bf_rna)

View File

@ -12,6 +12,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -24,3 +26,7 @@ set(LIB
blender_add_lib(bf_editor_space_topbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_space_topbar bf_rna)

View File

@ -21,6 +21,8 @@ set(INC
# dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -90,3 +92,5 @@ blender_add_lib(bf_editor_space_view3d "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# Needed so we can use dna_type_offsets.h for defaults initialization.
add_dependencies(bf_editor_space_view3d bf_dna)
# RNA_prototypes.h
add_dependencies(bf_editor_space_view3d bf_rna)

View File

@ -251,16 +251,6 @@ static void WIDGETGROUP_camera_message_subscribe(const bContext *C,
};
{
extern PropertyRNA rna_CameraDOFSettings_focus_distance;
extern PropertyRNA rna_Camera_display_size;
extern PropertyRNA rna_Camera_ortho_scale;
extern PropertyRNA rna_Camera_sensor_fit;
extern PropertyRNA rna_Camera_sensor_width;
extern PropertyRNA rna_Camera_sensor_height;
extern PropertyRNA rna_Camera_shift_x;
extern PropertyRNA rna_Camera_shift_y;
extern PropertyRNA rna_Camera_type;
extern PropertyRNA rna_Camera_lens;
const PropertyRNA *props[] = {
&rna_CameraDOFSettings_focus_distance,
&rna_Camera_display_size,

View File

@ -173,7 +173,6 @@ static void WIDGETGROUP_gizmo_message_subscribe(const bContext *C,
};
{
extern PropertyRNA rna_ToolSettings_workspace_tool_type;
const PropertyRNA *props[] = {
&rna_ToolSettings_workspace_tool_type,
};

View File

@ -17,6 +17,8 @@ set(INC
../../windowmanager
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -112,3 +114,6 @@ set(LIB
blender_add_lib(bf_editor_transform "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_transform bf_rna)

View File

@ -116,8 +116,6 @@ static void gizmo2d_pivot_point_message_subscribe(struct wmGizmoGroup *gzgroup,
PointerRNA ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceImageEditor, sima, &ptr);
{
extern PropertyRNA rna_SpaceImageEditor_pivot_point;
extern PropertyRNA rna_SpaceImageEditor_cursor_location;
const PropertyRNA *props[] = {
&rna_SpaceImageEditor_pivot_point,
(sima->around == V3D_AROUND_CURSOR) ? &rna_SpaceImageEditor_cursor_location : NULL,

View File

@ -1187,7 +1187,6 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup,
PointerRNA scene_ptr;
RNA_id_pointer_create(&scene->id, &scene_ptr);
{
extern PropertyRNA rna_Scene_transform_orientation_slots;
const PropertyRNA *props[] = {
&rna_Scene_transform_orientation_slots,
};
@ -1205,8 +1204,6 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup,
}
{
extern PropertyRNA rna_TransformOrientationSlot_type;
extern PropertyRNA rna_TransformOrientationSlot_use;
const PropertyRNA *props[] = {
&rna_TransformOrientationSlot_type,
&rna_TransformOrientationSlot_use,
@ -1223,7 +1220,6 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup,
RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr);
if (ELEM(type_fn, VIEW3D_GGT_xform_gizmo, VIEW3D_GGT_xform_shear)) {
extern PropertyRNA rna_ToolSettings_transform_pivot_point;
const PropertyRNA *props[] = {
&rna_ToolSettings_transform_pivot_point,
};
@ -1234,7 +1230,6 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup,
}
{
extern PropertyRNA rna_ToolSettings_workspace_tool_type;
const PropertyRNA *props[] = {
&rna_ToolSettings_workspace_tool_type,
};
@ -1250,9 +1245,6 @@ static void gizmo_xform_message_subscribe(wmGizmoGroup *gzgroup,
if (type_fn == VIEW3D_GGT_xform_gizmo) {
GizmoGroup *ggd = gzgroup->customdata;
if (ggd->use_twtype_refresh) {
extern PropertyRNA rna_SpaceView3D_show_gizmo_object_translate;
extern PropertyRNA rna_SpaceView3D_show_gizmo_object_rotate;
extern PropertyRNA rna_SpaceView3D_show_gizmo_object_scale;
const PropertyRNA *props[] = {
&rna_SpaceView3D_show_gizmo_object_translate,
&rna_SpaceView3D_show_gizmo_object_rotate,

View File

@ -485,7 +485,6 @@ static void gizmo_mesh_extrude_message_subscribe(const bContext *C,
Scene *scene = CTX_data_scene(C);
PointerRNA toolsettings_ptr;
RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr);
extern PropertyRNA rna_ToolSettings_workspace_tool_type;
const PropertyRNA *props[] = {
&rna_ToolSettings_workspace_tool_type,
};

View File

@ -14,6 +14,8 @@ set(INC
../../../../intern/eigen
../../../../intern/glew-mx
../../../../intern/guardedalloc
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
@ -39,3 +41,6 @@ set(LIB
blender_add_lib(bf_editor_uvedit "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_editor_uvedit bf_rna)

View File

@ -122,6 +122,7 @@ set(APISRC
string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
list(APPEND GENSRC
"${CMAKE_CURRENT_BINARY_DIR}/rna_prototypes_gen.h"
"${CMAKE_CURRENT_BINARY_DIR}/../RNA_prototypes.h"
)
set_source_files_properties(${GENSRC} PROPERTIES GENERATED TRUE)
@ -188,6 +189,8 @@ set(INC
# dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
# RNA_prototypes.h
${CMAKE_CURRENT_BINARY_DIR}/../../makesrna/
)
set(INC_SYS
@ -402,7 +405,7 @@ endif()
# note (linux only): with crashes try add this after COMMAND: valgrind --leak-check=full --track-origins=yes
add_custom_command(
OUTPUT ${GENSRC}
COMMAND "$<TARGET_FILE:makesrna>" ${CMAKE_CURRENT_BINARY_DIR}/
COMMAND "$<TARGET_FILE:makesrna>" ${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/../
DEPENDS makesrna
)

View File

@ -3304,7 +3304,7 @@ static const char *rna_property_subtype_unit(PropertySubType type)
}
}
static void rna_generate_prototypes(BlenderRNA *brna, FILE *f)
static void rna_generate_internal_struct_prototypes(BlenderRNA *brna, FILE *f)
{
StructRNA *srna;
@ -3343,7 +3343,19 @@ static void rna_generate_blender(BlenderRNA *brna, FILE *f)
"};\n\n");
}
static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f)
static void rna_generate_external_property_prototypes(BlenderRNA *brna, FILE *f)
{
for (StructRNA *srna = brna->structs.first; srna; srna = srna->cont.next) {
for (PropertyRNA *prop = srna->cont.properties.first; prop; prop = prop->next) {
fprintf(f, "extern struct PropertyRNA rna_%s_%s;\n", srna->identifier, prop->identifier);
}
fprintf(f, "\n");
}
}
static void rna_generate_internal_property_prototypes(BlenderRNA *UNUSED(brna),
StructRNA *srna,
FILE *f)
{
PropertyRNA *prop;
StructRNA *base;
@ -4499,7 +4511,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) {
if (!filename || ds->filename == filename) {
rna_generate_property_prototypes(brna, ds->srna, f);
rna_generate_internal_property_prototypes(brna, ds->srna, f);
rna_generate_function_prototypes(brna, ds->srna, f);
}
}
@ -5128,7 +5140,11 @@ static void make_bad_file(const char *file, int line)
fclose(fp);
}
static int rna_preprocess(const char *outfile)
/**
* \param extern_outfile: Directory to put public headers into. Can be NULL, in which case
* everything is put into \a outfile.
*/
static int rna_preprocess(const char *outfile, const char *public_header_outfile)
{
BlenderRNA *brna;
StructDefRNA *ds;
@ -5137,6 +5153,10 @@ static int rna_preprocess(const char *outfile)
int i, status;
const char *deps[3]; /* expand as needed */
if (!public_header_outfile) {
public_header_outfile = outfile;
}
/* define rna */
brna = RNA_create();
@ -5161,7 +5181,36 @@ static int rna_preprocess(const char *outfile)
status = (DefRNA.error != 0);
/* create rna prototype header file */
/* Create external rna struct prototype header file RNA_prototypes.h. */
strcpy(deffile, public_header_outfile);
strcat(deffile, "RNA_prototypes.h" TMP_EXT);
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 RNA property declarations, to statically reference \n"
" * properties as `rna_[struct-name]_[property-name]`.\n"
" *\n"
" * DO NOT EDIT MANUALLY, changes will be overwritten.\n"
" */\n\n");
fprintf(file, "#pragma once\n\n");
fprintf(file, "#ifdef __cplusplus\n extern \"C\" {\n#endif\n\n");
rna_generate_external_property_prototypes(brna, file);
fprintf(file, "#ifdef __cplusplus\n }\n#endif\n");
fclose(file);
status = (DefRNA.error != 0);
replace_if_different(deffile, NULL);
}
/* create internal rna struct prototype header file */
strcpy(deffile, outfile);
strcat(deffile, "rna_prototypes_gen.h");
if (status) {
@ -5176,7 +5225,7 @@ static int rna_preprocess(const char *outfile)
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);
rna_generate_internal_struct_prototypes(brna, file);
fclose(file);
status = (DefRNA.error != 0);
}
@ -5288,7 +5337,7 @@ int main(int argc, char **argv)
CLG_level_set(debugSRNA);
if (argc < 2) {
fprintf(stderr, "Usage: %s outdirectory/\n", argv[0]);
fprintf(stderr, "Usage: %s outdirectory [public header outdirectory]/\n", argv[0]);
return_status = 1;
}
else {
@ -5296,7 +5345,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Running makesrna\n");
}
makesrna_path = argv[0];
return_status = rna_preprocess(argv[1]);
return_status = rna_preprocess(argv[1], (argc > 2) ? argv[2] : NULL);
}
CLG_exit();

View File

@ -400,28 +400,28 @@ static bool rna_idproperty_verify_valid(PointerRNA *ptr, PropertyRNA *prop, IDPr
}
static PropertyRNA *typemap[IDP_NUMTYPES] = {
(PropertyRNA *)&rna_PropertyGroupItem_string,
(PropertyRNA *)&rna_PropertyGroupItem_int,
(PropertyRNA *)&rna_PropertyGroupItem_float,
&rna_PropertyGroupItem_string,
&rna_PropertyGroupItem_int,
&rna_PropertyGroupItem_float,
NULL,
NULL,
NULL,
(PropertyRNA *)&rna_PropertyGroupItem_group,
(PropertyRNA *)&rna_PropertyGroupItem_id,
(PropertyRNA *)&rna_PropertyGroupItem_double,
(PropertyRNA *)&rna_PropertyGroupItem_idp_array,
&rna_PropertyGroupItem_group,
&rna_PropertyGroupItem_id,
&rna_PropertyGroupItem_double,
&rna_PropertyGroupItem_idp_array,
};
static PropertyRNA *arraytypemap[IDP_NUMTYPES] = {
NULL,
(PropertyRNA *)&rna_PropertyGroupItem_int_array,
(PropertyRNA *)&rna_PropertyGroupItem_float_array,
&rna_PropertyGroupItem_int_array,
&rna_PropertyGroupItem_float_array,
NULL,
NULL,
NULL,
(PropertyRNA *)&rna_PropertyGroupItem_collection,
&rna_PropertyGroupItem_collection,
NULL,
(PropertyRNA *)&rna_PropertyGroupItem_double_array,
&rna_PropertyGroupItem_double_array,
};
void rna_property_rna_or_id_get(PropertyRNA *prop,

View File

@ -493,18 +493,6 @@ void RNA_def_main_simulations(BlenderRNA *brna, PropertyRNA *cprop);
/* ID Properties */
extern StringPropertyRNA rna_PropertyGroupItem_string;
extern IntPropertyRNA rna_PropertyGroupItem_int;
extern IntPropertyRNA rna_PropertyGroupItem_int_array;
extern FloatPropertyRNA rna_PropertyGroupItem_float;
extern FloatPropertyRNA rna_PropertyGroupItem_float_array;
extern PointerPropertyRNA rna_PropertyGroupItem_group;
extern PointerPropertyRNA rna_PropertyGroupItem_id;
extern CollectionPropertyRNA rna_PropertyGroupItem_collection;
extern CollectionPropertyRNA rna_PropertyGroupItem_idp_array;
extern FloatPropertyRNA rna_PropertyGroupItem_double;
extern FloatPropertyRNA rna_PropertyGroupItem_double_array;
#ifndef __RNA_ACCESS_H__
extern StructRNA RNA_PropertyGroupItem;
extern StructRNA RNA_PropertyGroup;

View File

@ -18,6 +18,8 @@ set(INC
../../../../intern/guardedalloc
../../../../intern/mantaflow/extern
../../../../intern/opencolorio
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(INC_SYS
@ -357,3 +359,6 @@ if(WITH_HARU)
endif()
blender_add_lib(bf_python "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# RNA_prototypes.h
add_dependencies(bf_python bf_rna)

View File

@ -29,6 +29,8 @@ set(INC
# for writefile.c: dna_type_offsets.h
${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
# RNA_prototypes.h
${CMAKE_BINARY_DIR}/source/blender/makesrna
)
set(SRC
@ -193,3 +195,5 @@ blender_add_lib_nolist(bf_windowmanager "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# Needed so we can use dna_type_offsets.h for defaults initialization.
add_dependencies(bf_windowmanager bf_dna)
# RNA_prototypes.h
add_dependencies(bf_windowmanager bf_rna)

View File

@ -6,6 +6,7 @@
#pragma once
#include "RNA_prototypes.h"
#include "RNA_types.h"
#include <stdio.h>
@ -230,23 +231,9 @@ void WM_msg_subscribe_ID(struct wmMsgBus *mbus,
const char *id_repr);
void WM_msg_publish_ID(struct wmMsgBus *mbus, struct ID *id);
/* FIXME
*
* For C++ code, some of the following macros need to be called in functions wrapped in
* `extern "C"` blocks. That is, the ones doing `extern PropertyRNA` declarations (trips up the
* MSVC linker).
* Although this shouldn't cause problems normally, if it does, the bits calling the macros can be
* moved to a separate function wrapped in `extern "C"`.
*
* Obviously this should be fixed properly (by not relying on inline `extern` declarations).
*/
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_) \
{ \
wmMsgParams_RNA msg_key_params_ = {{0}}; \
_WM_MESSAGE_EXTERN_BEGIN; \
extern PropertyRNA rna_##type_##_##prop_; \
_WM_MESSAGE_EXTERN_END; \
RNA_pointer_create(id_, &RNA_##type_, data_, &msg_key_params_.ptr); \
msg_key_params_.prop = &rna_##type_##_##prop_; \
WM_msg_publish_rna_params(mbus, &msg_key_params_); \
@ -255,9 +242,6 @@ void WM_msg_publish_ID(struct wmMsgBus *mbus, struct ID *id);
#define WM_msg_subscribe_rna_prop(mbus, id_, data_, type_, prop_, value) \
{ \
wmMsgParams_RNA msg_key_params_ = {{0}}; \
_WM_MESSAGE_EXTERN_BEGIN; \
extern PropertyRNA rna_##type_##_##prop_; \
_WM_MESSAGE_EXTERN_END; \
RNA_pointer_create(id_, &RNA_##type_, data_, &msg_key_params_.ptr); \
msg_key_params_.prop = &rna_##type_##_##prop_; \
WM_msg_subscribe_rna_params(mbus, &msg_key_params_, value, __func__); \
@ -276,10 +260,6 @@ void WM_msg_publish_ID(struct wmMsgBus *mbus, struct ID *id);
((void)0)
#define WM_msg_subscribe_rna_anon_prop(mbus, type_, prop_, value) \
{ \
_WM_MESSAGE_EXTERN_BEGIN; \
extern PropertyRNA rna_##type_##_##prop_; \
_WM_MESSAGE_EXTERN_END; \
\
PointerRNA msg_ptr_ = {0, &RNA_##type_}; \
wmMsgParams_RNA msg_key_params_ = {{0}}; \
msg_key_params_.ptr = msg_ptr_; \