/* Call back for V8 named properties.  This is the entry point for setting
 * properties from js.  We handle the properties we know and let V8 handle
 * all other properties.
 */
Handle<Value> TiObject::_propSetter(Local<String> prop, Local<Value> value, const AccessorInfo& info)
{
    HandleScope handleScope;
    Handle<Object> result;
    TiObject* obj = getTiObjectFromJsObject(info.Holder());
    if (obj == NULL)
    {
        // We are not tracking this object so let V8 handle it.
        info.Holder()->ForceSet(prop, value);
        return value;
    }
    return obj->setPropHelper(*String::Utf8Value(prop), value, &TiObject::setValue);
}
Пример #2
0
/* Call back for V8 named properties.  This is the entry point for accessing
 * properties from js.  We handle the properties we know and let V8 handle
 * all other properties.
 */
Handle<Value> TiObject::_propGetter(Local<String> prop, const AccessorInfo& info)
{
    HandleScope handleScope;
    Handle<Object> result;
    TiObject* obj = getTiObjectFromJsObject(info.Holder());
    if (obj == NULL)
    {
        // Returns "empty". This will cause V8 to go back to default lookup.
        return result;
    }
    Handle<ObjectTemplate> global = getObjectTemplateFromJsObject(info.Holder());
    String::Utf8Value propName(prop);
    const char* propString = (const char*)(*propName);
    TiObject* propObject = obj->onLookupMember(propString);
    if (propObject == NULL)
    {
        // TODO: Fix the following block of commented out code. Currently it breaks
        // Titanium runtime.
        /*
        if(obj->canAddMembers())
        {
            // If we're allowed to add members, return an "empty" result
            // so V8 will handle it. V8 will set the value internally so
            // we can ignore non-Titanium objects.
            return result;
        }
        */
        return Handle<Value>();
    }
    Handle<Value> ret = propObject->getValue();
    if (!ret.IsEmpty())
    {
        return handleScope.Close(ret);
    }
    if ((propObject->hasMembers()) || (propObject->isFunction()))
    {
        result = global->NewInstance();
        propObject->setValue(result);
        setTiObjectToJsObject(result, propObject);
    }
    else
    {
        propObject->release();
        return handleScope.Close(propObject->getValue());
    }
    propObject->release();
    return handleScope.Close(result);
}
Пример #3
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);
}
Пример #4
0
Handle<Value> get_classification(Local<String> property, const AccessorInfo &info) {
  const NdbError *err = unwrapPointer<const NdbError *>(info.Holder());

  switch(err->classification) {
    MAP_CODE(NoError);
    MAP_CODE(ApplicationError);
    MAP_CODE(NoDataFound);
    MAP_CODE(ConstraintViolation);
    MAP_CODE(SchemaError);
    MAP_CODE(UserDefinedError);
    MAP_CODE(InsufficientSpace);
    MAP_CODE(TemporaryResourceError);
    MAP_CODE(NodeRecoveryError);
    MAP_CODE(OverloadError);
    MAP_CODE(TimeoutExpired);
    MAP_CODE(UnknownResultError);
    MAP_CODE(InternalError);
    MAP_CODE(FunctionNotImplemented);
    MAP_CODE(UnknownErrorCode);
    MAP_CODE(NodeShutdown);
    MAP_CODE(SchemaObjectExists);
    MAP_CODE(InternalTemporary);
  }
  return String::New("-unknown-");
}
Пример #5
0
Handle<Value> ODBCResult::FetchModeGetter(Local<String> property, const AccessorInfo &info) {
  HandleScope scope;

  ODBCResult *obj = ObjectWrap::Unwrap<ODBCResult>(info.Holder());

  return scope.Close(Integer::New(obj->m_fetchMode));
}
void PushbotsModule::setter_enabled(Local<String> property, Local<Value> value, const AccessorInfo& info)
{
	LOGD(TAG, "set enabled");
	HandleScope scope;

	JNIEnv *env = titanium::JNIScope::getEnv();
	if (!env) {
		LOGE(TAG, "Failed to get environment, enabled wasn't set");
		return;
	}

	static jmethodID methodID = NULL;
	if (!methodID) {
		methodID = env->GetMethodID(PushbotsModule::javaClass, "setEnabled", "(Ljava/lang/Boolean;)V");
		if (!methodID) {
			const char *error = "Couldn't find proxy method 'setEnabled' with signature '(Ljava/lang/Boolean;)V'";
			LOGE(TAG, error);
		}
	}

	titanium::Proxy* proxy = titanium::Proxy::unwrap(info.Holder());
	if (!proxy) {
		return;
	}

	jvalue jArguments[1];

	bool isNew_0;
	
	if (!value->IsNull()) {
		Local<Value> arg_0 = value;
		jArguments[0].l =
			titanium::TypeConverter::jsValueToJavaObject(env, arg_0, &isNew_0);
	} else {
		jArguments[0].l = NULL;
	}

	jobject javaProxy = proxy->getJavaObject();
	env->CallVoidMethodA(javaProxy, methodID, jArguments);

	if (!JavaObject::useGlobalRefs) {
		env->DeleteLocalRef(javaProxy);
	}



			if (isNew_0) {
				env->DeleteLocalRef(jArguments[0].l);
			}


	if (env->ExceptionCheck()) {
		titanium::JSException::fromJavaException();
		env->ExceptionClear();
	}




}
Пример #7
0
/*
   DESCRIPTION
     Set Accessor of stmtCacheSize property
*/
void Oracledb::SetStmtCacheSize ( Local<String> property, Local<Value> value,
                                  const AccessorInfo& info)
{
  HandleScope scope;
  Oracledb* oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  NJS_SET_PROP_UINT(oracledb->stmtCacheSize_, value, "stmtCacheSize");
}
Пример #8
0
void MSMap::PropertySetter (Local<String> property, Local<Value> value, const AccessorInfo& info) {
  MSMap *map = ObjectWrap::Unwrap<MSMap>(info.Holder());
  v8::String::AsciiValue n(property);
  if (strcmp(*n, "width") == 0) {
    map->this_->width = value->Int32Value();
  } else if (strcmp(*n, "height") == 0) {
    map->this_->height = value->Int32Value();
  } else if (strcmp(*n, "maxsize") == 0) {
    map->this_->maxsize = value->Int32Value();
  } else if (strcmp(*n, "units") == 0) {
    int32_t units = value->Int32Value();
    if (units >= MS_INCHES && units <= MS_NAUTICALMILES) {
      map->this_->units = (MS_UNITS) units;
    }
  } else if (strcmp(*n, "resolution") == 0) {
    map->this_->resolution = value->NumberValue();
  } else if (strcmp(*n, "defresolution") == 0) {
    map->this_->defresolution = value->NumberValue();
  } else if (strcmp(*n, "name") == 0) {
    REPLACE_STRING(map->this_->name, value);
  } else if (strcmp(*n, "imagetype") == 0) {
    REPLACE_STRING(map->this_->imagetype, value);
  } else if (strcmp(*n, "shapepath") == 0) {
    REPLACE_STRING(map->this_->shapepath, value);
  } else if (strcmp(*n, "projection") == 0) {
    v8::String::AsciiValue _v_(value->ToString());
    msLoadProjectionString(&(map->this_->projection), *_v_);
  } else if (strcmp(*n, "mappath") == 0) {
    REPLACE_STRING(map->this_->mappath, value);
  }
}
Пример #9
0
/*
   DESCRIPTION
     Set Accessor of outFormat property
*/
void Oracledb::SetOutFormat ( Local<String> property, Local<Value> value,
                              const AccessorInfo& info )
{
  HandleScope scope;
  Oracledb* oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  NJS_SET_PROP_UINT(oracledb->outFormat_, value, "outFormat");
}
Пример #10
0
/*
   DESCRIPTION
     Set Accessor of isExternalAuth property
*/
void Oracledb::SetIsExternalAuth(Local<String> property, Local<Value> value,
                                 const AccessorInfo& info )
{
  HandleScope scope;
  Oracledb* oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  oracledb->isExternalAuth_ = value->ToBoolean()->Value();
}
Пример #11
0
Handle<Value> Proxy::setIndexedProperty(uint32_t index, Local<Value> value, const AccessorInfo& info)
{
	JNIEnv* env = JNIScope::getEnv();
	if (!env) {
		LOG_JNIENV_GET_ERROR(TAG);
		return Undefined();
	}

	Proxy* proxy = NativeObject::Unwrap<Proxy>(info.Holder());

	bool javaValueIsNew;
	jobject javaValue = TypeConverter::jsValueToJavaObject(value, &javaValueIsNew);
	jobject javaProxy = proxy->getJavaObject();
	env->CallVoidMethod(javaProxy,
		JNIUtil::krollProxySetIndexedPropertyMethod,
		index,
		javaValue);

	if (!JavaObject::useGlobalRefs) {
		env->DeleteLocalRef(javaProxy);
	}
	if (javaValueIsNew) {
		env->DeleteLocalRef(javaValue);
	}

	return value;
}
Пример #12
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);
}                    
Пример #13
0
Handle<Value> PDFHexStringDriver::GetValue(Local<String> property,const AccessorInfo &info)
{
    HandleScope scope;
    
    Handle<String> result = String::New(ObjectWrap::Unwrap<PDFHexStringDriver>(info.Holder())->TheObject->GetValue().c_str());
    return scope.Close(result);
}
Handle<Value> Ti::TiProxy::_Setter (Local<String> property, Local<Value> value, const AccessorInfo& info)
{
	HandleScope handleScope;
	// Ti::TiHelper::LogInternal(QString("Property Setter: ").append(Ti::TiHelper::QStringFromValue(property)));

	// Todo: Come back to this later
	// if(value == info.Holder()->Get(property)) {
	//	 Ti::TiHelper::LogInternal(QString("Already set: ").append(Ti::TiHelper::QStringFromValue(property)));
	//	 return value;
	// }


	Handle<Object> obj = Handle<Object>::Cast(info.Holder());
	// Todo: come back to this - might not be allowing GC to collect proxies
	obj->ForceSet(property, value);
	// for example. scrollView.views = [a,b,c]
	// scrollView.remove(a) <--- removed from view, but still in array
	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 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)];
		return handleScope.Close(prop->setValue(value));
	}

	return value;
}
Пример #15
0
Handle<Value> Geometry::GetSRID(Local<String> name, const AccessorInfo& info)
{
    Geometry *geom = ObjectWrap::Unwrap<Geometry>(info.Holder());
    const int srid = GEOSGetSRID(geom->geos_geom_);
    if (srid == 0)
        return ThrowException(String::New("couldn't get SRID (maybe it wasn't set)"));
    return Integer::New(srid);
}
Пример #16
0
/*
   DESCRIPTION
     Get Accessor of stmtCacheSize property
*/
Handle<Value> Oracledb::GetStmtCacheSize ( Local<String> property,
                                           const AccessorInfo& info )
{
  HandleScope scope;
  Oracledb* oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  Local<Integer> value = v8::Integer::New(oracledb->stmtCacheSize_);
  return scope.Close(value);
}
Пример #17
0
/*
   DESCRIPTION
     Get Accessor of outFormat property
*/
Handle<Value> Oracledb::GetOutFormat ( Local<String> property,
                                       const AccessorInfo& info )
{
  HandleScope scope;
  Oracledb* oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  Handle<Value> value = v8::Integer::New(oracledb->outFormat_);
  return scope.Close(value);
}
Пример #18
0
 Handle<Value> SCRGetLockCursor(Local<String> propname, const AccessorInfo& info)
 {
    HandleScope handle_scope;
    Handle<Context> context = info.Holder()->CreationContext();
    Handle<Value> ih = context->Global()->Get(String::New("Input"));
    dtEntity::InputInterface* input = UnwrapInputInterface(ih);
    return Boolean::New(input->GetLockCursor());
 }
