Changeset 20090 for trunk


Ignore:
Timestamp:
04/21/21 18:48:47 (4 years ago)
Author:
tbretz
Message:
ObjectTemplates can not hold non primitive values anymore, therefore implemented a workaround.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r20085 r20090  
    479479}
    480480
     481void InterpreterV8::GetterCallback(Local< Name > name, const PropertyCallbackInfo< Value > &info)
     482{
     483    //const string server = *String::Utf8Value(name);
     484    info.GetReturnValue().Set(info.Data());
     485}
     486
     487
     488void InterpreterV8::SetProperty(Handle<ObjectTemplate> &obj, const char *name, const Local<Value> &val)
     489{
     490    // My answer on: https://bugs.chromium.org/p/v8/issues/detail?id=4997
     491    obj->SetNativeDataProperty(String::NewFromUtf8(Isolate::GetCurrent(), name),
     492                               GetterCallback,
     493                               nullptr,
     494                               val,
     495                               ReadOnly,
     496                               Local<AccessorSignature>(),
     497                               ALL_CAN_READ);
     498}
     499
     500
    481501void InterpreterV8::FuncState(const Arguments& args)
    482502{
     
    515535    MaybeLocal<Value> date = Date::New(isolate->GetCurrentContext(), rc.time.JavaDate());
    516536    if (rc.index>-256 && !date.IsEmpty())
    517         obj->Set(String::NewFromUtf8(isolate, "time"), date.ToLocalChecked());
     537        SetProperty(obj, "time", date.ToLocalChecked());
    518538
    519539    args.GetReturnValue().Set(obj->NewInstance());
     
    19771997         MaybeLocal<Value> date = Date::New(isolate->GetCurrentContext(), state.time.JavaDate());
    19781998         if (!date.IsEmpty())
     1999             SetProperty(obj, "time", date.ToLocalChecked());
     2000         /*
    19792001         {
    19802002             obj->Set(String::NewFromUtf8(isolate, "time"), date.ToLocalChecked()->ToString(), ReadOnly);
     
    19822004             // This crahshes when called a secont time. I don't know why.
    19832005             // obj->Set(String::NewFromUtf8(isolate, "time"), date.ToLocalChecked(), ReadOnly);
    1984          }
     2006         }*/
    19852007    }
    19862008
  • trunk/FACT++/src/InterpreterV8-4.h

    r20085 r20090  
    8484
    8585    static void TerminateExecution(v8::Isolate*);
     86
     87
     88    static void GetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value> &info);
     89    static void SetProperty(v8::Handle<v8::ObjectTemplate> &obj, const char *name, const v8::Local<v8::Value> &val);
     90
    8691
    8792    void FuncWait(const FactArguments& args);
Note: See TracChangeset for help on using the changeset viewer.