RJSArray -> RJSList

This commit is contained in:
Ari Lazier 2015-10-13 15:27:24 -07:00
parent 385f387332
commit f6e0d34022
7 changed files with 26 additions and 26 deletions

View File

@ -21,8 +21,8 @@
02601F121BA10228007C91FF /* transact_log_handler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 02601F101BA10228007C91FF /* transact_log_handler.hpp */; }; 02601F121BA10228007C91FF /* transact_log_handler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 02601F101BA10228007C91FF /* transact_log_handler.hpp */; };
0270BC4C1B7CFC0D00010E03 /* RealmJS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC3E1B7CFC0D00010E03 /* RealmJS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0270BC4C1B7CFC0D00010E03 /* RealmJS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC3E1B7CFC0D00010E03 /* RealmJS.h */; settings = {ATTRIBUTES = (Public, ); }; };
0270BC4D1B7CFC0D00010E03 /* RealmJS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC3F1B7CFC0D00010E03 /* RealmJS.mm */; }; 0270BC4D1B7CFC0D00010E03 /* RealmJS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC3F1B7CFC0D00010E03 /* RealmJS.mm */; };
0270BC4E1B7CFC0D00010E03 /* RJSArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC401B7CFC0D00010E03 /* RJSArray.cpp */; }; 0270BC4E1B7CFC0D00010E03 /* RJSList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC401B7CFC0D00010E03 /* RJSList.cpp */; };
0270BC4F1B7CFC0D00010E03 /* RJSArray.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC411B7CFC0D00010E03 /* RJSArray.hpp */; settings = {ATTRIBUTES = (Private, ); }; }; 0270BC4F1B7CFC0D00010E03 /* RJSList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC411B7CFC0D00010E03 /* RJSList.hpp */; settings = {ATTRIBUTES = (Private, ); }; };
0270BC501B7CFC0D00010E03 /* RJSObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC421B7CFC0D00010E03 /* RJSObject.hpp */; settings = {ATTRIBUTES = (Private, ); }; }; 0270BC501B7CFC0D00010E03 /* RJSObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC421B7CFC0D00010E03 /* RJSObject.hpp */; settings = {ATTRIBUTES = (Private, ); }; };
0270BC511B7CFC0D00010E03 /* RJSObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC431B7CFC0D00010E03 /* RJSObject.mm */; }; 0270BC511B7CFC0D00010E03 /* RJSObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC431B7CFC0D00010E03 /* RJSObject.mm */; };
0270BC521B7CFC0D00010E03 /* RJSRealm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */; settings = {ATTRIBUTES = (Private, ); }; }; 0270BC521B7CFC0D00010E03 /* RJSRealm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */; settings = {ATTRIBUTES = (Private, ); }; };
@ -144,8 +144,8 @@
02601F101BA10228007C91FF /* transact_log_handler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = transact_log_handler.hpp; path = "src/object-store/transact_log_handler.hpp"; sourceTree = "<group>"; }; 02601F101BA10228007C91FF /* transact_log_handler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = transact_log_handler.hpp; path = "src/object-store/transact_log_handler.hpp"; sourceTree = "<group>"; };
0270BC3E1B7CFC0D00010E03 /* RealmJS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RealmJS.h; path = src/RealmJS.h; sourceTree = "<group>"; }; 0270BC3E1B7CFC0D00010E03 /* RealmJS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RealmJS.h; path = src/RealmJS.h; sourceTree = "<group>"; };
0270BC3F1B7CFC0D00010E03 /* RealmJS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RealmJS.mm; path = src/RealmJS.mm; sourceTree = "<group>"; }; 0270BC3F1B7CFC0D00010E03 /* RealmJS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RealmJS.mm; path = src/RealmJS.mm; sourceTree = "<group>"; };
0270BC401B7CFC0D00010E03 /* RJSArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RJSArray.cpp; path = src/RJSArray.cpp; sourceTree = "<group>"; }; 0270BC401B7CFC0D00010E03 /* RJSList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RJSList.cpp; path = src/RJSList.cpp; sourceTree = "<group>"; };
0270BC411B7CFC0D00010E03 /* RJSArray.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RJSArray.hpp; path = src/RJSArray.hpp; sourceTree = "<group>"; }; 0270BC411B7CFC0D00010E03 /* RJSList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RJSList.hpp; path = src/RJSList.hpp; sourceTree = "<group>"; };
0270BC421B7CFC0D00010E03 /* RJSObject.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RJSObject.hpp; path = src/RJSObject.hpp; sourceTree = "<group>"; }; 0270BC421B7CFC0D00010E03 /* RJSObject.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RJSObject.hpp; path = src/RJSObject.hpp; sourceTree = "<group>"; };
0270BC431B7CFC0D00010E03 /* RJSObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RJSObject.mm; path = src/RJSObject.mm; sourceTree = "<group>"; }; 0270BC431B7CFC0D00010E03 /* RJSObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RJSObject.mm; path = src/RJSObject.mm; sourceTree = "<group>"; };
0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RJSRealm.hpp; path = src/RJSRealm.hpp; sourceTree = "<group>"; }; 0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RJSRealm.hpp; path = src/RJSRealm.hpp; sourceTree = "<group>"; };
@ -246,8 +246,8 @@
0270BC3F1B7CFC0D00010E03 /* RealmJS.mm */, 0270BC3F1B7CFC0D00010E03 /* RealmJS.mm */,
02258FB11BC6E2D00075F13A /* RealmRPC.h */, 02258FB11BC6E2D00075F13A /* RealmRPC.h */,
02258FB21BC6E2D00075F13A /* RealmRPC.mm */, 02258FB21BC6E2D00075F13A /* RealmRPC.mm */,
0270BC401B7CFC0D00010E03 /* RJSArray.cpp */, 0270BC401B7CFC0D00010E03 /* RJSList.cpp */,
0270BC411B7CFC0D00010E03 /* RJSArray.hpp */, 0270BC411B7CFC0D00010E03 /* RJSList.hpp */,
0270BC421B7CFC0D00010E03 /* RJSObject.hpp */, 0270BC421B7CFC0D00010E03 /* RJSObject.hpp */,
0270BC431B7CFC0D00010E03 /* RJSObject.mm */, 0270BC431B7CFC0D00010E03 /* RJSObject.mm */,
0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */, 0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */,
@ -340,7 +340,7 @@
files = ( files = (
0270BC4C1B7CFC0D00010E03 /* RealmJS.h in Headers */, 0270BC4C1B7CFC0D00010E03 /* RealmJS.h in Headers */,
02258FB31BC6E2D00075F13A /* RealmRPC.h in Headers */, 02258FB31BC6E2D00075F13A /* RealmRPC.h in Headers */,
0270BC4F1B7CFC0D00010E03 /* RJSArray.hpp in Headers */, 0270BC4F1B7CFC0D00010E03 /* RJSList.hpp in Headers */,
0270BC541B7CFC0D00010E03 /* RJSResults.hpp in Headers */, 0270BC541B7CFC0D00010E03 /* RJSResults.hpp in Headers */,
0270BC581B7CFC0D00010E03 /* RJSUtil.hpp in Headers */, 0270BC581B7CFC0D00010E03 /* RJSUtil.hpp in Headers */,
0270BC561B7CFC0D00010E03 /* RJSSchema.hpp in Headers */, 0270BC561B7CFC0D00010E03 /* RJSSchema.hpp in Headers */,
@ -571,7 +571,7 @@
02601F031BA0F0C4007C91FF /* external_commit_helper.cpp in Sources */, 02601F031BA0F0C4007C91FF /* external_commit_helper.cpp in Sources */,
0270BC6B1B7CFC1C00010E03 /* object_store.cpp in Sources */, 0270BC6B1B7CFC1C00010E03 /* object_store.cpp in Sources */,
0270BC701B7CFC1C00010E03 /* shared_realm.cpp in Sources */, 0270BC701B7CFC1C00010E03 /* shared_realm.cpp in Sources */,
0270BC4E1B7CFC0D00010E03 /* RJSArray.cpp in Sources */, 0270BC4E1B7CFC0D00010E03 /* RJSList.cpp in Sources */,
0270BC531B7CFC0D00010E03 /* RJSRealm.mm in Sources */, 0270BC531B7CFC0D00010E03 /* RJSRealm.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;

View File

@ -16,7 +16,7 @@
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#include "RJSArray.hpp" #include "RJSList.hpp"
#include "RJSObject.hpp" #include "RJSObject.hpp"
#include "RJSUtil.hpp" #include "RJSUtil.hpp"
#include "object_accessor.hpp" #include "object_accessor.hpp"
@ -210,11 +210,11 @@ JSValueRef ArraySplice(JSContextRef ctx, JSObjectRef function, JSObjectRef thisO
return NULL; return NULL;
} }
JSObjectRef RJSArrayCreate(JSContextRef ctx, realm::List &list) { JSObjectRef RJSListCreate(JSContextRef ctx, realm::List &list) {
return RJSWrapObject<List *>(ctx, RJSArrayClass(), new List(list)); return RJSWrapObject<List *>(ctx, RJSListClass(), new List(list));
} }
const JSStaticFunction RJSArrayFuncs[] = { const JSStaticFunction RJSListFuncs[] = {
{"push", ArrayPush, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"push", ArrayPush, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
{"pop", ArrayPop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"pop", ArrayPop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
{"shift", ArrayShift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"shift", ArrayShift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
@ -223,7 +223,7 @@ const JSStaticFunction RJSArrayFuncs[] = {
{NULL, NULL}, {NULL, NULL},
}; };
JSClassRef RJSArrayClass() { JSClassRef RJSListClass() {
static JSClassRef s_arrayClass = RJSCreateWrapperClass<Object>("RealmArray", ArrayGetProperty, ArraySetProperty, RJSArrayFuncs, NULL, ArrayPropertyNames); static JSClassRef s_arrayClass = RJSCreateWrapperClass<Object>("RealmList", ArrayGetProperty, ArraySetProperty, RJSListFuncs, NULL, ArrayPropertyNames);
return s_arrayClass; return s_arrayClass;
} }

View File

@ -20,8 +20,8 @@
#import "shared_realm.hpp" #import "shared_realm.hpp"
#import "list.hpp" #import "list.hpp"
extern const JSStaticFunction RJSArrayFuncs[]; extern const JSStaticFunction RJSListFuncs[];
JSClassRef RJSArrayClass(); JSClassRef RJSListClass();
JSObjectRef RJSArrayCreate(JSContextRef ctx, realm::List &list); JSObjectRef RJSListCreate(JSContextRef ctx, realm::List &list);
JSValueRef ArrayGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* jsException); JSValueRef ArrayGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* jsException);

View File

@ -20,7 +20,7 @@
#import "RJSObject.hpp" #import "RJSObject.hpp"
#import "RJSResults.hpp" #import "RJSResults.hpp"
#import "RJSSchema.hpp" #import "RJSSchema.hpp"
#import "RJSArray.hpp" #import "RJSList.hpp"
#import "object_store.hpp" #import "object_store.hpp"
#import "object_accessor.hpp" #import "object_accessor.hpp"
@ -192,5 +192,5 @@ template<> JSValueRef RJSAccessor::list_value_at_index(JSContextRef ctx, JSValue
return RJSValidatedObjectAtIndex(ctx, RJSValidatedValueToObject(ctx, val), (unsigned int)index); return RJSValidatedObjectAtIndex(ctx, RJSValidatedValueToObject(ctx, val), (unsigned int)index);
} }
template<> JSValueRef RJSAccessor::from_list(JSContextRef ctx, List list) { template<> JSValueRef RJSAccessor::from_list(JSContextRef ctx, List list) {
return RJSArrayCreate(ctx, list); return RJSListCreate(ctx, list);
} }

View File

@ -19,7 +19,7 @@
#import "RJSRealm.hpp" #import "RJSRealm.hpp"
#import "RJSObject.hpp" #import "RJSObject.hpp"
#import "RJSResults.hpp" #import "RJSResults.hpp"
#import "RJSArray.hpp" #import "RJSList.hpp"
#import "RJSSchema.hpp" #import "RJSSchema.hpp"
#import "shared_realm.hpp" #import "shared_realm.hpp"
@ -280,7 +280,7 @@ JSValueRef RealmDelete(JSContextRef ctx, JSObjectRef function, JSObjectRef thisO
if (RJSIsValueArray(ctx, arguments[0]) || if (RJSIsValueArray(ctx, arguments[0]) ||
JSValueIsObjectOfClass(ctx, arguments[0], RJSResultsClass()) || JSValueIsObjectOfClass(ctx, arguments[0], RJSResultsClass()) ||
JSValueIsObjectOfClass(ctx, arguments[0], RJSArrayClass())) JSValueIsObjectOfClass(ctx, arguments[0], RJSListClass()))
{ {
JSObjectRef array = RJSValidatedValueToObject(ctx, arguments[0]); JSObjectRef array = RJSValidatedValueToObject(ctx, arguments[0]);
size_t length = RJSValidatedListLength(ctx, array); size_t length = RJSValidatedListLength(ctx, array);

View File

@ -24,7 +24,7 @@
#include "RealmJS.h" #include "RealmJS.h"
#include "RJSObject.hpp" #include "RJSObject.hpp"
#include "RJSResults.hpp" #include "RJSResults.hpp"
#include "RJSArray.hpp" #include "RJSList.hpp"
#include "RJSRealm.hpp" #include "RJSRealm.hpp"
#include "RJSUtil.hpp" #include "RJSUtil.hpp"
@ -166,7 +166,7 @@ using RPCRequest = std::function<NSDictionary *(NSDictionary *dictionary)>;
_requests["/call_list_method"] = [=](NSDictionary *dict) { _requests["/call_list_method"] = [=](NSDictionary *dict) {
NSString *name = dict[@"name"]; NSString *name = dict[@"name"];
return [self performObjectMethod:name.UTF8String return [self performObjectMethod:name.UTF8String
classMethods:RJSArrayFuncs classMethods:RJSListFuncs
args:dict[@"arguments"] args:dict[@"arguments"]
objectId:[dict[@"listId"] unsignedLongValue]]; objectId:[dict[@"listId"] unsignedLongValue]];
}; };
@ -249,7 +249,7 @@ using RPCRequest = std::function<NSDictionary *(NSDictionary *dictionary)>;
@"schema": [self objectSchemaToJSONObject:object->object_schema] @"schema": [self objectSchemaToJSONObject:object->object_schema]
}; };
} }
else if (JSValueIsObjectOfClass(_context, value, RJSArrayClass())) { else if (JSValueIsObjectOfClass(_context, value, RJSListClass())) {
realm::List *list = RJSGetInternal<realm::List *>(jsObject); realm::List *list = RJSGetInternal<realm::List *>(jsObject);
RPCObjectID oid = [self storeObject:jsObject]; RPCObjectID oid = [self storeObject:jsObject];
return @{ return @{

View File

@ -243,9 +243,9 @@ static JSClassRef s_globalClass;
} }
@end @end
@interface RJSArrayTests : RealmJSTests @interface RJSListTests : RealmJSTests
@end @end
@implementation RJSArrayTests @implementation RJSListTests
+ (NSString *)jsSuiteName { + (NSString *)jsSuiteName {
return @"ArrayTests"; return @"ArrayTests";
} }