Changeset 14125 for trunk/FACT++


Ignore:
Timestamp:
06/08/12 17:24:12 (12 years ago)
Author:
tbretz
Message:
Store pointer to event in external field -- not sure if we'll ever need that.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r14122 r14125  
    302302    HandleScope handle_scope;
    303303
     304    //const void *ptr = Local<External>::Cast(info.This()->GetInternalField(0))->Value();
     305
    304306    const String::Utf8Value str(args.Holder()->Get(String::New("name")));
    305307    return Boolean::New(JsUnsubscribe(*str));
     
    320322    //if (counter==cnt)
    321323    //    return info.Holder();//Holder()->Get(String::New("data"));
    322     //cout << counter << " " << cnt << endl;
    323 
    324     //const void *ppp = Local<External>::Cast(info.This()->GetInternalField(0))->Value();
    325     //info.This()->SetInternalField(0, External::New((void*)evt));
    326     //cout << info.This().
    327324
    328325    const vector<Description> vec = JsDescription(*str);
     
    418415    const String::Utf8Value str(args[0]);
    419416
    420     JsSubscribe(*str);
    421 
    422     //args.This()->SetInternalField(0, External::New((void*)test));
    423     //obj->SetInternalFieldCount(1);
    424 
    425     Handle<ObjectTemplate> obj = ObjectTemplate::New();
    426     obj->Set(String::New("get"),   FunctionTemplate::New(WrapGetData), ReadOnly);
    427     obj->Set(String::New("close"), FunctionTemplate::New(WrapClose),   ReadOnly);
    428     obj->Set(String::New("name"),  String::New(*str), ReadOnly);
    429     //obj->Set(String::New("toString"), String::New(("[object Dim "+string(*str)+"]").c_str()), ReadOnly);
    430 
    431     return obj->NewInstance();
     417    void *ptr = JsSubscribe(*str);
     418    if (ptr==0)
     419        return ThrowException(String::New(("Subscription to '"+string(*str)+"' already exists.").c_str()));
     420
     421    Handle<ObjectTemplate> tem = ObjectTemplate::New();
     422    tem->Set(String::New("get"),   FunctionTemplate::New(WrapGetData), ReadOnly);
     423    tem->Set(String::New("close"), FunctionTemplate::New(WrapClose),   ReadOnly);
     424    tem->Set(String::New("name"),  String::New(*str), ReadOnly);
     425    tem->SetInternalFieldCount(1);
     426    //tem->Set(String::New("toString"), String::New(("[object Dim "+string(*str)+"]").c_str()), ReadOnly);
     427
     428    Handle<Object> obj = tem->NewInstance();
     429    obj->SetInternalField(0, External::New(ptr));
     430
     431    return handle_scope.Close(obj);
    432432
    433433    // Persistent<Object> p = Persistent<Object>::New(obj->NewInstance());
  • trunk/FACT++/src/InterpreterV8.h

    r14093 r14125  
    7171    virtual std::pair<int32_t, std::string>  JsState(const std::string &) { return std::make_pair(-256, ""); };
    7272    virtual void *JsSubscribe(const std::string &) { return 0; };
    73     virtual bool JsUnsubscribe(const std::string &) { return false; };
     73    virtual bool  JsUnsubscribe(const void *) { return false; };
    7474    virtual std::vector<Description> JsDescription(const std::string &) { return std::vector<Description>(); };
    7575    virtual std::pair<uint64_t, EventImp *> JsGetEvent(const std::string &) { return std::make_pair(0, (EventImp*)0); };
Note: See TracChangeset for help on using the changeset viewer.