pr feedback

This commit is contained in:
Ari Lazier 2015-11-23 08:47:09 -08:00
parent ae5e4d82b8
commit 9ea8ab25c5
7 changed files with 48 additions and 19 deletions

3
.gitmodules vendored
View File

@ -1,9 +1,6 @@
[submodule "vendor/GCDWebServer"] [submodule "vendor/GCDWebServer"]
path = vendor/GCDWebServer path = vendor/GCDWebServer
url = https://github.com/swisspol/GCDWebServer.git url = https://github.com/swisspol/GCDWebServer.git
[submodule "PEGTL"]
path = PEGTL
url = https://github.com/ColinH/PEGTL.git
[submodule "vendor/PEGTL"] [submodule "vendor/PEGTL"]
path = vendor/PEGTL path = vendor/PEGTL
url = https://github.com/ColinH/PEGTL.git url = https://github.com/ColinH/PEGTL.git

View File

@ -65,7 +65,7 @@
02E9A9F11BFA84F100939F86 /* QueryTests.js in Resources */ = {isa = PBXBuildFile; fileRef = 02E9A9F01BFA84F100939F86 /* QueryTests.js */; }; 02E9A9F11BFA84F100939F86 /* QueryTests.js in Resources */ = {isa = PBXBuildFile; fileRef = 02E9A9F01BFA84F100939F86 /* QueryTests.js */; };
02EF76761BFFD41F000D5BAD /* queryTests.json in Resources */ = {isa = PBXBuildFile; fileRef = 02EF76751BFFD41F000D5BAD /* queryTests.json */; }; 02EF76761BFFD41F000D5BAD /* queryTests.json in Resources */ = {isa = PBXBuildFile; fileRef = 02EF76751BFFD41F000D5BAD /* queryTests.json */; };
02EF76861BFFDE37000D5BAD /* test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02EF76851BFFDE37000D5BAD /* test.cpp */; }; 02EF76861BFFDE37000D5BAD /* test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02EF76851BFFDE37000D5BAD /* test.cpp */; };
02EF76881BFFDE9E000D5BAD /* GrammerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 02EF76871BFFDE9E000D5BAD /* GrammerTests.mm */; }; 02EF76881BFFDE9E000D5BAD /* GrammarTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 02EF76871BFFDE9E000D5BAD /* GrammarTests.mm */; };
F636F6C81BCDB3570023F35C /* RealmReact.h in Headers */ = {isa = PBXBuildFile; fileRef = 0270BCCF1B7D067300010E03 /* RealmReact.h */; settings = {ATTRIBUTES = (Public, ); }; }; F636F6C81BCDB3570023F35C /* RealmReact.h in Headers */ = {isa = PBXBuildFile; fileRef = 0270BCCF1B7D067300010E03 /* RealmReact.h */; settings = {ATTRIBUTES = (Public, ); }; };
F64426C51BCDB1E200A81210 /* RealmJS.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CB11AE99CEC009B348C /* RealmJS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F64426C51BCDB1E200A81210 /* RealmJS.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02B58CB11AE99CEC009B348C /* RealmJS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F64E1EF11BC3510E00E0E150 /* util.js in Resources */ = {isa = PBXBuildFile; fileRef = F64E1EF01BC3510E00E0E150 /* util.js */; }; F64E1EF11BC3510E00E0E150 /* util.js in Resources */ = {isa = PBXBuildFile; fileRef = F64E1EF01BC3510E00E0E150 /* util.js */; };
@ -126,6 +126,20 @@
remoteGlobalIDString = 02B58CB01AE99CEC009B348C; remoteGlobalIDString = 02B58CB01AE99CEC009B348C;
remoteInfo = RealmJS; remoteInfo = RealmJS;
}; };
02D0F2A01C03775600B4FC45 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = E2DDD1C71BE698A8002CE867;
remoteInfo = "GCDWebServer (tvOS)";
};
02D0F2A21C03775600B4FC45 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = E2DDD18B1BE69404002CE867;
remoteInfo = "GCDWebServers (tvOS)";
};
02EE6D891BD87E310016A82E /* PBXContainerItemProxy */ = { 02EE6D891BD87E310016A82E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = 02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */; containerPortal = 02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */;
@ -228,7 +242,7 @@
02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactTests.xcodeproj; path = tests/ReactTests/ios/ReactTests.xcodeproj; sourceTree = "<group>"; }; 02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactTests.xcodeproj; path = tests/ReactTests/ios/ReactTests.xcodeproj; sourceTree = "<group>"; };
02EF76751BFFD41F000D5BAD /* queryTests.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = queryTests.json; path = "src/object-store/parser/queryTests.json"; sourceTree = SOURCE_ROOT; }; 02EF76751BFFD41F000D5BAD /* queryTests.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = queryTests.json; path = "src/object-store/parser/queryTests.json"; sourceTree = SOURCE_ROOT; };
02EF76851BFFDE37000D5BAD /* test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = test.cpp; path = "src/object-store/parser/test.cpp"; sourceTree = SOURCE_ROOT; }; 02EF76851BFFDE37000D5BAD /* test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = test.cpp; path = "src/object-store/parser/test.cpp"; sourceTree = SOURCE_ROOT; };
02EF76871BFFDE9E000D5BAD /* GrammerTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = GrammerTests.mm; path = tests/GrammerTests.mm; sourceTree = SOURCE_ROOT; }; 02EF76871BFFDE9E000D5BAD /* GrammarTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = GrammarTests.mm; path = tests/GrammarTests.mm; sourceTree = SOURCE_ROOT; };
F64E1EF01BC3510E00E0E150 /* util.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = util.js; path = tests/util.js; sourceTree = SOURCE_ROOT; }; F64E1EF01BC3510E00E0E150 /* util.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = util.js; path = tests/util.js; sourceTree = SOURCE_ROOT; };
F68A278A1BC2722A0063D40A /* RJSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RJSModuleLoader.h; path = tests/RJSModuleLoader.h; sourceTree = SOURCE_ROOT; }; F68A278A1BC2722A0063D40A /* RJSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RJSModuleLoader.h; path = tests/RJSModuleLoader.h; sourceTree = SOURCE_ROOT; };
F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RJSModuleLoader.m; path = tests/RJSModuleLoader.m; sourceTree = SOURCE_ROOT; }; F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RJSModuleLoader.m; path = tests/RJSModuleLoader.m; sourceTree = SOURCE_ROOT; };
@ -274,8 +288,10 @@
children = ( children = (
021CEA361BFD1BA000D69390 /* GCDWebServer */, 021CEA361BFD1BA000D69390 /* GCDWebServer */,
021CEA381BFD1BA000D69390 /* GCDWebServer.app */, 021CEA381BFD1BA000D69390 /* GCDWebServer.app */,
02D0F2A11C03775600B4FC45 /* GCDWebServer.app */,
021CEA3A1BFD1BA000D69390 /* GCDWebServers.framework */, 021CEA3A1BFD1BA000D69390 /* GCDWebServers.framework */,
021CEA3C1BFD1BA000D69390 /* GCDWebServers.framework */, 021CEA3C1BFD1BA000D69390 /* GCDWebServers.framework */,
02D0F2A31C03775600B4FC45 /* GCDWebServers.framework */,
021CEA3E1BFD1BA000D69390 /* Tests.xctest */, 021CEA3E1BFD1BA000D69390 /* Tests.xctest */,
); );
name = Products; name = Products;
@ -382,7 +398,7 @@
02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */, 02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */,
F68A278A1BC2722A0063D40A /* RJSModuleLoader.h */, F68A278A1BC2722A0063D40A /* RJSModuleLoader.h */,
F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */, F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */,
02EF76871BFFDE9E000D5BAD /* GrammerTests.mm */, 02EF76871BFFDE9E000D5BAD /* GrammarTests.mm */,
02EF76851BFFDE37000D5BAD /* test.cpp */, 02EF76851BFFDE37000D5BAD /* test.cpp */,
); );
path = RealmJSTests; path = RealmJSTests;
@ -604,6 +620,20 @@
remoteRef = 021CEA3D1BFD1BA000D69390 /* PBXContainerItemProxy */; remoteRef = 021CEA3D1BFD1BA000D69390 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR; sourceTree = BUILT_PRODUCTS_DIR;
}; };
02D0F2A11C03775600B4FC45 /* GCDWebServer.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = GCDWebServer.app;
remoteRef = 02D0F2A01C03775600B4FC45 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
02D0F2A31C03775600B4FC45 /* GCDWebServers.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = GCDWebServers.framework;
remoteRef = 02D0F2A21C03775600B4FC45 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
02EE6D8A1BD87E310016A82E /* ReactTests.app */ = { 02EE6D8A1BD87E310016A82E /* ReactTests.app */ = {
isa = PBXReferenceProxy; isa = PBXReferenceProxy;
fileType = wrapper.application; fileType = wrapper.application;
@ -706,7 +736,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
F68A278C1BC2722A0063D40A /* RJSModuleLoader.m in Sources */, F68A278C1BC2722A0063D40A /* RJSModuleLoader.m in Sources */,
02EF76881BFFDE9E000D5BAD /* GrammerTests.mm in Sources */, 02EF76881BFFDE9E000D5BAD /* GrammarTests.mm in Sources */,
02EF76861BFFDE37000D5BAD /* test.cpp in Sources */, 02EF76861BFFDE37000D5BAD /* test.cpp in Sources */,
0270BC821B7D020100010E03 /* RealmJSTests.mm in Sources */, 0270BC821B7D020100010E03 /* RealmJSTests.mm in Sources */,
02409DC21BCF11D6005F3B3E /* RealmJSCoreTests.m in Sources */, 02409DC21BCF11D6005F3B3E /* RealmJSCoreTests.m in Sources */,

View File

@ -269,7 +269,7 @@ JSValueRef RealmObjects(JSContextRef ctx, JSObjectRef function, JSObjectRef this
else { else {
std::string query = RJSValidatedStringForValue(ctx, arguments[1], "predicate"); std::string query = RJSValidatedStringForValue(ctx, arguments[1], "predicate");
std::vector<JSValueRef> args; std::vector<JSValueRef> args;
for (size_t i =2; i < argumentCount; i++) { for (size_t i = 2; i < argumentCount; i++) {
args.push_back(arguments[i]); args.push_back(arguments[i]);
} }
return RJSResultsCreate(ctx, sharedRealm, className, query, args); return RJSResultsCreate(ctx, sharedRealm, className, query, args);

View File

@ -151,7 +151,7 @@ template<> struct action< and_ext >
// if we were put into an OR group we need to rearrange // if we were put into an OR group we need to rearrange
auto &current = state.current(); auto &current = state.current();
if (current.type == Predicate::Type::Or) { if (current.type == Predicate::Type::Or) {
auto &sub_preds = state.current().cpnd.sub_predicates; auto &sub_preds = current.cpnd.sub_predicates;
auto &second_last = sub_preds[sub_preds.size()-2]; auto &second_last = sub_preds[sub_preds.size()-2];
if (second_last.type == Predicate::Type::And) { if (second_last.type == Predicate::Type::And) {
// if we are in an OR group and second to last predicate group is // if we are in an OR group and second to last predicate group is
@ -320,7 +320,7 @@ Predicate parse(const std::string &query)
return std::move(out_predicate); return std::move(out_predicate);
} }
void analyzeGrammer() void analyzeGrammar()
{ {
analyze<pred>(); analyze<pred>();
} }

View File

@ -36,7 +36,8 @@ namespace realm {
struct Predicate struct Predicate
{ {
enum class Type { enum class Type
{
Comparison, Comparison,
Or, Or,
And, And,
@ -44,7 +45,8 @@ namespace realm {
False False
} type = Type::And; } type = Type::And;
enum class Operator { enum class Operator
{
None, None,
Equal, Equal,
NotEqual, NotEqual,
@ -57,13 +59,15 @@ namespace realm {
Contains Contains
}; };
struct Comparison { struct Comparison
{
Operator op = Operator::None; Operator op = Operator::None;
Expression expr[2]; Expression expr[2];
~Comparison() {} ~Comparison() {}
}; };
struct Compound { struct Compound
{
std::vector<Predicate> sub_predicates; std::vector<Predicate> sub_predicates;
}; };
@ -77,7 +81,7 @@ namespace realm {
Predicate parse(const std::string &query); Predicate parse(const std::string &query);
void analyzeGrammer(); void analyzeGrammar();
bool testGrammer(); bool testGrammer();
} }
} }

View File

@ -12,8 +12,8 @@
@implementation GrammerTests @implementation GrammerTests
- (void)testGrammer { - (void)testGrammer {
realm::parser::analyzeGrammer(); realm::parser::analyzeGrammar();
XCTAssertTrue(realm::parser::testGrammer()); XCTAssertTrue(realm::parser::testGrammar());
} }
@end @end

View File

@ -62,5 +62,3 @@
} }
@end @end