This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
A typemap is a file, not a directory.
[perl5.git] / dist / ExtUtils-ParseXS / t / XSMore.xs
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
10
11 =for testing
12
13 This parts are ignored.
14
15 =cut
16
17 STATIC void
18 outlist(int* a, int* b){
19         *a = 'a';
20         *b = 'b';
21 }
22
23 STATIC int
24 len(const char* const s, int const l){
25         PERL_UNUSED_ARG(s);
26         return l;
27 }
28
29 MODULE = XSMore         PACKAGE = XSMore
30
31 =for testing
32
33 This parts are also ignored.
34
35 =cut
36
37 PROTOTYPES: ENABLE
38
39 VERSIONCHECK: DISABLE
40
41 REQUIRE: 2.20
42
43 SCOPE: DISABLE
44
45 FALLBACK: TRUE
46
47 BOOT:
48         sv_setiv(get_sv("XSMore::boot_ok", TRUE), 100);
49
50
51 TYPEMAP: <<END
52 MyType  T_IV
53 END
54
55 TYPEMAP: <<"  FOO BAR BAZ";
56 MyType2 T_FOOOO
57
58 OUTPUT
59 T_FOOOO
60         sv_setiv($arg, (IV)$var);
61   FOO BAR BAZ
62
63 TYPEMAP: <<'END'
64 MyType3 T_BAAR
65 MyType4 T_BAAR
66
67 OUTPUT
68 T_BAAR
69         sv_setiv($arg, (IV)$var);
70
71 INPUT
72 T_BAAR
73         $var = ($type)SvIV($arg)
74 END
75
76
77 MyType
78 typemaptest1()
79   CODE:
80     RETVAL = 42;
81   OUTPUT:
82     RETVAL
83
84 MyType2
85 typemaptest2()
86   CODE:
87     RETVAL = 42;
88   OUTPUT:
89     RETVAL
90
91 MyType3
92 typemaptest3(MyType4 foo)
93   CODE:
94     RETVAL = foo;
95   OUTPUT:
96     RETVAL
97
98 void
99 prototype_ssa()
100 PROTOTYPE: $$@
101 CODE:
102         NOOP;
103
104 void
105 attr_method(self, ...)
106 ATTRS: method
107 CODE:
108         NOOP;
109
110 #define RET_1 1
111 #define RET_2 2
112
113 int
114 return_1()
115 CASE: ix == 1
116         ALIAS:
117                 return_1 = RET_1
118                 return_2 = RET_2
119         CODE:
120                 RETVAL = ix;
121         OUTPUT:
122                 RETVAL
123 CASE: ix == 2
124         CODE:
125                 RETVAL = ix;
126         OUTPUT:
127                 RETVAL
128
129 int
130 arg_init(x)
131         int x = SvIV($arg);
132 CODE:
133         RETVAL = x;
134 OUTPUT:
135         RETVAL
136
137 int
138 myabs(...)
139 OVERLOAD: abs
140 CODE:
141         PERL_UNUSED_VAR(items);
142         RETVAL = 42;
143 OUTPUT:
144         RETVAL
145
146 void
147 hook(IN AV* av)
148 INIT:
149         av_push(av, newSVpv("INIT", 0));
150 CODE:
151         av_push(av, newSVpv("CODE", 0));
152 POSTCALL:
153         av_push(av, newSVpv("POSTCALL", 0));
154 CLEANUP:
155         av_push(av, newSVpv("CLEANUP", 0));
156
157
158 void
159 outlist(OUTLIST int a, OUTLIST int b)
160
161 int
162 len(char* s, int length(s))
163
164 INCLUDE_COMMAND: $^X -Ilib -It/lib -MIncludeTester -e IncludeTester::print_xs
165
166 #if 1
167
168 INCLUDE: XSInclude.xsh
169
170 #else
171
172 # for testing #else directive
173
174 #endif