Browse Source

prune out ported code

v0.2.x
Brett Langdon 13 years ago
parent
commit
2b28480462
2 changed files with 0 additions and 82 deletions
  1. +0
    -65
      src/luaobject.cc
  2. +0
    -17
      src/luaobject.h

+ 0
- 65
src/luaobject.cc View File

@ -4,30 +4,7 @@
#include "luaobject.h"
using namespace v8;
LuaObject::LuaObject() {};
LuaObject::~LuaObject() {};
std::map<char *, Persistent<Function> > functions;
void LuaObject::Init(Handle<Object> target) {
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
tpl->SetClassName(String::NewSymbol("LuaObject"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
tpl->PrototypeTemplate()->Set(String::NewSymbol("doString"),
FunctionTemplate::New(DoString)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("getGlobal"),
FunctionTemplate::New(GetGlobal)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("registerFunction"),
FunctionTemplate::New(RegisterFunction)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("status"),
FunctionTemplate::New(Status)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("collectGarbage"),
FunctionTemplate::New(CollectGarbage)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("close"),
FunctionTemplate::New(Close)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("push"),
FunctionTemplate::New(Push)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("pop"),
@ -38,50 +15,8 @@ void LuaObject::Init(Handle<Object> target) {
FunctionTemplate::New(SetTop)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("replace"),
FunctionTemplate::New(Replace)->GetFunction());
Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction());
target->Set(String::NewSymbol("LuaObject"), constructor);
}
Handle<Value> LuaObject::New(const Arguments& args) {
HandleScope scope;
LuaObject* obj = new LuaObject();
obj->lua_ = lua_open();
luaL_openlibs(obj->lua_);
lua_register(obj->lua_, "nodelua", LuaObject::CallFunction);
obj->Wrap(args.This());
return args.This();
}
Handle<Value> LuaObject::CollectGarbage(const Arguments& args){
HandleScope scope;
if(args.Length() < 1){
ThrowException(Exception::TypeError(String::New("Wrong number of arguments")));
return scope.Close(Undefined());
}
if(!args[0]->IsNumber()){
ThrowException(Exception::TypeError(String::New("Argument 1 must be a number, try nodelua.GC")));
return scope.Close(Undefined());
}
LuaObject* obj = ObjectWrap::Unwrap<LuaObject>(args.This());
int type = (int)args[0]->ToNumber()->Value();
int gc = lua_gc(obj->lua_, type, 0);
return scope.Close(Number::New(gc));
}
Handle<Value> LuaObject::Push(const Arguments& args) {
HandleScope scope;


+ 0
- 17
src/luaobject.h View File

@ -13,28 +13,11 @@ extern "C"{
}
class LuaObject : public node::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> target);
static int CallFunction(lua_State *L);
private:
LuaObject();
~LuaObject();
static v8::Handle<v8::Value> New(const v8::Arguments& args);
static v8::Handle<v8::Value> DoString(const v8::Arguments& args);
static v8::Handle<v8::Value> GetGlobal(const v8::Arguments& args);
static v8::Handle<v8::Value> RegisterFunction(const v8::Arguments& args);
static v8::Handle<v8::Value> Status(const v8::Arguments& args);
static v8::Handle<v8::Value> CollectGarbage(const v8::Arguments& args);
static v8::Handle<v8::Value> Close(const v8::Arguments& args);
static v8::Handle<v8::Value> Push(const v8::Arguments& args);
static v8::Handle<v8::Value> Pop(const v8::Arguments& args);
static v8::Handle<v8::Value> GetTop(const v8::Arguments& args);
static v8::Handle<v8::Value> SetTop(const v8::Arguments& args);
static v8::Handle<v8::Value> Replace(const v8::Arguments& args);
lua_State *lua_;
};
#endif

Loading…
Cancel
Save