1 /*
2 * Copyright (C) 2008 - 2011 Vivien Malerba <malerba@gnome-db.org>
3 * Copyright (C) 2010 David King <davidk@openismus.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #include "GdaJPStmt.h"
22 #include "jni-wrapper.h"
23
24 JniWrapperMethod *GdaJPStmt__clearParameters = NULL;
25 JniWrapperMethod *GdaJPStmt__execute = NULL;
26 JniWrapperMethod *GdaJPStmt__getResultSet = NULL;
27 JniWrapperMethod *GdaJPStmt__getImpactedRows = NULL;
28 JniWrapperMethod *GdaJPStmt__declareParamTypes = NULL;
29 JniWrapperMethod *GdaJPStmt__setParameterValue = NULL;
30
31 JNIEXPORT void
Java_GdaJPStmt_initIDs(JNIEnv * env,jclass klass)32 JNICALL Java_GdaJPStmt_initIDs (JNIEnv *env, jclass klass)
33 {
34 gsize i;
35 typedef struct {
36 const gchar *name;
37 const gchar *sig;
38 gboolean is_static;
39 JniWrapperMethod **symbol;
40 } MethodSignature;
41
42 MethodSignature methods[] = {
43 {"clearParameters", "()V", FALSE, &GdaJPStmt__clearParameters},
44 {"execute", "()Z", FALSE, &GdaJPStmt__execute},
45 {"getResultSet", "()LGdaJResultSet;", FALSE, &GdaJPStmt__getResultSet},
46 {"getImpactedRows", "()I", FALSE, &GdaJPStmt__getImpactedRows},
47 {"declareParamTypes", "(J[B)V", FALSE, &GdaJPStmt__declareParamTypes},
48 {"setParameterValue", "(IJ)V", FALSE, &GdaJPStmt__setParameterValue}
49 };
50
51 for (i = 0; i < sizeof (methods) / sizeof (MethodSignature); i++) {
52 MethodSignature *m = & (methods [i]);
53 *(m->symbol) = jni_wrapper_method_create (env, klass, m->name, m->sig, m->is_static, NULL);
54 if (!*(m->symbol))
55 g_error ("Can't find method: %s.%s", "GdaJPStmt", m->name);
56 }
57 }
58