Changeset 14641 for trunk/FACT++


Ignore:
Timestamp:
11/17/12 15:52:14 (12 years ago)
Author:
tbretz
Message:
Converted dim.subscrib into object Subscription
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/InterpreterV8.cc

    r14640 r14641  
    11161116}*/
    11171117
    1118 Handle<Value> InterpreterV8::FuncSubscribe(const Arguments &args)
    1119 {
     1118Handle<Value> InterpreterV8::FuncSubscription(const Arguments &args)
     1119{
     1120    if (!args.IsConstructCall())
     1121        return ThrowException(String::New("Subscription must be calles as constructor."));
     1122
    11201123    if (args.Length()!=1)
    11211124        return ThrowException(String::New("Number of arguments must be exactly 1."));
     
    11231126    if (!args[0]->IsString())
    11241127        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."));
    11281128
    11291129    const String::Utf8Value str(args[0]);
     
    11391139    HandleScope handle_scope;
    11401140
    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);
    11581151
    11591152    // Persistent<Object> p = Persistent<Object>::New(obj->NewInstance());
     
    16981691    dim->Set(String::New("getState"),  FunctionTemplate::New(WrapGetState),  ReadOnly);
    16991692    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);
    17021693    dim->Set(String::New("file"),      FunctionTemplate::New(WrapFile),      ReadOnly);
    17031694
    1704     // timeout   -> Thread  - class?
    1705     // subscribe -> Service - class?
    17061695    // file      -> File    - class?
    17071696    // new class State ?
     
    17191708    global->Set(String::New("exit"),     FunctionTemplate::New(WrapExit),                   ReadOnly);
    17201709    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);
    17211715
    17221716    Handle<FunctionTemplate> db = FunctionTemplate::New(WrapDatabase);
  • trunk/FACT++/src/InterpreterV8.h

    r14638 r14641  
    7373    v8::Handle<v8::Value> FuncNewState(const v8::Arguments& args);
    7474    //v8::Handle<v8::Value> FuncOpen(const v8::Arguments& args);
    75     v8::Handle<v8::Value> FuncSubscribe(const v8::Arguments& args);
     75    v8::Handle<v8::Value> FuncSubscription(const v8::Arguments& args);
    7676    v8::Handle<v8::Value> FuncGetData(const v8::Arguments &args);
    7777    v8::Handle<v8::Value> FuncClose(const v8::Arguments &args);
     
    114114    static v8::Handle<v8::Value> WrapGetState(const v8::Arguments &args) { if (This) return This->FuncGetState(args); else return v8::Undefined(); }
    115115    //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> WrapSubscribe(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(); }
    117117    static v8::Handle<v8::Value> WrapGetData(const v8::Arguments &args)  { if (This) return This->FuncGetData(args);  else return v8::Undefined(); }
    118118    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.