Refactor: rename SpaceType->new to SpaceType->create

The data member `new` was conflicting with the `new` keyword
when `BKE_screen.h` was included in C++ files.

Reviewers: sergey

Differential Revision: https://developer.blender.org/D8459
This commit is contained in:
Jacques Lucke 2020-08-04 14:39:53 +02:00
parent 7fbbe71922
commit 675fa2ee13
27 changed files with 46 additions and 64 deletions

View File

@ -73,7 +73,7 @@ typedef struct SpaceType {
/* Initial allocation, after this WM will call init() too. Some editors need
* area and scene data (e.g. frame range) to set their initial scrolling. */
struct SpaceLink *(*new)(const struct ScrArea *area, const struct Scene *scene);
struct SpaceLink *(*create)(const struct ScrArea *area, const struct Scene *scene);
/* not free spacelink itself */
void (*free)(struct SpaceLink *sl);

View File

@ -190,7 +190,7 @@ static void do_version_workspaces_create_from_screens(Main *bmain)
static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene)
{
SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION);
SpaceAction *saction = (SpaceAction *)stype->new (area, scene);
SpaceAction *saction = (SpaceAction *)stype->create(area, scene);
ARegion *region_channels;
/* Properly free current regions */

View File

@ -48,11 +48,8 @@
#include "BKE_idtype.h"
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_workspace.h"
#define new new_
#include "BKE_screen.h"
#undef new
#include "BKE_workspace.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_debug.h"

View File

