Exemple #1
2
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();
}
Exemple #2
0
static void WriteTestVal(Local<String> propname, Local<Value> v, const AccessorInfo &info) {
  do_check_true(!propname.IsEmpty());
  do_check_true(v->IsInt32());
  do_check_true(!info.Data().IsEmpty());
  do_check_true(info.Data()->IsInt32());
  test_val = v->Int32Value();
  int offset = info.Data()->Int32Value();
  test_val += offset;
}
Exemple #3
0
/* Generic getter for all NdbRecordObjects
*/
Handle<Value> nroGetter(Local<String>, const AccessorInfo & info) 
{
  NdbRecordObject * nro = 
    static_cast<NdbRecordObject *>(info.Holder()->GetPointerFromInternalField(1));
  int nField = info.Data()->Int32Value();
  return nro->getField(nField);
}                    
Exemple #4
0
/* Generic setter for all NdbRecordObjects
*/
void nroSetter(Local<String>, Local<Value> value, const AccessorInfo& info) 
{
  NdbRecordObject * nro = 
    static_cast<NdbRecordObject *>(info.Holder()->GetPointerFromInternalField(1));
  int nField = info.Data()->Int32Value();
  nro->setField(nField, value);
}
static Handle<Value> BrowserGet(Local<String> name, const AccessorInfo &info)
{
    HandleScope scope;
    Handle<Value> val;
    std::string key = value_to_string(name);

    LOG4CXX_TRACE(webEngine::iLogger::GetLogger(), _T("jsBrowserGet: property(")<< key <<_T(")"));

    Local<External> wrap = Local<External>::Cast(info.Data());
    void* ptr = wrap->Value();
    jsBrowser* el = static_cast<jsBrowser*>(ptr);
    if (key == "v8_context") {
        val = v8_wrapper::wrap_object<jsExecutor>(el);
    } else if (key == "v8_results") {
        val = String::New(el->get_results().c_str());
    } else if (key == "window") {
        val = v8_wrapper::wrap_object<jsWindow>(el->window);
    } else if (el->window->is_property(key)) {
        val = el->window->GetProperty(name, info);
    } else {
        // Look up the value if it exists using the standard STL idiom.
        jsPropertyMap::iterator iter = el->props.find(key);
        // If the key is not present return an empty handle as signal.
        if (iter != el->props.end()) {
            // Otherwise fetch the value and wrap it in a JavaScript string.
            val = Local<Value>::New(iter->second);
        }
    }

    return scope.Close(val);
}
Exemple #6
0
void vectorTemplate::setVectorY(Local<String> property, Local<Value> value, const AccessorInfo &info){
	Local<External> data = Local<External>::Cast(info.Data());
	vector<double> *vect = reinterpret_cast<vector<double> *>(data->Value());
	if(value->IsNumber()){
		vect->y = value->ToNumber()->Value();
	}
}
Handle<Value> jsBrowser::GetWindow( Local<String> name, const AccessorInfo &info )
{
    HandleScope scope;

    Local<External> wrap = Local<External>::Cast(info.Data());
    void* ptr = wrap->Value();
    jsBrowser* el = static_cast<jsBrowser*>(ptr);

    Handle<Object> _obj = v8_wrapper::wrap_object<jsWindow>(el->window);

    return scope.Close(_obj);
}
   Handle<Value> COPropertyGetter(Local<String> propname, const AccessorInfo& info)
   {
      dtEntity::Component* component = UnwrapComponent(info.Holder());
      if(component == NULL)
      {
         return ThrowError("Trying to access deleted component!");
      }

      HandleScope scope;

      Handle<External> ext = Handle<External>::Cast(info.Data());
      dtEntity::Property* prop = static_cast<dtEntity::Property*>(ext->Value());

      switch(prop->GetDataType())
      {
      case dtEntity::DataType::ARRAY:
      case dtEntity::DataType::VEC2:
      case dtEntity::DataType::VEC2D:
      case dtEntity::DataType::VEC3:
      case dtEntity::DataType::VEC3D:
      case dtEntity::DataType::VEC4:
      case dtEntity::DataType::VEC4D:
      case dtEntity::DataType::GROUP:
      case dtEntity::DataType::MATRIX:
      case dtEntity::DataType::QUAT:
      {
         Handle<Value> v;// = info.Holder()->GetHiddenValue(propname);
         if(true)//v.IsEmpty())
         {
            v = ConvertPropertyToValue(info.Holder()->CreationContext(), prop);
           // info.Holder()->SetHiddenValue(propname, v);
         }
         else
         {
            Handle<Value> ret = SetValueFromProperty(prop, v);
            if(ret->BooleanValue() == false) {
               return ThrowError("Internal error: Did property change type on the fly?");
            }
         }
         return scope.Close(v);
      }
      default:
         return scope.Close(ConvertPropertyToValue(info.Holder()->CreationContext(), prop));
      }
   }
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 COPropertySetter(Local<String> propname,
                               Local<Value> value,
                               const AccessorInfo& info)
   {

      assert(!info.Holder().IsEmpty());
      dtEntity::Component* component = UnwrapComponent(info.Holder());
      if(component == NULL)
      {
         LOG_ERROR("Trying to access deleted component!");
         return;
      }

      HandleScope scope;
      Handle<External> ext = Handle<External>::Cast(info.Data());
      dtEntity::Property* prop = static_cast<dtEntity::Property*>(ext->Value());
      assert(prop);
      SetPropertyFromValue(value, prop);
#if CALL_ONPROPERTYCHANGED_METHOD
      component->OnPropertyChanged(dtEntity::SIDHash(ToStdString(propname)), *prop);
#endif
   }
Exemple #11
0
void Interface::PlatformAttrSet(Local<String> property, Local<Value> value, 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;
    int result = interface->conv->ToJavaObject(jniEnv, value, attr->type, &jVal);
    if(result == OK) {
      jniEnv->CallStaticVoidMethod(interface->jPlatformStub, interface->jPlatformSet, ob, attrIdx, jVal);
    }
    jniEnv->PopLocalFrame(0);
    if(result == OK)
      env->getConv()->CheckForException(jniEnv);
    else
      interface->conv->ThrowV8ExceptionForErrno(result);
  }
}
Exemple #12
0
Handle<Value> vectorTemplate::getVectorY(Local<String> property, const AccessorInfo &info){
	HandleScope scope;
	Local<External> data = Local<External>::Cast(info.Data());
	vector<double> *vect = reinterpret_cast<vector<double> *>(data->Value());
	return scope.Close(Number::New(vect->y));	
}