From 187689b0cd24b96b8ca06b417c1a0674e5466af2 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 4 May 2009 11:49:18 -0400 Subject: [PATCH] stubbed v8 engine --- SConstruct | 8 +++--- mongo.xcodeproj/project.pbxproj | 4 +++ scripting/engine_v8.cpp | 11 ++++++++ scripting/engine_v8.h | 48 +++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 scripting/engine_v8.cpp create mode 100644 scripting/engine_v8.h diff --git a/SConstruct b/SConstruct index cc7997bbd39..a863d33f6e4 100644 --- a/SConstruct +++ b/SConstruct @@ -168,8 +168,9 @@ usesm = not GetOption( "usesm" ) is None commonFiles = Split( "stdafx.cpp buildinfo.cpp db/jsobj.cpp db/json.cpp db/commands.cpp db/lasterror.cpp db/nonce.cpp db/queryutil.cpp" ) commonFiles += [ "util/background.cpp" , "util/mmap.cpp" , "util/sock.cpp" , "util/util.cpp" , "util/message.cpp" ] -commonFiles += Glob( "util/*.c" ); +commonFiles += Glob( "util/*.c" ) commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/model.cpp" ) +commonFiles += [ "scripting/engine.cpp" ] #mmap stuff @@ -189,7 +190,6 @@ coreDbFiles = [] coreServerFiles = [ "util/message_server_port.cpp" , "util/message_server_asio.cpp" ] serverOnlyFiles = Split( "db/query.cpp db/introspect.cpp db/btree.cpp db/clientcursor.cpp db/tests.cpp db/repl.cpp db/btreecursor.cpp db/cloner.cpp db/namespace.cpp db/matcher.cpp db/dbcommands.cpp db/dbeval.cpp db/dbwebserver.cpp db/dbinfo.cpp db/dbhelpers.cpp db/instance.cpp db/pdfile.cpp db/cursor.cpp db/security_commands.cpp db/security.cpp util/miniwebserver.cpp db/storage.cpp db/reccache.cpp db/queryoptimizer.cpp" ) -serverOnlyFiles += [ "scripting/engine.cpp" ] if usesm: serverOnlyFiles += [ "scripting/engine_spidermonkey.cpp" , "shell/mongo.cpp" ] @@ -728,7 +728,7 @@ elif not onlyServer: shellEnv.Append( LIBS=["winmm.lib"] ) if weird: - shell32BitFiles = Glob( "shell/*.cpp" ) + shell32BitFiles = Glob( "shell/*.cpp" ) + [ "scripting/engine_v8.cpp" ] for f in allClientFiles: shell32BitFiles.append( "32bit/" + str( f ) ) @@ -742,7 +742,7 @@ elif not onlyServer: mongo = shellEnv.Program( "mongo" , shell32BitFiles ) else: shellEnv.Append( LIBS=[ "mongoclient"] ) - mongo = shellEnv.Program( "mongo" , Glob( "shell/*.cpp" ) ); + mongo = shellEnv.Program( "mongo" , Glob( "shell/*.cpp" ) + [ "scripting/engine_v8.cpp" ] ); # ---- RUNNING TESTS ---- diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj index abe5bae62eb..16b36a247ec 100644 --- a/mongo.xcodeproj/project.pbxproj +++ b/mongo.xcodeproj/project.pbxproj @@ -174,6 +174,8 @@ 93A479F70FAF2A5000E760DD /* engine_java.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = engine_java.h; sourceTree = ""; }; 93A479F90FAF2A5000E760DD /* engine_none.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = engine_none.cpp; sourceTree = ""; }; 93A479FA0FAF2A5000E760DD /* engine_spidermonkey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = engine_spidermonkey.cpp; sourceTree = ""; }; + 93A47AA50FAF416F00E760DD /* engine_v8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = engine_v8.cpp; sourceTree = ""; }; + 93A47AA60FAF41B200E760DD /* engine_v8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = engine_v8.h; sourceTree = ""; }; 93A6E10C0F24CF9800DA4EBF /* lasterror.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lasterror.h; sourceTree = ""; }; 93A6E10D0F24CFB100DA4EBF /* flushtest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flushtest.cpp; sourceTree = ""; }; 93A6E10E0F24CFD300DA4EBF /* security.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = security.h; sourceTree = ""; }; @@ -551,6 +553,8 @@ 93A479F20FAF2A5000E760DD /* scripting */ = { isa = PBXGroup; children = ( + 93A47AA60FAF41B200E760DD /* engine_v8.h */, + 93A47AA50FAF416F00E760DD /* engine_v8.cpp */, 93A479F30FAF2A5000E760DD /* engine.cpp */, 93A479F40FAF2A5000E760DD /* engine.h */, 93A479F60FAF2A5000E760DD /* engine_java.cpp */, diff --git a/scripting/engine_v8.cpp b/scripting/engine_v8.cpp new file mode 100644 index 00000000000..cd1ba1141b1 --- /dev/null +++ b/scripting/engine_v8.cpp @@ -0,0 +1,11 @@ +#include "engine_v8.h" + +namespace mongo { + +void ScriptEngine::setup(){ + if ( !globalScriptEngine ){ + globalScriptEngine = new V8ScriptEngine(); + } +} + +} // namespace mongo \ No newline at end of file diff --git a/scripting/engine_v8.h b/scripting/engine_v8.h new file mode 100644 index 00000000000..e29a56f96e4 --- /dev/null +++ b/scripting/engine_v8.h @@ -0,0 +1,48 @@ +#pragma once + +#include "engine.h" + +namespace mongo { + + class V8Scope : public Scope { + public: + V8Scope() {} + virtual ~V8Scope() {} + + virtual void reset() {} + virtual void init( BSONObj * data ) {} + + virtual void localConnect( const char * dbName ) {} + + virtual double getNumber( const char *field ) { assert( false ); return 0; } + virtual string getString( const char *field ) { assert( false ); return ""; } + virtual bool getBoolean( const char *field ) { assert( false ); return false; } + virtual BSONObj getObject( const char *field ) { assert( false ); return BSONObj(); } + + virtual int type( const char *field ) { assert( false ); return 0; } + + virtual void setNumber( const char *field , double val ) {} + virtual void setString( const char *field , const char * val ) {} + virtual void setObject( const char *field , const BSONObj& obj ) {} + virtual void setBoolean( const char *field , bool val ) {} + virtual void setThis( const BSONObj * obj ) {} + + virtual ScriptingFunction createFunction( const char * code ) { assert( false ); return 0; } + virtual int invoke( ScriptingFunction func , const BSONObj& args ) { assert( false ); return 0; } + virtual string getError() { assert( false ); return ""; } + + }; + + class V8ScriptEngine : public ScriptEngine { + public: + V8ScriptEngine() {} + virtual ~V8ScriptEngine() {} + + virtual Scope * createScope() { return new V8Scope(); } + + virtual void runTest() {} + }; + + + extern ScriptEngine * globalScriptEngine; +}