GithubHelp home page GithubHelp logo

happy-ferret / luar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stevedonovan/luar

0.0 2.0 0.0 301 KB

luar is a Go package for conveniently working with the luago Lua bindings. Arbitrary Go functions can be registered

License: MIT License

Go 100.00%

luar's Introduction

Luar: Lua reflection bindings for Go

Luar is designed to make using Lua from Go more convenient. Go structs, slices and maps can be automatically converted to Lua tables and vice-versa. The resulting conversion can either be a copy or a proxy. In the latter case, any change made to the result will reflect on the source.

Any Go function can be made available to Lua scripts, without having to write C-style wrappers.

Luar support cyclic structures (map[string]interface{}, lists, etc.).

User-defined types can be made available to Lua as well: their exported methods can be called and usual operations such as indexing or arithmetic can be performed.

See the documentation for usage instructions and examples.

Installation

Install with

go get <repo>/luar

Luar uses Alessandro Arzilli's golua. See golua's homepage for further installation details.

REPL

Version 1.x features an example REPL that is available in the cmd folder.

Changelog

Luar 2

This is a rewrite of 1.x with extended features and a cleaner API. The main differences with the previous version:

  • The function prototypes of GoToLua and LuaToGo are simpler and do not require the use of reflection from the callers. The dontproxify argument is gone, use GoToLuaProxy to control proxification.

  • The Copy* functions and GoLuaFunc are gone, use GoToLua and LuaToGo instead.

  • Use Register instead of RawRegister.

  • InitProxies is gone since it was not needed.

  • The LuaObject and LuaTableIter structure fields are unexported.

  • LuaObject methods not only work on Lua functions but also on anything with a __call metamethods. Idem for tables and the __index/__newindex metamethods.

  • Use NewLuaObjectFromName(L, "_G") instead of Global.

  • Lookup and Geti gone. Instead the Get and GetObject functions are variadic: each subfield argument can be any valid Lua key (string, integer...).

  • Use (*LuaObject) Call instead of (*LuaObject) Callf. The protoype of (*LuaObject) Call has changed in a fashion similar to GoToLua and LuaToGo. Types is gone as it is no longer needed.

  • Register ProxyIpairs and ProxyPairs instead of calling LuarSetup.

  • Register and use Unproxify instead of ArrayToTable, MapToTable, ProxyRaw, SliceToTable and StructToTable.

  • ComplexReal and ComplexImag have been replaced by the proxy attributes real and imag, respectively.

  • SliceSub and SliceAppend have been replaced by the proxy methods slice and append, respectively. Slice proxies have the cap metamethod alongside append and slice.

  • String proxies have a slice method just like slice proxies. They can be looped rune-by-rune over with ipairs.

The range of supported conversion has been extended:

  • LuaToGo can convert to interfaces and pointers with several levels of indirection.

  • LuaToGo can convert to non-empty maps and structs.

luar's People

Contributors

aarzilli avatar ambrevar avatar bitwalker avatar hirochachacha avatar jarcoal avatar kdar avatar stevedonovan avatar tasssadar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.