MCPcopy Index your code
hub / github.com/Shopify/go-lua / OpenLibraries

Function OpenLibraries

libs.go:31–54  ·  view source on GitHub ↗

OpenLibraries opens all standard libraries. Alternatively, the host program can open them individually by using Require to call BaseOpen (for the basic library), PackageOpen (for the package library), CoroutineOpen (for the coroutine library), StringOpen (for the string library), TableOpen (for the

(l *State, preloaded ...RegistryFunction)

Source from the content-addressed store, hash-verified

29// Except for the basic and the package libraries, each library provides all
30// its functions as fields of a global table or as methods of its objects.
31func OpenLibraries(l *State, preloaded ...RegistryFunction) {
32 libs := []RegistryFunction{
33 {"_G", BaseOpen},
34 {"package", PackageOpen},
35 // {"coroutine", CoroutineOpen},
36 {"table", TableOpen},
37 {"io", IOOpen},
38 {"os", OSOpen},
39 {"string", StringOpen},
40 {"bit32", Bit32Open},
41 {"math", MathOpen},
42 {"debug", DebugOpen},
43 }
44 for _, lib := range libs {
45 Require(l, lib.Name, lib.Function, true)
46 l.Pop(1)
47 }
48 SubTable(l, RegistryIndex, "_PRELOAD")
49 for _, lib := range preloaded {
50 l.PushGoFunction(lib.Function)
51 l.SetField(-2, lib.Name)
52 }
53 l.Pop(1)
54}

Callers 8

TestParserFunction · 0.85
testStringHelperFunction · 0.85
TestProtectedCallFunction · 0.85
TestLuaFunction · 0.85
benchmarkSortFunction · 0.85
TestUserDataEqualityNilFunction · 0.85
TestTableNextFunction · 0.85

Calls 5

RequireFunction · 0.85
SubTableFunction · 0.85
PopMethod · 0.80
PushGoFunctionMethod · 0.80
SetFieldMethod · 0.80

Tested by 8

TestParserFunction · 0.68
testStringHelperFunction · 0.68
TestProtectedCallFunction · 0.68
TestLuaFunction · 0.68
benchmarkSortFunction · 0.68
TestUserDataEqualityNilFunction · 0.68
TestTableNextFunction · 0.68