summaryrefslogtreecommitdiff
path: root/library/LuaTypes.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-03-25 15:20:58 +0400
committerAlexander Gavrilov2012-03-25 15:20:58 +0400
commit7209e4d3f2c3fc51d176131aa9da1654f211fed0 (patch)
treefebc6590161534b905fc676e25f1f7d7aa378a59 /library/LuaTypes.cpp
parent8d345be6e77fa2260eca64be9375608aa6bf2af7 (diff)
downloaddfhack-7209e4d3f2c3fc51d176131aa9da1654f211fed0.tar.gz
dfhack-7209e4d3f2c3fc51d176131aa9da1654f211fed0.tar.bz2
dfhack-7209e4d3f2c3fc51d176131aa9da1654f211fed0.tar.xz
Attach static methods to the type objects in the lua wrapper.
Diffstat (limited to 'library/LuaTypes.cpp')
-rw-r--r--library/LuaTypes.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/library/LuaTypes.cpp b/library/LuaTypes.cpp
index bede7430..c4b58b00 100644
--- a/library/LuaTypes.cpp
+++ b/library/LuaTypes.cpp
@@ -843,6 +843,33 @@ static void IndexFields(lua_State *state, struct_identity *pstruct)
lua_pushstring(state,fields[i].name);
lua_pushlightuserdata(state,(void*)&fields[i]);
lua_rawset(state,base+2);
+ break;
+ }
+ }
+ }
+}
+
+void LuaWrapper::IndexStatics(lua_State *state, int meta_idx, int ftable_idx, struct_identity *pstruct)
+{
+ // stack: metatable fieldtable
+
+ for (struct_identity *p = pstruct; p; p = p->getParent())
+ {
+ auto fields = p->getFields();
+ if (!fields)
+ continue;
+
+ for (int i = 0; fields[i].mode != struct_field_info::END; ++i)
+ {
+ switch (fields[i].mode)
+ {
+ case struct_field_info::CLASS_METHOD:
+ AddMethodWrapper(state, meta_idx, ftable_idx, fields[i].name,
+ (function_identity_base*)fields[i].type);
+ break;
+
+ default:
+ break;
}
}
}