Handle<Value> DispObject::NodeGet(Local<String> name, const AccessorInfo& info) { HandleScope scope; String::Value vname(name); LPOLESTR id = (vname.length() > 0) ? (LPOLESTR)*vname : 0; DispObject *me = DispObject::Unwrap<DispObject>(info.This()); if (!id || !me) return Undefined(); NODE_DEBUG_FMT2("DispObject '%S.%S' get", me->name.GetString(), id); // Process standard elements if (_wcsicmp(id, L"valueOf") == 0) return scope.Close(FunctionTemplate::New(NodeValueOf, info.This())->GetFunction()); if (_wcsicmp(id, L"toString") == 0) return scope.Close(FunctionTemplate::New(NodeToString, info.This())->GetFunction()); // Other return scope.Close(me->findElement(id)); }
static void Set_FontState_size(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope scope; Local<Object> self = info.Holder(); Local<External> wrap = Local<External>::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) return; FontState *tmp = (FontState *) wrap->Value(); if (tmp == NULL) return; if (!value.IsEmpty() && value->IsNumber()) tmp->setSize(value->Int32Value()); }
Handle<Value> Color::get_prop(Local<String> property, const AccessorInfo& info) { HandleScope scope; Color* c = ObjectWrap::Unwrap<Color>(info.This()); std::string a = TOSTR(property); if (a == "a") return scope.Close(Integer::New(c->get()->alpha())); else if (a == "r") return scope.Close(Integer::New(c->get()->red())); else if (a == "g") return scope.Close(Integer::New(c->get()->green())); else if (a == "b") return scope.Close(Integer::New(c->get()->blue())); return Undefined(); }
void FieldDefn::typeSetter(Local<String> property, Local<Value> value, const AccessorInfo &info) { HandleScope scope; FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This()); if(!value->IsString()){ NODE_THROW("type must be a string"); return; } std::string name = TOSTR(value); int type = getFieldTypeByName(name); if(type < 0){ NODE_THROW("Unrecognized field type"); } else { def->this_->SetType(OGRFieldType(type)); } }
void PDFPageDriver::SetMediaBox(Local<String> property,Local<Value> value,const AccessorInfo &info) { HandleScope scope; PDFPageDriver* pageDriver = ObjectWrap::Unwrap<PDFPageDriver>(info.Holder()); if(!value->IsArray()) ThrowException(Exception::TypeError(String::New("Media box is set to a value which is not a 4 numbers array"))); if(value->ToObject()->Get(v8::String::New("length"))->ToObject()->Uint32Value() != 4) ThrowException(Exception::TypeError(String::New("Media box is set to a value which is not a 4 numbers array"))); pageDriver->mPDFPage->SetMediaBox(PDFRectangle(value->ToObject()->Get(0)->ToNumber()->Value(), value->ToObject()->Get(1)->ToNumber()->Value(), value->ToObject()->Get(2)->ToNumber()->Value(), value->ToObject()->Get(3)->ToNumber()->Value())); }
/* DESCRIPTION Set Accessor of action property */ void Connection::SetAction(Local<String> property,Local<Value> value, const AccessorInfo& info) { HandleScope scope; Connection *njsConn = ObjectWrap::Unwrap<Connection>(info.Holder()); if(!njsConn->isValid_) { string msg = NJSMessages::getErrorMsg(errInvalidConnection); NJS_SET_EXCEPTION(msg.c_str(), (int) msg.length()); return; } else { std::string action; NJS_SET_PROP_STR( action, value, "action"); njsConn->dpiconn_->action(action); } }
static void Set_FontState_face(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope scope; Local<Object> self = info.Holder(); Local<External> wrap = Local<External>::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) return; FontState *tmp = (FontState *) wrap->Value(); if (tmp == NULL) return; if (!value.IsEmpty() && value->IsString()) { String::Utf8Value utf8_value(value); tmp->setFace(Utf8ToTchar(*utf8_value)); } }
Handle<Value> MSOutputFormat::PropertyGetter (Local<String> property, const AccessorInfo& info) { MSOutputFormat *of = ObjectWrap::Unwrap<MSOutputFormat>(info.This()); v8::String::AsciiValue n(property); if (strcmp(*n, "name") == 0) { RETURN_STRING(of->this_->name); } else if (strcmp(*n, "mimetype") == 0) { RETURN_STRING(of->this_->mimetype); } else if (strcmp(*n, "driver") == 0) { RETURN_STRING(of->this_->driver); } else if (strcmp(*n, "renderer") == 0) { RETURN_NUMBER(of->this_->renderer); } else if (strcmp(*n, "imagemode") == 0) { RETURN_NUMBER(of->this_->imagemode); } else if (strcmp(*n, "transparent") == 0) { RETURN_NUMBER(of->this_->transparent); } return Undefined(); }
// プロパティの取得 Handle<Value> TJSObject::getter(Local<String> property, const AccessorInfo& info) { String::Value propName(property); if (wcscmp(*propName, TJSINSTANCENAME) == 0) { return Handle<Value>(); } tTJSVariant self; if (getVariant(self, info.This())) { tjs_error error; tTJSVariant result; if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().PropGet(0, *propName, NULL, &result, NULL))) { return toJSValue(result); } else { return ERROR_KRKR(error); } } return ERROR_BADINSTANCE(); }
Handle<Value> ZipFile::get_prop(Local<String> property, const AccessorInfo& info) { HandleScope scope; ZipFile* zf = ObjectWrap::Unwrap<ZipFile>(info.This()); std::string a = TOSTR(property); if (a == "count") { return scope.Close(Integer::New(zf->names_.size())); } if (a == "names") { unsigned num = zf->names_.size(); Local<Array> a = Array::New(num); for (unsigned i = 0; i < num; ++i) { a->Set(i, String::New(zf->names_[i].c_str())); } return scope.Close(a); } return Undefined(); }
void Image::set_prop(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope scope; Image* im = node::ObjectWrap::Unwrap<Image>(info.Holder()); std::string a = TOSTR(property); if (a == "background") { if (!value->IsObject()) ThrowException(Exception::TypeError( String::New("mapnik.Color expected"))); Local<Object> obj = value->ToObject(); if (obj->IsNull() || obj->IsUndefined() || !Color::constructor->HasInstance(obj)) ThrowException(Exception::TypeError(String::New("mapnik.Color expected"))); Color *c = node::ObjectWrap::Unwrap<Color>(obj); im->get()->set_background(*c->get()); } }
void Color::set_prop(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope scope; Color* c = ObjectWrap::Unwrap<Color>(info.This()); std::string a = TOSTR(property); if (!value->IsNumber()) ThrowException(Exception::TypeError( String::New("color channel value must be an integer"))); if (a == "a") { c->get()->set_alpha(value->IntegerValue()); } else if (a == "r") { c->get()->set_red(value->IntegerValue()); } else if (a == "g") { c->get()->set_green(value->IntegerValue()); } else if (a == "b") { c->get()->set_blue(value->IntegerValue()); } }
Handle<Value> Window::GetState(Local<String> property, const AccessorInfo &info) { HandleScope scope; NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder()); Handle<Value> state = String::New("normal"); switch (window->GetState()) { case NW_STATE_NORMAL: state = String::New("normal"); break; case NW_STATE_MINIMIZED: state = String::New("minimized"); break; case NW_STATE_MAXIMIZED: state = String::New("maximized"); break; case NW_STATE_FULLSCREEN: state = String::New("fullscreen"); } return scope.Close(state); }
static Handle<Value> NavigatorGet(Local<String> name, const AccessorInfo &info) { HandleScope scope; Local<Object> self = info.This(); Local<External> wrap = Local<External>::Cast(self->GetInternalField(0)); v8_wrapper::tree_node* ptr = static_cast<v8_wrapper::tree_node*>(wrap->Value()); jsNavigator* el = dynamic_cast<jsNavigator*>(ptr); // Convert the JavaScript string to a std::string. std::string key = value_to_string(name); // Look up the value if it exists using the standard STL idiom. std::map< std::string, Persistent<Value> >::iterator iter = el->props.find(key); // If the key is not present return an empty handle as signal. if (iter == el->props.end()) return Handle<Value>(); // Otherwise fetch the value and wrap it in a JavaScript string. Local<Value> val = Local<Value>::New(iter->second); return scope.Close(val); }
static Handle<Value> BrowserSet(Local<String> name, Local<Value> value, const AccessorInfo& info) { Handle<Value> val; std::string key = value_to_string(name); LOG4CXX_TRACE(webEngine::iLogger::GetLogger(), _T("jsBrowserSet: property(")<< key <<_T(")")); Local<External> wrap = Local<External>::Cast(info.Data()); void* ptr = wrap->Value(); if (ptr != NULL) { jsBrowser* el = static_cast<jsBrowser*>(ptr); if (key == "v8_results") { string sval = value_to_string(value); el->append_results(sval); } else if (el->window->is_property(key)) { val = el->window->GetProperty(name, info); } else { el->props[key] = Persistent<Value>::New(value); } } return val; }
void ScrollView::PolicyVerticalSetter(Local<String> name, Local<Value> value, const AccessorInfo& info) { HandleScope scope; MxScrollPolicy policy; if (value->IsBoolean()) { ClutterActor *instance = ObjectWrap::Unwrap<ScrollView>(info.This())->_actor; policy = mx_scroll_view_get_scroll_policy(MX_SCROLL_VIEW(instance)); if (value->ToBoolean()->Value()) { if (policy == MX_SCROLL_POLICY_HORIZONTAL) mx_scroll_view_set_scroll_policy(MX_SCROLL_VIEW(instance), MX_SCROLL_POLICY_BOTH); else if (policy == MX_SCROLL_POLICY_NONE) mx_scroll_view_set_scroll_policy(MX_SCROLL_VIEW(instance), MX_SCROLL_POLICY_VERTICAL); } else { if (policy == MX_SCROLL_POLICY_VERTICAL) mx_scroll_view_set_scroll_policy(MX_SCROLL_VIEW(instance), MX_SCROLL_POLICY_NONE); else if (policy == MX_SCROLL_POLICY_BOTH) mx_scroll_view_set_scroll_policy(MX_SCROLL_VIEW(instance), MX_SCROLL_POLICY_HORIZONTAL); } } }
Handle<Value> Proxy::getIndexedProperty(uint32_t index, const AccessorInfo& info) { JNIEnv* env = JNIScope::getEnv(); if (!env) { return JSException::GetJNIEnvironmentError(); } 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); } Handle<Value> result = TypeConverter::javaObjectToJsValue(value); env->DeleteLocalRef(value); return result; }
/* DESCRIPTION Get Accessor of stmtCacheSize property */ Handle<Value> Connection::GetStmtCacheSize (Local<String> property, const AccessorInfo& info) { HandleScope scope; Connection* njsConn = ObjectWrap::Unwrap<Connection>(info.Holder()); if(!njsConn->isValid_) { string error = NJSMessages::getErrorMsg ( errInvalidConnection ); NJS_SET_EXCEPTION(error.c_str(), error.length()); return scope.Close(Undefined()); } try { Local<Integer> value = v8::Integer::New(njsConn->dpiconn_->stmtCacheSize()); return scope.Close(value); } catch(dpi::Exception &e) { NJS_SET_EXCEPTION(e.what(), strlen(e.what())); return Undefined(); } return Undefined(); }
static void SetLocationHref(Local<String> name, Local<Value> val, const AccessorInfo& info) { Local<Object> self = info.This(); Local<Value> x = self->GetInternalField(0); Local<External> wrap = Local<External>::Cast(x); void* ptr = wrap->Value(); jsLocation* url = static_cast<jsLocation*>(ptr); std::string log_info = "Location changed from '"; if(url->url.is_valid()) { log_info += url->url.tostring(); } else { log_info += "undefined"; } log_info += "' to \n\thref: "; url->url.assign_with_referer(value_to_string(val), &url->url); if(url->url.is_valid()) { log_info += url->url.tostring(); } else { log_info += "undefined"; } append_results(log_info); }
void Image::SetSource(Local<String>, Local<Value> val, const AccessorInfo &info) { HandleScope scope; Image *img = ObjectWrap::Unwrap<Image>(info.This()); cairo_status_t status = CAIRO_STATUS_READ_ERROR; // url string if (val->IsString()) { String::AsciiValue src(val); if (img->filename) free(img->filename); img->filename = strdup(*src); // status = img->load(); // Load from assets directory uint8_t* buf; int len; JSG::loadAsset(img->filename, (unsigned char**) &buf, &len); if (buf) { status = img->loadFromBuffer(buf, len); free(buf); } // Buffer } else if (Buffer::HasInstance(val)) { uint8_t *buf = (uint8_t *) Buffer::Data(val->ToObject()); unsigned len = Buffer::Length(val->ToObject()); status = img->loadFromBuffer(buf, len); } // check status if (status) { img->error(Canvas::Error(status)); } else { img->loaded(); } }
static Handle<Value> @(Model.Name)Getter(Local<String> property, const AccessorInfo &info) { HandleScope scope; if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.DeclaringType,true))>(info.This())) { return scope.Close(Undefined()); } @(Model.DeclaringType.Name) *wrapper = @(Model.DeclaringType.Name)::Unwrap<@(Model.DeclaringType.Name)>(info.This()); try {@{ var jsConversionInfo = Converter.ToJS(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)); var winrtConversionInfo = Converter.ToWinRT(Model.PropertyType);} @winrtConversionInfo[0] result = wrapper->_instance->@(Model.Name); return scope.Close(@string.Format(jsConversionInfo[1], "result")); } catch (Platform::Exception ^exception) { NodeRT::Utils::ThrowWinRtExceptionInJs(exception); return scope.Close(Undefined()); } }
Handle<Value> Ti::TiProxy::_Getter (Local<String> property, const AccessorInfo& info) { HandleScope handleScope; Handle<Object> obj = Handle<Object>::Cast(info.Holder()); Handle<External> proxyObject = Handle<External>::Cast(obj->GetHiddenValue(String::New("module"))); if(proxyObject.IsEmpty()) proxyObject = Handle<External>::Cast(obj->GetHiddenValue(String::New("proxy"))); if(proxyObject.IsEmpty()) return handleScope.Close(Handle<Value>()); Ti::TiProxy* tiProxy = static_cast<Ti::TiProxy*>(proxyObject->Value()); if(tiProxy->properties.contains(Ti::TiHelper::QStringFromValue(property))) { Ti::TiProperty *prop = tiProxy->properties[Ti::TiHelper::QStringFromValue(property)]; Handle<Value> r = prop->getValue(); if(r.IsEmpty() || r->IsUndefined()) return handleScope.Close(Handle<Value>()); return handleScope.Close(r); } return handleScope.Close(Handle<Value>()); }
void Window::SetWidth(Local<String> property, Local<Value> value, const AccessorInfo& info) { NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder()); window->SetWidth(value->Int32Value()); }
void Window::SetTitle(Local<String> property, Local<Value> value, const AccessorInfo& info) { NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder()); window->SetTitle(V8StringToChar(value->ToString())); }
Handle<Value> DatasetBands::dsGetter(Local<String> property, const AccessorInfo &info) { HandleScope scope; return scope.Close(info.This()->GetHiddenValue(String::NewSymbol("parent_"))); }
Handle<Value> FieldDefn::precisionGetter(Local<String> property, const AccessorInfo &info) { HandleScope scope; FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This()); return scope.Close(Integer::New(def->this_->GetPrecision())); }
Handle<Value> FieldDefn::ignoredGetter(Local<String> property, const AccessorInfo &info) { HandleScope scope; FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This()); return scope.Close(Boolean::New(def->this_->IsIgnored())); }
Handle<Value> FieldDefn::typeGetter(Local<String> property, const AccessorInfo &info) { HandleScope scope; FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This()); return scope.Close(SafeString::New(getFieldTypeName(def->this_->GetType()))); }
Handle<Value> Polygon::ringsGetter(Local<String> property, const AccessorInfo &info) { HandleScope scope; return scope.Close(info.This()->GetHiddenValue(String::NewSymbol("rings_"))); }
void Window::SetTopmost(Local<String> property, Local<Value> value, const AccessorInfo& info) { NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder()); window->SetTopmost(value->BooleanValue()); }