diff --git a/C/atomic.c b/C/atomic.c index 354ae5d84..10e39e909 100644 --- a/C/atomic.c +++ b/C/atomic.c @@ -661,26 +661,31 @@ static Int atom_concat3(USES_REGS1) { Term t1; Term t2, t3, ot; Atom at; + bool g1, g2, g3; restart_aux: t1 = Deref(ARG1); t2 = Deref(ARG2); t3 = Deref(ARG3); - if (Yap_IsGroundTerm(t1) && Yap_IsGroundTerm(t2)) { + g1 = Yap_IsGroundTerm(t1); + g2 = Yap_IsGroundTerm(t2); + g3 = Yap_IsGroundTerm(t3); + if (g1 && g2) { at = Yap_ConcatAtoms(t1, t2 PASS_REGS); ot = ARG3; - } else if (Yap_IsGroundTerm(t1) && Yap_IsGroundTerm(t3)) { - at = Yap_SubtractHeadAtom(Deref(ARG3), t1 PASS_REGS); + } else if (g1 && g3) { + at = Yap_SubtractHeadAtom(t3, t1 PASS_REGS); ot = ARG2; - } else if (Yap_IsGroundTerm(t2) && Yap_IsGroundTerm(t3)) { - at = Yap_SubtractTailAtom(Deref(ARG3), t2 PASS_REGS); + } else if (g2 && g3) { + at = Yap_SubtractTailAtom(t3, t2 PASS_REGS); ot = ARG1; - } else if (Yap_IsGroundTerm(t3)) { + } else if (g3) { EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0); EXTRA_CBACK_ARG(3, 2) = MkIntTerm(Yap_AtomToLength(t3 PASS_REGS)); return cont_atom_concat3(PASS_REGS1); } else { LOCAL_Error_TYPE = INSTANTIATION_ERROR; LOCAL_Error_Term = t1; + at = NULL; } if (at) { if (Yap_unify(ot, MkAtomTerm(at))) @@ -693,7 +698,7 @@ restart_aux: if (Yap_HandleError("atom_concat/3")) { goto restart_aux; } else { - return FALSE; + return false; } } cut_fail(); @@ -751,29 +756,34 @@ static Int atomic_concat3(USES_REGS1) { Term t1; Term t2, t3, ot; Atom at = NULL; + bool g1, g2, g3; restart_aux: t1 = Deref(ARG1); t2 = Deref(ARG2); t3 = Deref(ARG3); - if (Yap_IsGroundTerm(t1) && Yap_IsGroundTerm(t2)) { - at = Yap_ConcatAtoms(CastToAtom(t1), CastToAtom(t2) PASS_REGS); + g1 = Yap_IsGroundTerm(t1); + g2 = Yap_IsGroundTerm(t2); + g3 = Yap_IsGroundTerm(t3); + if (g1 && g2) { + at = Yap_ConcatAtomics(t1, t2 PASS_REGS); ot = ARG3; - } else if (Yap_IsGroundTerm(t1) && Yap_IsGroundTerm(t3)) { - at = Yap_SubtractHeadAtom(t3, CastToAtom(t1) PASS_REGS); + } else if (g1 && g3) { + at = Yap_SubtractHeadAtom(t3, t1 PASS_REGS); ot = ARG2; - } else if (Yap_IsGroundTerm(t2) && Yap_IsGroundTerm(t3)) { - at = Yap_SubtractTailAtom(t3, CastToAtom(t2) PASS_REGS); - ot = ARG1; - } else if (Yap_IsGroundTerm(t3)) { + } else if (g2 && g3) { + at = Yap_SubtractTailAtom(t3, t2 PASS_REGS); + ot = ARG1; + } else if (g3) { EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0); EXTRA_CBACK_ARG(3, 2) = MkIntTerm(Yap_AtomicToLength(t3 PASS_REGS)); return cont_atomic_concat3(PASS_REGS1); } else { - LOCAL_Error_TYPE = INSTANTIATION_ERROR; - LOCAL_Error_Term = t1; + LOCAL_Error_TYPE = INSTANTIATION_ERROR; + LOCAL_Error_Term = t1; + at = NULL; } if (at) { - if (Yap_unify(ot, CastToNumeric(at))) + if (Yap_unify(ot, MkAtomTerm(at))) cut_succeed(); else cut_fail(); @@ -783,7 +793,7 @@ restart_aux: if (Yap_HandleError("atomic_concat/3")) { goto restart_aux; } else { - return FALSE; + return false; } } cut_fail(); @@ -822,40 +832,45 @@ static Int string_concat3(USES_REGS1) { Term t1; Term t2, t3, ot; Term tf = 0; + bool g1, g2, g3; + Atom at; restart_aux: t1 = Deref(ARG1); t2 = Deref(ARG2); t3 = Deref(ARG3); - if (Yap_IsGroundTerm(t1) && Yap_IsGroundTerm(t2)) { + g1 = Yap_IsGroundTerm(t1); + g2 = Yap_IsGroundTerm(t2); + g3 = Yap_IsGroundTerm(t3); + if (g1 && g2) { tf = Yap_ConcatStrings(t1, t2 PASS_REGS); ot = ARG3; - } else if (Yap_IsGroundTerm(t1) && Yap_IsGroundTerm(t3)) { + } else if (g1 && g3) { tf = Yap_SubtractHeadString(t3, t1 PASS_REGS); ot = ARG2; - } else if (Yap_IsGroundTerm(t2) && Yap_IsGroundTerm(t3)) { + } else if (g2 && g3) { tf = Yap_SubtractTailString(t3, t2 PASS_REGS); - ot = ARG1; - } else if (Yap_IsGroundTerm(t3)) { + ot = ARG1; + } else if (g3) { EXTRA_CBACK_ARG(3, 1) = MkIntTerm(0); EXTRA_CBACK_ARG(3, 2) = MkIntTerm(Yap_StringToLength(t3 PASS_REGS)); return cont_string_concat3(PASS_REGS1); } else { - LOCAL_Error_TYPE = INSTANTIATION_ERROR; - LOCAL_Error_Term = t1; + LOCAL_Error_TYPE = INSTANTIATION_ERROR; + LOCAL_Error_Term = t1; + at = NULL; } if (tf) { - if (Yap_unify(ot, tf)) { + if (Yap_unify(ot, tf)) cut_succeed(); - } else { + else cut_fail(); - } } /* Error handling */ if (LOCAL_Error_TYPE) { - if (Yap_HandleError("string_concat/3")) { + if (Yap_HandleError("atom_concat/3")) { goto restart_aux; } else { - return FALSE; + return false; } } cut_fail(); diff --git a/C/text.c b/C/text.c index a71d46679..cecff54cc 100644 --- a/C/text.c +++ b/C/text.c @@ -104,6 +104,7 @@ static Int SkipListCodes(unsigned char **bufp, Term *l, Term **tailp, *bufp = st = st0; if (*l == TermNil) { + st[0] = '\0'; return 0; } if (IsPairTerm(*l)) { @@ -311,7 +312,7 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) { } else if (!IsStringTerm(inp->val.t) && inp->type == YAP_STRING_STRING) { LOCAL_Error_TYPE = TYPE_ERROR_STRING; - } else if (!IsPairTerm(inp->val.t) && !IsStringTerm(inp->val.t) && + } else if (!IsPairOrNilTerm(inp->val.t) && !IsStringTerm(inp->val.t) && inp->type == (YAP_STRING_ATOMS_CODES | YAP_STRING_STRING)) { LOCAL_Error_TYPE = TYPE_ERROR_LIST; @@ -344,20 +345,20 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) { return UStringOfTerm(inp->val.t); } if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) == - (YAP_STRING_CODES | YAP_STRING_ATOMS)) && IsPairTerm(inp->val.t)) { + (YAP_STRING_CODES | YAP_STRING_ATOMS)) && IsPairOrNilTerm(inp->val.t)) { //Yap_DebugPlWriteln(inp->val.t); return inp->val.uc = Yap_ListToBuffer(s0, inp->val.t, inp, &wide, lengp PASS_REGS); // this is a term, extract to a sfer, and representation is wide } - if (inp->type & YAP_STRING_CODES && IsPairTerm(inp->val.t)) { + if (inp->type & YAP_STRING_CODES && IsPairOrNilTerm(inp->val.t)) { //Yap_DebugPlWriteln(inp->val.t); return inp->val.uc = Yap_ListOfCodesToBuffer(s0, inp->val.t, inp, &wide, lengp PASS_REGS); // this is a term, extract to a sfer, and representation is wide } - if (inp->type & YAP_STRING_ATOMS && IsPairTerm(inp->val.t)) { + if (inp->type & YAP_STRING_ATOMS && IsPairOrNilTerm(inp->val.t)) { //Yap_DebugPlWriteln(inp->val.t); return inp->val.uc = Yap_ListOfAtomsToBuffer(s0, inp->val.t, inp, &wide, lengp PASS_REGS); @@ -1031,7 +1032,7 @@ const char *Yap_TextTermToText(Term t, char *buf, size_t len, encoding_t enc) { CACHE_REGS seq_tv_t inp, out; inp.val.t = t; - if (IsAtomTerm(t)) { + if (IsAtomTerm(t) && t != TermNil) { inp.type = YAP_STRING_ATOM; if (IsWideAtom(AtomOfTerm(t))) inp.enc = ENC_WCHAR; @@ -1040,7 +1041,7 @@ const char *Yap_TextTermToText(Term t, char *buf, size_t len, encoding_t enc) { } else if (IsStringTerm(t)) { inp.type = YAP_STRING_STRING; inp.enc = ENC_ISO_UTF8; - } else if (IsPairTerm(t)) { + } else if (IsPairOrNilTerm(t)) { inp.type = (YAP_STRING_CODES | YAP_STRING_ATOMS); } else { Yap_Error(TYPE_ERROR_TEXT, t, NULL); diff --git a/DisabledFeatures.txt b/DisabledFeatures.txt deleted file mode 100644 index 5c86c4094..000000000 --- a/DisabledFeatures.txt +++ /dev/null @@ -1,2 +0,0 @@ - * Threads Support - GNU Threads Library (or similar) diff --git a/EnabledFeatures.txt b/EnabledFeatures.txt deleted file mode 100644 index 51f3db8ac..000000000 --- a/EnabledFeatures.txt +++ /dev/null @@ -1,2 +0,0 @@ - * GNU libgmp (in some cases MPIR - GNU big integers and rationals - * libreadline - Readline line editing library diff --git a/H/YapTags.h b/H/YapTags.h index d2b446755..4ae7f2e06 100644 --- a/H/YapTags.h +++ b/H/YapTags.h @@ -350,4 +350,14 @@ INLINE_ONLY inline EXTERN void *AddressOfTerm(Term t) { return (void *)(IsIntTerm(t) ? IntOfTerm(t) : LongIntOfTerm(t)); } + +INLINE_ONLY inline EXTERN Int IsPairTermOrNil (Term); + +INLINE_ONLY inline EXTERN Int +IsPairOrNilTerm (Term t) +{ + return IsPairTerm(t) || t == TermNil; +} + + #endif diff --git a/YAPDroid/YAPDroid.md b/YAPDroid/YAPDroid.md deleted file mode 100644 index 51bd6dd88..000000000 --- a/YAPDroid/YAPDroid.md +++ /dev/null @@ -1,72 +0,0 @@ - -## YAPDroid - -This file documents the YAPDroid application. This app was developed in order to -test the YAP-Android interface. It provides a simple REPL with a query window and a text -viewer. - -### Design - -The YAP interface to Android is based on the SWIG interface generator. SWIG exports the YAP -C++ classes as Java classes. In practice there exist two worlds, the native application -and the Java application: - - - YAP runs in Android as a native application in a Linux -environment. Android does not support glibc. Instead, Android libraries are provided by the Android NDK, and -are somewhat limited, i.e., the NDK misses in-memory streams and a `glob` -predicate. Moreover, read-only data is kept in a zipped archive that is made to appear as -a directory, `~/assets` - - - SWIG generates the glue code: JNI classes that act as Java classes. Callbacks are possible. - - - Java code operates as usual. - -### Compiling YAPDroid - -The current version was compiled using the recent Android Studio `cmake` support. Android Studio uses -`gradle` as the build system. `gradle` orchestrates compilation of all Java code. External code is delegated -to `cmake` or the Android NDK own builder. The idea fits nicely with YAP; unfortunately, the process currently -crashes in middle. - -To install, navigate through these steps: -1. Obtain `gmp` for Android. YAP has used the [Rupan repo](https://github.com/Rupan/gmp); place the repo next to -the yap-6.3 top directory. - -2. Install [swig](www/swig.org) - -2. Obtain Android Studio. This work used Android Studio 2.2 Beta 3. The IDE includes most everything else you need: the ADK, the NDK, `cmake`, the `ninja` build system, and the debugger. - -3. Set YAPDroid as your directory. - -4. Adapt the `build.gradle` files to your configuration. - + It may be a good idea to first generate an empty configuration and compare. - + In the `lib` directory, please verify wich targets you are generating for. - -4. Build the system, either from the GUI or from a terminal, say as: -~~~~~ -./gradlew assembleDebug -~~~~~ -or -~~~~~ -./gradlew :lib:assembleDebug -~~~~~ -You should see `cmake` being executed, and after some time `gradle` crash. - -5. To actually install the binaries, use: -~~~~~ -cd lib/build/intermediates/cmake/debug/json/armeabi-v7a -ninja install -~~~~~ -6. Comment the four lines in `lib/build.gradle` to avoid crashing in the `cmake` task. - -7. use the GUI commands to compile the app or set your directory bak to -the YAPDroid top-directory and call `gradle`. - -Enjoy! - -### Limitations and TODO - -- improve error handling. -- support `/assets`: the code is written but not tested yet. -- network access -- sqlite testing and support diff --git a/YAPDroid/app/build.gradle b/YAPDroid/app/build.gradle deleted file mode 100644 index 8d9a4b9a3..000000000 --- a/YAPDroid/app/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" - defaultConfig { - applicationId "pt.up.yap.app" - minSdkVersion 19 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - -} - - -project.gradle.taskGraph.whenReady { - connectedDebugAndroidTest { - ignoreFailures = true - } -} -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.4.0' - testCompile 'junit:junit:4.12' - androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' - androidTestCompile 'com.android.support.test:runner:0.5' - androidTestCompile 'com.android.support:support-annotations:23.4.0' - compile 'com.google.android.gms:play-services-appindexing:8.4.0' -} diff --git a/YAPDroid/app/src/main/AndroidManifest.xml b/YAPDroid/app/src/main/AndroidManifest.xml deleted file mode 100755 index 377074404..000000000 --- a/YAPDroid/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - diff --git a/YAPDroid/app/src/main/java/pt/up/yap/app/CreateFiles.java b/YAPDroid/app/src/main/java/pt/up/yap/app/CreateFiles.java deleted file mode 100644 index b87215a9a..000000000 --- a/YAPDroid/app/src/main/java/pt/up/yap/app/CreateFiles.java +++ /dev/null @@ -1,86 +0,0 @@ -package pt.up.yap.app; - -import android.content.Context; -import android.content.res.AssetManager; - -import android.support.v4.content.res.ResourcesCompat; -import android.util.Log; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - - -/** - * Created by vsc on 30/05/16. - */ - -public class CreateFiles { - - - - public static void setupfiles(Context context, AssetManager assets){ - try { - - context.getExternalFilesDir("Yap").mkdirs(); - context.getExternalFilesDir("Yap/pl").mkdirs(); - context.getExternalFilesDir("Yap/os").mkdirs(); - String list[] = {}; - list= assets.list("Yap"); - for (int i = 0; i < list.length; i++) { - copy(context, "Yap/"+ list[i]); - } - list = null; - list= assets.list("Yap/pl"); - for (int i = 0; i < list.length; i++) { - copy(context, "Yap/pl/"+ list[i]); - } - list =null; - list= assets.list("Yap/os"); - for (int i = 0; i < list.length; i++) { - copy(context, "Yap/os/"+ list[i]); - } - Log.d("CreateFiles", context.getFilesDir().getAbsolutePath()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void copy(Context context, String originalName) { - try { - if (originalName.contains(".")) { - File outFile; - - outFile = new File(context.getExternalFilesDir(null), originalName ); - - InputStream in = context.getAssets().open(originalName); - BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); - - - byte data[] = new byte[1024]; - int count; - - while ((count = in.read(data)) != -1) { - out.write(data, 0, count); - } - - out.flush(); - out.close(); - in.close(); - - in = null; - out = null; - //Log.d("Copied: ", originalName + " to " + destinationName); - //System.out.println("Copied: "+ originalName + " to " + destinationName); - //System.out.println(); - } - }catch(IOException e){ - e.printStackTrace(); - } - - } -} diff --git a/YAPDroid/app/src/main/java/pt/up/yap/app/YAPDroid.java b/YAPDroid/app/src/main/java/pt/up/yap/app/YAPDroid.java deleted file mode 100755 index 073053273..000000000 --- a/YAPDroid/app/src/main/java/pt/up/yap/app/YAPDroid.java +++ /dev/null @@ -1,330 +0,0 @@ -package pt.up.yap.app; -/**** - * using sqlite - * For example,the following: - *

- * import android.database.sqlite.SQLiteDatabase; - *

- * should be replaced with: - *

- * import org.sqlite.database.sqlite.SQLiteDatabase; - *

- * As well as replacing all uses of the classes in the android.database.sqlite.* namespace, the application must also be sure to use the following two: - *

- * org.sqlite.database.SQLException - * org.sqlite.database.DatabaseErrorHandler - *

- * instead of: - *

- * android.database.SQLException - * android.database.DatabaseErrorHandler - *

- * Aside from namespace changes, there are other differences from the stock Android interface that applications need to be aware of: - *

- * The SQLiteStatement.simpleQueryForBlobFileDescriptor() API is not available. The collation sequence "UNICODE" is not available. The collation sequence "LOCALIZED", which normally changes with the system's current locale, is always equivalent to SQLite's built in collation BINARY. - ****/ - -import android.content.Context; -import android.app.Activity; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.AssetManager; -import android.net.Uri; -import android.os.Bundle; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import android.text.method.ScrollingMovementMethod; -import android.util.Log; -import android.view.View; -import android.widget.EditText; -import android.widget.ScrollView; -import android.widget.TextView; - -import com.google.android.gms.appindexing.Action; -import com.google.android.gms.appindexing.AppIndex; -import com.google.android.gms.appindexing.Thing; -import com.google.android.gms.common.api.GoogleApiClient; - -import org.sqlite.database.DatabaseErrorHandler; -import org.sqlite.database.sqlite.SQLiteDatabase; - -import pt.up.yap.lib.*; - -class DoNotDeleteErrorHandler implements DatabaseErrorHandler { - private static final String TAG = "DoNotDeleteErrorHandler"; - - public void onCorruption(SQLiteDatabase dbObj) { - Log.e(TAG, "Corruption reported by sqlite on database: " + dbObj.getPath()); - } -} - -public class YAPDroid extends Activity { - - private static final String TAG = "YAPDroid"; - - TextView outputText = null; - ScrollView scroller = null; - YAPEngine eng = null; - EditText text; - String str; - String buf; - YAPQuery q; - Boolean running = false, compute = true; - int i = 1; - YAPListTerm vs0; - private AssetManager mgr; - /** - * ATTENTION: This was auto-generated to implement the App Indexing API. - * See https://g.co/AppIndexing/AndroidStudio for more information. - */ - private GoogleApiClient client; - - // private static native void load(AssetManager mgr); - - - void runQuery(String str, Boolean more) { - try { - // check if at initial query - if (running) { - if (q != null) q.close(); - } - - if (BuildConfig.DEBUG) { - Log.i(TAG, "query " + str); - } - - q = eng.query(str); - // get the uninstantiated query variables. - vs0 = q.namedVars(); - running = true; - // start computing - compute = true; - - if (BuildConfig.DEBUG) { - Log.i(TAG, "onQueryButtonClick called"); - } - - Boolean rc = true; - - text.setText("?- "); - if (vs0.nil()) { - if (BuildConfig.DEBUG) { - Log.i(TAG, "q0=\n"); - } - if (compute && (rc = q.next())) { - outputText.append("yes\n"); - running = compute = more; - } else { - outputText.append("no\n"); - running = false; - compute = false; - } - } else { - // if (BuildConfig.DEBUG) { - // Log.i(TAG, "q1= " + vs0.text() + "\n"); - // } - while (compute && (rc = q.next())) { - YAPListTerm vs = q.namedVars(); - while (!vs.nil()) { - if (BuildConfig.DEBUG) { - Log.i(TAG, "q= " + vs.text() + "\n"); - } - YAPTerm eq = vs.car(); - //outputText.append(Integr.toString(i) + ": " + eq.text() ); - outputText.append(Integer.toString(i)); - outputText.append(":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() + "\n"); - vs = vs.cdr(); - } - compute = more; - } - } - if (!rc) { - outputText.append("no\n"); - if (q != null) - q.close(); - q = null; - compute = false; - running = false; - } - } catch (Exception e) { - outputText.append("Exception thrown :" + e); - if (q != null) - q.close(); - compute = true; - running = false; - } - } - - /** - * Called when the activity is first created. - */ - @Override - public void onCreate(Bundle savedInstanceState) { - String s = null; - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - try { - PackageManager - m = getPackageManager(); - s = getPackageName(); - PackageInfo p = m.getPackageInfo(s, 0); - //s = p.applicationInfo.dataDir; - mgr = this.getAssets(); - - /** static constructor */ - // follow this order carefully. - System.loadLibrary("gmp"); - System.loadLibrary("Yap"); - System.loadLibrary("Yapsqlite3"); - System.loadLibrary("Yap++"); - System.loadLibrary("YAPDroid"); - CreateFiles.setupfiles(this, mgr); - - } catch (NameNotFoundException e) { - Log.e(TAG, "Couldn't find package information in PackageManager", e); - } - Log.i(TAG, "mgr=" + mgr); - - text = (EditText) findViewById(R.id.EditText01); - outputText = (TextView) findViewById(R.id.OutputText); - outputText.setText("Application " + s + "\nPress 'First' or 'All' to query...\n"); - outputText.setMovementMethod(new ScrollingMovementMethod()); - scroller = (ScrollView) findViewById(R.id.Scroller); - if (BuildConfig.DEBUG) { - Log.i(TAG, "window making done"); - } - eng = new YAPEngine(null, this.getExternalFilesDir("/Yap/pl/boot.yap").getAbsolutePath()); - if (BuildConfig.DEBUG) { - Log.i(TAG, "engine done"); - } - if (BuildConfig.DEBUG) { - Log.i(TAG, "onClearButtonClick called"); - } - JavaCallback callback = new JavaCallback(outputText); - // set the Java Callback - if (BuildConfig.DEBUG) { - Log.i(TAG, "before setting callback"); - } - eng.setYAPCallback(callback); - if (BuildConfig.DEBUG) { - Log.i(TAG, "callback done"); - } - // ATTENTION: This was auto-generated to implement the App Indexing API. - // See https://g.co/AppIndexing/AndroidStudio for more information. - client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); - } - - public void onClearButtonClick(View view) { - if (BuildConfig.DEBUG) { - Log.i(TAG, "onClearButtonClick called"); - } - // Ensure scroll to end of text - scroller.post(new Runnable() { - public void run() { - scroller.fullScroll(ScrollView.FOCUS_DOWN); - if (running) { - if (q != null) - q.close(); - q = null; - } - running = false; - text.setText(""); - } - }); - } - - public void onFirstButtonClick(View view) { - if (BuildConfig.DEBUG) { - Log.i(TAG, "onQueryButtonClick called"); - } - // Ensure scroll to end of text - scroller.post(new Runnable() { - public void run() { - scroller.fullScroll(ScrollView.FOCUS_DOWN); - str = text.getText().toString(); - //outputText.append("?- " + str+"\n\n"); - Log.i(TAG, "onQueryAnyButtonClick " + str + "\n"); - runQuery(str, false); - scroller.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - } - - public void onAllButtonClick(View view) { - if (BuildConfig.DEBUG) { - Log.i(TAG, "onQueryButtonClick called"); - } - // Ensure scroll to end of text - scroller.post(new Runnable() { - public void run() { - str = text.getText().toString(); - scroller.fullScroll(ScrollView.FOCUS_DOWN); - outputText.append("?- " + str + "\n\n"); - Log.i(TAG, "onAllButtonClick " + str + "\n"); - runQuery(str, true); - scroller.fullScroll(ScrollView.FOCUS_DOWN); - } - }); - } - - /** - * ATTENTION: This was auto-generated to implement the App Indexing API. - * See https://g.co/AppIndexing/AndroidStudio for more information. - */ - public Action getIndexApiAction() { - Thing object = new Thing.Builder() - .setName("YAPDroid Page") // TODO: Define a title for the content shown. - // TODO: Make sure this auto-generated URL is correct. - .setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]")) - .build(); - return new Action.Builder(Action.TYPE_VIEW) - .setObject(object) - .setActionStatus(Action.STATUS_TYPE_COMPLETED) - .build(); - } - - @Override - public void onStart() { - super.onStart(); - - // ATTENTION: This was auto-generated to implement the App Indexing API. - // See https://g.co/AppIndexing/AndroidStudio for more information. - client.connect(); - AppIndex.AppIndexApi.start(client, getIndexApiAction()); - } - - @Override - public void onStop() { - super.onStop(); - - // ATTENTION: This was auto-generated to implement the App Indexing API. - // See https://g.co/AppIndexing/AndroidStudio for more information. - AppIndex.AppIndexApi.end(client, getIndexApiAction()); - client.disconnect(); - } -} - -class JavaCallback extends YAPCallback { - private static final String TAG = "JavaCallback"; - TextView output; - - public JavaCallback(TextView outputText) { - super(); - output = outputText; - Log.i(TAG, "java callback init"); - } - - public void run(String s) { - Log.i(TAG, "java callback "); - output.append(s); - } - -} diff --git a/YAPDroid/app/src/main/res/layout/main.xml b/YAPDroid/app/src/main/res/layout/main.xml deleted file mode 100755 index c981bcd4e..000000000 --- a/YAPDroid/app/src/main/res/layout/main.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - -