https://github.com/wendal/lua-newlisp
eval newLISP in lua
https://github.com/wendal/lua-newlisp
Last synced: 2 months ago
JSON representation
eval newLISP in lua
- Host: GitHub
- URL: https://github.com/wendal/lua-newlisp
- Owner: wendal
- Created: 2012-04-10T08:01:13.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-04-11T03:12:43.000Z (over 13 years ago)
- Last Synced: 2025-04-22T19:06:23.764Z (8 months ago)
- Language: C
- Homepage: http://wendal.net
- Size: 250 KB
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Lua-newLISP包装器
=============================================
*在lua中调用newLISP脚本. 项目创建的主要目的是在lua_nginx模块中,使用newLISP脚本.
编译
---------------------------------------------
* libnewlisp.so拷贝到/usr/lib
* 将newLISP.so拷贝到lua的cpath,或者编译一个
gcc -O3 -Wall -shared -o newLISP.so -lnewlisp -llua newLISP.c
API
---------------------------------------------
* eval(str)
* 执行并返回最后一个表达式的值,返回值的类型是str
* eval_file(file_path)
* 执行一个文件,并返回最后一个表达式的值,返回值的类型是str
示例
---------------------------------------------
-- 载入newLISP库
local lisp = require "newLISP"
-- 执行一个简单的newLISP脚本字符串
local result = lisp.eval("(+ 1 2)")
print(result)
print("-----------------------------------------")
-- 执行一个带方法定义的newLISP脚本字符串
result = lisp.eval2("(define (mk x y) (+ (* x x) (* y y))) (mk 3 4)")
print(result)
print("-----------------------------------------")
-- 执行一个lsp文件
result = lisp.eval_file("t.lsp")
print(result)
print("-----------------------------------------")