Browse Source

ref #3253: Fill out several stubs

Brennan Chesley 12 years ago
parent
commit
269c2927e2

+ 1 - 1
lib/pipeline/matcher/AllElemMatchOp.js

@@ -180,7 +180,7 @@ proto.matches = function matches( doc,details ) { //  const MatchableDocument* d
 proto.matchesSingleElement = function matchesSingleElement( e ){ //  const BSONElement& e
 
 // File: expression_array.cpp lines: 201-205
-	if ( e.type() != 'Array' ) {
+	if ( e instanceof 'Array' ) {
 		return false;
 	}
 	return this._allMatch(e.Obj());

+ 71 - 188
lib/pipeline/matcher/ArrayFilterEntries.js

@@ -1,10 +1,11 @@
-"use strict"
-
+"use strict";
 
+Value = require('../Value');
 
 // Autogenerated by cport.py on 2013-09-17 14:37
 var ArrayFilterEntries = module.exports = function (){
-
+	this._hasNull = false;
+	this._hasEmptyArray = false;
 }, klass = ArrayFilterEntries, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 
@@ -32,86 +33,35 @@ proto._hasNull = undefined;
 proto._regexes = undefined;
 
 
-// File: expression_leaf.h lines: 266-266
-//         BSONElementSet _equalities;
-
-proto._equalities = undefined;
-
-
-// File: expression_leaf.h lines: 265-265
-//         bool _hasEmptyArray;
-
-proto._hasEmptyArray = undefined;
-
-
-// File: expression_leaf.h lines: 264-264
-//         bool _hasNull; // if _equalities has a jstNULL element in it
-
-proto._hasNull = undefined;
-
-
-// File: expression_leaf.h lines: 267-267
-//         std::vector<RegexMatchExpression*> _regexes;
-
-proto._regexes = undefined;
-
-
-
-
-
 /**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method ArrayFilterEntries
- * @param
+ *  addEquality
  *
- */
-proto.ArrayFilterEntries = function ArrayFilterEntries( /*  */ ){
-
-// File: expression_leaf.cpp lines: 358-360
-//     ArrayFilterEntries::ArrayFilterEntries(){
-//         _hasNull = false;
-//         _hasEmptyArray = false;
-//     }
-
-
-
-}
-
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
  * @method addEquality
- * @param
+ *
  *
  */
-proto.addEquality = function addEquality( /*  const BSONElement& e  */ ){
-
-// File: expression_leaf.cpp lines: 369-386
-//     Status ArrayFilterEntries::addEquality( const BSONElement& e ) {
-//         if ( e.isABSONObj() ) {
-//             if ( e.Obj().firstElement().fieldName()[0] == '$' )
-//                 return Status( ErrorCodes::BadValue, "cannot next $ under $in" );
-//         }
-// 
-//         if ( e.type() == RegEx )
-//             return Status( ErrorCodes::BadValue, "ArrayFilterEntries equality cannot be a regex" );
-// 
-//         if ( e.type() == jstNULL ) {
-//             _hasNull = true;
-//         }
-// 
-//         if ( e.type() == Array && e.Obj().isEmpty() )
-//             _hasEmptyArray = true;
-// 
-//         _equalities.insert( e );
-//         return Status::OK();
-//     }
-
-
-
-}
+proto.addEquality = function addEquality( e ) {
+	//File expression_leaf.cpp lines 369-387
+	
+	if(Object.keys(e)[0][0] === '$'){
+		return {'code':'BAD_VALUE', 'desc':'cannot next $ under $in'};
+	}
+
+	if( e instanceof RegExp ) {
+		return {'code': 'BAD_VALUE', 'desc':'ArrayFilterEntries equality cannot be a regex'};
+	}
+
+	if( e === null ) {
+		this._hasNull = true;
+	}
+
+	if (e instanceof Array && e.length === 0) {
+		this._hasEmptyArray = true;
+	}
+	
+	this._equalities.insert( e );
+	return {'code':'OK'};
+};
 
 
 /**
@@ -121,17 +71,11 @@ proto.addEquality = function addEquality( /*  const BSONElement& e  */ ){
  * @param
  *
  */
-proto.addRegex = function addRegex( /*  RegexMatchExpression* expr  */ ){
-
+proto.addRegex = function addRegex( expr ) { //  RegexMatchExpression* expr
 // File: expression_leaf.cpp lines: 389-391
-//     Status ArrayFilterEntries::addRegex( RegexMatchExpression* expr ) {
-//         _regexes.push_back( expr );
-//         return Status::OK();
-//     }
-
-
-
-}
+	this._regexes.append( expr );
+	return {'code':'OK'};
+};
 
 
 /**
@@ -141,14 +85,15 @@ proto.addRegex = function addRegex( /*  RegexMatchExpression* expr  */ ){
  * @param
  *
  */
-proto.contains = function contains( /*  const BSONElement& elem  */ ){
+proto.contains = function contains( elem ) { //  const BSONElement& elem
 // File: expression_leaf.h lines: 249-248
-//         bool contains( const BSONElement& elem ) const { return _equalities.count(elem) > 0; }
-
-
-
-
-}
+	for (var i = 0; i < this._equalities.length; i++) {
+		if( Value.compare(elem, this._equalities[i])) {
+			return true;
+		}
+	}
+	return false;
+};
 
 
 /**
@@ -158,20 +103,13 @@ proto.contains = function contains( /*  const BSONElement& elem  */ ){
  * @param
  *
  */
-proto.copyTo = function copyTo( /*  ArrayFilterEntries& toFillIn  */ ){
-
+proto.copyTo = function copyTo( toFillIn ) { //  ArrayFilterEntries& toFillIn
 // File: expression_leaf.cpp lines: 407-412
-//     void ArrayFilterEntries::copyTo( ArrayFilterEntries& toFillIn ) const {
-//         toFillIn._hasNull = _hasNull;
-//         toFillIn._hasEmptyArray = _hasEmptyArray;
-//         toFillIn._equalities = _equalities;
-//         for ( unsigned i = 0; i < _regexes.size(); i++ )
-//             toFillIn._regexes.push_back( static_cast<RegexMatchExpression*>(_regexes[i]->shallowClone()) );
-//     }
-
-
-
-}
+	toFillIn._hasNull = this._hasNull;
+	toFillIn._hasEmptyArray = this._hasEmptyArray;
+	toFillIn._equalities = this._equalities;
+	toFillIn._regexes = this._regexes.slice(0); // Copy array
+};
 
 
 /**
@@ -183,12 +121,8 @@ proto.copyTo = function copyTo( /*  ArrayFilterEntries& toFillIn  */ ){
  */
 proto.equalities = function equalities( /*  */ ){
 // File: expression_leaf.h lines: 248-247
-//         const BSONElementSet& equalities() const { return _equalities; }
-
-
-
-
-}
+	return this._equalities;
+};
 
 
 /**
@@ -198,25 +132,18 @@ proto.equalities = function equalities( /*  */ ){
  * @param
  *
  */
-proto.equivalent = function equivalent( /*  const ArrayFilterEntries& other  */ ){
-
+proto.equivalent = function equivalent( other ) { //  const ArrayFilterEntries& other
 // File: expression_leaf.cpp lines: 394-404
-//     bool ArrayFilterEntries::equivalent( const ArrayFilterEntries& other ) const {
-//         if ( _hasNull != other._hasNull )
-//             return false;
-// 
-//         if ( _regexes.size() != other._regexes.size() )
-//             return false;
-//         for ( unsigned i = 0; i < _regexes.size(); i++ )
-//             if ( !_regexes[i]->equivalent( other._regexes[i] ) )
-//                 return false;
-// 
-//         return _equalities == other._equalities;
-//     }
-
+	if (this._hasNull != other._hasNull) {return false;}
+	if (this._regexes.length != other._regexes.length) {return false;}
 
-
-}
+	for (var i = 0; i < this._regexes.length; i++) {
+		if ( !this._regexes[i].equivalent( other._regexes[i] ) ) {
+			return false;
+		}
+	}
+	return Value.compare(this._equalities, other._equalities);
+};
 
 
 /**
@@ -228,12 +155,8 @@ proto.equivalent = function equivalent( /*  const ArrayFilterEntries& other  */
  */
 proto.hasEmptyArray = function hasEmptyArray( /*  */ ){
 // File: expression_leaf.h lines: 256-255
-//         bool hasEmptyArray() const { return _hasEmptyArray; }
-
-
-
-
-}
+	return this._hasEmptyArray;
+};
 
 
 /**
@@ -245,12 +168,8 @@ proto.hasEmptyArray = function hasEmptyArray( /*  */ ){
  */
 proto.hasNull = function hasNull( /*  */ ){
 // File: expression_leaf.h lines: 254-253
-//         bool hasNull() const { return _hasNull; }
-
-
-
-
-}
+	return this._hasNull;
+};
 
 
 /**
@@ -262,12 +181,8 @@ proto.hasNull = function hasNull( /*  */ ){
  */
 proto.numRegexes = function numRegexes( /*  */ ){
 // File: expression_leaf.h lines: 251-250
-//         size_t numRegexes() const { return _regexes.size(); }
-
-
-
-
-}
+	return this._regexes.length;
+};
 
 
 /**
@@ -277,14 +192,10 @@ proto.numRegexes = function numRegexes( /*  */ ){
  * @param
  *
  */
-proto.regex = function regex( /*  int idx  */ ){
+proto.regex = function regex( idx ) { //  int idx
 // File: expression_leaf.h lines: 252-251
-//         RegexMatchExpression* regex( int idx ) const { return _regexes[idx]; }
-
-
-
-
-}
+	return this._regexes[idx];
+};
 
 
 /**
@@ -296,12 +207,8 @@ proto.regex = function regex( /*  int idx  */ ){
  */
 proto.singleNull = function singleNull( /*  */ ){
 // File: expression_leaf.h lines: 255-254
-//         bool singleNull() const { return size() == 1 && _hasNull; }
-
-
-
-
-}
+	return this.size() == 1 && _hasNull;
+};
 
 
 /**
@@ -313,30 +220,6 @@ proto.singleNull = function singleNull( /*  */ ){
  */
 proto.size = function size( /*  */ ){
 // File: expression_leaf.h lines: 257-256
-//         int size() const { return _equalities.size() + _regexes.size(); }
-
-
-
-
-}
-
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method ~ArrayFilterEntries
- * @param
- *
- */
-proto.~ArrayFilterEntries = function ~ArrayFilterEntries( /*  */ ){
-
-// File: expression_leaf.cpp lines: 363-366
-//     ArrayFilterEntries::~ArrayFilterEntries() {
-//         for ( unsigned i = 0; i < _regexes.size(); i++ )
-//             delete _regexes[i];
-//         _regexes.clear();
-//     }
-
-
+	return this._equalities.length + this._regexes.length;
+};
 
-}

