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

Help typemapping wcprop_changes (partial patch)

From: Eric Gillespie <epg_at_pretzelnet.org>
Date: 2007-05-04 05:36:50 CEST

Below is a patch to typemap wcprop_changes for
svn_wc_process_committed* . Unfortunately--even though i put the
typemap in svn_wc.i--it causes a problem in svn_client.c:

subversion/bindings/swig/python/svn_client.c: In function '_wrap_svn_client_comm
it_item2_t_wcprop_changes_set':
subversion/bindings/swig/python/svn_client.c:3643: error: '_global_pool' undecla
red (first use in this function)
subversion/bindings/swig/python/svn_client.c:3643: error: (Each undeclared ident
ifier is reported only once
subversion/bindings/swig/python/svn_client.c:3643: error: for each function it a
ppears in.)
subversion/bindings/swig/python/svn_client.c: In function '_wrap_svn_client_comm
it_item_t_wcprop_changes_set':
subversion/bindings/swig/python/svn_client.c:4061: error: '_global_pool' undecla
red (first use in this function)

Indeed, those functions do not have _global_pool, though i don't
know why. I also don't know why svn_client.c is affected by my
patch at all. Just to get this working, i made this additional
change:

Index: subversion/bindings/swig/svn_client.i
===================================================================
--- subversion/bindings/swig/svn_client.i (revision 24930)
+++ subversion/bindings/swig/svn_client.i (working copy)
@@ -281,6 +281,11 @@
  * Prop change fields of svn_client_commit_item3_t need to be
  * converted between array data types. */
 
+#ifdef SWIGPYTHON
+%ignore svn_client_commit_item2_t;
+%ignore svn_client_commit_item_t;
+#endif
+
 #ifdef SWIGPERL
 %typemap(out) apr_array_header_t *incoming_prop_changes {
     if ($1) {

But of course that's not the right answer. Help?

[[[
Provide apr_array_header_t *wcprop_changes typemap, for
svn_wc_queue_committed and svn_wc_process_committed* .

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
  (svn_swig_py_proparray_from_dict): New function to convert a Python
    dictionary mapping strings to strings into an 'apr_array_header_t *' of
    svn_prop_t * .

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h
  (svn_swig_py_proparray_from_dict): Declare.

* subversion/bindings/swig/svn_wc.i
  (%typemap(in) apr_array_header_t *wcprop_changes): New typemap, using
    svn_swig_py_proparray_from_dict .
]]]

Index: subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
===================================================================
--- subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (revision 24930)
+++ subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (working copy)
@@ -37,6 +37,7 @@
 #include "svn_auth.h"
 #include "svn_pools.h"
 #include "svn_mergeinfo.h"
+#include "svn_types.h"
 
 #include "svn_private_config.h" /* for SVN_APR_INT64_T_PYCFMT */
 
@@ -901,6 +902,45 @@
   return hash;
 }
 
+apr_array_header_t *svn_swig_py_proparray_from_dict(PyObject *dict,
+ apr_pool_t *pool)
+{
+ apr_array_header_t *array;
+ PyObject *keys;
+ int i, num_keys;
+
+ if (dict == Py_None)
+ return NULL;
+
+ if (!PyDict_Check(dict))
+ {
+ PyErr_SetString(PyExc_TypeError, "not a dictionary");
+ return NULL;
+ }
+
+ keys = PyDict_Keys(dict);
+ num_keys = PyList_Size(keys);
+ array = apr_array_make(pool, num_keys, sizeof(svn_prop_t *));
+ for (i = 0; i < num_keys; i++)
+ {
+ PyObject *key = PyList_GetItem(keys, i);
+ PyObject *value = PyDict_GetItem(dict, key);
+ svn_prop_t *prop = apr_palloc(pool, sizeof(*prop));
+ prop->name = make_string_from_ob(key, pool);
+ prop->value = make_svn_string_from_ob(value, pool);
+ if (! (prop->name && prop->value))
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "dictionary keys/values aren't strings");
+ Py_DECREF(keys);
+ return NULL;
+ }
+ APR_ARRAY_PUSH(array, svn_prop_t *) = prop;
+ }
+ Py_DECREF(keys);
+ return array;
+}
+
 apr_hash_t *svn_swig_py_prophash_from_dict(PyObject *dict,
                                            apr_pool_t *pool)
 {
Index: subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h
===================================================================
--- subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h (revision 24930)
+++ subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h (working copy)
@@ -202,6 +202,13 @@
                                              apr_pool_t *pool);
 
 /* helper function to convert a Python dictionary mapping strings to
+ strings into an 'apr_array_header_t *' of svn_prop_t *
+ allocated in POOL. */
+SVN_SWIG_SWIGUTIL_EXPORT
+apr_array_header_t *svn_swig_py_proparray_from_dict(PyObject *dict,
+ apr_pool_t *pool);
+
+/* helper function to convert a Python dictionary mapping strings to
    strings into an apr_hash_t mapping const char *'s to svn_string_t's,
    allocated in POOL. */
 SVN_SWIG_SWIGUTIL_EXPORT
Index: subversion/bindings/swig/svn_wc.i
===================================================================
--- subversion/bindings/swig/svn_wc.i (revision 24930)
+++ subversion/bindings/swig/svn_wc.i (working copy)
@@ -66,6 +66,22 @@
   apr_hash_t *new_props
 };
 
+/*
+ svn_wc_queue_committed()
+ svn_wc_process_committed4()
+ svn_wc_process_committed3()
+ svn_wc_process_committed2()
+ svn_wc_process_committed()
+*/
+#ifdef SWIGPYTHON
+%typemap(in) apr_array_header_t *wcprop_changes {
+ $1 = svn_swig_py_proparray_from_dict($input, _global_pool);
+ if (PyErr_Occurred()) {
+ SWIG_fail;
+ }
+}
+#endif
+
 /* svn_wc_match_ignore_list() */
 %apply const apr_array_header_t *STRINGLIST {
   apr_array_header_t *list

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 4 05:38:02 2007

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.