summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2010-08-10 14:35:02 -0400
committerMathias Stearn <mathias@10gen.com>2010-08-10 14:44:10 -0400
commite8e772181a01d77efd988c27ad4418271f440e56 (patch)
tree89ffd1896fa7ce93da4f5e428b8860536de4cd39 /scripting
parent06cb7f821feeab260946303600db56681d1bb07b (diff)
downloadmongo-e8e772181a01d77efd988c27ad4418271f440e56.tar.gz
Use one string per JS file.
mongo_vstudio.cpp in next push
Diffstat (limited to 'scripting')
-rw-r--r--scripting/engine.h32
-rw-r--r--scripting/engine_v8.cpp4
-rw-r--r--scripting/sm_db.cpp2
3 files changed, 33 insertions, 5 deletions
diff --git a/scripting/engine.h b/scripting/engine.h
index f929b4db959..046f1778148 100644
--- a/scripting/engine.h
+++ b/scripting/engine.h
@@ -20,10 +20,23 @@
#include "../pch.h"
#include "../db/jsobj.h"
-extern const mongo::StringData jsconcatcode; // TODO: change name to mongoJSCode
-
namespace mongo {
+ struct JSFile {
+ const char* name;
+ const StringData& source;
+ };
+
+ 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 servers;
+ extern const JSFile utils;
+ }
+
typedef unsigned long long ScriptingFunction;
typedef BSONObj (*NativeFunction) ( const BSONObj &args );
@@ -85,6 +98,21 @@ namespace mongo {
virtual void execSetup( const StringData& code , const string& name = "setup" ){
exec( code , name , false , true , true , 0 );
}
+
+ void execSetup( const JSFile& file){
+ execSetup(file.source, file.name);
+ }
+
+ void execCoreFiles(){
+ // keeping same order as in SConstruct
+ execSetup(JSFiles::utils);
+ execSetup(JSFiles::db);
+ execSetup(JSFiles::mongo);
+ execSetup(JSFiles::mr);
+ execSetup(JSFiles::query);
+ execSetup(JSFiles::collection);
+ }
+
virtual bool execFile( const string& filename , bool printResult , bool reportError , bool assertOnError, int timeoutMs = 0 );
virtual void injectNative( const char *field, NativeFunction func ) = 0;
diff --git a/scripting/engine_v8.cpp b/scripting/engine_v8.cpp
index 1f488b6096e..85ccd882910 100644
--- a/scripting/engine_v8.cpp
+++ b/scripting/engine_v8.cpp
@@ -406,7 +406,7 @@ namespace mongo {
//_global->Set( v8::String::New( "Mongo" ) , _engine->_externalTemplate->GetFunction() );
_global->Set( v8::String::New( "Mongo" ) , getMongoFunctionTemplate( true )->GetFunction() );
- exec( jsconcatcode , "localConnect 1" , false , true , true , 0 );
+ execCoreFiles();
exec( "_mongo = new Mongo();" , "local connect 2" , false , true , true , 0 );
exec( (string)"db = _mongo.getDB(\"" + dbName + "\");" , "local connect 3" , false , true , true , 0 );
_connectState = LOCAL;
@@ -423,7 +423,7 @@ namespace mongo {
installFork( _global, _context );
_global->Set( v8::String::New( "Mongo" ) , getMongoFunctionTemplate( false )->GetFunction() );
- exec( jsconcatcode , "shell setup" , false , true , true , 0 );
+ execCoreFiles();
_connectState = EXTERNAL;
}
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp
index 855a50d345f..f1e6244aec8 100644
--- a/scripting/sm_db.cpp
+++ b/scripting/sm_db.cpp
@@ -990,7 +990,7 @@ namespace mongo {
dbref_class.name = dbrefName;
assert( JS_InitClass( cx , global , 0 , &dbref_class , dbref_constructor , 2 , 0 , bson_functions , 0 , 0 ) );
- scope->exec( jsconcatcode );
+ scope->execCoreFiles();
}
bool appendSpecialDBObject( Convertor * c , BSONObjBuilder& b , const string& name , jsval val , JSObject * o ){