diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index 381003bfa..535505744 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -379,7 +379,7 @@ YAPPredicate::YAPPredicate(const char *s, Term **outp, term_t &vnames) throw (in vnames = Yap_NewSlots(1 PASS_REGS); Term t = Yap_StringToTerm(s, strlen(s)+1, vnames); if (t == 0L) - throw SYNTAX_ERROR; + throw YAPError::YAP_SYNTAX_ERROR; ap = getPred( t, outp ); //{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "OUT vnames=%d ap=%p LCL0=%p", vnames, ap, LCL0) ; } } @@ -575,7 +575,6 @@ displayWithJava(int c) Yap_AndroidBufp[Yap_AndroidSz] = '\0'; if (c == '\n' ) { Yap_AndroidBufp[Yap_AndroidSz] = '\0'; - __android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "after char %c:%s %p",c, Yap_AndroidBufp, curren); curren->run(Yap_AndroidBufp); Yap_AndroidSz = 0; } @@ -636,8 +635,8 @@ YAPQuery *YAPEngine::safeQuery( char *s ) { n->resetFlag( PL_Q_PASS_EXCEPTION ); return n; } - catch (yap_error_number errno) { - error = errno; + catch (YAPError yerr) { + yerror = yerr; return 0; } } diff --git a/CXX/yapi.hh b/CXX/yapi.hh index 972be7313..68888e9b9 100644 --- a/CXX/yapi.hh +++ b/CXX/yapi.hh @@ -59,6 +59,8 @@ extern "C" { #include "YapText.h" +#include "yapie.hh" + #if HAVE_STDARG_H #include #endif @@ -421,7 +423,7 @@ public: Term t, tp; t = YAP_ReadBuffer(s,&tp); if (t == 0L) - throw SYNTAX_ERROR; + throw YAPError::YAP_SYNTAX_ERROR; ap = getPred( t, (Term **)NULL ); } @@ -433,7 +435,7 @@ public: Term t, tp; t = YAP_ReadBuffer(s,&tp); if (t == 0L) - throw SYNTAX_ERROR; + throw YAPError::YAP_SYNTAX_ERROR; ap = getPred( t, (Term **)NULL ); } @@ -551,7 +553,7 @@ class YAPEngine { private: YAPCallback *_callback; YAP_init_args init_args; - yap_error_number error; + YAPError yerror; public: YAPEngine(char *savedState = (char *)NULL, size_t stackSize = 0, @@ -575,12 +577,12 @@ public: void run() { if (_callback) _callback->run(); } /// execute the callback with a text argument. void run( char *s) { if (_callback) _callback->run(s); } + /// execute the callback with a text argument. + YAPError hasError( ) { return yerror; } /// build a query on the engine YAPQuery *query( char *s ); /// build a query on the engine handling exceptions YAPQuery *safeQuery( char *s ); - - yap_error_number hasError( ); //> report whether the engine has found an error }; /* diff --git a/CXX/yapie.hh b/CXX/yapie.hh index 4cacd1ec6..00d9741c3 100644 --- a/CXX/yapie.hh +++ b/CXX/yapie.hh @@ -10,27 +10,15 @@ class YAPPredicate; class YAPError { public: - static const int SYNTAX_ERROR = 0x10000; //> syntax error - static const int DOMAIN_ERROR = 0x20000; //> usually illegal parameter, like asin( 2 ) - static const int TYPE_ERROR = 0x40000; //> usually illegal parameter in the language, like ( 2 mod 3.0 ) - static const int PERMISSION_ERROR = 0x80000; //> wrong para,eter - static const int EVALUATION_ERROR = 0x100000; //> bad arithmetic expressions - static const int RESOURCE_ERROR = 0x200000; //> no resource available, like MEM - static const int REPRESENTATION_ERROR = 0x400000; //> bad UTF-8 strings, etc - static const int EXISTËNCE_ERROR = 0x400000; //> object not found - static const int PROFILER = 0x400000; //> improve profiling support. - static const int OTHER_ERROR = 0x800000; //> anything rldr.,,,,,,,,,,,,,,,,,,,, -}; - -class YAPErrorClass { -public: - static const int SYNTAX_ERROR = 0x10000; - static const int DOMAIN_ERROR = 0x20000; - static const int TYPE_ERROR = 0x40000; - static const int PERMISSION_ERROR = 0x80000; - static const int EVALUATION_ERROR = 0x100000; - static const int RESOURCE_ERROR = 0x200000; - static const int REPRESENTATION_ERROR = 0x400000; - static const int OTHER_ERROR = 0x800000; + static const int YAP_SYNTAX_ERROR = 0x10000; //> syntax error + static const int YAP_DOMAIN_ERROR = 0x20000; //> usually illegal parameter, like asin( 2 ) + static const int YAP_TYPE_ERROR = 0x40000; //> usually illegal parameter in the language, like ( 2 mod 3.0 ) + static const int YAP_PERMISSION_ERROR = 0x80000; //> wrong para,eter + static const int YAP_EVALUATION_ERROR = 0x100000; //> bad arithmetic expressions + static const int YAP_RESOURCE_ERROR = 0x200000; //> no resource available, like MEM + static const int YAP_REPRESENTATION_ERROR = 0x400000; //> bad UTF-8 strings, etc + static const int YAP_EXISTENCE_ERROR = 0x800000; //> object not found + static const int YAP_PROFILER = 0x100000; //> improve profiling support. + static const int YAP_OTHER_ERROR = 0x2000000; //> anything }; diff --git a/Makefile.in b/Makefile.in index 372ea37e2..0a8cf889f 100755 --- a/Makefile.in +++ b/Makefile.in @@ -563,13 +563,11 @@ INSTALLED_PACKAGES= \ @PKG_PRISM@ \ @PKG_PYTHON@ \ @PKG_RAPTOR@ \ - @PKG_CHR@ \ @PKG_CLIB@ \ + @PKG_CHR@ \ @PKG_JPL@ \ @PKG_LIBARCHIVE@ \ - @PKG_LTX2HTM@ \ @PKG_ODBC@ \ - \ @PKG_PLUNIT@ \ @PKG_REAL@ \ @PKG_RDF@ \ @@ -577,7 +575,7 @@ INSTALLED_PACKAGES= \ @PKG_SGML@ \ @PKG_SWIG@ \ @PKG_WINCONSOLE@ \ - @PKG_ZLIB@ # @PKG_PLDOC@ + @PKG_ZLIB@ PACKAGES= \ library \ @@ -603,7 +601,7 @@ yap-win: yap-win@EXEC_SUFFIX@ yapwin: yap-win@EXEC_SUFFIX@ yap-win@EXEC_SUFFIX@: $(PLCONS_OBJECTS) $(HEADERS) @YAPLIB@ - (cd swi/console; $(MAKE)) + $(MAKE) -C swi/console $(MPI_CC) -municode -DUNICODE -D_UNICODE $(EXECUTABLE_CFLAGS) $(LDFLAGS) -Wl,-subsystem,windows -o yap-win@EXEC_SUFFIX@ $(PLCONS_OBJECTS) plterm.dll @YAPLIB@ $(LIBS) -lgdi32 @MPILDF@ libYap.a: $(LIB_OBJECTS) yapi.o @@ -710,7 +708,7 @@ depend: $(HEADERS) $(C_SOURCES) fi clean: clean_docs clean_local - for f in $(PACKAGES); do ( cd $$f ; $(MAKE) clean ); done + for f in $(PACKAGES); do ( $(MAKE) -C $$f clean ); done clean_local: rm -f *.o *~ *.BAK *.a @@ -810,7 +808,7 @@ distclean_docs: clean_docs rm -f yap.ps yap.html yap_toc.html yap.pdf yap.info* installcheck: - (cd packages/cplint; $(MAKE) installcheck) + $(MAKE) -C packages/cplint installcheck # DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/misc/mkandroid b/misc/mkandroid index 660db823d..0f36ef60d 100755 --- a/misc/mkandroid +++ b/misc/mkandroid @@ -1,42 +1,105 @@ #!/bin/bash # # script to compile yap for Android. +# +# variables are +# +# SDK_ROOT: where is the SDK +# NDK_ROOT: and the NDK +# GMPDIR: get your copy of GMP from +# BUILDDROID: where we want to compile yap -if test -d $HOME/Yap/android-sdk-linux + +# ANDROID_RELEASE= 17 is 4.2.2, 19 is 4.4.2 +ANDROID_RELEASE=19 +# ANDROID_ARCH= arm, x86, mips +ANDROID_ARCH=arm +# ANDROID_BUILD=linux +ANDROID_BUILD=linux + +# what android to compile for +ANDROID_IMAGE=first + +# YAP_SRC="$HOME/Yap/yap-6.3" +if test -d "$HOME/git/yap-6.3" then - export SDK_ROOT=$HOME/Yap/android-sdk-linux -elif test -d $HOME/Yap/android-sdk-macosx + export YAP_SRC="$HOME/git/yap-6.3" +elif test -d "$HOME/Yap/yap-6.3" then - export SDK_ROOT=$HOME/Yap/android-sdk-macosx + export YAP_SRC="$HOME/Yap/yap-6.3" fi -export NDK_ROOT=$HOME/Yap/android-ndk-r9d +# check if the SDK is at the usual locations -export GMPDIR=$HOME/Yap/gmp-android +if test -d $HOME/Yap/android-sdk-"$ANDROID_BUILD" +then + export SDK_ROOT=$HOME/Yap/android-sdk-"$ANDROID_BUILD" +else + export SDK_ROOT=/scratch/vitor/android-sdk-"$ANDROID_BUILD" +fi -export ANDROID_NDK_ROOT="$NDK_ROOT"/ -export ANDROID_SYSROOT="$NDK_ROOT"/platforms/android-17/arch-arm +# check if the NDK is at the usual locations +if test -d $HOME/Yap/android-ndk-r9d +then + export NDK_ROOT=$HOME/Yap/android-ndk-r9d +elif test -d /scratch/vitor/android-ndk-r9d +then + export NDK_ROOT=/scratch/vitor/android-ndk-r9d +fi + +# fetch GMP from https://github.com/Rupan/gmp, +# or compile it. +if test -d /scratch +then + export GMPDIR=/scratch/vitor/gmp-android +else + export GMPDIR="$HOME"/Yap/gmp-android +fi + +#where I want to compile +#export BUILDTOOLCHAIN="$HOME/Yap/my-android-toolchain" +if test -d /scratch +then + export BUILDTOOLCHAIN="/scratch/vitor/my-android-toolchain" + export BUILDDROID="/scratch/vitor/yap-android" +else + export BUILDTOOLCHAIN="$HOME/Yap/my-android-toolchain" + export BUILDDROID="$HOME/Yap/bins/android" +fi -# which platform to compile for -ANDROID_PLATFORM=android-17 # which gcc to use GCC_VERSION=4.8 -# which disk -IMAGE=first -if test -d $HOME/Yap/my-android-toolchain +#======================================================== +# should be fine +#======================================================== + +export ANDROID_NDK_ROOT="$NDK_ROOT"/ +export ANDROID_SYSROOT="$NDK_ROOT"/platforms/android-"$ANDROID_RELEASE"/arch-"$ANDROID_ARCH" + +# which platform to compile for +ANDROID_PLATFORM=android-"$ANDROID_RELEASE" +# which disk +IMAGE="$ANDROID_IMAGE" + +export PATH="$BUILDTOOLCHAIN"/bin:"$NDK_ROOT":"$SDK_ROOT/tools":"$SDK_ROOT/platform-tools":$PATH + +echo $PATH + +if test -d "$BUILDTOOLCHAIN" then - echo using the setup at $HOME/Yap/my-android-toolchain + echo using the setup at "$BUILDTOOLCHAIN" else "$NDK_ROOT"/build/tools/make-standalone-toolchain.sh \ --platform="$ANDROID_PLATFORM" \ - --toolchain=arm-linux-androideabi-"$GCC_VERSION" \ - --install-dir="$HOME"/Yap/my-android-toolchain + --toolchain="$ANDROID_ARCH"-"$ANDROID_BUILD"-androideabi-"$GCC_VERSION" \ + --install-dir="$BUILDTOOLCHAIN" fi -export PATH="$HOME"/Yap/my-android-toolchain/bin:"$NDK_ROOT":"$SDK_ROOT/tools":"$SDK_ROOT/platform-tools":$PATH -cd ~/Yap/bins/android +mkdir -p $BUILDDROID + +cd $BUILDDROID if test x$1 = xmake then @@ -48,18 +111,22 @@ then elif test x$1 = xeclipse then emulator -avd $IMAGE & - ~/eclipse/eclipse & + "$ECLIPSE"eclipse & return 0 else - emulator -avd $IMAGE & - rm -rf ~/Yap/bins/android/* - cd ~/Yap/bins/android - ~/git/yap-6.3/configure --host=arm-linux-androideabi --prefix=`pwd` --enable-low-level-tracer --enable-debug-yap --enable-dynamic-loading --with-swig --with-gmp=$GMPDIR --disable-chr #--enable-threads + EMS=`ps -ef | grep emulator64| grep -v grep` + if test x"$EMS" = x + then + emulator -avd $IMAGE & + fi + rm -rf "$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 make depend make -j install fi cd packages/swig -mkdir -p $ANDROID_NDK_ROOT/build/core/lib +mkdir -p "$ANDROID_NDK_ROOT"/build/core/lib make android make install-android adb uninstall pt.up.fc.dcc.yap diff --git a/packages/real b/packages/real index 911ad4d6f..3637c14d2 160000 --- a/packages/real +++ b/packages/real @@ -1 +1 @@ -Subproject commit 911ad4d6f1cf58828dc755621c7f1e6072073a6d +Subproject commit 3637c14d2f0bcb2113e28de5aa0cae25a55dcca8 diff --git a/packages/swig/Android.mk.in b/packages/swig/Android.mk.in index a0fb7b1e6..d62f6d4eb 100644 --- a/packages/swig/Android.mk.in +++ b/packages/swig/Android.mk.in @@ -6,7 +6,7 @@ include $(CLEAR_VARS) LOCAL_LDLIBS := -landroid -llog LOCAL_MODULE := yap0 -LOCAL_SRC_FILES += @abs_top_builddir@/../../gmp-android/lib/libgmp.so +LOCAL_SRC_FILES += @abs_top_builddir@/../gmp-android/lib/libgmp.so include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -24,7 +24,7 @@ LOCAL_MODULE := example LOCAL_SHARED_LIBRARIES := yap0 yap1 LOCAL_STATIC_LIBRARIES := @abs_top_builddir@/libYap.ar 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@ @abs_top_builddir@/../gmp-android/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_CPP_FEATURES := rtti # LOCAL_ALLOW_UNDEFINED_SYMBOLS := true diff --git a/packages/swig/Makefile.in b/packages/swig/Makefile.in index d342605fb..f93dc684f 100644 --- a/packages/swig/Makefile.in +++ b/packages/swig/Makefile.in @@ -9,7 +9,7 @@ DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"$(DESTDIR)\" YAP_EXTRAS=@YAP_EXTRAS@ srcdir=@srcdir@ CPPFLAGS= -I../.. -I$(srcdir)/../../H -I$(srcdir)/../../include -I$(srcdir)/../../os -I$(srcdir)/../../OPTYap -I$(srcdir)/../../BEAM -I$(srcdir)/../../CXX -CXXFLAGS= $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS) +CXXFLAGS= $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS) PROGRAMS= $(srcdir)/python/demo.py \ @@ -22,14 +22,14 @@ python: $(SWIG_FILES) python/_yap.so python/yap.py cp $(srcdir)/python/demo.py python python/_yap.so: python/yap_wrap.o - $(CXX) -shared $(LDSOFLAGS) -o python/_yap.so python/yap_wrap.o ../../yapi.o $(LIBS) @PYTHON_LIBS@ -L ../.. -lYap -lpthrea + $(CXX) -shared $(LDSOFLAGS) -o python/_yap.so python/yap_wrap.o ../../yapi.o $(LIBS) @PYTHON_LIBS@ -L ../.. -lYap -lpthread python/yap_wrap.cpp python/yap.py: $(srcdir)/yap.i mkdir -p python $(SWIG) -c++ -python -outdir python -o $@ $(CXXFLAGS) -Wall $< python/yap_wrap.o: python/yap_wrap.cpp - $(CXX) -c $(CXXFLAGS) @PYTHON_INCLUDES@ $< -o $@ + $(CXX) -c @SHLIB_CXXFLAGS@ $(CXXFLAGS) @PYTHON_INCLUDES@ $< -o $@ java: jni/libyap.@SO@ java/yap.java cd java ; $(JAVAC) *.java; $(JAR) cvf yap.jar *.class @@ -41,7 +41,7 @@ jni/yap_wrap.cpp java/yap.java: $(srcdir)/yap.i $(SWIG) -c++ -java -package pt.up.fc.dcc.yap -outdir java -o jni/yap_wrap.cpp $(CXXFLAGS) -Wall $< jni/yap_wrap.o: jni/yap_wrap.cpp - $(CXX) -c $(CXXFLAGS) @JPLCFLAGS@ $< -o $@ + $(CXX) -c @SHLIB_CXXFLAGS@ $(CXXFLAGS) @JPLCFLAGS@ $< -o $@ # depends on make install on top-level # also, should have an android device running, say