Merge branch 'devel' of git://github.com/oliver----/swig-v8 into devel
Conflicts: Lib/javascript/v8/javascriptcode.swg
This commit is contained in:
commit
306b265af9
13 changed files with 235 additions and 90 deletions
87
.gitignore
vendored
Normal file
87
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/CCache
|
||||
*.Po
|
||||
swigp4.ml
|
||||
config.log
|
||||
config.status
|
||||
preinst-swig
|
||||
swig.spec
|
||||
3build
|
||||
*.o
|
||||
CCache/*
|
||||
Lib/ocaml/swigp4.ml
|
||||
Lib/swigwarn.swg
|
||||
Source/Include/stamp-h1
|
||||
Source/Include/swigconfig.h
|
||||
Source/Include/swigconfig.h.in
|
||||
.deps
|
||||
.dirstamp
|
||||
*.cxx~
|
||||
*.h~
|
||||
Tools/config/*
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
preinst-swig
|
||||
swig
|
||||
swig.spec
|
||||
Source/CParse/parser.*
|
||||
aclocal.m4
|
||||
autom4te.cache/*
|
||||
*.so
|
||||
example_wrap.cxx
|
||||
Source/eswig
|
||||
runme
|
||||
.gitignore
|
||||
swig-jsc.geany
|
||||
/Makefile
|
||||
Lib/guile/Makefile
|
||||
Lib/mzscheme/Makefile
|
||||
Examples/Makefile
|
||||
Examples/test-suite/*/Makefile
|
||||
Examples/perl5/*/Makefile
|
||||
Examples/android/*/Makefile
|
||||
Examples/lua/*/Makefile
|
||||
Examples/guile/Makefile
|
||||
Examples/guile/*/Makefile
|
||||
Examples/xml/Makefile
|
||||
Examples/tcl/*/Makefile
|
||||
Examples/r/*/Makefile
|
||||
Examples/octave/*/Makefile
|
||||
Examples/ruby/*/Makefile
|
||||
Examples/mzscheme/*/Makefile
|
||||
Examples/python/*/Makefile
|
||||
Examples/csharp/*/Makefile
|
||||
Examples/d/*/Makefile
|
||||
Examples/pike/*/Makefile
|
||||
Examples/java/*/Makefile
|
||||
Examples/php/*/Makefile
|
||||
Examples/chicken/*/Makefile
|
||||
Examples/go/*/Makefile
|
||||
Examples/ocaml/*/Makefile
|
||||
Examples/modula3/*/Makefile
|
||||
CCache/Makefile
|
||||
Source/Makefile
|
||||
Doc/Manual/Makefile
|
||||
Examples/test-suite/javascript/*.cxx
|
||||
Examples/test-suite/javascript/*.c
|
||||
Examples/test-suite/javascript/*.so
|
||||
Source/Makefile.in
|
||||
IndentBaks/
|
||||
Examples/javascript/vanilla/
|
||||
*.pyc
|
||||
core
|
||||
Examples/test-suite/*/*.cxx
|
||||
Examples/test-suite/*/*.c
|
||||
Examples/test-suite/*/*.h
|
||||
Examples/test-suite/python/*.py
|
||||
Examples/javascript/*/*_wrap.c
|
||||
Tools/javascript/javascript
|
||||
Tools/javascript/javascript_d
|
||||
.settings
|
||||
*.log
|
||||
*_wrap.cxx
|
||||
Examples/*/*/*.gdb
|
||||
*.orig
|
||||
*.kdev4
|
||||
*.geany
|
||||
/build
|
||||
|
|
@ -47,7 +47,8 @@ CPP_TEST_CASES = \
|
|||
typemap_namespace \
|
||||
typemap_ns_using \
|
||||
using1 \
|
||||
using2
|
||||
using2 \
|
||||
javascript_unicode
|
||||
|
||||
SKIP_CPP_CASES = @SKIP_CPP_CASES@
|
||||
SKIP_C_CASES = @SKIP_C_CASES@
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
var str = "olé";
|
||||
|
||||
var copy = javascript_unicode.copy_string(str);
|
||||
|
||||
if (str !== copy) {
|
||||
print("Error: copy is not equal: original="+str+", copy="+copy);
|
||||
}
|
||||
10
Examples/test-suite/javascript_unicode.i
Normal file
10
Examples/test-suite/javascript_unicode.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module javascript_unicode
|
||||
|
||||
%newobject copy_string;
|
||||
|
||||
%inline %{
|
||||
#include <string.h>
|
||||
const char* copy_string(const char* str) {
|
||||
return strdup(str);
|
||||
}
|
||||
%}
|
||||
|
|
@ -8,12 +8,12 @@ SWIG_JSC_AsCharPtrAndSize(JSContextRef context, JSValueRef valRef, char** cptr,
|
|||
if(JSValueIsString(context, valRef)) {
|
||||
JSStringRef js_str = JSValueToStringCopy(context, valRef, NULL);
|
||||
size_t len = JSStringGetMaximumUTF8CStringSize(js_str);
|
||||
size_t abs_len = JSStringGetLength(js_str);
|
||||
char* cstr = (char*) malloc(len * sizeof(char));
|
||||
JSStringGetUTF8CString(js_str, cstr, len);
|
||||
/* JSStringGetUTF8CString returns the length including 0-terminator */
|
||||
len = JSStringGetUTF8CString(js_str, cstr, len);
|
||||
|
||||
if(alloc) *alloc = SWIG_NEWOBJ;
|
||||
if(psize) *psize = abs_len + 1;
|
||||
if(psize) *psize = len;
|
||||
if(cptr) *cptr = cstr;
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
|||
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for contruction of $jsmangledname");
|
||||
|
||||
fail:
|
||||
scope.Close(v8::Undefined());
|
||||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -114,10 +114,12 @@ fail:
|
|||
void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
|
||||
SWIGV8_Proxy* proxy = (SWIGV8_Proxy*) parameter;
|
||||
if(proxy->swigCMemOwn && proxy->swigCObject) {
|
||||
// std::cout << "Deleting wrapped instance: " << proxy->info->name << std::endl;
|
||||
$jsfree proxy->swigCObject;
|
||||
}
|
||||
delete proxy;
|
||||
|
||||
object.Clear();
|
||||
object.Dispose();
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -132,11 +134,13 @@ void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
|
|||
void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
|
||||
SWIGV8_Proxy* proxy = (SWIGV8_Proxy*) parameter;
|
||||
if(proxy->swigCMemOwn && proxy->swigCObject) {
|
||||
// std::cout << "Deleting wrapped instance: " << proxy->info->name << std::endl;
|
||||
$jstype arg1 = ($jstype)proxy->swigCObject;
|
||||
${destructor_action}
|
||||
}
|
||||
delete proxy;
|
||||
|
||||
object.Clear();
|
||||
object.Dispose();
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include <v8.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <iostream>
|
||||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg"; /* SWIG API */
|
||||
|
|
@ -72,12 +71,17 @@ public:
|
|||
};
|
||||
|
||||
~SWIGV8_Proxy() {
|
||||
handle.ClearWeak();
|
||||
handle->SetInternalField(0, v8::Undefined());
|
||||
handle.Dispose();
|
||||
handle.Clear();
|
||||
v8::V8::AdjustAmountOfExternalAllocatedMemory(-SWIGV8_AVG_OBJ_SIZE);
|
||||
}
|
||||
|
||||
bool swigCMemOwn;
|
||||
void *swigCObject;
|
||||
swig_type_info *info;
|
||||
v8::Persistent<v8::Object> handle;
|
||||
};
|
||||
|
||||
class SWIGV8_ClientData {
|
||||
|
|
@ -132,13 +136,15 @@ void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void* ptr, swig_type_info
|
|||
cdata->info = info;
|
||||
obj->SetPointerInInternalField(0, cdata);
|
||||
|
||||
v8::Persistent<v8::Object> weakptr = v8::Persistent<v8::Object>::New(obj);
|
||||
cdata->handle = v8::Persistent<v8::Object>::New(obj);
|
||||
|
||||
// clientdata must be set for owned data as we need to register the dtor
|
||||
if(cdata->swigCMemOwn) {
|
||||
weakptr.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
|
||||
cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
|
||||
} else {
|
||||
weakptr.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
|
||||
cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
|
||||
}
|
||||
cdata->handle.MarkIndependent();
|
||||
}
|
||||
|
||||
int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void** ptr, swig_type_info *info, int flags) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
%insert("init") %{
|
||||
#ifndef BUILDING_NODE_EXTENSION
|
||||
#define BUILDING_NODE_EXTENSION
|
||||
#endif
|
||||
|
||||
#include <node.h>
|
||||
%}
|
||||
|
||||
%define %node(moduleName)
|
||||
%insert("post-init") %{
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
%fragment("SWIGV8_valueToString", "header", fragment="SWIG_AsCharPtrAndSize") {
|
||||
std::string* SWIGV8_valueToStringPtr(v8::Handle<v8::Value> val) {
|
||||
|
||||
if (!val->IsString()) return 0;
|
||||
|
||||
int alloc;
|
||||
size_t size;
|
||||
char* chars;
|
||||
|
|
@ -48,17 +51,19 @@ namespace std {
|
|||
%{
|
||||
tmp = SWIGV8_valueToStringPtr($input);
|
||||
$1 = *tmp;
|
||||
delete tmp;
|
||||
if (tmp == 0) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Null pointer."))); goto fail; }
|
||||
if (tmp) delete tmp;
|
||||
%}
|
||||
|
||||
%typemap(in, fragment="SWIGV8_valueToString") const string &
|
||||
%{
|
||||
$1 = SWIGV8_valueToStringPtr($input);
|
||||
if ($1 == 0) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Null pointer."))); goto fail; }
|
||||
%}
|
||||
|
||||
%typemap(freearg) const string &
|
||||
%{
|
||||
delete $1;
|
||||
if ($1) delete $1;
|
||||
%}
|
||||
|
||||
%typemap(out, fragment="SWIGV8_stringToValue") string
|
||||
|
|
|
|||
|
|
@ -553,11 +553,13 @@ void JAVASCRIPT::main(int argc, char *argv[]) {
|
|||
case JSEmitter::V8:
|
||||
{
|
||||
emitter = swig_javascript_create_V8Emitter();
|
||||
Preprocessor_define("SWIG_JAVASCRIPT_V8 1", 0);
|
||||
break;
|
||||
}
|
||||
case JSEmitter::JavascriptCore:
|
||||
{
|
||||
emitter = swig_javascript_create_JSCEmitter();
|
||||
Preprocessor_define("SWIG_JAVASCRIPT_JSC 1", 0);
|
||||
break;
|
||||
}
|
||||
case JSEmitter::QtScript:
|
||||
|
|
@ -667,7 +669,6 @@ int JSEmitter::initialize(Node *n) {
|
|||
namespaces = NewHash();
|
||||
Hash *global_namespace;
|
||||
if(State::IsSet(state.global(FLAG_NO_MODULE_OBJECT))) {
|
||||
Printf(stdout, "AAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||
global_namespace = createNamespaceEntry("global", 0);
|
||||
} else {
|
||||
global_namespace = createNamespaceEntry(Char(Getattr(n, "name")), "global");
|
||||
|
|
|
|||
|
|
@ -6,11 +6,16 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef __APPLE__
|
||||
#define LIBRARY_EXT ".dylib"
|
||||
#else
|
||||
#define LIBRARY_EXT ".so"
|
||||
#endif
|
||||
#include <dlfcn.h>
|
||||
#define LOAD_LIBRARY(name) dlopen(name, RTLD_LAZY)
|
||||
#define CLOSE_LIBRARY(handle) dlclose(handle)
|
||||
#define LIBRARY_ERROR dlerror
|
||||
#define LIBRARYFILE(name) std::string("lib").append(name).append(".so")
|
||||
#define LIBRARYFILE(name) std::string("lib").append(name).append(LIBRARY_EXT)
|
||||
#else
|
||||
#error "implement dll loading"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ bool V8Shell::RunShell() {
|
|||
|
||||
|
||||
bool V8Shell::InitializeEngine() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void V8Shell::ExtendEngine() {
|
||||
|
|
@ -194,6 +195,7 @@ bool V8Shell::ExecuteScript(const std::string& source, const std::string& name)
|
|||
}
|
||||
|
||||
bool V8Shell::DisposeEngine() {
|
||||
return true;
|
||||
}
|
||||
|
||||
v8::Persistent<v8::Context> V8Shell::CreateShellContext() {
|
||||
|
|
|
|||
89
configure.in
89
configure.in
|
|
@ -1106,11 +1106,13 @@ if test -z "$JSCOREINCDIR"; then
|
|||
esac
|
||||
fi
|
||||
|
||||
JSCORE=0
|
||||
for d in $JSCOREINCDIR ; do
|
||||
if test -r "$d/JavaScriptCore/JavaScript.h" || test -r "$d/JavaScript.h" ; then
|
||||
AC_MSG_RESULT($d)
|
||||
JSCOREINCDIR=$d
|
||||
JSCOREINC=-I\"$d\"
|
||||
JSCORE=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
|
@ -1119,42 +1121,46 @@ if test "$JSCOREINC" = "" ; then
|
|||
AC_MSG_RESULT(not found)
|
||||
fi
|
||||
|
||||
# under linux look for the javascript core library
|
||||
case $host in
|
||||
*-*-linux*)
|
||||
# check for JavaScriptCore, Webkit libraries
|
||||
AC_ARG_WITH(jscorelib,[ --with-jscorelib =path Set location of JavaScriptCore (Webkit) library directory], [JSCORELIB="-L$withval"], [JSCORELIB=])
|
||||
AC_MSG_CHECKING(for JavaScriptCore(Webkit) library)
|
||||
|
||||
# check for JavaScriptCore, Webkit libraries
|
||||
AC_ARG_WITH(jscorelib,[ --with-jscorelib =path Set location of JavaScriptCore (Webkit) library directory],
|
||||
[JSCORELIB="-L$withval"], [JSCORELIB=])
|
||||
AC_MSG_CHECKING(for JavaScriptCore(Webkit) library)
|
||||
if test -z "$JSCORELIB"; then
|
||||
JSCORELIBDIRS="/usr/lib/ /usr/local/lib/"
|
||||
for i in $JSCORELIBDIRS ; do
|
||||
|
||||
if test -z "$JSCORELIB"; then
|
||||
dirs="/usr/lib/ /usr/local/lib/"
|
||||
for i in $dirs ; do
|
||||
if test -r $i/libwebkit-1.0.la; then
|
||||
AC_MSG_RESULT($i)
|
||||
JSCORELIB="-L$i -lwebkit-1.0"
|
||||
break
|
||||
fi
|
||||
|
||||
if test -r $i/libwebkit-1.0.la; then
|
||||
AC_MSG_RESULT($i)
|
||||
JSCORELIB="-L$i -lwebkit-1.0"
|
||||
break
|
||||
fi
|
||||
if test -r $i/libjavascriptcoregtk-1.0.so; then
|
||||
AC_MSG_RESULT($i)
|
||||
JSCORELIB="-L$i -ljavascriptcoregtk-1.0"
|
||||
break
|
||||
fi
|
||||
|
||||
if test -r $i/libjavascriptcoregtk-1.0.so; then
|
||||
AC_MSG_RESULT($i)
|
||||
JSCORELIB="-L$i -ljavascriptcoregtk-1.0"
|
||||
break
|
||||
fi
|
||||
if test -r $i/libwebkitgtk-1.0.so; then
|
||||
AC_MSG_RESULT($i)
|
||||
JSCORELIB="-L$i -lwebkitgtk-1.0"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -r $i/libwebkitgtk-1.0.so; then
|
||||
AC_MSG_RESULT($i)
|
||||
JSCORELIB="-L$i -lwebkitgtk-1.0"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$JSCORELIB"; then
|
||||
AC_MSG_RESULT(not found)
|
||||
JSCORE=
|
||||
else
|
||||
AC_MSG_RESULT($JSCORELIB)
|
||||
JSCORE=1
|
||||
fi
|
||||
if test -z "$JSCORELIB"; then
|
||||
AC_MSG_RESULT(not found)
|
||||
JSCORE=0
|
||||
else
|
||||
AC_MSG_RESULT($JSCORELIB)
|
||||
JSCORE=1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# linking options
|
||||
case $host in
|
||||
|
|
@ -1163,7 +1169,7 @@ case $host in
|
|||
JSCORECFLAGS=""
|
||||
;;
|
||||
*-*-linux*)
|
||||
JSCOREDYNAMICLINKING="$JSCORELIB"
|
||||
JSCOREDYNAMICLINKING="$JSCORELIB"
|
||||
JSCORECFLAGS=""
|
||||
;;
|
||||
*)
|
||||
|
|
@ -1179,13 +1185,13 @@ case $host in
|
|||
esac
|
||||
|
||||
if test "$JS_NO_WARNINGS" == "1"; then
|
||||
case $host in
|
||||
*-*-darwin* | *-*-linux* | *-*-cygwin* | *-*-mingw*)
|
||||
JSCXXFLAGS="`echo $CXXFLAGS | sed 's/-Wall//g'`"
|
||||
;;
|
||||
*)
|
||||
JSCXXFLAGS="$CXXFLAGS"
|
||||
esac
|
||||
case $host in
|
||||
*-*-darwin* | *-*-linux* | *-*-cygwin* | *-*-mingw*)
|
||||
JSCXXFLAGS="`echo $CXXFLAGS | sed 's/-Wall//g'`"
|
||||
;;
|
||||
*)
|
||||
JSCXXFLAGS="$CXXFLAGS"
|
||||
esac
|
||||
fi
|
||||
|
||||
# library output
|
||||
|
|
@ -1201,7 +1207,6 @@ case $host in
|
|||
JSCORECXXSHARED='$(CXXSHARED)'
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_SUBST(JSCORE)
|
||||
AC_SUBST(JSCOREINC)
|
||||
|
|
@ -1259,8 +1264,10 @@ done
|
|||
|
||||
if test "$JSV8LIB" = "" ; then
|
||||
AC_MSG_RESULT(not found)
|
||||
JSV8=
|
||||
else
|
||||
AC_MSG_RESULT($JSV8LIB)
|
||||
JSV8=1
|
||||
fi
|
||||
|
||||
|
||||
|
|
@ -1277,8 +1284,10 @@ case $host in
|
|||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(JSV8)
|
||||
AC_SUBST(JSV8INC)
|
||||
AC_SUBST(JSV8DYNAMICLINKING)
|
||||
|
||||
AC_SUBST(JSDEFAULT)
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue