MCPcopy Index your code
hub / github.com/yuin/gopher-lua / baseSetMetatable

Function baseSetMetatable

baselib.go:387–402  ·  view source on GitHub ↗
(L *LState)

Source from the content-addressed store, hash-verified

385}
386
387func baseSetMetatable(L *LState) int {
388 L.CheckTypes(2, LTNil, LTTable)
389 obj := L.Get(1)
390 if obj == LNil {
391 L.RaiseError("cannot set metatable to a nil object.")
392 }
393 mt := L.Get(2)
394 if m := L.metatable(obj, true); m != LNil {
395 if tb, ok := m.(*LTable); ok && tb.RawGetString("__metatable") != LNil {
396 L.RaiseError("cannot change a protected metatable")
397 }
398 }
399 L.SetMetatable(obj, mt)
400 L.SetTop(1)
401 return 1
402}
403
404func baseToNumber(L *LState) int {
405 base := L.OptInt(2, 10)

Callers

nothing calls this directly

Calls 7

CheckTypesMethod · 0.80
RawGetStringMethod · 0.80
GetMethod · 0.45
RaiseErrorMethod · 0.45
metatableMethod · 0.45
SetMetatableMethod · 0.45
SetTopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…