v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shell.cc File Reference
#include <v8.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for shell.cc:

Go to the source code of this file.

Functions

v8::Handle< v8::ContextCreateShellContext (v8::Isolate *isolate)
 
void RunShell (v8::Handle< v8::Context > context)
 
int RunMain (v8::Isolate *isolate, int argc, char *argv[])
 
bool ExecuteString (v8::Isolate *isolate, v8::Handle< v8::String > source, v8::Handle< v8::Value > name, bool print_result, bool report_exceptions)
 
void Print (const v8::FunctionCallbackInfo< v8::Value > &args)
 
void Read (const v8::FunctionCallbackInfo< v8::Value > &args)
 
void Load (const v8::FunctionCallbackInfo< v8::Value > &args)
 
void Quit (const v8::FunctionCallbackInfo< v8::Value > &args)
 
void Version (const v8::FunctionCallbackInfo< v8::Value > &args)
 
v8::Handle< v8::StringReadFile (v8::Isolate *isolate, const char *name)
 
void ReportException (v8::Isolate *isolate, v8::TryCatch *handler)
 
int main (int argc, char *argv[])
 
const char * ToCString (const v8::String::Utf8Value &value)
 

Function Documentation

v8::Handle< v8::Context > CreateShellContext ( v8::Isolate isolate)

This sample program shows how to implement a simple javascript shell based on V8. This includes initializing V8 with command line options, creating global functions, compiling and executing strings.

For a more sophisticated shell, consider using the debug shell D8.

Definition at line 99 of file shell.cc.

References Load(), FunctionTemplate::New(), ObjectTemplate::New(), Context::New(), String::NewFromUtf8(), NULL, Print(), Quit(), Read(), Template::Set(), and Version().

Referenced by main().

bool ExecuteString ( v8::Isolate isolate,
v8::Handle< v8::String source,
v8::Handle< v8::Value name,
bool  print_result,
bool  report_exceptions 
)
void Print ( const v8::FunctionCallbackInfo< v8::Value > &  args)
void Quit ( const v8::FunctionCallbackInfo< v8::Value > &  args)

Definition at line 201 of file shell.cc.

Referenced by CreateShellContext().

v8::Handle<v8::String> ReadFile ( v8::Isolate isolate,
const char *  name 
)

Definition at line 218 of file shell.cc.

References String::kNormalString, String::NewFromUtf8(), NULL, and size.

Referenced by Load(), Read(), and RunMain().

int RunMain ( v8::Isolate isolate,
int  argc,
char *  argv[] 
)

Definition at line 241 of file shell.cc.

References ExecuteString(), Handle< T >::IsEmpty(), String::NewFromUtf8(), and ReadFile().

Referenced by main().

void RunShell ( v8::Handle< v8::Context context)

Definition at line 276 of file shell.cc.

References ExecuteString(), Context::GetIsolate(), V8::GetVersion(), name, String::NewFromUtf8(), and NULL.

Referenced by main(), and Shell::Main().

const char* ToCString ( const v8::String::Utf8Value value)

Definition at line 92 of file shell.cc.

Referenced by ExecuteString(), Print(), and ReportException().