Simplify creation of a Javascript shell.
This commit is contained in:
parent
57980975a0
commit
058a27bf32
4 changed files with 53 additions and 70 deletions
|
|
@ -7,14 +7,6 @@
|
|||
|
||||
#include "js_shell.h"
|
||||
|
||||
#ifdef USE_JSC
|
||||
extern JSShell* create_jsc_shell();
|
||||
#endif
|
||||
|
||||
#ifdef USE_V8
|
||||
extern JSShell* create_v8_shell();
|
||||
#endif
|
||||
|
||||
void print_usage() {
|
||||
std::cout << "javascript [-i] [-jsc|-v8] [-l module] <js-file>" << std::endl;
|
||||
}
|
||||
|
|
@ -37,16 +29,12 @@ int main(int argc, char* argv[]) {
|
|||
std::string module_name(argv[idx]);
|
||||
module_names.push_back(module_name);
|
||||
} else if(strcmp(argv[idx], "-v8") == 0) {
|
||||
#ifdef USE_V8
|
||||
shell = create_v8_shell();
|
||||
#else
|
||||
#ifndef USE_V8
|
||||
std::cerr << "V8 support is not enabled" << std::endl;
|
||||
exit(-1);
|
||||
#endif
|
||||
} else if(strcmp(argv[idx], "-jsc") == 0) {
|
||||
#ifdef USE_JSC
|
||||
shell = create_jsc_shell();
|
||||
#else
|
||||
#ifndef USE_JSC
|
||||
std::cerr << "JSC support is not enabled" << std::endl;
|
||||
exit(-1);
|
||||
#endif
|
||||
|
|
@ -56,16 +44,9 @@ int main(int argc, char* argv[]) {
|
|||
scriptPath = argv[idx];
|
||||
}
|
||||
}
|
||||
|
||||
if (shell == 0) {
|
||||
#ifdef USE_JSC
|
||||
shell = create_jsc_shell();
|
||||
#else
|
||||
std::cerr << "JSC support is not enabled" << std::endl;
|
||||
exit(-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
shell = JSShell::Create();
|
||||
|
||||
bool failed = false;
|
||||
for(std::vector<std::string>::iterator it = module_names.begin();
|
||||
it != module_names.end(); ++it) {
|
||||
|
|
@ -94,6 +75,6 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
delete shell;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue