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

Re: svn commit: r25741 - branches/ctypes-python-bindings/csvn

From: David James <james_at_cs.toronto.edu>
Date: 2007-07-14 21:05:41 CEST

Hi Sage,

On 7/14/07, sage@tigris.org <sage@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
Received on Sat Jul 14 21:05:18 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.