luar

package module
v0.0.0-...-35982da Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

README

go-luar

Custom type reflection for go-lua.

See the docs at https://godoc.org/github.com/jtolds/go-luar

See example usage at https://github.com/jtolds/go-manhole

Big thanks to Tim Cooper's https://github.com/layeh/gopher-luar for implementation ideas, etc!

TODO

  • Better docs
  • Arrays, slices
  • Channels
  • Maps

License

Copyright 2015 JT Olds

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PushReflectedValue

func PushReflectedValue(l *lua.State, val reflect.Value) (err error)

PushReflectedValue is like PushValue, but works on already reflected values.

func PushType

func PushType(l *lua.State, example interface{}) error

PushType pushes a constructor for the given example's type onto the Lua stack. Usually used like:

if err := PushType(l, Type{}); err == nil {
  l.SetGlobal("Type")
}

func PushValue

func PushValue(l *lua.State, val interface{}) error

PushValue pushes a Go value mapped to the appropriate Lua binding onto the Lua stack. Usually used like:

if err := PushValue(l, x); err == nil {
  l.SetGlobal("x")
}

Will return an error if the conversion is not possible.

func SetOptions

func SetOptions(l *lua.State, opts Options)

func ToReflectedValue

func ToReflectedValue(l *lua.State, index int, hint reflect.Type) (
	result reflect.Value, err error)

ToReflectedValue is like ToValue, but leaves the type as a reflect.Value. If hint is not nil, will use hint if possible to try and better inform the conversion (if hint is a slice and the lua value is a table, will simply get the numeric indexes).

func ToValue

func ToValue(l *lua.State, index int, hint reflect.Type) (interface{}, error)

ToValue returns the reverse-mapped Go value from the Lua stack at index `index`, and an error if the conversion isn't yet possible. If hint is not nil, will use hint if possible to try and better inform the conversion (if hint is a slice and the lua value is a table, will simply get the numeric indexes).

Types

type Options

type Options struct {
	AllowUnexportedAccess bool
}

func GetOptions

func GetOptions(l *lua.State) Options

Jump to

Keyboard shortcuts

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