Type -> Types

This commit is contained in:
Ari Lazier 2015-09-29 15:14:39 -07:00
parent a7662af484
commit 8f466d47b1
4 changed files with 38 additions and 38 deletions

View File

@ -21,14 +21,14 @@ var {
var TodoItemSchema = { var TodoItemSchema = {
name: 'Todo', name: 'Todo',
properties: [ properties: [
{name: 'text', type: Realm.Type.String}, {name: 'text', type: Realm.Types.String},
] ]
}; };
var TodoListSchmea = { var TodoListSchmea = {
name: 'TodoList', name: 'TodoList',
properties: [ properties: [
{name: 'name', type: Realm.Type.String}, {name: 'name', type: Realm.Types.String},
{name: 'items', type: Realm.Type.Array, objectType: 'Todo'} {name: 'items', type: Realm.Types.Array, objectType: 'Todo'}
] ]
}; };

View File

@ -26,7 +26,7 @@ JSValueRef RJSTypeGet(JSContextRef ctx, JSObjectRef object, JSStringRef property
JSClassRef RJSRealmTypeClass() { JSClassRef RJSRealmTypeClass() {
JSClassDefinition realmTypesDefinition = kJSClassDefinitionEmpty; JSClassDefinition realmTypesDefinition = kJSClassDefinitionEmpty;
realmTypesDefinition.className = "RealmType"; realmTypesDefinition.className = "RealmTypes";
JSStaticValue types[] = { JSStaticValue types[] = {
{ "Bool", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "Bool", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "Int", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "Int", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@ -51,7 +51,7 @@ JSClassRef RJSRealmTypeClass() {
JSObjectRef globalRealmObject = RJSRegisterGlobalClass(ctx, globalObject, RJSRealmConstructorClass(), "Realm", &exception); JSObjectRef globalRealmObject = RJSRegisterGlobalClass(ctx, globalObject, RJSRealmConstructorClass(), "Realm", &exception);
JSObjectRef typesObject = JSObjectMake(ctx, RJSRealmTypeClass(), NULL); JSObjectRef typesObject = JSObjectMake(ctx, RJSRealmTypeClass(), NULL);
JSStringRef typeString = JSStringCreateWithUTF8CString("Type"); JSStringRef typeString = JSStringCreateWithUTF8CString("Types");
JSObjectSetProperty(ctx, globalRealmObject, typeString, typesObject, kJSPropertyAttributeNone, &exception); JSObjectSetProperty(ctx, globalRealmObject, typeString, typesObject, kJSPropertyAttributeNone, &exception);
JSStringRelease(typeString); JSStringRelease(typeString);

View File

@ -29,10 +29,10 @@ var ObjectTests = {
for (var i = 0; i < BasicTypesObjectSchema.properties.length; i++) { for (var i = 0; i < BasicTypesObjectSchema.properties.length; i++) {
var prop = BasicTypesObjectSchema.properties[i]; var prop = BasicTypesObjectSchema.properties[i];
if (prop.type == Realm.Type.Float) { if (prop.type == Realm.Types.Float) {
TestCase.assertEqualWithTolerance(object[prop.name], basicTypesValues[i], 0.000001); TestCase.assertEqualWithTolerance(object[prop.name], basicTypesValues[i], 0.000001);
} }
else if (prop.type == Realm.Type.Date) { else if (prop.type == Realm.Types.Date) {
TestCase.assertEqual(object[prop.name].getTime(), basicTypesValues[i].getTime()); TestCase.assertEqual(object[prop.name].getTime(), basicTypesValues[i].getTime());
} }
else { else {

View File

@ -21,7 +21,7 @@
var TestObjectSchema = { var TestObjectSchema = {
name: 'TestObject', name: 'TestObject',
properties: [ properties: [
{name: 'doubleCol', type: Realm.Type.Double}, {name: 'doubleCol', type: Realm.Types.Double},
] ]
}; };
@ -29,8 +29,8 @@ function PersonObject() {}
PersonObject.prototype.schema = { PersonObject.prototype.schema = {
name: 'PersonObject', name: 'PersonObject',
properties: [ properties: [
{name: 'name', type: Realm.Type.String}, {name: 'name', type: Realm.Types.String},
{name: 'age', type: Realm.Type.Double}, {name: 'age', type: Realm.Types.Double},
] ]
}; };
PersonObject.prototype.description = function() { PersonObject.prototype.description = function() {
@ -40,13 +40,13 @@ PersonObject.prototype.description = function() {
var BasicTypesObjectSchema = { var BasicTypesObjectSchema = {
name: 'BasicTypesObject', name: 'BasicTypesObject',
properties: [ properties: [
{name: 'boolCol', type: Realm.Type.Bool}, {name: 'boolCol', type: Realm.Types.Bool},
{name: 'intCol', type: Realm.Type.Int}, {name: 'intCol', type: Realm.Types.Int},
{name: 'floatCol', type: Realm.Type.Float}, {name: 'floatCol', type: Realm.Types.Float},
{name: 'doubleCol', type: Realm.Type.Double}, {name: 'doubleCol', type: Realm.Types.Double},
{name: 'stringCol', type: Realm.Type.String}, {name: 'stringCol', type: Realm.Types.String},
{name: 'dateCol', type: Realm.Type.Date}, {name: 'dateCol', type: Realm.Types.Date},
{name: 'dataCol', type: Realm.Type.Data}, {name: 'dataCol', type: Realm.Types.Data},
] ]
}; };
@ -54,8 +54,8 @@ var LinkTypesObjectSchema = {
name: 'LinkTypesObject', name: 'LinkTypesObject',
properties: [ properties: [
{name: 'objectCol', type: 'TestObject'}, {name: 'objectCol', type: 'TestObject'},
{name: 'objectCol1', type: Realm.Type.Object, objectType: 'TestObject'}, {name: 'objectCol1', type: Realm.Types.Object, objectType: 'TestObject'},
{name: 'arrayCol', type: Realm.Type.Array, objectType: 'TestObject'}, {name: 'arrayCol', type: Realm.Types.Array, objectType: 'TestObject'},
] ]
}; };
@ -63,8 +63,8 @@ var IntPrimaryObjectSchema = {
name: 'IntPrimaryObject', name: 'IntPrimaryObject',
primaryKey: 'primaryCol', primaryKey: 'primaryCol',
properties: [ properties: [
{name: 'primaryCol', type: Realm.Type.Int}, {name: 'primaryCol', type: Realm.Types.Int},
{name: 'valueCol', type: Realm.Type.String}, {name: 'valueCol', type: Realm.Types.String},
] ]
}; };
@ -72,32 +72,32 @@ var AllTypesObjectSchema = {
name: 'AllTypesObject', name: 'AllTypesObject',
primaryKey: 'primaryCol', primaryKey: 'primaryCol',
properties: [ properties: [
{name: 'primaryCol',type: Realm.Type.String}, {name: 'primaryCol',type: Realm.Types.String},
{name: 'boolCol', type: Realm.Type.Bool}, {name: 'boolCol', type: Realm.Types.Bool},
{name: 'intCol', type: Realm.Type.Int}, {name: 'intCol', type: Realm.Types.Int},
{name: 'floatCol', type: Realm.Type.Float}, {name: 'floatCol', type: Realm.Types.Float},
{name: 'doubleCol', type: Realm.Type.Double}, {name: 'doubleCol', type: Realm.Types.Double},
{name: 'stringCol', type: Realm.Type.String}, {name: 'stringCol', type: Realm.Types.String},
{name: 'dateCol', type: Realm.Type.Date}, {name: 'dateCol', type: Realm.Types.Date},
{name: 'dataCol', type: Realm.Type.Data}, {name: 'dataCol', type: Realm.Types.Data},
{name: 'objectCol', type: 'TestObject'}, {name: 'objectCol', type: 'TestObject'},
{name: 'arrayCol', type: Realm.Type.Array, objectType: 'TestObject'}, {name: 'arrayCol', type: Realm.Types.Array, objectType: 'TestObject'},
] ]
}; };
var DefaultValuesObjectSchema = { var DefaultValuesObjectSchema = {
name: 'DefaultValuesObject', name: 'DefaultValuesObject',
properties: [ properties: [
{name: 'boolCol', type: Realm.Type.Bool, default: true}, {name: 'boolCol', type: Realm.Types.Bool, default: true},
{name: 'intCol', type: Realm.Type.Int, default: -1}, {name: 'intCol', type: Realm.Types.Int, default: -1},
{name: 'floatCol', type: Realm.Type.Float, default: -1.1}, {name: 'floatCol', type: Realm.Types.Float, default: -1.1},
{name: 'doubleCol', type: Realm.Type.Double, default: -1.11}, {name: 'doubleCol', type: Realm.Types.Double, default: -1.11},
{name: 'stringCol', type: Realm.Type.String, default: 'defaultString'}, {name: 'stringCol', type: Realm.Types.String, default: 'defaultString'},
{name: 'dateCol', type: Realm.Type.Date, default: new Date(1.111)}, {name: 'dateCol', type: Realm.Types.Date, default: new Date(1.111)},
{name: 'dataCol', type: Realm.Type.Data, default: 'defaultData'}, {name: 'dataCol', type: Realm.Types.Data, default: 'defaultData'},
{name: 'objectCol', type: 'TestObject', default: [1]}, {name: 'objectCol', type: 'TestObject', default: [1]},
{name: 'nullObjectCol', type: 'TestObject', default: null}, {name: 'nullObjectCol', type: 'TestObject', default: null},
{name: 'arrayCol', type: Realm.Type.Array, objectType: 'TestObject', default: [[2]]}, {name: 'arrayCol', type: Realm.Types.Array, objectType: 'TestObject', default: [[2]]},
] ]
}; };