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

Re: Help typemapping wcprop_changes (partial patch)

From: David James <james_at_cs.toronto.edu>
Date: 2007-05-04 17:51:09 CEST

On 5/3/07, Eric Gillespie <epg@pretzelnet.org> wrote:
> 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:

Hi Eric,

You added your typemap to svn_wc.i, but it also applies to
svn_client.i, since svn_client.i includes svn_wc.i. But that's not the
real issue, as I've explained below.

When you write SWIG input typemaps, they don't just apply to the input
arguments of functions -- they also apply to attribute setters.
Unfortunately, attribute setters don't by default have any pool
available unless you do some work to get one.

There are two ways to fix this issue:
   1. Mark all of the attributes as immutable, so that your input
typemap won't apply to them.
   2. Teach your typemap to work with attribute setters. To do this,
you'll need to grab the pool from the object whose attributes you're
setting, so that your incoming attributes will have the same lifespan
as the owner object.

Solution #1 is easy -- just mark the affected wcprop_changes fields in
svn_client_commit_item2_t and svn_client_commit_item_t as immutable.

Solution #2 is a bit more complicated. Fortunately, I've already
written some helper functions which will do exactly what you need. The
svn_swig_py_get_parent_pool function grabs the parent pool of the
owner object. We already use it in the CALLABLE_CALLBACK typemap.

I've sketched out an (untested) fix for your typemap below:

#ifdef SWIGPYTHON
%typemap(in) apr_array_header_t *wcprop_changes
  (apr_pool_t *_global_pool = NULL, PyObject *_global_py_pool = NULL)
{
  if (_global_pool == NULL)
  {
    if (svn_swig_py_get_parent_pool(args, $descriptor(apr_pool_t *),
                                    &_global_py_pool, &_global_pool))
      SWIG_fail;
  }

  $1 = svn_swig_py_proparray_from_dict($input, _global_pool);
  if (PyErr_Occurred()) {
    SWIG_fail;
  }
}
#endif

Hope this helps,

David

P.S. On a related note, have you tried out the ctypes python bindings
yet? I highly recommend you give them a try -- they're much easier to
use and work on than the Python bindings, and I could use some help in
their development.

In the ctypes Python bindings, there's no need to write any typemaps,
because the low-level bindings are generated entirely automatically.
So you might have an easier time if you gave them a try.

The ctypes python bindings are hosted at:
   http://svn.collab.net/repos/svn/branches/ctypes-python-bindings/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri May 4 17:51:26 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.