@@ -389,7 +389,8 @@ void MetadataNode::ArrayLengthGetterCallack(Local<Name> property, const Property
389389}
390390
391391Local<Object> MetadataNode::CreateArrayWrapper (Isolate* isolate) {
392- auto node = GetOrCreate (" java/lang/Object" );
392+ // Nodes are shared by every runtime and never freed.
393+ static MetadataNode* const node = GetOrCreate (" java/lang/Object" );
393394 auto ctorFunc = node->GetConstructorFunction (isolate);
394395
395396 auto arrayObjectTemplate = GetOrCreateArrayObjectTemplate (isolate);
@@ -656,12 +657,11 @@ void MetadataNode::PropertyAccessorGetterCallback(const FunctionCallbackInfo<Val
656657 auto thiz = info.This ();
657658 auto propertyCallbackData = reinterpret_cast <PropertyCallbackData*>(info.Data ().As <External>()->Value (v8::kExternalPointerTypeTagDefault ));
658659
659- std::string getterMethodName = propertyCallbackData->getterMethodName ;
660- if (getterMethodName == " " ){
660+ if (propertyCallbackData->getterName .IsEmpty ()) {
661661 throw NativeScriptException (" Missing getter method for property: " + propertyCallbackData->propertyName );
662662 }
663663
664- auto getter = thiz->Get (context, v8::String::NewFromUtf8 (isolate, getterMethodName. c_str ()). ToLocalChecked ( )).ToLocalChecked ();
664+ auto getter = thiz->Get (context, propertyCallbackData-> getterName . Get (isolate )).ToLocalChecked ();
665665 auto value = getter.As <Function>()->Call (context, thiz, 0 , nullptr ).ToLocalChecked ();
666666 info.GetReturnValue ().Set (value);
667667 } catch (NativeScriptException& e) {
@@ -684,12 +684,11 @@ void MetadataNode::PropertyAccessorSetterCallback(const FunctionCallbackInfo<Val
684684 auto thiz = info.This ();
685685 auto propertyCallbackData = reinterpret_cast <PropertyCallbackData*>(info.Data ().As <External>()->Value (v8::kExternalPointerTypeTagDefault ));
686686
687- std::string setterMethodName = propertyCallbackData->setterMethodName ;
688- if (setterMethodName == " " ){
687+ if (propertyCallbackData->setterName .IsEmpty ()) {
689688 throw NativeScriptException (" Missing setter method for property: " + propertyCallbackData->propertyName );
690689 }
691690
692- auto setter = thiz->Get (context, v8::String::NewFromUtf8 (isolate, setterMethodName. c_str ()). ToLocalChecked ( )).ToLocalChecked ();
691+ auto setter = thiz->Get (context, propertyCallbackData-> setterName . Get (isolate )).ToLocalChecked ();
693692 setter.As <Function>()->Call (context, thiz, 1 , &value).ToLocalChecked ();
694693 info.GetReturnValue ().Set (value);
695694 } catch (NativeScriptException& e) {
@@ -709,7 +708,7 @@ void MetadataNode::SuperAccessorGetterCallback(const FunctionCallbackInfo<Value>
709708 try {
710709 auto isolate = info.GetIsolate ();
711710 auto thiz = ResolveProxyReceiver (isolate, info.This (), " read" , " super" , true );
712- auto key = ArgConverter::ConvertToV8String (isolate, " supervalue " );
711+ auto key = V8StringConstants::GetSuperValuePrivate (isolate);
713712 Local<Value> hidenVal;
714713 V8GetPrivateValue (isolate, thiz, key, hidenVal);
715714 auto superValue = hidenVal.As <Object>();
@@ -980,7 +979,7 @@ void MetadataNode::SetInstanceMethodsFromStaticMetadata(
980979 setterMethodName = entry.getName ();
981980 }
982981
983- auto propertyInfo = cache->Own <PropertyCallbackData>(propertyName, getterMethodName, setterMethodName);
982+ auto propertyInfo = cache->Own <PropertyCallbackData>(isolate, propertyName, getterMethodName, setterMethodName);
984983 protoFiller.FillPrototypeProperty (isolate, propertyName, propertyInfo);
985984 }
986985}
@@ -1444,7 +1443,7 @@ Persistent<Function>* MetadataNode::GetPersistentConstructorFunction(Isolate* is
14441443
14451444MetadataNode::TypeMetadata* MetadataNode::GetTypeMetadata (Isolate* isolate, const Local<Function>& value) {
14461445 Local<Value> hiddenVal;
1447- V8GetPrivateValue (isolate, value, String::NewFromUtf8 (isolate, " typemetadata " ). ToLocalChecked ( ), hiddenVal);
1446+ V8GetPrivateValue (isolate, value, V8StringConstants::GetTypeMetadataPrivate (isolate), hiddenVal);
14481447 if (hiddenVal.IsEmpty () || !hiddenVal->IsExternal ()) {
14491448 return nullptr ;
14501449 }
@@ -1454,7 +1453,7 @@ MetadataNode::TypeMetadata* MetadataNode::GetTypeMetadata(Isolate* isolate, cons
14541453}
14551454
14561455void MetadataNode::SetTypeMetadata (Isolate* isolate, Local<Function> value, TypeMetadata* data) {
1457- V8SetPrivateValue (isolate, value, String::NewFromUtf8 (isolate, " typemetadata " ). ToLocalChecked (), External::New (isolate, data, v8::kExternalPointerTypeTagDefault ));
1456+ V8SetPrivateValue (isolate, value, V8StringConstants::GetTypeMetadataPrivate (isolate), External::New (isolate, data, v8::kExternalPointerTypeTagDefault ));
14581457}
14591458
14601459MetadataNode::InstanceData& MetadataNode::GetInstanceData (Isolate* isolate) {
@@ -1521,7 +1520,7 @@ void MetadataNode::ExtendedClassConstructorCallback(const v8::FunctionCallbackIn
15211520
15221521 SetInstanceMetadata (isolate, thiz, extData->node );
15231522 thiz->SetInternalField (static_cast <int >(ObjectManager::MetadataNodeKeys::CallSuper), True (isolate));
1524- V8SetPrivateValue (isolate, thiz, V8StringConstants::GetImplementationObject (isolate), implementationObject);
1523+ V8SetPrivateValue (isolate, thiz, V8StringConstants::GetImplementationObjectPrivate (isolate), implementationObject);
15251524
15261525 ArgsWrapper argWrapper (info, ArgType::Class);
15271526
@@ -1591,7 +1590,7 @@ void MetadataNode::InterfaceConstructorCallback(const v8::FunctionCallbackInfo<v
15911590
15921591 implementationObject->SetPrototype (context, thiz->GetPrototype ());
15931592 thiz->SetPrototype (context, implementationObject);
1594- V8SetPrivateValue (isolate, thiz, V8StringConstants::GetImplementationObject (isolate), implementationObject);
1593+ V8SetPrivateValue (isolate, thiz, V8StringConstants::GetImplementationObjectPrivate (isolate), implementationObject);
15951594
15961595 ArgsWrapper argWrapper (info, ArgType::Interface);
15971596
@@ -1648,8 +1647,8 @@ void MetadataNode::MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& inf
16481647
16491648 auto e = info.Data ().As <External>();
16501649
1651- auto callbackData = reinterpret_cast <MethodCallbackData*>(e->Value (v8::kExternalPointerTypeTagDefault ));
16521650 auto initialCallbackData = reinterpret_cast <MethodCallbackData*>(e->Value (v8::kExternalPointerTypeTagDefault ));
1651+ auto callbackData = initialCallbackData;
16531652
16541653 // Number of arguments the method is invoked with
16551654 int argLength = info.Length ();
@@ -1772,7 +1771,7 @@ Local<Object> MetadataNode::GetImplementationObject(Isolate* isolate, const Loca
17721771 Local<Object> implementationObject;
17731772
17741773 Local<Value> hiddenVal;
1775- V8GetPrivateValue (isolate, object, V8StringConstants::GetImplementationObject (isolate), hiddenVal);
1774+ V8GetPrivateValue (isolate, object, V8StringConstants::GetImplementationObjectPrivate (isolate), hiddenVal);
17761775 implementationObject = hiddenVal.As <Object>();
17771776
17781777 if (!implementationObject.IsEmpty ()) {
0 commit comments