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

Re: svn commit: rev 5608 - trunk/subversion/bindings/swig

From: Nicholas Riley <njriley_at_uiuc.edu>
Date: 2003-04-14 11:36:34 CEST

On Mon, Apr 14, 2003 at 12:25:47AM -0700, Greg Stein wrote:
> Yah, there is. Look at the code just below that, for svn_filesize_t.
> Basically, we'd just define the actual code to do the mappings.

That's what I originally wrote, prior to finding Mike's patch. Using
a predefined typemap with %apply is simpler, and produces functionally
equivalent results (the assignment from PyInt_FromLong is generated on
a separate line with the %apply version). I can't see a reason why
svn_filesize_t * shouldn't also use %apply long rather than an
explicit %typemap.

> In the %apply case, however, we get to use whatever was defined for the
> 'unsigned int' type (in this case). Whether that's the Python, Java, or
> whatever language's code.

There's no difference in the generated Python code for any of the
integer data types:

%typemap(out) int, unsigned int,
                      short, unsigned short,
                      long, unsigned long,
                      signed char, unsigned char,
                      bool, enum SWIGTYPE
       "$result = PyInt_FromLong((long)$1);";

There is a difference in other languages, for example the Java SWIG
bindings include:

%typemap(out) long %{ $result = (jint)$1; %}
%typemap(out) unsigned int %{ $result = (jlong)$1; %}
%typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %}

> A tradeoff. I just applied the thing to get it to work. Didn't put too much
> brainpower into it, since the enum and unsigned int types are compatible.
> I'd be totally fine if it gets expanded out to the "right" code.

I didn't know about the generic enum typemap (enum SWIGTYPE), but it
appears a better match than unsigned int. See section 8.3.3 of the
SWIG manual.

-- 
=Nicholas Riley <njriley_at_uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
        Pablo Research Group, Department of Computer Science and
  Medical Scholars Program, University of Illinois at Urbana-Champaign
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Apr 14 11:38:11 2003

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.