Merge branch 'devel' of github.com:oliver----/swig-v8 into devel
This commit is contained in:
commit
b0cb875ac1
8 changed files with 114 additions and 67 deletions
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Makefile
|
||||
/Examples/Makefile
|
||||
/Examples/*/Makefile
|
||||
/Examples/test-suite/*/Makefile
|
||||
/CCache
|
||||
*.Po
|
||||
swigp4.ml
|
||||
Source/Include/stamp-h1
|
||||
Source/Include/swigconfig.h
|
||||
config.log
|
||||
config.status
|
||||
preinst-swig
|
||||
swig.spec
|
||||
|
|
@ -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@
|
||||
|
|
@ -94,7 +95,7 @@ run_testcase = \
|
|||
|
||||
# Clean
|
||||
%.clean:
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile javascript_clean
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
%}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/* ------------------------------------------------------------
|
||||
* utility methods for char strings
|
||||
* utility methods for char strings
|
||||
* ------------------------------------------------------------ */
|
||||
%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
|
||||
SWIGINTERN int
|
||||
|
|
@ -8,14 +8,14 @@ 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;
|
||||
} else {
|
||||
if(JSValueIsObject(context, valRef)) {
|
||||
|
|
@ -47,7 +47,7 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
|
|||
if (size > INT_MAX) {
|
||||
// TODO: handle extra long strings
|
||||
//swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
|
||||
//return pchar_descriptor ?
|
||||
//return pchar_descriptor ?
|
||||
// SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
|
||||
return JSValueMakeUndefined(context);
|
||||
} else {
|
||||
|
|
@ -58,7 +58,7 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
|
|||
for(i=0;i<size;++i) {
|
||||
c[i] = carray[i];
|
||||
}
|
||||
c[size] = 0;
|
||||
c[size] = 0;
|
||||
jsstring = JSStringCreateWithUTF8CString(c);
|
||||
} else {
|
||||
jsstring = JSStringCreateWithUTF8CString(carray);
|
||||
|
|
@ -81,19 +81,19 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
|
|||
SWIG_NewCopyCharArray,
|
||||
SWIG_DeleteCharArray,
|
||||
FragLimits, CHAR_MIN, CHAR_MAX)
|
||||
|
||||
|
||||
%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) {
|
||||
SWIGINTERNINLINE SWIG_Object
|
||||
SWIGINTERNINLINE SWIG_Object
|
||||
SWIG_JSC_From##CharName##Ptr(JSContextRef context, const Char *cptr)
|
||||
{
|
||||
{
|
||||
return SWIG_JSC_FromCharPtrAndSize(context, cptr, (cptr ? SWIG_CharPtrLen(cptr) : 0));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_From"#CharName"Array","header",fragment=#SWIG_FromCharPtrAndSize) {
|
||||
SWIGINTERNINLINE SWIG_Object
|
||||
SWIGINTERNINLINE SWIG_Object
|
||||
SWIG_JSC_From##CharName##Array(JSContextRef context, const Char *cptr, size_t size)
|
||||
{
|
||||
{
|
||||
return SWIG_JSC_FromCharPtrAndSize(context, cptr, size);
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ SWIG_JSC_From##CharName##Array(JSContextRef context, const Char *cptr, size_t si
|
|||
%fragment("SWIG_As" #CharName "Array","header",fragment=#SWIG_AsCharPtrAndSize) {
|
||||
SWIGINTERN int
|
||||
SWIG_JSC_As##CharName##Array(JSContextRef context, SWIG_Object obj, Char *val, size_t size)
|
||||
{
|
||||
{
|
||||
Char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ;
|
||||
int res = SWIG_JSC_AsCharPtrAndSize(context, obj, &cptr, &csize, &alloc);
|
||||
if (SWIG_IsOK(res)) {
|
||||
|
|
@ -118,7 +118,7 @@ SWIG_JSC_As##CharName##Array(JSContextRef context, SWIG_Object obj, Char *val, s
|
|||
if (alloc == SWIG_NEWOBJ) {
|
||||
SWIG_DeleteCharArray(cptr);
|
||||
res = SWIG_DelNewMask(res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ) SWIG_DeleteCharArray(cptr);
|
||||
|
|
@ -133,8 +133,8 @@ SWIG_JSC_As##CharName##Array(JSContextRef context, SWIG_Object obj, Char *val, s
|
|||
|
||||
%fragment(SWIG_From_frag(Char),"header",fragment=#SWIG_FromCharPtrAndSize) {
|
||||
SWIGINTERNINLINE SWIG_Object
|
||||
SWIG_From_dec(Char)(Char c)
|
||||
{
|
||||
SWIG_From_dec(Char)(Char c)
|
||||
{
|
||||
return SWIG_JSC_FromCharPtrAndSize(context, &c,1);
|
||||
}
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ SWIG_From_dec(Char)(Char c)
|
|||
fragment=SWIG_AsVal_frag(long)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
|
||||
{
|
||||
{
|
||||
int res = SWIG_As##CharName##Array(obj, val, 1);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
long v;
|
||||
|
|
@ -162,7 +162,7 @@ SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
|
|||
}
|
||||
}
|
||||
|
||||
%_typemap_string(StringCode,
|
||||
%_typemap_string(StringCode,
|
||||
Char,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtrAndSize,
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
99
configure.in
99
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,51 +1121,55 @@ 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
|
||||
*-*-darwin*)
|
||||
*-*-darwin*)
|
||||
JSCOREDYNAMICLINKING="-framework JavaScriptCore"
|
||||
JSCORECFLAGS=""
|
||||
;;
|
||||
*-*-linux*)
|
||||
JSCOREDYNAMICLINKING="$JSCORELIB"
|
||||
*-*-linux*)
|
||||
JSCOREDYNAMICLINKING="$JSCORELIB"
|
||||
JSCORECFLAGS=""
|
||||
;;
|
||||
*)
|
||||
|
|
@ -1179,18 +1185,18 @@ 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
|
||||
case $host in
|
||||
*-*-darwin*)
|
||||
*-*-darwin*)
|
||||
JSCORESO=".dylib"
|
||||
JSCORELDSHARED='$(CC) -dynamiclib'
|
||||
JSCORECXXSHARED='$(CXX) -dynamiclib'
|
||||
|
|
@ -1201,7 +1207,6 @@ case $host in
|
|||
JSCORECXXSHARED='$(CXXSHARED)'
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_SUBST(JSCORE)
|
||||
AC_SUBST(JSCOREINC)
|
||||
|
|
@ -1259,17 +1264,19 @@ done
|
|||
|
||||
if test "$JSV8LIB" = "" ; then
|
||||
AC_MSG_RESULT(not found)
|
||||
JSV8=
|
||||
else
|
||||
AC_MSG_RESULT($JSV8LIB)
|
||||
JSV8=1
|
||||
fi
|
||||
|
||||
|
||||
# linking options
|
||||
case $host in
|
||||
*-*-darwin*)
|
||||
*-*-darwin*)
|
||||
JSV8DYNAMICLINKING="" # TODO: add osx configuration
|
||||
;;
|
||||
*-*-linux*)
|
||||
*-*-linux*)
|
||||
JSV8DYNAMICLINKING="$JSV8LIB"
|
||||
;;
|
||||
*)
|
||||
|
|
@ -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