Improve compatibility with cpp
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 10 Sep 2015 01:01:16 +0000 (11:01 +1000)
committerGitLab <gitlab@gitlab.com>
Mon, 21 Sep 2015 06:30:35 +0000 (06:30 +0000)
12 files changed:
qcsrc/client/hud.qh
qcsrc/common/deathtypes.qh
qcsrc/common/effects.qh
qcsrc/common/mutators/base.qh
qcsrc/common/notifications.qc
qcsrc/common/notifications.qh
qcsrc/common/turrets/turrets.qh
qcsrc/common/util-pre.qh
qcsrc/common/weapons/all.qh
qcsrc/lib/Cvar.qh
qcsrc/lib/OO.qh
qcsrc/menu/xonotic/dialog_settings_game.qc

index d30eea1..62b5ec6 100644 (file)
@@ -198,7 +198,7 @@ void HUD_ItemsTime();
                hud_panelent.panel_showflags = showflags;                                                                                                                                       \
                HUD_PANEL_NUM++;                                                                                                                                                                                        \
        }                                                                                                                                                                                                                               \
-       ACCUMULATE_FUNCTION(RegisterHUD_Panels, RegisterHUD_Panel_##NAME);
+       ACCUMULATE_FUNCTION(RegisterHUD_Panels, RegisterHUD_Panel_##NAME)
 
 HUD_PANELS(HUD_PANEL)
 #undef HUD_PANEL
index b9c215f..c1e8bd2 100644 (file)
@@ -104,7 +104,7 @@ entity deathtypes[DT_MAX];
                if (msg_death_by != NO_MSG) \
                        deathent.death_msgmurder = msg_multi_notifs[msg_death_by - 1]; \
        } \
-       ACCUMULATE_FUNCTION(RegisterDeathtypes, RegisterDeathtype_##name);
+       ACCUMULATE_FUNCTION(RegisterDeathtypes, RegisterDeathtype_##name)
 
 DEATHTYPES
 #undef DEATHTYPE
index b0c452c..a1102e9 100644 (file)
@@ -53,9 +53,9 @@ void RegisterEffects_Done()
 }
 
 // NOW we actually activate the declarations
-ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_First);
+ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_First)
 EFFECT(0, Null, string_null)
 #include "effects.inc"
-ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_Done);
+ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_Done)
 
 #endif
index a8f6c53..6fa77a8 100644 (file)
@@ -247,7 +247,7 @@ STATIC_INIT_LATE(Mutators) {
     [[accumulate]] void RegisterCallbacks() { CALLBACK_##name = NEW(Callback, func); }
 
 #define MUTATOR_HOOKFUNCTION(...) \
-    OVERLOAD(MUTATOR_HOOKFUNCTION, __VA_ARGS__)
+    EVAL(OVERLOAD(MUTATOR_HOOKFUNCTION, __VA_ARGS__))
 
 #define MUTATOR_HOOKFUNCTION_1(name) \
     _MUTATOR_CALLBACK(name, HOOKFUNCTION_##name) \
index 16521a8..626c42c 100644 (file)
@@ -69,7 +69,7 @@ string Notification_CheckArgs_TypeName(float net_type, float net_name)
 {
        // check supplied type and name for errors
        string checkargs = "";
-       #define CHECKARG_TYPENAME(type) case MSG_##type##: \
+       #define CHECKARG_TYPENAME(type) case MSG_##type: \
                { if(!net_name || (net_name > NOTIF_##type##_COUNT)) \
                { checkargs = sprintf("Improper name: %d!", net_name); } break; }
        switch(net_type)
index 2fbc9cd..d44a651 100644 (file)
@@ -623,7 +623,7 @@ float notif_global_error;
             NO_MSG,   /* optiona     */ \
             NO_MSG);  /* optionb     */ \
     } \
-    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name);
+    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_INFO_NOTIF(default,name,strnum,flnum,args,hudargs,icon,normal,gentle) \
     NOTIF_ADD_AUTOCVAR(name, default) \
@@ -665,7 +665,7 @@ float notif_global_error;
             NO_MSG,   /* optiona     */ \
             NO_MSG);  /* optionb     */ \
     } \
-    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name);
+    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 .string nent_iconargs;
 #define MULTIICON_INFO(default,name,strnum,flnum,args,hudargs,iconargs,icon,normal,gentle) \