+ 18 - 69
lib/pipeline/matcher/AtomicMatchExpression.js

@@ -1,32 +1,11 @@
 "use strict"
 
-
+MatchExpression = require('MatchExpression');
 
 // Autogenerated by cport.py on 2013-09-17 14:37
-var AtomicMatchExpression = module.exports = function (){
-
-}, klass = AtomicMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
-
-
-
-
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method AtomicMatchExpression
- * @param
- *
- */
-proto.AtomicMatchExpression = function AtomicMatchExpression( /*  ATOMIC  */ ){
-// File: expression.h lines: 182-181
-//         AtomicMatchExpression() : MatchExpression( ATOMIC ){}
-
-
-
-
-}
-
+var AtomicMatchExpression = module.exports = function AtomicMatchExpression(){
+	this._matchType = 'ATOMIC';
+}, klass = AtomicMatchExpression, base =  MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 /**
  * 
@@ -35,17 +14,11 @@ proto.AtomicMatchExpression = function AtomicMatchExpression( /*  ATOMIC  */ ){
  * @param
  *
  */
-proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
-
+proto.debugString = function debugString( level ) { //  StringBuilder& debug, int level
 // File: expression.cpp lines: 48-50
-//     void AtomicMatchExpression::debugString( StringBuilder& debug, int level ) const {
-//         _debugAddSpace( debug, level );
-//         debug << "$atomic\n";
-//     }
+	return this._debugAddSpace( level ) + "$atomic\n";
 
-
-
-}
+};
 
 
 /**
@@ -55,16 +28,10 @@ proto.debugString = function debugString( /*  StringBuilder& debug, int level  *
  * @param
  *
  */
-proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+proto.equivalent = function equivalent( other ) { //  const MatchExpression* other
 // File: expression.h lines: 198-199
-//         virtual bool equivalent( const MatchExpression* other ) const {
-//             return other->matchType() == ATOMIC;
-//         }
-
-
-
-
-}
+	return other._matchType == 'ATOMIC';
+};
 
 
 /**
@@ -74,16 +41,10 @@ proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
  * @param
  *
  */
-proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details = 0  */ ){
+proto.matches = function matches( doc ) { //  const MatchableDocument* doc, MatchDetails* details = 0
 // File: expression.h lines: 184-185
-//         virtual bool matches( const MatchableDocument* doc, MatchDetails* details = 0 ) const {
-//             return true;
-//         }
-
-
-
-
-}
+	return true;
+};
 
 
 /**
@@ -93,16 +54,10 @@ proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails
  * @param
  *
  */
-proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+proto.matchesSingleElement = function matchesSingleElement( e ) { //  const BSONElement& e
 // File: expression.h lines: 188-189
-//         virtual bool matchesSingleElement( const BSONElement& e ) const {
-//             return true;
-//         }
-
-
-
-
-}
+	return true;
+};
 
 
 /**
@@ -114,11 +69,5 @@ proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElemen
  */
 proto.shallowClone = function shallowClone( /*  */ ){
 // File: expression.h lines: 192-193
-//         virtual MatchExpression* shallowClone() const {
-//             return new AtomicMatchExpression();
-//         }
-
-
-
-
-}
+	return new AtomicMatchExpression();	
+};

