]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/OO.qh
Improve compatibility with cpp
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / OO.qh
index 63a70f7da8bbce07dc95bc1f9f83f2c25fe0e7b6..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
@@ -40,12 +40,24 @@ entity __spawn(string _classname, string _sourceFile, int _sourceLine) {
 // Classes have a `spawn##cname(entity)` constructor
 // The parameter is used across [[accumulate]] functions
 
-// Macro to hide this implementation detail
+// 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; } \