On Monday, September 16, 2002, at 04:27 PM, cmpilato@collab.net wrote:
> Daniel, for reference, please check out your patch at:
> http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=21138
>
> Specifically, this section (which appears to be the real guts of the
> things):
>
> %typemap(arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
> SWIG_ConvertPtr(PyObject_GetItem(args, PyInt_FromLong($argnum)),
> (void
> **)&$1, SWIGTYPE_p_apr_pool_t, SWIG_POINTER_EXCEPTION | 0);
> _global_pool = $1;
> }
> %typemap (in) apr_pool_t *pool "";
>
> Now, I had all kinds of trouble trying to get that to compile. So I
> made some mods (which appear to be in accordance with SWIG docs):
>
> %typemap(arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
> if (SWIG_ConvertPtr(PyObject_GetItem(args,
> PyInt_FromLong($argnum)),
> (void **)&$1, $1_descriptor, 0) == -1) {
> return NULL;
> }
> _global_pool = $1;
> }
> %typemap(in) apr_pool_t *pool "";
>
This should work fine too.
> However, whenever I try to actually use the bindings, things SEGFAULT
> left and right. I managed to GDB one of those segfaults (by
> temporarily inserting a sleep() into the code above and attaching to
> the process), and it looks as though the pool at that context is just
> garbage (0xc in my case). Questions for you:
>
> - Did you actually test your patch?
>
Yes
> - What is the SWIG_POINTER_EXCEPTION flag? I can't find any doc or
> code references to it in SWIG 1.3.12.
It throws a python exception if the pointer conversion fails.
it's part of the swig python runtime.
>
> - You are using the $argnum magic variable to get the argument which
> is the apr_pool_t, yes?
No
> How does that hold up in the presence of
> other typemap directives that mod the argument list? For example,
> svn_repos_open() as a C function takes 3 args, but as a python
> binding takes only two (since the svn_repos_t ** is converted to a
> return value). Will $argnum still do what you expect in those
> cases?
It better.
This is what beazley suggested to me to do, and since he wrote SWIG, ...
:)
I should note i've only tried it with current SWIG CVS (1.3.15pre) ,
*not* with 1.3.12.
_global was brand new in 1.3.12.
>
> Love, an exhausted C-Mike.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Sep 16 22:42:14 2002