new test to test windows calling conventions with extern functions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7320 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
45df1dfa20
commit
c838d83d2c
3 changed files with 49 additions and 0 deletions
|
|
@ -317,6 +317,7 @@ C_TEST_CASES += \
|
||||||
char_constant \
|
char_constant \
|
||||||
const_const \
|
const_const \
|
||||||
enums \
|
enums \
|
||||||
|
extern_declaration \
|
||||||
function_typedef \
|
function_typedef \
|
||||||
inctest \
|
inctest \
|
||||||
lextype \
|
lextype \
|
||||||
|
|
|
||||||
27
Examples/test-suite/extern_declaration.i
Normal file
27
Examples/test-suite/extern_declaration.i
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
%module extern_declaration
|
||||||
|
|
||||||
|
// Test different calling conventions on Windows. Old versions of SWIG generated
|
||||||
|
// an incorrect extern declarations that wouldn't compile with Windows compilers.
|
||||||
|
#define SWIGEXPORT
|
||||||
|
#define SWIGSTDCALL
|
||||||
|
#define DLLIMPORT
|
||||||
|
|
||||||
|
%{
|
||||||
|
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
|
# define DLLIMPORT __declspec(dllimport)
|
||||||
|
#else
|
||||||
|
# define DLLIMPORT
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
|
DLLIMPORT extern int externimport(int in);
|
||||||
|
SWIGEXPORT extern int externexport(int);
|
||||||
|
extern int SWIGSTDCALL externstdcall(int);
|
||||||
|
|
||||||
|
%{
|
||||||
|
SWIGEXPORT extern int externimport(int in) { return in; }
|
||||||
|
SWIGEXPORT extern int externexport(int in) { return in; }
|
||||||
|
extern int SWIGSTDCALL externstdcall(int in) { return in; }
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
21
Examples/test-suite/java/extern_declaration_runme.java
Normal file
21
Examples/test-suite/java/extern_declaration_runme.java
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
import extern_declaration.*;
|
||||||
|
|
||||||
|
public class extern_declaration_runme {
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("extern_declaration");
|
||||||
|
} catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String argv[])
|
||||||
|
{
|
||||||
|
if (extern_declaration.externimport(100) != 100) throw new RuntimeException("externimport failed");
|
||||||
|
if (extern_declaration.externexport(200) != 200) throw new RuntimeException("externexport failed");
|
||||||
|
if (extern_declaration.externstdcall(300) != 300) throw new RuntimeException("externstdcall failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue