List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:September 13 2007 9:41pm
Subject:Rev 147: Step 2 in big reorg. 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: 147
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Thu 2007-09-13 14:40:51 -0700
message:
  Step 2 in big reorg. 
removed:
  java/ndbapi.i                  ndbapi.i-20070130002924-gcvhapmvh0lu1pkd-3
modified:
  swig/NdbClusterConnection.i    ndb_cluster_connecti-20070228021421-qkr4cbpxymyqdrf3-6
=== removed file 'java/ndbapi.i'
--- a/java/ndbapi.i	2007-09-13 21:28:09 +0000
+++ b/java/ndbapi.i	1970-01-01 00:00:00 +0000
@@ -1,330 +0,0 @@
-// -*- 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);
-    }
-    ndbapi.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 'swig/NdbClusterConnection.i'
--- a/swig/NdbClusterConnection.i	2007-05-29 15:45:11 +0000
+++ b/swig/NdbClusterConnection.i	2007-09-13 21:40:51 +0000
@@ -18,6 +18,9 @@
 */
 
 %rename Ndb_cluster_connection NdbClusterConnection; 
+#if defined(SWIG_JAVA)
+  %rename Ndb_cluster_connection NdbClusterConnectionRef; 
+#if
 
 class Ndb_cluster_connection {
 

Thread
Rev 147: Step 2 in big reorg. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/ndbjmergeMonty Taylor13 Sep