Handle<Value> Interface::PlatformAttrGet(Local<String> property, const AccessorInfo& info) { HandleScope scope; jobject ob = (jobject)info.This()->GetPointerFromInternalField(0); int attrData = info.Data()->Int32Value(); int attrIdx = attrData & 0xffff; int clsid = attrData >> 16; Env *env = Env::getEnv_nocheck(); Interface *interface = env->getInterface(clsid); if(interface) { Attribute *attr = interface->attributes->addr(attrIdx); JNIEnv *jniEnv = interface->env->getVM()->getJNIEnv(); jniEnv->PushLocalFrame(256); jobject jVal = jniEnv->CallStaticObjectMethod(interface->jPlatformStub, interface->jPlatformGet, ob, attrIdx); if(env->getConv()->CheckForException(jniEnv)) { jniEnv->PopLocalFrame(0); return Undefined(); } Local<Value> val; int result = interface->conv->ToV8Value(jniEnv, jVal, attr->type, &val); jniEnv->PopLocalFrame(0); if(result == OK) { return scope.Close(val); } interface->conv->ThrowV8ExceptionForErrno(result); } return Undefined(); }
Handle<Value> ArrayType::PlatformLengthGet(Local<String> property, const AccessorInfo& info) { HandleScope scope; jobject ob = (jobject)info.This()->GetPointerFromInternalField(0); ArrayType *arr = (ArrayType *)info.This()->GetPointerFromInternalField(1); JNIEnv *jniEnv = arr->env->getVM()->getJNIEnv(); jint length = jniEnv->CallIntMethod(ob, arr->getLength); if(arr->env->getConv()->CheckForException(jniEnv)) { return Undefined(); } return scope.Close(Integer::New(length)); }
void Widget::ClassNameSetter(Local<String> name, Local<Value> value, const AccessorInfo& info) { HandleScope scope; if (value->IsString()) { ClutterActor *instance = ObjectWrap::Unwrap<Actor>(info.This())->_actor; ObjectWrap::Unwrap<Widget>(info.This())->hasClassName = TRUE; mx_stylable_set_style_class(MX_STYLABLE(instance), *String::Utf8Value(value->ToString())); mx_stylable_set_style(MX_STYLABLE(instance), mx_style_get_default()); } }
void ArrayType::PlatformLengthSet(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope scope; jobject ob = (jobject)info.This()->GetPointerFromInternalField(0); ArrayType *arr = (ArrayType *)info.This()->GetPointerFromInternalField(1); JNIEnv *jniEnv = arr->env->getVM()->getJNIEnv(); if(value.IsEmpty()) { ThrowException(Exception::ReferenceError(String::New("No value specified"))); return; } jint length = (jint)value->IntegerValue(); jniEnv->CallVoidMethod(ob, arr->setLength, length); arr->env->getConv()->CheckForException(jniEnv); }
Handle<v8::Value> Function::GetOnlyReadsMemory (Local<String> property, const AccessorInfo& info) { HandleScope scope; Function* fun = ObjectWrap::Unwrap<Function>(info.This()); Handle<v8::Value> result = Boolean::New(fun->llvm_fun->onlyReadsMemory()); return scope.Close(result); }
Handle<v8::Value> Function::GetType (Local<String> property, const AccessorInfo& info) { HandleScope scope; Function* fun = ObjectWrap::Unwrap<Function>(info.This()); Handle<v8::Value> result = FunctionType::New(fun->llvm_fun->getFunctionType()); return scope.Close(result); }
Handle<v8::Value> Function::GetName (Local<String> property, const AccessorInfo& info) { HandleScope scope; Function* fun = ObjectWrap::Unwrap<Function>(info.This()); std::string fun_name = fun->llvm_fun->getName(); return scope.Close(String::New(fun_name.c_str())); }
Handle<v8::Value> Function::GetArgSize (Local<String> property, const AccessorInfo& info) { HandleScope scope; Function* fun = ObjectWrap::Unwrap<Function>(info.This()); Handle<Integer> result = v8::Integer::New(fun->llvm_fun->arg_size()); return scope.Close(result); }
Handle<Value> Layer::get_prop(Local<String> property, const AccessorInfo& info) { HandleScope scope; Layer* l = ObjectWrap::Unwrap<Layer>(info.This()); std::string a = TOSTR(property); if (a == "name") return scope.Close(String::New(l->layer_->name().c_str())); else if (a == "srs") return scope.Close(String::New(l->layer_->srs().c_str())); else if (a == "styles") { std::vector<std::string> const& style_names = l->layer_->styles(); Local<Array> s = Array::New(style_names.size()); for (unsigned i = 0; i < style_names.size(); ++i) { s->Set(i, String::New(style_names[i].c_str()) ); } return scope.Close(s); } else if (a == "datasource") { mapnik::datasource_ptr ds = l->layer_->datasource(); if (ds) { return scope.Close(Datasource::New(ds)); } } return Undefined(); }
void Image::SetOnerror(Local<String>, Local<Value> val, const AccessorInfo &info) { if (val->IsFunction()) { Image *img = ObjectWrap::Unwrap<Image>(info.This()); img->onerror = Persistent<Function>::New(Handle<Function>::Cast(val)); } }
void NodeSandbox::node_setDebugOnCrash(Local<String> property, Local<Value> value, const AccessorInfo& info) { SandboxWrapper* wrap; wrap = node::ObjectWrap::Unwrap<SandboxWrapper>(info.This()); wrap->sbox->m_debuggerOnCrash = value->ToBoolean()->Value(); }
Handle<Value> NodeSandbox::node_getDebugOnCrash(Local<String> property, const AccessorInfo& info) { SandboxWrapper* wrap; wrap = node::ObjectWrap::Unwrap<SandboxWrapper>(info.This()); return Boolean::New (wrap->sbox->m_debuggerOnCrash); }
Handle<Array> jsWindow::WindowEnum( const AccessorInfo &info ) { HandleScope scope; Handle<Array> retval = Local<Array>::New(Array::New()); Local<Object> self = info.This(); Local<External> wrap = Local<External>::Cast(self->GetInternalField(0)); void* ptr = wrap->Value(); jsWindow* el = static_cast<jsWindow*>(ptr); map<string, int> prop_list; size_t i; for (i = 0; i < ro_props.size(); ++i) { prop_list[ro_props[i]] = 1; } jsPropertyMap::iterator it; for (it = el->props.begin(); it != el->props.end(); ++it) { prop_list[it->first] = 1; } map<string, int>::iterator ins; i = 0; for (ins = prop_list.begin(); ins != prop_list.end(); ++ins) { string val = ins->first; retval->Set(Number::New(i), String::New(val.c_str())); i++; } return scope.Close(retval); }
void FieldDefn::justificationSetter(Local<String> property, Local<Value> value, const AccessorInfo &info) { HandleScope scope; FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This()); OGRJustification justification; std::string str = TOSTR(value); if(value->IsString()){ if(str == "Left") { justification = OJLeft; } else if (str == "Right") { justification = OJRight; } else if (str == "Undefined") { justification = OJUndefined; } else { NODE_THROW("Unrecognized justification"); return; } } else if (value->IsNull() || value->IsUndefined()){ justification = OJUndefined; } else { NODE_THROW("justification must be a string or undefined"); return; } def->this_->SetJustify(justification); }
void NodeFFT::SetSize (Local<String> property, Local<Value> value, const AccessorInfo &info) { NodeFFT *nfft = ObjectWrap::Unwrap<NodeFFT>(info.This()); if (!nfft->reset(value->Uint32Value())) { /* TODO: Throw an error somehow */ } }
void Base_SetA(Local<String> property, Local<Value> value, const AccessorInfo& info) { Base* ptr = GetObjectPtr(info.This()); assert(ptr); ptr->a = value->Int32Value(); }
Handle<Value> Base_GetA(Local<String> property, const AccessorInfo &info) { Base* ptr = GetObjectPtr(info.This()); assert(ptr); return Integer::New(ptr->a); }
Handle<Value> DispObject::NodeSetByIndex(uint32_t index, Local<Value> value, const AccessorInfo& info) { HandleScope scope; DispObject *me = DispObject::Unwrap<DispObject>(info.This()); if (!me) return Undefined(); NODE_DEBUG_FMT2("DispObject '%S[%u]' set", me->name.GetString(), index); return scope.Close(DispError(E_NOTIMPL, __FUNCTIONW__)); }
Handle<Value> Widget::ClassNameGetter(Local<String> name, const AccessorInfo& info) { HandleScope scope; /* This widget has no class name */ if (!ObjectWrap::Unwrap<Widget>(info.This())->hasClassName) { return scope.Close( String::New("") ); } ClutterActor *instance = ObjectWrap::Unwrap<Actor>(info.This())->_actor; return scope.Close( String::New(mx_stylable_get_style_class(MX_STYLABLE(instance))) ); }
Handle<Value> DispObject::NodeGetByIndex(uint32_t index, const AccessorInfo& info) { HandleScope scope; DispObject *me = DispObject::Unwrap<DispObject>(info.This()); if (!me) return Undefined(); NODE_DEBUG_FMT2("DispObject '%S[%u]' get", me->name.GetString(), index); return scope.Close(me->findElement(index)); }
void Scene_SetEnabled(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope handle_scope; Scene* ptr = GetPtr(info.This()); assert(ptr); ptr->enable(value->ToBoolean()->Value()); }
Handle<Value> FieldDefn::justificationGetter(Local<String> property, const AccessorInfo &info) { HandleScope scope; FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This()); OGRJustification justification = def->this_->GetJustify(); if (justification == OJRight) return scope.Close(String::New("Right")); if (justification == OJLeft) return scope.Close(String::New("Left")); return scope.Close(Undefined()); }
Handle<Value> Scene_GetSignalsList(Local<String> property, const AccessorInfo &info) { HandleScope handle_scope; Scene* ptr = GetPtr(info.This()); assert(ptr); return handle_scope.Close(toJavaScript(ptr->getSignalsList())); }
void EntityComponent_SetVisible(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope handle_scope; EntityComponent* ptr = GetPtr(info.This()); assert(ptr); ptr->setVisible(value->ToBoolean()->Value()); }
v8::Handle<Value> EntityComponent_IsVisible(Local<String> property, const AccessorInfo &info) { HandleScope handle_scope; EntityComponent* ptr = GetPtr(info.This()); assert(ptr); return handle_scope.Close(v8::Boolean::New(ptr->isVisible())); }
void DirectionalLight_SetSpecularColor(Local<String> property, Local<Value> value, const AccessorInfo& info) { HandleScope handle_scope; Visual::DirectionalLight* ptr = GetPtr(info.This()); assert(ptr); ptr->setSpecularColor(fromJSColor(value)); }
v8::Handle<Value> DirectionalLight_GetSpecularColor(Local<String> property, const AccessorInfo &info) { HandleScope handle_scope; Visual::DirectionalLight* ptr = GetPtr(info.This()); assert(ptr); return handle_scope.Close(toJavaScript(ptr->getSpecularColor())); }
Handle<Value> Scene_GetName(Local<String> property, const AccessorInfo &info) { HandleScope handle_scope; Scene* ptr = GetPtr(info.This()); assert(ptr); return handle_scope.Close(String::New(ptr->getName().c_str())); }
static Handle<Value> GetLocationPort(Local<String> name, const AccessorInfo& info) { Local<Object> self = info.This(); Local<External> wrap = Local<External>::Cast(self->GetInternalField(0)); void* ptr = wrap->Value(); jsLocation* url = static_cast<jsLocation*>(ptr); return Int32::New(url->url.port); }
Handle<Value> Scene_GetShown(Local<String> property, const AccessorInfo &info) { HandleScope handle_scope; Scene* ptr = GetPtr(info.This()); assert(ptr); return handle_scope.Close(Boolean::New(ptr->isShown())); }