X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Foo.qh;h=3c7237ef408adb7ea2237536a175f4d19476a126;hb=4b58d4bcc6769c7047225a9840cea3515a3c5da1;hp=1485d4da4067ad2466010821fe6cc542c65ac617;hpb=c5155e54e757f83bc5340ae814ccdce60e441db4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/oo.qh b/qcsrc/common/oo.qh index 1485d4da4..3c7237ef4 100644 --- a/qcsrc/common/oo.qh +++ b/qcsrc/common/oo.qh @@ -43,14 +43,18 @@ entity __spawn(string _classname, string _sourceFile, int _sourceLine) { #define NEW(cname, ...) \ OVERLOAD(spawn##cname, new(cname), ##__VA_ARGS__) +#define CONSTRUCT(cname, ...) \ + OVERLOAD(spawn##cname, this, ##__VA_ARGS__) + #define CONSTRUCTOR(cname, ...) \ - cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) + cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) { return = this; } \ + [[accumulate]] cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) .string vtblname; .entity vtblbase; void RegisterClasses() { } -ACCUMULATE_FUNCTION(__static_init, RegisterClasses) +STATIC_INIT(RegisterClasses) { RegisterClasses(); } #define VTBL(cname, base) \ INIT_STATIC(cname); \ @@ -94,7 +98,8 @@ ACCUMULATE_FUNCTION(__static_init, RegisterClasses) #define METHOD(cname, name, prototype) \ class(cname) .prototype name; \ prototype cname##_##name; \ - INIT_STATIC(cname) { this.name = cname##_##name; } + INIT_STATIC(cname) { this.name = cname##_##name; } \ + prototype cname##_##name #define ATTRIB(cname, name, type, val) \ class(cname) .type name; \ @@ -107,11 +112,26 @@ ACCUMULATE_FUNCTION(__static_init, RegisterClasses) [[last]] INIT(cname) { return this; } #define SUPER(cname) (cname##_vtbl.vtblbase) +#define super (this.vtblbase.vtblbase) #define spawn_static(this) #define spawn_1(this) #define _vtbl NULL -CLASS(Object, ); ENDCLASS(Object) +CLASS(Object, ); + METHOD(Object, describe, string(entity this)) { + string s = _("No description"); + if (cvar("developer")) { + for (int i = 0, n = numentityfields(); i < n; ++i) { + string value = getentityfieldstring(i, this); + if (value != "") s = sprintf("%s\n%s = %s", s, entityfieldname(i), value); + } + } + return s; + } + METHOD(Object, display, void(entity this, void(string name, string icon) returns)) { + returns(sprintf("entity %i", this), "nopreview_map"); + } +ENDCLASS(Object) #undef spawn_static #undef spawn_1 #undef _vtbl