v8  3.14.5(node0.10.28)
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::Persistent< v8::ContextCreateShellContext ()
 
void RunShell (v8::Handle< v8::Context > context)
 
int RunMain (int argc, char *argv[])
 
bool ExecuteString (v8::Handle< v8::String > source, v8::Handle< v8::Value > name, bool print_result, bool report_exceptions)
 
v8::Handle< v8::ValuePrint (const v8::Arguments &args)
 
v8::Handle< v8::ValueRead (const v8::Arguments &args)
 
v8::Handle< v8::ValueLoad (const v8::Arguments &args)
 
v8::Handle< v8::ValueQuit (const v8::Arguments &args)
 
v8::Handle< v8::ValueVersion (const v8::Arguments &args)
 
v8::Handle< v8::StringReadFile (const char *name)
 
void ReportException (v8::TryCatch *handler)
 
int main (int argc, char *argv[])
 
const char * ToCString (const v8::String::Utf8Value &value)
 

Function Documentation

v8::Persistent< v8::Context > CreateShellContext ( )

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 97 of file shell.cc.

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

Referenced by main().

bool ExecuteString ( v8::Handle< v8::String source,
v8::Handle< v8::Value name,
bool  print_result,
bool  report_exceptions 
)
int main ( int  argc,
char *  argv[] 
)
v8::Handle<v8::Value> Print ( const v8::Arguments args)

Definition at line 118 of file shell.cc.

References Arguments::Length(), ToCString(), and v8::Undefined().

Referenced by CreateShellContext().

v8::Handle< v8::Value > Quit ( const v8::Arguments args)

Definition at line 180 of file shell.cc.

References v8::Undefined().

Referenced by CreateShellContext().

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

Definition at line 197 of file shell.cc.

References String::New(), and NULL.

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

int RunMain ( int  argc,
char *  argv[] 
)

Definition at line 219 of file shell.cc.

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

Referenced by main().

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

Definition at line 251 of file shell.cc.

References ExecuteString(), V8::GetVersion(), String::New(), and NULL.

Referenced by main().

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

Definition at line 90 of file shell.cc.

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

v8::Handle< v8::Value > Version ( const v8::Arguments args)

Definition at line 191 of file shell.cc.

References V8::GetVersion(), and String::New().

Referenced by CreateShellContext().