void Point::GetX( Local< String > prop, const PropertyCallbackInfo< Value > &info ) { // Enter new scope HandleScope scope; // Get wrapped object Local< Object > self = info.Holder(); Local< External > wrap = Local< External >::Cast( self->GetInternalField( 0 ) ); // Set return value Point* point = static_cast< Point* >( wrap->Value() ); info.GetReturnValue().Set( Number::New( point->GetX() ) ); }
void BookWrap::Enumerator(const PropertyCallbackInfo<Array>& info) { Isolate* isolate = info.GetIsolate(); HandleScope scope(isolate); Book* b = ObjectWrap::Unwrap<BookWrap>(info.This())->m_book; Handle<v8::Array> result = v8::Array::New(isolate, b->size()); for(size_t i=0; i<b->size(); ++i) { result->Set(i, Integer::New(isolate, i)); } info.GetReturnValue().Set(result); }
void MetadataNode::PackageGetterCallback(Local<String> property, const PropertyCallbackInfo<Value>& info) { try { string propName = ConvertToString(property); if (propName.empty()) return; auto isolate = Isolate::GetCurrent(); HandleScope handleScope(isolate); auto thiz = info.This(); auto cachedItem = thiz->GetHiddenValue(property); if (cachedItem.IsEmpty()) { auto node = GetPackageMetadata(isolate, thiz); uint8_t nodeType = s_metadataReader.GetNodeType(node->m_treeNode); DEBUG_WRITE("MetadataNode::GetterCallback: prop '%s' for node '%s' called, nodeType=%d, hash=%d", propName.c_str(), node->m_treeNode->name.c_str(), nodeType, thiz.IsEmpty() ? -42 : thiz->GetIdentityHash()); auto child = GetChildMetadataForPackage(node, propName); auto foundChild = child.treeNode != nullptr; if (foundChild) { auto childNode = MetadataNode::GetOrCreateInternal(child.treeNode); cachedItem = childNode->CreateWrapper(isolate); thiz->SetHiddenValue(property, cachedItem); } } info.GetReturnValue().Set(cachedItem); } catch (NativeScriptException& e) { e.ReThrowToV8(); } catch (std::exception e) { stringstream ss; ss << "Error: c++ exception: " << e.what() << endl; NativeScriptException nsEx(ss.str()); nsEx.ReThrowToV8(); } catch (...) { NativeScriptException nsEx(std::string("Error: c++ exception!")); nsEx.ReThrowToV8(); } }
// プロパティの取得 void TJSObject::getter(Local<String> property, const PropertyCallbackInfo<Value>& info) { Isolate *isolate = info.GetIsolate(); HandleScope handle_scope(isolate); String::Value propName(property); if (wcscmp(*propName, TJSINSTANCENAME) == 0) { return; } tTJSVariant self; if (getVariant(isolate, self, info.This())) { tjs_error error; tTJSVariant result; if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().PropGet(0, *propName, NULL, &result, NULL))) { info.GetReturnValue().Set(toJSValue(isolate, result)); } else { info.GetReturnValue().Set(ERROR_KRKR(isolate, error)); } return; } info.GetReturnValue().Set(ERROR_BADINSTANCE(isolate)); }
void JsHttpRequestProcessor::GetPath(Local<String> name, const PropertyCallbackInfo<Value>& info) { // Extract the C++ request object from the JavaScript wrapper. HttpRequest* request = UnwrapRequest(info.Holder()); // Fetch the path. const string& path = request->Path(); // Wrap the result in a JavaScript string and return it. info.GetReturnValue().Set( String::NewFromUtf8(info.GetIsolate(), path.c_str(), NewStringType::kNormal, static_cast<int>(path.length())).ToLocalChecked()); }
void JsHttpRequestProcessor::MapSet(Local<Name> name, Local<Value> value_obj, const PropertyCallbackInfo<Value>& info) { if (name->IsSymbol()) return; // Fetch the map wrapped by this object. map<string, string>* obj = UnwrapMap(info.Holder()); // Convert the key and value to std::strings. string key = ObjectToString(Local<String>::Cast(name)); string value = ObjectToString(value_obj); // Update the map. (*obj)[key] = value; // Return the value; any non-empty handle will work. info.GetReturnValue().Set(value_obj); }
void MetadataNode::SuperAccessorGetterCallback(Local<String> property, const PropertyCallbackInfo<Value>& info) { try { auto thiz = info.This(); auto isolate = info.GetIsolate(); auto k = ConvertToV8String("supervalue"); auto superValue = thiz->GetHiddenValue(k).As<Object>(); if (superValue.IsEmpty()) { superValue = s_objectManager->GetEmptyObject(isolate); bool d = superValue->Delete(ConvertToV8String("toString")); d = superValue->Delete(ConvertToV8String("valueOf")); superValue->SetInternalField(static_cast<int>(ObjectManager::MetadataNodeKeys::CallSuper), True(isolate)); superValue->SetPrototype(thiz->GetPrototype().As<Object>()->GetPrototype().As<Object>()->GetPrototype()); thiz->SetHiddenValue(k, superValue); s_objectManager->CloneLink(thiz, superValue); DEBUG_WRITE("superValue.GetPrototype=%d", superValue->GetPrototype().As<Object>()->GetIdentityHash()); auto node = GetInstanceMetadata(isolate, thiz); SetInstanceMetadata(isolate, superValue, node); thiz->SetHiddenValue(k, superValue); } info.GetReturnValue().Set(superValue); } catch (NativeScriptException& e) { e.ReThrowToV8(); } catch (std::exception e) { stringstream ss; ss << "Error: c++ exception: " << e.what() << endl; NativeScriptException nsEx(ss.str()); nsEx.ReThrowToV8(); } catch (...) { NativeScriptException nsEx(std::string("Error: c++ exception!")); nsEx.ReThrowToV8(); } }
void MetadataNode::InnerClassAccessorGetterCallback(Local<String> property, const PropertyCallbackInfo<Value>& info) { try { auto isolate = info.GetIsolate(); auto thiz = info.This(); auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value()); auto innerKey = ConvertToV8String("inner:" + node->m_treeNode->name); auto innerTypeCtorFunc = thiz->GetHiddenValue(innerKey).As<Function>(); if (innerTypeCtorFunc.IsEmpty()) { auto funcTemplate = node->GetConstructorFunctionTemplate(isolate, node->m_treeNode); auto ctorFunc = funcTemplate->GetFunction(); auto innerClassData = External::New(isolate, new InnerClassData(new Persistent<Object>(isolate, thiz), node)); auto innerTypeCtorFuncTemplate = FunctionTemplate::New(isolate, InnerClassConstructorCallback, innerClassData); innerTypeCtorFuncTemplate->InstanceTemplate()->SetInternalFieldCount(static_cast<int>(ObjectManager::MetadataNodeKeys::END)); innerTypeCtorFunc = innerTypeCtorFuncTemplate->GetFunction(); auto prototypeName = ConvertToV8String("prototype"); auto innerTypeCtorFuncPrototype = innerTypeCtorFunc->Get(prototypeName).As<Object>(); innerTypeCtorFuncPrototype->SetPrototype(ctorFunc->Get(prototypeName)); thiz->SetHiddenValue(innerKey, innerTypeCtorFunc); } info.GetReturnValue().Set(innerTypeCtorFunc); } catch (NativeScriptException& e) { e.ReThrowToV8(); } catch (std::exception e) { stringstream ss; ss << "Error: c++ exception: " << e.what() << endl; NativeScriptException nsEx(ss.str()); nsEx.ReThrowToV8(); } catch (...) { NativeScriptException nsEx(std::string("Error: c++ exception!")); nsEx.ReThrowToV8(); } }
static void gum_v8_probe_args_on_get_nth (uint32_t index, const PropertyCallbackInfo<Value> & info) { Handle<Object> instance = info.This (); GumV8CallProbe * self = static_cast<GumV8CallProbe *> ( instance->GetAlignedPointerFromInternalField (0)); GumCallSite * site = static_cast<GumCallSite *> ( instance->GetAlignedPointerFromInternalField (1)); gsize value; gsize * stack_argument = static_cast<gsize *> (site->stack_data); #if defined (HAVE_I386) && GLIB_SIZEOF_VOID_P == 8 switch (index) { # if GUM_NATIVE_ABI_IS_UNIX case 0: value = site->cpu_context->rdi; break; case 1: value = site->cpu_context->rsi; break; case 2: value = site->cpu_context->rdx; break; case 3: value = site->cpu_context->rcx; break; case 4: value = site->cpu_context->r8; break; case 5: value = site->cpu_context->r9; break; default: value = stack_argument[index - 6]; break; # else case 0: value = site->cpu_context->rcx; break; case 1: value = site->cpu_context->rdx; break; case 2: value = site->cpu_context->r8; break; case 3: value = site->cpu_context->r9; break; default: value = stack_argument[index]; break; # endif } #else value = stack_argument[index]; #endif info.GetReturnValue ().Set ( _gum_v8_native_pointer_new (GSIZE_TO_POINTER (value), self->parent->core)); }
void Shape::attributeGetValue(Local<String> name, const PropertyCallbackInfo<Value> &info) { Local<Object> self = info.Holder(); Local<External> wrap = Local<External>::Cast(self->GetInternalField(0)); void *ptr = wrap->Value(); map<string, int> *indexes = static_cast<map<string, int> *>(ptr); wrap = Local<External>::Cast(self->GetInternalField(1)); ptr = wrap->Value(); char **values = static_cast<char **>(ptr); String::Utf8Value utf8_value(name); string key = string(*utf8_value); map<string, int>::iterator iter = indexes->find(key); if (iter != indexes->end()) { const int &index = (*iter).second; info.GetReturnValue().Set(String::New(values[index])); } }
void MetadataNode::FieldAccessorSetterCallback(Local<String> property,Local<Value> value, const PropertyCallbackInfo<void>& info) { DEBUG_WRITE("FieldAccessorSetterCallback"); auto thiz = info.This(); auto fieldCallbackData = reinterpret_cast<FieldCallbackData*>(info.Data().As<External>()->Value()); if (fieldCallbackData->isFinal) { stringstream ss; ss << "You are trying to set \"" << fieldCallbackData->name << "\" which is a final field! Final fields can only be read."; string exceptionMessage = ss.str(); ExceptionUtil::GetInstance()->ThrowExceptionToJs(exceptionMessage); } else { NativeScriptRuntime::SetJavaField(thiz, value, fieldCallbackData); info.GetReturnValue().Set(value); } }
void JsHttpRequestProcessor::MapGet(Local<Name> name, const PropertyCallbackInfo<Value>& info) { if (name->IsSymbol()) return; // Fetch the map wrapped by this object. map<string, string>* obj = UnwrapMap(info.Holder()); // Convert the JavaScript string to a std::string. string key = ObjectToString(Local<String>::Cast(name)); // Look up the value if it exists using the standard STL ideom. map<string, string>::iterator iter = obj->find(key); // If the key is not present return an empty handle as signal if (iter == obj->end()) return; // Otherwise fetch the value and wrap it in a JavaScript string const string& value = (*iter).second; info.GetReturnValue().Set( String::NewFromUtf8(info.GetIsolate(), value.c_str(), NewStringType::kNormal, static_cast<int>(value.length())).ToLocalChecked()); }
void MetadataNode::ArrayLengthGetterCallack(Local<String> property, const PropertyCallbackInfo<Value>& info) { try { auto thiz = info.This(); auto length = NativeScriptRuntime::GetArrayLength(thiz); info.GetReturnValue().Set(Integer::New(info.GetIsolate(), length)); } catch (NativeScriptException& e) { e.ReThrowToV8(); } catch (std::exception e) { stringstream ss; ss << "Error: c++ exception: " << e.what() << endl; NativeScriptException nsEx(ss.str()); nsEx.ReThrowToV8(); } catch (...) { NativeScriptException nsEx(std::string("Error: c++ exception!")); nsEx.ReThrowToV8(); } }
void Proxy::getIndexedProperty(uint32_t index, const PropertyCallbackInfo<Value>& info) { Isolate* isolate = info.GetIsolate(); JNIEnv* env = JNIScope::getEnv(); if (!env) { JSException::GetJNIEnvironmentError(isolate); return; } Proxy* proxy = NativeObject::Unwrap<Proxy>(info.Holder()); jobject javaProxy = proxy->getJavaObject(); jobject value = env->CallObjectMethod(javaProxy, JNIUtil::krollProxyGetIndexedPropertyMethod, index); if (!JavaObject::useGlobalRefs) { env->DeleteLocalRef(javaProxy); } Local<Value> result = TypeConverter::javaObjectToJsValue(isolate, env, value); env->DeleteLocalRef(value); info.GetReturnValue().Set(result); }
//! \verbatim //! Real Quaternion.z //! \endverbatim void Quaternion::jsGetZ( Local<v8::String> prop, const PropertyCallbackInfo<v8::Value>& info ) { Quaternion* ptr = unwrap( info.This() ); info.GetReturnValue().Set( ptr->z ); }
void MetadataNode::ArrayLengthGetterCallack(Local<String> property, const PropertyCallbackInfo<Value>& info) { auto thiz = info.This(); auto length = NativeScriptRuntime::GetArrayLength(thiz); info.GetReturnValue().Set(Integer::New(info.GetIsolate(), length)); }
void GetOriginX(Local<v8::String> name, const PropertyCallbackInfo<Value>& info) { DEFINE_HANDLE_SCOPE_AND_GET_SELF_FOR_TRANSFORMABLE; info.GetReturnValue().Set(Number::New(info.GetIsolate(), static_cast<double>(self->getOrigin().x))); }
void UiWindow::GetOnMessage(Local<String> property, const PropertyCallbackInfo<Value>& info) { Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); UiWindow* _this = Unwrap<UiWindow>(info.This()); info.GetReturnValue().Set(_this->_onMessageFn); }
void Dollar::jsGetter(Local<String> property, const PropertyCallbackInfo<v8::Value>& info) { auto data = info.Data(); info.GetReturnValue().Set(data); }
void TaskStateChangeNotification::TaskStateGetter(Local<String> property, const PropertyCallbackInfo<Value>& info) { Local<Object> self = info.Holder(); TaskStateChangeNotification* command=Unwrap<TaskStateChangeNotification>(self); int value = command->state; info.GetReturnValue().Set(value); }
void TaskStateChangeNotification::TaskNameGetter(Local<String> property, const PropertyCallbackInfo<Value>& info) { Local<Object> self = info.Holder(); TaskStateChangeNotification* command=Unwrap<TaskStateChangeNotification>(self); string value = command->task; info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), value.c_str())); }
void SideNotification::SideGetter(Local<String> property, const PropertyCallbackInfo<Value>& info){ Local<Object> self = info.Holder(); SideNotification* notification=Unwrap<SideNotification>(self); info.GetReturnValue().Set(notification->getSide()); }
void APIModule::getter_apiName(Local<Name> name, const PropertyCallbackInfo<Value>& args) { args.GetReturnValue().Set(STRING_NEW(args.GetIsolate(), "Ti.API")); }
void Proxy::getProperty(Local<Name> property, const PropertyCallbackInfo<Value>& args) { Isolate* isolate = args.GetIsolate(); args.GetReturnValue().Set(getPropertyForProxy(isolate, property->ToString(isolate), args.Holder())); }
void Texture2D::GetHeight( Local<String> name, const PropertyCallbackInfo<Value>& args) { HandleScope scope(args.GetIsolate()); auto self = GetInternalObject(args.Holder()); args.GetReturnValue().Set(self->height()); }
void CanvasRenderingContext2D::GetStrokeStyle(Local<Name> property, const PropertyCallbackInfo<Value>& info) { auto context = ToContext(info); info.GetReturnValue().Set(ConvertToV8String(context->myStrokeStyle)); }