Fix some more instances of __LINE__ and __FILE__ numbering
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12194 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
13d18e4c3f
commit
5a6443ebcf
3 changed files with 33 additions and 18 deletions
|
|
@ -34,8 +34,16 @@ public class preproc_line_file_runme {
|
|||
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)
|
||||
if (preproc_line_file.getThing27() != -1)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (preproc_line_file.getThing28() != -2)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (preproc_line_file.MYLINE2 != 30)
|
||||
throw new RuntimeException("preproc failure");
|
||||
|
||||
if (SillyStruct.LINE_NUMBER != 41)
|
||||
throw new RuntimeException("preproc failure");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
%module preproc_line_file
|
||||
|
||||
// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying)
|
||||
// Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying)
|
||||
#define MYLINE __LINE__
|
||||
#define MYLINE_ADJUSTED __LINE__ + 100
|
||||
|
||||
|
|
@ -20,14 +20,23 @@
|
|||
#define NUMBER(a,b) NUMBER_HELP(a,b)
|
||||
#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
|
||||
|
||||
%{
|
||||
const int thing27 = -1;
|
||||
const int thing28 = -2;
|
||||
%}
|
||||
const int NUMBER_UNIQUE(thing) = -1; /* resolves to thing27 */
|
||||
const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */
|
||||
|
||||
#define MYLINE2 __LINE__
|
||||
|
||||
/*
|
||||
TODO: __LINE__ is wrong
|
||||
struct Struct {
|
||||
static const int line_num = __LINE__;
|
||||
%javaconst(1);
|
||||
%{
|
||||
struct SillyStruct {
|
||||
int num;
|
||||
/* static const int line_num = __LINE__; */
|
||||
};
|
||||
%}
|
||||
struct SillyStruct {
|
||||
int num;
|
||||
static const int LINE_NUMBER = __LINE__; /* This is a C test case, but we can still use a C++ feature to wrap a constant to test __LINE__ here */
|
||||
};
|
||||
const int NUMBER_UNIQUE(thing) = 0;
|
||||
const int NUMBER_UNIQUE(thingamebob) = 0;
|
||||
#define MYLINE3 __LINE__
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -353,8 +353,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
/*Swig_error(Getfile(str),Getline(str),"Illegal character in macro name\n");
|
||||
goto macro_error; */
|
||||
Ungetc(c, str);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1287,8 +1285,8 @@ String *Preprocessor_parse(String *s) {
|
|||
case 0: /* Initial state - in first column */
|
||||
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
|
||||
if (c == '#') {
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
cpp_lines = 1;
|
||||
state = 40;
|
||||
} else if (isspace(c)) {
|
||||
|
|
@ -1682,8 +1680,8 @@ String *Preprocessor_parse(String *s) {
|
|||
/* %{,%} block */
|
||||
if (c == '{') {
|
||||
start_line = Getline(s);
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Putc('%', chunk);
|
||||
Putc(c, chunk);
|
||||
state = 105;
|
||||
|
|
@ -1759,8 +1757,8 @@ String *Preprocessor_parse(String *s) {
|
|||
s1 = cpp_include(fn, sysfile);
|
||||
if (s1) {
|
||||
char *dirname;
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
|
||||
if (Equal(decl, kpp_dimport)) {
|
||||
push_imported();
|
||||
|
|
@ -1793,8 +1791,8 @@ String *Preprocessor_parse(String *s) {
|
|||
} else if (Equal(decl, kpp_ddefine)) {
|
||||
/* Got a define directive */
|
||||
dlevel++;
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Clear(value);
|
||||
copy_location(s, value);
|
||||
state = 150;
|
||||
|
|
@ -1868,8 +1866,8 @@ String *Preprocessor_parse(String *s) {
|
|||
if ((state >= 30) && (state < 40)) {
|
||||
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
|
||||
}
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
|
||||
/* DelScope(scp); */
|
||||
Delete(decl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue