3 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) one; /* Ruby, wrong constant name */
4 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) two; /* Ruby, wrong constant name */
5 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) three; /* Ruby, wrong constant name */
6 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_CONST; /* Ruby, wrong constant name */
7 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */
8 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
10 /* check __cplusplus case */
16 #endif /* __cplusplus */
20 #endif /* __cplusplus */
25 /* This interface file tests whether SWIG's extended C
26 preprocessor is working right.
28 In this example, SWIG 1.3.6 chokes on "//" in a #define with a
32 #define SLASHSLASH "//"
34 /* This SWIG -*- c -*- interface is to test for some strange
37 I get syntax errors unless I remove the apostrophe in the comment
38 or the sharp-sign substitution. (The apostrophe seems to disable
39 sharp-sign substitution.)
43 %define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(SCM_TYPE)
45 /* Don't check for NULL pointers (override checks). */
47 %typemap(argout, doc="($arg <vector of <" #SCM_TYPE ">>)")
54 TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(boolean)
79 int f(int min) { return min; }
82 #define ARITH_RTYPE(A1, A2) A2
84 #define HELLO_TYPE(A, B) ARITH_RTYPE(A, ARITH_RTYPE(A,B))
87 // These two work fine
90 ARITH_RTYPE(double,int) hello1();
94 // This doesn't work with 1.3.17+ ( but it was ok in 1.3.16 )
95 // it gets expanded as (using -E)
97 // ARITH_RTYPE(double,int) hello2();
99 HELLO_TYPE(double,int) hello2();
101 #define min(x,y) ((x) < (y)) ? (x) : (y)
106 %warnfilter(SWIGWARN_PARSE_REDEFINED) A5; // Ruby, wrong constant name
107 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) a5; // Ruby, wrong constant name
108 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) b5; // Ruby, wrong constant name
109 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) c5; // Ruby, wrong constant name
110 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) d5; // Ruby, wrong constant name
112 // Various preprocessor bits of nastiness.
115 /* Test argument name substitution */
116 #define foo(x,xx) #x #xx
117 #define bar(x,xx) x + xx
119 %constant char *a5 = foo(hello,world);
120 %constant int b5 = bar(3,4);
122 // Wrap your brain around this one ;-)
125 #define cat(x,y) x ## y
128 #define cat(x,y) x ## y
130 /* This should expand to cat(1,2);
133 %constant int c5 = cat(cat(1,2),;)
135 #define xcat(x,y) cat(x,y)
137 /* This expands to 123. See K&R, p. 231 */
138 %constant int d5 = xcat(xcat(1,2),3);
154 %warnfilter(SWIGWARN_PARSE_REDEFINED) A6; /* Ruby, wrong constant name */
155 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) a6; /* Ruby, wrong constant name */
156 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) b6; /* Ruby, wrong constant name */
157 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) c6; /* Ruby, wrong constant name */
158 %warnfilter(SWIGWARN_RUBY_WRONG_NAME) d6; /* Ruby, wrong constant name */
160 #define add(a, b) (a + b)
161 #define times(a, b) (a * b)
162 #define op(x) x(1, 5)
164 /* expand to (1 + 5) */
165 %constant int a6 = op(add);
166 /* expand to (1 * 5) */
167 %constant int b6 = op(times);
168 /* expand to ((1 + 5) * 5) */
169 %constant int c6 = times(add(1, 5), 5);
170 /* expand to ((1 + 5) * 5) */
171 %constant int d6 = times(op(add), 5);
173 /* This interface file tests whether SWIG's extended C
174 preprocessor is working right.
176 In this example, SWIG 1.3a5 reports missing macro arguments, which
180 %define MACRO1(C_TYPE, GETLENGTH)
184 %define MACRO2(XYZZY)
190 // cpp_macro_noarg. Tests to make sure macros with no arguments work right.
191 #define MACROWITHARG(x) something(x)
193 typedef int MACROWITHARG;
196 This testcase tests for embedded defines and embedded %constants
201 typedef struct EmbeddedDefines {
203 #define EMBEDDED_DEFINE 44
205 %constant EMBEDDED_SWIG_CONSTANT = 55;
212 This testcase tests operators for defines
233 #define %mangle_macro(...) #@__VA_ARGS__
234 #define %mangle_macro_str(...) ##@__VA_ARGS__
237 inline const char* mangle_macro ## #@__VA_ARGS__ () {
238 return %mangle_macro_str(__VA_ARGS__);
244 my_func(std::pair<double, std::complex< double > >*) ;
250 #if defined (__cplusplus) \
252 || defined (__DECC) \
253 || (defined (__mips) && defined (_SYSTYPE_SVR4)) \
254 || defined (_MSC_VER) \
256 #define __GMP_HAVE_CONST 1
257 #define __GMP_HAVE_PROTOTYPES 1
258 #define __GMP_HAVE_TOKEN_PASTE 1
260 #define __GMP_HAVE_CONST 0
261 #define __GMP_HAVE_PROTOTYPES 0
262 #define __GMP_HAVE_TOKEN_PASTE 0
266 /* empty TWO() macro is broken */
273 #define three THREE(42)
283 /* define is a scheme keyword (and thus an invalid variable name), so SWIG warns about it */
284 %warnfilter(SWIGWARN_PARSE_KEYWORD) define;
288 %rename(ddefined) defined;
291 %rename(endif_) endif;
295 const int define = 1;
296 const int defined = 1;
297 int test(int defined)
304 #pragma SWIG nowarn=SWIGWARN_PP_CPP_WARNING
305 #warning "Some warning"
307 /* check that #error can be turned into a warning, but suppress the warning message for the test-suite! */
308 #pragma SWIG nowarn=SWIGWARN_PP_CPP_ERROR
309 #pragma SWIG cpperraswarn=1
313 #define MASK(shift, size) (((1 << (size)) - 1) <<(shift))
314 #define SOME_MASK_DEF (80*MASK(8, 10))
317 #define BOLTZMANN (1.380658e-23)
318 #define AVOGADRO (6.0221367e23)
319 #define RGAS (BOLTZMANN*AVOGADRO)
320 #define RGASX (BOLTZMANN*AVOGADRO*BOLTZMANN)
323 #define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \
324 struct TypeNameTraits { \
331 #define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \
332 struct TypeNameTraits { \
337 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(int);
341 int method(struct TypeNameTraits tnt) {