* }}} */ * GopherLua original APIs {{{ */ ToStringMeta returns string representation of given LValue. This method calls the `__tostring` meta method if defined.
(lv LValue)
| 418 | // ToStringMeta returns string representation of given LValue. |
| 419 | // This method calls the `__tostring` meta method if defined. |
| 420 | func (ls *LState) ToStringMeta(lv LValue) LValue { |
| 421 | if fn, ok := ls.metaOp1(lv, "__tostring").(*LFunction); ok { |
| 422 | ls.Push(fn) |
| 423 | ls.Push(lv) |
| 424 | ls.Call(1, 1) |
| 425 | return ls.reg.Pop() |
| 426 | } else { |
| 427 | return LString(lv.String()) |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | // Set a module loader to the package.preload table. |
| 432 | func (ls *LState) PreloadModule(name string, loader LGFunction) { |