@@ -709,7 +709,7 @@ float notif_global_error;
             NO_MSG);  /* optionb     */ \
         msg_info_notifs[name - 1].nent_iconargs = iconargs; \
     } \
-    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name);
+    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_CENTER_NOTIF(default,name,strnum,flnum,args,cpid,durcnt,normal,gentle) \
     NOTIF_ADD_AUTOCVAR(name, default) \
@@ -751,7 +751,7 @@ float notif_global_error;
             NO_MSG,   /* optiona     */ \
             NO_MSG);  /* optionb     */ \
     } \
-    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name);
+    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_MULTI_NOTIF(default,name,anncename,infoname,centername) \
     NOTIF_ADD_AUTOCVAR(name, default) \
@@ -793,7 +793,7 @@ float notif_global_error;
             NO_MSG,   /* optiona     */ \
             NO_MSG);  /* optionb     */ \
     } \
-    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name);
+    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define ACVNN(name) autocvar_notification_##name
 
@@ -838,7 +838,7 @@ float notif_global_error;
             optiona,                                 /* optiona     */ \
             optionb);                                /* optionb     */ \
     } \
-    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name);
+    ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 void RegisterNotifications_First()
 {
@@ -882,8 +882,8 @@ void RegisterNotifications_Done()
 }
 
 // NOW we actually activate the declarations
-ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_First);
+ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_First)
 #include "notifications.inc"
-ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_Done);
+ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_Done)
 
 #endif
index 0c2250b..e1bf48c 100644 (file)
@@ -183,6 +183,6 @@ float TUR_LAST;
 #include "all.qh"
 
 #undef REGISTER_TURRET
-ACCUMULATE_FUNCTION(RegisterTurrets, register_turrets_done);
+ACCUMULATE_FUNCTION(RegisterTurrets, register_turrets_done)
 
 #endif
index 22cdfda..ad9be12 100644 (file)
 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)
 
 #ifdef GMQCC
-    #define OVERLOAD(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
+    #define EVAL(...)           __VA_ARGS__
+
+    #define OVERLOAD_(F, ...)   F##_##__VA_COUNT__(__VA_ARGS__)
+    #define OVERLOAD(F, ...)    F##_##__VA_COUNT__(__VA_ARGS__)
 #else
-    #define OVERLOAD_(F,_16,_15,_14,_13,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,n,...) F##_##n
-    #define OVERLOAD(F, ...) OVERLOAD_(F,__VA_ARGS__,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1)(__VA_ARGS__)
+    #define EMPTY()
+    #define DEFER(id) id EMPTY()
+
+    #define EVAL(...)  EVAL1(EVAL1(EVAL1(__VA_ARGS__)))
+    #define EVAL1(...) EVAL2(EVAL2(EVAL2(__VA_ARGS__)))
+    #define EVAL2(...) EVAL3(EVAL3(EVAL3(__VA_ARGS__)))
+    #define EVAL3(...) EVAL4(EVAL4(EVAL4(__VA_ARGS__)))
+    #define EVAL4(...) EVAL5(EVAL5(EVAL5(__VA_ARGS__)))
+    #define EVAL5(...) __VA_ARGS__
+
+    #define OVERLOAD___(F,_16,_15,_14,_13,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,n,...) F##_##n
+    #define OVERLOAD__(F, ...)  OVERLOAD___(F,##__VA_ARGS__,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
+    #define OVERLOAD_(...)      DEFER(OVERLOAD__(__VA_ARGS__))
+    #define OVERLOAD(F, ...)    OVERLOAD_(F,##__VA_ARGS__)(__VA_ARGS__)
 #endif
 
 #define LAMBDA(...) { __VA_ARGS__ ; }
 
