List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:September 13 2007 10:33pm
Subject:Rev 154: Added clean rules to build.xml to clean things up. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge
View as plain text  
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmerge

------------------------------------------------------------
revno: 154
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Thu 2007-09-13 15:33:10 -0700
message:
  Added clean rules to build.xml to clean things up.
removed:
  java/com/mysql/cluster/mgmapi/Makefile.am makefile.am-20070415064100-zwla03of7on3v9nf-2
added:
  java/ndbj.i                    ndbj.i-20070913223244-5938mztpztyn9sry-1
modified:
  java/Makefile.am               makefile.am-20070415032352-9dpe6aurqcnuwcrd-1
  java/build.xml                 build.xml-20070521233115-yg3ylf2k3vuzr27o-1
=== removed file 'java/com/mysql/cluster/mgmapi/Makefile.am'
--- a/java/com/mysql/cluster/mgmapi/Makefile.am	2007-05-21 23:56:36 +0000
+++ b/java/com/mysql/cluster/mgmapi/Makefile.am	1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
-#package_namespace = com/mysql/cluster/mgmapi
-CLEANFILES =  ndb_mgm*java ndb_logevent*java Ndb_logevent*java mgmapi*java SWIG* *log
-
-#all-am: Makefile mgmapi.jar
-
-#mgmapi.class: mgmapi.java
-#	$(JAVAC) *java
-#
-#mgmapi.jar: mgmapi.class
-#	(  cd ${top_srcdir}/java ; \
-#           $(JAR) cvf ${package_namespace}/$@ ${package_namespace}/*class )
-

=== added file 'java/ndbj.i'
--- a/java/ndbj.i	1970-01-01 00:00:00 +0000
+++ b/java/ndbj.i	2007-09-13 22:33:10 +0000
@@ -0,0 +1,330 @@
+// -*- mode: c++ -*-
+/*  ndb-connectors: Wrappers for the NDBAPI
+    Copyright (C) 2006 MySQL, Inc.
+    
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or 
+    (at your option) any later version.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+%module(directors="1") ndbj
+
+
+%rename AbortOption AbortOptionRef;
+%rename BaseCallback BaseCallbackRef;
+%rename ExecType ExecTypeRef;
+%rename NdbBlob NdbBlobRef;
+%rename NdbClusterConnection NdbClusterConnectionRef;
+%rename NdbColumn NdbColumnRef;
+%rename NdbDictionary NdbDictionaryRef;
+%rename NdbError NdbErrorRef;
+%rename NdbEventOperation NdbEventOperationRef;
+%rename NdbEvent NdbEventRef;
+%rename NdbException NdbExeptionRef;
+%rename NdbFactory NdbFactoryRef;
+%rename NdbIndexOperation NdbIndexOperationRef;
+%rename NdbIndexScanOperation NdbIndexScanOperationRef;
+%rename NdbObject NdbObjectRef;
+%rename NdbOperation NdbOperationRef;
+%rename NdbRecAttr NdbRecAttrRef;
+%rename Ndb NdbRef;
+%rename NdbScanFilter NdbScanFilterRef;
+%rename NdbScanOperation NdbScanOperationRef;
+%rename NdbTable NdbTableRef;
+%rename NdbTransaction NdbTransactionRef;
+
+
+%include "ndbglobals.i"
+%include "various.i"
+%include "enums.swg"
+
+%{
+#include <stdio.h>
+//#include <iostream>
+
+typedef struct
+asynch_callback_t
+{  
+  JNIEnv *env; 
+  jobject obj; 
+};
+
+static void JavaCallBack(int result,
+                     NdbTransaction *trans,
+                     void *aObject)
+{
+
+  asynch_callback_t * callback_data = (asynch_callback_t *)aObject;
+
+  JNIEnv *env = callback_data->env; 
+
+  jclass callablecls = env->GetObjectClass((callback_data->obj));
+
+  jmethodID mid = env->GetMethodID(callablecls, "callback", "(ILNdbTransaction;)V");
+  if (mid == NULL) { 
+    jclass clazz = env->FindClass("java/lang/RuntimeException");
+    env->ThrowNew(clazz,"No callback method!");
+  }
+
+  env->CallVoidMethod(callback_data->obj,mid,trans,(jlong)result);
+
+}
+
+#define NDB_exception(excp, msg) { ndb_throw_exception(jenv, #excp,msg);  } 
+
+void ndb_throw_exception(JNIEnv *jenv, const char * excp, const char *msg) { 
+  const char * prefix = "com/mysql/cluster/errors/";
+  char * exception = (char *)malloc(strlen(excp)+strlen(prefix)+1);
+  strcpy(exception,prefix);
+  strcat(exception,excp);
+
+  //jclass clazz = jenv->FindClass("java/lang/RuntimeException");
+  jclass clazz = jenv->FindClass(exception);
+  free(exception);
+
+  jenv->ThrowNew(clazz,msg);
+}
+ %}
+
+
+%typemap(in) asynch_callback_t * cb
+%{ 
+  asynch_callback_t * callback_data; 
+    callback_data = new asynch_callback_t;
+    callback_data->env = jenv; 
+    callback_data->obj = $input;
+    
+    $1 = callback_data;
+ %}
+
+%typemap(jni) asynch_callback_t * "jobject" 
+%typemap(jtype) asynch_callback_t * "Object"
+%typemap(jstype) asynch_callback_t * "INdbCallable"
+%typemap(javain) asynch_callback_t * "(Object)$javainput"
+
+%typemap(javaimports) NdbFactory, Ndb, Ndb_cluster_connection, NdbTransaction,
NdbOperation, NdbIndexOperation, NdbScanOperation, NdbIndexScanOperation, NdbBlob,
NdbDictDictionary, NdbDictColumn, NdbDictIndex, NdbDictTable, NdbDictObject,
NdbScanFilter, NdbEvent, NdbEventOperation, NdbRecAttr "import
com.mysql.cluster.errors.*;"
+%pragma(java) moduleimports="import com.mysql.cluster.errors.*;"
+%pragma(java) jniclassimports="import com.mysql.cluster.errors.*;"
+
+
+%typemap(jni) MYSQL_TIME * "jobject"
+%typemap(jtype) MYSQL_TIME * "Object"
+%typemap(jstype) MYSQL_TIME * "java.util.Calendar"
+%typemap(javain) MYSQL_TIME * "$javainput"
+%typemap(javaout) MYSQL_TIME * { return (java.util.Calendar)$jnicall; }
+
+%typemap(jstype) NdbTimestamp "java.sql.Timestamp"
+ //%typemap(jtype) NdbTimestamp "java.sql.Timestamp"
+%typemap(javain) NdbTimestamp "$javainput.getTime()/1000"
+%typemap(javaout) NdbTimestamp { return new java.sql.Timestamp($jnicall); }
+
+%typemap(jni) BYTES "jbyteArray"
+%typemap(jtype) BYTES "byte[]"
+%typemap(jstype) BYTES "byte[]"
+%typemap(javaout) BYTES { return $jnicall; } 
+
+%typemap(in) (MYSQL_TIME *) { 
+   MYSQL_TIME * dt = (MYSQL_TIME *)malloc(sizeof(MYSQL_TIME));
+   static jclass calendar_class = jenv->FindClass("java/util/Calendar");
+   static jmethodID getID = jenv->GetMethodID(calendar_class,"get","(I)I");
+   static jfieldID yearID = jenv->GetFieldID(calendar_class,"YEAR","I");
+   static jfieldID monthID = jenv->GetFieldID(calendar_class,"MONTH","I");
+   static jfieldID dayID = jenv->GetFieldID(calendar_class,"DAY","I");
+   static jfieldID hourID = jenv->GetFieldID(calendar_class,"HOUR","I");
+   static jfieldID minuteID = jenv->GetFieldID(calendar_class,"MINUTE","I");
+   static jfieldID secondID = jenv->GetFieldID(calendar_class,"SECOND","I");
+   static jint yearfield = jenv->GetIntField(calendar_class,yearID);
+   static jint monthfield = jenv->GetIntField(calendar_class,monthID);
+   static jint dayfield = jenv->GetIntField(calendar_class,dayID);
+   static jint hourfield = jenv->GetIntField(calendar_class,hourID);
+   static jint minutefield = jenv->GetIntField(calendar_class,minuteID);
+   static jint secondfield = jenv->GetIntField(calendar_class,secondID);
+   jint yearval = jenv->CallIntMethod($input,getID,yearfield);
+   jint monthval = jenv->CallIntMethod($input,getID,monthfield);
+   jint dayval = jenv->CallIntMethod($input,getID,dayfield);
+   jint hourval = jenv->CallIntMethod($input,getID,hourfield);
+   jint minuteval = jenv->CallIntMethod($input,getID,minutefield);
+   jint secondval = jenv->CallIntMethod($input,getID,secondfield);
+   dt->year = (int)yearval;
+   dt->month = (int)monthval;
+   dt->day = (int)dayval;
+   dt->hour = (int)hourval;
+   dt->minute = (int)minuteval;
+   dt->second = (int)secondval;
+   $1 = dt;
+ }
+
+%typemap(out) (MYSQL_TIME *) { 
+  static jclass calendar_class = jenv->FindClass("java/util/Calendar");
+  static jmethodID get_calendar_instance =
jenv->GetStaticMethodID(calendar_class,"getInstance","()Ljava/util/Calendar;");
+  static jmethodID setID = jenv->GetMethodID(calendar_class,"set","(IIIIII)V");
+  $result = jenv->CallObjectMethod(calendar_class,get_calendar_instance);
+ 
jenv->CallVoidMethod($result,setID,$1->year,$1->month,$1->day,$1->hour,$1->minute,$1->second);
+
+ }
+
+%typemap(out) (BYTES)  { 
+ 
+ $result = jenv->NewByteArray($1.theLength); 
+ jenv->SetByteArrayRegion($result,0,$1.theLength,(const jbyte*) $1.theString);
+ 
+} 
+
+%typemap(freearg) (MYSQL_TIME *) {
+  free((MYSQL_TIME *) $1);
+ }
+
+
+%typemap(in) (const char* anInputString, size_t len) {
+  /* Check that we are getting a string */
+  $1 = (char *)(jenv->GetStringUTFChars($input,0));
+  $2 = jenv->GetStringUTFLength($input);
+ }
+
+%typemap(freearg) (const char * anInputString, size_t len) { 
+  if ($1) { 
+    jenv->ReleaseStringUTFChars($input,$1); 
+  }
+ }
+
+%typemap(in) (const char* BYTE, size_t len) { 
+  $1 = (char *)(jenv->GetByteArrayElements($input,0));
+  $2 = jenv->GetArrayLength($input);
+ }
+%typemap(in) (Int64 anInputTimestamp) { 
+  // Java timestamp is higher precision - so we cut it down
+  $1 = (Int64) ($input / 1000);
+ }
+
+
+/* char ** typemap */
+
+/* This tells SWIG to treat char ** as a special case when used as a parameter
+   in a function call */
+%typemap(in) (unsigned noOfNames, const char ** names) {
+    Uint32 i = 0;
+    $1 = jenv->GetArrayLength($input);
+    $2 = (char **) malloc(($1+1)*sizeof(char *));
+    /* make a copy of each string */
+    for (i = 0; i<$1; i++) {
+      jstring j_string = (jstring)(jenv->GetObjectArrayElement($input, i));
+      const char * c_string = jenv->GetStringUTFChars(j_string, 0);
+      $2[i] = (char *)malloc(strlen((c_string)+1)*sizeof(const char *));
+      strcpy($2[i], c_string);
+      jenv->ReleaseStringUTFChars(j_string, c_string);
+      jenv->DeleteLocalRef(j_string);
+    }
+    $2[i] = 0;
+ }
+
+/* This cleans up the memory we malloc'd before the function call */
+%typemap(freearg) (unsigned noOfNames, const char ** names)  {
+  Uint32 i;
+  for (i=0; i<$1-1; i++)
+    free($2[i]);
+  free($2);
+ }
+
+/* This allows a C function to return a char ** as a Java String array */
+%typemap(out) char ** {
+  Uint32 i;
+  Uint32 len=0;
+  jstring temp_string;
+  const jclass clazz = jenv->FindClass("java/lang/String");
+  
+  while ($1[len]) len++;    
+  jresult = jenv->NewObjectArray(len, clazz, NULL);
+  /* exception checking omitted */
+  
+  for (i=0; i<len; i++) {
+    temp_string = jenv->NewStringUTF(*result++);
+    jenv->SetObjectArrayElement(jresult, i, temp_string);
+    jenv->DeleteLocalRef(temp_string);
+  }
+}
+
+/* These 3 typemaps tell SWIG what JNI and Java types to use */
+%typemap(jni) (unsigned noOfNames, const char ** names) "jobjectArray"
+%typemap(jtype) (unsigned noOfNames, const char ** names) "String[]"
+%typemap(jstype)(unsigned noOfNames, const char ** names) "String[]"
+
+/* These 2 typemaps handle the conversion of the jtype to jstype typemap type
+   and visa versa */
+%typemap(javain) (unsigned noOfNames, const char ** names) "$javainput"
+%typemap(javaout) char ** {
+    return $jnicall;
+  }
+
+
+
+
+
+%pragma(java) modulecode=%{
+  static {
+    try {
+      System.loadLibrary("ndbj");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. \n" + e);
+      System.exit(1);
+    }
+    ndbj.ndb_init();
+  }
+%}
+
+%include "NdbFactory.i"
+%include "NdbClusterConnection.i"
+%include "Ndb.i"
+%include "NdbDictionary.i"
+%include "NdbTransaction.i"
+
+%extend NdbTransaction { 
+  
+  void executeAsynchPrepare(ExecType execType, asynch_callback_t * cb, AbortOption      
abortOption = AbortOnError){ 
+    self->executeAsynchPrepare(execType,JavaCallBack,(void *)cb, abortOption); 
+    
+  }
+};
+%include "NdbOperation.i"
+%include "NdbScanOperation.i"
+%include "NdbIndexOperation.i"
+%include "NdbIndexScanOperation.i"
+%include "NdbEventOperation.i"
+%include "NdbRecAttr.i"
+%include "NdbBlob.i"
+%include "NdbError.i"
+%include "NdbScanFilter.i"
+
+
+/*%rename AbortOption AbortOptionRef; 
+%rename BaseCallback BaseCallbackRef; 
+%rename ExecType ExecTypeRef; 
+%rename NdbBlob NdbBlobRef; 
+%rename NdbClusterConnection NdbClusterConnectionRef; 
+%rename NdbColumn NdbColumnRef; 
+%rename NdbDictionary NdbDictionaryRef; 
+%rename NdbError NdbErrorRef; 
+%rename NdbEventOperation NdbEventOperationRef; 
+%rename NdbEvent NdbEventRef; 
+%rename NdbException NdbExeptionRef; 
+%rename NdbFactory NdbFactoryRef; 
+%rename NdbIndexOperation NdbIndexOperationRef; 
+%rename NdbIndexScanOperation NdbIndexScanOperationRef; 
+%rename NdbObject NdbObjectRef; 
+%rename NdbOperation NdbOperationRef; 
+%rename NdbRecAttr NdbRecAttrRef; 
+%rename Ndb NdbRef; 
+%rename NdbScanFilter NdbScanFilterRef; 
+%rename NdbScanOperation NdbScanOperationRef; 
+%rename NdbTable NdbTableRef; 
+%rename NdbTransaction NdbTransactionRef; 
+*/

