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"))
|
if (!preproc_line_file.MY_STRINGNUM_B.equals("my16"))
|
||||||
throw new RuntimeException("preproc failed MY_STRINGNUM_B");
|
throw new RuntimeException("preproc failed MY_STRINGNUM_B");
|
||||||
|
|
||||||
int myline2 = preproc_line_file.MYLINE2;
|
if (preproc_line_file.getThing27() != -1)
|
||||||
if (myline2 != 23)
|
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");
|
throw new RuntimeException("preproc failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
%module preproc_line_file
|
%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 __LINE__
|
||||||
#define MYLINE_ADJUSTED __LINE__ + 100
|
#define MYLINE_ADJUSTED __LINE__ + 100
|
||||||
|
|
||||||
|
|
@ -20,14 +20,23 @@
|
||||||
#define NUMBER(a,b) NUMBER_HELP(a,b)
|
#define NUMBER(a,b) NUMBER_HELP(a,b)
|
||||||
#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
|
#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__
|
#define MYLINE2 __LINE__
|
||||||
|
|
||||||
/*
|
%javaconst(1);
|
||||||
TODO: __LINE__ is wrong
|
%{
|
||||||
struct Struct {
|
struct SillyStruct {
|
||||||
static const int line_num = __LINE__;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*Swig_error(Getfile(str),Getline(str),"Illegal character in macro name\n");
|
|
||||||
goto macro_error; */
|
|
||||||
Ungetc(c, str);
|
Ungetc(c, str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1287,8 +1285,8 @@ String *Preprocessor_parse(String *s) {
|
||||||
case 0: /* Initial state - in first column */
|
case 0: /* Initial state - in first column */
|
||||||
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
|
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
|
||||||
if (c == '#') {
|
if (c == '#') {
|
||||||
add_chunk(ns, chunk, allow);
|
|
||||||
copy_location(s, chunk);
|
copy_location(s, chunk);
|
||||||
|
add_chunk(ns, chunk, allow);
|
||||||
cpp_lines = 1;
|
cpp_lines = 1;
|
||||||
state = 40;
|
state = 40;
|
||||||
} else if (isspace(c)) {
|
} else if (isspace(c)) {
|
||||||
|
|
@ -1682,8 +1680,8 @@ String *Preprocessor_parse(String *s) {
|
||||||
/* %{,%} block */
|
/* %{,%} block */
|
||||||
if (c == '{') {
|
if (c == '{') {
|
||||||
start_line = Getline(s);
|
start_line = Getline(s);
|
||||||
add_chunk(ns, chunk, allow);
|
|
||||||
copy_location(s, chunk);
|
copy_location(s, chunk);
|
||||||
|
add_chunk(ns, chunk, allow);
|
||||||
Putc('%', chunk);
|
Putc('%', chunk);
|
||||||
Putc(c, chunk);
|
Putc(c, chunk);
|
||||||
state = 105;
|
state = 105;
|
||||||
|
|
@ -1759,8 +1757,8 @@ String *Preprocessor_parse(String *s) {
|
||||||
s1 = cpp_include(fn, sysfile);
|
s1 = cpp_include(fn, sysfile);
|
||||||
if (s1) {
|
if (s1) {
|
||||||
char *dirname;
|
char *dirname;
|
||||||
add_chunk(ns, chunk, allow);
|
|
||||||
copy_location(s, chunk);
|
copy_location(s, chunk);
|
||||||
|
add_chunk(ns, chunk, allow);
|
||||||
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
|
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
|
||||||
if (Equal(decl, kpp_dimport)) {
|
if (Equal(decl, kpp_dimport)) {
|
||||||
push_imported();
|
push_imported();
|
||||||
|
|
@ -1793,8 +1791,8 @@ String *Preprocessor_parse(String *s) {
|
||||||
} else if (Equal(decl, kpp_ddefine)) {
|
} else if (Equal(decl, kpp_ddefine)) {
|
||||||
/* Got a define directive */
|
/* Got a define directive */
|
||||||
dlevel++;
|
dlevel++;
|
||||||
add_chunk(ns, chunk, allow);
|
|
||||||
copy_location(s, chunk);
|
copy_location(s, chunk);
|
||||||
|
add_chunk(ns, chunk, allow);
|
||||||
Clear(value);
|
Clear(value);
|
||||||
copy_location(s, value);
|
copy_location(s, value);
|
||||||
state = 150;
|
state = 150;
|
||||||
|
|
@ -1868,8 +1866,8 @@ String *Preprocessor_parse(String *s) {
|
||||||
if ((state >= 30) && (state < 40)) {
|
if ((state >= 30) && (state < 40)) {
|
||||||
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
|
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
|
||||||
}
|
}
|
||||||
add_chunk(ns, chunk, allow);
|
|
||||||
copy_location(s, chunk);
|
copy_location(s, chunk);
|
||||||
|
add_chunk(ns, chunk, allow);
|
||||||
|
|
||||||
/* DelScope(scp); */
|
/* DelScope(scp); */
|
||||||
Delete(decl);
|
Delete(decl);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue