You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by David James <ja...@cs.toronto.edu> on 2007/07/14 19:05:41 UTC
Re: svn commit: r25741 - branches/ctypes-python-bindings/csvn
Hi Sage,
On 7/14/07, sage@tigris.org <sa...@tigris.org> wrote:
> + def set_progress_func(self, progress_func):
> + """Setup a callback for network progress information. This callback
> + should accept two apr_off_t objects, being the number of bytes sent
> + and the number of bytes to send.
> +
> + For details of apr_off_t objects, see the apr_off_t documentation."""
In the wrapper, why don't we just convert the apr_off_t objects into
regular Python numbers? We might need to add a bit of logic to handle
cross-platform compatibility, but I think it'd be worth it for the
ease of use.
Here's a cross-platform function for converting apr_off_t into an integer.
if hasattr(apr_off_t, "value"):
def value_of_apr_off_t(x):
return x.value
elif sizeof(apr_off_t) == sizeof(c_int64):
def value_of_apr_off_t(x):
return cast(pointer(x), POINTER(c_int64))[0]
else:
raise Exception("Can't figure out how to convert apr_off_t to an integer")
I believe that apr_off_t is either a "long" or an "off64_t" on all
platforms and versions of APR, so the above logic should be portable.
We can then call this function from within your
_progress_func_wrapper.
Cheers,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r25741 - branches/ctypes-python-bindings/csvn
Posted by David James <ja...@cs.toronto.edu>.
On 7/14/07, David James <ja...@cs.toronto.edu> wrote:
> Hi Sage,
>
> On 7/14/07, sage@tigris.org <sa...@tigris.org> wrote:
> > + def set_progress_func(self, progress_func):
> > + """Setup a callback for network progress information. This callback
> > + should accept two apr_off_t objects, being the number of bytes sent
> > + and the number of bytes to send.
> > +
> > + For details of apr_off_t objects, see the apr_off_t documentation."""
>
> In the wrapper, why don't we just convert the apr_off_t objects into
> regular Python numbers? We might need to add a bit of logic to handle
> cross-platform compatibility, but I think it'd be worth it for the
> ease of use.
>
> Here's a cross-platform function for converting apr_off_t into an integer.
> [... snip fancy function ...]
Actually, I've updated ctypesgen so that it marks apr_off_t as a
64-bit int, so that you don't need to do any fancy math to convert
between apr_off_t and Python integers. If you update to the latest
version of ctypesgen and rerun autogen.py, you'll be able to convert
an apr_off_t to a Python integer by simply accessing "progress.value"
and "total.value". We should do this in our wrapper function (i.e. in
_progress_func_wrapper) so that the library users won't have to.
Cheers,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org