Using Lua API and tag method facilities, tolua maps C/C++ constants, external variables, functions, classes, and methods to Lua.

How tolua works

(1)创建a package file (a C/C++ cleaned header file) listing the constants, variables, functions, classes, and methods we want to export to the Lua environment.

(2)parses this file and creates a C/C++ file that automatically binds the C/C++ code to Lua. 
(3) accesed from Lua

How to use toLua
由(1)an executable (2)and a library组成
the executable represents the parser that reads a package file and output a C/C++ code that implements the binding to access the C/C++ features from Lua.

tolua -o myfile.c myfile.pkg

tolua -n pkgname -o myfile.c myfile.pkg

when using C++, we can opt for automatic initialization
tolua -a -n pkgname -o myfile.c myfile.pkg
automatic initialization sometimes does not work

也能够调用tolua_pkgname_close(void);解绑

能够使用-H选项将open与close操作导出到头文件里。


void tolua_restorestate (void);

Basic Concepts

package file may include other package file, use $<include_file>

Basic types
char int float double     ->       number
char*       ->              string
void*       ->              userdata
tolua ignores const modifier

Functions in C/C++ can also manipulate Lua objects explicitly.
lua_Object也是一种基本类型。

User defined types

非Basic Types均为用户自己定义类型,are mapped to tagged userdata type in Lua.
Lua can only store pointers to 自己定义类型。

NULL and nil
posted on 2017-06-09 12:07 lxjshuju 阅读(...) 评论(...) 编辑 收藏

var allowComments=true,cb_blogId=348859,cb_entryId=6971409,cb_blogApp=currentBlogApp,cb_blogUserGuid='75fef63f-ae21-e711-9fc1-ac853d9f53cc',cb_entryCreatedDate='2017/6/9 12:07:00';loadViewCount(cb_entryId);var cb_postType=1;var isMarkdown=false;

最新文章

  1. jQuery如何判断元素是否是隐藏的?
  2. 微信公共服务平台开发(.Net 的实现)12-------网页授权(上 :更加深入理解OAuth2.0 )
  3. js和jq添加新表格
  4. SQL 存储过程优化经验
  5. 关于Entity Framework中的Attached报错相关解决方案的总结
  6. 关于IPv6被拒
  7. access数据库连接问题
  8. Android View事件机制 21问21答
  9. Mac相关命令
  10. LtUpload上传组件
  11. Working with Other Node Types
  12. .NET(C#)调用webService获取客户端IP地址所属区域(非异步)
  13. 计数方法,博弈论(扫描线,树形SG):HDU 5299 Circles Game
  14. dede仿站笔记
  15. openStack kilo 手动Manual部署随笔记录
  16. Linux 添加ssh 公钥访问
  17. windows7下django项目搭建
  18. text-decoration:[ text-decoration-line ] || [ text-decoration-style ] || [ text-decoration-color ] 默认值:
  19. JSON笔记
  20. linux安装flash player来播放视频

热门文章

  1. Linq学习(二)-本次学习用到的资料
  2. 6.11---multipartfile在哪个jar包下---6.11---uuid---swagger上传图片包错去掉注解响应体
  3. PAT甲级1016Phone Bills
  4. 03-Servlet 体系结构知识梳理
  5. Caffe FCN:可视化featureMaps和Weights(C++)、获取FCN结果
  6. [文章转载]-Java后端,应该日常翻看的中文技术网站 -江南白衣
  7. Web 服务器与应用服务器的区别是什么?
  8. Android中Webview使用经验总结
  9. tidyverse生态链
  10. 如何创建一个项目,让gitlab自动触发jenkins进行构建