|
Re: Re: using stdout/stderr with python: msg#00163programming.swig
On 2004.05.26 11:45, Martin F Krafft wrote: also sprach Luigi Ballabio <luigi.ballabio@xxxxxxxxxxxxx> I actually tried this time---it works for me. Here's my foo.i file: ------------------------------------------------------ %module Foo %include exception.i %{ #include <stdlib.h> %} %typemap(in) FILE* { if (PyFile_Check($input)) { $1 = PyFile_AsFile($input); } else { SWIG_exception(SWIG_TypeError, "file expected"); } } %inline %{ void test(FILE* out) { fprintf(out, "Hello World!\n"); } %} ------------------------------------------------------ and here's a transcript from my console: ballabl:~$ swig -python foo.i ballabl:~$ gcc -shared -I/usr/include/python2.3/ -o _Foo.so foo_wrap.c ballabl:~$ python Python 2.3.4c1 (#2, May 13 2004, 21:46:36) [GCC 3.3.3 (Debian 20040429)] on linux2 Type "help", "copyright", "credits" or "license" for more information. Hello World!import Foo ballabl:~$ cat foo.txtf = open('foo.txt','w') Hello World! ballabl:~$ you might want to start working from here to get the desired behavior for your functions. Hope this helps, Luigi _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: SWIG and autotools - some solutions (corrected further): 00163, Martin F Krafft |
|---|---|
| Next by Date: | bug while wrapping const char arrays without an explicitly defined size: 00163, Oren Miller |
| Previous by Thread: | Re: Re: using stdout/stderr with pythoni: 00163, Martin F Krafft |
| Next by Thread: | [solved] using stdout/stderr with python: 00163, Martin F Krafft |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |