MCPcopy Create free account
hub / github.com/defold/defold / csRunTestsLua

Method csRunTestsLua

engine/lua/src/test/cs/test_lua.cs:37–74  ·  view source on GitHub ↗
(Lua.State* L)

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 9

gettopMethod · 0.80
pushintegerMethod · 0.80
tostringMethod · 0.80
newtableMethod · 0.80
pushstringMethod · 0.80
setfieldMethod · 0.80
pushnumberMethod · 0.80
RegisterMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected