summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 19e851d)
raw | patch | inline | side by side (parent: 19e851d)
author | ishmal <ishmal@users.sourceforge.net> | |
Tue, 11 Mar 2008 16:51:24 +0000 (16:51 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Tue, 11 Mar 2008 16:51:24 +0000 (16:51 +0000) |
src/bind/dobinding.cpp | patch | blob | history |
diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp
index ec0518d8bcab2f938f1e85e377d0a6e3e6d8cd4b..29d61b722d0810af3aa2bebfee0e2c949c7c2944 100644 (file)
--- a/src/bind/dobinding.cpp
+++ b/src/bind/dobinding.cpp
* This file can get quite large!
*/
+/**
+ * This struct associates a class name with its native
+ * bindings. Since C++ does not allow "flexible" arrays,
+ * we will separate each of the tables into a JNINativeMethod
+ * array, and a class with a name and a pointer to that array.
+ */
+typedef struct
+{
+ const char *className;
+ JNINativeMethod *methods;
+} NativeClass;
+
//########################################################################
//# BASE OBJECT
}
-static JNINativeMethod DOMBaseMethods[] =
+static JNINativeMethod nm_DOMBase[] =
{
{ (char *)"construct", (char *)"()V", (void *)DOMBase_construct },
{ (char *)"destruct", (char *)"()V", (void *)DOMBase_destruct },
{ NULL, NULL, NULL }
};
+static NativeClass nc_DOMBase =
+{
+ "org/inkscape/dom/DOMBase",
+ nm_DOMBase
+};
//########################################################################
//# DOMImplementation
//########################################################################
-static JNINativeMethod DOMImplementationMethods[] =
+static JNINativeMethod nm_DOMImplementation[] =
{
{ (char *)"construct", (char *)"()V", (void *)DOMImplementation_nCreateDocument },
{ NULL, NULL, NULL }
};
+static NativeClass nc_DOMImplementation =
+{
+ "org/inkscape/dom/DOMImplementation",
+ nm_DOMImplementation
+};
+
//########################################################################
//# MAIN
//########################################################################
-typedef struct
-{
- const char *className;
- JNINativeMethod *methods;
-} NativeEntry;
-static NativeEntry nativeEntries[] =
+/**
+ * This is a table-of-tables, matching a class name to its
+ * table of native methods. We can probably think of a cleaner way
+ * of doing this
+ */
+static NativeClass *allClasses[] =
{
- { "org/inkscape/dom/DOMBase", DOMBaseMethods },
- { "org/inkscape/dom/DOMImplementation", DOMImplementationMethods },
- { NULL, NULL }
+ &nc_DOMBase,
+ &nc_DOMImplementation,
+ NULL
};
bool JavaBinderyImpl::doBinding()
{
- for (NativeEntry *ne = nativeEntries ; ne->className ; ne++)
+ for (NativeClass **nc = allClasses ; *nc ; nc++)
{
- bool ret = registerNatives(ne->className, ne->methods);
+ bool ret = registerNatives((*nc)->className, (*nc)->methods);
if (!ret)
{
err("Could not bind native methods");