Пример #19
0
   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));
      }
   }
Пример #20
0
Handle<Value> MSHashTable::NamedSetter (Local<String> property, Local<Value> value, const AccessorInfo& info) {
  MSHashTable *table = ObjectWrap::Unwrap<MSHashTable>(info.Holder());
  v8::String::AsciiValue key(property);
  v8::String::AsciiValue val(value);

  msInsertHashTable(table->this_, *key, *val);

  RETURN_STRING(*val);
}
Пример #21
0
/*
   DESCRIPTION
     Get Accessor of isExternalAuth property
*/
Handle<Value> Oracledb::GetIsExternalAuth(Local<String> property,
                                          const AccessorInfo& info )
{
  HandleScope scope;

  Oracledb* oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  Handle<Boolean> value = v8::Boolean::New(oracledb->isExternalAuth_);
  return scope.Close(value);
}
Пример #22
0
void ODBCResult::FetchModeSetter(Local<String> property, Local<Value> value, const AccessorInfo &info) {
  HandleScope scope;

  ODBCResult *obj = ObjectWrap::Unwrap<ODBCResult>(info.Holder());
  
  if (value->IsNumber()) {
    obj->m_fetchMode = value->Int32Value();
  }
}
Handle<Value> PushbotsModule::getter_exampleProp(Local<String> property, const AccessorInfo& info)
{
	LOGD(TAG, "get exampleProp");
	HandleScope scope;

	JNIEnv *env = titanium::JNIScope::getEnv();
	if (!env) {
		return titanium::JSException::GetJNIEnvironmentError();
	}
	static jmethodID methodID = NULL;
	if (!methodID) {
		methodID = env->GetMethodID(PushbotsModule::javaClass, "getExampleProp", "()Ljava/lang/String;");
		if (!methodID) {
			const char *error = "Couldn't find proxy method 'getExampleProp' with signature '()Ljava/lang/String;'";
			LOGE(TAG, error);
				return titanium::JSException::Error(error);
		}
	}

	titanium::Proxy* proxy = titanium::Proxy::unwrap(info.Holder());

	if (!proxy) {
		return Undefined();
	}

	jvalue* jArguments = 0;

	jobject javaProxy = proxy->getJavaObject();
	jstring jResult = (jstring)env->CallObjectMethodA(javaProxy, methodID, jArguments);



	if (!JavaObject::useGlobalRefs) {
		env->DeleteLocalRef(javaProxy);
	}



	if (env->ExceptionCheck()) {
		Handle<Value> jsException = titanium::JSException::fromJavaException();
		env->ExceptionClear();
		return jsException;
	}

	if (jResult == NULL) {
		return Null();
	}

	Handle<Value> v8Result = titanium::TypeConverter::javaStringToJsString(env, jResult);

	env->DeleteLocalRef(jResult);


	return v8Result;

}
Пример #24
0
void setHeight(Local<String> property, Local<Value> value,
		const AccessorInfo& info) {
	Local<Object> self = info.Holder();
	Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
	void* ptr = wrap->Value();
#ifdef DEBUG
	LOGI("Setting height to %d", value->Int32Value());
#endif
	static_cast<BGJSView*>(ptr)->height = value->Int32Value();
}
Пример #25
0
Handle<Value> Grid::get_prop(Local<String> property,
                             const AccessorInfo& info)
{
    HandleScope scope;
    Grid* g = ObjectWrap::Unwrap<Grid>(info.Holder());
    std::string a = TOSTR(property);
    if (a == "key")
        return scope.Close(String::New(g->get()->get_key().c_str()));
    return Undefined();
}
Пример #26
0
Handle<Value> getHeight(Local<String> property, const AccessorInfo &info) {
	Local<Object> self = info.Holder();
	Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
	void* ptr = wrap->Value();
	int value = static_cast<BGJSView*>(ptr)->height;
#ifdef DEBUG
	LOGD("getHeight %u", value);
#endif
	return Integer::New(value);
}
Пример #27
0
/*
  DESCRIPTION
    Get Accessor of connectionClass property
*/
Handle<Value> Oracledb::GetConnectionClass ( Local<String> property,
                                             const AccessorInfo& info)
{
  HandleScope scope;

  Oracledb *oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  Handle<String> value = v8::String::New (oracledb->connClass_.c_str(),
                                          (int)oracledb->connClass_.length ());
  return scope.Close(value);
}
Пример #28
0
/*
  DESCRIPTION
    Set Accessor of connectionClass property
*/
void Oracledb::SetConnectionClass (Local<String> property, Local<Value> value,
                                   const AccessorInfo& info)
{
  HandleScope scope;

  Oracledb *oracledb = ObjectWrap::Unwrap<Oracledb>(info.Holder());
  v8::String::Utf8Value utfstr ( value->ToString () );

  oracledb->connClass_ = std::string ( *utfstr, utfstr.length() );
}
Пример #29
0
Handle<Value> Geometry::GetLength(Local<String> name, const AccessorInfo& info)
{
    HandleScope scope;
    Geometry *geom = ObjectWrap::Unwrap<Geometry>(info.Holder());
    double length;
    int r = GEOSLength(geom->geos_geom_, &length);
    if (r != 1)
        return ThrowException(String::New("couldn't get length"));
    Handle<Value> length_obj = Number::New(length);
    return scope.Close(length_obj);
}
Пример #30
0
Handle<Value> Geometry::GetArea(Local<String> name, const AccessorInfo& info)
{
    HandleScope scope;
    Geometry *geom = ObjectWrap::Unwrap<Geometry>(info.Holder());
    double area;
    int r = GEOSArea(geom->geos_geom_, &area);
    if (r != 1)
        return ThrowException(String::New("couldn't get area"));
    Handle<Value> area_obj = Number::New(area);
    return scope.Close(area_obj);
}