From a82a72fc1427f2be176790bfa7d4f146937f379f Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 1 Aug 2016 19:16:39 -0500 Subject: [PATCH] myddas cleanups --- CMakeLists.txt | 5 ++++- packages/myddas/MyddasProto.h | 1 + packages/myddas/sqlite3/CMakeLists.txt | 19 +++++++++++-------- packages/myddas/sqlite3/myddas_sqlite3.c | 10 +--------- packages/myddas/sqlite3/sqlite3.c | 4 +--- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2e8caa0c..4c49b373f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,10 @@ include(Sources NO_POLICY_SCOPE) include(Model NO_POLICY_SCOPE) -include_directories ( utf8proc packages/myddas packages/myddas/sqlite3 packages/myddas/sqlite3/Android/jni/sqlite/nativehelper packages/myddas/sqlite3/Android/jni/sqlite/ ) +include_directories ( utf8proc packages/myddas packages/myddas/sqlite3 ) +if (ANDROID) + include_directories ( packages/myddas/sqlite3/Android/jni/sqlite/nativehelper packages/myddas/sqlite3/Android/jni/sqlite ) +endif (ANDROID) add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1) if (MYSQL_FOUND) diff --git a/packages/myddas/MyddasProto.h b/packages/myddas/MyddasProto.h index 72b7cdc5c..66eb1e400 100644 --- a/packages/myddas/MyddasProto.h +++ b/packages/myddas/MyddasProto.h @@ -10,6 +10,7 @@ extern MYDDAS_UTIL_CONNECTION extern MYDDAS_UTIL_PREDICATE myddas_init_initialize_predicate(const char *, int, const char *, MYDDAS_UTIL_PREDICATE); +extern int myddas_util_connection_type(void *con); #ifdef MYDDAS_STATS /* myddas_statistics.c */ diff --git a/packages/myddas/sqlite3/CMakeLists.txt b/packages/myddas/sqlite3/CMakeLists.txt index 9067deffd..f36f0a805 100644 --- a/packages/myddas/sqlite3/CMakeLists.txt +++ b/packages/myddas/sqlite3/CMakeLists.txt @@ -5,6 +5,7 @@ set( YAPSQLITE3_SOURCES sqlite3.h ) +if (ANDROID) set( YAPSQLITE3_ANDROID_SOURCES Android/jni/sqlite/JNIHelp.cpp Android/jni/sqlite/JniConstants.cpp @@ -13,7 +14,12 @@ Android/jni/sqlite/android_database_SQLiteCommon.h Android/jni/sqlite/android_database_SQLiteConnection.cpp Android/jni/sqlite/android_database_SQLiteDebug.cpp Android/jni/sqlite/android_database_SQLiteGlobal.cpp - ) +) +set( YAPSQLITE3_ANDROID_DIRS + Android/jni/sqlite + Android/jni/sqlite/nativehelper + ) +endif (ANDROID) #sqlite3 is now in the system @@ -27,15 +33,12 @@ set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE) set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS -DMYDDAS_SQLITE3=1) - include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Android/jni/sqlite ${CMAKE_CURRENT_SOURCE_DIR}/Android/jni/sqlite/nativehelper) + include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR} ${YAPSQLITE3_ANDROID_DIRS}) -if (ANDROID) - add_external (Yapsqlite3 ${YAPSQLITE3_SOURCES} ${YAPSQLITE3_ANDROID_SOURCES}) - else() - add_component (Yapsqlite3 ${YAPSQLITE3_SOURCES} ) - - #xtarget_link_libraries(Yapsqlite3 libYap) + add_component (Yapsqlite3 ${YAPSQLITE3_SOURCES} ${YAPSQLITE3_ANDROID_SOURCES}) + if (NOT ANDROID) + #target_link_libraries(Yapsqlite3 libYap) set_target_properties (Yapsqlite3 PROPERTIES PREFIX "" ) diff --git a/packages/myddas/sqlite3/myddas_sqlite3.c b/packages/myddas/sqlite3/myddas_sqlite3.c index d63c2e270..80954c466 100644 --- a/packages/myddas/sqlite3/myddas_sqlite3.c +++ b/packages/myddas/sqlite3/myddas_sqlite3.c @@ -275,11 +275,10 @@ static Int c_sqlite3_query(USES_REGS1) { Term arg_sql_query = Deref(ARG1); Term arg_result_set = Deref(ARG2); Term arg_db = Deref(ARG3); - Term arg_mode = Deref(ARG4); + // Term arg_mode = Deref(ARG4); // ignored by SQLite3 Term arg_arity = Deref(ARG5); const char *sql = AtomName(AtomOfTerm(arg_sql_query)); - const char *mode = AtomName(AtomOfTerm(arg_mode)); sqlite3 *db = AddressOfTerm(arg_db); sqlite3_stmt *stmt; @@ -287,7 +286,6 @@ static Int c_sqlite3_query(USES_REGS1) { MYDDAS_STATS_TIME start, end; #endif - int length = strlen(sql); struct result_set *rs = malloc(sizeof(struct result_set)); if (!rs) return FALSE; @@ -529,12 +527,6 @@ static Int c_sqlite3_row_cut(USES_REGS1) { return TRUE; } -#define cvt(s) cvt__(s PASS_REGS) - -static Term cvt__(const char *s USES_REGS) { - return Yap_CharsToTDQ(s, CurrentModule, LOCAL_encoding PASS_REGS); -} - /* db_row: ResultSet x Arity_ListOfArgs x ListOfArgs -> */ static Int c_sqlite3_row(USES_REGS1) { #ifdef MYDDAS_STATS diff --git a/packages/myddas/sqlite3/sqlite3.c b/packages/myddas/sqlite3/sqlite3.c index e19867890..507e5f34a 100644 --- a/packages/myddas/sqlite3/sqlite3.c +++ b/packages/myddas/sqlite3/sqlite3.c @@ -26349,7 +26349,6 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject); /* os_win.c */ /* Get the results of the thread */ SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ DWORD rc; - BOOL bRc; assert( ppOut!=0 ); if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT; @@ -26361,8 +26360,7 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ assert( p->id!=0 && p->id!=GetCurrentThreadId() ); rc = sqlite3Win32Wait((HANDLE)p->tid); assert( rc!=WAIT_IO_COMPLETION ); - bRc = CloseHandle((HANDLE)p->tid); - assert( bRc ); + assert( CloseHandle((HANDLE)p->tid) ); } if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult; sqlite3_free(p);