Changeset 14641 for trunk/FACT++
- Timestamp:
- 11/17/12 15:52:14 (12 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/InterpreterV8.cc
r14640 r14641 1116 1116 }*/ 1117 1117 1118 Handle<Value> InterpreterV8::FuncSubscribe(const Arguments &args) 1119 { 1118 Handle<Value> InterpreterV8::FuncSubscription(const Arguments &args) 1119 { 1120 if (!args.IsConstructCall()) 1121 return ThrowException(String::New("Subscription must be calles as constructor.")); 1122 1120 1123 if (args.Length()!=1) 1121 1124 return ThrowException(String::New("Number of arguments must be exactly 1.")); … … 1123 1126 if (!args[0]->IsString()) 1124 1127 return ThrowException(String::New("Argument 1 must be a string.")); 1125 1126 //if (!args.IsConstructCall())1127 // return ThrowException(String::New("Must be used as constructor."));1128 1128 1129 1129 const String::Utf8Value str(args[0]); … … 1139 1139 HandleScope handle_scope; 1140 1140 1141 Handle<ObjectTemplate> tem = ObjectTemplate::New(); 1142 tem->Set(String::New("get"), FunctionTemplate::New(WrapGetData), ReadOnly); 1143 tem->Set(String::New("close"), FunctionTemplate::New(WrapClose), ReadOnly); 1144 tem->Set(String::New("name"), String::New(*str), ReadOnly); 1145 tem->Set(String::New("isOpen"), Boolean::New(true)); 1146 tem->SetInternalFieldCount(1); 1147 //tem->Set(String::New("toString"), String::New(("[object Dim "+string(*str)+"]").c_str()), ReadOnly); 1148 1149 Handle<Object> obj = tem->NewInstance(); 1150 if (obj.IsEmpty()) 1151 return Undefined(); 1152 1153 obj->SetInternalField(0, External::New(ptr)); 1154 1155 fReverseMap[*str] = Persistent<Object>::New(obj); 1156 1157 return handle_scope.Close(obj); 1141 Handle<Object> This = args.This(); 1142 This->Set(String::New("get"), FunctionTemplate::New(WrapGetData)->GetFunction(), ReadOnly); 1143 This->Set(String::New("close"), FunctionTemplate::New(WrapClose)->GetFunction(), ReadOnly); 1144 This->Set(String::New("name"), String::New(*str), ReadOnly); 1145 This->Set(String::New("isOpen"), Boolean::New(true)); 1146 This->SetInternalField(0, External::New(ptr)); 1147 1148 fReverseMap[*str] = Persistent<Object>::New(This); 1149 1150 return Undefined();//handle_scope.Close(obj); 1158 1151 1159 1152 // Persistent<Object> p = Persistent<Object>::New(obj->NewInstance()); … … 1698 1691 dim->Set(String::New("getState"), FunctionTemplate::New(WrapGetState), ReadOnly); 1699 1692 dim->Set(String::New("sleep"), FunctionTemplate::New(WrapSleep), ReadOnly); 1700 dim->Set(String::New("kill"), FunctionTemplate::New(WrapKill), ReadOnly);1701 dim->Set(String::New("subscribe"), FunctionTemplate::New(WrapSubscribe), ReadOnly);1702 1693 dim->Set(String::New("file"), FunctionTemplate::New(WrapFile), ReadOnly); 1703 1694 1704 // timeout -> Thread - class?1705 // subscribe -> Service - class?1706 1695 // file -> File - class? 1707 1696 // new class State ? … … 1719 1708 global->Set(String::New("exit"), FunctionTemplate::New(WrapExit), ReadOnly); 1720 1709 global->Set(String::New("version"), FunctionTemplate::New(InterpreterV8::FuncVersion), ReadOnly); 1710 1711 Handle<FunctionTemplate> sub = FunctionTemplate::New(WrapSubscription); 1712 sub->SetClassName(String::New("Subscription")); 1713 sub->InstanceTemplate()->SetInternalFieldCount(1); 1714 global->Set(String::New("Subscription"), sub, ReadOnly); 1721 1715 1722 1716 Handle<FunctionTemplate> db = FunctionTemplate::New(WrapDatabase); -
trunk/FACT++/src/InterpreterV8.h
r14638 r14641 73 73 v8::Handle<v8::Value> FuncNewState(const v8::Arguments& args); 74 74 //v8::Handle<v8::Value> FuncOpen(const v8::Arguments& args); 75 v8::Handle<v8::Value> FuncSubscri be(const v8::Arguments& args);75 v8::Handle<v8::Value> FuncSubscription(const v8::Arguments& args); 76 76 v8::Handle<v8::Value> FuncGetData(const v8::Arguments &args); 77 77 v8::Handle<v8::Value> FuncClose(const v8::Arguments &args); … … 114 114 static v8::Handle<v8::Value> WrapGetState(const v8::Arguments &args) { if (This) return This->FuncGetState(args); else return v8::Undefined(); } 115 115 //static v8::Handle<v8::Value> WrapOpen(const v8::Arguments &args) { if (This) return This->FuncOpen(args); else return v8::Undefined(); } 116 static v8::Handle<v8::Value> WrapSubscri be(const v8::Arguments &args){ if (This) return This->FuncSubscribe(args);else return v8::Undefined(); }116 static v8::Handle<v8::Value> WrapSubscription(const v8::Arguments &args){ if (This) return This->FuncSubscription(args);else return v8::Undefined(); } 117 117 static v8::Handle<v8::Value> WrapGetData(const v8::Arguments &args) { if (This) return This->FuncGetData(args); else return v8::Undefined(); } 118 118 static v8::Handle<v8::Value> WrapClose(const v8::Arguments &args) { if (This) return This->FuncClose(args); else return v8::Undefined(); }
Note:
See TracChangeset
for help on using the changeset viewer.