You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Dale Hirt <da...@sbcltd.com> on 2003/02/13 22:12:17 UTC

Python SWIG for Win32

Hello all,

I have been hacking on the Python bindings, and it's been a bit of a beyatch
to say the least.  However, I am starting to get there.  I am simply stuck
on one portion of it. 

Here's the error message:

swigging d:\work\svn_work\subversion\bindings\swig/svn_repos.i to
build\svn_repos.c
svn_repos.c
build\svn_repos.c(1677) : error C2632: 'long' followed by 'long' is illegal
D:\Programs\SWIG-1.3.17\swig.exe -c -python -noproxy
-Id:\work\svn_work\subversion\bindings\swig
-Id:\work\subversion\subversion\include -IC:\Apache\Apache2\include
-ID:\Programs\ActiveState\Python\2.2.2b224\include -o build\svn_repos.c
d:\work\svn_work\subversion\bindings\swig/svn_repos.i
C:\Program Files\Microsoft Visual Studio\VC98\BIN\cl.exe /c /nologo /Ox /MD
/W3 /GX -Id:\work\svn_work\subversion\bindings\swig
-Id:\work\subversion\subversion\include -IC:\Apache\Apache2\include
-ID:\Programs\ActiveState\Python\2.2.2b224\include /Tcbuild\svn_repos.c
/Fobuild\temp.win32-2.2\Release\svn_repos.obj /D APR_STATIC /D WIN32 /D
APU_STATIC /D __WIN32__
error: command '"C:\Program Files\Microsoft Visual Studio\VC98\BIN\cl.exe"'
failed with exit status 2

I tracked it down to these lines in svn_repos.c:

static PyObject *_wrap_svn_repos_dated_revision(PyObject *self, PyObject
*args) {
...
    apr_time_t arg3 ;
....
->   arg3 = (long long) PyLong_AsLongLong(obj1);
...
}

So then I tracked it down to these lines in apr.i:

/* -----------------------------------------------------------------------
   handle the mappings for apr_time_t

   Note: we don't generalize this to 'long long' since SWIG is starting
   to handle that.
*/

%apply long long { apr_time_t };

/* 'apr_time_t *' will always be an OUTPUT parameter */
%typemap(in,numinputs=0) apr_time_t * (apr_time_t temp)
    "$1 = &temp;";

%typemap(python,argout,fragment="t_output_helper") apr_time_t *
    "$result = t_output_helper($result, PyLong_FromLongLong(*$1));";


Since I am now in virgin territory wrt SWIG typemaps and apply's, can
someone help me make sense of all this.  I have tried reading the swig
documentation, but it's almost as confusing as just reading the source code.

TIA,

Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Python SWIG for Win32

Posted by Branko Čibej <br...@xbc.nu>.
Dale Hirt wrote:

>Hello all,
>
>I have been hacking on the Python bindings, and it's been a bit of a beyatch
>to say the least.  However, I am starting to get there.  I am simply stuck
>on one portion of it. 
>
>Here's the error message:
>
>swigging d:\work\svn_work\subversion\bindings\swig/svn_repos.i to
>build\svn_repos.c
>svn_repos.c
>build\svn_repos.c(1677) : error C2632: 'long' followed by 'long' is illegal
>D:\Programs\SWIG-1.3.17\swig.exe -c -python -noproxy
>-Id:\work\svn_work\subversion\bindings\swig
>-Id:\work\subversion\subversion\include -IC:\Apache\Apache2\include
>-ID:\Programs\ActiveState\Python\2.2.2b224\include -o build\svn_repos.c
>d:\work\svn_work\subversion\bindings\swig/svn_repos.i
>C:\Program Files\Microsoft Visual Studio\VC98\BIN\cl.exe /c /nologo /Ox /MD
>/W3 /GX -Id:\work\svn_work\subversion\bindings\swig
>-Id:\work\subversion\subversion\include -IC:\Apache\Apache2\include
>-ID:\Programs\ActiveState\Python\2.2.2b224\include /Tcbuild\svn_repos.c
>/Fobuild\temp.win32-2.2\Release\svn_repos.obj /D APR_STATIC /D WIN32 /D
>APU_STATIC /D __WIN32__
>error: command '"C:\Program Files\Microsoft Visual Studio\VC98\BIN\cl.exe"'
>failed with exit status 2
>
>I tracked it down to these lines in svn_repos.c:
>
>static PyObject *_wrap_svn_repos_dated_revision(PyObject *self, PyObject
>*args) {
>...
>    apr_time_t arg3 ;
>....
>->   arg3 = (long long) PyLong_AsLongLong(obj1);
>
Oh blast, this is wrong...

>...
>}
>
>So then I tracked it down to these lines in apr.i:
>
>/* -----------------------------------------------------------------------
>   handle the mappings for apr_time_t
>
>   Note: we don't generalize this to 'long long' since SWIG is starting
>   to handle that.
>*/
>
>%apply long long { apr_time_t };
>
And so is this. Nuts, nuts, nuts. Nobody shoudl use "long long" directly
-- instead, we should use

    LONG_LONG