+ 95 - 169
lib/pipeline/matcher/ComparisonMatchExpression.js

@@ -1,17 +1,12 @@
-"use strict"
-
+"use strict";
 
+LeafMatchExpression = require('LeafMatchExpression');
+Value = require('../Value');
 
 // Autogenerated by cport.py on 2013-09-17 14:37
-var ComparisonMatchExpression = module.exports = function (){
-
-}, klass = ComparisonMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
-
-
-// File: expression_leaf.h lines: 88-88
-//         BSONElement _rhs;
-
-proto._rhs = undefined;
+var ComparisonMatchExpression = module.exports = function ComparisonMatchExpression( type ){
+	this._matchType = type;
+}, klass = ComparisonMatchExpression, base =  LeafMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 
 // File: expression_leaf.h lines: 88-88
@@ -19,27 +14,6 @@ proto._rhs = undefined;
 
 proto._rhs = undefined;
 
-
-
-
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method ComparisonMatchExpression
- * @param
- *
- */
-proto.ComparisonMatchExpression = function ComparisonMatchExpression( /*  MatchType type  */ ){
-// File: expression_leaf.h lines: 71-70
-//         ComparisonMatchExpression( MatchType type ) : LeafMatchExpression( type ){}
-
-
-
-
-}
-
-
 /**
  * 
  * This documentation was automatically generated. Please update when you touch this function.
@@ -48,33 +22,35 @@ proto.ComparisonMatchExpression = function ComparisonMatchExpression( /*  MatchT
  *
  */
 proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
-
 // File: expression_leaf.cpp lines: 135-154
-//     void ComparisonMatchExpression::debugString( StringBuilder& debug, int level ) const {
-//         _debugAddSpace( debug, level );
-//         debug << path() << " ";
-//         switch ( matchType() ) {
-//         case LT: debug << "$lt"; break;
-//         case LTE: debug << "$lte"; break;
-//         case EQ: debug << "=="; break;
-//         case GT: debug << "$gt"; break;
-//         case GTE: debug << "$gte"; break;
-//         default: debug << " UNKNOWN - should be impossible"; break;
-//         }
-//         debug << " " << _rhs.toString( false );
-// 
-//         MatchExpression::TagData* td = getTag();
-//         if (NULL != td) {
-//             debug << " ";
-//             td->debugString(&debug);
-//         }
-// 
-//         debug << "\n";
-//     }
-
-
-
-}
+	var retStr = this._debugAddSpace( level ) + this.path() + " ";
+	switch (this._matchType){
+		case 'LT':
+			retStr += '$lt';
+			break;
+		case 'LTE':
+			retStr += '$lte';
+			break;
+		case 'EQ':
+			retStr += '==';
+			break;
+		case 'GT':
+			retStr += '$gt';
+			break;
+		case 'GTE':
+			retStr += '$gte';
+			break;
+		default:
+			retStr += "Unknown comparison!";
+			break;
+	}
+
+	retStr += this._rhs.toString();
+	if (this.getTag() !== null ) {
+		retStr += this.getTag().debugString();
+	}
+	return retStr + '\n';
+};
 
 
 /**
@@ -84,8 +60,7 @@ proto.debugString = function debugString( /*  StringBuilder& debug, int level  *
  * @param
  *
  */
-proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
-
+proto.equivalent = function equivalent( other ) {//  const MatchExpression* other
 // File: expression_leaf.cpp lines: 53-61
 //     bool ComparisonMatchExpression::equivalent( const MatchExpression* other ) const {
 //         if ( other->matchType() != matchType() )
@@ -97,10 +72,11 @@ proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
 //             path() == realOther->path() &&
 //             _rhs.valuesEqual( realOther->_rhs );
 //     }
+	if (other._matchType != this._matchType) { return false; }
+	
+	return this.path() == other.path() && Values.compare(this._rhs,other._rhs);
 
-
-
-}
+};
 
 
 /**
@@ -112,12 +88,8 @@ proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
  */
 proto.getData = function getData( /*  */ ){
 // File: expression_leaf.h lines: 85-84
-//         const BSONElement& getData() const { return _rhs; }
-
-
-
-
-}
+	return this._rhs;
+};
 
 
 /**
@@ -129,12 +101,8 @@ proto.getData = function getData( /*  */ ){
  */
 proto.getRHS = function getRHS( /*  */ ){
 // File: expression_leaf.h lines: 79-78
-//         virtual const BSONElement& getRHS() const { return _rhs; }
-
-
-
-
-}
+	return this._rhs;
+};
 
 
 /**
@@ -144,37 +112,18 @@ proto.getRHS = function getRHS( /*  */ ){
  * @param
  *
  */
-proto.init = function init( /*  const StringData& path, const BSONElement& rhs  */ ){
-
+proto.init = function init( path,rhs ) { //  const StringData& path, const BSONElement& rhs
 // File: expression_leaf.cpp lines: 65-87
-//     Status ComparisonMatchExpression::init( const StringData& path, const BSONElement& rhs ) {
-//         _rhs = rhs;
-// 
-//         if ( rhs.eoo() ) {
-//             return Status( ErrorCodes::BadValue, "need a real operand" );
-//         }
-// 
-//         if ( rhs.type() == Undefined ) {
-//             return Status( ErrorCodes::BadValue, "cannot compare to undefined" );
-//         }
-// 
-//         switch ( matchType() ) {
-//         case LT:
-//         case LTE:
-//         case EQ:
-//         case GT:
-//         case GTE:
-//             break;
-//         default:
-//             return Status( ErrorCodes::BadValue, "bad match type for ComparisonMatchExpression" );
-//         }
-// 
-//         return initPath( path );
-//     }
-
+	this._rhs = rhs;
+	if ( rhs === {}) { return {'code':'BAD_VALUE', 'desc':'Need a real operand'};}
 
+	if ( rhs === undefined ) { return {'code':'BAD_VALUE', 'desc':'Cannot compare to undefined'};}
 
-}
+	if (!(this._matchType in {"LT":1, "LTE":1, "EQ":1, "GT":1, "GTE":1})) {
+		return {'code':'BAD_VALUE', 'desc':'Bad match type for ComparisonMatchExpression'};
+	}
+	return this.initPath( path );
+};
 
 
 /**
@@ -184,70 +133,47 @@ proto.init = function init( /*  const StringData& path, const BSONElement& rhs
  * @param
  *
  */
-proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
-
-// File: expression_leaf.cpp lines: 91-132
-//     bool ComparisonMatchExpression::matchesSingleElement( const BSONElement& e ) const {
-//         //log() << "\t ComparisonMatchExpression e: " << e << " _rhs: " << _rhs << "\n"
-//         //<< toString() << std::endl;
-// 
-//         if ( e.canonicalType() != _rhs.canonicalType() ) {
-//             // some special cases
-//             //  jstNULL and undefined are treated the same
-//             if ( e.canonicalType() + _rhs.canonicalType() == 5 ) {
-//                 return matchType() == EQ || matchType() == LTE || matchType() == GTE;
-//             }
-// 
-//             if ( _rhs.type() == MaxKey || _rhs.type() == MinKey ) {
-//                 return matchType() != EQ;
-//             }
-// 
-//             return false;
-//         }
-// 
-//         if ( _rhs.type() == Array ) {
-//             if ( matchType() != EQ ) {
-//                 return false;
-//             }
-//         }
-// 
-//         int x = compareElementValues( e, _rhs );
-// 
-//         //log() << "\t\t" << x << endl;
-// 
-//         switch ( matchType() ) {
-//         case LT:
-//             return x < 0;
-//         case LTE:
-//             return x <= 0;
-//         case EQ:
-//             return x == 0;
-//         case GT:
-//             return x > 0;
-//         case GTE:
-//             return x >= 0;
-//         default:
-//             fassertFailed( 16828 );
-//         }
-//     }
-
-
-
-}
-
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method ~ComparisonMatchExpression
- * @param
- *
- */
-proto.~ComparisonMatchExpression = function ~ComparisonMatchExpression( /*  */ ){
-// File: expression_leaf.h lines: 75-74
-//         virtual ~ComparisonMatchExpression(){}
-
-
-
+proto.matchesSingleElement = function matchesSingleElement( e ){ //  const BSONElement& e
+// File: expression_leaf.cpp lines: 91-132	
+	if( typeof(e) != typeof(this._rhs) ){
+		if ((e === null || e === undefined) && (this._rhs ===null || this._rhs === undefined)) {
+			return ["EQ","LTE","GTE"].indexOf(this._matchType) != -1;
+		}
+	
+		if (this._rhs instanceof MaxKey || this._rhs instanceof MinKey) {
+			return this._matchType != "EQ";
+		}
+		return false;
+	}
+
+	if( this._rhs instanceof Array) {
+		if( this._matchType != 'EQ') {
+			return false;
+		}
+	}
+	
+	var x = Value.compare( e, this._rhs );
+	
+	switch( this._matchType ) {
+		case "LT":
+			return x == -1;
+			break;
+		case "LTE":
+			return x <= 0;
+			break;
+		case "EQ":
+			return x === 0;
+			break;
+		case "GT":
+			return x == 1;
+			break;
+		case "GTE":
+			return x >= 0;
+			break;
+		default:
+			throw new Error("Invalid comparison type evaluated.");
+			break;
+	}
+	return false;
+};
 
-}

