On 10/24/05, jerenkrantz@tigris.org <jerenkrantz@tigris.org> wrote:
> * r16920, r16923, r16950
> Define typemaps for APR datatypes in all SWIG bindings.
> Justification:
> Fixes check-swig-pl on 64 bit platforms.
> Fixes check-swig-rb.
> Depends: r16903
> Votes:
> +1: djames
> +1: kou (r16923 only)
> + +0: jerenkrantz (too hacky; need a more portable solution)
Thanks for your review, Justin! With my +1 and your +0, this change is approved.
Our current typemaps work on standard 32-bit and 64-bit platforms,
because char, short, and int normally have standard sizes. Subversion
developers, do you have any ideas how to implement the APR typemaps in
a more portable way? In future, I'm hoping to rewrite our SWIG
typemaps for APR datatypes to work without making assumptions about
type sizes.
Here's what we have now.
+%apply unsigned char { apr_byte_t }
+%apply short { apr_int16_t }
+%apply unsigned short { apr_uint16_t }
+%apply int { apr_int32_t }
+%apply unsigned int { apr_uint32_t }
+%apply unsigned long { apr_size_t }
+%apply signed long { apr_ssize_t }
+%apply long long { apr_int64_t }
+%apply unsigned long long { apr_uint64_t }
+
+%apply unsigned int *OUTPUT { apr_uint32_t * }
+%apply unsigned long *OUTPUT { apr_size_t * }
+
+/* We assume here that apr_off_t is no bigger than a 64-bit integer.
+ * In some cases, apr_off_t might be as big as 128-bits. In those cases,
+ * we'll simply truncate apr_off_t to a 64-bit integer.
+ */
+
+%typemap(perl5, in) apr_off_t {
+ $1 = (apr_off_t) strtoll(SvPV($input, PL_na), 0, 0);
+}
+
+%typemap(python, in) apr_off_t {
+ $1 = (apr_off_t) PyLong_AsLongLong($input);
+}
+
+%typemap(ruby, in) apr_off_t {
+ $1 = (apr_off_t) NUM2LL($input);
+}
--
David James -- http://www.cs.toronto.edu/~james
Received on Mon Oct 24 18:01:16 2005