Browse Source

ref #3174: Initial Javascript skeletons

Brennan Chesley 12 years ago
parent
commit
21084bd269
42 changed files with 7709 additions and 0 deletions
  1. 333 0
      lib/pipeline/matcher/AllElemMatchOp.js
  2. 139 0
      lib/pipeline/matcher/AndMatchExpression.js
  3. 342 0
      lib/pipeline/matcher/ArrayFilterEntries.js
  4. 200 0
      lib/pipeline/matcher/ArrayMatchingMatchExpression.js
  5. 124 0
      lib/pipeline/matcher/AtomicMatchExpression.js
  6. 288 0
      lib/pipeline/matcher/BSONElementIterator.js
  7. 96 0
      lib/pipeline/matcher/BSONMatchableDocument.js
  8. 253 0
      lib/pipeline/matcher/ComparisonMatchExpression.js
  9. 134 0
      lib/pipeline/matcher/Context.js
  10. 167 0
      lib/pipeline/matcher/ElemMatchObjectMatchExpression.js
  11. 236 0
      lib/pipeline/matcher/ElemMatchValueMatchExpression.js
  12. 29 0
      lib/pipeline/matcher/ElementIterator.js
  13. 107 0
      lib/pipeline/matcher/ElementPath.js
  14. 49 0
      lib/pipeline/matcher/EqualityMatchExpression.js
  15. 136 0
      lib/pipeline/matcher/ExistsMatchExpression.js
  16. 124 0
      lib/pipeline/matcher/FalseMatchExpression.js
  17. 49 0
      lib/pipeline/matcher/GTEMatchExpression.js
  18. 49 0
      lib/pipeline/matcher/GTMatchExpression.js
  19. 179 0
      lib/pipeline/matcher/GeoMatchExpression.js
  20. 191 0
      lib/pipeline/matcher/GeoNearMatchExpression.js
  21. 247 0
      lib/pipeline/matcher/InMatchExpression.js
  22. 130 0
      lib/pipeline/matcher/IndexKeyMatchableDocument.js
  23. 49 0
      lib/pipeline/matcher/LTEMatchExpression.js
  24. 49 0
      lib/pipeline/matcher/LTMatchExpression.js
  25. 137 0
      lib/pipeline/matcher/LeafMatchExpression.js
  26. 184 0
      lib/pipeline/matcher/ListOfMatchExpression.js
  27. 238 0
      lib/pipeline/matcher/MatchDetails.js
  28. 291 0
      lib/pipeline/matcher/MatchExpression.js
  29. 836 0
      lib/pipeline/matcher/MatchExpressionParser.js
  30. 29 0
      lib/pipeline/matcher/MatchableDocument.js
  31. 448 0
      lib/pipeline/matcher/Matcher2.js
  32. 203 0
      lib/pipeline/matcher/ModMatchExpression.js
  33. 137 0
      lib/pipeline/matcher/NorMatchExpression.js
  34. 197 0
      lib/pipeline/matcher/NotMatchExpression.js
  35. 137 0
      lib/pipeline/matcher/OrMatchExpression.js
  36. 243 0
      lib/pipeline/matcher/RegexMatchExpression.js
  37. 113 0
      lib/pipeline/matcher/SimpleArrayElementIterator.js
  38. 106 0
      lib/pipeline/matcher/SingleElementElementIterator.js
  39. 162 0
      lib/pipeline/matcher/SizeMatchExpression.js
  40. 28 0
      lib/pipeline/matcher/TagData.js
  41. 240 0
      lib/pipeline/matcher/TypeMatchExpression.js
  42. 280 0
      lib/pipeline/matcher/WhereMatchExpression.js

+ 333 - 0
lib/pipeline/matcher/AllElemMatchOp.js

@@ -0,0 +1,333 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var AllElemMatchOp = module.exports = function (){
+
+}, klass = AllElemMatchOp, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_array.h lines: 175-175
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_array.h lines: 176-176
+//         std::vector< const ArrayMatchingMatchExpression* > _list;
+
+proto._list = undefined;
+
+
+// File: expression_array.h lines: 174-174
+//         StringData _path;
+
+proto._path = undefined;
+
+
+// File: expression_array.h lines: 175-175
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_array.h lines: 176-176
+//         std::vector< const ArrayMatchingMatchExpression* > _list;
+
+proto._list = undefined;
+
+
+// File: expression_array.h lines: 174-174
+//         StringData _path;
+
+proto._path = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method AllElemMatchOp
+ * @param
+ *
+ */
+proto.AllElemMatchOp = function AllElemMatchOp( /*  ALL  */ ){
+// File: expression_array.h lines: 139-138
+//         AllElemMatchOp() : MatchExpression( ALL ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _allMatch
+ * @param
+ *
+ */
+proto._allMatch = function _allMatch( /*  const BSONObj& anArray  */ ){
+
+// File: expression_array.cpp lines: 208-215
+//     bool AllElemMatchOp::_allMatch( const BSONObj& anArray ) const {
+//         if ( _list.size() == 0 )
+//             return false;
+//         for ( unsigned i = 0; i < _list.size(); i++ ) {
+//             if ( !_list[i]->matchesArray( anArray, NULL ) )
+//                 return false;
+//         }
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method add
+ * @param
+ *
+ */
+proto.add = function add( /*  const ArrayMatchingMatchExpression* expr  */ ){
+
+// File: expression_array.cpp lines: 184-186
+//     void AllElemMatchOp::add( const ArrayMatchingMatchExpression* expr ) {
+//         verify( expr );
+//         _list.push_back( expr );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_array.cpp lines: 219-224
+//     void AllElemMatchOp::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << _path << " AllElemMatchOp: " << _path << "\n";
+//         for ( size_t i = 0; i < _list.size(); i++ ) {
+//             _list[i]->debugString( debug, level + 1);
+//         }
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_array.cpp lines: 227-242
+//     bool AllElemMatchOp::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const AllElemMatchOp* realOther = static_cast<const AllElemMatchOp*>( other );
+//         if ( _path != realOther->_path )
+//             return false;
+// 
+//         if ( _list.size() != realOther->_list.size() )
+//             return false;
+// 
+//         for ( unsigned i = 0; i < _list.size(); i++ )
+//             if ( !_list[i]->equivalent( realOther->_list[i] ) )
+//                 return false;
+// 
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getChild
+ * @param
+ *
+ */
+proto.getChild = function getChild( /*  size_t i  */ ){
+// File: expression_array.h lines: 167-166
+//         virtual const ArrayMatchingMatchExpression* getChild( size_t i ) const { return _list[i]; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path  */ ){
+
+// File: expression_array.cpp lines: 177-181
+//     Status AllElemMatchOp::init( const StringData& path ) {
+//         _path = path;
+//         Status s = _elementPath.init( _path );
+//         _elementPath.setTraverseLeafArray( false );
+//         return s;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
+
+// File: expression_array.cpp lines: 189-198
+//     bool AllElemMatchOp::matches( const MatchableDocument* doc, MatchDetails* details ) const {
+//         boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) );
+//         while ( cursor->more() ) {
+//             ElementIterator::Context e = cursor->next();
+//             if ( e.element().type() != Array )
+//                 continue;
+//             if ( _allMatch( e.element().Obj() ) )
+//                 return true;
+//         }
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_array.cpp lines: 201-205
+//     bool AllElemMatchOp::matchesSingleElement( const BSONElement& e ) const {
+//         if ( e.type() != Array )
+//             return false;
+// 
+//         return _allMatch( e.Obj() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method numChildren
+ * @param
+ *
+ */
+proto.numChildren = function numChildren( /*  */ ){
+// File: expression_array.h lines: 166-165
+//         virtual size_t numChildren() const { return _list.size(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method path
+ * @param
+ *
+ */
+proto.path = function path( /*  */ ){
+// File: expression_array.h lines: 169-168
+//         const StringData path() const { return _path; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_array.h lines: 145-152
+//         virtual MatchExpression* shallowClone() const {
+//             AllElemMatchOp* e = new AllElemMatchOp();
+//             e->init(path());
+//             for (size_t i = 0; i < _list.size(); ++i) {
+//                 e->add(reinterpret_cast<const ArrayMatchingMatchExpression*>(
+//                     _list[i]->shallowClone()));
+//             }
+//             return e;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~AllElemMatchOp
+ * @param
+ *
+ */
+proto.~AllElemMatchOp = function ~AllElemMatchOp( /*  */ ){
+
+// File: expression_array.cpp lines: 171-174
+//     AllElemMatchOp::~AllElemMatchOp() {
+//         for ( unsigned i = 0; i < _list.size(); i++ )
+//             delete _list[i];
+//         _list.clear();
+//     }
+
+
+
+}

+ 139 - 0
lib/pipeline/matcher/AndMatchExpression.js

@@ -0,0 +1,139 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var AndMatchExpression = module.exports = function (){
+
+}, klass = AndMatchExpression, 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 AndMatchExpression
+ * @param
+ *
+ */
+proto.AndMatchExpression = function AndMatchExpression( /*  AND  */ ){
+// File: expression_tree.h lines: 61-60
+//         AndMatchExpression() : ListOfMatchExpression( AND ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_tree.cpp lines: 85-88
+//     void AndMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "$and\n";
+//         _debugList( debug, level );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
+
+// File: expression_tree.cpp lines: 64-72
+//     bool AndMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
+//         for ( size_t i = 0; i < numChildren(); i++ ) {
+//             if ( !getChild(i)->matches( doc, details ) ) {
+//                 if ( details )
+//                     details->resetOutput();
+//                 return false;
+//             }
+//         }
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_tree.cpp lines: 75-81
+//     bool AndMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         for ( size_t i = 0; i < numChildren(); i++ ) {
+//             if ( !getChild(i)->matchesSingleElement( e ) ) {
+//                 return false;
+//             }
+//         }
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_tree.h lines: 67-72
+//         virtual MatchExpression* shallowClone() const {
+//             AndMatchExpression* self = new AndMatchExpression();
+//             for (size_t i = 0; i < numChildren(); ++i) {
+//                 self->add(getChild(i)->shallowClone());
+//             }
+//             return self;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~AndMatchExpression
+ * @param
+ *
+ */
+proto.~AndMatchExpression = function ~AndMatchExpression( /*  */ ){
+// File: expression_tree.h lines: 62-61
+//         virtual ~AndMatchExpression(){}
+
+
+
+
+}

+ 342 - 0
lib/pipeline/matcher/ArrayFilterEntries.js

@@ -0,0 +1,342 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ArrayFilterEntries = module.exports = function (){
+
+}, klass = ArrayFilterEntries, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// 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;
+
+
+// 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
+ *
+ */
+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();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method addRegex
+ * @param
+ *
+ */
+proto.addRegex = function addRegex( /*  RegexMatchExpression* expr  */ ){
+
+// File: expression_leaf.cpp lines: 389-391
+//     Status ArrayFilterEntries::addRegex( RegexMatchExpression* expr ) {
+//         _regexes.push_back( expr );
+//         return Status::OK();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method contains
+ * @param
+ *
+ */
+proto.contains = function contains( /*  const BSONElement& elem  */ ){
+// File: expression_leaf.h lines: 249-248
+//         bool contains( const BSONElement& elem ) const { return _equalities.count(elem) > 0; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method copyTo
+ * @param
+ *
+ */
+proto.copyTo = function copyTo( /*  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()) );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equalities
+ * @param
+ *
+ */
+proto.equalities = function equalities( /*  */ ){
+// File: expression_leaf.h lines: 248-247
+//         const BSONElementSet& equalities() const { return _equalities; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  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;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method hasEmptyArray
+ * @param
+ *
+ */
+proto.hasEmptyArray = function hasEmptyArray( /*  */ ){
+// File: expression_leaf.h lines: 256-255
+//         bool hasEmptyArray() const { return _hasEmptyArray; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method hasNull
+ * @param
+ *
+ */
+proto.hasNull = function hasNull( /*  */ ){
+// File: expression_leaf.h lines: 254-253
+//         bool hasNull() const { return _hasNull; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method numRegexes
+ * @param
+ *
+ */
+proto.numRegexes = function numRegexes( /*  */ ){
+// File: expression_leaf.h lines: 251-250
+//         size_t numRegexes() const { return _regexes.size(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method regex
+ * @param
+ *
+ */
+proto.regex = function regex( /*  int idx  */ ){
+// File: expression_leaf.h lines: 252-251
+//         RegexMatchExpression* regex( int idx ) const { return _regexes[idx]; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method singleNull
+ * @param
+ *
+ */
+proto.singleNull = function singleNull( /*  */ ){
+// File: expression_leaf.h lines: 255-254
+//         bool singleNull() const { return size() == 1 && _hasNull; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method size
+ * @param
+ *
+ */
+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();
+//     }
+
+
+
+}

+ 200 - 0
lib/pipeline/matcher/ArrayMatchingMatchExpression.js

@@ -0,0 +1,200 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ArrayMatchingMatchExpression = module.exports = function (){
+
+}, klass = ArrayMatchingMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_array.h lines: 55-55
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_array.h lines: 54-54
+//         StringData _path;
+
+proto._path = undefined;
+
+
+// File: expression_array.h lines: 55-55
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_array.h lines: 54-54
+//         StringData _path;
+
+proto._path = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ArrayMatchingMatchExpression
+ * @param
+ *
+ */
+proto.ArrayMatchingMatchExpression = function ArrayMatchingMatchExpression( /*  MatchType matchType  */ ){
+// File: expression_array.h lines: 36-35
+//         ArrayMatchingMatchExpression( MatchType matchType ) : MatchExpression( matchType ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_array.cpp lines: 63-79
+//     bool ArrayMatchingMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const ArrayMatchingMatchExpression* realOther =
+//             static_cast<const ArrayMatchingMatchExpression*>( other );
+// 
+//         if ( _path != realOther->_path )
+//             return false;
+// 
+//         if ( numChildren() != realOther->numChildren() )
+//             return false;
+// 
+//         for ( unsigned i = 0; i < numChildren(); i++ )
+//             if ( !getChild(i)->equivalent( realOther->getChild(i) ) )
+//                 return false;
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method initPath
+ * @param
+ *
+ */
+proto.initPath = function initPath( /*  const StringData& path  */ ){
+
+// File: expression_array.cpp lines: 27-31
+//     Status ArrayMatchingMatchExpression::initPath( const StringData& path ) {
+//         _path = path;
+//         Status s = _elementPath.init( _path );
+//         _elementPath.setTraverseLeafArray( false );
+//         return s;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
+
+// File: expression_array.cpp lines: 34-53
+//     bool ArrayMatchingMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
+// 
+//         boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) );
+// 
+//         while ( cursor->more() ) {
+//             ElementIterator::Context e = cursor->next();
+//             if ( e.element().type() != Array )
+//                 continue;
+// 
+//             bool amIRoot = e.arrayOffset().eoo();
+// 
+//             if ( !matchesArray( e.element().Obj(), amIRoot ? details : NULL ) )
+//                 continue;
+// 
+//             if ( !amIRoot && details && details->needRecord() && !e.arrayOffset().eoo() ) {
+//                 details->setElemMatchKey( e.arrayOffset().fieldName() );
+//             }
+//             return true;
+//         }
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_array.cpp lines: 56-59
+//     bool ArrayMatchingMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         if ( e.type() != Array )
+//             return false;
+//         return matchesArray( e.Obj(), NULL );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method path
+ * @param
+ *
+ */
+proto.path = function path( /*  */ ){
+// File: expression_array.h lines: 52-51
+//         const StringData path() const { return _path; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~ArrayMatchingMatchExpression
+ * @param
+ *
+ */
+proto.~ArrayMatchingMatchExpression = function ~ArrayMatchingMatchExpression( /*  */ ){
+// File: expression_array.h lines: 37-36
+//         virtual ~ArrayMatchingMatchExpression(){}
+
+
+
+
+}

+ 124 - 0
lib/pipeline/matcher/AtomicMatchExpression.js

@@ -0,0 +1,124 @@
+"use strict"
+
+
+
+// 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 ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression.cpp lines: 48-50
+//     void AtomicMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "$atomic\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+// File: expression.h lines: 198-199
+//         virtual bool equivalent( const MatchExpression* other ) const {
+//             return other->matchType() == ATOMIC;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details = 0  */ ){
+// File: expression.h lines: 184-185
+//         virtual bool matches( const MatchableDocument* doc, MatchDetails* details = 0 ) const {
+//             return true;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+// File: expression.h lines: 188-189
+//         virtual bool matchesSingleElement( const BSONElement& e ) const {
+//             return true;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression.h lines: 192-193
+//         virtual MatchExpression* shallowClone() const {
+//             return new AtomicMatchExpression();
+//         }
+
+
+
+
+}

+ 288 - 0
lib/pipeline/matcher/BSONElementIterator.js

@@ -0,0 +1,288 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var BSONElementIterator = module.exports = function (){
+
+}, klass = BSONElementIterator, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: path.h lines: 140-140
+//         ArrayIterationState _arrayIterationState;
+
+proto._arrayIterationState = undefined;
+
+
+// File: path.h lines: 114-114
+//         BSONObj _context;
+
+proto._context = undefined;
+
+
+// File: path.h lines: 117-117
+//         Context _next;
+
+proto._next = undefined;
+
+
+// File: path.h lines: 113-113
+//         const ElementPath& _path;
+
+proto._path = undefined;
+
+
+// File: path.h lines: 116-115
+//         enum State { BEGIN, IN_ARRAY, DONE } _state;
+
+proto._state = undefined;
+
+
+// File: path.h lines: 142-142
+//         boost::scoped_ptr<ElementIterator> _subCursor;
+
+proto._subCursor = undefined;
+
+
+// File: path.h lines: 143-143
+//         boost::scoped_ptr<ElementPath> _subCursorPath;
+
+proto._subCursorPath = undefined;
+
+
+// File: path.h lines: 140-140
+//         ArrayIterationState _arrayIterationState;
+
+proto._arrayIterationState = undefined;
+
+
+// File: path.h lines: 114-114
+//         BSONObj _context;
+
+proto._context = undefined;
+
+
+// File: path.h lines: 117-117
+//         Context _next;
+
+proto._next = undefined;
+
+
+// File: path.h lines: 113-113
+//         const ElementPath& _path;
+
+proto._path = undefined;
+
+
+// File: path.h lines: 116-115
+//         enum State { BEGIN, IN_ARRAY, DONE } _state;
+
+proto._state = undefined;
+
+
+// File: path.h lines: 142-142
+//         boost::scoped_ptr<ElementIterator> _subCursor;
+
+proto._subCursor = undefined;
+
+
+// File: path.h lines: 143-143
+//         boost::scoped_ptr<ElementPath> _subCursorPath;
+
+proto._subCursorPath = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method BSONElementIterator
+ * @param
+ *
+ */
+proto.BSONElementIterator = function BSONElementIterator( /*  const ElementPath& path, const BSONObj& context  */ ){
+
+// File: path.cpp lines: 77-80
+//     BSONElementIterator::BSONElementIterator( const ElementPath& path, const BSONObj& context )
+//         : _path( path ), _context( context ) {
+//         _state = BEGIN;
+//         //log() << "path: " << path.fieldRef().dottedField() << " context: " << context << endl;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method more
+ * @param
+ *
+ */
+proto.more = function more( /*  */ ){
+
+// File: path.cpp lines: 120-230
+//     bool BSONElementIterator::more() {
+//         if ( _subCursor ) {
+// 
+//             if ( _subCursor->more() )
+//                 return true;
+// 
+//             _subCursor.reset();
+// 
+//             if ( _arrayIterationState.isArrayOffsetMatch( _arrayIterationState._current.fieldName() ) ) {
+//                 if ( _arrayIterationState.nextEntireRest() ) {
+//                     _next.reset( _arrayIterationState._current, _arrayIterationState._current, true );
+//                     _arrayIterationState._current = BSONElement();
+//                     return true;
+//                 }
+// 
+//                 _subCursorPath.reset( new ElementPath() );
+//                 _subCursorPath->init( _arrayIterationState.restOfPath.substr( _arrayIterationState.nextPieceOfPath.size() + 1 ) );
+//                 _subCursorPath->setTraverseLeafArray( _path.shouldTraverseLeafArray() );
+//                 _subCursor.reset( new BSONElementIterator( *_subCursorPath, _arrayIterationState._current.Obj() ) );
+//                 _arrayIterationState._current = BSONElement();
+//                 return more();
+//             }
+// 
+//         }
+// 
+//         if ( !_next.element().eoo() )
+//             return true;
+// 
+//         if ( _state == DONE ){
+//             return false;
+//         }
+// 
+//         if ( _state == BEGIN ) {
+//             size_t idxPath = 0;
+//             BSONElement e = getFieldDottedOrArray( _context, _path.fieldRef(), &idxPath );
+// 
+//             if ( e.type() != Array ) {
+//                 _next.reset( e, BSONElement(), false );
+//                 _state = DONE;
+//                 return true;
+//             }
+// 
+//             // its an array
+// 
+//             _arrayIterationState.reset( _path.fieldRef(), idxPath + 1 );
+// 
+//             if ( !_arrayIterationState.hasMore && !_path.shouldTraverseLeafArray() ) {
+//                 _next.reset( e, BSONElement(), true );
+//                 _state = DONE;
+//                 return true;
+//             }
+// 
+//             _arrayIterationState.startIterator( e );
+//             _state = IN_ARRAY;
+//             return more();
+//         }
+// 
+//         if ( _state == IN_ARRAY ) {
+// 
+//             while ( _arrayIterationState.more() ) {
+// 
+//                 BSONElement x = _arrayIterationState.next();
+//                 if ( !_arrayIterationState.hasMore ) {
+//                     _next.reset( x, x, false );
+//                     return true;
+//                 }
+// 
+//                 // i have deeper to go
+// 
+//                 if ( x.type() == Object ) {
+//                     _subCursorPath.reset( new ElementPath() );
+//                     _subCursorPath->init( _arrayIterationState.restOfPath );
+//                     _subCursorPath->setTraverseLeafArray( _path.shouldTraverseLeafArray() );
+// 
+//                     _subCursor.reset( new BSONElementIterator( *_subCursorPath, x.Obj() ) );
+//                     return more();
+//                 }
+// 
+// 
+//                 if ( _arrayIterationState.isArrayOffsetMatch( x.fieldName() ) ) {
+// 
+//                     if ( _arrayIterationState.nextEntireRest() ) {
+//                         _next.reset( x, x, false );
+//                         return true;
+//                     }
+// 
+//                     if ( x.isABSONObj() ) {
+//                         _subCursorPath.reset( new ElementPath() );
+//                         _subCursorPath->init( _arrayIterationState.restOfPath.substr( _arrayIterationState.nextPieceOfPath.size() + 1 ) );
+//                         _subCursorPath->setTraverseLeafArray( _path.shouldTraverseLeafArray() );
+//                         BSONElementIterator* real = new BSONElementIterator( *_subCursorPath, _arrayIterationState._current.Obj() );
+//                         _subCursor.reset( real );
+//                         real->_arrayIterationState.reset( _subCursorPath->fieldRef(), 0 );
+//                         real->_arrayIterationState.startIterator( x );
+//                         real->_state = IN_ARRAY;
+//                         _arrayIterationState._current = BSONElement();
+//                         return more();
+//                     }
+//                 }
+// 
+//             }
+// 
+//             if ( _arrayIterationState.hasMore )
+//                 return false;
+// 
+//             _next.reset( _arrayIterationState._theArray, BSONElement(), true );
+//             _state = DONE;
+//             return true;
+//         }
+// 
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method next
+ * @param
+ *
+ */
+proto.next = function next( /*  */ ){
+
+// File: path.cpp lines: 233-241
+//     ElementIterator::Context BSONElementIterator::next() {
+//         if ( _subCursor ) {
+//             Context e = _subCursor->next();
+//             e.setArrayOffset( _arrayIterationState._current );
+//             return e;
+//         }
+//         Context x = _next;
+//         _next.reset();
+//         return x;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~BSONElementIterator
+ * @param
+ *
+ */
+proto.~BSONElementIterator = function ~BSONElementIterator( /*  */ ){
+
+// File: path.cpp lines: 83-83
+//     BSONElementIterator::~BSONElementIterator() {
+//     }
+
+
+
+}

+ 96 - 0
lib/pipeline/matcher/BSONMatchableDocument.js

@@ -0,0 +1,96 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var BSONMatchableDocument = module.exports = function (){
+
+}, klass = BSONMatchableDocument, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: matchable.h lines: 49-49
+//         BSONObj _obj;
+
+proto._obj = undefined;
+
+
+// File: matchable.h lines: 49-49
+//         BSONObj _obj;
+
+proto._obj = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method BSONMatchableDocument
+ * @param
+ *
+ */
+proto.BSONMatchableDocument = function BSONMatchableDocument( /*  const BSONObj& obj  */ ){
+
+// File: matchable.cpp lines: 28-29
+//     BSONMatchableDocument::BSONMatchableDocument( const BSONObj& obj )
+//         : _obj( obj ) {
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getIterator
+ * @param
+ *
+ */
+proto.getIterator = function getIterator( /*  const ElementPath& path  */ ){
+// File: matchable.h lines: 44-45
+//         virtual ElementIterator* getIterator( const ElementPath& path ) const {
+//             return new BSONElementIterator( path, _obj );
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method toBSON
+ * @param
+ *
+ */
+proto.toBSON = function toBSON( /*  */ ){
+// File: matchable.h lines: 42-41
+//         virtual BSONObj toBSON() const { return _obj; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~BSONMatchableDocument
+ * @param
+ *
+ */
+proto.~BSONMatchableDocument = function ~BSONMatchableDocument( /*  */ ){
+
+// File: matchable.cpp lines: 32-32
+//     BSONMatchableDocument::~BSONMatchableDocument() {
+//     }
+
+
+
+}

+ 253 - 0
lib/pipeline/matcher/ComparisonMatchExpression.js

@@ -0,0 +1,253 @@
+"use strict"
+
+
+
+// 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;
+
+
+// File: expression_leaf.h lines: 88-88
+//         BSONElement _rhs;
+
+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.
+ * @method debugString
+ * @param
+ *
+ */
+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";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_leaf.cpp lines: 53-61
+//     bool ComparisonMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( other->matchType() != matchType() )
+//             return false;
+//         const ComparisonMatchExpression* realOther =
+//             static_cast<const ComparisonMatchExpression*>( other );
+// 
+//         return
+//             path() == realOther->path() &&
+//             _rhs.valuesEqual( realOther->_rhs );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getData
+ * @param
+ *
+ */
+proto.getData = function getData( /*  */ ){
+// File: expression_leaf.h lines: 85-84
+//         const BSONElement& getData() const { return _rhs; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getRHS
+ * @param
+ *
+ */
+proto.getRHS = function getRHS( /*  */ ){
+// File: expression_leaf.h lines: 79-78
+//         virtual const BSONElement& getRHS() const { return _rhs; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  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 documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @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(){}
+
+
+
+
+}

+ 134 - 0
lib/pipeline/matcher/Context.js

@@ -0,0 +1,134 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var Context = module.exports = function (){
+
+}, klass = Context, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: path.h lines: 62-62
+//             BSONElement _arrayOffset;
+
+proto._arrayOffset = undefined;
+
+
+// File: path.h lines: 61-61
+//             BSONElement _element;
+
+proto._element = undefined;
+
+
+// File: path.h lines: 63-63
+//             bool _outerArray;
+
+proto._outerArray = undefined;
+
+
+// File: path.h lines: 62-62
+//             BSONElement _arrayOffset;
+
+proto._arrayOffset = undefined;
+
+
+// File: path.h lines: 61-61
+//             BSONElement _element;
+
+proto._element = undefined;
+
+
+// File: path.h lines: 63-63
+//             bool _outerArray;
+
+proto._outerArray = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method arrayOffset
+ * @param
+ *
+ */
+proto.arrayOffset = function arrayOffset( /*  */ ){
+// File: path.h lines: 57-56
+//             BSONElement arrayOffset() const { return _arrayOffset; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method element
+ * @param
+ *
+ */
+proto.element = function element( /*  */ ){
+// File: path.h lines: 56-55
+//             BSONElement element() const { return _element; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method outerArray
+ * @param
+ *
+ */
+proto.outerArray = function outerArray( /*  */ ){
+// File: path.h lines: 58-57
+//             bool outerArray() const { return _outerArray; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method reset
+ * @param
+ *
+ */
+proto.reset = function reset( /*  BSONElement element,$/;" */ ){
+
+// File: path.cpp lines: 37-38
+//     void ElementIterator::Context::reset() {
+//         _element = BSONElement();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method setArrayOffset
+ * @param
+ *
+ */
+proto.setArrayOffset = function setArrayOffset( /*  BSONElement e  */ ){
+// File: path.h lines: 54-53
+//             void setArrayOffset( BSONElement e ) { _arrayOffset = e; }
+
+
+
+
+}

+ 167 - 0
lib/pipeline/matcher/ElemMatchObjectMatchExpression.js

@@ -0,0 +1,167 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ElemMatchObjectMatchExpression = module.exports = function (){
+
+}, klass = ElemMatchObjectMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_array.h lines: 77-77
+//         boost::scoped_ptr<const MatchExpression> _sub;
+
+proto._sub = undefined;
+
+
+// File: expression_array.h lines: 77-77
+//         boost::scoped_ptr<const MatchExpression> _sub;
+
+proto._sub = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ElemMatchObjectMatchExpression
+ * @param
+ *
+ */
+proto.ElemMatchObjectMatchExpression = function ElemMatchObjectMatchExpression( /*  ELEM_MATCH_OBJECT  */ ){
+// File: expression_array.h lines: 60-59
+//         ElemMatchObjectMatchExpression() : ArrayMatchingMatchExpression( ELEM_MATCH_OBJECT ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_array.cpp lines: 106-109
+//     void ElemMatchObjectMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << path() << " $elemMatch\n";
+//         _sub->debugString( debug, level + 1 );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getChild
+ * @param
+ *
+ */
+proto.getChild = function getChild( /*  size_t i  */ ){
+// File: expression_array.h lines: 74-73
+//         virtual const MatchExpression* getChild( size_t i ) const { return _sub.get(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, const MatchExpression* sub  */ ){
+
+// File: expression_array.cpp lines: 85-87
+//     Status ElemMatchObjectMatchExpression::init( const StringData& path, const MatchExpression* sub ) {
+//         _sub.reset( sub );
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesArray
+ * @param
+ *
+ */
+proto.matchesArray = function matchesArray( /*  const BSONObj& anArray, MatchDetails* details  */ ){
+
+// File: expression_array.cpp lines: 90-103
+//     bool ElemMatchObjectMatchExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
+//         BSONObjIterator i( anArray );
+//         while ( i.more() ) {
+//             BSONElement inner = i.next();
+//             if ( !inner.isABSONObj() )
+//                 continue;
+//             if ( _sub->matchesBSON( inner.Obj(), NULL ) ) {
+//                 if ( details && details->needRecord() ) {
+//                     details->setElemMatchKey( inner.fieldName() );
+//                 }
+//                 return true;
+//             }
+//         }
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method numChildren
+ * @param
+ *
+ */
+proto.numChildren = function numChildren( /*  */ ){
+// File: expression_array.h lines: 73-72
+//         virtual size_t numChildren() const { return 1; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_array.h lines: 65-68
+//         virtual ElemMatchObjectMatchExpression* shallowClone() const {
+//             ElemMatchObjectMatchExpression* e = new ElemMatchObjectMatchExpression();
+//             e->init(path(), _sub->shallowClone());
+//             return e;
+//         }
+
+
+
+
+}

+ 236 - 0
lib/pipeline/matcher/ElemMatchValueMatchExpression.js

@@ -0,0 +1,236 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ElemMatchValueMatchExpression = module.exports = function (){
+
+}, klass = ElemMatchValueMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_array.h lines: 108-108
+//         std::vector< const MatchExpression* > _subs;
+
+proto._subs = undefined;
+
+
+// File: expression_array.h lines: 108-108
+//         std::vector< const MatchExpression* > _subs;
+
+proto._subs = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ElemMatchValueMatchExpression
+ * @param
+ *
+ */
+proto.ElemMatchValueMatchExpression = function ElemMatchValueMatchExpression( /*  ELEM_MATCH_VALUE  */ ){
+// File: expression_array.h lines: 82-81
+//         ElemMatchValueMatchExpression() : ArrayMatchingMatchExpression( ELEM_MATCH_VALUE ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _arrayElementMatchesAll
+ * @param
+ *
+ */
+proto._arrayElementMatchesAll = function _arrayElementMatchesAll( /*  const BSONElement& e  */ ){
+
+// File: expression_array.cpp lines: 152-157
+//     bool ElemMatchValueMatchExpression::_arrayElementMatchesAll( const BSONElement& e ) const {
+//         for ( unsigned i = 0; i < _subs.size(); i++ ) {
+//             if ( !_subs[i]->matchesSingleElement( e ) )
+//                 return false;
+//         }
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method add
+ * @param
+ *
+ */
+proto.add = function add( /*  const MatchExpression* sub  */ ){
+
+// File: expression_array.cpp lines: 132-134
+//     void ElemMatchValueMatchExpression::add( const MatchExpression* sub ) {
+//         verify( sub );
+//         _subs.push_back( sub );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_array.cpp lines: 160-165
+//     void ElemMatchValueMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << path() << " $elemMatch\n";
+//         for ( unsigned i = 0; i < _subs.size(); i++ ) {
+//             _subs[i]->debugString( debug, level + 1 );
+//         }
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getChild
+ * @param
+ *
+ */
+proto.getChild = function getChild( /*  size_t i  */ ){
+// File: expression_array.h lines: 103-102
+//         virtual const MatchExpression* getChild( size_t i ) const { return _subs[i]; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, const MatchExpression* sub  */ ){
+
+// File: expression_array.cpp lines: 121-124
+//     Status ElemMatchValueMatchExpression::init( const StringData& path, const MatchExpression* sub ) {
+//         init( path );
+//         add( sub );
+//         return Status::OK();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesArray
+ * @param
+ *
+ */
+proto.matchesArray = function matchesArray( /*  const BSONObj& anArray, MatchDetails* details  */ ){
+
+// File: expression_array.cpp lines: 137-149
+//     bool ElemMatchValueMatchExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
+//         BSONObjIterator i( anArray );
+//         while ( i.more() ) {
+//             BSONElement inner = i.next();
+// 
+//             if ( _arrayElementMatchesAll( inner ) ) {
+//                 if ( details && details->needRecord() ) {
+//                     details->setElemMatchKey( inner.fieldName() );
+//                 }
+//                 return true;
+//             }
+//         }
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method numChildren
+ * @param
+ *
+ */
+proto.numChildren = function numChildren( /*  */ ){
+// File: expression_array.h lines: 102-101
+//         virtual size_t numChildren() const { return _subs.size(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_array.h lines: 91-97
+//         virtual ElemMatchValueMatchExpression* shallowClone() const {
+//             ElemMatchValueMatchExpression* e = new ElemMatchValueMatchExpression();
+//             e->init(path());
+//             for (size_t i = 0; i < _subs.size(); ++i) {
+//                 e->add(_subs[i]->shallowClone());
+//             }
+//             return e;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~ElemMatchValueMatchExpression
+ * @param
+ *
+ */
+proto.~ElemMatchValueMatchExpression = function ~ElemMatchValueMatchExpression( /*  */ ){
+
+// File: expression_array.cpp lines: 115-118
+//     ElemMatchValueMatchExpression::~ElemMatchValueMatchExpression() {
+//         for ( unsigned i = 0; i < _subs.size(); i++ )
+//             delete _subs[i];
+//         _subs.clear();
+//     }
+
+
+
+}

+ 29 - 0
lib/pipeline/matcher/ElementIterator.js

@@ -0,0 +1,29 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ElementIterator = module.exports = function (){
+
+}, klass = ElementIterator, 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 ~ElementIterator
+ * @param
+ *
+ */
+proto.~ElementIterator = function ~ElementIterator( /*  */ ){
+
+// File: path.cpp lines: 34-34
+//     ElementIterator::~ElementIterator(){
+//     }
+
+
+
+}

+ 107 - 0
lib/pipeline/matcher/ElementPath.js

@@ -0,0 +1,107 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ElementPath = module.exports = function (){
+
+}, klass = ElementPath, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: path.h lines: 41-41
+//         FieldRef _fieldRef;
+
+proto._fieldRef = undefined;
+
+
+// File: path.h lines: 42-42
+//         bool _shouldTraverseLeafArray;
+
+proto._shouldTraverseLeafArray = undefined;
+
+
+// File: path.h lines: 41-41
+//         FieldRef _fieldRef;
+
+proto._fieldRef = undefined;
+
+
+// File: path.h lines: 42-42
+//         bool _shouldTraverseLeafArray;
+
+proto._shouldTraverseLeafArray = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method fieldRef
+ * @param
+ *
+ */
+proto.fieldRef = function fieldRef( /*  */ ){
+// File: path.h lines: 37-36
+//         const FieldRef& fieldRef() const { return _fieldRef; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path  */ ){
+
+// File: path.cpp lines: 26-29
+//     Status ElementPath::init( const StringData& path ) {
+//         _shouldTraverseLeafArray = true;
+//         _fieldRef.parse( path );
+//         return Status::OK();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method setTraverseLeafArray
+ * @param
+ *
+ */
+proto.setTraverseLeafArray = function setTraverseLeafArray( /*  bool b  */ ){
+// File: path.h lines: 35-34
+//         void setTraverseLeafArray( bool b ) { _shouldTraverseLeafArray = b; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shouldTraverseLeafArray
+ * @param
+ *
+ */
+proto.shouldTraverseLeafArray = function shouldTraverseLeafArray( /*  */ ){
+// File: path.h lines: 38-37
+//         bool shouldTraverseLeafArray() const { return _shouldTraverseLeafArray; }
+
+
+
+
+}

+ 49 - 0
lib/pipeline/matcher/EqualityMatchExpression.js

@@ -0,0 +1,49 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var EqualityMatchExpression = module.exports = function (){
+
+}, klass = EqualityMatchExpression, 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 EqualityMatchExpression
+ * @param
+ *
+ */
+proto.EqualityMatchExpression = function EqualityMatchExpression( /*  EQ  */ ){
+// File: expression_leaf.h lines: 97-96
+//         EqualityMatchExpression() : ComparisonMatchExpression( EQ ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 98-101
+//         virtual LeafMatchExpression* shallowClone() const {
+//             ComparisonMatchExpression* e = new EqualityMatchExpression();
+//             e->init( path(), _rhs  );
+//             return e;
+//         }
+
+
+
+
+}

+ 136 - 0
lib/pipeline/matcher/ExistsMatchExpression.js

@@ -0,0 +1,136 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ExistsMatchExpression = module.exports = function (){
+
+}, klass = ExistsMatchExpression, 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 ExistsMatchExpression
+ * @param
+ *
+ */
+proto.ExistsMatchExpression = function ExistsMatchExpression( /*  EXISTS  */ ){
+// File: expression_leaf.h lines: 216-215
+//         ExistsMatchExpression() : LeafMatchExpression( EXISTS ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_leaf.cpp lines: 286-294
+//     void ExistsMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << path() << " exists";
+//         MatchExpression::TagData* td = getTag();
+//         if (NULL != td) {
+//             debug << " ";
+//             td->debugString(&debug);
+//         }
+//         debug << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_leaf.cpp lines: 297-302
+//     bool ExistsMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const ExistsMatchExpression* realOther = static_cast<const ExistsMatchExpression*>( other );
+//         return path() == realOther->path();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path  */ ){
+
+// File: expression_leaf.cpp lines: 278-279
+//     Status ExistsMatchExpression::init( const StringData& path ) {
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_leaf.cpp lines: 282-283
+//     bool ExistsMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         return !e.eoo();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 220-223
+//         virtual LeafMatchExpression* shallowClone() const {
+//             ExistsMatchExpression* e = new ExistsMatchExpression();
+//             e->init( path() );
+//             return e;
+//         }
+
+
+
+
+}

+ 124 - 0
lib/pipeline/matcher/FalseMatchExpression.js

@@ -0,0 +1,124 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var FalseMatchExpression = module.exports = function (){
+
+}, klass = FalseMatchExpression, 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 FalseMatchExpression
+ * @param
+ *
+ */
+proto.FalseMatchExpression = function FalseMatchExpression( /*  ALWAYS_FALSE  */ ){
+// File: expression.h lines: 206-205
+//         FalseMatchExpression() : MatchExpression( ALWAYS_FALSE ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression.cpp lines: 53-55
+//     void FalseMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "$false\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+// File: expression.h lines: 222-223
+//         virtual bool equivalent( const MatchExpression* other ) const {
+//             return other->matchType() == ALWAYS_FALSE;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details = 0  */ ){
+// File: expression.h lines: 208-209
+//         virtual bool matches( const MatchableDocument* doc, MatchDetails* details = 0 ) const {
+//             return false;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+// File: expression.h lines: 212-213
+//         virtual bool matchesSingleElement( const BSONElement& e ) const {
+//             return false;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression.h lines: 216-217
+//         virtual MatchExpression* shallowClone() const {
+//             return new FalseMatchExpression();
+//         }
+
+
+
+
+}

+ 49 - 0
lib/pipeline/matcher/GTEMatchExpression.js

@@ -0,0 +1,49 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var GTEMatchExpression = module.exports = function (){
+
+}, klass = GTEMatchExpression, 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 GTEMatchExpression
+ * @param
+ *
+ */
+proto.GTEMatchExpression = function GTEMatchExpression( /*  GTE  */ ){
+// File: expression_leaf.h lines: 140-139
+//         GTEMatchExpression() : ComparisonMatchExpression( GTE ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 141-144
+//         virtual LeafMatchExpression* shallowClone() const {
+//             ComparisonMatchExpression* e = new GTEMatchExpression();
+//             e->init( path(), _rhs  );
+//             return e;
+//         }
+
+
+
+
+}

+ 49 - 0
lib/pipeline/matcher/GTMatchExpression.js

@@ -0,0 +1,49 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var GTMatchExpression = module.exports = function (){
+
+}, klass = GTMatchExpression, 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 GTMatchExpression
+ * @param
+ *
+ */
+proto.GTMatchExpression = function GTMatchExpression( /*  GT  */ ){
+// File: expression_leaf.h lines: 129-128
+//         GTMatchExpression() : ComparisonMatchExpression( GT ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 130-133
+//         virtual LeafMatchExpression* shallowClone() const {
+//             ComparisonMatchExpression* e = new GTMatchExpression();
+//             e->init( path(), _rhs  );
+//             return e;
+//         }
+
+
+
+
+}

+ 179 - 0
lib/pipeline/matcher/GeoMatchExpression.js

@@ -0,0 +1,179 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var GeoMatchExpression = module.exports = function (){
+
+}, klass = GeoMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_geo.h lines: 45-45
+//         GeoQuery _query;
+
+proto._query = undefined;
+
+
+// File: expression_geo.h lines: 45-45
+//         GeoQuery _query;
+
+proto._query = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method GeoMatchExpression
+ * @param
+ *
+ */
+proto.GeoMatchExpression = function GeoMatchExpression( /*  GEO  */ ){
+// File: expression_geo.h lines: 31-30
+//         GeoMatchExpression() : LeafMatchExpression( GEO ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_geo.cpp lines: 44-52
+//     void GeoMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "GEO";
+//         MatchExpression::TagData* td = getTag();
+//         if (NULL != td) {
+//             debug << " ";
+//             td->debugString(&debug);
+//         }
+//         debug << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_geo.cpp lines: 55-66
+//     bool GeoMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const GeoMatchExpression* realOther = static_cast<const GeoMatchExpression*>( other );
+// 
+//         if ( path() != realOther->path() )
+//             return false;
+// 
+//         // TODO:
+//         // return _query == realOther->_query;
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, const GeoQuery& query  */ ){
+
+// File: expression_geo.cpp lines: 28-30
+//     Status GeoMatchExpression::init( const StringData& path, const GeoQuery& query ) {
+//         _query = query;
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_geo.cpp lines: 33-41
+//     bool GeoMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         if ( !e.isABSONObj())
+//             return false;
+// 
+//         GeometryContainer container;
+//         if ( !container.parseFrom( e.Obj() ) )
+//                 return false;
+// 
+//         return _query.satisfiesPredicate( container );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+
+// File: expression_geo.cpp lines: 69-72
+//     LeafMatchExpression* GeoMatchExpression::shallowClone() const {
+//         GeoMatchExpression* next = new GeoMatchExpression();
+//         next->init( path(), _query );
+//         return next;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~GeoMatchExpression
+ * @param
+ *
+ */
+proto.~GeoMatchExpression = function ~GeoMatchExpression( /*  */ ){
+// File: expression_geo.h lines: 32-31
+//         virtual ~GeoMatchExpression(){}
+
+
+
+
+}

+ 191 - 0
lib/pipeline/matcher/GeoNearMatchExpression.js

@@ -0,0 +1,191 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var GeoNearMatchExpression = module.exports = function (){
+
+}, klass = GeoNearMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_geo.h lines: 66-66
+//         NearQuery _query;
+
+proto._query = undefined;
+
+
+// File: expression_geo.h lines: 66-66
+//         NearQuery _query;
+
+proto._query = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method GeoNearMatchExpression
+ * @param
+ *
+ */
+proto.GeoNearMatchExpression = function GeoNearMatchExpression( /*  GEO_NEAR  */ ){
+// File: expression_geo.h lines: 50-49
+//         GeoNearMatchExpression() : LeafMatchExpression( GEO_NEAR ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_geo.cpp lines: 90-98
+//     void GeoNearMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "GEONEAR";
+//         MatchExpression::TagData* td = getTag();
+//         if (NULL != td) {
+//             debug << " ";
+//             td->debugString(&debug);
+//         }
+//         debug << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_geo.cpp lines: 101-112
+//     bool GeoNearMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const GeoNearMatchExpression* realOther = static_cast<const GeoNearMatchExpression*>(other);
+// 
+//         if ( path() != realOther->path() )
+//             return false;
+// 
+//         // TODO:
+//         // return _query == realOther->_query;
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getData
+ * @param
+ *
+ */
+proto.getData = function getData( /*  */ ){
+// File: expression_geo.h lines: 64-63
+//         const NearQuery& getData() const { return _query; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, const NearQuery& query  */ ){
+
+// File: expression_geo.cpp lines: 79-81
+//     Status GeoNearMatchExpression::init( const StringData& path, const NearQuery& query ) {
+//         _query = query;
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_geo.cpp lines: 84-87
+//     bool GeoNearMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         // This shouldn't be called.
+//         verify(0);
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+
+// File: expression_geo.cpp lines: 115-118
+//     LeafMatchExpression* GeoNearMatchExpression::shallowClone() const {
+//         GeoNearMatchExpression* next = new GeoNearMatchExpression();
+//         next->init( path(), _query );
+//         return next;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~GeoNearMatchExpression
+ * @param
+ *
+ */
+proto.~GeoNearMatchExpression = function ~GeoNearMatchExpression( /*  */ ){
+// File: expression_geo.h lines: 51-50
+//         virtual ~GeoNearMatchExpression(){}
+
+
+
+
+}

+ 247 - 0
lib/pipeline/matcher/InMatchExpression.js

@@ -0,0 +1,247 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var InMatchExpression = module.exports = function (){
+
+}, klass = InMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_leaf.h lines: 294-294
+//         ArrayFilterEntries _arrayEntries;
+
+proto._arrayEntries = undefined;
+
+
+// File: expression_leaf.h lines: 294-294
+//         ArrayFilterEntries _arrayEntries;
+
+proto._arrayEntries = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method InMatchExpression
+ * @param
+ *
+ */
+proto.InMatchExpression = function InMatchExpression( /*  MATCH_IN  */ ){
+// File: expression_leaf.h lines: 275-274
+//         InMatchExpression() : LeafMatchExpression( MATCH_IN ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _matchesRealElement
+ * @param
+ *
+ */
+proto._matchesRealElement = function _matchesRealElement( /*  const BSONElement& e  */ ){
+
+// File: expression_leaf.cpp lines: 422-431
+//     bool InMatchExpression::_matchesRealElement( const BSONElement& e ) const {
+//         if ( _arrayEntries.contains( e ) )
+//             return true;
+// 
+//         for ( unsigned i = 0; i < _arrayEntries.numRegexes(); i++ ) {
+//             if ( _arrayEntries.regex(i)->matchesSingleElement( e ) )
+//                 return true;
+//         }
+// 
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method copyTo
+ * @param
+ *
+ */
+proto.copyTo = function copyTo( /*  InMatchExpression* toFillIn  */ ){
+
+// File: expression_leaf.cpp lines: 481-483
+//     void InMatchExpression::copyTo( InMatchExpression* toFillIn ) const {
+//         toFillIn->init( path() );
+//         _arrayEntries.copyTo( toFillIn->_arrayEntries );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_leaf.cpp lines: 455-463
+//     void InMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << path() << ";$in: TODO ";
+//         MatchExpression::TagData* td = getTag();
+//         if (NULL != td) {
+//             debug << " ";
+//             td->debugString(&debug);
+//         }
+//         debug << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_leaf.cpp lines: 466-472
+//     bool InMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+//         const InMatchExpression* realOther = static_cast<const InMatchExpression*>( other );
+//         return
+//             path() == realOther->path() &&
+//             _arrayEntries.equivalent( realOther->_arrayEntries );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getArrayFilterEntries
+ * @param
+ *
+ */
+proto.getArrayFilterEntries = function getArrayFilterEntries( /*  */ ){
+// File: expression_leaf.h lines: 280-279
+//         ArrayFilterEntries* getArrayFilterEntries() { return &_arrayEntries; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getData
+ * @param
+ *
+ */
+proto.getData = function getData( /*  */ ){
+// File: expression_leaf.h lines: 290-289
+//         const ArrayFilterEntries& getData() const { return _arrayEntries; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path  */ ){
+
+// File: expression_leaf.cpp lines: 418-419
+//     Status InMatchExpression::init( const StringData& path ) {
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_leaf.cpp lines: 434-452
+//     bool InMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         if ( _arrayEntries.hasNull() && e.eoo() )
+//             return true;
+// 
+//         if ( _matchesRealElement( e ) )
+//             return true;
+// 
+//         /*
+//         if ( e.type() == Array ) {
+//             BSONObjIterator i( e.Obj() );
+//             while ( i.more() ) {
+//                 BSONElement sub = i.next();
+//                 if ( _matchesRealElement( sub ) )
+//                     return true;
+//             }
+//         }
+//         */
+// 
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+
+// File: expression_leaf.cpp lines: 475-478
+//     LeafMatchExpression* InMatchExpression::shallowClone() const {
+//         InMatchExpression* next = new InMatchExpression();
+//         copyTo( next );
+//         return next;
+//     }
+
+
+
+}

+ 130 - 0
lib/pipeline/matcher/IndexKeyMatchableDocument.js

@@ -0,0 +1,130 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var IndexKeyMatchableDocument = module.exports = function (){
+
+}, klass = IndexKeyMatchableDocument, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: matcher.cpp lines: 52-52
+//         BSONObj _doc;
+
+proto._doc = undefined;
+
+
+// File: matcher.cpp lines: 51-51
+//         BSONObj _pattern;
+
+proto._pattern = undefined;
+
+
+// File: matcher.cpp lines: 52-52
+//         BSONObj _doc;
+
+proto._doc = undefined;
+
+
+// File: matcher.cpp lines: 51-51
+//         BSONObj _pattern;
+
+proto._pattern = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method IndexKeyMatchableDocument
+ * @param
+ *
+ */
+proto.IndexKeyMatchableDocument = function IndexKeyMatchableDocument( /*  const BSONObj& pattern,$/;" */ ){
+
+// File: matcher.cpp lines: 34-36
+//         IndexKeyMatchableDocument( const BSONObj& pattern,
+//                                    const BSONObj& doc )
+//             : _pattern( pattern ), _doc( doc ) {
+//         }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _getElement
+ * @param
+ *
+ */
+proto._getElement = function _getElement( /*  const FieldRef& path  */ ){
+
+// File: matcher.cpp lines: 63-77
+//     BSONElement IndexKeyMatchableDocument::_getElement( const FieldRef& path ) const {
+//         BSONObjIterator patternIterator( _pattern );
+//         BSONObjIterator docIterator( _doc );
+// 
+//         while ( patternIterator.more() ) {
+//             BSONElement patternElement = patternIterator.next();
+//             verify( docIterator.more() );
+//             BSONElement docElement = docIterator.next();
+// 
+//             if ( path.equalsDottedField( patternElement.fieldName() ) ) {
+//                 return docElement;
+//             }
+//         }
+// 
+//         return BSONElement();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getIterator
+ * @param
+ *
+ */
+proto.getIterator = function getIterator( /*  const ElementPath& path  */ ){
+
+// File: matcher.cpp lines: 55-59
+//     ElementIterator* IndexKeyMatchableDocument::getIterator( const ElementPath& path ) const {
+//         BSONElement e = _getElement( path.fieldRef() );
+//         if ( e.type() == Array )
+//             return new SimpleArrayElementIterator( e, true );
+//         return new SingleElementElementIterator( e );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method toBSON
+ * @param
+ *
+ */
+proto.toBSON = function toBSON( /*  */ ){
+
+// File: matcher.cpp lines: 39-42
+//         BSONObj toBSON() const {
+//             // TODO: this isn't quite correct because of dots
+//             // don't think it'll ever be called though
+//             return _doc.replaceFieldNames( _pattern );
+//         }
+
+
+
+}

+ 49 - 0
lib/pipeline/matcher/LTEMatchExpression.js

@@ -0,0 +1,49 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var LTEMatchExpression = module.exports = function (){
+
+}, klass = LTEMatchExpression, 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 LTEMatchExpression
+ * @param
+ *
+ */
+proto.LTEMatchExpression = function LTEMatchExpression( /*  LTE  */ ){
+// File: expression_leaf.h lines: 107-106
+//         LTEMatchExpression() : ComparisonMatchExpression( LTE ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 108-111
+//         virtual LeafMatchExpression* shallowClone() const {
+//             ComparisonMatchExpression* e = new LTEMatchExpression();
+//             e->init( path(), _rhs  );
+//             return e;
+//         }
+
+
+
+
+}

+ 49 - 0
lib/pipeline/matcher/LTMatchExpression.js

@@ -0,0 +1,49 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var LTMatchExpression = module.exports = function (){
+
+}, klass = LTMatchExpression, 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 LTMatchExpression
+ * @param
+ *
+ */
+proto.LTMatchExpression = function LTMatchExpression( /*  LT  */ ){
+// File: expression_leaf.h lines: 118-117
+//         LTMatchExpression() : ComparisonMatchExpression( LT ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 119-122
+//         virtual LeafMatchExpression* shallowClone() const {
+//             ComparisonMatchExpression* e = new LTMatchExpression();
+//             e->init( path(), _rhs  );
+//             return e;
+//         }
+
+
+
+
+}

+ 137 - 0
lib/pipeline/matcher/LeafMatchExpression.js

@@ -0,0 +1,137 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var LeafMatchExpression = module.exports = function (){
+
+}, klass = LeafMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_leaf.h lines: 63-63
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_leaf.h lines: 62-62
+//         StringData _path;
+
+proto._path = undefined;
+
+
+// File: expression_leaf.h lines: 63-63
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_leaf.h lines: 62-62
+//         StringData _path;
+
+proto._path = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method LeafMatchExpression
+ * @param
+ *
+ */
+proto.LeafMatchExpression = function LeafMatchExpression( /*  MatchType matchType  */ ){
+// File: expression_leaf.h lines: 46-47
+//         LeafMatchExpression( MatchType matchType )
+//             : MatchExpression( matchType ) {
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method initPath
+ * @param
+ *
+ */
+proto.initPath = function initPath( /*  const StringData& path  */ ){
+
+// File: expression_leaf.cpp lines: 31-33
+//     Status LeafMatchExpression::initPath( const StringData& path ) {
+//         _path = path;
+//         return _elementPath.init( _path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
+
+// File: expression_leaf.cpp lines: 37-48
+//     bool LeafMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
+//         boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) );
+//         while ( cursor->more() ) {
+//             ElementIterator::Context e = cursor->next();
+//             if ( !matchesSingleElement( e.element() ) )
+//                 continue;
+//             if ( details && details->needRecord() && !e.arrayOffset().eoo() ) {
+//                 details->setElemMatchKey( e.arrayOffset().fieldName() );
+//             }
+//             return true;
+//         }
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method path
+ * @param
+ *
+ */
+proto.path = function path( /*  */ ){
+// File: expression_leaf.h lines: 56-55
+//         virtual const StringData path() const { return _path; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~LeafMatchExpression
+ * @param
+ *
+ */
+proto.~LeafMatchExpression = function ~LeafMatchExpression( /*  */ ){
+// File: expression_leaf.h lines: 50-49
+//         virtual ~LeafMatchExpression(){}
+
+
+
+
+}

+ 184 - 0
lib/pipeline/matcher/ListOfMatchExpression.js

@@ -0,0 +1,184 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ListOfMatchExpression = module.exports = function (){
+
+}, klass = ListOfMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_tree.h lines: 56-56
+//         std::vector< MatchExpression* > _expressions;
+
+proto._expressions = undefined;
+
+
+// File: expression_tree.h lines: 56-56
+//         std::vector< MatchExpression* > _expressions;
+
+proto._expressions = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ListOfMatchExpression
+ * @param
+ *
+ */
+proto.ListOfMatchExpression = function ListOfMatchExpression( /*  MatchType type  */ ){
+// File: expression_tree.h lines: 33-32
+//         ListOfMatchExpression( MatchType type ) : MatchExpression( type ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _debugList
+ * @param
+ *
+ */
+proto._debugList = function _debugList( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_tree.cpp lines: 40-42
+//     void ListOfMatchExpression::_debugList( StringBuilder& debug, int level ) const {
+//         for ( unsigned i = 0; i < _expressions.size(); i++ )
+//             _expressions[i]->debugString( debug, level + 1 );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method add
+ * @param
+ *
+ */
+proto.add = function add( /*  MatchExpression* e  */ ){
+
+// File: expression_tree.cpp lines: 34-36
+//     void ListOfMatchExpression::add( MatchExpression* e ) {
+//         verify( e );
+//         _expressions.push_back( e );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method clearAndRelease
+ * @param
+ *
+ */
+proto.clearAndRelease = function clearAndRelease( /*  */ ){
+// File: expression_tree.h lines: 45-44
+//         void clearAndRelease() { _expressions.clear(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_tree.cpp lines: 45-59
+//     bool ListOfMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const ListOfMatchExpression* realOther = static_cast<const ListOfMatchExpression*>( other );
+// 
+//         if ( _expressions.size() != realOther->_expressions.size() )
+//             return false;
+// 
+//         // TOOD: order doesn't matter
+//         for ( unsigned i = 0; i < _expressions.size(); i++ )
+//             if ( !_expressions[i]->equivalent( realOther->_expressions[i] ) )
+//                 return false;
+// 
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getChild
+ * @param
+ *
+ */
+proto.getChild = function getChild( /*  size_t i  */ ){
+// File: expression_tree.h lines: 48-47
+//         virtual const MatchExpression* getChild( size_t i ) const { return _expressions[i]; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method numChildren
+ * @param
+ *
+ */
+proto.numChildren = function numChildren( /*  */ ){
+// File: expression_tree.h lines: 47-46
+//         virtual size_t numChildren() const { return _expressions.size(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~ListOfMatchExpression
+ * @param
+ *
+ */
+proto.~ListOfMatchExpression = function ~ListOfMatchExpression( /*  */ ){
+
+// File: expression_tree.cpp lines: 28-31
+//     ListOfMatchExpression::~ListOfMatchExpression() {
+//         for ( unsigned i = 0; i < _expressions.size(); i++ )
+//             delete _expressions[i];
+//         _expressions.clear();
+//     }
+
+
+
+}

+ 238 - 0
lib/pipeline/matcher/MatchDetails.js

@@ -0,0 +1,238 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var MatchDetails = module.exports = function (){
+
+}, klass = MatchDetails, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: match_details.h lines: 60-60
+//         boost::scoped_ptr<std::string> _elemMatchKey;
+
+proto._elemMatchKey = undefined;
+
+
+// File: match_details.h lines: 59-59
+//         bool _elemMatchKeyRequested;
+
+proto._elemMatchKeyRequested = undefined;
+
+
+// File: match_details.h lines: 58-58
+//         bool _loadedRecord;
+
+proto._loadedRecord = undefined;
+
+
+// File: match_details.h lines: 60-60
+//         boost::scoped_ptr<std::string> _elemMatchKey;
+
+proto._elemMatchKey = undefined;
+
+
+// File: match_details.h lines: 59-59
+//         bool _elemMatchKeyRequested;
+
+proto._elemMatchKeyRequested = undefined;
+
+
+// File: match_details.h lines: 58-58
+//         bool _loadedRecord;
+
+proto._loadedRecord = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method MatchDetails
+ * @param
+ *
+ */
+proto.MatchDetails = function MatchDetails( /*  */ ){
+
+// File: match_details.cpp lines: 27-29
+//     MatchDetails::MatchDetails() :
+//         _elemMatchKeyRequested() {
+//         resetOutput();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method elemMatchKey
+ * @param
+ *
+ */
+proto.elemMatchKey = function elemMatchKey( /*  */ ){
+
+// File: match_details.cpp lines: 41-43
+//     std::string MatchDetails::elemMatchKey() const {
+//         verify( hasElemMatchKey() );
+//         return *(_elemMatchKey.get());
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method hasElemMatchKey
+ * @param
+ *
+ */
+proto.hasElemMatchKey = function hasElemMatchKey( /*  */ ){
+
+// File: match_details.cpp lines: 37-38
+//     bool MatchDetails::hasElemMatchKey() const {
+//         return _elemMatchKey.get();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method hasLoadedRecord
+ * @param
+ *
+ */
+proto.hasLoadedRecord = function hasLoadedRecord( /*  */ ){
+// File: match_details.h lines: 41-40
+//         bool hasLoadedRecord() const { return _loadedRecord; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method needRecord
+ * @param
+ *
+ */
+proto.needRecord = function needRecord( /*  */ ){
+// File: match_details.h lines: 45-44
+//         bool needRecord() const { return _elemMatchKeyRequested; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method requestElemMatchKey
+ * @param
+ *
+ */
+proto.requestElemMatchKey = function requestElemMatchKey( /*  */ ){
+// File: match_details.h lines: 50-49
+//         void requestElemMatchKey() { _elemMatchKeyRequested = true; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method resetOutput
+ * @param
+ *
+ */
+proto.resetOutput = function resetOutput( /*  */ ){
+
+// File: match_details.cpp lines: 32-34
+//     void MatchDetails::resetOutput() {
+//         _loadedRecord = false;
+//         _elemMatchKey.reset();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method setElemMatchKey
+ * @param
+ *
+ */
+proto.setElemMatchKey = function setElemMatchKey( /*  const std::string &elemMatchKey  */ ){
+
+// File: match_details.cpp lines: 46-49
+//     void MatchDetails::setElemMatchKey( const std::string &elemMatchKey ) {
+//         if ( _elemMatchKeyRequested ) {
+//             _elemMatchKey.reset( new std::string( elemMatchKey ) );
+//         }
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method setLoadedRecord
+ * @param
+ *
+ */
+proto.setLoadedRecord = function setLoadedRecord( /*  bool loadedRecord  */ ){
+// File: match_details.h lines: 39-38
+//         void setLoadedRecord( bool loadedRecord ) { _loadedRecord = loadedRecord; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method toString
+ * @param
+ *
+ */
+proto.toString = function toString( /*  */ ){
+
+// File: match_details.cpp lines: 52-57
+//     string MatchDetails::toString() const {
+//         std::stringstream ss;
+//         ss << "loadedRecord: " << _loadedRecord << " ";
+//         ss << "elemMatchKeyRequested: " << _elemMatchKeyRequested << " ";
+//         ss << "elemMatchKey: " << ( _elemMatchKey ? _elemMatchKey->c_str() : "NONE" ) << " ";
+//         return ss.str();
+//     }
+
+
+
+}

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

@@ -0,0 +1,291 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var MatchExpression = module.exports = function (){
+
+}, klass = MatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression.h lines: 172-172
+//         MatchType _matchType;
+
+proto._matchType = undefined;
+
+
+// File: expression.h lines: 173-173
+//         boost::scoped_ptr<TagData> _tagData;
+
+proto._tagData = undefined;
+
+
+// File: expression.h lines: 172-172
+//         MatchType _matchType;
+
+proto._matchType = undefined;
+
+
+// File: expression.h lines: 173-173
+//         boost::scoped_ptr<TagData> _tagData;
+
+proto._tagData = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method MatchExpression
+ * @param
+ *
+ */
+proto.MatchExpression = function MatchExpression( /*  MatchType type  */ ){
+
+// File: expression.cpp lines: 28-28
+//     MatchExpression::MatchExpression( MatchType type )
+//         : _matchType( type ) { }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _debugAddSpace
+ * @param
+ *
+ */
+proto._debugAddSpace = function _debugAddSpace( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression.cpp lines: 37-39
+//     void MatchExpression::_debugAddSpace( StringBuilder& debug, int level ) const {
+//         for ( int i = 0; i < level; i++ )
+//             debug << "    ";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getChild
+ * @param
+ *
+ */
+proto.getChild = function getChild( /*  size_t i  */ ){
+// File: expression.h lines: 78-77
+//         virtual const MatchExpression* getChild( size_t i ) const { return NULL; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getTag
+ * @param
+ *
+ */
+proto.getTag = function getTag( /*  */ ){
+// File: expression.h lines: 159-158
+//         TagData* getTag() const { return _tagData.get(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method isArray
+ * @param
+ *
+ */
+proto.isArray = function isArray( /*  */ ){
+// File: expression.h lines: 111-113
+//         bool isArray() const {
+//             return SIZE == _matchType || ALL == _matchType || ELEM_MATCH_VALUE == _matchType
+//                    || ELEM_MATCH_OBJECT == _matchType;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method isLeaf
+ * @param
+ *
+ */
+proto.isLeaf = function isLeaf( /*  */ ){
+// File: expression.h lines: 124-125
+//         bool isLeaf() const {
+//             return !isArray() && !isLogical();
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method isLogical
+ * @param
+ *
+ */
+proto.isLogical = function isLogical( /*  */ ){
+// File: expression.h lines: 100-101
+//         bool isLogical() const {
+//             return AND == _matchType || OR == _matchType || NOT == _matchType || NOR == _matchType;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchType
+ * @param
+ *
+ */
+proto.matchType = function matchType( /*  */ ){
+// File: expression.h lines: 67-66
+//         MatchType matchType() const { return _matchType; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesBSON
+ * @param
+ *
+ */
+proto.matchesBSON = function matchesBSON( /*  const BSONObj& doc, MatchDetails* details  */ ){
+
+// File: expression.cpp lines: 42-44
+//     bool MatchExpression::matchesBSON( const BSONObj& doc, MatchDetails* details ) const {
+//         BSONMatchableDocument mydoc( doc );
+//         return matches( &mydoc, details );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method numChildren
+ * @param
+ *
+ */
+proto.numChildren = function numChildren( /*  */ ){
+// File: expression.h lines: 73-72
+//         virtual size_t numChildren() const { return 0; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method path
+ * @param
+ *
+ */
+proto.path = function path( /*  */ ){
+// File: expression.h lines: 83-82
+//         virtual const StringData path() const { return StringData(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method setTag
+ * @param
+ *
+ */
+proto.setTag = function setTag( /* TagData* data */ ){
+// File: expression.h lines: 158-157
+//         void setTag(TagData* data) { _tagData.reset(data); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method toString
+ * @param
+ *
+ */
+proto.toString = function toString( /*  */ ){
+
+// File: expression.cpp lines: 31-34
+//     string MatchExpression::toString() const {
+//         StringBuilder buf;
+//         debugString( buf, 0 );
+//         return buf.str();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~MatchExpression
+ * @param
+ *
+ */
+proto.~MatchExpression = function ~MatchExpression( /*  */ ){
+// File: expression.h lines: 58-57
+//         virtual ~MatchExpression(){}
+
+
+
+
+}

+ 836 - 0
lib/pipeline/matcher/MatchExpressionParser.js

@@ -0,0 +1,836 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var MatchExpressionParser = module.exports = function (){
+
+}, klass = MatchExpressionParser, 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 _isExpressionDocument
+ * @param
+ *
+ */
+proto._isExpressionDocument = function _isExpressionDocument( /*  const BSONElement& e  */ ){
+
+// File: expression_parser.cpp lines: 340-355
+//     bool MatchExpressionParser::_isExpressionDocument( const BSONElement& e ) {
+//         if ( e.type() != Object )
+//             return false;
+// 
+//         BSONObj o = e.Obj();
+//         if ( o.isEmpty() )
+//             return false;
+// 
+//         const char* name = o.firstElement().fieldName();
+//         if ( name[0] != '$' )
+//             return false;
+// 
+//         if ( mongoutils::str::equals( "$ref", name ) )
+//             return false;
+// 
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parse
+ * @param
+ *
+ */
+proto._parse = function _parse( /*  const BSONObj& obj, bool topLevel  */ ){
+
+// File: expression_parser.cpp lines: 217-319
+//     StatusWithMatchExpression MatchExpressionParser::_parse( const BSONObj& obj, bool topLevel ) {
+// 
+//         std::auto_ptr<AndMatchExpression> root( new AndMatchExpression() );
+// 
+//         BSONObjIterator i( obj );
+//         while ( i.more() ){
+// 
+//             BSONElement e = i.next();
+//             if ( e.fieldName()[0] == '$' ) {
+//                 const char * rest = e.fieldName() + 1;
+// 
+//                 // TODO: optimize if block?
+//                 if ( mongoutils::str::equals( "or", rest ) ) {
+//                     if ( e.type() != Array )
+//                         return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                      "$or needs an array" );
+//                     std::auto_ptr<OrMatchExpression> temp( new OrMatchExpression() );
+//                     Status s = _parseTreeList( e.Obj(), temp.get() );
+//                     if ( !s.isOK() )
+//                         return StatusWithMatchExpression( s );
+//                     root->add( temp.release() );
+//                 }
+//                 else if ( mongoutils::str::equals( "and", rest ) ) {
+//                     if ( e.type() != Array )
+//                         return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                      "and needs an array" );
+//                     std::auto_ptr<AndMatchExpression> temp( new AndMatchExpression() );
+//                     Status s = _parseTreeList( e.Obj(), temp.get() );
+//                     if ( !s.isOK() )
+//                         return StatusWithMatchExpression( s );
+//                     root->add( temp.release() );
+//                 }
+//                 else if ( mongoutils::str::equals( "nor", rest ) ) {
+//                     if ( e.type() != Array )
+//                         return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                      "and needs an array" );
+//                     std::auto_ptr<NorMatchExpression> temp( new NorMatchExpression() );
+//                     Status s = _parseTreeList( e.Obj(), temp.get() );
+//                     if ( !s.isOK() )
+//                         return StatusWithMatchExpression( s );
+//                     root->add( temp.release() );
+//                 }
+//                 else if ( mongoutils::str::equals( "atomic", rest ) || 
+//                           mongoutils::str::equals( "isolated", rest ) ) {
+//                     if ( !topLevel )
+//                         return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                           "$atomic/$isolated has to be at the top level" );
+//                     if ( e.trueValue() )
+//                         root->add( new AtomicMatchExpression() );
+//                 }
+//                 else if ( mongoutils::str::equals( "where", rest ) ) {
+//                     /*
+//                     if ( !topLevel )
+//                         return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                           "$where has to be at the top level" );
+//                     */
+//                     StatusWithMatchExpression s = expressionParserWhereCallback( e );
+//                     if ( !s.isOK() )
+//                         return s;
+//                     root->add( s.getValue() );
+//                 }
+//                 else if ( mongoutils::str::equals( "comment", rest ) ) {
+//                 }
+//                 else {
+//                     return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                  mongoutils::str::stream()
+//                                                  << "unknown top level operator: "
+//                                                  << e.fieldName() );
+//                 }
+// 
+//                 continue;
+//             }
+// 
+//             if ( _isExpressionDocument( e ) ) {
+//                 Status s = _parseSub( e.fieldName(), e.Obj(), root.get() );
+//                 if ( !s.isOK() )
+//                     return StatusWithMatchExpression( s );
+//                 continue;
+//             }
+// 
+//             if ( e.type() == RegEx ) {
+//                 StatusWithMatchExpression result = _parseRegexElement( e.fieldName(), e );
+//                 if ( !result.isOK() )
+//                     return result;
+//                 root->add( result.getValue() );
+//                 continue;
+//             }
+// 
+//             std::auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
+//             Status s = eq->init( e.fieldName(), e );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+// 
+//             root->add( eq.release() );
+//         }
+// 
+//         if ( root->numChildren() == 1 ) {
+//             const MatchExpression* real = root->getChild(0);
+//             root->clearAndRelease();
+//             return StatusWithMatchExpression( const_cast<MatchExpression*>(real) );
+//         }
+// 
+//         return StatusWithMatchExpression( root.release() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseAll
+ * @param
+ *
+ */
+proto._parseAll = function _parseAll( /*  const char* name,$/;" */ ){
+
+// File: expression_parser.cpp lines: 512-583
+//     StatusWithMatchExpression MatchExpressionParser::_parseAll( const char* name,
+//                                                       const BSONElement& e ) {
+//         if ( e.type() != Array )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "$all needs an array" );
+// 
+//         BSONObj arr = e.Obj();
+//         if ( arr.firstElement().type() == Object &&
+//              mongoutils::str::equals( "$elemMatch",
+//                                       arr.firstElement().Obj().firstElement().fieldName() ) ) {
+//             // $all : [ { $elemMatch : {} } ... ]
+// 
+//             std::auto_ptr<AllElemMatchOp> temp( new AllElemMatchOp() );
+//             Status s = temp->init( name );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+// 
+//             BSONObjIterator i( arr );
+//             while ( i.more() ) {
+//                 BSONElement hopefullyElemMatchElement = i.next();
+// 
+//                 if ( hopefullyElemMatchElement.type() != Object ) {
+//                     // $all : [ { $elemMatch : ... }, 5 ]
+//                     return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                  "$all/$elemMatch has to be consistent" );
+//                 }
+// 
+//                 BSONObj hopefullyElemMatchObj = hopefullyElemMatchElement.Obj();
+//                 if ( !mongoutils::str::equals( "$elemMatch",
+//                                                hopefullyElemMatchObj.firstElement().fieldName() ) ) {
+//                     // $all : [ { $elemMatch : ... }, { x : 5 } ]
+//                     return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                  "$all/$elemMatch has to be consistent" );
+//                 }
+// 
+//                 StatusWithMatchExpression inner = _parseElemMatch( "", hopefullyElemMatchObj.firstElement() );
+//                 if ( !inner.isOK() )
+//                     return inner;
+//                 temp->add( static_cast<ArrayMatchingMatchExpression*>( inner.getValue() ) );
+//             }
+// 
+//             return StatusWithMatchExpression( temp.release() );
+//         }
+// 
+//         std::auto_ptr<AndMatchExpression> myAnd( new AndMatchExpression() );
+//         BSONObjIterator i( arr );
+//         while ( i.more() ) {
+//             BSONElement e = i.next();
+// 
+//             if ( e.type() == RegEx ) {
+//                 std::auto_ptr<RegexMatchExpression> r( new RegexMatchExpression() );
+//                 Status s = r->init( name, e );
+//                 if ( !s.isOK() )
+//                     return StatusWithMatchExpression( s );
+//                 myAnd->add( r.release() );
+//             }
+//             else if ( e.type() == Object && e.Obj().firstElement().getGtLtOp(-1) != -1 ) {
+//                 return StatusWithMatchExpression( ErrorCodes::BadValue, "no $ expressions in $all" );
+//             }
+//             else {
+//                 std::auto_ptr<EqualityMatchExpression> x( new EqualityMatchExpression() );
+//                 Status s = x->init( name, e );
+//                 if ( !s.isOK() )
+//                     return StatusWithMatchExpression( s );
+//                 myAnd->add( x.release() );
+//             }
+//         }
+// 
+//         if ( myAnd->numChildren() == 0 ) {
+//             return StatusWithMatchExpression( new FalseMatchExpression() );
+//         }
+// 
+//         return StatusWithMatchExpression( myAnd.release() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseArrayFilterEntries
+ * @param
+ *
+ */
+proto._parseArrayFilterEntries = function _parseArrayFilterEntries( /*  ArrayFilterEntries* entries,$/;" */ ){
+
+// File: expression_parser.cpp lines: 445-468
+//     Status MatchExpressionParser::_parseArrayFilterEntries( ArrayFilterEntries* entries,
+//                                                             const BSONObj& theArray ) {
+// 
+//         BSONObjIterator i( theArray );
+//         while ( i.more() ) {
+//             BSONElement e = i.next();
+// 
+//             if ( e.type() == RegEx ) {
+//                 std::auto_ptr<RegexMatchExpression> r( new RegexMatchExpression() );
+//                 Status s = r->init( "", e );
+//                 if ( !s.isOK() )
+//                     return s;
+//                 s =  entries->addRegex( r.release() );
+//                 if ( !s.isOK() )
+//                     return s;
+//             }
+//             else {
+//                 Status s = entries->addEquality( e );
+//                 if ( !s.isOK() )
+//                     return s;
+//             }
+//         }
+//         return Status::OK();
+// 
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseComparison
+ * @param
+ *
+ */
+proto._parseComparison = function _parseComparison( /*  const char* name,$/;" */ ){
+
+// File: expression_parser.cpp lines: 34-43
+//     StatusWithMatchExpression MatchExpressionParser::_parseComparison( const char* name,
+//                                                                        ComparisonMatchExpression* cmp,
+//                                                                        const BSONElement& e ) {
+//         std::auto_ptr<ComparisonMatchExpression> temp( cmp );
+// 
+//         Status s = temp->init( name, e );
+//         if ( !s.isOK() )
+//             return StatusWithMatchExpression(s);
+// 
+//         return StatusWithMatchExpression( temp.release() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseElemMatch
+ * @param
+ *
+ */
+proto._parseElemMatch = function _parseElemMatch( /*  const char* name,$/;" */ ){
+
+// File: expression_parser.cpp lines: 471-509
+//     StatusWithMatchExpression MatchExpressionParser::_parseElemMatch( const char* name,
+//                                                             const BSONElement& e ) {
+//         if ( e.type() != Object )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "$elemMatch needs an Object" );
+// 
+//         BSONObj obj = e.Obj();
+//         if ( _isExpressionDocument( e ) ) {
+//             // value case
+// 
+//             AndMatchExpression theAnd;
+//             Status s = _parseSub( "", obj, &theAnd );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+// 
+//             std::auto_ptr<ElemMatchValueMatchExpression> temp( new ElemMatchValueMatchExpression() );
+//             s = temp->init( name );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+// 
+//             for ( size_t i = 0; i < theAnd.numChildren(); i++ ) {
+//                 temp->add( theAnd.getChild( i ) );
+//             }
+//             theAnd.clearAndRelease();
+// 
+//             return StatusWithMatchExpression( temp.release() );
+//         }
+// 
+//         // object case
+// 
+//         StatusWithMatchExpression sub = _parse( obj, false );
+//         if ( !sub.isOK() )
+//             return sub;
+// 
+//         std::auto_ptr<ElemMatchObjectMatchExpression> temp( new ElemMatchObjectMatchExpression() );
+//         Status status = temp->init( name, sub.getValue() );
+//         if ( !status.isOK() )
+//             return StatusWithMatchExpression( status );
+// 
+//         return StatusWithMatchExpression( temp.release() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseMOD
+ * @param
+ *
+ */
+proto._parseMOD = function _parseMOD( /*  const char* name,$/;" */ ){
+
+// File: expression_parser.cpp lines: 360-387
+//     StatusWithMatchExpression MatchExpressionParser::_parseMOD( const char* name,
+//                                                       const BSONElement& e ) {
+// 
+//         if ( e.type() != Array )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, needs to be an array" );
+// 
+//         BSONObjIterator i( e.Obj() );
+// 
+//         if ( !i.more() )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, not enough elements" );
+//         BSONElement d = i.next();
+//         if ( !d.isNumber() )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, divisor not a number" );
+// 
+//         if ( !i.more() )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, not enough elements" );
+//         BSONElement r = i.next();
+//         if ( !d.isNumber() )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, remainder not a number" );
+// 
+//         if ( i.more() )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, too many elements" );
+// 
+//         std::auto_ptr<ModMatchExpression> temp( new ModMatchExpression() );
+//         Status s = temp->init( name, d.numberInt(), r.numberInt() );
+//         if ( !s.isOK() )
+//             return StatusWithMatchExpression( s );
+//         return StatusWithMatchExpression( temp.release() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseNot
+ * @param
+ *
+ */
+proto._parseNot = function _parseNot( /*  const char* name,$/;" */ ){
+
+// File: expression_parser_tree.cpp lines: 55-91
+//     StatusWithMatchExpression MatchExpressionParser::_parseNot( const char* name,
+//                                                       const BSONElement& e ) {
+//         if ( e.type() == RegEx ) {
+//             StatusWithMatchExpression s = _parseRegexElement( name, e );
+//             if ( !s.isOK() )
+//                 return s;
+//             std::auto_ptr<NotMatchExpression> n( new NotMatchExpression() );
+//             Status s2 = n->init( s.getValue() );
+//             if ( !s2.isOK() )
+//                 return StatusWithMatchExpression( s2 );
+//             return StatusWithMatchExpression( n.release() );
+//         }
+// 
+//         if ( e.type() != Object )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "$not needs a regex or a document" );
+// 
+//         BSONObj notObject = e.Obj();
+//         if ( notObject.isEmpty() )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "$not cannot be empty" );
+// 
+//         std::auto_ptr<AndMatchExpression> theAnd( new AndMatchExpression() );
+//         Status s = _parseSub( name, notObject, theAnd.get() );
+//         if ( !s.isOK() )
+//             return StatusWithMatchExpression( s );
+// 
+//         // TODO: this seems arbitrary?
+//         // tested in jstests/not2.js
+//         for ( unsigned i = 0; i < theAnd->numChildren(); i++ )
+//             if ( theAnd->getChild(i)->matchType() == MatchExpression::REGEX )
+//                 return StatusWithMatchExpression( ErrorCodes::BadValue, "$not cannot have a regex" );
+// 
+//         std::auto_ptr<NotMatchExpression> theNot( new NotMatchExpression() );
+//         s = theNot->init( theAnd.release() );
+//         if ( !s.isOK() )
+//             return StatusWithMatchExpression( s );
+// 
+//         return StatusWithMatchExpression( theNot.release() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseRegexDocument
+ * @param
+ *
+ */
+proto._parseRegexDocument = function _parseRegexDocument( /*  const char* name,$/;" */ ){
+
+// File: expression_parser.cpp lines: 402-442
+//     StatusWithMatchExpression MatchExpressionParser::_parseRegexDocument( const char* name,
+//                                                                 const BSONObj& doc ) {
+//         string regex;
+//         string regexOptions;
+// 
+//         BSONObjIterator i( doc );
+//         while ( i.more() ) {
+//             BSONElement e = i.next();
+//             switch ( e.getGtLtOp() ) {
+//             case BSONObj::opREGEX:
+//                 if ( e.type() == String ) {
+//                     regex = e.String();
+//                 }
+//                 else if ( e.type() == RegEx ) {
+//                     regex = e.regex();
+//                     regexOptions = e.regexFlags();
+//                 }
+//                 else {
+//                     return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                       "$regex has to be a string" );
+//                 }
+// 
+//                 break;
+//             case BSONObj::opOPTIONS:
+//                 if ( e.type() != String )
+//                     return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                                       "$options has to be a string" );
+//                 regexOptions = e.String();
+//                 break;
+//             default:
+//                 break;
+//             }
+// 
+//         }
+// 
+//         std::auto_ptr<RegexMatchExpression> temp( new RegexMatchExpression() );
+//         Status s = temp->init( name, regex, regexOptions );
+//         if ( !s.isOK() )
+//             return StatusWithMatchExpression( s );
+//         return StatusWithMatchExpression( temp.release() );
+// 
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseRegexElement
+ * @param
+ *
+ */
+proto._parseRegexElement = function _parseRegexElement( /*  const char* name,$/;" */ ){
+
+// File: expression_parser.cpp lines: 390-399
+//     StatusWithMatchExpression MatchExpressionParser::_parseRegexElement( const char* name,
+//                                                                const BSONElement& e ) {
+//         if ( e.type() != RegEx )
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "not a regex" );
+// 
+//         std::auto_ptr<RegexMatchExpression> temp( new RegexMatchExpression() );
+//         Status s = temp->init( name, e.regex(), e.regexFlags() );
+//         if ( !s.isOK() )
+//             return StatusWithMatchExpression( s );
+//         return StatusWithMatchExpression( temp.release() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseSub
+ * @param
+ *
+ */
+proto._parseSub = function _parseSub( /*  const char* name,$/;" */ ){
+
+// File: expression_parser.cpp lines: 322-337
+//     Status MatchExpressionParser::_parseSub( const char* name,
+//                                              const BSONObj& sub,
+//                                              AndMatchExpression* root ) {
+//         BSONObjIterator j( sub );
+//         while ( j.more() ) {
+//             BSONElement deep = j.next();
+// 
+//             StatusWithMatchExpression s = _parseSubField( sub, root, name, deep );
+//             if ( !s.isOK() )
+//                 return s.getStatus();
+// 
+//             if ( s.getValue() )
+//                 root->add( s.getValue() );
+//         }
+// 
+//         return Status::OK();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseSubField
+ * @param
+ *
+ */
+proto._parseSubField = function _parseSubField( /*  const BSONObj& context,$/;" */ ){
+
+// File: expression_parser.cpp lines: 46-214
+//     StatusWithMatchExpression MatchExpressionParser::_parseSubField( const BSONObj& context,
+//                                                                      const AndMatchExpression* andSoFar,
+//                                                                      const char* name,
+//                                                                      const BSONElement& e ) {
+// 
+//         // TODO: these should move to getGtLtOp, or its replacement
+// 
+//         if ( mongoutils::str::equals( "$eq", e.fieldName() ) )
+//             return _parseComparison( name, new EqualityMatchExpression(), e );
+// 
+//         if ( mongoutils::str::equals( "$not", e.fieldName() ) ) {
+//             return _parseNot( name, e );
+//         }
+// 
+//         int x = e.getGtLtOp(-1);
+//         switch ( x ) {
+//         case -1:
+//             return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                               mongoutils::str::stream() << "unknown operator: "
+//                                               << e.fieldName() );
+//         case BSONObj::LT:
+//             return _parseComparison( name, new LTMatchExpression(), e );
+//         case BSONObj::LTE:
+//             return _parseComparison( name, new LTEMatchExpression(), e );
+//         case BSONObj::GT:
+//             return _parseComparison( name, new GTMatchExpression(), e );
+//         case BSONObj::GTE:
+//             return _parseComparison( name, new GTEMatchExpression(), e );
+//         case BSONObj::NE: {
+//             StatusWithMatchExpression s = _parseComparison( name, new EqualityMatchExpression(), e );
+//             if ( !s.isOK() )
+//                 return s;
+//             std::auto_ptr<NotMatchExpression> n( new NotMatchExpression() );
+//             Status s2 = n->init( s.getValue() );
+//             if ( !s2.isOK() )
+//                 return StatusWithMatchExpression( s2 );
+//             return StatusWithMatchExpression( n.release() );
+//         }
+//         case BSONObj::Equality:
+//             return _parseComparison( name, new EqualityMatchExpression(), e );
+// 
+//         case BSONObj::opIN: {
+//             if ( e.type() != Array )
+//                 return StatusWithMatchExpression( ErrorCodes::BadValue, "$in needs an array" );
+//             std::auto_ptr<InMatchExpression> temp( new InMatchExpression() );
+//             Status s = temp->init( name );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+//             s = _parseArrayFilterEntries( temp->getArrayFilterEntries(), e.Obj() );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+//             return StatusWithMatchExpression( temp.release() );
+//         }
+// 
+//         case BSONObj::NIN: {
+//             if ( e.type() != Array )
+//                 return StatusWithMatchExpression( ErrorCodes::BadValue, "$nin needs an array" );
+//             std::auto_ptr<InMatchExpression> temp( new InMatchExpression() );
+//             Status s = temp->init( name );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+//             s = _parseArrayFilterEntries( temp->getArrayFilterEntries(), e.Obj() );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+// 
+//             std::auto_ptr<NotMatchExpression> temp2( new NotMatchExpression() );
+//             s = temp2->init( temp.release() );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+// 
+//             return StatusWithMatchExpression( temp2.release() );
+//         }
+// 
+//         case BSONObj::opSIZE: {
+//             int size = 0;
+//             if ( e.type() == String ) {
+//                 // matching old odd semantics
+//                 size = 0;
+//             }
+//             else if ( e.type() == NumberInt || e.type() == NumberLong ) {
+//                 size = e.numberInt();
+//             }
+//             else if ( e.type() == NumberDouble ) {
+//                 if ( e.numberInt() == e.numberDouble() ) {
+//                     size = e.numberInt();
+//                 }
+//                 else {
+//                     // old semantcs require exact numeric match
+//                     // so [1,2] != 1 or 2
+//                     size = -1;
+//                 }
+//             }
+//             else {
+//                 return StatusWithMatchExpression( ErrorCodes::BadValue, "$size needs a number" );
+//             }
+// 
+//             std::auto_ptr<SizeMatchExpression> temp( new SizeMatchExpression() );
+//             Status s = temp->init( name, size );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+//             return StatusWithMatchExpression( temp.release() );
+//         }
+// 
+//         case BSONObj::opEXISTS: {
+//             if ( e.eoo() )
+//                 return StatusWithMatchExpression( ErrorCodes::BadValue, "$exists can't be eoo" );
+//             std::auto_ptr<ExistsMatchExpression> temp( new ExistsMatchExpression() );
+//             Status s = temp->init( name );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+//             if ( e.trueValue() )
+//                 return StatusWithMatchExpression( temp.release() );
+//             std::auto_ptr<NotMatchExpression> temp2( new NotMatchExpression() );
+//             s = temp2->init( temp.release() );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+//             return StatusWithMatchExpression( temp2.release() );
+//         }
+// 
+//         case BSONObj::opTYPE: {
+//             if ( !e.isNumber() )
+//                 return StatusWithMatchExpression( ErrorCodes::BadValue, "$type has to be a number" );
+//             int type = e.numberInt();
+//             if ( e.type() != NumberInt && type != e.number() )
+//                 type = -1;
+//             std::auto_ptr<TypeMatchExpression> temp( new TypeMatchExpression() );
+//             Status s = temp->init( name, type );
+//             if ( !s.isOK() )
+//                 return StatusWithMatchExpression( s );
+//             return StatusWithMatchExpression( temp.release() );
+//         }
+// 
+// 
+//         case BSONObj::opMOD:
+//             return _parseMOD( name, e );
+// 
+//         case BSONObj::opOPTIONS: {
+//             // TODO: try to optimize this
+//             // we have to do this since $options can be before or after a $regex
+//             // but we validate here
+//             BSONObjIterator i( context );
+//             while ( i.more() ) {
+//                 BSONElement temp = i.next();
+//                 if ( temp.getGtLtOp( -1 ) == BSONObj::opREGEX )
+//                     return StatusWithMatchExpression( NULL );
+//             }
+// 
+//             return StatusWithMatchExpression( ErrorCodes::BadValue, "$options needs a $regex" );
+//         }
+// 
+//         case BSONObj::opREGEX: {
+//             return _parseRegexDocument( name, context );
+//         }
+// 
+//         case BSONObj::opELEM_MATCH:
+//             return _parseElemMatch( name, e );
+// 
+//         case BSONObj::opALL:
+//             return _parseAll( name, e );
+// 
+//         case BSONObj::opWITHIN:
+//         case BSONObj::opGEO_INTERSECTS:
+//         case BSONObj::opNEAR:
+//             return expressionParserGeoCallback( name, x, context );
+// 
+//         }
+// 
+//         return StatusWithMatchExpression( ErrorCodes::BadValue,
+//                                           mongoutils::str::stream() << "not handled: " << e.fieldName() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _parseTreeList
+ * @param
+ *
+ */
+proto._parseTreeList = function _parseTreeList( /*  const BSONObj& arr, ListOfMatchExpression* out  */ ){
+
+// File: expression_parser_tree.cpp lines: 33-52
+//     Status MatchExpressionParser::_parseTreeList( const BSONObj& arr, ListOfMatchExpression* out ) {
+//         if ( arr.isEmpty() )
+//             return Status( ErrorCodes::BadValue,
+//                            "$and/$or/$nor must be a nonempty array" );
+// 
+//         BSONObjIterator i( arr );
+//         while ( i.more() ) {
+//             BSONElement e = i.next();
+// 
+//             if ( e.type() != Object )
+//                 return Status( ErrorCodes::BadValue,
+//                                "$or/$and/$nor entries need to be full objects" );
+// 
+//             StatusWithMatchExpression sub = _parse( e.Obj(), false );
+//             if ( !sub.isOK() )
+//                 return sub.getStatus();
+// 
+//             out->add( sub.getValue() );
+//         }
+//         return Status::OK();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method parse
+ * @param
+ *
+ */
+proto.parse = function parse( /*  const BSONObj& obj  */ ){
+// File: expression_parser.h lines: 40-41
+//         static StatusWithMatchExpression parse( const BSONObj& obj ) {
+//             return _parse( obj, true );
+//         }
+
+
+
+
+}

+ 29 - 0
lib/pipeline/matcher/MatchableDocument.js

@@ -0,0 +1,29 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var MatchableDocument = module.exports = function (){
+
+}, klass = MatchableDocument, 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 ~MatchableDocument
+ * @param
+ *
+ */
+proto.~MatchableDocument = function ~MatchableDocument( /*  */ ){
+
+// File: matchable.cpp lines: 25-25
+//     MatchableDocument::~MatchableDocument(){
+//     }
+
+
+
+}

+ 448 - 0
lib/pipeline/matcher/Matcher2.js

@@ -0,0 +1,448 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var Matcher2 = module.exports = function (){
+
+}, klass = Matcher2, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: matcher.h lines: 82-82
+//         boost::scoped_ptr<MatchExpression> _expression;
+
+proto._expression = undefined;
+
+
+// File: matcher.h lines: 80-80
+//         BSONObj _indexKey;
+
+proto._indexKey = undefined;
+
+
+// File: matcher.h lines: 79-79
+//         BSONObj _pattern;
+
+proto._pattern = undefined;
+
+
+// File: matcher.h lines: 84-84
+//         IndexSpliceInfo _spliceInfo;
+
+proto._spliceInfo = undefined;
+
+
+// File: matcher.h lines: 82-82
+//         boost::scoped_ptr<MatchExpression> _expression;
+
+proto._expression = undefined;
+
+
+// File: matcher.h lines: 80-80
+//         BSONObj _indexKey;
+
+proto._indexKey = undefined;
+
+
+// File: matcher.h lines: 79-79
+//         BSONObj _pattern;
+
+proto._pattern = undefined;
+
+
+// File: matcher.h lines: 84-84
+//         IndexSpliceInfo _spliceInfo;
+
+proto._spliceInfo = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method Matcher2
+ * @param
+ *
+ */
+proto.Matcher2 = function Matcher2( /*  const Matcher2 &docMatcher, const BSONObj &constrainIndexKey  */ ){
+
+// File: matcher.cpp lines: 94-102
+//     Matcher2::Matcher2( const Matcher2 &docMatcher, const BSONObj &constrainIndexKey )
+//         : _indexKey( constrainIndexKey ) {
+// 
+//         MatchExpression* indexExpression = spliceForIndex( constrainIndexKey,
+//                                                            docMatcher._expression.get(),
+//                                                            &_spliceInfo );
+//         if ( indexExpression ) {
+//             _expression.reset( indexExpression );
+//         }
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method _spliceForIndex
+ * @param
+ *
+ */
+proto._spliceForIndex = function _spliceForIndex( /*  const set<string>& keys,$/;" */ ){
+
+// File: matcher.cpp lines: 236-380
+//     MatchExpression* Matcher2::_spliceForIndex( const set<string>& keys,
+//                                                 const MatchExpression* full,
+//                                                 Matcher2::IndexSpliceInfo* spliceInfo  ) {
+// 
+//         switch ( full->matchType() ) {
+//         case MatchExpression::ALWAYS_FALSE:
+//             return new FalseMatchExpression();
+// 
+//         case MatchExpression::GEO_NEAR:
+//         case MatchExpression::NOT:
+//         case MatchExpression::NOR:
+//             // maybe?
+//             return NULL;
+// 
+//         case MatchExpression::OR:
+// 
+//         case MatchExpression::AND: {
+//             auto_ptr<ListOfMatchExpression> dup;
+//             for ( unsigned i = 0; i < full->numChildren(); i++ ) {
+//                 MatchExpression* sub = _spliceForIndex( keys, full->getChild( i ), spliceInfo );
+//                 if ( !sub )
+//                     continue;
+//                 if ( !dup.get() ) {
+//                     if ( full->matchType() == MatchExpression::AND )
+//                         dup.reset( new AndMatchExpression() );
+//                     else
+//                         dup.reset( new OrMatchExpression() );
+//                 }
+//                 dup->add( sub );
+//             }
+//             if ( dup.get() ) {
+//                 if ( full->matchType() == MatchExpression::OR &&
+//                      dup->numChildren() != full->numChildren() ) {
+//                     // TODO: I think this should actuall get a list of all the fields
+//                     // and make sure that's the same
+//                     // with an $or, have to make sure its all or nothing
+//                     return NULL;
+//                 }
+//                 return dup.release();
+//             }
+//             return NULL;
+//         }
+// 
+//         case MatchExpression::EQ: {
+//             const ComparisonMatchExpression* cmp =
+//                 static_cast<const ComparisonMatchExpression*>( full );
+// 
+//             if ( cmp->getRHS().type() == Array ) {
+//                 // need to convert array to an $in
+// 
+//                 if ( !keys.count( cmp->path().toString() ) )
+//                     return NULL;
+// 
+//                 auto_ptr<InMatchExpression> newIn( new InMatchExpression() );
+//                 newIn->init( cmp->path() );
+// 
+//                 if ( newIn->getArrayFilterEntries()->addEquality( cmp->getRHS() ).isOK() )
+//                     return NULL;
+// 
+//                 if ( cmp->getRHS().Obj().isEmpty() )
+//                     newIn->getArrayFilterEntries()->addEquality( myUndefinedElement );
+// 
+//                 BSONObjIterator i( cmp->getRHS().Obj() );
+//                 while ( i.more() ) {
+//                     Status s = newIn->getArrayFilterEntries()->addEquality( i.next() );
+//                     if ( !s.isOK() )
+//                         return NULL;
+//                 }
+// 
+//                 return newIn.release();
+//             }
+//             else if ( cmp->getRHS().type() == jstNULL ) {
+//                 //spliceInfo->hasNullEquality = true;
+//                 return NULL;
+//             }
+//         }
+// 
+//         case MatchExpression::LTE:
+//         case MatchExpression::LT:
+//         case MatchExpression::GT:
+//         case MatchExpression::GTE: {
+//             const ComparisonMatchExpression* cmp =
+//                 static_cast<const ComparisonMatchExpression*>( full );
+// 
+//             if ( cmp->getRHS().type() == jstNULL ) {
+//                 // null and indexes don't play nice
+//                 //spliceInfo->hasNullEquality = true;
+//                 return NULL;
+//             }
+//         }
+//         case MatchExpression::REGEX:
+//         case MatchExpression::MOD: {
+//             const LeafMatchExpression* lme = static_cast<const LeafMatchExpression*>( full );
+//             if ( !keys.count( lme->path().toString() ) )
+//                 return NULL;
+//             return lme->shallowClone();
+//         }
+// 
+//         case MatchExpression::MATCH_IN: {
+//             const LeafMatchExpression* lme = static_cast<const LeafMatchExpression*>( full );
+//             if ( !keys.count( lme->path().toString() ) )
+//                 return NULL;
+//             InMatchExpression* cloned = static_cast<InMatchExpression*>(lme->shallowClone());
+//             if ( cloned->getArrayFilterEntries()->hasEmptyArray() )
+//                 cloned->getArrayFilterEntries()->addEquality( myUndefinedElement );
+// 
+//             // since { $in : [[1]] } matches [1], need to explode
+//             for ( BSONElementSet::const_iterator i = cloned->getArrayFilterEntries()->equalities().begin();
+//                   i != cloned->getArrayFilterEntries()->equalities().end();
+//                   ++i ) {
+//                 const BSONElement& x = *i;
+//                 if ( x.type() == Array ) {
+//                     BSONObjIterator j( x.Obj() );
+//                     while ( j.more() ) {
+//                         cloned->getArrayFilterEntries()->addEquality( j.next() );
+//                     }
+//                 }
+//             }
+// 
+//             return cloned;
+//         }
+// 
+//         case MatchExpression::ALL:
+//             // TODO: conver to $in
+//             return NULL;
+// 
+//         case MatchExpression::ELEM_MATCH_OBJECT:
+//         case MatchExpression::ELEM_MATCH_VALUE:
+//             // future
+//             return NULL;
+// 
+//         case MatchExpression::GEO:
+//         case MatchExpression::SIZE:
+//         case MatchExpression::EXISTS:
+//         case MatchExpression::NIN:
+//         case MatchExpression::TYPE_OPERATOR:
+//         case MatchExpression::ATOMIC:
+//         case MatchExpression::WHERE:
+//             // no go
+//             return NULL;
+// 
+// 
+//         }
+// 
+//         return NULL;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method atomic
+ * @param
+ *
+ */
+proto.atomic = function atomic( /*  */ ){
+
+// File: matcher.cpp lines: 120-133
+//     bool Matcher2::atomic() const {
+//         if ( !_expression )
+//             return false;
+// 
+//         if ( _expression->matchType() == MatchExpression::ATOMIC )
+//             return true;
+// 
+//         // we only go down one level
+//         for ( unsigned i = 0; i < _expression->numChildren(); i++ ) {
+//             if ( _expression->getChild( i )->matchType() == MatchExpression::ATOMIC )
+//                 return true;
+//         }
+// 
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getQuery
+ * @param
+ *
+ */
+proto.getQuery = function getQuery( /*  */ ){
+// File: matcher.h lines: 65-64
+//         const BSONObj* getQuery() const { return &_pattern; };
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method hasExistsFalse
+ * @param
+ *
+ */
+proto.hasExistsFalse = function hasExistsFalse( /*  */ ){
+
+// File: matcher.cpp lines: 172-180
+//     bool Matcher2::hasExistsFalse() const {
+//         if ( _spliceInfo.hasNullEquality ) {
+//             // { a : NULL } is very dangerous as it may not got indexed in some cases
+//             // so we just totally ignore
+//             return true;
+//         }
+// 
+//         return _isExistsFalse( _expression.get(), false,
+//                                _expression->matchType() == MatchExpression::AND ? -1 : 0 );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method keyMatch
+ * @param
+ *
+ */
+proto.keyMatch = function keyMatch( /*  const Matcher2 &docMatcher  */ ){
+
+// File: matcher.cpp lines: 199-206
+//     bool Matcher2::keyMatch( const Matcher2 &docMatcher ) const {
+//         if ( !_expression )
+//             return docMatcher._expression.get() == NULL;
+//         if ( !docMatcher._expression )
+//             return false;
+//         if ( _spliceInfo.hasNullEquality )
+//             return false;
+//         return _expression->equivalent( docMatcher._expression.get() );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /* const BSONObj& doc, MatchDetails* details  */ ){
+
+// File: matcher.cpp lines: 105-116
+//     bool Matcher2::matches(const BSONObj& doc, MatchDetails* details ) const {
+//         if ( !_expression )
+//             return true;
+// 
+//         if ( _indexKey.isEmpty() )
+//             return _expression->matchesBSON( doc, details );
+// 
+//         if ( !doc.isEmpty() && doc.firstElement().fieldName()[0] )
+//             return _expression->matchesBSON( doc, details );
+// 
+//         IndexKeyMatchableDocument mydoc( _indexKey, doc );
+//         return _expression->matches( &mydoc, details );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method singleSimpleCriterion
+ * @param
+ *
+ */
+proto.singleSimpleCriterion = function singleSimpleCriterion( /*  */ ){
+
+// File: matcher.cpp lines: 184-196
+//     bool Matcher2::singleSimpleCriterion() const {
+//         if ( !_expression )
+//             return false;
+// 
+//         if ( _expression->matchType() == MatchExpression::EQ )
+//             return true;
+// 
+//         if ( _expression->matchType() == MatchExpression::AND &&
+//              _expression->numChildren() == 1 &&
+//              _expression->getChild(0)->matchType() == MatchExpression::EQ )
+//             return true;
+// 
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method spliceForIndex
+ * @param
+ *
+ */
+proto.spliceForIndex = function spliceForIndex( /*  const BSONObj& key,$/;" */ ){
+
+// File: matcher.cpp lines: 209-217
+//     MatchExpression* Matcher2::spliceForIndex( const BSONObj& key,
+//                                                const MatchExpression* full,
+//                                                Matcher2::IndexSpliceInfo* spliceInfo ) {
+//         set<string> keys;
+//         for ( BSONObjIterator i(key); i.more(); ) {
+//             BSONElement e = i.next();
+//             keys.insert( e.fieldName() );
+//         }
+//         return _spliceForIndex( keys, full, spliceInfo );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method toString
+ * @param
+ *
+ */
+proto.toString = function toString( /*  */ ){
+// File: matcher.h lines: 66-65
+//         std::string toString() const { return _pattern.toString(); }
+
+
+
+
+}

+ 203 - 0
lib/pipeline/matcher/ModMatchExpression.js

@@ -0,0 +1,203 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var ModMatchExpression = module.exports = function (){
+
+}, klass = ModMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_leaf.h lines: 210-210
+//         int _divisor;
+
+proto._divisor = undefined;
+
+
+// File: expression_leaf.h lines: 211-211
+//         int _remainder;
+
+proto._remainder = undefined;
+
+
+// File: expression_leaf.h lines: 210-210
+//         int _divisor;
+
+proto._divisor = undefined;
+
+
+// File: expression_leaf.h lines: 211-211
+//         int _remainder;
+
+proto._remainder = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ModMatchExpression
+ * @param
+ *
+ */
+proto.ModMatchExpression = function ModMatchExpression( /*  MOD  */ ){
+// File: expression_leaf.h lines: 190-189
+//         ModMatchExpression() : LeafMatchExpression( MOD ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_leaf.cpp lines: 253-261
+//     void ModMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << path() << " mod " << _divisor << " % x == "  << _remainder;
+//         MatchExpression::TagData* td = getTag();
+//         if (NULL != td) {
+//             debug << " ";
+//             td->debugString(&debug);
+//         }
+//         debug << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_leaf.cpp lines: 264-272
+//     bool ModMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const ModMatchExpression* realOther = static_cast<const ModMatchExpression*>( other );
+//         return
+//             path() == realOther->path() &&
+//             _divisor == realOther->_divisor &&
+//             _remainder == realOther->_remainder;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getDivisor
+ * @param
+ *
+ */
+proto.getDivisor = function getDivisor( /*  */ ){
+// File: expression_leaf.h lines: 206-205
+//         int getDivisor() const { return _divisor; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getRemainder
+ * @param
+ *
+ */
+proto.getRemainder = function getRemainder( /*  */ ){
+// File: expression_leaf.h lines: 207-206
+//         int getRemainder() const { return _remainder; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, int divisor, int remainder  */ ){
+
+// File: expression_leaf.cpp lines: 239-244
+//     Status ModMatchExpression::init( const StringData& path, int divisor, int remainder ) {
+//         if ( divisor == 0 )
+//             return Status( ErrorCodes::BadValue, "divisor cannot be 0" );
+//         _divisor = divisor;
+//         _remainder = remainder;
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_leaf.cpp lines: 247-250
+//     bool ModMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         if ( !e.isNumber() )
+//             return false;
+//         return e.numberLong() % _divisor == _remainder;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 194-197
+//         virtual LeafMatchExpression* shallowClone() const {
+//             ModMatchExpression* m = new ModMatchExpression();
+//             m->init( path(), _divisor, _remainder );
+//             return m;
+//         }
+
+
+
+
+}

+ 137 - 0
lib/pipeline/matcher/NorMatchExpression.js

@@ -0,0 +1,137 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var NorMatchExpression = module.exports = function (){
+
+}, klass = NorMatchExpression, 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 NorMatchExpression
+ * @param
+ *
+ */
+proto.NorMatchExpression = function NorMatchExpression( /*  NOR  */ ){
+// File: expression_tree.h lines: 99-98
+//         NorMatchExpression() : ListOfMatchExpression( NOR ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_tree.cpp lines: 138-141
+//     void NorMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "$nor\n";
+//         _debugList( debug, level );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
+
+// File: expression_tree.cpp lines: 120-126
+//     bool NorMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
+//         for ( size_t i = 0; i < numChildren(); i++ ) {
+//             if ( getChild(i)->matches( doc, NULL ) ) {
+//                 return false;
+//             }
+//         }
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_tree.cpp lines: 129-135
+//     bool NorMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         for ( size_t i = 0; i < numChildren(); i++ ) {
+//             if ( getChild(i)->matchesSingleElement( e ) ) {
+//                 return false;
+//             }
+//         }
+//         return true;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_tree.h lines: 105-110
+//         virtual MatchExpression* shallowClone() const {
+//             NorMatchExpression* self = new NorMatchExpression();
+//             for (size_t i = 0; i < numChildren(); ++i) {
+//                 self->add(getChild(i)->shallowClone());
+//             }
+//             return self;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~NorMatchExpression
+ * @param
+ *
+ */
+proto.~NorMatchExpression = function ~NorMatchExpression( /*  */ ){
+// File: expression_tree.h lines: 100-99
+//         virtual ~NorMatchExpression(){}
+
+
+
+
+}

+ 197 - 0
lib/pipeline/matcher/NotMatchExpression.js

@@ -0,0 +1,197 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var NotMatchExpression = module.exports = function (){
+
+}, klass = NotMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_tree.h lines: 152-152
+//         boost::scoped_ptr<MatchExpression> _exp;
+
+proto._exp = undefined;
+
+
+// File: expression_tree.h lines: 152-152
+//         boost::scoped_ptr<MatchExpression> _exp;
+
+proto._exp = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method NotMatchExpression
+ * @param
+ *
+ */
+proto.NotMatchExpression = function NotMatchExpression( /*  NOT  */ ){
+// File: expression_tree.h lines: 118-117
+//         NotMatchExpression() : MatchExpression( NOT ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_tree.cpp lines: 146-149
+//     void NotMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "$not\n";
+//         _exp->debugString( debug, level + 1 );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_tree.cpp lines: 152-156
+//     bool NotMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         return _exp->equivalent( other->getChild(0) );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getChild
+ * @param
+ *
+ */
+proto.getChild = function getChild( /*  size_t i  */ ){
+// File: expression_tree.h lines: 148-147
+//         virtual MatchExpression* getChild( size_t i ) const { return _exp.get(); }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  MatchExpression* exp  */ ){
+// File: expression_tree.h lines: 123-125
+//         virtual Status init( MatchExpression* exp ) {
+//             _exp.reset( exp );
+//             return Status::OK();
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details = 0  */ ){
+// File: expression_tree.h lines: 135-136
+//         virtual bool matches( const MatchableDocument* doc, MatchDetails* details = 0 ) const {
+//             return !_exp->matches( doc, NULL );
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+// File: expression_tree.h lines: 139-140
+//         virtual bool matchesSingleElement( const BSONElement& e ) const {
+//             return !_exp->matchesSingleElement( e );
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method numChildren
+ * @param
+ *
+ */
+proto.numChildren = function numChildren( /*  */ ){
+// File: expression_tree.h lines: 147-146
+//         virtual size_t numChildren() const { return 1; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_tree.h lines: 128-132
+//         virtual MatchExpression* shallowClone() const {
+//             NotMatchExpression* self = new NotMatchExpression();
+//             MatchExpression* child = _exp->shallowClone();
+//             self->init(child);
+//             return self;
+//         }
+
+
+
+
+}

+ 137 - 0
lib/pipeline/matcher/OrMatchExpression.js

@@ -0,0 +1,137 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var OrMatchExpression = module.exports = function (){
+
+}, 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 documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  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 );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  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;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  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;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+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;
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * 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(){}
+
+
+
+
+}

+ 243 - 0
lib/pipeline/matcher/RegexMatchExpression.js

@@ -0,0 +1,243 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var RegexMatchExpression = module.exports = function (){
+
+}, klass = RegexMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_leaf.h lines: 160-160
+//         static const size_t MaxPatternSize = 32764;
+
+proto.MaxPatternSize = undefined;
+
+
+// File: expression_leaf.h lines: 184-184
+//         std::string _flags;
+
+proto._flags = undefined;
+
+
+// File: expression_leaf.h lines: 185-185
+//         boost::scoped_ptr<pcrecpp::RE> _re;
+
+proto._re = undefined;
+
+
+// File: expression_leaf.h lines: 183-183
+//         std::string _regex;
+
+proto._regex = undefined;
+
+
+// File: expression_leaf.h lines: 160-160
+//         static const size_t MaxPatternSize = 32764;
+
+proto.MaxPatternSize = undefined;
+
+
+// File: expression_leaf.h lines: 184-184
+//         std::string _flags;
+
+proto._flags = undefined;
+
+
+// File: expression_leaf.h lines: 185-185
+//         boost::scoped_ptr<pcrecpp::RE> _re;
+
+proto._re = undefined;
+
+
+// File: expression_leaf.h lines: 183-183
+//         std::string _regex;
+
+proto._regex = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method RegexMatchExpression
+ * @param
+ *
+ */
+proto.RegexMatchExpression = function RegexMatchExpression( /*  REGEX  */ ){
+// File: expression_leaf.h lines: 162-161
+//         RegexMatchExpression() : LeafMatchExpression( REGEX ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_leaf.cpp lines: 225-234
+//     void RegexMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << path() << " regex /" << _regex << "/" << _flags;
+// 
+//         MatchExpression::TagData* td = getTag();
+//         if (NULL != td) {
+//             debug << " ";
+//             td->debugString(&debug);
+//         }
+//         debug << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_leaf.cpp lines: 177-185
+//     bool RegexMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const RegexMatchExpression* realOther = static_cast<const RegexMatchExpression*>( other );
+//         return
+//             path() == realOther->path() &&
+//             _regex == realOther->_regex
+//             && _flags == realOther->_flags;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getFlags
+ * @param
+ *
+ */
+proto.getFlags = function getFlags( /*  */ ){
+// File: expression_leaf.h lines: 180-179
+//         const string& getFlags() const { return _flags; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getString
+ * @param
+ *
+ */
+proto.getString = function getString( /*  */ ){
+// File: expression_leaf.h lines: 179-178
+//         const string& getString() const { return _regex; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, const StringData& regex, const StringData& options  */ ){
+
+// File: expression_leaf.cpp lines: 196-205
+//     Status RegexMatchExpression::init( const StringData& path, const StringData& regex, const StringData& options ) {
+//         if ( regex.size() > MaxPatternSize ) {
+//             return Status( ErrorCodes::BadValue, "Regular expression is too long" );
+//         }
+// 
+//         _regex = regex.toString();
+//         _flags = options.toString();
+//         _re.reset( new pcrecpp::RE( _regex.c_str(), flags2options( _flags.c_str() ) ) );
+// 
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_leaf.cpp lines: 208-222
+//     bool RegexMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         //log() << "RegexMatchExpression::matchesSingleElement _regex: " << _regex << " e: " << e << std::endl;
+//         switch (e.type()) {
+//         case String:
+//         case Symbol:
+//             // TODO
+//             //if (rm._prefix.empty())
+//                 return _re->PartialMatch(e.valuestr());
+//                 //else
+//                 //return !strncmp(e.valuestr(), rm._prefix.c_str(), rm._prefix.size());
+//         case RegEx:
+//             return _regex == e.regex() && _flags == e.regexFlags();
+//         default:
+//             return false;
+//         }
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 167-170
+//         virtual LeafMatchExpression* shallowClone() const {
+//             RegexMatchExpression* e = new RegexMatchExpression();
+//             e->init( path(), _regex, _flags );
+//             return e;
+//         }
+
+
+
+
+}

+ 113 - 0
lib/pipeline/matcher/SimpleArrayElementIterator.js

@@ -0,0 +1,113 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var SimpleArrayElementIterator = module.exports = function (){
+
+}, klass = SimpleArrayElementIterator, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: path.h lines: 101-101
+//         BSONObjIterator _iterator;
+
+proto._iterator = undefined;
+
+
+// File: path.h lines: 100-100
+//         bool _returnArrayLast;
+
+proto._returnArrayLast = undefined;
+
+
+// File: path.h lines: 99-99
+//         BSONElement _theArray;
+
+proto._theArray = undefined;
+
+
+// File: path.h lines: 101-101
+//         BSONObjIterator _iterator;
+
+proto._iterator = undefined;
+
+
+// File: path.h lines: 100-100
+//         bool _returnArrayLast;
+
+proto._returnArrayLast = undefined;
+
+
+// File: path.h lines: 99-99
+//         BSONElement _theArray;
+
+proto._theArray = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method SimpleArrayElementIterator
+ * @param
+ *
+ */
+proto.SimpleArrayElementIterator = function SimpleArrayElementIterator( /*  const BSONElement& theArray, bool returnArrayLast  */ ){
+
+// File: path.cpp lines: 52-54
+//     SimpleArrayElementIterator::SimpleArrayElementIterator( const BSONElement& theArray, bool returnArrayLast )
+//         : _theArray( theArray ), _returnArrayLast( returnArrayLast ), _iterator( theArray.Obj() ) {
+// 
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method more
+ * @param
+ *
+ */
+proto.more = function more( /*  */ ){
+
+// File: path.cpp lines: 57-58
+//     bool SimpleArrayElementIterator::more() {
+//         return _iterator.more() || _returnArrayLast;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method next
+ * @param
+ *
+ */
+proto.next = function next( /*  */ ){
+
+// File: path.cpp lines: 61-70
+//     ElementIterator::Context SimpleArrayElementIterator::next() {
+//         if ( _iterator.more() ) {
+//             Context e;
+//             e.reset( _iterator.next(), BSONElement(), false );
+//             return e;
+//         }
+//         _returnArrayLast = false;
+//         Context e;
+//         e.reset( _theArray, BSONElement(), true );
+//         return e;
+//     }
+
+
+
+}

+ 106 - 0
lib/pipeline/matcher/SingleElementElementIterator.js

@@ -0,0 +1,106 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var SingleElementElementIterator = module.exports = function (){
+
+}, klass = SingleElementElementIterator, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: path.h lines: 88-88
+//         ElementIterator::Context _element;
+
+proto._element = undefined;
+
+
+// File: path.h lines: 87-87
+//         bool _seen;
+
+proto._seen = undefined;
+
+
+// File: path.h lines: 88-88
+//         ElementIterator::Context _element;
+
+proto._element = undefined;
+
+
+// File: path.h lines: 87-87
+//         bool _seen;
+
+proto._seen = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method SingleElementElementIterator
+ * @param
+ *
+ */
+proto.SingleElementElementIterator = function SingleElementElementIterator( /*  BSONElement e  */ ){
+// File: path.h lines: 77-79
+//         explicit SingleElementElementIterator( BSONElement e )
+//             : _seen( false ) {
+//             _element.reset( e, BSONElement(), false );
+//         }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method more
+ * @param
+ *
+ */
+proto.more = function more( /*  */ ){
+// File: path.h lines: 83-82
+//         virtual bool more() { return !_seen; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method next
+ * @param
+ *
+ */
+proto.next = function next( /*  */ ){
+// File: path.h lines: 84-83
+//         virtual Context next() { _seen = true; return _element; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~SingleElementElementIterator
+ * @param
+ *
+ */
+proto.~SingleElementElementIterator = function ~SingleElementElementIterator( /*  */ ){
+// File: path.h lines: 81-80
+//         virtual ~SingleElementElementIterator(){}
+
+
+
+
+}

+ 162 - 0
lib/pipeline/matcher/SizeMatchExpression.js

@@ -0,0 +1,162 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var SizeMatchExpression = module.exports = function (){
+
+}, klass = SizeMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_array.h lines: 131-131
+//         int _size; // >= 0 real, < 0, nothing will match
+
+proto._size = undefined;
+
+
+// File: expression_array.h lines: 131-131
+//         int _size; // >= 0 real, < 0, nothing will match
+
+proto._size = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method SizeMatchExpression
+ * @param
+ *
+ */
+proto.SizeMatchExpression = function SizeMatchExpression( /*  SIZE  */ ){
+// File: expression_array.h lines: 113-112
+//         SizeMatchExpression() : ArrayMatchingMatchExpression( SIZE ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_array.cpp lines: 259-261
+//     void SizeMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << path() << " $size : " << _size << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_array.cpp lines: 264-269
+//     bool SizeMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const SizeMatchExpression* realOther = static_cast<const SizeMatchExpression*>( other );
+//         return path() == realOther->path() && _size == realOther->_size;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getData
+ * @param
+ *
+ */
+proto.getData = function getData( /*  */ ){
+// File: expression_array.h lines: 128-127
+//         int getData() const { return _size; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, int size  */ ){
+
+// File: expression_array.cpp lines: 248-250
+//     Status SizeMatchExpression::init( const StringData& path, int size ) {
+//         _size = size;
+//         return initPath( path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesArray
+ * @param
+ *
+ */
+proto.matchesArray = function matchesArray( /*  const BSONObj& anArray, MatchDetails* details  */ ){
+
+// File: expression_array.cpp lines: 253-256
+//     bool SizeMatchExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
+//         if ( _size < 0 )
+//             return false;
+//         return anArray.nFields() == _size;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_array.h lines: 116-119
+//         virtual SizeMatchExpression* shallowClone() const {
+//             SizeMatchExpression* e = new SizeMatchExpression();
+//             e->init(path(), _size);
+//             return e;
+//         }
+
+
+
+
+}

+ 28 - 0
lib/pipeline/matcher/TagData.js

@@ -0,0 +1,28 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var TagData = module.exports = function (){
+
+}, klass = TagData, 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 ~TagData
+ * @param
+ *
+ */
+proto.~TagData = function ~TagData( /*  */ ){
+// File: expression.h lines: 151-150
+//             virtual ~TagData() { }
+
+
+
+
+}

+ 240 - 0
lib/pipeline/matcher/TypeMatchExpression.js

@@ -0,0 +1,240 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var TypeMatchExpression = module.exports = function (){
+
+}, klass = TypeMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_leaf.h lines: 338-338
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_leaf.h lines: 337-337
+//         StringData _path;
+
+proto._path = undefined;
+
+
+// File: expression_leaf.h lines: 339-339
+//         int _type;
+
+proto._type = undefined;
+
+
+// File: expression_leaf.h lines: 338-338
+//         ElementPath _elementPath;
+
+proto._elementPath = undefined;
+
+
+// File: expression_leaf.h lines: 337-337
+//         StringData _path;
+
+proto._path = undefined;
+
+
+// File: expression_leaf.h lines: 339-339
+//         int _type;
+
+proto._type = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method TypeMatchExpression
+ * @param
+ *
+ */
+proto.TypeMatchExpression = function TypeMatchExpression( /*  TYPE_OPERATOR  */ ){
+// File: expression_leaf.h lines: 307-306
+//         TypeMatchExpression() : MatchExpression( TYPE_OPERATOR ){}
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_leaf.cpp lines: 335-343
+//     void TypeMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << _path << " type: " << _type;
+//         MatchExpression::TagData* td = getTag();
+//         if (NULL != td) {
+//             debug << " ";
+//             td->debugString(&debug);
+//         }
+//         debug << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_leaf.cpp lines: 347-352
+//     bool TypeMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+// 
+//         const TypeMatchExpression* realOther = static_cast<const TypeMatchExpression*>( other );
+//         return _path == realOther->_path && _type == realOther->_type;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method getData
+ * @param
+ *
+ */
+proto.getData = function getData( /*  */ ){
+// File: expression_leaf.h lines: 328-327
+//         int getData() const { return _type; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& path, int type  */ ){
+
+// File: expression_leaf.cpp lines: 308-311
+//     Status TypeMatchExpression::init( const StringData& path, int type ) {
+//         _path = path;
+//         _type = type;
+//         return _elementPath.init( _path );
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
+
+// File: expression_leaf.cpp lines: 318-332
+//     bool TypeMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
+//         boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) );
+//         while ( cursor->more() ) {
+//             ElementIterator::Context e = cursor->next();
+//             if ( e.outerArray() )
+//                 continue;
+// 
+//             if ( !matchesSingleElement( e.element() ) )
+//                 continue;
+//             if ( details && details->needRecord() && !e.arrayOffset().eoo() ) {
+//                 details->setElemMatchKey( e.arrayOffset().fieldName() );
+//             }
+//             return true;
+//         }
+//         return false;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_leaf.cpp lines: 314-315
+//     bool TypeMatchExpression::matchesSingleElement( const BSONElement& e ) const {
+//         return e.type() == _type;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method path
+ * @param
+ *
+ */
+proto.path = function path( /*  */ ){
+// File: expression_leaf.h lines: 330-329
+//         virtual const StringData path() const { return _path; }
+
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+// File: expression_leaf.h lines: 311-314
+//         virtual MatchExpression* shallowClone() const {
+//             TypeMatchExpression* e = new TypeMatchExpression();
+//             e->init(_path, _type);
+//             return e;
+//         }
+
+
+
+
+}

+ 280 - 0
lib/pipeline/matcher/WhereMatchExpression.js

@@ -0,0 +1,280 @@
+"use strict"
+
+
+
+// Autogenerated by cport.py on 2013-09-17 14:37
+var WhereMatchExpression = module.exports = function (){
+
+}, klass = WhereMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
+
+
+// File: expression_where.cpp lines: 55-55
+//         string _code;
+
+proto._code = undefined;
+
+
+// File: expression_where.cpp lines: 59-59
+//         ScriptingFunction _func;
+
+proto._func = undefined;
+
+
+// File: expression_where.cpp lines: 54-54
+//         string _ns;
+
+proto._ns = undefined;
+
+
+// File: expression_where.cpp lines: 58-58
+//         auto_ptr<Scope> _scope;
+
+proto._scope = undefined;
+
+
+// File: expression_where.cpp lines: 56-56
+//         BSONObj _userScope;
+
+proto._userScope = undefined;
+
+
+// File: expression_where.cpp lines: 55-55
+//         string _code;
+
+proto._code = undefined;
+
+
+// File: expression_where.cpp lines: 59-59
+//         ScriptingFunction _func;
+
+proto._func = undefined;
+
+
+// File: expression_where.cpp lines: 54-54
+//         string _ns;
+
+proto._ns = undefined;
+
+
+// File: expression_where.cpp lines: 58-58
+//         auto_ptr<Scope> _scope;
+
+proto._scope = undefined;
+
+
+// File: expression_where.cpp lines: 56-56
+//         BSONObj _userScope;
+
+proto._userScope = undefined;
+
+
+
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method WhereMatchExpression
+ * @param
+ *
+ */
+proto.WhereMatchExpression = function WhereMatchExpression( /*  WHERE  */ ){
+
+// File: expression_where.cpp lines: 33-32
+//         WhereMatchExpression() : MatchExpression( WHERE ){ _func = 0; }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method debugString
+ * @param
+ *
+ */
+proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
+
+// File: expression_where.cpp lines: 113-124
+//     void WhereMatchExpression::debugString( StringBuilder& debug, int level ) const {
+//         _debugAddSpace( debug, level );
+//         debug << "$where\n";
+// 
+//         _debugAddSpace( debug, level + 1 );
+//         debug << "ns: " << _ns << "\n";
+// 
+//         _debugAddSpace( debug, level + 1 );
+//         debug << "code: " << _code << "\n";
+// 
+//         _debugAddSpace( debug, level + 1 );
+//         debug << "scope: " << _userScope << "\n";
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method equivalent
+ * @param
+ *
+ */
+proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
+
+// File: expression_where.cpp lines: 127-134
+//     bool WhereMatchExpression::equivalent( const MatchExpression* other ) const {
+//         if ( matchType() != other->matchType() )
+//             return false;
+//         const WhereMatchExpression* realOther = static_cast<const WhereMatchExpression*>(other);
+//         return
+//             _ns == realOther->_ns &&
+//             _code == realOther->_code &&
+//             _userScope == realOther->_userScope;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method init
+ * @param
+ *
+ */
+proto.init = function init( /*  const StringData& ns,$/;" */ ){
+
+// File: expression_where.cpp lines: 62-86
+//     Status WhereMatchExpression::init( const StringData& ns,
+//                                        const StringData& theCode,
+//                                        const BSONObj& scope ) {
+// 
+//         if ( ns.size() == 0 )
+//             return Status( ErrorCodes::BadValue, "ns for $where cannot be empty" );
+// 
+//         if ( theCode.size() == 0 )
+//             return Status( ErrorCodes::BadValue, "code for $where cannot be empty" );
+// 
+//         _ns = ns.toString();
+//         _code = theCode.toString();
+//         _userScope = scope.getOwned();
+// 
+//         NamespaceString nswrapper( _ns );
+//         const string userToken = ClientBasic::getCurrent()->getAuthorizationSession()
+//                                                           ->getAuthenticatedUserNamesToken();
+//         _scope = globalScriptEngine->getPooledScope( nswrapper.db().toString(),
+//                                                      "where" + userToken );
+//         _func = _scope->createFunction( _code.c_str() );
+// 
+//         if ( !_func )
+//             return Status( ErrorCodes::BadValue, "$where compile error" );
+// 
+//         return Status::OK();
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matches
+ * @param
+ *
+ */
+proto.matches = function matches( /*  const MatchableDocument* doc, MatchDetails* details  */ ){
+
+// File: expression_where.cpp lines: 89-110
+//     bool WhereMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
+//         verify( _func );
+//         BSONObj obj = doc->toBSON();
+// 
+//         if ( ! _userScope.isEmpty() ) {
+//             _scope->init( &_userScope );
+//         }
+//         _scope->setObject( "obj", const_cast< BSONObj & >( obj ) );
+//         _scope->setBoolean( "fullObject" , true ); // this is a hack b/c fullObject used to be relevant
+// 
+//         int err = _scope->invoke( _func, 0, &obj, 1000 * 60, false );
+//         if ( err == -3 ) { // INVOKE_ERROR
+//             stringstream ss;
+//             ss << "error on invocation of $where function:\n"
+//                << _scope->getError();
+//             uassert( 16812, ss.str(), false);
+//         }
+//         else if ( err != 0 ) {   // ! INVOKE_SUCCESS
+//             uassert( 16813, "unknown error in invocation of $where function", false);
+//         }
+// 
+//         return _scope->getBoolean( "__returnValue" ) != 0;
+//     }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method matchesSingleElement
+ * @param
+ *
+ */
+proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
+
+// File: expression_where.cpp lines: 40-41
+//         virtual bool matchesSingleElement( const BSONElement& e ) const {
+//             return false;
+//         }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method shallowClone
+ * @param
+ *
+ */
+proto.shallowClone = function shallowClone( /*  */ ){
+
+// File: expression_where.cpp lines: 44-47
+//         virtual MatchExpression* shallowClone() const {
+//             WhereMatchExpression* e = new WhereMatchExpression();
+//             e->init(_ns, _code, _userScope);
+//             return e;
+//         }
+
+
+
+}
+
+
+/**
+ * 
+ * This documentation was automatically generated. Please update when you touch this function.
+ * @method ~WhereMatchExpression
+ * @param
+ *
+ */
+proto.~WhereMatchExpression = function ~WhereMatchExpression( /*  */ ){
+
+// File: expression_where.cpp lines: 34-33
+//         virtual ~WhereMatchExpression(){}
+
+
+
+}