summaryrefslogtreecommitdiff
path: root/scripting/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/engine.cpp')
-rw-r--r--scripting/engine.cpp45
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;