Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-14741] Added applyProperties to all TiProxies #143

Merged
merged 1 commit into from
Aug 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/tibb/TiProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void TiProxy::onCreateStaticMembers()
TiGenericFunctionObject::addGenericFunctionToParent(this, "fireEvent", this, _fireEvent);
TiGenericFunctionObject::addGenericFunctionToParent(this, "removeEventListener", this, _removeEventListener);
TiPropertySetGetObject::createProperty(this, "apiName", this, NULL, _getApiName);
TiGenericFunctionObject::addGenericFunctionToParent(this, "applyProperties", this, _applyProperties);
}

void TiProxy::createSettersAndGetters(const char* name, SET_PROPERTY_CALLBACK setter, GET_PROPERTY_CALLBACK getter)
Expand Down Expand Up @@ -82,6 +83,17 @@ Handle<Value> TiProxy::createProxy(TiProxy *proxy, void* userContext, const Argu
return handleScope.Close(result);
}

Handle<Value> TiProxy::_applyProperties(void* userContext, TiObject* caller, const Arguments& args)
{
TiUIBase* proxy = (TiUIBase*) userContext;

if(args.Length() > 0)
{
proxy->applyProperties(args[0]);
}
return Undefined();
}

Handle<Value> TiProxy::_addEventListener(void* userContext, TiObject*, const Arguments& args)
{
// JavaScript usage:
Expand Down
1 change: 1 addition & 0 deletions src/tibb/TiProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class TiProxy : public TiObject
static Handle<Value> _fireEvent(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _removeEventListener(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _getApiName(void*userContext);
static Handle<Value> _applyProperties(void* userContext, TiObject* caller, const Arguments& args);
};

#endif /* TIPROXY_H_ */
21 changes: 0 additions & 21 deletions src/tibb/TiUIBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,33 +582,12 @@ void TiUIBase::onCreateStaticMembers()
TiGenericFunctionObject::addGenericFunctionToParent(this, "focus", this, _focus);
TiGenericFunctionObject::addGenericFunctionToParent(this, "blur", this, _blur);
TiGenericFunctionObject::addGenericFunctionToParent(this, "animate", this, _animate);
TiGenericFunctionObject::addGenericFunctionToParent(this, "applyProperties", this, _applyProperties);
TiGenericFunctionObject::addGenericFunctionToParent(this, "convertPointToView", this, _convertPointToView);

TiPropertySetGetObject::createProperty(this, "children", this, NULL, _getChildren);
setTiMappingProperties(g_tiProperties, sizeof(g_tiProperties) / sizeof(*g_tiProperties));
}

Handle<Value> TiUIBase::_applyProperties(void* userContext, TiObject* caller, const Arguments& args)
{
TiUIBase* proxy = (TiUIBase*) userContext;

if(args.Length() > 0 && args[0]->IsObject())
{
Local<Object> obj = args[0]->ToObject();
Local<Array> props = obj->GetPropertyNames();

for(uint32_t i = 0, len = props->Length(); i < len; i++)
{
Local<Value> key = props->Get(i);
Local<Value> value = obj->Get(key);
QString propName = titanium::V8ValueToQString(key);
const char* propString = propName.toLocal8Bit().data();
proxy->setPropHelper(propString, value, &TiObject::setValue);
}
}
return Undefined();
}
Handle<Value> TiUIBase::_add(void* userContext, TiObject*, const Arguments& args)
{
HandleScope handleScope;
Expand Down
1 change: 0 additions & 1 deletion src/tibb/TiUIBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class TiUIBase : public TiProxy
static Handle<Value> _focus(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _blur(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _animate(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _applyProperties(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _convertPointToView(void* userContext, TiObject* caller, const Arguments& args);
// fields
NativeObject* nativeObject_;
Expand Down