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. Java系列学习(五)-流程控制语句

    1.顺序结构 1.if语句 (1)图例 (2)三种格式 A:格式1 B:格式2 C:格式3 2.swich语句 图例: 格式: [注]input可以是byte,short,int,char:JDK5以 ...

  2. Laravel5.1学习笔记18 数据库4 数据填充

    简介 编写数据填充类 使用模型工厂类 调用额外填充类 执行填充 #简介 Laravel includes a simple method of seeding your database with t ...

  3. sqlite学习笔记之sqlite3_open函数的使用

    作者:朱金灿 来源:http://blog.csdn.net/clever101 打开sqlite数据库需要用到sqlite3_open函数,但是sqlite3_open函数的第一个参数是数据库文件的 ...

  4. RTL Compiler之synthesis flow

    1 generic RTL Compiler work flow 2 invoking RTL compiler RTL Compiler is invoked from the operating ...

  5. (转)分布式文件存储FastDFS(四)配置fastdfs-apache-module

    http://blog.csdn.net/xingjiarong/article/details/50560605 在前边我们已经配置好了FastDFS的环境,但是此时的FastDFS还不能通过htt ...

  6. java_servlet执行流程和生命周期

        

  7. ASLR(Address space layout randomization)地址空间布局随机化

    /*********************************************************************  * Author  : Samson  * Date   ...

  8. Resetting the SMC & PRAM

    Resetting the SMC & PRAM on portables with a battery you should not remove on your own 1. Shut d ...

  9. get传数组

    开发真的处处都是坑呀 ajax get请求,传数组,想当然的给了个json数组['','',''],结果500错误 正确的方式,多次赋值,见下图,后台会自动转数组

  10. centos 7 配置nginx

    安装nginx: curl -o  nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0. ...