1 /* 2 * Copyright 2007, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "JNIHelp.h" 18 #include "sqlite_jni.h" 19 20 /* Methods for class SQLite_Database */ 21 extern JNIEXPORT void JNICALL Java_SQLite_Database__1open 22 (JNIEnv *, jobject, jstring, jint); 23 extern JNIEXPORT void JNICALL Java_SQLite_Database__1open_1aux_1file 24 (JNIEnv *, jobject, jstring); 25 extern JNIEXPORT void JNICALL Java_SQLite_Database__1finalize 26 (JNIEnv *, jobject); 27 extern JNIEXPORT void JNICALL Java_SQLite_Database__1close 28 (JNIEnv *, jobject); 29 extern JNIEXPORT void JNICALL Java_SQLite_Database__1exec__Ljava_lang_String_2LSQLite_Callback_2 30 (JNIEnv *, jobject, jstring, jobject); 31 extern JNIEXPORT void JNICALL Java_SQLite_Database__1exec__Ljava_lang_String_2LSQLite_Callback_2_3Ljava_lang_String_2 32 (JNIEnv *, jobject, jstring, jobject, jobjectArray); 33 extern JNIEXPORT jlong JNICALL Java_SQLite_Database__1last_1insert_1rowid 34 (JNIEnv *, jobject); 35 extern JNIEXPORT void JNICALL Java_SQLite_Database__1interrupt 36 (JNIEnv *, jobject); 37 extern JNIEXPORT jlong JNICALL Java_SQLite_Database__1changes 38 (JNIEnv *, jobject); 39 extern JNIEXPORT void JNICALL Java_SQLite_Database__1busy_1handler 40 (JNIEnv *, jobject, jobject); 41 extern JNIEXPORT void JNICALL Java_SQLite_Database__1busy_1timeout 42 (JNIEnv *, jobject, jint); 43 extern JNIEXPORT jboolean JNICALL Java_SQLite_Database__1complete 44 (JNIEnv *, jclass, jstring); 45 extern JNIEXPORT jstring JNICALL Java_SQLite_Database_version 46 (JNIEnv *, jclass); 47 extern JNIEXPORT jstring JNICALL Java_SQLite_Database_dbversion 48 (JNIEnv *, jobject); 49 extern JNIEXPORT void JNICALL Java_SQLite_Database__1create_1function 50 (JNIEnv *, jobject, jstring, jint, jobject); 51 extern JNIEXPORT void JNICALL Java_SQLite_Database__1create_1aggregate 52 (JNIEnv *, jobject, jstring, jint, jobject); 53 extern JNIEXPORT void JNICALL Java_SQLite_Database__1function_1type 54 (JNIEnv *, jobject, jstring, jint); 55 extern JNIEXPORT jstring JNICALL Java_SQLite_Database__1errmsg 56 (JNIEnv *, jobject); 57 extern JNIEXPORT jstring JNICALL Java_SQLite_Database_error_1string 58 (JNIEnv *, jclass, jint); 59 extern JNIEXPORT void JNICALL Java_SQLite_Database__1set_1encoding 60 (JNIEnv *, jobject, jstring); 61 extern JNIEXPORT void JNICALL Java_SQLite_Database__1set_1authorizer 62 (JNIEnv *, jobject, jobject); 63 extern JNIEXPORT void JNICALL Java_SQLite_Database__1trace 64 (JNIEnv *, jobject, jobject); 65 extern JNIEXPORT jboolean JNICALL Java_SQLite_Database_is3 66 (JNIEnv *, jobject); 67 extern JNIEXPORT void JNICALL Java_SQLite_Database_vm_1compile 68 (JNIEnv *, jobject, jstring, jobject); 69 extern JNIEXPORT void JNICALL Java_SQLite_Database_vm_1compile_1args 70 (JNIEnv *, jobject, jstring, jobject, jobjectArray); 71 extern JNIEXPORT void JNICALL Java_SQLite_Database_stmt_1prepare 72 (JNIEnv *, jobject, jstring, jobject); 73 extern JNIEXPORT void JNICALL Java_SQLite_Database__1open_1blob 74 (JNIEnv *, jobject, jstring, jstring, jstring, jlong, jboolean, jobject); 75 extern JNIEXPORT void JNICALL Java_SQLite_Database__1progress_1handler 76 (JNIEnv *, jobject, jint, jobject); 77 extern JNIEXPORT void JNICALL Java_SQLite_Database_internal_1init 78 (JNIEnv *, jclass); 79 80 81 /* Methods for class SQLite_Vm */ 82 83 extern JNIEXPORT jboolean JNICALL Java_SQLite_Vm_step 84 (JNIEnv *, jobject, jobject); 85 extern JNIEXPORT jboolean JNICALL Java_SQLite_Vm_compile 86 (JNIEnv *, jobject); 87 extern JNIEXPORT void JNICALL Java_SQLite_Vm_stop 88 (JNIEnv *, jobject); 89 extern JNIEXPORT void JNICALL Java_SQLite_Vm_finalize 90 (JNIEnv *, jobject); 91 extern JNIEXPORT void JNICALL Java_SQLite_Vm_internal_1init 92 (JNIEnv *, jclass); 93 94 /* Methods for class SQLite_FunctionContext */ 95 96 extern JNIEXPORT void JNICALL Java_SQLite_FunctionContext_set_1result__Ljava_lang_String_2 97 (JNIEnv *, jobject, jstring); 98 extern JNIEXPORT void JNICALL Java_SQLite_FunctionContext_set_1result__I 99 (JNIEnv *, jobject, jint); 100 extern JNIEXPORT void JNICALL Java_SQLite_FunctionContext_set_1result__D 101 (JNIEnv *, jobject, jdouble); 102 extern JNIEXPORT void JNICALL Java_SQLite_FunctionContext_set_1error 103 (JNIEnv *, jobject, jstring); 104 extern JNIEXPORT void JNICALL Java_SQLite_FunctionContext_set_1result___3B 105 (JNIEnv *, jobject, jbyteArray); 106 extern JNIEXPORT void JNICALL Java_SQLite_FunctionContext_set_1result_1zeroblob 107 (JNIEnv *, jobject, jint); 108 extern JNIEXPORT jint JNICALL Java_SQLite_FunctionContext_count 109 (JNIEnv *, jobject); 110 extern JNIEXPORT void JNICALL Java_SQLite_FunctionContext_internal_1init 111 (JNIEnv *, jclass); 112 113 /* Methods for class SQLite_Stmt */ 114 115 extern JNIEXPORT jboolean JNICALL Java_SQLite_Stmt_prepare 116 (JNIEnv *, jobject); 117 extern JNIEXPORT jboolean JNICALL Java_SQLite_Stmt_step 118 (JNIEnv *, jobject); 119 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_close 120 (JNIEnv *, jobject); 121 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_reset 122 (JNIEnv *, jobject); 123 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_clear_1bindings 124 (JNIEnv *, jobject); 125 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_bind__II 126 (JNIEnv *, jobject, jint, jint); 127 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_bind__IJ 128 (JNIEnv *, jobject, jint, jlong); 129 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_bind__ID 130 (JNIEnv *, jobject, jint, jdouble); 131 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_bind__I_3B 132 (JNIEnv *, jobject, jint, jbyteArray); 133 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_bind__ILjava_lang_String_2 134 (JNIEnv *, jobject, jint, jstring); 135 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_bind__I 136 (JNIEnv *, jobject, jint); 137 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_bind_1zeroblob 138 (JNIEnv *, jobject, jint, jint); 139 extern JNIEXPORT jint JNICALL Java_SQLite_Stmt_bind_1parameter_1count 140 (JNIEnv *, jobject); 141 extern JNIEXPORT jstring JNICALL Java_SQLite_Stmt_bind_1parameter_1name 142 (JNIEnv *, jobject, jint); 143 extern JNIEXPORT jint JNICALL Java_SQLite_Stmt_bind_1parameter_1index 144 (JNIEnv *, jobject, jstring); 145 extern JNIEXPORT jint JNICALL Java_SQLite_Stmt_column_1int 146 (JNIEnv *, jobject, jint); 147 extern JNIEXPORT jlong JNICALL Java_SQLite_Stmt_column_1long 148 (JNIEnv *, jobject, jint); 149 extern JNIEXPORT jdouble JNICALL Java_SQLite_Stmt_column_1double 150 (JNIEnv *, jobject, jint); 151 extern JNIEXPORT jbyteArray JNICALL Java_SQLite_Stmt_column_1bytes 152 (JNIEnv *, jobject, jint); 153 extern JNIEXPORT jstring JNICALL Java_SQLite_Stmt_column_1string 154 (JNIEnv *, jobject, jint); 155 extern JNIEXPORT jint JNICALL Java_SQLite_Stmt_column_1type 156 (JNIEnv *, jobject, jint); 157 extern JNIEXPORT jint JNICALL Java_SQLite_Stmt_column_1count 158 (JNIEnv *, jobject); 159 extern JNIEXPORT jstring JNICALL Java_SQLite_Stmt_column_1table_1name 160 (JNIEnv *, jobject, jint); 161 extern JNIEXPORT jstring JNICALL Java_SQLite_Stmt_column_1database_1name 162 (JNIEnv *, jobject, jint); 163 extern JNIEXPORT jstring JNICALL Java_SQLite_Stmt_column_1decltype 164 (JNIEnv *, jobject, jint); 165 extern JNIEXPORT jstring JNICALL Java_SQLite_Stmt_column_1origin_1name 166 (JNIEnv *, jobject, jint); 167 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_finalize 168 (JNIEnv *, jobject); 169 extern JNIEXPORT void JNICALL Java_SQLite_Stmt_internal_1init 170 (JNIEnv *, jclass); 171 172 /* Methods for class SQLite_Blob */ 173 174 extern JNIEXPORT void JNICALL Java_SQLite_Blob_close 175 (JNIEnv *, jobject); 176 extern JNIEXPORT jint JNICALL Java_SQLite_Blob_write 177 (JNIEnv *, jobject, jbyteArray, jint, jint, jint); 178 extern JNIEXPORT jint JNICALL Java_SQLite_Blob_read 179 (JNIEnv *, jobject, jbyteArray, jint, jint, jint); 180 extern JNIEXPORT void JNICALL Java_SQLite_Blob_finalize 181 (JNIEnv *, jobject); 182 extern JNIEXPORT void JNICALL Java_SQLite_Blob_internal_1init 183 (JNIEnv *, jclass); 184 185 /* 186 * JNI registration 187 */ 188 static JNINativeMethod sqliteDatabaseMethods[] = { 189 /* name, signature, funcPtr */ 190 /* Header for class SQLite_Database */ 191 { "_open", "(Ljava/lang/String;I)V", Java_SQLite_Database__1open}, 192 { "_open_aux_file", "(Ljava/lang/String;)V", Java_SQLite_Database__1open_1aux_1file}, 193 { "_finalize", "()V", Java_SQLite_Database__1finalize}, 194 { "_close", "()V", Java_SQLite_Database__1close}, 195 { "_exec", "(Ljava/lang/String;LSQLite/Callback;)V", Java_SQLite_Database__1exec__Ljava_lang_String_2LSQLite_Callback_2}, 196 { "_exec", "(Ljava/lang/String;LSQLite/Callback;[Ljava/lang/String;)V", Java_SQLite_Database__1exec__Ljava_lang_String_2LSQLite_Callback_2_3Ljava_lang_String_2}, 197 { "_last_insert_rowid", "()J", Java_SQLite_Database__1last_1insert_1rowid}, 198 { "_interrupt", "()V", Java_SQLite_Database__1interrupt}, 199 { "_changes", "()J", Java_SQLite_Database__1changes}, 200 { "_busy_handler", "(LSQLite/BusyHandler;)V", Java_SQLite_Database__1busy_1handler}, 201 { "_busy_timeout", "(I)V", Java_SQLite_Database__1busy_1timeout}, 202 { "_complete", "(Ljava/lang/String;)Z", Java_SQLite_Database__1complete}, 203 { "version", "()Ljava/lang/String;", Java_SQLite_Database_version}, 204 { "dbversion", "()Ljava/lang/String;", Java_SQLite_Database_dbversion}, 205 { "_create_function", "(Ljava/lang/String;ILSQLite/Function;)V", Java_SQLite_Database__1create_1function}, 206 { "_create_aggregate", "(Ljava/lang/String;ILSQLite/Function;)V", Java_SQLite_Database__1create_1aggregate}, 207 { "_function_type", "(Ljava/lang/String;I)V", Java_SQLite_Database__1function_1type}, 208 { "_errmsg", "()Ljava/lang/String;", Java_SQLite_Database__1errmsg}, 209 { "error_string", "(I)Ljava/lang/String;", Java_SQLite_Database_error_1string}, 210 { "_set_encoding", "(Ljava/lang/String;)V", Java_SQLite_Database__1set_1encoding}, 211 { "_set_authorizer", "(LSQLite/Authorizer;)V", Java_SQLite_Database__1set_1authorizer}, 212 { "_trace", "(LSQLite/Trace;)V", Java_SQLite_Database__1trace}, 213 { "is3", "()Z", Java_SQLite_Database_is3}, 214 { "vm_compile", "(Ljava/lang/String;LSQLite/Vm;)V", Java_SQLite_Database_vm_1compile}, 215 { "vm_compile_args", "(Ljava/lang/String;LSQLite/Vm;[Ljava/lang/String;)V", Java_SQLite_Database_vm_1compile_1args}, 216 { "stmt_prepare", "(Ljava/lang/String;LSQLite/Stmt;)V", Java_SQLite_Database_stmt_1prepare}, 217 { "_open_blob", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JZLSQLite/Blob;)V", Java_SQLite_Database__1open_1blob}, 218 { "_progress_handler", "(ILSQLite/ProgressHandler;)V", Java_SQLite_Database__1progress_1handler}, 219 { "internal_init", "()V", Java_SQLite_Database_internal_1init} 220 }; 221 222 static JNINativeMethod sqliteVmMethods[] = { 223 /* Header for class SQLite_Vm */ 224 { "step", "(LSQLite/Callback;)Z", Java_SQLite_Vm_step}, 225 { "compile", "()Z", Java_SQLite_Vm_compile}, 226 { "stop", "()V", Java_SQLite_Vm_stop}, 227 { "finalize", "()V", Java_SQLite_Vm_finalize}, 228 { "internal_init", "()V", Java_SQLite_Vm_internal_1init} 229 }; 230 231 static JNINativeMethod sqliteFunctionContextMethods[] = { 232 /* Header for class SQLite_FunctionContext */ 233 { "set_result", "(Ljava/lang/String;)V", Java_SQLite_FunctionContext_set_1result__Ljava_lang_String_2}, 234 { "set_result", "(I)V", Java_SQLite_FunctionContext_set_1result__I}, 235 { "set_result", "(D)V", Java_SQLite_FunctionContext_set_1result__D}, 236 { "set_error", "(Ljava/lang/String;)V", Java_SQLite_FunctionContext_set_1error}, 237 { "set_result", "([B)V", Java_SQLite_FunctionContext_set_1result___3B}, 238 { "set_result_zeroblob", "(I)V", Java_SQLite_FunctionContext_set_1result_1zeroblob}, 239 { "count", "()I", Java_SQLite_FunctionContext_count}, 240 { "internal_init", "()V", Java_SQLite_FunctionContext_internal_1init} 241 }; 242 243 static JNINativeMethod sqliteStmtMethods[] = { 244 /* Header for class SQLite_Stmt */ 245 { "prepare", "()Z", Java_SQLite_Stmt_prepare}, 246 { "step", "()Z", JNICALL Java_SQLite_Stmt_step}, 247 { "close", "()V", Java_SQLite_Stmt_close}, 248 { "reset", "()V", Java_SQLite_Stmt_reset}, 249 { "clear_bindings", "()V", Java_SQLite_Stmt_clear_1bindings}, 250 { "bind", "(II)V", Java_SQLite_Stmt_bind__II}, 251 { "bind", "(IJ)V", Java_SQLite_Stmt_bind__IJ}, 252 { "bind", "(ID)V", Java_SQLite_Stmt_bind__ID}, 253 { "bind", "(I[B)V", Java_SQLite_Stmt_bind__I_3B}, 254 { "bind", "(ILjava/lang/String;)V", Java_SQLite_Stmt_bind__ILjava_lang_String_2}, 255 { "bind", "(I)V", Java_SQLite_Stmt_bind__I}, 256 { "bind_zeroblob", "(II)V", Java_SQLite_Stmt_bind_1zeroblob}, 257 { "bind_parameter_count", "()I", Java_SQLite_Stmt_bind_1parameter_1count}, 258 { "bind_parameter_name", "(I)Ljava/lang/String;", Java_SQLite_Stmt_bind_1parameter_1name}, 259 { "bind_parameter_index", "(Ljava/lang/String;)I", Java_SQLite_Stmt_bind_1parameter_1index}, 260 { "column_int", "(I)I", Java_SQLite_Stmt_column_1int}, 261 { "column_long", "(I)J", Java_SQLite_Stmt_column_1long}, 262 { "column_double", "(I)D", Java_SQLite_Stmt_column_1double}, 263 { "column_bytes", "(I)[B", Java_SQLite_Stmt_column_1bytes}, 264 { "column_string", "(I)Ljava/lang/String;", Java_SQLite_Stmt_column_1string}, 265 { "column_type", "(I)I", Java_SQLite_Stmt_column_1type}, 266 { "column_count", "()I", Java_SQLite_Stmt_column_1count}, 267 { "column_table_name", "(I)Ljava/lang/String;", Java_SQLite_Stmt_column_1table_1name}, 268 { "column_database_name", "(I)Ljava/lang/String;", Java_SQLite_Stmt_column_1database_1name}, 269 { "column_decltype", "(I)Ljava/lang/String;", Java_SQLite_Stmt_column_1decltype}, 270 { "column_origin_name", "(I)Ljava/lang/String;", Java_SQLite_Stmt_column_1origin_1name}, 271 { "finalize", "()V", Java_SQLite_Stmt_finalize}, 272 { "internal_init", "()V", Java_SQLite_Stmt_internal_1init} 273 }; 274 275 static JNINativeMethod sqliteBlobMethods[] = { 276 /* Header for class SQLite_Blob */ 277 278 { "close", "()V", Java_SQLite_Blob_close}, 279 { "write", "([BIII)I", Java_SQLite_Blob_write}, 280 { "read", "([BIII)I", Java_SQLite_Blob_read}, 281 { "finalize", "()V", Java_SQLite_Blob_finalize}, 282 { "internal_init", "()V", Java_SQLite_Blob_internal_1init} 283 }; 284 285 int register_SQLite_Database(JNIEnv* env) { 286 return jniRegisterNativeMethods(env, "SQLite/Database", 287 sqliteDatabaseMethods, NELEM(sqliteDatabaseMethods)); 288 } 289 290 int register_SQLite_Vm(JNIEnv* env) { 291 return jniRegisterNativeMethods(env, "SQLite/Vm", 292 sqliteVmMethods, NELEM(sqliteVmMethods)); 293 } 294 295 int register_SQLite_FunctionContext(JNIEnv* env) { 296 return jniRegisterNativeMethods(env, "SQLite/FunctionContext", 297 sqliteFunctionContextMethods, NELEM(sqliteFunctionContextMethods)); 298 } 299 300 int register_SQLite_Stmt(JNIEnv* env) { 301 return jniRegisterNativeMethods(env, "SQLite/Stmt", 302 sqliteStmtMethods, NELEM(sqliteStmtMethods)); 303 } 304 305 int register_SQLite_Blob(JNIEnv* env) { 306 return jniRegisterNativeMethods(env, "SQLite/Blob", 307 sqliteBlobMethods, NELEM(sqliteBlobMethods)); 308 } 309