Python typemap for FILE* (in behalf of Marcelo)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5929 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9edaaf5a7d
commit
95a6fa8edb
5 changed files with 92 additions and 0 deletions
28
SWIG/Examples/test-suite/file_test.i
Normal file
28
SWIG/Examples/test-suite/file_test.i
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
%module file_test
|
||||
|
||||
%include file.i
|
||||
|
||||
|
||||
%inline
|
||||
%{
|
||||
int nfile(FILE *file) {
|
||||
printf("hello %p\n", (void*)file);
|
||||
if (file) {
|
||||
// fprintf(file,"hello\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nfile(const char *filename) {
|
||||
FILE *file = fopen(filename,"w");
|
||||
nfile(file);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE* GetStdOut() {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
|
@ -14,6 +14,7 @@ CPP_TEST_CASES += \
|
|||
attributetest \
|
||||
complextest \
|
||||
director_stl \
|
||||
file_test \
|
||||
implicittest \
|
||||
inplaceadd \
|
||||
lib_std_vectora \
|
||||
|
|
|
|||
9
SWIG/Examples/test-suite/python/file_test_runme.py
Normal file
9
SWIG/Examples/test-suite/python/file_test_runme.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import sys
|
||||
import file_test
|
||||
|
||||
file_test.nfile(sys.stdout)
|
||||
|
||||
cstdout = file_test.GetStdOut()
|
||||
|
||||
file_test.nfile(cstdout)
|
||||
file_test.nfile("test.dat")
|
||||
Loading…
Add table
Add a link
Reference in a new issue