partial rpc server implemenation
This commit is contained in:
parent
bf1ecfbb07
commit
476b3623bb
|
@ -0,0 +1,27 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <GCDWebServers/GCDWebServers.h>
|
||||
|
||||
@interface RJSRPCServer : NSObject
|
||||
|
||||
+ (void)start;
|
||||
|
||||
@end
|
|
@ -0,0 +1,108 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import "RealmRPC.h"
|
||||
#import <JavaScriptCore/JavaScriptCore.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "RJSObject.hpp"
|
||||
#include "RJSResults.hpp"
|
||||
#include "RJSRealm.hpp"
|
||||
#include "RJSUtil.hpp"
|
||||
|
||||
using RPCObjectID = long;
|
||||
using RPCRequest = std::function<std::string(NSDictionary *dictionary)>;
|
||||
static std::map<std::string, RPCRequest> s_requests;
|
||||
static std::map<RPCObjectID, JSObjectRef> s_objects;
|
||||
|
||||
static JSGlobalContextRef s_context;
|
||||
static RPCObjectID s_id_counter = 0;
|
||||
|
||||
@implementation RJSRPCServer
|
||||
|
||||
+ (void)start {
|
||||
// Create server
|
||||
GCDWebServer* webServer = [[GCDWebServer alloc] init];
|
||||
s_context = JSGlobalContextCreate(NULL);
|
||||
|
||||
s_requests["create_realm"] = [=](NSDictionary *dict) {
|
||||
RPCObjectID realmId = s_id_counter++;
|
||||
JSValueRef value = [[JSValue valueWithObject:dict
|
||||
inContext:[JSContext contextWithJSGlobalContextRef:s_context]] JSValueRef];
|
||||
s_objects[realmId] = RealmConstructor(s_context, NULL, 1, &value, NULL);
|
||||
return std::to_string(realmId);
|
||||
};
|
||||
s_requests["create_object"] = [=](NSDictionary *dict) {
|
||||
RPCObjectID newOid = s_id_counter++;
|
||||
RPCObjectID realmId = [dict[@"realmId"] longValue];
|
||||
JSValueRef value = [[JSValue valueWithObject:dict[@"value"]
|
||||
inContext:[JSContext contextWithJSGlobalContextRef:s_context]] JSValueRef];
|
||||
JSValueRef exception = NULL;
|
||||
JSValueRef object = RealmCreateObject(s_context, NULL, s_objects[realmId], 1, &value, &exception);
|
||||
JSValueProtect(s_context, object);
|
||||
s_objects[newOid] = (JSObjectRef)object;
|
||||
return std::to_string(newOid);
|
||||
};
|
||||
s_requests["dispose_realm"] = [=](NSDictionary *dict) {
|
||||
RPCObjectID realmId = [dict[@"realmId"] longValue];
|
||||
JSValueUnprotect(s_context, s_objects[realmId]);
|
||||
s_objects.erase(realmId);
|
||||
return "";
|
||||
};
|
||||
s_requests["get_property"] = [=](NSDictionary *dict) {
|
||||
JSStringRef propString = RJSStringForString([dict[@"name"] UTF8String]);
|
||||
RPCObjectID realmId = [dict[@"realmId"] longValue];
|
||||
JSValueRef propertyValue = ObjectGetProperty(s_context, s_objects[realmId], propString, NULL);
|
||||
JSStringRelease(propString);
|
||||
|
||||
return RJSValidatedStringForValue(s_context, propertyValue);
|
||||
};
|
||||
s_requests["set_property"] = [=](NSDictionary *dict) {
|
||||
JSValueRef exception = NULL;
|
||||
JSStringRef propString = RJSStringForString([dict[@"name"] UTF8String]);
|
||||
RPCObjectID realmId = [dict[@"realmId"] longValue];
|
||||
JSValueRef value = [[JSValue valueWithObject:dict[@"value"]
|
||||
inContext:[JSContext contextWithJSGlobalContextRef:s_context]] JSValueRef];
|
||||
ObjectSetProperty(s_context, s_objects[realmId], propString, value, &exception);
|
||||
JSStringRelease(propString);
|
||||
|
||||
return exception ? "exception" : "";
|
||||
};
|
||||
s_requests["dispose_object"] = [=](NSDictionary *dict) {
|
||||
RPCObjectID oid = [dict[@"realmId"] longValue];
|
||||
JSValueUnprotect(s_context, s_objects[oid]);
|
||||
s_objects.erase(oid);
|
||||
return "";
|
||||
};
|
||||
|
||||
// Add a handler to respond to GET requests on any URL
|
||||
[webServer addDefaultHandlerForMethod:@"POST"
|
||||
requestClass:[GCDWebServerDataRequest class]
|
||||
processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
|
||||
RPCRequest action = s_requests[request.path.UTF8String];
|
||||
NSDictionary *json = [(GCDWebServerDataRequest *)request jsonObject];
|
||||
return [GCDWebServerDataResponse responseWithHTML:@(action(json).c_str())];
|
||||
}];
|
||||
[webServer startWithPort:8082 bonjourName:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "Base/RCTBridgeModule.h"
|
||||
#import "RealmRPC.h"
|
||||
|
||||
@protocol RCTBridgeModule;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#import "RealmReactModule.h"
|
||||
#import "Base/RCTLog.h"
|
||||
#import "Base/RCTBridge.h"
|
||||
#import "RealmRPC.h"
|
||||
|
||||
@import RealmJS;
|
||||
@import JavaScriptCore;
|
||||
|
@ -49,6 +50,7 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
// The executor could be a RCTWebSocketExecutor, in which case it won't have a JS context.
|
||||
if (!contextIvar) {
|
||||
[RJSRPCServer start];
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
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 */; };
|
||||
0270BC4E1B7CFC0D00010E03 /* RJSArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC401B7CFC0D00010E03 /* RJSArray.cpp */; };
|
||||
0270BC4F1B7CFC0D00010E03 /* RJSArray.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC411B7CFC0D00010E03 /* RJSArray.hpp */; };
|
||||
0270BC501B7CFC0D00010E03 /* RJSObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC421B7CFC0D00010E03 /* RJSObject.hpp */; };
|
||||
0270BC4F1B7CFC0D00010E03 /* RJSArray.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC411B7CFC0D00010E03 /* RJSArray.hpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0270BC501B7CFC0D00010E03 /* RJSObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC421B7CFC0D00010E03 /* RJSObject.hpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0270BC511B7CFC0D00010E03 /* RJSObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC431B7CFC0D00010E03 /* RJSObject.mm */; };
|
||||
0270BC521B7CFC0D00010E03 /* RJSRealm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */; };
|
||||
0270BC521B7CFC0D00010E03 /* RJSRealm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC441B7CFC0D00010E03 /* RJSRealm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0270BC531B7CFC0D00010E03 /* RJSRealm.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC451B7CFC0D00010E03 /* RJSRealm.mm */; };
|
||||
0270BC541B7CFC0D00010E03 /* RJSResults.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC461B7CFC0D00010E03 /* RJSResults.hpp */; };
|
||||
0270BC541B7CFC0D00010E03 /* RJSResults.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC461B7CFC0D00010E03 /* RJSResults.hpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0270BC551B7CFC0D00010E03 /* RJSResults.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC471B7CFC0D00010E03 /* RJSResults.mm */; };
|
||||
0270BC561B7CFC0D00010E03 /* RJSSchema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC481B7CFC0D00010E03 /* RJSSchema.hpp */; };
|
||||
0270BC561B7CFC0D00010E03 /* RJSSchema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC481B7CFC0D00010E03 /* RJSSchema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0270BC571B7CFC0D00010E03 /* RJSSchema.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC491B7CFC0D00010E03 /* RJSSchema.mm */; };
|
||||
0270BC581B7CFC0D00010E03 /* RJSUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC4A1B7CFC0D00010E03 /* RJSUtil.hpp */; };
|
||||
0270BC581B7CFC0D00010E03 /* RJSUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC4A1B7CFC0D00010E03 /* RJSUtil.hpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0270BC591B7CFC0D00010E03 /* RJSUtil.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC4B1B7CFC0D00010E03 /* RJSUtil.mm */; };
|
||||
0270BC671B7CFC1C00010E03 /* object_accessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC5C1B7CFC1C00010E03 /* object_accessor.cpp */; };
|
||||
0270BC681B7CFC1C00010E03 /* object_accessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0270BC5D1B7CFC1C00010E03 /* object_accessor.hpp */; };
|
||||
|
@ -49,6 +49,8 @@
|
|||
0270BC861B7D020100010E03 /* TestObjects.js in Resources */ = {isa = PBXBuildFile; fileRef = 0270BC7F1B7D020100010E03 /* TestObjects.js */; };
|
||||
0270BC871B7D023200010E03 /* RealmJS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CB11AE99CEC009B348C /* RealmJS.framework */; };
|
||||
0270BCD11B7D067300010E03 /* RealmReactModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 0270BCD01B7D067300010E03 /* RealmReactModule.m */; };
|
||||
027799291BC3037900C96559 /* RealmRPC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 027799281BC3037900C96559 /* RealmRPC.mm */; settings = {ASSET_TAGS = (); }; };
|
||||
02A3C7971BC4318600B1A7BE /* GCDWebServers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02A3C7941BC4317A00B1A7BE /* GCDWebServers.framework */; };
|
||||
02B29A311B7CF86D008A7E6B /* RealmJS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CB11AE99CEC009B348C /* RealmJS.framework */; };
|
||||
02B58CCE1AE99D4D009B348C /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CCD1AE99D4D009B348C /* JavaScriptCore.framework */; };
|
||||
02D456DA1B7E59A500EE1299 /* ArrayTests.js in Resources */ = {isa = PBXBuildFile; fileRef = 02D456D91B7E59A500EE1299 /* ArrayTests.js */; };
|
||||
|
@ -56,6 +58,41 @@
|
|||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
02A3C78D1BC4317A00B1A7BE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 8DD76FB20486AB0100D96B5E;
|
||||
remoteInfo = "GCDWebServer (Mac)";
|
||||
};
|
||||
02A3C78F1BC4317A00B1A7BE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = E221125A1690B4DE0048D2B2;
|
||||
remoteInfo = "GCDWebServer (iOS)";
|
||||
};
|
||||
02A3C7911BC4317A00B1A7BE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = CEE28CD11AE004D800F4023C;
|
||||
remoteInfo = "GCDWebServers (Mac)";
|
||||
};
|
||||
02A3C7931BC4317A00B1A7BE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = CEE28CEF1AE0051F00F4023C;
|
||||
remoteInfo = "GCDWebServers (iOS)";
|
||||
};
|
||||
02A3C7951BC4317A00B1A7BE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = E24039251BA09207000B7089;
|
||||
remoteInfo = "Tests (Mac)";
|
||||
};
|
||||
02B29A2F1B7CF7ED008A7E6B /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 02B58CA81AE99CEB009B348C /* Project object */;
|
||||
|
@ -130,6 +167,10 @@
|
|||
0270BC7F1B7D020100010E03 /* TestObjects.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = TestObjects.js; path = tests/TestObjects.js; sourceTree = SOURCE_ROOT; };
|
||||
0270BCCF1B7D067300010E03 /* RealmReactModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RealmReactModule.h; path = ReactNative/RealmReactModule.h; sourceTree = "<group>"; };
|
||||
0270BCD01B7D067300010E03 /* RealmReactModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RealmReactModule.m; path = ReactNative/RealmReactModule.m; sourceTree = "<group>"; };
|
||||
027799281BC3037900C96559 /* RealmRPC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RealmRPC.mm; path = ReactNative/RealmRPC.mm; sourceTree = "<group>"; };
|
||||
0277992A1BC3039100C96559 /* RealmRPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RealmRPC.h; path = ReactNative/RealmRPC.h; sourceTree = "<group>"; };
|
||||
02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GCDWebServer.xcodeproj; path = "../../../Downloads/GCDWebServer-3.2.7/GCDWebServer.xcodeproj"; sourceTree = "<group>"; };
|
||||
02A3C7A41BC4341500B1A7BE /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
|
||||
02B29A161B7CF7C9008A7E6B /* libRealmReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRealmReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
02B58CB11AE99CEC009B348C /* RealmJS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RealmJS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
02B58CBC1AE99CEC009B348C /* RealmJSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RealmJSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -142,6 +183,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
02A3C7971BC4318600B1A7BE /* GCDWebServers.framework in Frameworks */,
|
||||
02B29A311B7CF86D008A7E6B /* RealmJS.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -213,13 +255,28 @@
|
|||
children = (
|
||||
0270BCCF1B7D067300010E03 /* RealmReactModule.h */,
|
||||
0270BCD01B7D067300010E03 /* RealmReactModule.m */,
|
||||
027799281BC3037900C96559 /* RealmRPC.mm */,
|
||||
0277992A1BC3039100C96559 /* RealmRPC.h */,
|
||||
);
|
||||
name = ReactNativeModule;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
02A3C7851BC4317A00B1A7BE /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02A3C78E1BC4317A00B1A7BE /* GCDWebServer */,
|
||||
02A3C7901BC4317A00B1A7BE /* GCDWebServer.app */,
|
||||
02A3C7921BC4317A00B1A7BE /* GCDWebServers.framework */,
|
||||
02A3C7941BC4317A00B1A7BE /* GCDWebServers.framework */,
|
||||
02A3C7961BC4317A00B1A7BE /* Tests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
02B58CA71AE99CEB009B348C = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */,
|
||||
02B58CCF1AE99D8C009B348C /* Frameworks */,
|
||||
0270BC3D1B7CFBFD00010E03 /* RealmJS */,
|
||||
02B58CC01AE99CEC009B348C /* RealmJSTests */,
|
||||
|
@ -257,6 +314,7 @@
|
|||
02B58CCF1AE99D8C009B348C /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02A3C7A41BC4341500B1A7BE /* libc++.tbd */,
|
||||
02B58CCD1AE99D4D009B348C /* JavaScriptCore.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
|
@ -271,22 +329,22 @@
|
|||
files = (
|
||||
0270BC4C1B7CFC0D00010E03 /* RealmJS.h in Headers */,
|
||||
0270BC4F1B7CFC0D00010E03 /* RJSArray.hpp in Headers */,
|
||||
0270BC541B7CFC0D00010E03 /* RJSResults.hpp in Headers */,
|
||||
0270BC581B7CFC0D00010E03 /* RJSUtil.hpp in Headers */,
|
||||
0270BC561B7CFC0D00010E03 /* RJSSchema.hpp in Headers */,
|
||||
0270BC521B7CFC0D00010E03 /* RJSRealm.hpp in Headers */,
|
||||
0270BC501B7CFC0D00010E03 /* RJSObject.hpp in Headers */,
|
||||
02601F0E1BA0F3A7007C91FF /* schema.hpp in Headers */,
|
||||
0270BC6C1B7CFC1C00010E03 /* object_store.hpp in Headers */,
|
||||
02601F0A1BA0F0CD007C91FF /* realm_delegate.hpp in Headers */,
|
||||
0270BC541B7CFC0D00010E03 /* RJSResults.hpp in Headers */,
|
||||
02601F121BA10228007C91FF /* transact_log_handler.hpp in Headers */,
|
||||
0270BC681B7CFC1C00010E03 /* object_accessor.hpp in Headers */,
|
||||
0270BC711B7CFC1C00010E03 /* shared_realm.hpp in Headers */,
|
||||
0270BC581B7CFC0D00010E03 /* RJSUtil.hpp in Headers */,
|
||||
0270BC6A1B7CFC1C00010E03 /* object_schema.hpp in Headers */,
|
||||
02601F041BA0F0C4007C91FF /* external_commit_helper.hpp in Headers */,
|
||||
02601F091BA0F0CD007C91FF /* index_set.hpp in Headers */,
|
||||
0270BC6D1B7CFC1C00010E03 /* property.hpp in Headers */,
|
||||
0270BC6F1B7CFC1C00010E03 /* results.hpp in Headers */,
|
||||
0270BC561B7CFC0D00010E03 /* RJSSchema.hpp in Headers */,
|
||||
0270BC521B7CFC0D00010E03 /* RJSRealm.hpp in Headers */,
|
||||
0270BC501B7CFC0D00010E03 /* RJSObject.hpp in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -378,6 +436,12 @@
|
|||
mainGroup = 02B58CA71AE99CEB009B348C;
|
||||
productRefGroup = 02B58CB21AE99CEC009B348C /* Products */;
|
||||
projectDirPath = "";
|
||||
projectReferences = (
|
||||
{
|
||||
ProductGroup = 02A3C7851BC4317A00B1A7BE /* Products */;
|
||||
ProjectRef = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
|
||||
},
|
||||
);
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
02B58CB01AE99CEC009B348C /* RealmJS */,
|
||||
|
@ -387,6 +451,44 @@
|
|||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXReferenceProxy section */
|
||||
02A3C78E1BC4317A00B1A7BE /* GCDWebServer */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = "compiled.mach-o.executable";
|
||||
path = GCDWebServer;
|
||||
remoteRef = 02A3C78D1BC4317A00B1A7BE /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
02A3C7901BC4317A00B1A7BE /* GCDWebServer.app */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.application;
|
||||
path = GCDWebServer.app;
|
||||
remoteRef = 02A3C78F1BC4317A00B1A7BE /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
02A3C7921BC4317A00B1A7BE /* GCDWebServers.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = GCDWebServers.framework;
|
||||
remoteRef = 02A3C7911BC4317A00B1A7BE /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
02A3C7941BC4317A00B1A7BE /* GCDWebServers.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = GCDWebServers.framework;
|
||||
remoteRef = 02A3C7931BC4317A00B1A7BE /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
02A3C7961BC4317A00B1A7BE /* Tests.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = Tests.xctest;
|
||||
remoteRef = 02A3C7951BC4317A00B1A7BE /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
02B58CAF1AE99CEC009B348C /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
|
@ -433,6 +535,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0270BCD11B7D067300010E03 /* RealmReactModule.m in Sources */,
|
||||
027799291BC3037900C96559 /* RealmRPC.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -486,6 +589,11 @@
|
|||
02B29A281B7CF7C9008A7E6B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
|
@ -495,7 +603,7 @@
|
|||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/examples/ReactExample/node_modules/react-native/React/",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
|
@ -505,12 +613,17 @@
|
|||
02B29A291B7CF7C9008A7E6B /* GCov_Build */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/examples/ReactExample/node_modules/react-native/React/",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
|
@ -520,12 +633,17 @@
|
|||
02B29A2A1B7CF7C9008A7E6B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/examples/ReactExample/node_modules/react-native/React/",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
|
@ -636,7 +754,7 @@
|
|||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)";
|
||||
GCC_NO_COMMON_BLOCKS = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
REALM_HAVE_CONFIG,
|
||||
|
@ -650,7 +768,7 @@
|
|||
);
|
||||
INFOPLIST_FILE = src/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = core;
|
||||
OTHER_CPLUSPLUSFLAGS = (
|
||||
|
@ -674,7 +792,7 @@
|
|||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)";
|
||||
GCC_NO_COMMON_BLOCKS = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -682,7 +800,7 @@
|
|||
);
|
||||
INFOPLIST_FILE = src/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = core;
|
||||
OTHER_CPLUSPLUSFLAGS = (
|
||||
|
@ -710,6 +828,7 @@
|
|||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = tests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
|
@ -724,6 +843,7 @@
|
|||
build/iOS,
|
||||
);
|
||||
INFOPLIST_FILE = tests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
|
@ -788,7 +908,7 @@
|
|||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)";
|
||||
GCC_NO_COMMON_BLOCKS = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
REALM_HAVE_CONFIG,
|
||||
|
@ -802,7 +922,7 @@
|
|||
);
|
||||
INFOPLIST_FILE = src/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = core;
|
||||
OTHER_CPLUSPLUSFLAGS = (
|
||||
|
@ -830,6 +950,7 @@
|
|||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = tests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
|
||||
0270BCD21B7D095C00010E03 /* libRealmReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0270BCB31B7D04D700010E03 /* libRealmReact.a */; };
|
||||
027798491BBB2F1000C96559 /* ReactExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 027798481BBB2F1000C96559 /* ReactExampleTests.m */; };
|
||||
02A3C7A71BC4347100B1A7BE /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 02A3C7A61BC4347100B1A7BE /* libc++.tbd */; };
|
||||
02BB0BE51B9A06DC004D6DD2 /* RealmJS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0270BCAF1B7D04D700010E03 /* RealmJS.framework */; };
|
||||
02BB0BE61B9A06DC004D6DD2 /* RealmJS.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0270BCAF1B7D04D700010E03 /* RealmJS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
|
||||
|
@ -161,6 +162,7 @@
|
|||
027798461BBB2F1000C96559 /* ReactExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ReactExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
027798481BBB2F1000C96559 /* ReactExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReactExampleTests.m; sourceTree = "<group>"; };
|
||||
0277984A1BBB2F1000C96559 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
02A3C7A61BC4347100B1A7BE /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
|
||||
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
|
||||
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = "<group>"; };
|
||||
13B07F961A680F5B00A75B9A /* ReactExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ReactExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -187,6 +189,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
02A3C7A71BC4347100B1A7BE /* libc++.tbd in Frameworks */,
|
||||
0270BCD21B7D095C00010E03 /* libRealmReact.a in Frameworks */,
|
||||
146834051AC3E58100842450 /* libReact.a in Frameworks */,
|
||||
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
|
||||
|
@ -339,6 +342,7 @@
|
|||
83CBB9F61A601CBA00E9B192 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02A3C7A61BC4347100B1A7BE /* libc++.tbd */,
|
||||
13B07FAE1A68108700A75B9A /* ReactExample */,
|
||||
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
||||
027798471BBB2F1000C96559 /* ReactExampleTests */,
|
||||
|
@ -382,6 +386,7 @@
|
|||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ReactExample" */;
|
||||
buildPhases = (
|
||||
02A3C7C11BC4597900B1A7BE /* ShellScript */,
|
||||
13B07F871A680F5B00A75B9A /* Sources */,
|
||||
13B07F8C1A680F5B00A75B9A /* Frameworks */,
|
||||
13B07F8E1A680F5B00A75B9A /* Resources */,
|
||||
|
@ -591,6 +596,22 @@
|
|||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
02A3C7C11BC4597900B1A7BE /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "rm -rf node_modules/realm\nnpm install";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
027798421BBB2F1000C96559 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
|
@ -645,7 +666,7 @@
|
|||
ENABLE_TESTABILITY = YES;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = ReactExampleTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.realm.ReactExampleTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -661,7 +682,7 @@
|
|||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = ReactExampleTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.realm.ReactExampleTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -705,7 +726,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
|
@ -740,7 +761,7 @@
|
|||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/node_modules/react-native/React/**",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
|
@ -751,7 +772,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
|
@ -780,7 +801,7 @@
|
|||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
||||
"$(SRCROOT)/node_modules/react-native/React/**",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
if (typeof Realm != 'undefined') {
|
||||
module.exports = Realm; // eslint-disable-line no-undef
|
||||
} else {
|
||||
module.exports = require('./shim');
|
||||
module.exports = require('./realm');
|
||||
}
|
||||
|
|
10
lib/lists.js
10
lib/lists.js
|
@ -1,10 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
const rpc = require('./rpc');
|
||||
let rpc = require('./rpc');
|
||||
|
||||
const idKey = Symbol();
|
||||
const realmKey = Symbol();
|
||||
const prototype = {};
|
||||
let idKey = Symbol();
|
||||
let realmKey = Symbol();
|
||||
let prototype = {};
|
||||
|
||||
exports.create = create;
|
||||
|
||||
|
@ -15,7 +15,7 @@ exports.create = create;
|
|||
'unshift',
|
||||
'splice',
|
||||
].forEach(function(name, i) {
|
||||
const growthMethod = (i >= 2);
|
||||
let growthMethod = (i >= 2);
|
||||
|
||||
Object.defineProperty(prototype, name, {
|
||||
value: function() {
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
const rpc = require('./rpc');
|
||||
let rpc = require('./rpc');
|
||||
|
||||
const idKey = Symbol();
|
||||
const realmKey = Symbol();
|
||||
const schemaKey = Symbol();
|
||||
const registeredConstructors = {};
|
||||
let idKey = Symbol();
|
||||
let realmKey = Symbol();
|
||||
let schemaKey = Symbol();
|
||||
let registeredconstructors = {};
|
||||
|
||||
exports.create = create;
|
||||
exports.registerConstructors = registerConstructors;
|
||||
exports.registerconstructors = registerconstructors;
|
||||
|
||||
function create(realmId, info) {
|
||||
let schema = info.schema;
|
||||
let constructor = (registeredConstructors[realmId] || {})[schema.name];
|
||||
let constructor = (registeredconstructors[realmId] || {})[schema.name];
|
||||
let object = constructor ? Object.create(constructor.prototype) : {};
|
||||
let props = {};
|
||||
|
||||
|
@ -34,8 +34,8 @@ function create(realmId, info) {
|
|||
return object;
|
||||
}
|
||||
|
||||
function registerConstructors(realmId, constructors) {
|
||||
registeredConstructors[realmId] = constructors;
|
||||
function registerconstructors(realmId, constructors) {
|
||||
registeredconstructors[realmId] = constructors;
|
||||
}
|
||||
|
||||
function getterForProperty(name) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const lists = require('./lists');
|
||||
const objects = require('./objects');
|
||||
const rpc = require('./rpc');
|
||||
const types = require('./types');
|
||||
let lists = require('./lists');
|
||||
let objects = require('./objects');
|
||||
let rpc = require('./rpc');
|
||||
let types = require('./types');
|
||||
|
||||
const realmKey = Symbol();
|
||||
let realmKey = Symbol();
|
||||
|
||||
// TODO: DATA
|
||||
rpc.registerTypeConverter(types.DATE, (_, info) => new Date(info.value));
|
||||
|
@ -21,7 +21,7 @@ class Realm {
|
|||
let item = schema[i];
|
||||
let proto = item.prototype;
|
||||
|
||||
if (proto.schema) {
|
||||
if (proto && proto.schema) {
|
||||
schema.splice(i, 1, proto.schema);
|
||||
constructors[proto.schema.name] = item;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class Realm {
|
|||
|
||||
let realmId = this[realmKey] = rpc.createRealm(config);
|
||||
|
||||
objects.registerConstructors(realmId, constructors);
|
||||
objects.registerconstructors(realmId, constructors);
|
||||
}
|
||||
|
||||
addNotification(callback) {
|
|
@ -1,8 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
const DEVICE_HOST = 'localhost:8082';
|
||||
let DEVICE_HOST = 'localhost:8082';
|
||||
|
||||
const typeConverters = {};
|
||||
let typeConverters = {};
|
||||
|
||||
exports.registerTypeConverter = registerTypeConverter;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const types = {};
|
||||
let types = {};
|
||||
|
||||
[
|
||||
'BOOL',
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "RJSUtil.hpp"
|
||||
#include "object_accessor.hpp"
|
||||
|
||||
using RJSAccessor = realm::NativeAccessor<JSValueRef, JSContextRef>;
|
||||
using namespace realm;
|
||||
|
||||
size_t ObjectArray::size() {
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import "RJSUtil.hpp"
|
||||
#import "shared_realm.hpp"
|
||||
#import "object_accessor.hpp"
|
||||
|
||||
namespace realm {
|
||||
class Object;
|
||||
}
|
||||
|
||||
using RJSAccessor = realm::NativeAccessor<JSValueRef, JSContextRef>;
|
||||
|
||||
JSClassRef RJSObjectClass();
|
||||
JSObjectRef RJSObjectCreate(JSContextRef ctx, realm::Object object);
|
||||
|
||||
JSValueRef ObjectGetProperty(JSContextRef ctx, JSObjectRef jsObject, JSStringRef jsPropertyName, JSValueRef* exception);
|
||||
bool ObjectSetProperty(JSContextRef ctx, JSObjectRef jsObject, JSStringRef jsPropertyName, JSValueRef value, JSValueRef* exception);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#import "object_store.hpp"
|
||||
#import "object_accessor.hpp"
|
||||
|
||||
using RJSAccessor = realm::NativeAccessor<JSValueRef, JSContextRef>;
|
||||
using namespace realm;
|
||||
|
||||
JSValueRef ObjectGetProperty(JSContextRef ctx, JSObjectRef jsObject, JSStringRef jsPropertyName, JSValueRef* exception) {
|
||||
|
@ -69,7 +70,6 @@ JSValueRef ObjectGetProperty(JSContextRef ctx, JSObjectRef jsObject, JSStringRef
|
|||
auto arrayObjectSchema = obj->realm->config().schema->find(prop->object_type);
|
||||
return RJSArrayCreate(ctx, new ObjectArray(obj->realm, *arrayObjectSchema, static_cast<LinkViewRef>(obj->row.get_linklist(prop->table_column))));
|
||||
}
|
||||
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -25,3 +25,5 @@ JSClassRef RJSNotificationClass();
|
|||
std::string RJSDefaultPath();
|
||||
void RJSSetDefaultPath(std::string path);
|
||||
|
||||
JSObjectRef RealmConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* jsException);
|
||||
JSValueRef RealmCreateObject(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* jsException);
|
|
@ -26,3 +26,5 @@ namespace realm {
|
|||
JSClassRef RJSResultsClass();
|
||||
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, std::string className);
|
||||
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, std::string className, std::string query);
|
||||
|
||||
JSObjectRef RealmConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* jsException);
|
||||
|
|
Loading…
Reference in New Issue