@ -2126,7 +2126,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
area->spacetype = type;
area->type = st;
/* If st->new may be called, don't use context until then. The
/* If st->create may be called, don't use context until then. The
* area->type->context() callback has changed but data may be invalid
* (e.g. with properties editor) until space-data is properly created */
@ -2166,7 +2166,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
if (st) {
/* Don't get scene from context here which may depend on space-data. */
Scene *scene = WM_window_get_active_scene(win);
sl = st->new (area, scene);
sl = st->create(area, scene);
BLI_addhead(&area->spacedata, sl);
/* swap regions */

View File

@ -897,7 +897,7 @@ static void screen_global_area_refresh(wmWindow *win,
else {
area = screen_area_create_with_geometry(&win->global_areas, rect, space_type);
SpaceType *stype = BKE_spacetype_from_id(space_type);
SpaceLink *slink = stype->new (area, WM_window_get_active_scene(win));
SpaceLink *slink = stype->create(area, WM_window_get_active_scene(win));
area->regionbase = slink->regionbase;

View File

@ -60,7 +60,7 @@
/* ******************** default callbacks for action space ***************** */
static SpaceLink *action_new(const ScrArea *area, const Scene *scene)
static SpaceLink *action_create(const ScrArea *area, const Scene *scene)
{
SpaceAction *saction;
ARegion *region;
@ -863,7 +863,7 @@ void ED_spacetype_action(void)
st->spaceid = SPACE_ACTION;
strncpy(st->name, "Action", BKE_ST_MAXNAME);
st->new = action_new;
st->create = action_create;
st->free = action_free;
st->init = action_init;
st->duplicate = action_duplicate;

View File

@ -280,7 +280,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type)
void ED_spacetype_xxx(void);
/* allocate and init some vars */
static SpaceLink *xxx_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *xxx_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
return NULL;
}
@ -324,7 +324,7 @@ void ED_spacetype_xxx(void)
st.spaceid = SPACE_VIEW3D;
st.new = xxx_new;
st.create = xxx_create;
st.free = xxx_free;
st.init = xxx_init;
st.duplicate = xxx_duplicate;

View File

@ -54,7 +54,7 @@
/* ******************** default callbacks for buttons space ***************** */
static SpaceLink *buttons_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *buttons_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceProperties *sbuts;
@ -699,7 +699,7 @@ void ED_spacetype_buttons(void)
st->spaceid = SPACE_PROPERTIES;
strncpy(st->name, "Buttons", BKE_ST_MAXNAME);
st->new = buttons_new;
st->create = buttons_create;
st->free = buttons_free;
st->init = buttons_init;
st->duplicate = buttons_duplicate;

View File

@ -237,7 +237,7 @@ static void clip_area_sync_frame_from_scene(ScrArea *area, Scene *scene)
/* ******************** default callbacks for clip space ***************** */
static SpaceLink *clip_new(const ScrArea *area, const Scene *scene)
static SpaceLink *clip_create(const ScrArea *area, const Scene *scene)
{
ARegion *region;
SpaceClip *sc;
@ -1351,7 +1351,7 @@ void ED_spacetype_clip(void)
st->spaceid = SPACE_CLIP;
strncpy(st->name, "Clip", BKE_ST_MAXNAME);
st->new = clip_new;
st->create = clip_create;
st->free = clip_free;
st->init = clip_init;
st->duplicate = clip_duplicate;

View File

@ -46,7 +46,7 @@
/* ******************** default callbacks for console space ***************** */
static SpaceLink *console_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *console_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceConsole *sconsole;
@ -312,7 +312,7 @@ void ED_spacetype_console(void)
st->spaceid = SPACE_CONSOLE;
strncpy(st->name, "Console", BKE_ST_MAXNAME);
st->new = console_new;
st->create = console_create;
st->free = console_free;
st->init = console_init;
st->duplicate = console_duplicate;

View File

@ -91,7 +91,7 @@ static ARegion *file_tool_props_region_ensure(ScrArea *area, ARegion *region_pre
/* ******************** default callbacks for file space ***************** */
static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *file_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceFile *sfile;
@ -693,7 +693,7 @@ void ED_spacetype_file(void)
st->spaceid = SPACE_FILE;
strncpy(st->name, "File", BKE_ST_MAXNAME);
st->new = file_new;
st->create = file_create;
st->free = file_free;
st->init = file_init;
st->exit = file_exit;

View File

@ -64,7 +64,7 @@
/* ******************** default callbacks for ipo space ***************** */
static SpaceLink *graph_new(const ScrArea *UNUSED(area), const Scene *scene)
static SpaceLink *graph_create(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
SpaceGraph *sipo;
@ -838,7 +838,7 @@ void ED_spacetype_ipo(void)
st->spaceid = SPACE_GRAPH;
strncpy(st->name, "Graph", BKE_ST_MAXNAME);
st->new = graph_new;
st->create = graph_create;
st->free = graph_free;
st->init = graph_init;
st->duplicate = graph_duplicate;

View File

@ -117,7 +117,7 @@ static void image_user_refresh_scene(const bContext *C, SpaceImage *sima)
/* ******************** default callbacks for image space ***************** */
static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceImage *simage;
@ -1093,7 +1093,7 @@ void ED_spacetype_image(void)
st->spaceid = SPACE_IMAGE;
strncpy(st->name, "Image", BKE_ST_MAXNAME);
st->new = image_new;
st->create = image_create;
st->free = image_free;
st->init = image_init;
st->duplicate = image_duplicate;

View File

@ -53,7 +53,7 @@
/* ******************** default callbacks for info space ***************** */
static SpaceLink *info_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *info_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceInfo *sinfo;
@ -287,7 +287,7 @@ void ED_spacetype_info(void)
st->spaceid = SPACE_INFO;
strncpy(st->name, "Info", BKE_ST_MAXNAME);
st->new = info_new;
st->create = info_create;
st->free = info_free;
st->init = info_init;
st->duplicate = info_duplicate;

View File

@ -57,7 +57,7 @@
/* ******************** default callbacks for nla space ***************** */
static SpaceLink *nla_new(const ScrArea *area, const Scene *scene)
static SpaceLink *nla_create(const ScrArea *area, const Scene *scene)
{
ARegion *region;
SpaceNla *snla;
@ -608,7 +608,7 @@ void ED_spacetype_nla(void)
st->spaceid = SPACE_NLA;
strncpy(st->name, "NLA", BKE_ST_MAXNAME);
st->new = nla_new;
st->create = nla_create;
st->free = nla_free;
st->init = nla_init;
st->duplicate = nla_duplicate;

View File

@ -244,7 +244,7 @@ void snode_group_offset(SpaceNode *snode, float *x, float *y)
/* ******************** default callbacks for node space ***************** */
static SpaceLink *node_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *node_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceNode *snode;
@ -954,7 +954,7 @@ void ED_spacetype_node(void)
st->spaceid = SPACE_NODE;
strncpy(st->name, "Node", BKE_ST_MAXNAME);
st->new = node_new;
st->create = node_create;
st->free = node_free;
st->init = node_init;
st->duplicate = node_duplicate;

View File

@ -294,7 +294,7 @@ static void outliner_header_region_listener(wmWindow *UNUSED(win),
/* ******************** default callbacks for outliner space ***************** */
static SpaceLink *outliner_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *outliner_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceOutliner *soutliner;
@ -407,7 +407,7 @@ void ED_spacetype_outliner(void)
st->spaceid = SPACE_OUTLINER;
strncpy(st->name, "Outliner", BKE_ST_MAXNAME);
st->new = outliner_new;
st->create = outliner_create;
st->free = outliner_free;
st->init = outliner_init;
st->duplicate = outliner_duplicate;

View File

@ -51,7 +51,7 @@
/* ******************** default callbacks for script space ***************** */
static SpaceLink *script_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *script_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceScript *sscript;
@ -179,7 +179,7 @@ void ED_spacetype_script(void)
st->spaceid = SPACE_SCRIPT;
strncpy(st->name, "Script", BKE_ST_MAXNAME);
st->new = script_new;
st->create = script_create;
st->free = script_free;
st->init = script_init;
st->duplicate = script_duplicate;

View File

@ -86,7 +86,7 @@ static ARegion *sequencer_find_region(ScrArea *area, short type)
/* ******************** default callbacks for sequencer space ***************** */
static SpaceLink *sequencer_new(const ScrArea *UNUSED(area), const Scene *scene)
static SpaceLink *sequencer_create(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
SpaceSeq *sseq;
@ -852,7 +852,7 @@ void ED_spacetype_sequencer(void)
st->spaceid = SPACE_SEQ;
strncpy(st->name, "Sequencer", BKE_ST_MAXNAME);
st->new = sequencer_new;
st->create = sequencer_create;
st->free = sequencer_free;
st->init = sequencer_init;
st->duplicate = sequencer_duplicate;

View File

@ -42,7 +42,7 @@
/* ******************** default callbacks for statusbar space ******************** */
static SpaceLink *statusbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *statusbar_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceStatusBar *sstatusbar;
@ -158,7 +158,7 @@ void ED_spacetype_statusbar(void)
st->spaceid = SPACE_STATUSBAR;
strncpy(st->name, "Status Bar", BKE_ST_MAXNAME);
st->new = statusbar_new;
st->create = statusbar_create;
st->free = statusbar_free;
st->init = statusbar_init;
st->duplicate = statusbar_duplicate;

View File

@ -53,7 +53,7 @@
/* ******************** default callbacks for text space ***************** */
static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceText *stext;
@ -445,7 +445,7 @@ void ED_spacetype_text(void)
st->spaceid = SPACE_TEXT;
strncpy(st->name, "Text", BKE_ST_MAXNAME);
st->new = text_new;
st->create = text_create;
st->free = text_free;
st->init = text_init;
st->duplicate = text_duplicate;

View File

@ -52,7 +52,7 @@
/* ******************** default callbacks for topbar space ***************** */
static SpaceLink *topbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *topbar_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
ARegion *region;
SpaceTopBar *stopbar;
@ -250,7 +250,7 @@ void ED_spacetype_topbar(void)
st->spaceid = SPACE_TOPBAR;
strncpy(st->name, "Top Bar", BKE_ST_MAXNAME);
st->new = topbar_new;
st->create = topbar_create;
st->free = topbar_free;
st->init = topbar_init;
st->duplicate = topbar_duplicate;

View File

@ -45,7 +45,7 @@
/* ******************** default callbacks for userpref space ***************** */
static SpaceLink *userpref_new(const ScrArea *area, const Scene *UNUSED(scene))
static SpaceLink *userpref_create(const ScrArea *area, const Scene *UNUSED(scene))
{
ARegion *region;
SpaceUserPref *spref;
@ -235,7 +235,7 @@ void ED_spacetype_userpref(void)
st->spaceid = SPACE_USERPREF;
strncpy(st->name, "Userpref", BKE_ST_MAXNAME);
st->new = userpref_new;
st->create = userpref_create;
st->free = userpref_free;
st->init = userpref_init;
st->duplicate = userpref_duplicate;

View File

@ -260,7 +260,7 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *area)
/* ******************** default callbacks for view3d space ***************** */
static SpaceLink *view3d_new(const ScrArea *UNUSED(area), const Scene *scene)
static SpaceLink *view3d_create(const ScrArea *UNUSED(area), const Scene *scene)
{
ARegion *region;
View3D *v3d;
@ -1611,7 +1611,7 @@ void ED_spacetype_view3d(void)
st->spaceid = SPACE_VIEW3D;
strncpy(st->name, "View3D", BKE_ST_MAXNAME);
st->new = view3d_new;
st->create = view3d_create;
st->free = view3d_free;
st->init = view3d_init;
st->listener = space_view3d_listener;

View File

@ -48,18 +48,13 @@
#include "BKE_lib_id.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "ED_undo.h"
/* SpaceType struct has a member called 'new' which obviously conflicts with C++
* so temporarily redefining the new keyword to make it compile. */
#define new extern_new
#include "BKE_screen.h"
#undef new
#include "BLI_compiler_compat.h"
#include "BLI_fileops.h"
#include "BLI_ghash.h"

View File

@ -44,12 +44,7 @@
#include "BKE_lib_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
/* SpaceType struct has a member called 'new' which obviously conflicts with C++
* so temporarily redefining the new keyword to make it compile. */
#define new extern_new
#include "BKE_screen.h"
#undef new
#include "UI_interface.h"
#include "UI_resources.h"

View File

@ -46,16 +46,11 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_pointcloud.h"
#include "BKE_screen.h"
#include "BKE_simulation.h"
#include "BLO_read_write.h"
/* SpaceType struct has a member called 'new' which obviously conflicts with C++
* so temporarily redefining the new keyword to make it compile. */
#define new extern_new
#include "BKE_screen.h"
#undef new
#include "UI_interface.h"
#include "UI_resources.h"