From 3a29f3a52b98ced29273298a04ea69988a20d460 Mon Sep 17 00:00:00 2001 From: Brett Langdon Date: Sun, 25 Nov 2012 18:17:09 -0500 Subject: [PATCH] added INFO constants, updated example, README and version bump --- README.md | 13 +++++++++++-- example/example.js | 3 +++ example/test.lua | 2 +- package.json | 2 +- src/nodelua.cc | 10 ++++++++++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 19bf0ca..5fabd6c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The `NodeLua` module itself only contains a single object `LuaObject` used to in var lua = new nodelua.LuaObject() ``` -### STATUS +#### STATUS `STATUS` is an object that contains the constants for values returned by `LuaObject.status()`. `nodelua.STATUS` conatins the following constants: @@ -33,7 +33,7 @@ var lua = new nodelua.LuaObject() * `ERRMEM: 4` * `ERRERR: 5` -## GC +#### GC `GC` is an object of constants used for controlling the lua garbage collector. `nodelua.GC` conatins the following constants: @@ -46,6 +46,15 @@ var lua = new nodelua.LuaObject() * `SETPAUSE: 6` * `SETSTEPMUL: 7` +#### INFO +`INFO` is an object containing constants with information about the version of lua you are using. + +`nodelua.INFO` contains the following constants: + * `VERSION` + * `VERSION_NUM` + * `COPYRIGHT` + * `AUTHORS` + ### LuaObject The `LuaObject` is an object wrapper around a `lua_State` instance. diff --git a/example/example.js b/example/example.js index b5dabe0..ae032ff 100755 --- a/example/example.js +++ b/example/example.js @@ -1,6 +1,9 @@ var path = require('path'); var nodelua = require('../'); +console.log('Lua Info:'); +console.dir(nodelua.INFO); + var lua = new nodelua.LuaObject(); lua.registerFunction('test_func', function(a,b){ diff --git a/example/test.lua b/example/test.lua index 61ce524..54b10b7 100644 --- a/example/test.lua +++ b/example/test.lua @@ -1,5 +1,5 @@ print("Calling JS Function 'test_func' From Lua"); -print(nodelua("test_func", 3, 5)) +nodelua("test_func", 3, 5) global_var = 'this is a global variable from lua' diff --git a/package.json b/package.json index ebfd3d7..ecc046d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodelua", - "version": "0.1.2", + "version": "0.1.3", "description": "Lua Bindings For Node.JS", "keywords": [ "lua" diff --git a/src/nodelua.cc b/src/nodelua.cc index d41c2fd..58834c5 100644 --- a/src/nodelua.cc +++ b/src/nodelua.cc @@ -9,6 +9,15 @@ extern "C"{ using namespace v8; +void init_info_constants(Handle target){ + Local constants = Object::New(); + constants->Set(String::NewSymbol("VERSION"), String::New(LUA_VERSION)); + constants->Set(String::NewSymbol("VERSION_NUM"), Number::New(LUA_VERSION_NUM)); + constants->Set(String::NewSymbol("COPYRIGHT"), String::New(LUA_COPYRIGHT)); + constants->Set(String::NewSymbol("AUTHORS"), String::New(LUA_AUTHORS)); + target->Set(String::NewSymbol("INFO"), constants); +} + void init_status_constants(Handle target){ Local constants = Object::New(); constants->Set(String::NewSymbol("YIELD"), Number::New(LUA_YIELD)); @@ -36,5 +45,6 @@ void init(Handle target) { LuaObject::Init(target); init_gc_constants(target); init_status_constants(target); + init_info_constants(target); } NODE_MODULE(nodelua, init)