rt-thread-official/components/external/lua
xiongyihui3@gmail.com c77e9d5c76 add lua support for rt-thead
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2399 bbd45198-f89e-11dd-88c7-29a3b14d5316
2012-11-10 07:32:39 +00:00
..
applications add lua support for rt-thead 2012-11-10 07:32:39 +00:00
exlibs add lua support for rt-thead 2012-11-10 07:32:39 +00:00
lua add lua support for rt-thead 2012-11-10 07:32:39 +00:00
test add lua support for rt-thead 2012-11-10 07:32:39 +00:00
ChangeLog add lua support for rt-thead 2012-11-10 07:32:39 +00:00
README.TXT add lua support for rt-thead 2012-11-10 07:32:39 +00:00
SConscript add lua support for rt-thead 2012-11-10 07:32:39 +00:00

README.TXT

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Lua on RT-Thread

## 简介
RT-Thread中的Lua修改自[eLua](http://www.eluaproject.net/)的Lua-5.1.4版本。
Lua依赖于Neblib库。
启动lua的RAM占用情况
    - 标准的lua        17.1904296875 KB
    - 优化的lua        5.01953125 KB
    注数据来自print(collectgarbage('count'))的输出
优化是指采用一个lua patch --- [Lua Tiny RAM](http://www.eluaproject.net/doc/v0.8/en_arch_ltr.html)

## 使用
在RT-Thread的finsh中调用lua()获得一个lua解释器。
在lua解释器中
    - 可以调用lua标准库中的函数print('hello, lua on rt-thread')
    - 可以执行脚本文件dofile('/hello.lua')
    - 可以定义新的函数function sinc(x) return math.sin(x)/x end
    - etc.

## 配置
    1.通过在rtconfig.h中定义RT_USING_LUA加入lua组件
    2.可以定义RT_LUA_OPTRAM减少RAM占用
    3.可以定义RT_LUS_USE_EXLIBS而添加外部库如arduino的常用函数封装为一个arduino库
    3.更多的配置项可以在luaconf.h中找到

## 开发相关
    - 开启编译器对C99的支持如MDK中在C/C++选项的Misc Controls输入框中添加--c99
    - 开启内存优化时需要在链接脚本中定义_stext和_etext.ordata*放在两者之间。
      用于判断数据是read-only和writable。MDK中如何实现
    - 添加新的模块参见larduinolib.c
    
## 目录说明
    - lua从eLua获得Lua-5.1.4版本代码
    - exlibsexternal libraries外部库代码如Arduino库
    - applicationsLua应用代码如finsh中lua()
    - test测试代码