-#define MAP(f, ...) OVERLOAD(MAP, f, __VA_ARGS__)
+#define MAP(f, ...) EVAL(OVERLOAD(MAP, f, __VA_ARGS__))
 #define MAP_2(f, it) f(it)
 #define MAP_3(f, it, ...) f(it)MAP_2(f, __VA_ARGS__)
 #define MAP_4(f, it, ...) f(it)MAP_3(f, __VA_ARGS__)
index 081e13a..f965c39 100644 (file)
@@ -267,5 +267,5 @@ entity dummy_weapon_info;
 #undef WEP_ADD_CVAR
 #undef WEP_ADD_PROP
 void register_weapons_done();
-ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done);
+ACCUMULATE_FUNCTION(RegisterWeapons, register_weapons_done)
 #endif
index 02016a2..b2093b1 100644 (file)
@@ -17,7 +17,7 @@ STATIC_INIT_LATE(Cvars) { RegisterCvars(RegisterCvars_Set); }
     type autocvar_##var
 #define AUTOCVAR_6(file, archive, var, type, default, desc) \
     AUTOCVAR_5(file, archive, var, type, desc) = default
-#define _AUTOCVAR(...) OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__)
+#define _AUTOCVAR(...) EVAL(OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__))
 #define AUTOCVAR_SAVE(...) _AUTOCVAR(true, __VA_ARGS__)
 #define AUTOCVAR(...) _AUTOCVAR(false, __VA_ARGS__)
 
index d4efe9a..96978ba 100644 (file)
@@ -25,7 +25,7 @@ entity __spawn(string _classname, string _sourceFile, int _sourceLine) {
 
 
 
-#define entityclass(...) OVERLOAD(entityclass, __VA_ARGS__)
+#define entityclass(...) EVAL(OVERLOAD(entityclass, __VA_ARGS__))
 #define entityclass_1(name) entityclass_2(name, Object)
 #ifndef QCC_SUPPORT_ENTITYCLASS
     #define entityclass_2(name, base) typedef entity name
@@ -41,11 +41,23 @@ entity __spawn(string _classname, string _sourceFile, int _sourceLine) {
 // The parameter is used across [[accumulate]] functions
 
 // Macros to hide this implementation detail:
+#ifdef GMQCC
 #define NEW(cname, ...) \
     OVERLOAD(spawn##cname, new(cname), ##__VA_ARGS__)
 
 #define CONSTRUCT(cname, ...) \
     OVERLOAD(spawn##cname, this, ##__VA_ARGS__)
+#else
+#define NEW_(cname, ...) \
+    OVERLOAD_(spawn##cname, __VA_ARGS__)
+#define NEW(cname, ...) \
+    NEW_(cname, new(cname), ##__VA_ARGS__)(new(cname), ##__VA_ARGS__)
+
+#define CONSTRUCT_(cname, ...) \
+    OVERLOAD_(spawn##cname, __VA_ARGS__)
+#define CONSTRUCT(cname, ...) \
+    CONSTRUCT_(cname, this, ##__VA_ARGS__)(this, ##__VA_ARGS__)
+#endif
 
 #define CONSTRUCTOR(cname, ...) \
     cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) { return = this; } \
index 497e1e5..fc87261 100644 (file)
@@ -84,7 +84,8 @@ CLASS(XonoticGameSettingsTab, XonoticTab)
        ATTRIB(XonoticGameSettingsTab, intendedWidth, float, 0.9)
     ATTRIB(XonoticGameSettingsTab, rows, float, 15.5)
     ATTRIB(XonoticGameSettingsTab, columns, float, 6.5)
-    ATTRIB(XonoticGameSettingsTab, topicList, entity, NEW(XonoticRegisteredSettingsList, NEW(SettingSource)))
+    ATTRIB(XonoticGameSettingsTab, source, DataSource, NEW(SettingSource))
+    ATTRIB(XonoticGameSettingsTab, topicList, entity, NEW(XonoticRegisteredSettingsList, this.source))
     ATTRIB(XonoticGameSettingsTab, currentPanel, entity, NEW(XonoticTab))
     ATTRIB(XonoticGameSettingsTab, currentItem, entity, NULL)
     METHOD(XonoticGameSettingsTab, topicChangeNotify, void(entity, entity this))