use capitalized names for enums/constants
This commit is contained in:
parent
8f466d47b1
commit
aa78436f53
|
@ -21,14 +21,14 @@ var {
|
||||||
var TodoItemSchema = {
|
var TodoItemSchema = {
|
||||||
name: 'Todo',
|
name: 'Todo',
|
||||||
properties: [
|
properties: [
|
||||||
{name: 'text', type: Realm.Types.String},
|
{name: 'text', type: Realm.Types.STRING},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
var TodoListSchmea = {
|
var TodoListSchmea = {
|
||||||
name: 'TodoList',
|
name: 'TodoList',
|
||||||
properties: [
|
properties: [
|
||||||
{name: 'name', type: Realm.Types.String},
|
{name: 'name', type: Realm.Types.STRING},
|
||||||
{name: 'items', type: Realm.Types.Array, objectType: 'Todo'}
|
{name: 'items', type: Realm.Types.ARRAY, objectType: 'Todo'}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -64,33 +64,33 @@ static inline Property RJSParseProperty(JSContextRef ctx, JSObjectRef propertyOb
|
||||||
prop.name = RJSValidatedStringProperty(ctx, propertyObject, nameString);
|
prop.name = RJSValidatedStringProperty(ctx, propertyObject, nameString);
|
||||||
|
|
||||||
std::string type = RJSValidatedStringProperty(ctx, propertyObject, typeString);
|
std::string type = RJSValidatedStringProperty(ctx, propertyObject, typeString);
|
||||||
if (type == "RealmTypeBool") {
|
if (type == "PropTypesBOOL") {
|
||||||
prop.type = PropertyTypeBool;
|
prop.type = PropertyTypeBool;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeInt") {
|
else if (type == "PropTypesINT") {
|
||||||
prop.type = PropertyTypeInt;
|
prop.type = PropertyTypeInt;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeFloat") {
|
else if (type == "PropTypesFLOAT") {
|
||||||
prop.type = PropertyTypeFloat;
|
prop.type = PropertyTypeFloat;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeDouble") {
|
else if (type == "PropTypesDOUBLE") {
|
||||||
prop.type = PropertyTypeDouble;
|
prop.type = PropertyTypeDouble;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeString") {
|
else if (type == "PropTypesSTRING") {
|
||||||
prop.type = PropertyTypeString;
|
prop.type = PropertyTypeString;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeDate") {
|
else if (type == "PropTypesDATE") {
|
||||||
prop.type = PropertyTypeDate;
|
prop.type = PropertyTypeDate;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeData") {
|
else if (type == "PropTypesDATA") {
|
||||||
prop.type = PropertyTypeData;
|
prop.type = PropertyTypeData;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeObject") {
|
else if (type == "PropTypesOBJECT") {
|
||||||
prop.type = PropertyTypeObject;
|
prop.type = PropertyTypeObject;
|
||||||
prop.object_type = RJSValidatedStringProperty(ctx, propertyObject, objectTypeString);
|
prop.object_type = RJSValidatedStringProperty(ctx, propertyObject, objectTypeString);
|
||||||
prop.is_nullable = true;
|
prop.is_nullable = true;
|
||||||
}
|
}
|
||||||
else if (type == "RealmTypeArray") {
|
else if (type == "PropTypesARRAY") {
|
||||||
prop.type = PropertyTypeArray;
|
prop.type = PropertyTypeArray;
|
||||||
prop.object_type = RJSValidatedStringProperty(ctx, propertyObject, objectTypeString);
|
prop.object_type = RJSValidatedStringProperty(ctx, propertyObject, objectTypeString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,10 +54,10 @@ std::string RJSStringForJSString(JSStringRef jsString) {
|
||||||
std::string RJSValidatedStringForValue(JSContextRef ctx, JSValueRef value, const char * name) {
|
std::string RJSValidatedStringForValue(JSContextRef ctx, JSValueRef value, const char * name) {
|
||||||
if (!JSValueIsString(ctx, value)) {
|
if (!JSValueIsString(ctx, value)) {
|
||||||
if (name) {
|
if (name) {
|
||||||
throw std::invalid_argument((std::string)"'" + name + "' must be of type 'string'");
|
throw std::invalid_argument((std::string)"'" + name + "' must be of type 'STRING'");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw std::invalid_argument("JSValue must be of type 'string'");
|
throw std::invalid_argument("JSValue must be of type 'STRING'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,22 +21,22 @@
|
||||||
#import "RJSObject.hpp"
|
#import "RJSObject.hpp"
|
||||||
|
|
||||||
JSValueRef RJSTypeGet(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
JSValueRef RJSTypeGet(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
|
||||||
return RJSValueForString(ctx, "RealmType" + RJSStringForJSString(propertyName));
|
return RJSValueForString(ctx, "PropTypes" + RJSStringForJSString(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
JSClassRef RJSRealmTypeClass() {
|
JSClassRef RJSRealmTypeClass() {
|
||||||
JSClassDefinition realmTypesDefinition = kJSClassDefinitionEmpty;
|
JSClassDefinition realmTypesDefinition = kJSClassDefinitionEmpty;
|
||||||
realmTypesDefinition.className = "RealmTypes";
|
realmTypesDefinition.className = "PropTypes";
|
||||||
JSStaticValue types[] = {
|
JSStaticValue types[] = {
|
||||||
{ "Bool", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "BOOL", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "Int", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "INT", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "Float", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "FLOAT", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "Double", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "DOUBLE", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "String", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "STRING", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "Date", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "DATE", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "Data", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "DATA", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "Object", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "OBJECT", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ "Array", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
{ "ARRAY", RJSTypeGet, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
|
||||||
{ NULL, NULL, NULL, 0 }
|
{ NULL, NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
realmTypesDefinition.staticValues = types;
|
realmTypesDefinition.staticValues = types;
|
||||||
|
@ -55,8 +55,6 @@ JSClassRef RJSRealmTypeClass() {
|
||||||
JSObjectSetProperty(ctx, globalRealmObject, typeString, typesObject, kJSPropertyAttributeNone, &exception);
|
JSObjectSetProperty(ctx, globalRealmObject, typeString, typesObject, kJSPropertyAttributeNone, &exception);
|
||||||
JSStringRelease(typeString);
|
JSStringRelease(typeString);
|
||||||
|
|
||||||
RJSRegisterGlobalClass(ctx, globalObject, RJSObjectClass(), "RealmObject", &exception);
|
|
||||||
|
|
||||||
assert(!exception);
|
assert(!exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.Types.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.Types.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 {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
var TestObjectSchema = {
|
var TestObjectSchema = {
|
||||||
name: 'TestObject',
|
name: 'TestObject',
|
||||||
properties: [
|
properties: [
|
||||||
{name: 'doubleCol', type: Realm.Types.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.Types.String},
|
{name: 'name', type: Realm.Types.STRING},
|
||||||
{name: 'age', type: Realm.Types.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.Types.Bool},
|
{name: 'boolCol', type: Realm.Types.BOOL},
|
||||||
{name: 'intCol', type: Realm.Types.Int},
|
{name: 'intCol', type: Realm.Types.INT},
|
||||||
{name: 'floatCol', type: Realm.Types.Float},
|
{name: 'floatCol', type: Realm.Types.FLOAT},
|
||||||
{name: 'doubleCol', type: Realm.Types.Double},
|
{name: 'doubleCol', type: Realm.Types.DOUBLE},
|
||||||
{name: 'stringCol', type: Realm.Types.String},
|
{name: 'stringCol', type: Realm.Types.STRING},
|
||||||
{name: 'dateCol', type: Realm.Types.Date},
|
{name: 'dateCol', type: Realm.Types.DATE},
|
||||||
{name: 'dataCol', type: Realm.Types.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.Types.Object, objectType: 'TestObject'},
|
{name: 'objectCol1', type: Realm.Types.OBJECT, objectType: 'TestObject'},
|
||||||
{name: 'arrayCol', type: Realm.Types.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.Types.Int},
|
{name: 'primaryCol', type: Realm.Types.INT},
|
||||||
{name: 'valueCol', type: Realm.Types.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.Types.String},
|
{name: 'primaryCol',type: Realm.Types.STRING},
|
||||||
{name: 'boolCol', type: Realm.Types.Bool},
|
{name: 'boolCol', type: Realm.Types.BOOL},
|
||||||
{name: 'intCol', type: Realm.Types.Int},
|
{name: 'intCol', type: Realm.Types.INT},
|
||||||
{name: 'floatCol', type: Realm.Types.Float},
|
{name: 'floatCol', type: Realm.Types.FLOAT},
|
||||||
{name: 'doubleCol', type: Realm.Types.Double},
|
{name: 'doubleCol', type: Realm.Types.DOUBLE},
|
||||||
{name: 'stringCol', type: Realm.Types.String},
|
{name: 'stringCol', type: Realm.Types.STRING},
|
||||||
{name: 'dateCol', type: Realm.Types.Date},
|
{name: 'dateCol', type: Realm.Types.DATE},
|
||||||
{name: 'dataCol', type: Realm.Types.Data},
|
{name: 'dataCol', type: Realm.Types.DATA},
|
||||||
{name: 'objectCol', type: 'TestObject'},
|
{name: 'objectCol', type: 'TestObject'},
|
||||||
{name: 'arrayCol', type: Realm.Types.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.Types.Bool, default: true},
|
{name: 'boolCol', type: Realm.Types.BOOL, default: true},
|
||||||
{name: 'intCol', type: Realm.Types.Int, default: -1},
|
{name: 'intCol', type: Realm.Types.INT, default: -1},
|
||||||
{name: 'floatCol', type: Realm.Types.Float, default: -1.1},
|
{name: 'floatCol', type: Realm.Types.FLOAT, default: -1.1},
|
||||||
{name: 'doubleCol', type: Realm.Types.Double, default: -1.11},
|
{name: 'doubleCol', type: Realm.Types.DOUBLE, default: -1.11},
|
||||||
{name: 'stringCol', type: Realm.Types.String, default: 'defaultString'},
|
{name: 'stringCol', type: Realm.Types.STRING, default: 'defaultString'},
|
||||||
{name: 'dateCol', type: Realm.Types.Date, default: new Date(1.111)},
|
{name: 'dateCol', type: Realm.Types.DATE, default: new Date(1.111)},
|
||||||
{name: 'dataCol', type: Realm.Types.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.Types.Array, objectType: 'TestObject', default: [[2]]},
|
{name: 'arrayCol', type: Realm.Types.ARRAY, objectType: 'TestObject', default: [[2]]},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue