diff --git a/scripting/engine.cpp b/scripting/engine.cpp index 3f6c84cc143..eac00cadf14 100644 --- a/scripting/engine.cpp +++ b/scripting/engine.cpp @@ -436,6 +436,10 @@ namespace mongo { _real->gc(); } + void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ) { + _real->append(builder, fieldName, scopeName); + } + private: string _pool; Scope * _real; diff --git a/scripting/engine.h b/scripting/engine.h index bec8abc76df..65f49542102 100644 --- a/scripting/engine.h +++ b/scripting/engine.h @@ -69,7 +69,7 @@ namespace mongo { virtual int type( const char *field ) = 0; - void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ); + virtual void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ); virtual void setElement( const char *field , const BSONElement& e ) = 0; virtual void setNumber( const char *field , double val ) = 0; diff --git a/scripting/engine_v8.cpp b/scripting/engine_v8.cpp index d3f40265e1d..45e9b0ab09f 100644 --- a/scripting/engine_v8.cpp +++ b/scripting/engine_v8.cpp @@ -47,7 +47,6 @@ namespace mongo { BSONObj* obj = unwrapBSONObj(v8::Persistent::Cast(p)); delete obj; p.Dispose(); - cout << "deleted obj" << endl; } static Handle namedGet(Local name, const v8::AccessorInfo &info) { @@ -1023,7 +1022,6 @@ namespace mongo { Persistent p = Persistent::New(o); p.MakeWeak(this, weakRefCallback); - cout << "created obj" << endl; return p; } @@ -1155,6 +1153,13 @@ namespace mongo { return v8::Undefined(); } + void V8Scope::append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ) { + V8_SIMPLE_HEADER + Handle v8name = getV8Str(scopeName); + Handle value = _global->Get( v8name ); + v8ToMongoElement(builder, v8name, fieldName, value); + } + void V8Scope::v8ToMongoElement( BSONObjBuilder & b , v8::Handle name , const string sname , v8::Handle value , int depth ) { if ( value->IsString() ) { diff --git a/scripting/engine_v8.h b/scripting/engine_v8.h index f8acc9d1346..6a9126814db 100644 --- a/scripting/engine_v8.h +++ b/scripting/engine_v8.h @@ -113,6 +113,7 @@ namespace mongo { void v8ToMongoElement( BSONObjBuilder & b , v8::Handle name , const string sname , v8::Handle value , int depth = 0 ); v8::Handle mongoToV8Element( const BSONElement &f ); + virtual void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ); v8::Function * getNamedCons( const char * name ); v8::Function * getObjectIdCons();