tolua reference

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

时间: 2024-08-08 09:35:34

tolua reference的相关文章

tolua#代码简要分析

简介 tolua#是Unity静态绑定lua的一个解决方案,它通过C#提供的反射信息分析代码并生成包装的类.它是一个用来简化在C#中集成lua的插件,可以自动生成用于在lua中访问Unity的绑定代码,并把C#中的常量.变量.函数.属性.类以及枚举暴露给lua.它是从cstolua衍变而来.从它的名字可以看出,它是集成了原来的tolua代码通过二次封装写了一个C#与tolua(c)的一个中间层. All problems in computer science can be solved by

Android中JNI调用时出现accessed stale local reference的问题

之前在做一个native的模块时遇到这样一个问题: 代码运行在android2.3上没有任何问题,可是在4.2上运行时报出了:JNI ERROR (app bug): accessed stale local reference 的错误. 后来在StackOverflow上找到了问题的答案.简单来说就是  4.0以上的android系统GC在垃圾回收时为了减少内存碎片,会对内存进行整理,整理时必然会移动对象的内存地址,这时C代码的指针还指向原来对象的地址,这时该对象已经被移动到了其他位置,因此会

tolua++ 试用demo

一直知道cocos2dx lua是通过tolua++导出lua接口的,但一直没自己去导过,最近比较闲,试了下. 我的环境是:ubuntu ,安装好tolua++后就可以在命令行下试用 tolua++ 工具导出. MyClass.cpp文件: #include <iostream> #include "tolua++.h" class MyClass { public:     void say()     {         std::cout << "

ECShop后台站点地图关于 Deprecated: Assigning the return value of new by reference is deprecated的错误的解决办法

今天对后台系统进行一些简单的操作,当点击  系统设置---站点地图  时发现提示: Deprecated: Assigning the return value of new by reference is deprecated 的错误,如下图: 起先以为是代码的问题,可是一想到这个模板是官网的默认模板,对sitemap.php文件进行查找后未能发现问题.后来将错误内容从网上一查找,原来是由于从php5.3开始后,废除了php中的"=&"符号,所以删除&符号即可. 删除

caffe日常坑系列之:undefined reference to symbol &#39;_ZN2cv6String10deallocateEv&#39;

在使用caffe库编译C++时出现的 解决如下: /usr/bin/ld: /tmp/ccA5JGRP.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'//usr/local/lib/libopencv_core.so.3.2: error adding symbols: DSO missing from command line解决:sudo apt-get autoremove libopencv-dev caffe

在codeblocks 下,C++编译不成功一直出现“undefined reference to `std::cout&#39;|

自己搞了好久才知道,编辑c++,要用g++ 希望对大家有帮助 在codeblocks 下,C++编译不成功一直出现"undefined reference to `std::cout'|

Linux下运行《UNIX环境高级编程》undefined reference to `err_quit 编译出错的处理方法

错误信息: : undefined reference to `err_quit': undefined reference to `err_sys' 解决方法: 因为err_quit跟err_sys是作者自己定义的错误处理函数.所以最简单的解决办法是修改下apue.h文件,如下 /* * Our own header, to be included before all standard system headers. */ #ifndef _APUE_H #define _APUE_H #d

lua-5.2.3编译问题记录&amp;quot;libreadline.so: undefined reference to `PC&amp;#39;&amp;quot;

作者:zhanhailiang 日期:2014-10-21 [root@~/software]# cd lua-5.2.3 [root@~/software/lua-5.2.3]# make linux cd src && make linux make[1]: Entering directory `/root/software/lua-5.2.3/src' make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,

Unity报错 : BCE0004: Ambiguous reference &#39;preview&#39;: CameraMotionBlurEditor.preview, UnityEditor.Editor.preview.

建立项目版本为Unity4.6,改为5.3.4版本,运行项目报如下错误: "BCE0004: Ambiguous reference 'preview': CameraMotionBlurEditor.preview, UnityEditor.Editor.preview." 修改  preview 为 preview_ var preview_ : SerializedProperty; preview_ = serObj.FindProperty ("preview&qu