1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4 
5 typedef IV MyType;
6 typedef IV MyType2;
7 typedef IV MyType3;
8 typedef IV MyType4;
9 typedef IV MyType5;
10 typedef IV MyType6;
11 
12 
13 =for testing
14 
15 This parts are ignored.
16 
17 =cut
18 
19 /* Old perls (pre 5.8.9 or so) did not have PERL_UNUSED_ARG in XSUB.h.
20  * This is normally covered by ppport.h. */
21 #ifndef PERL_UNUSED_ARG
22 #  if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
23 #    include <note.h>
24 #    define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x))
25 #  else
26 #    define PERL_UNUSED_ARG(x) ((void)x)
27 #  endif
28 #endif
29 #ifndef PERL_UNUSED_VAR
30 #  define PERL_UNUSED_VAR(x) ((void)x)
31 #endif
32 
33 
34 
35 STATIC void
36 outlist(int* a, int* b){
37 	*a = 'a';
38 	*b = 'b';
39 }
40 
41 STATIC int
42 len(const char* const s, int const l){
43 	PERL_UNUSED_ARG(s);
44 	return l;
45 }
46 
47 MODULE = XSMore         PACKAGE = XSMore
48 
49 =for testing
50 
51 This parts are also ignored.
52 
53 =cut
54 
55 PROTOTYPES: ENABLE
56 
57 VERSIONCHECK: DISABLE
58 
59 REQUIRE: 2.20
60 
61 SCOPE: DISABLE
62 
63 FALLBACK: TRUE
64 
65 BOOT:
66 	sv_setiv(get_sv("XSMore::boot_ok", TRUE), 100);
67 
68 
69 TYPEMAP: <<END
70 MyType	T_IV
71 END
72 
73 TYPEMAP: <<"  FOO BAR BAZ";
74 MyType2	T_FOOOO
75 
76 OUTPUT
77 T_FOOOO
78 	sv_setiv($arg, (IV)$var);
79   FOO BAR BAZ
80 
81 TYPEMAP: <<'END'
82 MyType3	T_BAAR
83 MyType4	T_BAAR
84 
85 OUTPUT
86 T_BAAR
87 	sv_setiv($arg, (IV)$var);
88 
89 INPUT
90 T_BAAR
91 	$var = ($type)SvIV($arg)
92 END
93 
94 TYPEMAP: <<END
95 MyType5 T_WITHSEMICOLON
96 
97 INPUT
98 
99 T_WITHSEMICOLON
100     $var = ($type)SvIV($arg);
101 END
102 
103 TYPEMAP: <<SEMICOLONHERE;
104 MyType6	T_IV
105 SEMICOLONHERE
106 
107 MyType
108 typemaptest1()
109   CODE:
110     RETVAL = 42;
111   OUTPUT:
112     RETVAL
113 
114 MyType2
115 typemaptest2()
116   CODE:
117     RETVAL = 42;
118   OUTPUT:
119     RETVAL
120 
121 MyType3
122 typemaptest3(foo, bar, baz)
123     MyType4 foo
124     MyType5 bar
125     MyType5 baz
126   CODE:
127     PERL_UNUSED_VAR(bar);
128     PERL_UNUSED_VAR(baz);
129     RETVAL = foo;
130   OUTPUT:
131     RETVAL
132 
133 MyType6
134 typemaptest6(foo)
135     MyType6 foo
136   CODE:
137     RETVAL = foo;
138   OUTPUT:
139     RETVAL
140 
141 void
142 prototype_ssa()
143 PROTOTYPE: $$@
144 CODE:
145 	NOOP;
146 
147 void
148 attr_method(self, ...)
149 ATTRS: method
150 CODE:
151 	NOOP;
152 
153 #define RET_1 1
154 #define RET_2 2
155 
156 int
157 return_1()
158 CASE: ix == 1
159 	ALIAS:
160 		return_1 = RET_1
161 		return_2 = RET_2
162 	CODE:
163 		RETVAL = ix;
164 	OUTPUT:
165 		RETVAL
166 CASE: ix == 2
167 	CODE:
168 		RETVAL = ix;
169 	OUTPUT:
170 		RETVAL
171 
172 int
173 arg_init(x)
174 	int x = SvIV($arg);
175 CODE:
176 	RETVAL = x;
177 OUTPUT:
178 	RETVAL
179 
180 int
181 myabs(...)
182 OVERLOAD: abs
183 CODE:
184 	PERL_UNUSED_VAR(items);
185 	RETVAL = 42;
186 OUTPUT:
187 	RETVAL
188 
189 void
190 hook(IN AV* av)
191 INIT:
192 	av_push(av, newSVpv("INIT", 0));
193 CODE:
194 	av_push(av, newSVpv("CODE", 0));
195 POSTCALL:
196 	av_push(av, newSVpv("POSTCALL", 0));
197 CLEANUP:
198 	av_push(av, newSVpv("CLEANUP", 0));
199 
200 
201 void
202 outlist(OUTLIST int a, OUTLIST int b)
203 
204 int
205 len(char* s, int length(s))
206 
207 INCLUDE_COMMAND: $^X -Ilib -It/lib -MIncludeTester -e IncludeTester::print_xs
208 
209 #if 1
210 
211 INCLUDE: XSInclude.xsh
212 
213 #else
214 
215 # for testing #else directive
216 
217 #endif
218