diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
commit | 5d342a758c6095b4d30aba0750b54f13b8916f51 (patch) | |
tree | 762e9aa84781f5e3b96db2c02d356c29cf0217c0 /scripting/engine.cpp | |
parent | cbe2d992e9cd1ea66af9fa91df006106775d3073 (diff) | |
download | mongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz |
Imported Upstream version 2.0.0
Diffstat (limited to 'scripting/engine.cpp')
-rw-r--r-- | scripting/engine.cpp | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/scripting/engine.cpp b/scripting/engine.cpp index f9be639..1982940 100644 --- a/scripting/engine.cpp +++ b/scripting/engine.cpp @@ -85,10 +85,10 @@ namespace mongo { } - int Scope::invoke( const char* code , const BSONObj& args, int timeoutMs ) { + int Scope::invoke( const char* code , const BSONObj* args, const BSONObj* recv, int timeoutMs ) { ScriptingFunction func = createFunction( code ); uassert( 10207 , "compile failed" , func ); - return invoke( func , args, timeoutMs ); + return invoke( func , args, recv, timeoutMs ); } bool Scope::execFile( const string& filename , bool printResult , bool reportError , bool assertOnError, int timeoutMs ) { @@ -241,6 +241,27 @@ namespace mongo { return f; } + namespace JSFiles { + extern const JSFile collection; + extern const JSFile db; + extern const JSFile mongo; + extern const JSFile mr; + extern const JSFile query; + extern const JSFile utils; + extern const JSFile utils_sh; + } + + void Scope::execCoreFiles() { + // keeping same order as in SConstruct + execSetup(JSFiles::utils); + execSetup(JSFiles::utils_sh); + execSetup(JSFiles::db); + execSetup(JSFiles::mongo); + execSetup(JSFiles::mr); + execSetup(JSFiles::query); + execSetup(JSFiles::collection); + } + typedef map< string , list<Scope*> > PoolToScopes; class ScopeCache { @@ -373,8 +394,12 @@ namespace mongo { void setBoolean( const char *field , bool val ) { _real->setBoolean( field , val ); } - void setThis( const BSONObj * obj ) { - _real->setThis( obj ); +// void setThis( const BSONObj * obj ) { +// _real->setThis( obj ); +// } + + void setFunction( const char *field , const char * code ) { + _real->setFunction(field, code); } ScriptingFunction createFunction( const char * code ) { @@ -392,8 +417,8 @@ namespace mongo { /** * @return 0 on success */ - int invoke( ScriptingFunction func , const BSONObj& args, int timeoutMs , bool ignoreReturn ) { - return _real->invoke( func , args , timeoutMs , ignoreReturn ); + int invoke( ScriptingFunction func , const BSONObj* args, const BSONObj* recv, int timeoutMs , bool ignoreReturn, bool readOnlyArgs, bool readOnlyRecv ) { + return _real->invoke( func , args , recv, timeoutMs , ignoreReturn ); } string getError() { @@ -407,14 +432,18 @@ namespace mongo { return _real->execFile( filename , printResult , reportError , assertOnError , timeoutMs ); } - void injectNative( const char *field, NativeFunction func ) { - _real->injectNative( field , func ); + void injectNative( const char *field, NativeFunction func, void* data ) { + _real->injectNative( field , func, data ); } void gc() { _real->gc(); } + void append( BSONObjBuilder & builder , const char * fieldName , const char * scopeName ) { + _real->append(builder, fieldName, scopeName); + } + private: string _pool; Scope * _real; |