• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

stevedonovan/luar: luar is a Go package for conveniently working with the luago ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

stevedonovan/luar

开源软件地址(OpenSource Url):

https://github.com/stevedonovan/luar

开源编程语言(OpenSource Language):

Go 100.0%

开源软件介绍(OpenSource 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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap