]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 d30eea145de3c29e86281185819f3732f4344bb0..62b5ec6fd3675e5cf6f41ff0066e41a6c5c9fcb9 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 b9c215f907b5fe28e53c121337829cc9bd2fc450..c1e8bd2218f0c7787f4e327106649ad0632c868a 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 b0c452ce07664d596935312497b020d0677379d1..a1102e96a26fb6cf92eee01d0a69e78f08ca8f8b 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 a8f6c53a9f07bf4b3c467d36d336a27abd06b6d0..6fa77a858a21a2bceb2169d603c5b1a577111797 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 16521a849d32f5f7c20c3be16311ab3d0ea3e444..626c42c7d61d590c5d4e00f71b34041220e64edc 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 2fbc9cdf0e67154affb28ff7f62bdb3be2600fe0..d44a651567f767b95ed80da560fea7bf22794587 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 0c2250bc93e849ec581c44121b312b5dfba7889f..e1bf48c1b2af08d2d70a6a062b33ea93c0b32823 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 22cdfda81de444f529ac27bca3346cb75fe13d36..ad9be12cbab8b5bf7773429f72d30ba6733a3d88 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 081e13a7e58e64f4c5205d047b58fa8f3f7ea0d0..f965c39988783e32b704a9959e6068ccaa583c31 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 02016a251724f6468939e6adaba2a6f3f9e849d1..b2093b13e47bd3cb50391b0791cc8e25b1a97d92 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 d4efe9a6e346f48217426f4c292bfa0b7f919ec8..96978baf7d449f2a978b46bf99b8dbe7e3bf3ffe 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 497e1e5e77dff8cd7d163be44f945dd92258e24b..fc87261a538b736546e2481b29d992d6d3abc2eb 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))