]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Doxygen: improve static members and zoned strings
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Mar 2016 11:32:58 +0000 (22:32 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Mar 2016 11:34:07 +0000 (22:34 +1100)
qcsrc/Doxyfile
qcsrc/lib/oo.qh
qcsrc/menu/xonotic/datasource.qh

index 631b9d5cf11f8efcc8d63ae777b8fc732f90e700..d0379e41fca0c9643bbdcf1a14bb4fe99564af46 100644 (file)
@@ -2002,6 +2002,9 @@ PREDEFINED             = \
     "CONSTRUCTOR(class)=class::class(" \
     "DESTRUCTOR(class)=class::~class()" \
     "ATTRIB(class, name, T, val)=T name = val;" \
+    "ATTRIB_STRZONE(class, name, T, val)=T name = val;" \
+    "STATIC_ATTRIB(class, name, T, val)=static T name = val;" \
+    "STATIC_ATTRIB_STRZONE(class, name, T, val)=static T name = val;" \
     "METHOD(class, name, prototype)=virtual void class::name()" \
     "ENDCLASS(class)=};" \
     __STDC__
@@ -2018,7 +2021,8 @@ EXPAND_AS_DEFINED      = \
     CLASS \
     CONSTRUCTOR \
     DESTRUCTOR \
-    ATTRIB \
+    ATTRIB ATTRIB_STRZONE \
+    STATIC_ATTRIB STATIC_ATTRIB_STRZONE \
     METHOD \
     ENDCLASS \
     LABEL \
index 5e0efc218e2f565365984467cd03b309f582b1e0..45fbb2627dd1f6d947c0aa0b61c2c1ad83ee9715 100644 (file)
@@ -136,7 +136,7 @@ STATIC_INIT(RegisterClasses)
 }
 
 #define VTBL(cname, base) \
-       INIT_STATIC(cname); \
+       _INIT_STATIC(cname); \
        entity cname##_vtbl; \
        void cname##_vtbl_init() \
        { \
@@ -149,7 +149,7 @@ STATIC_INIT(RegisterClasses)
        } \
        ACCUMULATE_FUNCTION(RegisterClasses, cname##_vtbl_init)
 
-#define INIT_STATIC(cname) [[accumulate]] void spawn##cname##_static(cname this)
+#define _INIT_STATIC(cname) [[accumulate]] void spawn##cname##_static(cname this)
 #define INIT(cname) [[accumulate]] cname spawn##cname##_1(cname this)
 
 #define CLASS(cname, base)                  \
@@ -157,7 +157,7 @@ STATIC_INIT(RegisterClasses)
        class(cname).bool instanceOf##cname;   \
     bool is_##cname(entity e) { return e.instanceOf##cname; } \
        VTBL(cname, base)                       \
-       INIT_STATIC(cname) \
+       _INIT_STATIC(cname) \
        {                    \
                if (cname##_vtbl) \
                {                 \
@@ -189,7 +189,7 @@ STATIC_INIT(RegisterClasses)
 #define METHOD(cname, name, prototype) \
        STATIC_METHOD(cname, name, prototype); \
        class(cname) .prototype name; \
-       INIT_STATIC(cname) \
+       _INIT_STATIC(cname) \
        { \
                this.name = METHOD_REFERENCE(cname, name); \
        } \
@@ -213,6 +213,16 @@ STATIC_INIT(RegisterClasses)
                this.name = val; \
        }
 
+#define STATIC_ATTRIB(cname, name, type, val) \
+       type cname##_##name; \
+       _INIT_STATIC(cname) \
+       { \
+               noref bool strzone; /* Error on strzone() calls. */ \
+               cname##_##name = val; \
+       }
+
+// cleanup potentially zoned strings from base classes
+
 #define ATTRIB_STRZONE(cname, name, type, val)      \
        class(cname).type name;                \
        INIT(cname) \
@@ -222,6 +232,15 @@ STATIC_INIT(RegisterClasses)
                this.name = strzone(val); \
        }
 
+#define STATIC_ATTRIB_STRZONE(cname, name, type, val) \
+       type cname##_##name; \
+       _INIT_STATIC(cname) \
+       { \
+        if (cname##_##name) \
+            strunzone(cname##_##name); \
+               cname##_##name = val; \
+       }
+
 #define ATTRIBARRAY(cname, name, type, cnt) \
        class(cname).type name[cnt];
 
index 1808b765515d0d81f60e9a3c517ef1ecdbe423be..1ca3d5811fd316192c7ca4b86bbf5b10ada6ca5c 100644 (file)
@@ -1,12 +1,8 @@
 #pragma once
 
 CLASS(DataSource, Object)
-    entity DataSource_true;
-    entity DataSource_false;
-    INIT_STATIC(DataSource) {
-        DataSource_true = NEW(Object);
-        DataSource_false = NULL;
-    }
+    STATIC_ATTRIB(DataSource, true, entity, NEW(Object));
+    STATIC_ATTRIB(DataSource, false, entity, NULL);
     /**
      * get entry `i` passing `name` and `icon` through `returns` if it is not null
      * returns `DataSource_false` if out of bounds