This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct GLFunc | |
| { | |
| GLFunc(){} | |
| GLFunc(const GLFunc& r) { | |
| *this = r; | |
| } | |
| const GLFunc& operator=(const GLFunc& r) { | |
| name = r.name; | |
| decl = r.decl; | |
| caster = r.caster; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int MesBox(lua_State *L) | |
| { | |
| const char* str = lua_tostring(L, 1); | |
| MessageBoxA(nullptr, str, "LuaTest", MB_OK); | |
| return 0; | |
| } | |
| void Bind() | |
| { | |
| lua_register(L, "MesBox", MesBox); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyClass | |
| { | |
| public: | |
| int value; | |
| }; | |
| static const char* myClassName = "MyClass"; | |
| static int MyClassSetValue(lua_State *L) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void _dumpStack(lua_State* L, const char* func, int line) | |
| { | |
| int top = lua_gettop(L); | |
| printf("(%s,%d) top=%d\n", func, line, top); | |
| for (int i = 0; i < top; i++) { | |
| int positive = top - i; | |
| int negative = -(i + 1); | |
| int type = lua_type(L, positive); | |
| const char* typeName = lua_typename(L, type); | |
| const char* value = lua_tostring(L, positive); // danger!!! numbers on the Lua stack will be replaced with string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local v = Vec4() | |
| v = Vec4(1, 2, 3, 4) | |
| v.wzyx = Vec4(1, 2, 3, 4) | |
| v = Vec4(1.111, 2.2222, 3.333, 4.444).wzyx | |
| v.w = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <algorithm> | |
| #include <string.h> | |
| #include "af_lua_helpers.h" | |
| #include "af_math.h" | |
| extern lua_State *L; | |
| static const char* myClassName = "Vec4"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <new> | |
| class MyClass | |
| { | |
| public: | |
| MyClass() | |
| { | |
| value = 0; | |
| puts("MyClass::MyClass called"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <new> | |
| extern lua_State *L; | |
| class MyClass | |
| { | |
| public: | |
| MyClass() | |
| { | |
| value = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int CreateCppClassInstance(lua_State* L) | |
| { | |
| const char* className = lua_tostring(L, lua_upvalueindex(1)); | |
| lua_CFunction actualInstanceCreator = lua_tocfunction(L, lua_upvalueindex(2)); | |
| actualInstanceCreator(L); | |
| luaL_getmetatable(L, className); | |
| lua_setmetatable(L, -2); | |
| return 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void _dumpStack(lua_State* L, const char* func, int line) | |
| { | |
| int top = lua_gettop(L); | |
| printf("(%s,%d) top=%d\n", func, line, top); | |
| for (int i = 0; i < top; i++) { | |
| int positive = top - i; | |
| int negative = -(i + 1); | |
| int type = lua_type(L, positive); | |
| int typeN = lua_type(L, negative); | |
| assert(type == typeN); |
OlderNewer