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 bool 42 outlist_bool(const char *a, const char *b, char **c) 43 { 44 dTHX; 45 STRLEN lena = strlen(a); 46 STRLEN lenb = strlen(b); 47 STRLEN lenc = lena + lenb; 48 Newx(*c, lenc+1, char); 49 strcpy(*c, a); 50 strcat(*c, b); 51 SAVEFREEPV(*c); 52 53 return TRUE; 54 } 55 56 STATIC int 57 outlist_int(const char *a, const char *b, char **c) 58 { 59 dTHX; 60 STRLEN lena = strlen(a); 61 STRLEN lenb = strlen(b); 62 STRLEN lenc = lena + lenb; 63 Newx(*c, lenc+1, char); 64 strcpy(*c, a); 65 strcat(*c, b); 66 SAVEFREEPV(*c); 67 68 return 11; 69 } 70 71 STATIC int 72 len(const char* const s, int const l){ 73 PERL_UNUSED_ARG(s); 74 return l; 75 } 76 77 MODULE = XSMore PACKAGE = XSMore 78 79 =for testing 80 81 This parts are also ignored. 82 83 =cut 84 85 PROTOTYPES: ENABLE 86 87 VERSIONCHECK: DISABLE 88 89 REQUIRE: 2.20 90 91 SCOPE: DISABLE 92 93 FALLBACK: TRUE 94 95 BOOT: 96 sv_setiv(get_sv("XSMore::boot_ok", TRUE), 100); 97 98 99 TYPEMAP: <<END 100 MyType T_IV 101 END 102 103 TYPEMAP: <<" FOO BAR BAZ"; 104 MyType2 T_FOOOO 105 106 OUTPUT 107 T_FOOOO 108 sv_setiv($arg, (IV)$var); 109 FOO BAR BAZ 110 111 TYPEMAP: <<'END' 112 MyType3 T_BAAR 113 MyType4 T_BAAR 114 115 OUTPUT 116 T_BAAR 117 sv_setiv($arg, (IV)$var); 118 119 INPUT 120 T_BAAR 121 $var = ($type)SvIV($arg) 122 END 123 124 TYPEMAP: <<END 125 MyType5 T_WITHSEMICOLON 126 127 INPUT 128 129 T_WITHSEMICOLON 130 $var = ($type)SvIV($arg); 131 END 132 133 TYPEMAP: <<SEMICOLONHERE; 134 MyType6 T_IV 135 SEMICOLONHERE 136 137 MyType 138 typemaptest1() 139 CODE: 140 RETVAL = 42; 141 OUTPUT: 142 RETVAL 143 144 MyType2 145 typemaptest2() 146 CODE: 147 RETVAL = 42; 148 OUTPUT: 149 RETVAL 150 151 MyType3 152 typemaptest3(foo, bar, baz) 153 MyType4 foo 154 MyType5 bar 155 MyType5 baz 156 CODE: 157 PERL_UNUSED_VAR(bar); 158 PERL_UNUSED_VAR(baz); 159 RETVAL = foo; 160 OUTPUT: 161 RETVAL 162 163 MyType6 164 typemaptest6(foo) 165 MyType6 foo 166 CODE: 167 RETVAL = foo; 168 OUTPUT: 169 RETVAL 170 171 void 172 prototype_ssa() 173 PROTOTYPE: $$@ 174 CODE: 175 NOOP; 176 177 void 178 attr_method(self, ...) 179 ATTRS: method 180 CODE: 181 NOOP; 182 183 #define RET_1 1 184 #define RET_2 2 185 186 int 187 return_1() 188 CASE: ix == 1 189 ALIAS: 190 return_1 = RET_1 191 return_2 = RET_2 192 CODE: 193 RETVAL = ix; 194 OUTPUT: 195 RETVAL 196 CASE: ix == 2 197 CODE: 198 RETVAL = ix; 199 OUTPUT: 200 RETVAL 201 202 int 203 arg_init(x) 204 int x = SvIV($arg); 205 CODE: 206 RETVAL = x; 207 OUTPUT: 208 RETVAL 209 210 int 211 myabs(...) 212 OVERLOAD: abs 213 CODE: 214 PERL_UNUSED_VAR(items); 215 RETVAL = 42; 216 OUTPUT: 217 RETVAL 218 219 void 220 hook(IN AV* av) 221 INIT: 222 av_push(av, newSVpv("INIT", 0)); 223 CODE: 224 av_push(av, newSVpv("CODE", 0)); 225 POSTCALL: 226 av_push(av, newSVpv("POSTCALL", 0)); 227 CLEANUP: 228 av_push(av, newSVpv("CLEANUP", 0)); 229 230 231 void 232 outlist(OUTLIST int a, OUTLIST int b) 233 234 bool 235 outlist_bool(const char *a, const char *b, OUTLIST char *c) 236 237 int 238 outlist_int(const char *a, const char *b, OUTLIST char *c) 239 240 int 241 len(char* s, int length(s)) 242 243 INCLUDE_COMMAND: $^X -Ilib -It/lib -MIncludeTester -e IncludeTester::print_xs 244 245 #if 1 246 247 INCLUDE: XSInclude.xsh 248 249 #else 250 251 # for testing #else directive 252 253 #endif 254 255 MODULE=XSMore PACKAGE=XSMore::More 256 257 void 258 dummy() 259 PROTOTYPE: $$$$$ 260 CODE: 261 NOOP; 262 263 void 264 should_not_have_prototype() 265 OVERLOAD: + 266 CODE: 267 NOOP; 268