+ 1 - 1
lib/pipeline/matcher/Context.js

@@ -93,7 +93,7 @@ proto.outerArray = function outerArray( ){
  */
 proto.reset = function reset( ){
 // File: path.cpp lines: 37-38
-	this._element = new BSONElement();
+	this._element = {};
 };
 
 

+ 13 - 21
lib/pipeline/matcher/ElementPath.js

@@ -1,7 +1,6 @@
 "use strict";
 
 FieldRef = require('FieldRef');
-BSONElement = require('BSONElement');
 
 // Autogenerated by cport.py on 2013-09-17 14:37
 var ElementPath = module.exports = function (){
@@ -52,27 +51,20 @@ klass.getFieldDottedOrArray = function getFieldDottedOrArray(doc, path, idxPathO
 	    partNum = 0;
 	while (partNum < path.numParts() && !stop) {
 		res = curr.getField( path.getPart( partNum) );
-		switch (res.type() ) {
-			case 'EOO':
-				stop = true;
-				break;
-
-			case 'Object':
-				curr = res.Obj();
-				partNum++;
-				break;
-
-			case 'Array':
-				stop = true;
-				break;
-
-			default:
-				if (partNum + 1 < path.numParts() ) {
-					res = new BSONELEMENT();
-				}
-				stope = true;
-				break;
+		if(res instanceof EOO){
+			stop = true;
+		} else if (res instanceof Object) {
+			curr = res;
+			partNum++;
+		} else if (res instanceof Array) {
+			stop = true;
+		} else {
+			if (partNum + 1 < path.numParts() ) {
+				res = {};
+			}
+			stope = true;
 		}
+		
 	}
 
 	idxPath.pathID = partNum;

+ 0 - 17
lib/pipeline/matcher/MatchExpression.js

@@ -210,20 +210,3 @@ proto.toString = function toString( /*  */ ){
 	return this.debugString();
 };
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 26 - 90
lib/pipeline/matcher/OrMatchExpression.js

@@ -1,32 +1,11 @@
 "use strict";
 
-
+ListOfMatchExpression = require('ListOfMatchExpression');
 
 // Autogenerated by cport.py on 2013-09-17 14:37
 var OrMatchExpression = module.exports = function OrMatchExpression (){
-
-}, klass = OrMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
-
-
-
-
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method OrMatchExpression
- * @param
- *
- */
-proto.OrMatchExpression = function OrMatchExpression( /*  OR  */ ){
-// File: expression_tree.h lines: 80-79
-//         OrMatchExpression() : ListOfMatchExpression( OR ){}
-
-
-
-
-}
-
+	this._matchType = 'OR';
+}, klass = OrMatchExpression, base = ListOfMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 /**
  * 
@@ -35,18 +14,10 @@ proto.OrMatchExpression = function OrMatchExpression( /*  OR  */ ){
  * @param
  *
  */
-proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
-
+proto.debugString = function debugString( level ) { //  StringBuilder& debug, int level
 // File: expression_tree.cpp lines: 112-115
-//     void OrMatchExpression::debugString( StringBuilder& debug, int level ) const {
-//         _debugAddSpace( debug, level );
-//         debug << "$or\n";
-//         _debugList( debug, level );
-//     }
-
-
-
-}
+	return this._debugAddSpace( level ) + "$or\n" + this._debugList( level );
+};
 
 
 /**
@@ -56,21 +27,14 @@ proto.debugString = function debugString( /*  StringBuilder& debug, int level  *
  * @param
  *
  */
-proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
-
+proto.matches = function matches( doc,details ) { //  const MatchableDocument* doc, MatchDetails* details
 // File: expression_tree.cpp lines: 93-99
-//     bool OrMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
-//         for ( size_t i = 0; i < numChildren(); i++ ) {
-//             if ( getChild(i)->matches( doc, NULL ) ) {
-//                 return true;
-//             }
-//         }
-//         return false;
-//     }
-
-
-
-}
+	for (var i = 0; i < this.numChildren(); i++) {
+		if (this.getChild(i).matches( doc, null ) ){
+			return true;
+		}
+	}	
+};
 
 
 /**
@@ -80,21 +44,15 @@ proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails
  * @param
  *
  */
-proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
-
+proto.matchesSingleElement = function matchesSingleElement( e ) { //  const BSONElement& e
 // File: expression_tree.cpp lines: 102-108
-//     bool OrMatchExpression::matchesSingleElement( const BSONElement& e ) const {
-//         for ( size_t i = 0; i < numChildren(); i++ ) {
-//             if ( getChild(i)->matchesSingleElement( e ) ) {
-//                 return true;
-//             }
-//         }
-//         return false;
-//     }
-
-
-
-}
+	for (var i = 0; i < this.numChildren(); i++) {
+		if( this.getChild(i).matchesSingleElement(e) ) {
+			return true;
+		}
+	}
+	return false;
+};
 
 
 /**
@@ -106,32 +64,10 @@ proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElemen
  */
 proto.shallowClone = function shallowClone( /*  */ ){
 // File: expression_tree.h lines: 86-91
-//         virtual MatchExpression* shallowClone() const {
-//             OrMatchExpression* self = new OrMatchExpression();
-//             for (size_t i = 0; i < numChildren(); ++i) {
-//                 self->add(getChild(i)->shallowClone());
-//             }
-//             return self;
-//         }
-
-
-
-
+	clone = new OrMatchExpression();
+	for (var i = 0; i < this.numChildren(); i++) {
+		clone.add(this.getChild(i).shallowClone());
+	}
+	return clone;
 }
 
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method ~OrMatchExpression
- * @param
- *
- */
-proto.~OrMatchExpression = function ~OrMatchExpression( /*  */ ){
-// File: expression_tree.h lines: 81-80
-//         virtual ~OrMatchExpression(){}
-
-
-
-
-}