as that's always guaranteed to be 64 bits, while "long long" could
easily be 128 bits on some architectures (not to mention that it's not
portable to non-C99 compilers).


-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Python SWIG for Win32

Posted by Axel Kollmorgen <ax...@kollmorgen.net>.
On Friday, February 21, 2003 7:41 PM [GMT+1=CET],
Axel Kollmorgen <ax...@kollmorgen.net> wrote:

> On Thursday, February 13, 2003 11:12 PM [GMT+1=CET],
> Dale Hirt <da...@sbcltd.com> wrote:
>
>> swigging d:\work\svn_work\subversion\bindings\swig/svn_repos.i to
>> build\svn_repos.c svn_repos.c build\svn_repos.c(1677) :
>> error C2632: 'long' followed by 'long' is illegal
>> [...]
>
> i googled for "'long' followed by 'long' is illegal" and found this
>
(http://www.modpython.org/pipermail/mod_python/2003-January/002796.html)
>>
>
> Microsoft C compiler doesn't support "long long", this has been fixed
> in the latest CVS code. [Replace long long with LONG_LONG], and it
> will work OK.
>
>
> note: LONG_LONG is defined in <python>\include\pyconfig.h.
>
> so you should get this to work by replacing all "long long"s in
> <swig>\Lib\python\python.swg by LONG_LONG. i didn't have time to try
> yet (i build it earlier by just replacing all "long long" in
> python.swg by just "long") and would welcome feedback.

tried and working ;)

-- 
ax

People talk peace. But men give their lifes work to war. It wont stop
til there is as much brains and scientific study put to aid peace as
there is to promote war. - Will Rogers


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Python SWIG for Win32

Posted by Axel Kollmorgen <ax...@kollmorgen.net>.
On Thursday, February 13, 2003 11:12 PM [GMT+1=CET],
Dale Hirt <da...@sbcltd.com> wrote:

> swigging d:\work\svn_work\subversion\bindings\swig/svn_repos.i to
> build\svn_repos.c svn_repos.c build\svn_repos.c(1677) :
> error C2632: 'long' followed by 'long' is illegal
> [...]

i googled for "'long' followed by 'long' is illegal" and found this
(http://www.modpython.org/pipermail/mod_python/2003-January/002796.html)
:

Microsoft C compiler doesn't support "long long", this has been fixed in
the latest CVS code. [Replace long long with LONG_LONG], and it will
work OK.


note: LONG_LONG is defined in <python>\include\pyconfig.h.

so you should get this to work by replacing all "long long"s in
<swig>\Lib\python\python.swg by LONG_LONG. i didn't have time to try yet
(i build it earlier by just replacing all "long long" in python.swg by
just "long") and would welcome feedback.

-- 
ax

An optimist is a person who sees a green light everywhere. The
pessimist sees only the red light. But the truly wise person is color
blind. - albert schweitzer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org