=== modified file 'java/Makefile.am'
--- a/java/Makefile.am	2007-09-13 22:13:14 +0000
+++ b/java/Makefile.am	2007-09-13 22:33:10 +0000
@@ -5,7 +5,7 @@
 BUILT_SOURCES = $(NDBAPI_BUILT_SRC) $(MGMAPI_BUILT_SRC)
 NDBAPI_SWIG_SRC = ndbapi.i $(SWIG_SOURCES)
 MGMAPI_SWIG_SRC = mgmapi.i $(topdir)/swig/mgm.i
-CLEANFILES = $(BUILT_SOURCES) *class *log ndbj.jar
+CLEANFILES = $(BUILT_SOURCES) *class *log ndbj.jar *_wrap.h
 
 lib_LTLIBRARIES = libndbj.la libmgmj.la
 libndbj_la_SOURCES = ndbj_wrap.cxx

=== modified file 'java/build.xml'
--- a/java/build.xml	2007-09-13 22:15:20 +0000
+++ b/java/build.xml	2007-09-13 22:33:10 +0000
@@ -22,8 +22,20 @@
   </target>
   <target name="clean">
     <delete>
-<!--      <fileset dir="." includes="**/*Ref.class"/> -->
+      <fileset dir="." includes="**/*.class"/> 
       <fileset dir="." includes="ndbj.jar"/>
+      <fileset dir="com/mysql/cluster/mgmapi" includes="*"/> 
+      <fileset dir="com/mysql/cluster/ndbj" includes="SWIG*" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="*Ref*" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="ndbj*" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="MYSQL_TIME.java" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="NdbColumn.java" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="NdbDictionary.java" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="NdbEvent.java" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="NdbIndex.java" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="NdbObject.java" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="NdbTable.java" />
+      <fileset dir="com/mysql/cluster/ndbj" includes="enum_mysql_timestamp_type.java"
/>
     </delete>
     <delete dir="javadoc" />
   </target>

Thread
Rev 154: Added clean rules to build.xml to clean things up. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmergeMonty Taylor14 Sep