Fix for setting properties through RPC

This commit is contained in:
Scott Kyle 2015-10-08 02:00:10 -07:00
parent ebb400ed41
commit 3c9fb1a323
2 changed files with 5 additions and 4 deletions

View File

@ -122,11 +122,11 @@ static JSGlobalContextRef s_context;
return @{@"result": [self resultForJSValue:propertyValue]}; return @{@"result": [self resultForJSValue:propertyValue]};
}; };
s_requests["/set_property"] = [=](NSDictionary *dict) { s_requests["/set_property"] = [=](NSDictionary *dict) {
JSValueRef exception = NULL;
JSStringRef propString = RJSStringForString([dict[@"name"] UTF8String]); JSStringRef propString = RJSStringForString([dict[@"name"] UTF8String]);
RPCObjectID realmId = [dict[@"realmId"] longValue]; RPCObjectID realmId = [dict[@"objectId"] longValue];
JSValueRef value = [[JSValue valueWithObject:dict[@"value"] JSValueRef value = [self valueFromDictionary:dict[@"value"]];
inContext:[JSContext contextWithJSGlobalContextRef:s_context]] JSValueRef]; JSValueRef exception = NULL;
ObjectSetProperty(s_context, s_objects[realmId], propString, value, &exception); ObjectSetProperty(s_context, s_objects[realmId], propString, value, &exception);
JSStringRelease(propString); JSStringRelease(propString);

View File

@ -71,6 +71,7 @@ function getObjectProperty(realmId, objectId, name) {
} }
function setObjectProperty(realmId, objectId, name, value) { function setObjectProperty(realmId, objectId, name, value) {
value = serialize(realmId, value);
sendRequest('set_property', {realmId, objectId, name, value}); sendRequest('set_property', {realmId, objectId, name, value});
} }