[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

unable to commit to svn.collab.net repository

From: Daniel Rall <dlr_at_finemaltcoding.com>
Date: 2003-02-07 21:43:45 CET

dlr@despot:swig$ svn ci -F /tmp/msg
Sending swig/apr.i
Sending swig/svn_client.i
Sending swig/svn_string.i
Sending swig/svn_types.i
Sending swig/swigutil_java.c
Sending swig/swigutil_java.h
Sending swig/util.i
Transmitting file data .......subversion/libsvn_client/commit.c:647: (apr_err=165001)
svn: A repository hook failed.
svn: Commit failed (details follow):
subversion/libsvn_ra_dav/util.c:400: (apr_err=165001)
svn: MERGE request failed on /repos/svn/trunk/subversion/bindings/swig
subversion/libsvn_ra_dav/util.c:152: (apr_err=165001)
svn:
pre-commit hook failed with error output:
subversion/libsvn_subr/utf.c:168: (apr_err=22)
svn: Invalid argument
svn: failure during string recoding

dlr@despot:swig$ svn --version
svn, version 0.17.1 (dev build)
   compiled Feb 5 2003, 01:04:52

Copyright (C) 2000-2003 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/

The following repository access (RA) modules are available:

* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
  - handles 'http' schema
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' schema
* ra_svn : Module for accessing a repository using the svn network protocol.
  - handles 'svn' schema

Here's what I was trying to commit:

Work by Jesper Steen Møller <jesper@selskabet.org> towards usable
SWIG/Java bindings. He says that this gives us hash conversion and a
usable `svn st` command:

* subversion/bindings/swig/apr.i
* subversion/bindings/swig/svn_client.i
* subversion/bindings/swig/svn_string.i
* subversion/bindings/swig/svn_types.i
* subversion/bindings/swig/util.i
  Typemaps for Java and JNI.

* subversion/bindings/swig/swigutil_java.h
  (SWIG_NewPointerObj): Removed function. Jesper indicates its not
    necessary.

  (svn_swig_java_add_to_map): Adds all the elements from a hash to an
    existing java.util.Map

  (svn_swig_java_notify_func): A notify function that executes a Java
    method on an object which is passed in via the baton argument.

  (svn_swig_java_get_commit_log_func): Thunked commit log fetcher.

  (svn_swig_java_log_message_receiver): Log messages are returned in
    this.

* subversion/bindings/swig/swigutil_java.c
  (make_pointer): Now returns a java.lang.Long as a jobject.

  (make_ob_pool, make_ob_window): Removed functions.

  (convert_hash): converter_func argument now itself takes a JNIEnv *.

  (svn_swig_java_add_to_map): No longer static. Now takes a JNIEnv *.
    Implementation heavily modified.

  (convert_to_swigtype): Now implemented using make_pointer().

  (convert_svn_string_t): Now implemented using JNI's NewStringUTF().

  (svn_swig_java_prophash_to_dict): Now implemented using JNI's
    NewStringUTF().

  (svn_swig_java_array_to_list): Improved impl.

  (make_baton): Notes new global references to editor and baton.

  (svn_swig_java_notify_func, svn_swig_java_get_commit_log_func,
   svn_swig_java_log_message_receiver): New stub functions.

Index: svn_types.i
===================================================================
--- svn_types.i (revision 4787)
+++ svn_types.i (working copy)
@@ -28,7 +28,11 @@
          typemap will be applied onto a "real" type.
 */
 
-%typemap(in,numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
+%typemap(python, in, numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
+ $1 = ($1_ltype)&temp;
+}
+
+%typemap(java, in) SWIGTYPE **OUTPARAM ($*1_type temp) {
     $1 = ($1_ltype)&temp;
 }
 %typemap(python, argout, fragment="t_output_helper") SWIGTYPE **OUTPARAM {
@@ -60,7 +64,7 @@
    Specify how svn_error_t returns are turned into exceptions.
 */
 
-%typemap(python,out) svn_error_t * {
+%typemap(python, out) svn_error_t * {
     if ($1 != NULL) {
         if ($1->apr_err != SVN_ERR_SWIG_PY_EXCEPTION_SET)
             PyErr_SetString(PyExc_RuntimeError,
@@ -71,6 +75,19 @@
     $result = Py_None;
 }
 
+%typemap(java, out) svn_error_t * {
+ if ($1 != NULL) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1->message);
+ }
+}
+%typemap(jni) svn_error_t * "int"
+%typemap(jtype) svn_error_t * "int"
+%typemap(jstype) svn_error_t * "int"
+%typemap(javain) svn_error_t * "@javainput"
+%typemap(javaout) svn_error_t * {
+ $jnicall;
+}
+
 /* -----------------------------------------------------------------------
    'svn_renum_t *' will always be an OUTPUT parameter
 */
@@ -88,21 +105,23 @@
     $1 = PyString_AS_STRING($input);
     $2 = PyString_GET_SIZE($input);
 }
-%typemap(java, in) (const char *PTR, apr_size_t LEN) {
- /* FIXME: This is just a stub -- implement JNI code! */
-}
 
 /* -----------------------------------------------------------------------
    Define a generic arginit mapping for pools.
 */
 
-%typemap(arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
+%typemap(python, arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
     /* Assume that the pool here is the last argument in the list */
     SWIG_ConvertPtr(PyTuple_GET_ITEM(args, PyTuple_GET_SIZE(args) - 1),
                     (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION | 0);
     _global_pool = $1;
 }
-%typemap(in) apr_pool_t *pool "";
+
+%typemap(java, arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
+ /* ### HACK: Get the input variable based on naming convention */
+ _global_pool = (apr_pool_t *)j$1;
+ $1 = 0;
+}
 
 /* -----------------------------------------------------------------------
    Handle python thread locking.
Index: svn_string.i
===================================================================
--- svn_string.i (revision 4787)
+++ svn_string.i (working copy)
@@ -42,11 +42,13 @@
     }
     $result = t_output_helper($result, s);
 }
-%typemap(java,argout,fragment="t_output_helper") RET_STRING {
- /* FIXME: This is just a stub -- implement JNI code! */
- return NULL;
+%typemap(java,out) RET_STRING {
+ /* FIXME: This is just a stub -- implement JNI code for returning a string! */
+ $output = NULL;
 }
 
+%typemap(jni) char * "jstring"
+
 /* -----------------------------------------------------------------------
    TYPE: svn_stringbuf_t
 */
@@ -67,7 +69,7 @@
 }
 
 /* svn_stringbuf_t ** is always an output parameter */
-%typemap(in,numinputs=0) svn_stringbuf_t ** (svn_stringbuf_t *temp) {
+%typemap(python,in,numinputs=0) svn_stringbuf_t ** (svn_stringbuf_t *temp) {
     $1 = &temp;
 }
 %apply RET_STRING { svn_stringbuf_t ** };
@@ -142,8 +144,20 @@
     if ($1 == NULL)
         return NULL;
 }
-%typemap(java,in) const apr_array_header_t *STRINGLIST {
- /* FIXME: This is just a stub -- implement JNI code! */
+
+%typemap(jni) const apr_array_header_t *STRINGLIST "jobjectArray"
+%typemap(jtype) const apr_array_header_t *STRINGLIST "java.lang.String[]"
+%typemap(jstype) const apr_array_header_t *STRINGLIST "java.lang.String[]"
+%typemap(javain) const apr_array_header_t *STRINGLIST "$javainput"
+
+%typemap(java,in) const apr_array_header_t *STRINGLIST (apr_array_header_t *temp) {
+ temp = (apr_array_header_t *)svn_swig_java_strings_to_array(jenv, $input, _global_pool);
+ $1 = temp;
 }
 
+%typemap(java,freearg) const apr_array_header_t *STRINGLIST {
+ /* FIXME: Perhaps free up "temp"? */
+}
+
+
 /* ----------------------------------------------------------------------- */
Index: swigutil_java.c
===================================================================
--- swigutil_java.c (revision 4787)
+++ swigutil_java.c (working copy)
@@ -22,12 +22,14 @@
 #include <apr_pools.h>
 #include <apr_hash.h>
 
+
+#include "svn_client.h"
+
 #include "svn_string.h"
 #include "svn_delta.h"
 
 #include "swigutil_java.h"
 
-
 /* FIXME: Need java.swg for the JCALL macros. The following was taken
    from javahead.swg (which is included by java.swg). */
 #ifndef JCALL0
@@ -60,27 +62,19 @@
   JNIEnv *jenv; /* Java native interface structure */
 } handler_baton;
 
-
-static jobject make_pointer(const char *typename, void *ptr)
-{
- /* ### cache the swig_type_info at some point? */
- return SWIG_NewPointerObj(ptr, SWIG_TypeQuery(typename), 0);
-}
-
-/* for use by the "O&" format specifier */
-static jobject make_ob_pool(void *ptr)
-{
- return make_pointer("apr_pool_t *", ptr);
-}
-
-/* for use by the "O&" format specifier */
-static jobject make_ob_window(void *ptr)
+static jobject make_pointer(JNIEnv* env, void *ptr)
 {
- return make_pointer("svn_txdelta_window_t *", ptr);
+ /* Return a Long object contining the C pointer to the object
+ (SWIG/Java knows nothing of SWIG_NewPointerObj) */
+ jclass cls = JCALL1(FindClass, env, "java/lang/Long");
+ return JCALL3(NewObject, env, cls,
+ JCALL3(GetMethodID, env, cls, "<init>", "(J)V"),
+ (jlong) ptr);
 }
 
-static jobject convert_hash(JNIEnv *jenv, apr_hash_t *hash,
- jobject (*converter_func)(void *value,
+static jobject convert_hash(JNIEnv* jenv, apr_hash_t *hash,
+ jobject (*converter_func)(JNIEnv* env,
+ void *value,
                                                        void *ctx),
                             void *ctx)
 {
@@ -103,33 +97,58 @@
       jobject value;
 
       apr_hash_this(hi, &key, NULL, &val);
- value = (*converter_func)(val, ctx);
+ value = (*converter_func)(jenv, val, ctx);
       JCALL4(CallObjectMethod, jenv, dict, put,
- JCALL2(NewString, jenv, key, strlen(key)), value);
+ JCALL1(NewStringUTF, jenv, key), value);
       JCALL1(DeleteLocalRef, jenv, value);
     }
 
   return dict;
 }
 
-static jobject convert_to_swigtype(void *value, void *ctx)
+void svn_swig_java_add_to_map(JNIEnv* jenv, apr_hash_t *hash, jobject map)
 {
- /* ctx is a 'swig_type_info *' */
- return SWIG_NewPointerObj(value, ctx, 0);
+ apr_hash_index_t *hi;
+ jclass cls = JCALL1(FindClass, jenv, "java/util/Map");
+ jmethodID put = JCALL3(GetMethodID, jenv, cls, "put",
+ "(Ljava/lang/Object;Ljava/lang/Object;)"
+ "Ljava/lang/Object;");
+
+ for (hi = apr_hash_first(NULL, hash); hi; hi = apr_hash_next(hi))
+ {
+ const void *key;
+ void *val;
+ jobject keyname, value, oldvalue;
+
+ apr_hash_this(hi, &key, NULL, &val);
+ keyname = JCALL1(NewStringUTF, jenv, key);
+ value = make_pointer(jenv, val);
+
+ oldvalue = JCALL4(CallObjectMethod, jenv, map, put, keyname, value);
+
+ JCALL1(DeleteLocalRef, jenv, value);
+ JCALL1(DeleteLocalRef, jenv, oldvalue);
+ JCALL1(DeleteLocalRef, jenv, keyname);
+
+ if (JCALL0(ExceptionOccurred, jenv))
+ return;
+ }
 }
 
-static jobject convert_svn_string_t(void *value, void *ctx)
+static jobject convert_to_swigtype(JNIEnv* jenv, void *value, void *ctx)
 {
- JNIEnv *jenv = (JNIEnv *) ctx;
- const svn_string_t *s = value;
+ /* ctx is a 'swig_type_info *', but this is lost entirely */
+ return make_pointer(jenv, value);
+}
 
- /* ### borrowing from value in the pool. or should we copy? note
- ### that copying is "safest" */
+static jobject convert_svn_string_t(JNIEnv* jenv, void *value, void *ctx)
+{
+ const svn_string_t *s = value;
 
- return JCALL2(NewString, jenv, (const jchar *) s->data, s->len);
+ /* This will copy the data */
+ return JCALL1(NewStringUTF, jenv, s->data);
 }
 
-
 jobject svn_swig_java_prophash_to_dict(JNIEnv *jenv, apr_hash_t *hash)
 {
   return convert_hash(jenv, hash, convert_svn_string_t, jenv);
@@ -151,7 +170,7 @@
   jobject obj;
   while ((s = *strings++) != NULL)
     {
- obj = JCALL2(NewString, jenv, (const jchar *) s, strlen(s));
+ obj = JCALL1(NewStringUTF, jenv, s);
 
       if (obj == NULL)
           goto error;
@@ -168,7 +187,8 @@
   return NULL;
 }
 
-jobject svn_swig_java_array_to_list(JNIEnv *jenv, const apr_array_header_t *strings)
+jobject svn_swig_java_array_to_list(JNIEnv *jenv,
+ const apr_array_header_t *strings)
 {
   jclass cls = JCALL1(FindClass, jenv, "java/util/ArrayList");
   jobject list = JCALL3(NewObject, jenv, cls,
@@ -177,17 +197,19 @@
   int i;
   jobject obj;
 
+ jmethodID add;
+ if (strings->nelts > 0)
+ add = JCALL3(GetMethodID, jenv, cls, "add", "(i, Ljava/lang/Object;)Z");
+
   for (i = 0; i < strings->nelts; ++i)
     {
- jmethodID add;
       const char *s;
 
       s = APR_ARRAY_IDX(strings, i, const char *);
- obj = JCALL2(NewString, jenv, (const jchar *) s, strlen(s));
+ obj = JCALL1(NewStringUTF, jenv, s);
       if (obj == NULL)
         goto error;
       /* ### HELP: The format specifier might be 'I' instead of 'i' */
- add = JCALL3(GetMethodID, jenv, cls, "add", "(i, Ljava/lang/Object;)Z");
       JCALL4(CallObjectMethod, jenv, list, add, i, obj);
       JCALL1(DeleteLocalRef, jenv, obj);
     }
@@ -225,6 +247,7 @@
   while (targlen--)
     {
       jobject o = JCALL3(CallObjectMethod, jenv, source, get, targlen);
+ const char * c_string;
       if (o == NULL)
           return NULL;
       else if (!JCALL2(IsInstanceOf, jenv, o,
@@ -236,15 +259,15 @@
               return NULL;
             }
         }
-
- APR_ARRAY_IDX(temp, targlen, const char *) =
- (char *) JCALL2(GetStringChars, jenv, o, FALSE);
+ c_string = (*jenv)->GetStringUTFChars(jenv, o, 0);
+ APR_ARRAY_IDX(temp, targlen, const char *) = apr_pstrdup(pool, c_string);
+ (*jenv)->ReleaseStringUTFChars(jenv, o, c_string);
       JCALL1(DeleteLocalRef, jenv, o);
+
     }
   return temp;
 }
 
-
 static svn_error_t * convert_java_error(JNIEnv *jenv, apr_pool_t *pool)
 {
     /* ### need to fetch the Java error and map it to an svn_error_t
@@ -260,6 +283,10 @@
 {
   item_baton *newb = apr_palloc(pool, sizeof(*newb));
 
+ /* one more reference to the editor. */
+ JCALL1(NewGlobalRef, jenv, editor);
+ JCALL1(NewGlobalRef, jenv, baton);
+
   /* note: we take the caller's reference to 'baton' */
 
   newb->editor = JCALL1(NewGlobalRef, jenv, editor);
@@ -281,6 +308,7 @@
   /* If there is no baton object, then it is an edit_baton, and we should
      not bother to pass an object. Note that we still shove a NULL onto
      the stack, but the format specified just won't reference it. */
+
   if (ib->baton)
     {
       methodID = JCALL3(GetMethodID, jenv, cls, method,
@@ -662,3 +690,42 @@
   *editor = thunk_editor;
   *edit_baton = make_baton(jenv, pool, java_editor, NULL);
 }
+
+/* a notify function that executes a Java method on an object which is
+ passed in via the baton argument */
+void svn_swig_java_notify_func(void *baton,
+ const char *path,
+ svn_wc_notify_action_t action,
+ svn_node_kind_t kind,
+ const char *mime_type,
+ svn_wc_notify_state_t content_state,
+ svn_wc_notify_state_t prop_state,
+ svn_revnum_t revision)
+{
+ /* TODO: svn_swig_java_notify_func is not implemented yet */
+}
+
+/* thunked commit log fetcher */
+svn_error_t *svn_swig_java_get_commit_log_func (const char **log_msg,
+ const char **tmp_file,
+ apr_array_header_t *commit_items,
+ void *baton,
+ apr_pool_t *pool)
+{
+ return svn_error_create(APR_EGENERAL, NULL, "TODO: "
+ "svn_swig_java_get_commit_log_func is not "
+ "implemented yet");
+}
+
+/* log messages are returned in this */
+svn_error_t *svn_swig_java_log_message_receiver(void *baton,
+ apr_hash_t *changed_paths,
+ svn_revnum_t revision,
+ const char *author,
+ const char *date, /* use svn_time_from_string() if need apr_time_t */
+ const char *message,
+ apr_pool_t *pool)
+{
+ return svn_error_create(APR_EGENERAL, NULL, "TODO: svn_swig_java_get_commit_log_func is not implemented yet");
+}
+
Index: svn_client.i
===================================================================
--- svn_client.i (revision 4787)
+++ svn_client.i (working copy)
@@ -54,7 +54,7 @@
    handle the return value for svn_client_proplist()
 */
 
-%typemap(in,numinputs=0) apr_array_header_t ** (apr_array_header_t *temp) {
+%typemap(python,in,numinputs=0) apr_array_header_t ** (apr_array_header_t *temp) {
     $1 = &temp;
 }
 %typemap(python,argout,fragment="t_output_helper") apr_array_header_t ** {
@@ -85,12 +85,6 @@
     }
     $result = t_output_helper($result, list);
 }
-%typemap(java,argout) apr_hash_t **statushash {
- /* FIXME: Use JNI equiv of Java type SWIGTYPE_p_svn_wc_status_t */
- $result = t_output_helper(
- $result,
- svn_swig_java_convert_hash(*$1, SWIGTYPE_p_svn_wc_status_t));
-}
 
 /* -----------------------------------------------------------------------
    handle svn_wc_notify_func_t/baton pairs
@@ -102,6 +96,20 @@
   $2 = $input; /* our function is the baton. */
 }
 
+%typemap(java,in) (svn_wc_notify_func_t notify_func, void *notify_baton) {
+
+ $1 = svn_swig_java_notify_func;
+ $2 = (void*)$input; /* our function is the baton. */
+}
+
+%typemap(jni) svn_wc_notify_func_t "jobject"
+%typemap(jtype) svn_wc_notify_func_t "org.tigris.subversion.Notifier"
+%typemap(jstype) svn_wc_notify_func_t "org.tigris.subversion.Notifier"
+%typemap(javain) svn_wc_notify_func_t "$javainput"
+%typemap(javaout) svn_wc_notify_func_t {
+ return $jnicall;
+ }
+
 /* -----------------------------------------------------------------------
    handle svn_client_get_commit_log_t/baton pairs
 */
@@ -113,10 +121,45 @@
   $2 = $input; /* our function is the baton. */
 }
 
+%typemap(java,in) (svn_client_get_commit_log_t log_msg_func,
+ void *log_msg_baton) {
+
+ $1 = svn_swig_java_get_commit_log_func;
+ $2 = (void*)$input; /* our function is the baton. */
+}
+
+%typemap(jni) svn_client_get_commit_log_t "jobject"
+%typemap(jtype) svn_client_get_commit_log_t "org.tigris.subversion.client.ClientPrompt"
+%typemap(jstype) svn_client_get_commit_log_t "org.tigris.subversion.client.ClientPrompt"
+%typemap(javain) svn_client_get_commit_log_t "$javainput"
+%typemap(javaout) svn_client_get_commit_log_t {
+ return $jnicall;
+ }
+
+
+/* -----------------------------------------------------------------------
+ handle svn_client_get_commit_log_t/baton pairs
+*/
+
+%typemap(java,in) (svn_log_message_receiver_t receiver,
+ void *receiver_baton) {
+
+ $1 = svn_swig_java_log_message_receiver;
+ $2 = (void*)$input; /* our function is the baton. */
+}
+
+%typemap(jni) svn_log_message_receiver_t "jobject"
+%typemap(jtype) svn_log_message_receiver_t "org.tigris.subversion.client.LogMessageReceiver"
+%typemap(jstype) svn_log_message_receiver_t "org.tigris.subversion.client.LogMessageReceiver"
+%typemap(javain) svn_log_message_receiver_t "$javainput"
+%typemap(javaout) svn_log_message_receiver_t {
+ return $jnicall;
+ }
+
 /* -----------------------------------------------------------------------
    handle the "statushash" OUTPUT param for svn_client_status()
 */
-%typemap(in,numinputs=0) apr_hash_t **statushash = apr_hash_t **OUTPUT;
+%typemap(python,in,numinputs=0) apr_hash_t **statushash = apr_hash_t **OUTPUT;
 %typemap(python,argout,fragment="t_output_helper") apr_hash_t **statushash {
     $result = t_output_helper(
         $result,
@@ -127,7 +170,7 @@
    fix up the return hash for svn_client_ls()
 */
 
-%typemap(in,numinputs=0) apr_hash_t **dirents = apr_hash_t **OUTPUT;
+%typemap(python,in,numinputs=0) apr_hash_t **dirents = apr_hash_t **OUTPUT;
 %typemap(python,argout,fragment="t_output_helper") apr_hash_t **dirents {
         $result = t_output_helper(
                 $result,
@@ -135,6 +178,18 @@
 }
 
 /* -----------------------------------------------------------------------
+ handle the prompt_baton
+*/
+
+%typemap(jni) svn_log_message_receiver_t "jobject"
+%typemap(jtype) svn_log_message_receiver_t "org.tigris.subversion.swig.callbacks.LogMessageReceiver"
+%typemap(jstype) svn_log_message_receiver_t "org.tigris.subversion.swig.callbacks.LogMessageReceiver"
+%typemap(javain) svn_log_message_receiver_t "$javainput"
+%typemap(javaout) svn_log_message_receiver_t {
+ return $jnicall;
+ }
+
+/* -----------------------------------------------------------------------
    We use 'svn_wc_status_t *' in some custom code, but it isn't in the
    API anywhere. Thus, SWIG doesn't generate a typemap entry for it. by
    adding a simple declaration here, SWIG will insert a name for it.
Index: swigutil_java.h
===================================================================
--- swigutil_java.h (revision 4787)
+++ swigutil_java.h (working copy)
@@ -31,6 +31,7 @@
 #include "svn_types.h"
 #include "svn_string.h"
 #include "svn_delta.h"
+#include "svn_wc.h"
 
 
 #ifdef __cplusplus
@@ -50,7 +51,6 @@
 #ifdef SVN_NEED_SWIG_TYPES
 
 typedef struct _unnamed swig_type_info;
-jobject SWIG_NewPointerObj(void *, swig_type_info *, int own);
 swig_type_info *SWIG_TypeQuery(const char *name);
 
 #endif /* SVN_NEED_SWIG_TYPES */
@@ -64,6 +64,9 @@
 jobject svn_swig_java_convert_hash(JNIEnv *jenv, apr_hash_t *hash,
                                    swig_type_info *type);
 
+/* add all the elements from a hash to an existing java.util.Map */
+void svn_swig_java_add_to_map(JNIEnv* jenv, apr_hash_t *hash, jobject map);
+
 /* helper function to convert a 'char **' into a Java List of String
    objects */
 jobject svn_swig_java_c_strings_to_list(JNIEnv *jenv, char **strings);
@@ -89,6 +92,34 @@
                                jobject java_editor,
                                apr_pool_t *pool);
 
+/* a notify function that executes a Java method on an object which is
+ passed in via the baton argument */
+void svn_swig_java_notify_func(void *baton,
+ const char *path,
+ svn_wc_notify_action_t action,
+ svn_node_kind_t kind,
+ const char *mime_type,
+ svn_wc_notify_state_t content_state,
+ svn_wc_notify_state_t prop_state,
+ svn_revnum_t revision);
+
+/* thunked commit log fetcher */
+svn_error_t *svn_swig_java_get_commit_log_func(const char **log_msg,
+ const char **tmp_file,
+ apr_array_header_t *commit_items,
+ void *baton,
+ apr_pool_t *pool);
+
+/* log messages are returned in this */
+svn_error_t *svn_swig_java_log_message_receiver(void *baton,
+ apr_hash_t *changed_paths,
+ svn_revnum_t revision,
+ const char *author,
+ const char *date, /* use svn_time_from_string() if need apr_time_t */
+ const char *message,
+ apr_pool_t *pool);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: util.i
===================================================================
--- util.i (revision 4787)
+++ util.i (working copy)
@@ -20,6 +20,13 @@
 
 %include typemaps.i
 
+/* This is default in SWIG 1.3.17 and is a really good idea */
+%typemap(javagetcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+ protected static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
 %{
 #include "svn_opt.h"
 %}
@@ -203,4 +210,5 @@
 #ifdef SWIGJAVA
 #include "swigutil_java.h"
 #endif
+
 %}
Index: apr.i
===================================================================
--- apr.i (revision 4787)
+++ apr.i (working copy)
@@ -25,21 +25,24 @@
 
 %include typemaps.i
 
+/* This is default in SWIG 1.3.17 and is a really good idea */
+%typemap(javagetcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+ protected static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
 
 /* ----------------------------------------------------------------------- */
 
 /* define an OUTPUT typemap for 'apr_off_t *'. for now, we'll treat it as
    a 'long' even if that isn't entirely correct... */
-%typemap(in,numinputs=0) apr_off_t * (apr_off_t temp)
+
+%typemap(python,in,numinputs=0) apr_off_t * (apr_off_t temp)
     "$1 = &temp;";
 
 %typemap(python,argout,fragment="t_output_helper") apr_off_t *
     "$result = t_output_helper($result,PyInt_FromLong((long) (*$1)));";
 
-%typemap(java,argout) apr_off_t * {
- /* ### FIXME */
-}
-
 /* ----------------------------------------------------------------------- */
 
 %include apr.h
@@ -68,17 +71,14 @@
 %apply long long { apr_time_t };
 
 /* 'apr_time_t *' will always be an OUTPUT parameter */
-%typemap(in,numinputs=0) apr_time_t * (apr_time_t temp)
+%typemap(java,in,numinputs=0) apr_time_t * (apr_time_t temp)
     "$1 = &temp;";
 
 %typemap(python,argout,fragment="t_output_helper") apr_time_t *
     "$result = t_output_helper($result, PyLong_FromLongLong(*$1));";
 
 %typemap(java,argout) apr_time_t * {
- jclass cls = JCALL1(FindClass, jenv, "java/lang/Long");
- jmethodID ctor = JCALL3(GetMethodID, jenv, cls, "<init>", "(J)V");
- jobject l = JCALL3(NewObject, jenv, cls, ctor, (jlong) *$1);
- $result = t_output_helper($result, JCALL1(NewGlobalRef, jenv, l));
+ /* FIXME: What goes here? */
 }
 
 /* -----------------------------------------------------------------------
@@ -93,8 +93,8 @@
 }
 %typemap(java,in) apr_size_t *INOUT (apr_size_t temp) {
     jclass cls = JCALL1(FindClass, jenv, "java/lang/Long");
- jmethodID mid = JCALL3(GetStaticMethodID, jenv, cls, "longValue", "()J");
- temp = (apr_size_t) JCALL2(CallStaticLongMethod, jenv, mid, $input);
+ jmethodID mid = JCALL3(GetMethodID, jenv, cls, "longValue", "()J");
+ temp = (apr_size_t) JCALL2(CallLongMethod, jenv, $input, mid);
     $1 = &temp;
 }
 
@@ -102,7 +102,7 @@
    create an OUTPUT argument typemap for an apr_hash_t **
 */
 
-%typemap(in,numinputs=0) apr_hash_t **OUTPUT (apr_hash_t *temp)
+%typemap(python,in,numinputs=0) apr_hash_t **OUTPUT (apr_hash_t *temp)
     "$1 = &temp;";
 
 /* -----------------------------------------------------------------------
@@ -110,17 +110,35 @@
    property values
 */
 
-%typemap(in,numinputs=0) apr_hash_t **PROPHASH = apr_hash_t **OUTPUT;
+%typemap(python,in,numinputs=0) apr_hash_t **PROPHASH = apr_hash_t **OUTPUT;
 %typemap(python,argout) apr_hash_t **PROPHASH {
     /* toss prior result, get new result from the hash */
     Py_DECREF($result);
     $result = svn_swig_py_prophash_to_dict(*$1);
 }
-%typemap(java,argout) apr_hash_t **PROPHASH {
- /* toss prior result, get new result from the hash */
- JCALL1(DeleteGlobalRef, jenv, $result);
- $result = JCALL1(NewGlobalRef, jenv,
- svn_swig_java_prophash_to_dict(jenv, *$1));
+
+/* -----------------------------------------------------------------------
+ Handle an apr_hash_t ** in Java
+*/
+
+%typemap(jni) apr_hash_t ** "jobject"
+%typemap(jtype) apr_hash_t ** "java.util.Map"
+%typemap(jstype) apr_hash_t ** "java.util.Map"
+%typemap(javain) apr_hash_t ** "$javainput"
+
+%typemap(javaout) apr_hash_t ** {
+ return $jnicall;
+ }
+
+%typemap(java,in) apr_hash_t **(apr_hash_t *temp){
+ $1 = &temp;
+}
+
+%typemap(java,out) apr_hash_t ** {
+ svn_swig_java_add_to_map(jenv, *$1, $input);
+}
+%typemap(java,argout) apr_hash_t ** {
+ svn_swig_java_add_to_map(jenv, *$1, $input);
 }
 
 /* -----------------------------------------------------------------------
@@ -142,11 +160,5 @@
     "$result = t_output_helper(
         $result,
         SWIG_NewPointerObj(*$1, $*1_descriptor, 0));";
-%typemap(java,argout,fragment="t_output_helper") apr_file_t **
- /* HELP: Is there a JNI equivalent of SWIG_NewPointerObj, or is
- this actually a cross-language typemap? */
- "$result = t_output_helper(
- $result,
- SWIG_NewPointerObj(*$1, $*1_descriptor, 0));";
 
 /* ----------------------------------------------------------------------- */

-- 
Daniel Rall <dlr@finemaltcoding.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Feb 7 21:44:26 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.