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

Re: [PROPOSAL] Safe Memory Management for the Python/SWIG bindings

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2005-07-20 23:14:22 CEST

David James wrote:
> On 7/19/05, David James <james82@gmail.com> wrote:
>
>>CHALLENGES
>>
>>In order for the above implementation to work, we will need to have a
>>Python proxy object for every C object that is accessible from Python.
>>Currently, SWIG only creates Python proxy objects if we provide it
>>with the details of the internals of the C struct.
>>
>>Currently, we do not provide SWIG with all the details of how the
>>internals of Subversion are implemented, so SWIG treats some
>>Subversion datastructures as opaque pointers.
>
> OK, I've identified the problem. So far, so good.
>
>
>>We can fix this problem by using the %include directive -- just
>>%include the internal .h or .c files which describe the structure.
>>If we do this, then SWIG will generate real Python objects for
>>our "opaque pointers" -- not just C Objects.
>
> I've looked into this issue further. There is an easier way to ask
> SWIG to setup proxy objects: just setup a dummy declaration, and tell
> SWIG which functions to call in order to create and destroy objects.
> Kouhei has demonstrated this technique inside core.i:
>
> /* Dummy declaration */
> struct apr_pool_t
> {
> };
>
> /* Leave memory administration to ruby's GC */
> %extend apr_pool_t
> {
> apr_pool_t(apr_pool_t *parent=NULL, apr_allocator_t *allocator=NULL) {
> /* Disable parent pool. */
> return svn_pool_create_ex(NULL, NULL);
> }
>
> ~apr_pool_t() {
> apr_pool_destroy(self);
> }
> };
>
>
> In order for my proposal to work, we will need to use Kouhei's
> technique to create Pythonic proxies for all of the SVN datatypes. If
> we define a single proxy for each object inside the SWIG interface
> file, SWIG will generate code in all three languages (Python, Perl,
> Ruby) automatically.

That seems reasonable to me, although as usual in this area, I have only
the bare minimum experience with SWIG and our language bindings.

-garrett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jul 20 23:19:55 2005

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.