找回密码
 立即注册
查看: 254|回复: 0

tolua reference

[复制链接]
发表于 2023-4-9 09:46 | 显示全部楼层 |阅读模式
   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:07lxjshuju 阅读(   ...) 评论(   ...)    编辑收藏


转载于:https://www.cnblogs.com/lxjshuju/p/6971409.html
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-11-23 12:18 , Processed in 0.090354 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表