Commit 8c0277e8d8652c7108087c0f56c7f57b1245537b

Authored by Georg Hopp
1 parent aed0c24a

some minor fixes for the classvars stuff

Showing 1 changed file with 9 additions and 6 deletions
... ... @@ -84,7 +84,7 @@
84 84 * even compile.
85 85 */
86 86 #define TR_EXTENDS(parent) const char _[sizeof(struct c_##parent)]
87   -#define TR_CV_EXTENDS(parent) const char _[sizeof(struct c_##parent##_vars)]
  87 +#define TR_CV_EXTENDS(parent) struct c_##parent##_vars _
88 88
89 89 /**
90 90 * Some macros might translate a give NULL to _NULL,
... ... @@ -107,13 +107,13 @@
107 107 * created.
108 108 */
109 109 #define TR_CREATE_CLASS(name,_parent,cvInit,...) \
110   - struct c_##name##_vars c_vars; \
  110 + struct c_##name##_vars _##name##_vars; \
111 111 void (* TR_initClassVars##name)(TR_class_ptr) = cvInit; \
112 112 static TR_class_ptr _classInit##name##_(void) { \
  113 + c_##name.init = NULL; \
113 114 c_##name.parent = _##_parent; \
114 115 if (TR_initClassVars##name) \
115 116 TR_initClassVars##name(_##name); \
116   - c_##name.init = NULL; \
117 117 return &c_##name; \
118 118 }; \
119 119 struct TR_class c_##name = { \
... ... @@ -121,11 +121,11 @@
121 121 NULL, \
122 122 sizeof(struct c_##name), \
123 123 _classInit##name##_, \
124   - &c_vars, \
  124 + &_##name##_vars, \
125 125 TR_INIT_IFACE_IMPL(__VA_ARGS__) \
126 126 }; \
127 127 struct TR_class * const _##name = &c_##name; \
128   - struct c_##name##_vars c_vars
  128 + struct c_##name##_vars _##name##_vars
129 129
130 130 /**
131 131 * Create a static instance of a class.
... ... @@ -176,7 +176,10 @@
176 176 * \see TR_CREATE_CLASS
177 177 */
178 178 #define TR_GET_CLASS(object) \
179   - (TR_INIT_CLASS(*(TR_class_ptr *)((void*)(object) - sizeof(void*))))
  179 + (TR_INIT_CLASS(*(TR_class_ptr *)((void*)(object) - sizeof(void*))))
  180 +
  181 +#define TR_CLASS_BY_NAME(class_name) (TR_INIT_CLASS(& c_##class_name))
  182 +#define TR_CLASS_BY_NAME_STATIC(class_name) (& c_##class_name)
180 183
181 184 /**
182 185 * Returns this class's implementations of the interface
... ...
Please register or login to post a comment