#define GET(name) name##get
#define GETTER(type, name) type GET(name)() { return name; }
-
+#define PROPERTY(type, name) type name; GETTER(type, name)
- #define LAMBDA(...) { __VA_ARGS__ ; }
+ #define LAMBDA(...) { __VA_ARGS__; }
- // Can't wrap with do-while as block may contain continue or break
- #define WITH(type, name, value, block) { \
- type __with_save = (name); \
- name = (value); \
- LAMBDA(block) \
- name = __with_save; \
- } do { } while (0)
+ // With block may not contain continue or break
+ #define WITH(type, name, value, block) \
+ do \
+ { \
+ type __with_save = (name); \
+ name = (value); \
+ LAMBDA(block) \
+ name = __with_save; \
+ } \
+ while (0)
#endif
#define INIT(cname) [[accumulate]] cname spawn##cname##_1(cname this)
#define CLASS(cname, base) \
- entityclass(cname, base); \
- class(cname) .bool instanceOf##cname; \
- VTBL(cname, base) \
- INIT_STATIC(cname) { \
- if (cname##_vtbl) { \
- copyentity(cname##_vtbl, this); \
- return; \
- } \
- spawn##base##_static(this); \
- this.instanceOf##cname = true; \
- } \
- INIT(cname) { \
- /* Only statically initialize the current class, it contains everything it inherits */ \
- if (cname##_vtbl.vtblname == this.classname) { \
- spawn##cname##_static(this); \
- this.classname = #cname; \
- this.vtblname = string_null; \
- this.vtblbase = cname##_vtbl; \
- } \
- spawn##base##_1(this); \
- }
+ entityclass(cname, base); \
+ class(cname).bool instanceOf##cname; \
+ VTBL(cname, base) \
+ INIT_STATIC(cname) \
+ { \
+ if (cname##_vtbl) \
+ { \
+ copyentity(cname##_vtbl, this); \
+ return; \
+ } \
+ spawn##base##_static(this); \
+ this.instanceOf##cname = true; \
+ } \
+ INIT(cname) \
+ { \
+ /* Only statically initialize the current class, it contains everything it inherits */ \
+ if (cname##_vtbl.vtblname == this.classname) \
+ { \
+ spawn##cname##_static(this); \
+ this.classname = #cname; \
+ this.vtblname = string_null; \
+ this.vtblbase = cname##_vtbl; \
+ } \
+ spawn##base##_1(this); \
+ }
#define METHOD(cname, name, prototype) \
- class(cname) .prototype name; \
- prototype cname##_##name; \
- INIT_STATIC(cname) { this.name = cname##_##name; } \
- prototype cname##_##name
+ class(cname).prototype name; \
+ prototype cname##_##name; \
+ INIT_STATIC(cname) \
+ { \
+ this.name = cname##_##name; \
+ } \
+ prototype cname##_##name
#define ATTRIB(cname, name, type, val) \
- class(cname) .type name; \
- INIT(cname) { this.name = val; }
+ class(cname).type name; \
+ INIT(cname) \
+ { \
+ this.name = val; \
+ }
#define ATTRIBARRAY(cname, name, type, cnt) \
- class(cname) .type name[cnt];
+ class(cname).type name[cnt];
#define ENDCLASS(cname) \
- INIT(cname) { return this; }
- [[last]] INIT(cname) \
++ INIT(cname) \
+ { \
+ return this; \
+ }
#define SUPER(cname) (cname##_vtbl.vtblbase)
- #define super (this.vtblbase.vtblbase)
#define spawn_static(this)
#define spawn_1(this)