2009-01-27 04:19:15 +01:00
|
|
|
// ShellUtils.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <v8.h>
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <iostream>
|
|
|
|
|
2009-05-04 23:37:02 +02:00
|
|
|
#include "../scripting/engine.h"
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
// Executes a string within the current v8 context.
|
|
|
|
bool ExecuteString(v8::Handle<v8::String> source,
|
|
|
|
v8::Handle<v8::Value> name,
|
|
|
|
bool print_result,
|
|
|
|
bool report_exceptions);
|
|
|
|
|
|
|
|
v8::Handle<v8::Value> Print(const v8::Arguments& args);
|
|
|
|
v8::Handle<v8::Value> Load(const v8::Arguments& args);
|
2009-01-29 15:05:46 +01:00
|
|
|
v8::Handle<v8::Value> ListFiles(const v8::Arguments& args);
|
2009-01-27 04:19:15 +01:00
|
|
|
v8::Handle<v8::Value> Quit(const v8::Arguments& args);
|
|
|
|
v8::Handle<v8::Value> Version(const v8::Arguments& args);
|
2009-03-05 06:07:09 +01:00
|
|
|
v8::Handle<v8::Value> JSFork(const v8::Arguments& args);
|
2009-03-05 22:06:11 +01:00
|
|
|
v8::Handle<v8::Value> Join(const v8::Arguments& args);
|
2009-01-27 04:19:15 +01:00
|
|
|
|
|
|
|
v8::Handle<v8::String> ReadFile(const char* name);
|
|
|
|
|
|
|
|
|
|
|
|
void ReportException(v8::TryCatch* handler);
|
|
|
|
|
|
|
|
|
2009-05-05 00:28:13 +02:00
|
|
|
void installShellUtils( mongo::Scope &scope, v8::Handle<v8::ObjectTemplate>& global );
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
|
|
|
|
#define jsassert(x,msg) assert(x)
|
|
|
|
|
|
|
|
std::ostream& operator<<( std::ostream &s, const v8::Handle<v8::Value> & o );
|
|
|
|
std::ostream& operator<<( std::ostream &s, const v8::Handle<v8::TryCatch> * try_catch );
|
|
|
|
std::string toSTLString( const v8::Handle<v8::Value> & o );
|
2009-01-29 17:46:29 +01:00
|
|
|
|
2009-02-13 18:01:37 +01:00
|
|
|
// Scoped management of mongo program instances. Simple implementation:
|
|
|
|
// destructor kills all mongod instances created by the shell.
|
|
|
|
struct MongoProgramScope {
|
|
|
|
MongoProgramScope() {} // Avoid 'unused variable' warning.
|
|
|
|
~MongoProgramScope();
|
2009-01-29 17:46:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void RecordMyLocation( const char *_argv0 );
|
2009-02-13 18:01:37 +01:00
|
|
|
void KillMongoProgramInstances();
|