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;

tolua reference的更多相关文章

  1. tolua#代码简要分析

    简介 tolua#是Unity静态绑定lua的一个解决方案,它通过C#提供的反射信息分析代码并生成包装的类.它是一个用来简化在C#中集成lua的插件,可以自动生成用于在lua中访问Unity的绑定代码 ...

  2. tolua#是Unity静态绑定lua的一个解决方案

    tolua#代码简要分析 2017-04-16 23:02 by 风恋残雪, 98 阅读, 1 评论, 收藏, 编辑 简介 tolua#是Unity静态绑定lua的一个解决方案,它通过C#提供的反射信 ...

  3. ASP.NET Core: You must add a reference to assembly mscorlib, version=4.0.0.0

    ASP.NET Core 引用外部程序包的时候,有时会出现下面的错误: The type 'Object' is defined in an assembly that is not referenc ...

  4. 【转】Django Model field reference学习总结

    Django Model field reference学习总结(一) 本文档包含所有字段选项(field options)的内部细节和Django已经提供的field types. Field 选项 ...

  5. (转) Qt 出现“undefined reference to `vtable for”原因总结

    由于Qt本身实现的机制所限,我们在使用Qt制作某些软件程序的时候,会遇到各种各样这样那样的问题,而且很多是很难,或者根本找不到原因的,即使解决了问题,如果有人问你为什么,你只能回答--不知道. 今天我 ...

  6. undefined reference to `__android_log_print'

    使用android studio 编写NDK代码时出现错误:undefined reference to `__android_log_print' 解决办法: eclipse       andro ...

  7. CentOS 6.5 编译 PHP-7 报错:undefined reference to `libiconv_open 无法编译 PHP libiconv

    ./configure --with-mysql=/backup/mysql --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zli ...

  8. Qt - 错误总结 - 在自定义类头文件中添加Q_OBJECT 编译时报错(undefined reference to ‘vtable for xxThread)

    错误提示:在添加的QThread子类头文件添加Q_OBJECT时,编译程序,出现"undefined reference to 'vtable for xxThread'"错误提示 ...

  9. Conditional project or library reference in Visual Studio

    Conditional project or library reference in Visual Studio In case you were wondering why you haven’t ...

随机推荐

  1. 软件图标显示不正常【win7企业版】

    现象: 原因: 图标缓存没有把该软件图标建立起来 解决: 一. 1.找到 IconCache.db 2.你要把电脑隐藏文件打开不然找不到这个文件的,组织—文件夹及搜索选项——查看——显示隐藏文件.文件 ...

  2. Unity学习-预制(四)

    预制即克隆 比如要模拟一个下雨的场景,天下掉下来一颗一颗的雨滴.如果此时,我们给每一个雨滴创建一个对象的话,那会很浪费资源,而且也没必要,因为所有的雨滴是相同的.这个时候就使用到了预制,一种可以被重复 ...

  3. React Native状态机和应用设计思路

    React Native状态机和应用设计思路 在原生Android开发中:当用户点击“登录”按钮时,从用户名输入框中读取用户输入的用户名,从密码输入框中读取用户输入的密码,然后交给注册模块去处理.但是 ...

  4. Ubuntu16安装jdk8配置Tomcat9

    一.配置jdk 1.下载解压是肯定不能少的 2.配置环境变量根据自己需求来 export JAVA_HOME=/usr/software/jdk1.8.0_121 export CLASSPATH=. ...

  5. C#连接Sqlite 出现:混合模式程序集是针对“v2.0.50727”版的运行时生成的,在没有配置其他信息的情况下,无法在 4.0 运行时中加载该程序集。的解决方案

    C#连接Sqlite 出现: 混合模式程序集是针对“v2.0.50727”版的运行时生成的,在没有配置其他信息的情况下,无法在 4.0 运行时中加载该程序集.的解决方案 C#连接sqlite数据库代码 ...

  6. PHP 之转换excel表格中的经纬度

    <?php set_time_limit(0); include './plugin/PHPExcel/PHPExcel.php'; include './plugin/PHPExcel/PHP ...

  7. Sping bean的作用域

    单例(Singleton):在整个应用中,只创建bean的一个实例.(默认) 原型(Prototype):每次注入或者通过Sping应用上下文获取的时候,都会创建一个新的bean. 回话(Sessio ...

  8. [nodejs]在mac环境下如何将node更新至最新?

    在mac下安装angular-cli时,报出较多错误.初步怀疑是因为node环境版本过低导致. 在mac下,需要执行如下几步将node更新至最新版本,也可以更新到指定版本 1. sudo npm ca ...

  9. C/C++ 中野指针产生的问题

    野指针产生的问题: 野指针的定义: > 野指针是指:指向一个已删除的对象或未申请访问受限内存区域的指针.与空指针不同,野指针无法通过简单地判断是否为NULL避免,而只能通过养成良好的编程习惯来尽 ...

  10. vmware 15安装破解及使用教程

    VMware Workstation Pro15虚拟机破解版(序列号+安装教程) VMware15已经推出,根据版本号名为VMware Workstation Pro 15是一款强大好用的桌面虚拟机软 ...