~laney/ubuntu/quantal/swig2.0/guile-2.0

« back to all changes in this revision

Viewing changes to Examples/test-suite/preproc_line_file.i

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Landschoff
  • Date: 2010-12-19 18:25:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101219182559-8lh77o66bo890jwo
Tags: 2.0.1-1
* Merge new upstream release 2.0.1.
* Remove dependency on quilt and usage in debian/rules, the new source
  format will take care of that.
* Remove patch fix-cleaning.diff (applied upstream).
* Remove patch keep_docs.diff (applied upstream).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%module preproc_line_file
 
2
 
 
3
// Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying)
 
4
#define MYLINE __LINE__
 
5
#define MYLINE_ADJUSTED __LINE__ + 100 
 
6
 
 
7
#define MYFILE __FILE__
 
8
#define MYFILE_ADJUSTED __FILE__ ".bak"
 
9
 
 
10
 
 
11
#define STRINGNUM_HELP(a,b) #a#b
 
12
#define STRINGNUM(a,b) STRINGNUM_HELP(a,b)
 
13
#define STRINGNUM_UNIQUE(a) STRINGNUM(a,__LINE__)
 
14
 
 
15
#define MY_STRINGNUM_A STRINGNUM_UNIQUE(my)
 
16
#define MY_STRINGNUM_B STRINGNUM_UNIQUE(my)
 
17
 
 
18
 
 
19
#define NUMBER_HELP(a,b) a##b
 
20
#define NUMBER(a,b) NUMBER_HELP(a,b)
 
21
#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
 
22
 
 
23
%{
 
24
const int thing27 = -1;
 
25
const int thing28 = -2;
 
26
%}
 
27
const int NUMBER_UNIQUE(thing) = -1; /* resolves to thing27 */
 
28
const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */
 
29
 
 
30
#define MYLINE2 __LINE__
 
31
 
 
32
#if defined (SWIGJAVA)
 
33
%javaconst(1);
 
34
#elif defined(SWIGCSHARP)
 
35
%csconst(1);
 
36
#else
 
37
%ignore LINE_NUMBER;
 
38
%ignore LINE_NUM;
 
39
/* spare space */
 
40
 
 
41
 
 
42
#endif
 
43
 
 
44
%{
 
45
struct SillyStruct {
 
46
  int num;
 
47
  /* static const int line_num = __LINE__; */
 
48
};
 
49
%}
 
50
struct SillyStruct {
 
51
  int num;
 
52
  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 */
 
53
};
 
54
 
 
55
#define SILLY_CLASS struct SillyMacroClass { int num; static const int LINE_NUM = __LINE__; };
 
56
SILLY_CLASS
 
57
 
 
58
%{
 
59
#define SILLY_CLASS struct SillyMacroClass { int num; };
 
60
SILLY_CLASS
 
61
%}
 
62
 
 
63
 
 
64
%inline %{
 
65
#ifdef SWIG
 
66
%define BODY
 
67
  int num;
 
68
  static const int LINE_NUM = __LINE__;
 
69
%enddef
 
70
%define KLASS(NAME)
 
71
struct NAME {
 
72
  BODY
 
73
};
 
74
%enddef
 
75
#else
 
76
#define KLASS(NAME) \
 
77
struct NAME { \
 
78
  int num; \
 
79
};
 
80
#endif
 
81
KLASS(SillyMultipleMacroStruct)
 
82
%}
 
83
 
 
84
%inline %{
 
85
 
 
86
#define INLINE_FILE __FILE__
 
87
#define INLINE_LINE __LINE__
 
88
%}
 
89
 
 
90
#define MACRO_END_WITH_SLASH ABCD/
 
91
 
 
92
%inline %{
 
93
KLASS(Slash)
 
94
%}
 
95