SQLite Android Bindings

Check-in [e01e48cd52]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Re-enable some disabled code required by user-defined function implementations.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e01e48cd524b3124103a8f3753f77b37d021678d
User & Date: dan 2013-12-21 17:58:45.433
Context
2013-12-21
19:02
Replace some leftover "android/database/" namespaces with "org/sqlite/database/". Make sure the native methods are all registered when the library is loaded. (check-in: b03c0713c9 user: dan tags: trunk)
17:58
Re-enable some disabled code required by user-defined function implementations. (check-in: e01e48cd52 user: dan tags: trunk)
16:04
Replace nativeExecuteForCursorWindow() with an implementation that builds with the NDK. Seems to work, but is not yet tested. Exception handling is almost certainly still wrong. (check-in: 365586dcaf user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to jni/ALog-priv.h.
59
60
61
62
63
64
65






66
#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif

#ifndef ALOGE
#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif







#endif







>
>
>
>
>
>

59
60
61
62
63
64
65
66
67
68
69
70
71
72
#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif

#ifndef ALOGE
#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif

/*
** Not quite the same as the core android LOG_FATAL_IF (which also
** sends a SIGTRAP), but close enough.
*/
#define LOG_FATAL_IF(bCond, zErr) if( bCond ) ALOGE(zErr);

#endif
Changes to jni/android_database_SQLiteConnection.cpp.
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949

#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
        var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
        LOG_FATAL_IF(! var, "Unable to find field " fieldName);

int register_android_database_SQLiteConnection(JNIEnv *env)
{
#if 0
    jclass clazz;
    FIND_CLASS(clazz, "android/database/sqlite/SQLiteCustomFunction");

    GET_FIELD_ID(gSQLiteCustomFunctionClassInfo.name, clazz,
            "name", "Ljava/lang/String;");
    GET_FIELD_ID(gSQLiteCustomFunctionClassInfo.numArgs, clazz,
            "numArgs", "I");
    GET_METHOD_ID(gSQLiteCustomFunctionClassInfo.dispatchCallback,
            clazz, "dispatchCallback", "([Ljava/lang/String;)V");

    FIND_CLASS(clazz, "java/lang/String");
    gStringClassInfo.clazz = jclass(env->NewGlobalRef(clazz));

#endif
    return jniRegisterNativeMethods(env, 
        "org/sqlite/database/sqlite/SQLiteConnection",
        sMethods, NELEM(sMethods)
    );
}

} // namespace android







<













<







921
922
923
924
925
926
927

928
929
930
931
932
933
934
935
936
937
938
939
940

941
942
943
944
945
946
947

#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
        var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
        LOG_FATAL_IF(! var, "Unable to find field " fieldName);

int register_android_database_SQLiteConnection(JNIEnv *env)
{

    jclass clazz;
    FIND_CLASS(clazz, "android/database/sqlite/SQLiteCustomFunction");

    GET_FIELD_ID(gSQLiteCustomFunctionClassInfo.name, clazz,
            "name", "Ljava/lang/String;");
    GET_FIELD_ID(gSQLiteCustomFunctionClassInfo.numArgs, clazz,
            "numArgs", "I");
    GET_METHOD_ID(gSQLiteCustomFunctionClassInfo.dispatchCallback,
            clazz, "dispatchCallback", "([Ljava/lang/String;)V");

    FIND_CLASS(clazz, "java/lang/String");
    gStringClassInfo.clazz = jclass(env->NewGlobalRef(clazz));


    return jniRegisterNativeMethods(env, 
        "org/sqlite/database/sqlite/SQLiteConnection",
        sMethods, NELEM(sMethods)
    );
}

} // namespace android
Changes to jni/android_database_SQLiteDebug.cpp.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

#define LOG_TAG "SQLiteDebug"

#include <jni.h>
#include <JNIHelp.h>
#include <ALog-priv.h>

/*
** Not quite the same as the core android LOG_FATAL_IF (which also
** sends a SIGTRAP), but close enough.
*/
#define LOG_FATAL_IF(bCond, zErr) if( bCond ) ALOGE(zErr);

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <sqlite3.h>








<
<
<
<
<
<







16
17
18
19
20
21
22






23
24
25
26
27
28
29

#define LOG_TAG "SQLiteDebug"

#include <jni.h>
#include <JNIHelp.h>
#include <ALog-priv.h>







#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <sqlite3.h>