Rename some functions according to PR feedback
This commit is contained in:
parent
4a81b091cb
commit
85832f0f02
|
@ -249,7 +249,7 @@ JSValueRef RealmGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef pr
|
|||
return NULL;
|
||||
}
|
||||
|
||||
std::string RealmObjectTypeForValue(SharedRealm &realm, JSContextRef ctx, JSValueRef value) {
|
||||
std::string RJSValidatedObjectTypeForValue(SharedRealm &realm, JSContextRef ctx, JSValueRef value) {
|
||||
if (JSValueIsObject(ctx, value) && JSObjectIsConstructor(ctx, (JSObjectRef)value)) {
|
||||
JSObjectRef constructor = (JSObjectRef)value;
|
||||
|
||||
|
@ -270,7 +270,7 @@ JSValueRef RealmObjects(JSContextRef ctx, JSObjectRef function, JSObjectRef this
|
|||
RJSValidateArgumentCount(argumentCount, 1);
|
||||
|
||||
SharedRealm sharedRealm = *RJSGetInternal<SharedRealm *>(thisObject);
|
||||
std::string className = RealmObjectTypeForValue(sharedRealm, ctx, arguments[0]);
|
||||
std::string className = RJSValidatedObjectTypeForValue(sharedRealm, ctx, arguments[0]);
|
||||
return RJSResultsCreate(ctx, sharedRealm, className);
|
||||
}
|
||||
catch (std::exception &exp) {
|
||||
|
@ -309,7 +309,7 @@ JSValueRef RealmCreateObject(JSContextRef ctx, JSObjectRef function, JSObjectRef
|
|||
RJSValidateArgumentRange(argumentCount, 2, 3);
|
||||
|
||||
SharedRealm sharedRealm = *RJSGetInternal<SharedRealm *>(thisObject);
|
||||
std::string className = RealmObjectTypeForValue(sharedRealm, ctx, arguments[0]);
|
||||
std::string className = RJSValidatedObjectTypeForValue(sharedRealm, ctx, arguments[0]);
|
||||
auto &schema = sharedRealm->config().schema;
|
||||
auto object_schema = schema->find(className);
|
||||
|
||||
|
|
|
@ -334,12 +334,12 @@ module.exports = BaseTest.extend({
|
|||
});
|
||||
|
||||
// Only the original constructor should be valid.
|
||||
function WrongCustomObject() {}
|
||||
WrongCustomObject.schema = CustomObject.schema;
|
||||
function InvalidCustomObject() {}
|
||||
InvalidCustomObject.schema = CustomObject.schema;
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
realm.write(function() {
|
||||
realm.create(WrongCustomObject, {intCol: 1});
|
||||
realm.create(InvalidCustomObject, {intCol: 1});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -419,8 +419,8 @@ module.exports = BaseTest.extend({
|
|||
var objects = realm.objects(schemas.PersonObject);
|
||||
TestCase.assertTrue(objects[0] instanceof schemas.PersonObject);
|
||||
|
||||
function WrongPerson() {}
|
||||
WrongPerson.schema = schemas.PersonObject.schema;
|
||||
function InvalidPerson() {}
|
||||
InvalidPerson.schema = schemas.PersonObject.schema;
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
realm.objects();
|
||||
|
@ -435,7 +435,7 @@ module.exports = BaseTest.extend({
|
|||
realm.objects('PersonObject', 'truepredicate');
|
||||
});
|
||||
TestCase.assertThrows(function() {
|
||||
realm.objects(WrongPerson);
|
||||
realm.objects(InvalidPerson);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue