summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-07-31 09:54:35 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-07-31 09:54:35 +0200
commited4e627d314bff09013dbd5547b2dcb40eb43037 (patch)
treef81fa51059928b7456775b83882de52a892bf022 /includes
parentc39b1a665114ad2a8231f0ea69f9c730cc434070 (diff)
Few more tweaks to the Lua class exporter. Now we have parent support as well as as the class name.
Diffstat (limited to 'includes')
-rw-r--r--includes/BLua.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/includes/BLua.h b/includes/BLua.h
index 926782a..6db642e 100644
--- a/includes/BLua.h
+++ b/includes/BLua.h
@@ -264,26 +264,36 @@ struct lua_functypes_t {
sLua_##classname::method_##enumvar)
#define PUSH_CLASS(classname) \
- bool constructorPushed = false; \
+ bool classPushed = true; \
{ \
L.newtable(); \
+ L.push("name"); \
L.push(#classname); \
- L.copy(-2); \
+ L.copy(); \
+ L.copy(-4); \
L.setvar(); \
+ L.settable(); \
}
-#define PUSH_CONSTRUCTOR(classname, enumvar) \
- bool constructorPushed = true; \
+#define PUSH_SUBCLASS(classname, parentname) \
+ bool classPushed = true; \
{ \
L.newtable(); \
+ L.push("name"); \
L.push(#classname); \
- L.copy(-2); \
+ L.copy(); \
+ L.copy(-4); \
L.setvar(); \
- L.declareFunc("new", sLua_##classname::constructor, -1); \
+ L.settable(); \
+ L.push("parent"); \
+ L.getglobal(#parentname); \
+ L.settable(); \
}
+#define PUSH_CONSTRUCTOR(classname, enumvar) L.declareFunc("new", sLua_##classname::constructor, -1)
+
#define PUSH_STATIC(classname, enumvar) { \
- AAssert(constructorPushed, "Please call PUSH_CONSTRUCTOR first"); \
+ AAssert(classPushed, "Please call PUSH_(SUB)CLASS first"); \
L.declareFunc( \
classname##_functions[enumvar].name, \
sLua_##classname::static_##enumvar, \