|
@@ -1,18 +1,28 @@
|
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
|
|
// Autogenerated by cport.py on 2013-09-17 14:37
|
|
// Autogenerated by cport.py on 2013-09-17 14:37
|
|
|
-var Matcher2 = module.exports = function (docMatcher, constrainIndexKey){
|
|
|
|
|
|
|
+var Matcher2 = module.exports = function Matcher2(pattern, nested){
|
|
|
|
|
+ // File: matcher.cpp lines: 83-92
|
|
|
|
|
+ this._pattern = pattern;
|
|
|
|
|
+ var result = this.parser.parse(pattern);
|
|
|
|
|
+ if (result.code != ErrorCodes.OK)
|
|
|
|
|
+ return {code:16810, description:"bad query: " + result};
|
|
|
|
|
+ this._expression = result.result;
|
|
|
|
|
+
|
|
|
// File: matcher.cpp lines: 94-102
|
|
// File: matcher.cpp lines: 94-102
|
|
|
- var indexExpression = this.spliceForIndex(constrainIndexKey, docMatcher._expression.get(), this._spliceInfo);
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ var indexExpression = this.spliceForIndex(constrainIndexKey, docMatcher, this._spliceInfo);
|
|
|
if (indexExpression) {
|
|
if (indexExpression) {
|
|
|
- this._expression.reset(indexExpression);
|
|
|
|
|
|
|
+ this._expression = indexExpression;
|
|
|
}
|
|
}
|
|
|
-}, klass = Matcher2, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+}, klass = Matcher2, base = Object, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
|
|
// DEPENDENCIES
|
|
// DEPENDENCIES
|
|
|
var errors = require("../../Errors.js"),
|
|
var errors = require("../../Errors.js"),
|
|
|
ErrorCodes = errors.ErrorCodes,
|
|
ErrorCodes = errors.ErrorCodes,
|
|
|
MatchExpression = require("./MatchExpression.js"),
|
|
MatchExpression = require("./MatchExpression.js"),
|
|
|
|
|
+ MatchExpressionParser = require("./MatchExpressionParser.js"),
|
|
|
FalseMatchExpression = require("./FalseMatchExpression.js"),
|
|
FalseMatchExpression = require("./FalseMatchExpression.js"),
|
|
|
ComparisonMatchExpression = require("./ComparisonMatchExpression.js"),
|
|
ComparisonMatchExpression = require("./ComparisonMatchExpression.js"),
|
|
|
InMatchExpression = require("./InMatchExpression.js"),
|
|
InMatchExpression = require("./InMatchExpression.js"),
|
|
@@ -34,17 +44,7 @@ proto._pattern = undefined;
|
|
|
// File: matcher.h lines: 84-84
|
|
// File: matcher.h lines: 84-84
|
|
|
proto._spliceInfo = undefined;
|
|
proto._spliceInfo = undefined;
|
|
|
|
|
|
|
|
-// File: matcher.h lines: 82-82
|
|
|
|
|
-proto._expression = undefined;
|
|
|
|
|
-
|
|
|
|
|
-// File: matcher.h lines: 80-80
|
|
|
|
|
-proto._indexKey = undefined;
|
|
|
|
|
-
|
|
|
|
|
-// File: matcher.h lines: 79-79
|
|
|
|
|
-proto._pattern = undefined;
|
|
|
|
|
-
|
|
|
|
|
-// File: matcher.h lines: 84-84
|
|
|
|
|
-proto._spliceInfo = undefined;
|
|
|
|
|
|
|
+proto.parser = new MatchExpressionParser();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
@@ -56,7 +56,7 @@ proto._spliceInfo = undefined;
|
|
|
proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
|
// File: matcher.cpp lines: 236-380
|
|
// File: matcher.cpp lines: 236-380
|
|
|
var dup, i, obj, lme;
|
|
var dup, i, obj, lme;
|
|
|
- switch (full.matchType()) {
|
|
|
|
|
|
|
+ switch (full) {
|
|
|
case MatchExpression.ALWAYS_FALSE:
|
|
case MatchExpression.ALWAYS_FALSE:
|
|
|
return new FalseMatchExpression();
|
|
return new FalseMatchExpression();
|
|
|
|
|
|
|
@@ -273,10 +273,10 @@ proto.matches = function matches(doc, details){
|
|
|
if (!this._expression)
|
|
if (!this._expression)
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
|
- if (this._indexKey.isEmpty())
|
|
|
|
|
|
|
+ if (this._indexKey == {})
|
|
|
return this._expression.matchesBSON(doc, details);
|
|
return this._expression.matchesBSON(doc, details);
|
|
|
|
|
|
|
|
- if (!doc.isEmpty() && doc.firstElement().fieldName()[0])
|
|
|
|
|
|
|
+ if ((doc != {}) && (Object.keys(doc)[0]))
|
|
|
return this._expression.matchesBSON(doc, details);
|
|
return this._expression.matchesBSON(doc, details);
|
|
|
|
|
|
|
|
var mydoc = new IndexKeyMatchableDocument(this._indexKey, doc);
|
|
var mydoc = new IndexKeyMatchableDocument(this._indexKey, doc);
|