Fix __LINE__ and __FILE__ expansion. Mostly this did not work at all.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12192 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8f8804b7a1
commit
69af82caa4
5 changed files with 116 additions and 13 deletions
|
|
@ -486,6 +486,7 @@ C_TEST_CASES += \
|
|||
overload_extendc \
|
||||
preproc \
|
||||
preproc_constants_c \
|
||||
preproc_line_file \
|
||||
ret_by_value \
|
||||
simple_array \
|
||||
sizeof_pointer \
|
||||
|
|
|
|||
41
Examples/test-suite/java/preproc_line_file_runme.java
Normal file
41
Examples/test-suite/java/preproc_line_file_runme.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import preproc_line_file.*;
|
||||
|
||||
public class preproc_line_file_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("preproc_line_file");
|
||||
} 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[]) throws Throwable
|
||||
{
|
||||
int myline = preproc_line_file.MYLINE;
|
||||
int myline_adjusted = preproc_line_file.MYLINE_ADJUSTED;
|
||||
if (myline != 4)
|
||||
throw new RuntimeException("preproc failure");
|
||||
if (myline + 100 + 1 != myline_adjusted)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
String myfile = preproc_line_file.MYFILE;
|
||||
String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED;
|
||||
if (!(myfile.equals("../../../../Examples/test-suite/preproc_line_file.i") || myfile.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i")))
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (!(myfile_adjusted.equals("../../../../Examples/test-suite/preproc_line_file.i.bak") || myfile_adjusted.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i.bak")))
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (!preproc_line_file.MY_STRINGNUM_A.equals("my15"))
|
||||
throw new RuntimeException("preproc failed MY_STRINGNUM_A");
|
||||
|
||||
if (!preproc_line_file.MY_STRINGNUM_B.equals("my16"))
|
||||
throw new RuntimeException("preproc failed MY_STRINGNUM_B");
|
||||
|
||||
int myline2 = preproc_line_file.MYLINE2;
|
||||
if (myline2 != 23)
|
||||
throw new RuntimeException("preproc failure");
|
||||
}
|
||||
}
|
||||
33
Examples/test-suite/preproc_line_file.i
Normal file
33
Examples/test-suite/preproc_line_file.i
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
%module preproc_line_file
|
||||
%javaconst(1);
|
||||
// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying)
|
||||
#define MYLINE __LINE__
|
||||
#define MYLINE_ADJUSTED __LINE__ + 100
|
||||
|
||||
#define MYFILE __FILE__
|
||||
#define MYFILE_ADJUSTED __FILE__ ".bak"
|
||||
|
||||
|
||||
#define STRINGNUM_HELP(a,b) #a#b
|
||||
#define STRINGNUM(a,b) STRINGNUM_HELP(a,b)
|
||||
#define STRINGNUM_UNIQUE(a) STRINGNUM(a,__LINE__)
|
||||
|
||||
#define MY_STRINGNUM_A STRINGNUM_UNIQUE(my)
|
||||
#define MY_STRINGNUM_B STRINGNUM_UNIQUE(my)
|
||||
|
||||
|
||||
#define NUMBER_HELP(a,b) a##b
|
||||
#define NUMBER(a,b) NUMBER_HELP(a,b)
|
||||
#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
|
||||
|
||||
#define MYLINE2 __LINE__
|
||||
|
||||
/*
|
||||
TODO: __LINE__ is wrong
|
||||
struct Struct {
|
||||
static const int line_num = __LINE__;
|
||||
};
|
||||
const int NUMBER_UNIQUE(thing) = 0;
|
||||
const int NUMBER_UNIQUE(thingamebob) = 0;
|
||||
#define MYLINE3 __LINE__
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue