(Lua.State* L)
| 35 | } |
| 36 | |
| 37 | [UnmanagedCallersOnly(EntryPoint = "csRunTestsLua")] |
| 38 | public static int csRunTestsLua(Lua.State* L) |
| 39 | { |
| 40 | int top = Lua.gettop(L); |
| 41 | |
| 42 | // Register a new function |
| 43 | LuaL.RegHelper[] functions = { |
| 44 | new() {name = "add", func = GetFunctionPointer(CsLuaAdd)}, |
| 45 | new() {name = "mul", func = GetFunctionPointer(CsLuaMul)}, |
| 46 | new() {name = null, func = 0} |
| 47 | }; |
| 48 | |
| 49 | LuaL.Register(L, "csfuncs", functions); |
| 50 | Lua.pop(L, 1); |
| 51 | |
| 52 | Lua.pushinteger(L, 17); |
| 53 | String s = Lua.tostring(L, -1); // converts the integer into a string |
| 54 | Console.WriteLine(String.Format(" tostring(17): {0}", s)); |
| 55 | Lua.pop(L, 1); // Pop the string |
| 56 | |
| 57 | // Create the return value |
| 58 | Lua.newtable(L); |
| 59 | |
| 60 | Lua.pushstring(L, "hello"); |
| 61 | Lua.setfield(L, -2, "string"); |
| 62 | |
| 63 | Lua.pushnumber(L, 3.0); |
| 64 | Lua.setfield(L, -2, "number"); |
| 65 | |
| 66 | Lua.pushinteger(L, 2); |
| 67 | Lua.setfield(L, -2, "integer"); |
| 68 | |
| 69 | Lua.pushnumber(L, 3.0); |
| 70 | Lua.setfield(L, -2, "number"); |
| 71 | |
| 72 | int newtop = Lua.gettop(L); |
| 73 | return (newtop - top) == 1 ? 0 : 1; // We want to leave the table on the stack |
| 74 | } |
| 75 | } |
nothing calls this directly
no test coverage detected