fix paths and introduce exceptions in SWIG and android yap
This commit is contained in:
parent
e1fc397cc1
commit
6ba88f8cc0
13
CXX/yapi.cpp
13
CXX/yapi.cpp
@ -627,16 +627,3 @@ YAPQuery *YAPEngine::query( char *s ) {
|
|||||||
YAPQuery *n = new YAPQuery( s );
|
YAPQuery *n = new YAPQuery( s );
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPQuery *YAPEngine::safeQuery( char *s ) {
|
|
||||||
try {
|
|
||||||
YAPQuery *n = new YAPQuery( s );
|
|
||||||
n->setFlag( PL_Q_CATCH_EXCEPTION );
|
|
||||||
n->resetFlag( PL_Q_PASS_EXCEPTION );
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
catch (YAPError yerr) {
|
|
||||||
yerror = yerr;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -566,7 +566,7 @@ public:
|
|||||||
char *topLevel = (char *)NULL,
|
char *topLevel = (char *)NULL,
|
||||||
bool script = FALSE,
|
bool script = FALSE,
|
||||||
bool fastBoot = FALSE,
|
bool fastBoot = FALSE,
|
||||||
YAPCallback *callback=(YAPCallback *)NULL); /// construct a new engine, including aaccess to callbacks
|
YAPCallback *callback=(YAPCallback *)NULL); /// construct a new engine, including aaccess to callbacks
|
||||||
/// kill engine
|
/// kill engine
|
||||||
~YAPEngine() { delYAPCallback(); }
|
~YAPEngine() { delYAPCallback(); }
|
||||||
/// remove current callback
|
/// remove current callback
|
||||||
@ -581,8 +581,6 @@ public:
|
|||||||
YAPError hasError( ) { return yerror; }
|
YAPError hasError( ) { return yerror; }
|
||||||
/// build a query on the engine
|
/// build a query on the engine
|
||||||
YAPQuery *query( char *s );
|
YAPQuery *query( char *s );
|
||||||
/// build a query on the engine handling exceptions
|
|
||||||
YAPQuery *safeQuery( char *s );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
14
configure
vendored
14
configure
vendored
@ -753,6 +753,7 @@ PKG_CLIB
|
|||||||
PKG_CHR
|
PKG_CHR
|
||||||
NO_BUILTIN_REGEXP
|
NO_BUILTIN_REGEXP
|
||||||
YAP_EXTRAS
|
YAP_EXTRAS
|
||||||
|
GMPDIR
|
||||||
SONAMEFLAG
|
SONAMEFLAG
|
||||||
DYNYAPLIB
|
DYNYAPLIB
|
||||||
YAPLIB
|
YAPLIB
|
||||||
@ -4567,10 +4568,12 @@ fi
|
|||||||
if test "${with_gmp+set}" = set; then :
|
if test "${with_gmp+set}" = set; then :
|
||||||
withval=$with_gmp; if test "$withval" = yes; then
|
withval=$with_gmp; if test "$withval" = yes; then
|
||||||
yap_cv_gmp=yes
|
yap_cv_gmp=yes
|
||||||
|
GMPDIR=/usr
|
||||||
elif test "$withval" = no; then
|
elif test "$withval" = no; then
|
||||||
yap_cv_gmp=no
|
yap_cv_gmp=no
|
||||||
else
|
else
|
||||||
yap_cv_gmp=$with_gmp
|
yap_cv_gmp="$with_gmp"
|
||||||
|
GMPDIR="$with_gmp"
|
||||||
LDFLAGS="$LDFLAGS -L${yap_cv_gmp}/lib"
|
LDFLAGS="$LDFLAGS -L${yap_cv_gmp}/lib"
|
||||||
LIBS="$LIBS -L${yap_cv_gmp}/lib"
|
LIBS="$LIBS -L${yap_cv_gmp}/lib"
|
||||||
CPPFLAGS="$CPPFLAGS -I${yap_cv_gmp}/include"
|
CPPFLAGS="$CPPFLAGS -I${yap_cv_gmp}/include"
|
||||||
@ -8872,6 +8875,7 @@ CMDEXT=sh
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc threaded code" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc threaded code" >&5
|
||||||
@ -13595,7 +13599,7 @@ else
|
|||||||
JAVA_TEST=Test.java
|
JAVA_TEST=Test.java
|
||||||
CLASS_TEST=Test.class
|
CLASS_TEST=Test.class
|
||||||
cat << \EOF > $JAVA_TEST
|
cat << \EOF > $JAVA_TEST
|
||||||
/* #line 13598 "configure" */
|
/* #line 13602 "configure" */
|
||||||
public class Test {
|
public class Test {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@ -13771,7 +13775,7 @@ EOF
|
|||||||
if uudecode$EXEEXT Test.uue; then
|
if uudecode$EXEEXT Test.uue; then
|
||||||
ac_cv_prog_uudecode_base64=yes
|
ac_cv_prog_uudecode_base64=yes
|
||||||
else
|
else
|
||||||
echo "configure: 13774: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
|
echo "configure: 13778: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
|
||||||
echo "configure: failed file was:" >&5
|
echo "configure: failed file was:" >&5
|
||||||
cat Test.uue >&5
|
cat Test.uue >&5
|
||||||
ac_cv_prog_uudecode_base64=no
|
ac_cv_prog_uudecode_base64=no
|
||||||
@ -13902,7 +13906,7 @@ else
|
|||||||
JAVA_TEST=Test.java
|
JAVA_TEST=Test.java
|
||||||
CLASS_TEST=Test.class
|
CLASS_TEST=Test.class
|
||||||
cat << \EOF > $JAVA_TEST
|
cat << \EOF > $JAVA_TEST
|
||||||
/* #line 13905 "configure" */
|
/* #line 13909 "configure" */
|
||||||
public class Test {
|
public class Test {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@ -13937,7 +13941,7 @@ JAVA_TEST=Test.java
|
|||||||
CLASS_TEST=Test.class
|
CLASS_TEST=Test.class
|
||||||
TEST=Test
|
TEST=Test
|
||||||
cat << \EOF > $JAVA_TEST
|
cat << \EOF > $JAVA_TEST
|
||||||
/* [#]line 13940 "configure" */
|
/* [#]line 13944 "configure" */
|
||||||
public class Test {
|
public class Test {
|
||||||
public static void main (String args[]) {
|
public static void main (String args[]) {
|
||||||
System.exit (0);
|
System.exit (0);
|
||||||
|
@ -192,10 +192,12 @@ AC_ARG_WITH(gmp,
|
|||||||
[ --with-gmp[=DIR] use GNU Multiple Precision in DIR],
|
[ --with-gmp[=DIR] use GNU Multiple Precision in DIR],
|
||||||
if test "$withval" = yes; then
|
if test "$withval" = yes; then
|
||||||
yap_cv_gmp=yes
|
yap_cv_gmp=yes
|
||||||
|
GMPDIR=/usr
|
||||||
elif test "$withval" = no; then
|
elif test "$withval" = no; then
|
||||||
yap_cv_gmp=no
|
yap_cv_gmp=no
|
||||||
else
|
else
|
||||||
yap_cv_gmp=$with_gmp
|
yap_cv_gmp="$with_gmp"
|
||||||
|
GMPDIR="$with_gmp"
|
||||||
LDFLAGS="$LDFLAGS -L${yap_cv_gmp}/lib"
|
LDFLAGS="$LDFLAGS -L${yap_cv_gmp}/lib"
|
||||||
LIBS="$LIBS -L${yap_cv_gmp}/lib"
|
LIBS="$LIBS -L${yap_cv_gmp}/lib"
|
||||||
CPPFLAGS="$CPPFLAGS -I${yap_cv_gmp}/include"
|
CPPFLAGS="$CPPFLAGS -I${yap_cv_gmp}/include"
|
||||||
@ -1396,6 +1398,7 @@ AC_SUBST(YAPLIB)
|
|||||||
AC_SUBST(DYNYAPLIB)
|
AC_SUBST(DYNYAPLIB)
|
||||||
AC_SUBST(LDFLAGS)
|
AC_SUBST(LDFLAGS)
|
||||||
AC_SUBST(SONAMEFLAG)
|
AC_SUBST(SONAMEFLAG)
|
||||||
|
AC_SUBST(GMPDIR)
|
||||||
dnl install_info
|
dnl install_info
|
||||||
AC_SUBST(INSTALL_INFO)
|
AC_SUBST(INSTALL_INFO)
|
||||||
dnl let YAP_EXTRAS fall through configure, from the env into Makefile
|
dnl let YAP_EXTRAS fall through configure, from the env into Makefile
|
||||||
|
@ -15,7 +15,14 @@ ANDROID_RELEASE=19
|
|||||||
# ANDROID_ARCH= arm, x86, mips
|
# ANDROID_ARCH= arm, x86, mips
|
||||||
ANDROID_ARCH=arm
|
ANDROID_ARCH=arm
|
||||||
# ANDROID_BUILD=linux
|
# ANDROID_BUILD=linux
|
||||||
ANDROID_BUILD=linux
|
if test `uname` = Darwin
|
||||||
|
then
|
||||||
|
ANDROID_BUILD_TOOLS=macosx
|
||||||
|
ANDROID_BUILD=darwin
|
||||||
|
else
|
||||||
|
ANDROID_BUILD_TOOLS=linux
|
||||||
|
ANDROID_BUILD=linux
|
||||||
|
fi
|
||||||
|
|
||||||
# what android to compile for
|
# what android to compile for
|
||||||
ANDROID_IMAGE=first
|
ANDROID_IMAGE=first
|
||||||
@ -31,11 +38,11 @@ fi
|
|||||||
|
|
||||||
# check if the SDK is at the usual locations
|
# check if the SDK is at the usual locations
|
||||||
|
|
||||||
if test -d $HOME/Yap/android-sdk-"$ANDROID_BUILD"
|
if test -d $HOME/Yap/android-sdk-"$ANDROID_BUILD_TOOLS"
|
||||||
then
|
then
|
||||||
export SDK_ROOT=$HOME/Yap/android-sdk-"$ANDROID_BUILD"
|
export SDK_ROOT=$HOME/Yap/android-sdk-"$ANDROID_BUILD_TOOLS"
|
||||||
else
|
else
|
||||||
export SDK_ROOT=/scratch/vitor/android-sdk-"$ANDROID_BUILD"
|
export SDK_ROOT=/scratch/vitor/android-sdk-"$ANDROID_BUILD_TOOLS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if the NDK is at the usual locations
|
# check if the NDK is at the usual locations
|
||||||
@ -71,7 +78,7 @@ fi
|
|||||||
GCC_VERSION=4.8
|
GCC_VERSION=4.8
|
||||||
|
|
||||||
#========================================================
|
#========================================================
|
||||||
# should be fine
|
# should need no further work.
|
||||||
#========================================================
|
#========================================================
|
||||||
|
|
||||||
export ANDROID_NDK_ROOT="$NDK_ROOT"/
|
export ANDROID_NDK_ROOT="$NDK_ROOT"/
|
||||||
@ -91,14 +98,23 @@ then
|
|||||||
echo using the setup at "$BUILDTOOLCHAIN"
|
echo using the setup at "$BUILDTOOLCHAIN"
|
||||||
else
|
else
|
||||||
"$NDK_ROOT"/build/tools/make-standalone-toolchain.sh \
|
"$NDK_ROOT"/build/tools/make-standalone-toolchain.sh \
|
||||||
--platform="$ANDROID_PLATFORM" \
|
--platform="$ANDROID_PLATFORM" \
|
||||||
--toolchain="$ANDROID_ARCH"-"$ANDROID_BUILD"-androideabi-"$GCC_VERSION" \
|
--toolchain="$ANDROID_ARCH"-linux-androideabi-"$GCC_VERSION" \
|
||||||
--install-dir="$BUILDTOOLCHAIN"
|
--install-dir="$BUILDTOOLCHAIN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
mkdir -p $BUILDDROID
|
mkdir -p $BUILDDROID
|
||||||
|
|
||||||
|
startemulator () {
|
||||||
|
EMS=`ps -ef | grep emulator64| grep -v grep`
|
||||||
|
if test x"$EMS" = x
|
||||||
|
then
|
||||||
|
nohup emulator -avd $IMAGE &
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cd $BUILDDROID
|
cd $BUILDDROID
|
||||||
|
|
||||||
if test x$1 = xmake
|
if test x$1 = xmake
|
||||||
@ -110,18 +126,14 @@ then
|
|||||||
return 0
|
return 0
|
||||||
elif test x$1 = xeclipse
|
elif test x$1 = xeclipse
|
||||||
then
|
then
|
||||||
emulator -avd $IMAGE &
|
startemulator
|
||||||
"$ECLIPSE"eclipse &
|
"$ECLIPSE" &
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
EMS=`ps -ef | grep emulator64| grep -v grep`
|
startemulator
|
||||||
if test x"$EMS" = x
|
|
||||||
then
|
|
||||||
emulator -avd $IMAGE &
|
|
||||||
fi
|
|
||||||
rm -rf "$BUILDDROID"/*
|
rm -rf "$BUILDDROID"/*
|
||||||
cd "$BUILDDROID"
|
cd "$BUILDDROID"
|
||||||
"$YAP_SRC"/configure --host="$ANDROID_ARCH"-"$ANDROID_BUILD"-androideabi --prefix=`pwd` --enable-low-level-tracer --enable-debug-yap --enable-dynamic-loading --with-swig --with-gmp=$GMPDIR --disable-chr #--enable-threads
|
"$YAP_SRC"/configure --host="$ANDROID_ARCH"-linux-androideabi --prefix=`pwd` --enable-low-level-tracer --enable-debug-yap --enable-dynamic-loading --with-swig --with-gmp=$GMPDIR --disable-chr #--enable-threads
|
||||||
make depend
|
make depend
|
||||||
make -j install
|
make -j install
|
||||||
fi
|
fi
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 3637c14d2f0bcb2113e28de5aa0cae25a55dcca8
|
Subproject commit 911ad4d6f1cf58828dc755621c7f1e6072073a6d
|
@ -6,7 +6,7 @@ include $(CLEAR_VARS)
|
|||||||
|
|
||||||
LOCAL_LDLIBS := -landroid -llog
|
LOCAL_LDLIBS := -landroid -llog
|
||||||
LOCAL_MODULE := yap0
|
LOCAL_MODULE := yap0
|
||||||
LOCAL_SRC_FILES += @abs_top_builddir@/../gmp-android/lib/libgmp.so
|
LOCAL_SRC_FILES += @GMPDIR@/lib/libgmp.so
|
||||||
include $(PREBUILT_SHARED_LIBRARY)
|
include $(PREBUILT_SHARED_LIBRARY)
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
@ -24,7 +24,7 @@ LOCAL_MODULE := example
|
|||||||
LOCAL_SHARED_LIBRARIES := yap0 yap1
|
LOCAL_SHARED_LIBRARIES := yap0 yap1
|
||||||
LOCAL_STATIC_LIBRARIES := @abs_top_builddir@/libYap.ar
|
LOCAL_STATIC_LIBRARIES := @abs_top_builddir@/libYap.ar
|
||||||
LOCAL_SRC_FILES += @abs_top_builddir@/packages/swig/android/jni/yap_wrap.cpp
|
LOCAL_SRC_FILES += @abs_top_builddir@/packages/swig/android/jni/yap_wrap.cpp
|
||||||
LOCAL_C_INCLUDES := @abs_top_builddir@ @abs_top_builddir@/../gmp-android/include @srcdir@/../../H @srcdir@/../../include @srcdir@/../../os @srcdir@/../../OPTYap @srcdir@/../../BEAM @srcdir@/../../CXX
|
LOCAL_C_INCLUDES := @abs_top_builddir@ @GMPDIR@/include @srcdir@/../../H @srcdir@/../../include @srcdir@/../../os @srcdir@/../../OPTYap @srcdir@/../../BEAM @srcdir@/../../CXX
|
||||||
LOCAL_CFLAGS := @YAP_EXTRAS@ @DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"\"
|
LOCAL_CFLAGS := @YAP_EXTRAS@ @DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"\"
|
||||||
LOCAL_CPP_FEATURES := rtti
|
LOCAL_CPP_FEATURES := rtti
|
||||||
# LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
|
# LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
|
||||||
|
@ -30,7 +30,7 @@ public class JavaYap extends Activity
|
|||||||
YAPQuery q = eng.query( str );
|
YAPQuery q = eng.query( str );
|
||||||
|
|
||||||
YAPListTerm vs0 = q.namedVars();
|
YAPListTerm vs0 = q.namedVars();
|
||||||
int rc;
|
Boolean rc;
|
||||||
|
|
||||||
// text.setText("");
|
// text.setText("");
|
||||||
if (vs0.nil()) {
|
if (vs0.nil()) {
|
||||||
|
@ -12,7 +12,7 @@ def go():
|
|||||||
try:
|
try:
|
||||||
q = engine.query(s)
|
q = engine.query(s)
|
||||||
except:
|
except:
|
||||||
... print "Oops! That was no valid number. Try again..."
|
print "Oops! That was no valid number. Try again..."
|
||||||
while q.next():
|
while q.next():
|
||||||
vs = q.namedVars();
|
vs = q.namedVars();
|
||||||
while vs.length() > 0:
|
while vs.length() > 0:
|
||||||
|
@ -1,11 +1,51 @@
|
|||||||
/* example.i */
|
/* example.i */
|
||||||
%module(directors="1") yap
|
%module(directors="1") yap
|
||||||
|
|
||||||
|
// Language independent exception handler
|
||||||
|
%include exception.i
|
||||||
|
|
||||||
|
class YAPPredicate;
|
||||||
|
class YAPEngine;
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
%exception YAPPredicate {
|
||||||
|
try {
|
||||||
|
$action
|
||||||
|
} catch (...) {
|
||||||
|
PyErr_SetString(PyExc_SyntaxError, "syntax error");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%exception query {
|
||||||
|
try {
|
||||||
|
$action
|
||||||
|
}
|
||||||
|
catch (YAPError YAP_SYMTAX_ERROR) {
|
||||||
|
SWIG_exception(SWIG_SyntaxError,"Syntax Error exception");
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%exception next {
|
||||||
|
try {
|
||||||
|
$action
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
/* Put header files here or function declarations like below */
|
/* Put header files here or function declarations like below */
|
||||||
|
|
||||||
#define YAP_CPP_INTERFACE 1
|
#define YAP_CPP_INTERFACE 1
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#include "yapi.hh"
|
#include "yapi.hh"
|
||||||
@ -26,20 +66,6 @@ extern "C" {
|
|||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") YAPCallback;
|
%feature("director") YAPCallback;
|
||||||
|
|
||||||
class YAPPredicate;
|
|
||||||
|
|
||||||
#ifdef SWIGPYTHON
|
|
||||||
%exception YAPPredicate {
|
|
||||||
try {
|
|
||||||
$action
|
|
||||||
} catch (...) {
|
|
||||||
PyErr_SetString(PyExc_SyntaxError, "syntax error");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
%include "yapi.hh"
|
%include "yapi.hh"
|
||||||
|
|
||||||
#ifdef SWIGJAVA
|
#ifdef SWIGJAVA
|
||||||
|
Reference in New Issue
Block a user