Minor cleanup in javascript shell implementation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13785 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0341e6b14c
commit
5fab9c8a38
2 changed files with 8 additions and 14 deletions
|
|
@ -12,10 +12,6 @@
|
||||||
#error "implement dll loading"
|
#error "implement dll loading"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JSValueRef JSCShell_Print(JSContextRef context, JSObjectRef object,
|
|
||||||
JSObjectRef globalobj, size_t argc,
|
|
||||||
const JSValueRef args[], JSValueRef* ex);
|
|
||||||
|
|
||||||
class JSCShell: public JSShell {
|
class JSCShell: public JSShell {
|
||||||
|
|
||||||
typedef int (*JSCIntializer)(JSGlobalContextRef context);
|
typedef int (*JSCIntializer)(JSGlobalContextRef context);
|
||||||
|
|
@ -38,7 +34,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//static JSValueRef Print(JSContextRef context,JSObjectRef object, JSObjectRef globalobj, size_t argc, const JSValueRef args[], JSValueRef* ex);
|
static JSValueRef Print(JSContextRef context,JSObjectRef object, JSObjectRef globalobj, size_t argc, const JSValueRef args[], JSValueRef* ex);
|
||||||
|
|
||||||
static bool RegisterFunction(JSGlobalContextRef context, JSObjectRef object, const char* functionName, JSObjectCallAsFunctionCallback cbFunction);
|
static bool RegisterFunction(JSGlobalContextRef context, JSObjectRef object, const char* functionName, JSObjectCallAsFunctionCallback cbFunction);
|
||||||
|
|
||||||
|
|
@ -51,8 +47,6 @@ private:
|
||||||
JSGlobalContextRef context;
|
JSGlobalContextRef context;
|
||||||
};
|
};
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
JSCShell::~JSCShell() {
|
JSCShell::~JSCShell() {
|
||||||
if(context != 0) {
|
if(context != 0) {
|
||||||
JSGlobalContextRelease(context);
|
JSGlobalContextRelease(context);
|
||||||
|
|
@ -79,7 +73,7 @@ bool JSCShell::InitializeEngine() {
|
||||||
context = JSGlobalContextCreate(NULL);
|
context = JSGlobalContextCreate(NULL);
|
||||||
if(context == 0) return false;
|
if(context == 0) return false;
|
||||||
JSObjectRef globalObject = JSContextGetGlobalObject(context);
|
JSObjectRef globalObject = JSContextGetGlobalObject(context);
|
||||||
JSCShell::RegisterFunction(context, globalObject, "print", JSCShell_Print);
|
JSCShell::RegisterFunction(context, globalObject, "print", JSCShell::Print);
|
||||||
// Call module initializers
|
// Call module initializers
|
||||||
for(std::vector<JSCIntializer>::iterator it = module_initializers.begin();
|
for(std::vector<JSCIntializer>::iterator it = module_initializers.begin();
|
||||||
it != module_initializers.end(); ++it) {
|
it != module_initializers.end(); ++it) {
|
||||||
|
|
@ -110,7 +104,7 @@ bool JSCShell::DisposeEngine() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSValueRef JSCShell_Print(JSContextRef context, JSObjectRef object,
|
JSValueRef JSCShell::Print(JSContextRef context, JSObjectRef object,
|
||||||
JSObjectRef globalobj, size_t argc,
|
JSObjectRef globalobj, size_t argc,
|
||||||
const JSValueRef args[], JSValueRef* ex) {
|
const JSValueRef args[], JSValueRef* ex) {
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,6 @@ protected:
|
||||||
#error "implement dll loading"
|
#error "implement dll loading"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Extracts a C string from a V8 Utf8Value.
|
|
||||||
const char* V8Shell::ToCString(const v8::String::Utf8Value& value) {
|
|
||||||
return *value ? *value : "<string conversion failed>";
|
|
||||||
}
|
|
||||||
|
|
||||||
V8Shell::V8Shell()
|
V8Shell::V8Shell()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -220,3 +215,8 @@ void V8Shell::ReportException(v8::TryCatch* try_catch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extracts a C string from a V8 Utf8Value.
|
||||||
|
const char* V8Shell::ToCString(const v8::String::Utf8Value& value) {
|
||||||
|
return *value ? *value : "<string conversion failed>";
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue