stdlib

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package api defines the interface for Lua standard library registration.

Each library is a Go function that registers Lua functions into a state. Libraries use the public Go API (internal/api/) to interact with the VM.

Reference: .analysis/09-standard-libraries.md

testlib.go — T (testC) testing library for the Lua 5.5 test suite.

Implements the T global table with T.testC(), T.makeCfunc(), etc. Reference: lua-master/ltests.c

tracegc module — test helper for suppressing/enabling GC finalizer execution.

Provides two functions:

  • tracegc.stop() — suppress GC finalizer execution (sets GCStopped = true)
  • tracegc.start() — re-enable GC finalizer execution (sets GCStopped = false)

Used by cstack.lua tests to control when finalizers fire. This is a stub that provides just enough for the test suite; C Lua's tracegc is more complex (tracks individual finalizer calls).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenAll

func OpenAll(L *luaapi.State)

OpenAll opens all standard libraries. Convenience function.

func OpenBase

func OpenBase(L *luaapi.State) int

OpenBase opens the base library into _G.

func OpenCoroutineLib

func OpenCoroutineLib(L *luaapi.State) int

OpenCoroutineLib registers all coroutine library functions. Replaces the stub OpenCoroutine.

func OpenDebug

func OpenDebug(L *luaapi.State) int

func OpenIO

func OpenIO(L *luaapi.State) int

func OpenLog added in v0.9.2

func OpenLog(L *luaapi.State) int

OpenLog registers the "log" module. It is designed to be used as a preloaded module: require("log").

func OpenMath

func OpenMath(L *luaapi.State) int

OpenMath opens the math library.

func OpenOS

func OpenOS(L *luaapi.State) int

func OpenPackage

func OpenPackage(L *luaapi.State) int

OpenPackage opens the "package" library for a Lua state.

func OpenString

func OpenString(L *luaapi.State) int

OpenString opens the string library.

func OpenTable

func OpenTable(L *luaapi.State) int

OpenTable opens the table library.

func OpenTestLib

func OpenTestLib(L *luaapi.State)

func OpenTraceGC

func OpenTraceGC(L *luaapi.State) int

OpenTraceGC is the opener for the "tracegc" module. Returns a table with stop/start functions.

func OpenUTF8

func OpenUTF8(L *luaapi.State) int

OpenUTF8 opens the utf8 library.

Types

type Library

type Library struct {
	Name string   // library name (e.g., "string", "table")
	Open OpenFunc // opener function
}

Library describes a standard library for registration.

func StandardLibraries

func StandardLibraries() []Library

StandardLibraries returns the list of all standard libraries in load order. Order matters: base must be first (it defines _G and core functions).

type OpenFunc

type OpenFunc func(L *luaapi.State) int

OpenFunc is the type for library opener functions. Each takes a State and registers its functions. Returns 1 (the library table).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL