1 #define PERL_IN_XS_APITEST
3 /* We want to be able to test things that aren't API yet. */
6 /* Do *not* define PERL_NO_GET_CONTEXT. This is the one place where we get
7 to test implicit Perl_get_context(). */
12 #include "fakesdio.h" /* Causes us to use PerlIO below */
15 typedef PTR_TBL_t *XS__APItest__PtrTable;
17 #define croak_fail() croak("fail at " __FILE__ " line %d", __LINE__)
18 #define croak_fail_ne(h, w) croak("fail %p!=%p at " __FILE__ " line %d", (h), (w), __LINE__)
23 cat_utf8a2n(SV* sv, const char * const ascii_utf8, STRLEN len)
25 /* Converts variant UTF-8 text pointed to by 'ascii_utf8' of length 'len',
26 * to UTF-EBCDIC, appending that text to the text already in 'sv'.
27 * Currently doesn't work on invariants, as that is unneeded here, and we
28 * could get double translations if we did.
30 * It has the algorithm for strict UTF-8 hard-coded in to find the code
31 * point it represents, then calls uvchr_to_utf8() to convert to
34 * Note that this uses code points, not characters. Thus if the input is
35 * the UTF-8 for the code point 0xFF, the output will be the UTF-EBCDIC for
36 * 0xFF, even though that code point represents different characters on
37 * ASCII vs EBCDIC platforms. */
40 char * p = (char *) ascii_utf8;
41 const char * const e = p + len;
45 U8 native_utf8[UTF8_MAXBYTES + 1];
49 /* Start bytes are the same in both UTF-8 and I8, therefore we can
50 * treat this ASCII UTF-8 byte as an I8 byte. But PL_utf8skip[] is
51 * indexed by NATIVE_UTF8 bytes, so transform to that */
52 STRLEN char_bytes_len = PL_utf8skip[I8_TO_NATIVE_UTF8(start)];
55 croak("fail: Expecting start byte, instead got 0x%X at %s line %d",
56 (U8) *p, __FILE__, __LINE__);
58 code_point = (start & (((char_bytes_len) >= 7)
60 : (0x1F >> ((char_bytes_len)-2))));
62 while (p < e && ((( (U8) *p) & 0xC0) == 0x80)) {
64 code_point = (code_point << 6) | (( (U8) *p) & 0x3F);
68 char_end = uvchr_to_utf8(native_utf8, code_point);
69 sv_catpvn(sv, (char *) native_utf8, char_end - native_utf8);
75 /* for my_cxt tests */
77 #define MY_CXT_KEY "XS::APItest::_guts" XS_VERSION
96 MGVTBL vtbl_foo, vtbl_bar;
98 /* indirect functions to test the [pa]MY_CXT macros */
101 my_cxt_getint_p(pMY_CXT)
107 my_cxt_setint_p(pMY_CXT_ int i)
113 my_cxt_getsv_interp_context(void)
116 dMY_CXT_INTERP(my_perl);
121 my_cxt_getsv_interp(void)
128 my_cxt_setsv_p(SV* sv _pMY_CXT)
134 /* from exception.c */
135 int apitest_exception(int);
137 /* from core_or_not.inc */
138 bool sv_setsv_cow_hashkey_core(void);
139 bool sv_setsv_cow_hashkey_notcore(void);
141 /* A routine to test hv_delayfree_ent
142 (which itself is tested by testing on hv_free_ent */
144 typedef void (freeent_function)(pTHX_ HV *, HE *);
147 test_freeent(freeent_function *f) {
149 HV *test_hash = newHV();
156 victim = (HE*)safemalloc(sizeof(HE));
158 /* Storing then deleting something should ensure that a hash entry is
160 (void) hv_store(test_hash, "", 0, &PL_sv_yes, 0);
161 (void) hv_delete(test_hash, "", 0, 0);
163 /* We need to "inline" new_he here as it's static, and the functions we
164 test expect to be able to call del_HE on the HE */
165 if (!PL_body_roots[HE_SVSLOT])
166 croak("PL_he_root is 0");
167 victim = (HE*) PL_body_roots[HE_SVSLOT];
168 PL_body_roots[HE_SVSLOT] = HeNEXT(victim);
171 victim->hent_hek = Perl_share_hek(aTHX_ "", 0, 0);
173 test_scalar = newSV(0);
174 SvREFCNT_inc(test_scalar);
175 HeVAL(victim) = test_scalar;
177 /* Need this little game else we free the temps on the return stack. */
178 results[0] = SvREFCNT(test_scalar);
180 results[1] = SvREFCNT(test_scalar);
181 f(aTHX_ test_hash, victim);
182 results[2] = SvREFCNT(test_scalar);
184 results[3] = SvREFCNT(test_scalar);
189 } while (++i < (int)(sizeof(results)/sizeof(results[0])));
191 /* Goodbye to our extra reference. */
192 SvREFCNT_dec(test_scalar);
195 /* Not that it matters much, but it's handy for the flipped character to just
196 * be the opposite case (at least for ASCII-range and most Latin1 as well). */
197 #define FLIP_BIT ('A' ^ 'a')
200 bitflip_key(pTHX_ IV action, SV *field) {
201 MAGIC *mg = mg_find(field, PERL_MAGIC_uvar);
203 PERL_UNUSED_ARG(action);
204 if (mg && (keysv = mg->mg_obj)) {
206 const char *p = SvPV(keysv, len);
209 /* Allow for the flipped val to be longer than the original. This
210 * is just for testing, so can afford to have some slop */
211 const STRLEN newlen = len * 2;
213 SV *newkey = newSV(newlen);
214 const char * const new_p_orig = SvPVX(newkey);
215 char *new_p = (char *) new_p_orig;
218 const char *const end = p + len;
221 UV chr = utf8_to_uvchr_buf((U8 *)p, (U8 *) end, &curlen);
223 /* Make sure don't exceed bounds */
224 assert(new_p - new_p_orig + curlen < newlen);
226 new_p = (char *)uvchr_to_utf8((U8 *)new_p, chr ^ FLIP_BIT);
232 *new_p++ = *p++ ^ FLIP_BIT;
235 SvCUR_set(newkey, new_p - new_p_orig);
245 rot13_key(pTHX_ IV action, SV *field) {
246 MAGIC *mg = mg_find(field, PERL_MAGIC_uvar);
248 PERL_UNUSED_ARG(action);
249 if (mg && (keysv = mg->mg_obj)) {
251 const char *p = SvPV(keysv, len);
254 SV *newkey = newSV(len);
255 char *new_p = SvPVX(newkey);
257 /* There's a deliberate fencepost error here to loop len + 1 times
258 to copy the trailing \0 */
261 /* Try doing this cleanly and clearly in EBCDIC another way: */
263 case 'A': new_c = 'N'; break;
264 case 'B': new_c = 'O'; break;
265 case 'C': new_c = 'P'; break;
266 case 'D': new_c = 'Q'; break;
267 case 'E': new_c = 'R'; break;
268 case 'F': new_c = 'S'; break;
269 case 'G': new_c = 'T'; break;
270 case 'H': new_c = 'U'; break;
271 case 'I': new_c = 'V'; break;
272 case 'J': new_c = 'W'; break;
273 case 'K': new_c = 'X'; break;
274 case 'L': new_c = 'Y'; break;
275 case 'M': new_c = 'Z'; break;
276 case 'N': new_c = 'A'; break;
277 case 'O': new_c = 'B'; break;
278 case 'P': new_c = 'C'; break;
279 case 'Q': new_c = 'D'; break;
280 case 'R': new_c = 'E'; break;
281 case 'S': new_c = 'F'; break;
282 case 'T': new_c = 'G'; break;
283 case 'U': new_c = 'H'; break;
284 case 'V': new_c = 'I'; break;
285 case 'W': new_c = 'J'; break;
286 case 'X': new_c = 'K'; break;
287 case 'Y': new_c = 'L'; break;
288 case 'Z': new_c = 'M'; break;
289 case 'a': new_c = 'n'; break;
290 case 'b': new_c = 'o'; break;
291 case 'c': new_c = 'p'; break;
292 case 'd': new_c = 'q'; break;
293 case 'e': new_c = 'r'; break;
294 case 'f': new_c = 's'; break;
295 case 'g': new_c = 't'; break;
296 case 'h': new_c = 'u'; break;
297 case 'i': new_c = 'v'; break;
298 case 'j': new_c = 'w'; break;
299 case 'k': new_c = 'x'; break;
300 case 'l': new_c = 'y'; break;
301 case 'm': new_c = 'z'; break;
302 case 'n': new_c = 'a'; break;
303 case 'o': new_c = 'b'; break;
304 case 'p': new_c = 'c'; break;
305 case 'q': new_c = 'd'; break;
306 case 'r': new_c = 'e'; break;
307 case 's': new_c = 'f'; break;
308 case 't': new_c = 'g'; break;
309 case 'u': new_c = 'h'; break;
310 case 'v': new_c = 'i'; break;
311 case 'w': new_c = 'j'; break;
312 case 'x': new_c = 'k'; break;
313 case 'y': new_c = 'l'; break;
314 case 'z': new_c = 'm'; break;
318 SvCUR_set(newkey, SvCUR(keysv));
330 rmagical_a_dummy(pTHX_ IV idx, SV *sv) {
331 PERL_UNUSED_ARG(idx);
336 /* We could do "= { 0 };" but some versions of gcc do warn
337 * (with -Wextra) about missing initializer, this is probably gcc
338 * being a bit too paranoid. But since this is file-static, we can
339 * just have it without initializer, since it should get
340 * zero-initialized. */
341 STATIC MGVTBL rmagical_b;
344 blockhook_csc_start(pTHX_ int full)
347 AV *const cur = GvAV(MY_CXT.cscgv);
349 PERL_UNUSED_ARG(full);
350 SAVEGENERICSV(GvAV(MY_CXT.cscgv));
354 AV *const new_av = newAV();
356 for (i = 0; i <= av_tindex(cur); i++) {
357 av_store(new_av, i, newSVsv(*av_fetch(cur, i, 0)));
360 GvAV(MY_CXT.cscgv) = new_av;
365 blockhook_csc_pre_end(pTHX_ OP **o)
370 /* if we hit the end of a scope we missed the start of, we need to
371 * unconditionally clear @CSC */
372 if (GvAV(MY_CXT.cscgv) == MY_CXT.cscav && MY_CXT.cscav) {
373 av_clear(MY_CXT.cscav);
379 blockhook_test_start(pTHX_ int full)
384 if (MY_CXT.bhk_record) {
386 av_push(av, newSVpvs("start"));
387 av_push(av, newSViv(full));
388 av_push(MY_CXT.bhkav, newRV_noinc(MUTABLE_SV(av)));
393 blockhook_test_pre_end(pTHX_ OP **o)
398 if (MY_CXT.bhk_record)
399 av_push(MY_CXT.bhkav, newSVpvs("pre_end"));
403 blockhook_test_post_end(pTHX_ OP **o)
408 if (MY_CXT.bhk_record)
409 av_push(MY_CXT.bhkav, newSVpvs("post_end"));
413 blockhook_test_eval(pTHX_ OP *const o)
418 if (MY_CXT.bhk_record) {
420 av_push(av, newSVpvs("eval"));
421 av_push(av, newSVpv(OP_NAME(o), 0));
422 av_push(MY_CXT.bhkav, newRV_noinc(MUTABLE_SV(av)));
426 STATIC BHK bhk_csc, bhk_test;
429 my_peep (pTHX_ OP *o)
436 MY_CXT.orig_peep(aTHX_ o);
438 if (!MY_CXT.peep_recording)
441 for (; o; o = o->op_next) {
442 if (o->op_type == OP_CONST && cSVOPx_sv(o) && SvPOK(cSVOPx_sv(o))) {
443 av_push(MY_CXT.peep_recorder, newSVsv(cSVOPx_sv(o)));
449 my_rpeep (pTHX_ OP *o)
456 MY_CXT.orig_rpeep(aTHX_ o);
458 if (!MY_CXT.peep_recording)
461 for (; o; o = o->op_next) {
462 if (o->op_type == OP_CONST && cSVOPx_sv(o) && SvPOK(cSVOPx_sv(o))) {
463 av_push(MY_CXT.rpeep_recorder, newSVsv(cSVOPx_sv(o)));
469 THX_ck_entersub_args_lists(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
471 PERL_UNUSED_ARG(namegv);
472 PERL_UNUSED_ARG(ckobj);
473 return ck_entersub_args_list(entersubop);
477 THX_ck_entersub_args_scalars(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
479 OP *aop = cUNOPx(entersubop)->op_first;
480 PERL_UNUSED_ARG(namegv);
481 PERL_UNUSED_ARG(ckobj);
482 if (!OpHAS_SIBLING(aop))
483 aop = cUNOPx(aop)->op_first;
484 for (aop = OpSIBLING(aop); OpHAS_SIBLING(aop); aop = OpSIBLING(aop)) {
485 op_contextualize(aop, G_SCALAR);
491 THX_ck_entersub_multi_sum(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
494 OP *parent = entersubop;
495 OP *pushop = cUNOPx(entersubop)->op_first;
496 PERL_UNUSED_ARG(namegv);
497 PERL_UNUSED_ARG(ckobj);
498 if (!OpHAS_SIBLING(pushop)) {
500 pushop = cUNOPx(pushop)->op_first;
503 OP *aop = OpSIBLING(pushop);
504 if (!OpHAS_SIBLING(aop))
506 /* cut out first arg */
507 op_sibling_splice(parent, pushop, 1, NULL);
508 op_contextualize(aop, G_SCALAR);
510 sumop = newBINOP(OP_ADD, 0, sumop, aop);
516 sumop = newSVOP(OP_CONST, 0, newSViv(0));
521 STATIC void test_op_list_describe_part(SV *res, OP *o);
523 test_op_list_describe_part(SV *res, OP *o)
525 sv_catpv(res, PL_op_name[o->op_type]);
526 switch (o->op_type) {
528 sv_catpvf(res, "(%d)", (int)SvIV(cSVOPx(o)->op_sv));
531 if (o->op_flags & OPf_KIDS) {
534 for (k = cUNOPx(o)->op_first; k; k = OpSIBLING(k))
535 test_op_list_describe_part(res, k);
543 test_op_list_describe(OP *o)
545 SV *res = sv_2mortal(newSVpvs(""));
547 test_op_list_describe_part(res, o);
551 /* the real new*OP functions have a tendency to call fold_constants, and
552 * other such unhelpful things, so we need our own versions for testing */
554 #define mkUNOP(t, f) THX_mkUNOP(aTHX_ (t), (f))
556 THX_mkUNOP(pTHX_ U32 type, OP *first)
559 NewOp(1103, unop, 1, UNOP);
560 unop->op_type = (OPCODE)type;
561 op_sibling_splice((OP*)unop, NULL, 0, first);
565 #define mkBINOP(t, f, l) THX_mkBINOP(aTHX_ (t), (f), (l))
567 THX_mkBINOP(pTHX_ U32 type, OP *first, OP *last)
570 NewOp(1103, binop, 1, BINOP);
571 binop->op_type = (OPCODE)type;
572 op_sibling_splice((OP*)binop, NULL, 0, last);
573 op_sibling_splice((OP*)binop, NULL, 0, first);
577 #define mkLISTOP(t, f, s, l) THX_mkLISTOP(aTHX_ (t), (f), (s), (l))
579 THX_mkLISTOP(pTHX_ U32 type, OP *first, OP *sib, OP *last)
582 NewOp(1103, listop, 1, LISTOP);
583 listop->op_type = (OPCODE)type;
584 op_sibling_splice((OP*)listop, NULL, 0, last);
585 op_sibling_splice((OP*)listop, NULL, 0, sib);
586 op_sibling_splice((OP*)listop, NULL, 0, first);
591 test_op_linklist_describe(OP *start)
593 SV *rv = sv_2mortal(newSVpvs(""));
595 o = start = LINKLIST(start);
598 sv_catpv(rv, OP_NAME(o));
599 if (o->op_type == OP_CONST)
600 sv_catsv(rv, cSVOPo->op_sv);
602 } while (o && o != start);
606 /** establish_cleanup operator, ripped off from Scope::Cleanup **/
609 THX_run_cleanup(pTHX_ void *cleanup_code_ref)
616 call_sv((SV*)cleanup_code_ref, G_VOID|G_DISCARD);
623 THX_pp_establish_cleanup(pTHX)
626 SV *cleanup_code_ref;
627 cleanup_code_ref = newSVsv(POPs);
628 SAVEFREESV(cleanup_code_ref);
629 SAVEDESTRUCTOR_X(THX_run_cleanup, cleanup_code_ref);
630 if(GIMME_V != G_VOID) PUSHs(&PL_sv_undef);
635 THX_ck_entersub_establish_cleanup(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
637 OP *parent, *pushop, *argop, *estop;
638 ck_entersub_args_proto(entersubop, namegv, ckobj);
640 pushop = cUNOPx(entersubop)->op_first;
641 if(!OpHAS_SIBLING(pushop)) {
643 pushop = cUNOPx(pushop)->op_first;
645 /* extract out first arg, then delete the rest of the tree */
646 argop = OpSIBLING(pushop);
647 op_sibling_splice(parent, pushop, 1, NULL);
650 estop = mkUNOP(OP_RAND, argop);
651 estop->op_ppaddr = THX_pp_establish_cleanup;
652 PL_hints |= HINT_BLOCK_SCOPE;
657 THX_ck_entersub_postinc(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
659 OP *parent, *pushop, *argop;
660 ck_entersub_args_proto(entersubop, namegv, ckobj);
662 pushop = cUNOPx(entersubop)->op_first;
663 if(!OpHAS_SIBLING(pushop)) {
665 pushop = cUNOPx(pushop)->op_first;
667 argop = OpSIBLING(pushop);
668 op_sibling_splice(parent, pushop, 1, NULL);
670 return newUNOP(OP_POSTINC, 0,
671 op_lvalue(op_contextualize(argop, G_SCALAR), OP_POSTINC));
675 THX_ck_entersub_pad_scalar(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
678 PADOFFSET padoff = NOT_IN_PAD;
680 ck_entersub_args_proto(entersubop, namegv, ckobj);
681 pushop = cUNOPx(entersubop)->op_first;
682 if(!OpHAS_SIBLING(pushop))
683 pushop = cUNOPx(pushop)->op_first;
684 argop = OpSIBLING(pushop);
685 if(argop->op_type != OP_CONST || OpSIBLING(argop)->op_type != OP_CONST)
686 croak("bad argument expression type for pad_scalar()");
687 a0 = cSVOPx_sv(argop);
688 a1 = cSVOPx_sv(OpSIBLING(argop));
691 SV *namesv = sv_2mortal(newSVpvs("$"));
692 sv_catsv(namesv, a1);
693 padoff = pad_findmy_sv(namesv, 0);
698 SV *namesv = sv_2mortal(newSVpvs("$"));
699 sv_catsv(namesv, a1);
700 namepv = SvPV(namesv, namelen);
701 padoff = pad_findmy_pvn(namepv, namelen, SvUTF8(namesv));
705 SV *namesv = sv_2mortal(newSVpvs("$"));
706 sv_catsv(namesv, a1);
707 namepv = SvPV_nolen(namesv);
708 padoff = pad_findmy_pv(namepv, SvUTF8(namesv));
711 padoff = pad_findmy_pvs("$foo", 0);
713 default: croak("bad type value for pad_scalar()");
716 if(padoff == NOT_IN_PAD) {
717 return newSVOP(OP_CONST, 0, newSVpvs("NOT_IN_PAD"));
718 } else if(PAD_COMPNAME_FLAGS_isOUR(padoff)) {
719 return newSVOP(OP_CONST, 0, newSVpvs("NOT_MY"));
721 OP *padop = newOP(OP_PADSV, 0);
722 padop->op_targ = padoff;
727 /** RPN keyword parser **/
729 #define sv_is_glob(sv) (SvTYPE(sv) == SVt_PVGV)
730 #define sv_is_regexp(sv) (SvTYPE(sv) == SVt_REGEXP)
731 #define sv_is_string(sv) \
732 (!sv_is_glob(sv) && !sv_is_regexp(sv) && \
733 (SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK|SVp_IOK|SVp_NOK|SVp_POK)))
735 static SV *hintkey_rpn_sv, *hintkey_calcrpn_sv, *hintkey_stufftest_sv;
736 static SV *hintkey_swaptwostmts_sv, *hintkey_looprest_sv;
737 static SV *hintkey_scopelessblock_sv;
738 static SV *hintkey_stmtasexpr_sv, *hintkey_stmtsasexpr_sv;
739 static SV *hintkey_loopblock_sv, *hintkey_blockasexpr_sv;
740 static SV *hintkey_swaplabel_sv, *hintkey_labelconst_sv;
741 static SV *hintkey_arrayfullexpr_sv, *hintkey_arraylistexpr_sv;
742 static SV *hintkey_arraytermexpr_sv, *hintkey_arrayarithexpr_sv;
743 static SV *hintkey_arrayexprflags_sv;
744 static SV *hintkey_DEFSV_sv;
745 static SV *hintkey_with_vars_sv;
746 static SV *hintkey_join_with_space_sv;
747 static int (*next_keyword_plugin)(pTHX_ char *, STRLEN, OP **);
749 /* low-level parser helpers */
751 #define PL_bufptr (PL_parser->bufptr)
752 #define PL_bufend (PL_parser->bufend)
756 #define parse_var() THX_parse_var(aTHX)
757 static OP *THX_parse_var(pTHX)
763 if(*s != '$') croak("RPN syntax error");
766 if(!isALNUM(c)) break;
768 if(s-start < 2) croak("RPN syntax error");
770 varpos = pad_findmy_pvn(start, s-start, 0);
771 if(varpos == NOT_IN_PAD || PAD_COMPNAME_FLAGS_isOUR(varpos))
772 croak("RPN only supports \"my\" variables");
773 padop = newOP(OP_PADSV, 0);
774 padop->op_targ = varpos;
778 #define push_rpn_item(o) \
779 op_sibling_splice(parent, NULL, 0, o);
780 #define pop_rpn_item() ( \
781 (tmpop = op_sibling_splice(parent, NULL, 1, NULL)) \
782 ? tmpop : (croak("RPN stack underflow"), (OP*)NULL))
784 #define parse_rpn_expr() THX_parse_rpn_expr(aTHX)
785 static OP *THX_parse_rpn_expr(pTHX)
788 /* fake parent for splice to mess with */
789 OP *parent = mkBINOP(OP_NULL, NULL, NULL);
794 c = lex_peek_unichar(0);
796 case /*(*/')': case /*{*/'}': {
797 OP *result = pop_rpn_item();
798 if(cLISTOPx(parent)->op_first)
799 croak("RPN expression must return a single value");
803 case '0': case '1': case '2': case '3': case '4':
804 case '5': case '6': case '7': case '8': case '9': {
808 val = 10*val + (c - '0');
809 c = lex_peek_unichar(0);
810 } while(c >= '0' && c <= '9');
811 push_rpn_item(newSVOP(OP_CONST, 0, newSVuv(val)));
814 push_rpn_item(parse_var());
817 OP *b = pop_rpn_item();
818 OP *a = pop_rpn_item();
820 push_rpn_item(newBINOP(OP_I_ADD, 0, a, b));
823 OP *b = pop_rpn_item();
824 OP *a = pop_rpn_item();
826 push_rpn_item(newBINOP(OP_I_SUBTRACT, 0, a, b));
829 OP *b = pop_rpn_item();
830 OP *a = pop_rpn_item();
832 push_rpn_item(newBINOP(OP_I_MULTIPLY, 0, a, b));
835 OP *b = pop_rpn_item();
836 OP *a = pop_rpn_item();
838 push_rpn_item(newBINOP(OP_I_DIVIDE, 0, a, b));
841 OP *b = pop_rpn_item();
842 OP *a = pop_rpn_item();
844 push_rpn_item(newBINOP(OP_I_MODULO, 0, a, b));
847 croak("RPN syntax error");
853 #define parse_keyword_rpn() THX_parse_keyword_rpn(aTHX)
854 static OP *THX_parse_keyword_rpn(pTHX)
858 if(lex_peek_unichar(0) != '('/*)*/)
859 croak("RPN expression must be parenthesised");
861 op = parse_rpn_expr();
862 if(lex_peek_unichar(0) != /*(*/')')
863 croak("RPN expression must be parenthesised");
868 #define parse_keyword_calcrpn() THX_parse_keyword_calcrpn(aTHX)
869 static OP *THX_parse_keyword_calcrpn(pTHX)
875 if(lex_peek_unichar(0) != '{'/*}*/)
876 croak("RPN expression must be braced");
878 exprop = parse_rpn_expr();
879 if(lex_peek_unichar(0) != /*{*/'}')
880 croak("RPN expression must be braced");
882 return newASSIGNOP(OPf_STACKED, varop, 0, exprop);
885 #define parse_keyword_stufftest() THX_parse_keyword_stufftest(aTHX)
886 static OP *THX_parse_keyword_stufftest(pTHX)
891 do_stuff = lex_peek_unichar(0) == '+';
896 c = lex_peek_unichar(0);
899 } else if(c != /*{*/'}') {
900 croak("syntax error");
902 if(do_stuff) lex_stuff_pvs(" ", 0);
903 return newOP(OP_NULL, 0);
906 #define parse_keyword_swaptwostmts() THX_parse_keyword_swaptwostmts(aTHX)
907 static OP *THX_parse_keyword_swaptwostmts(pTHX)
910 a = parse_fullstmt(0);
911 b = parse_fullstmt(0);
913 PL_hints |= HINT_BLOCK_SCOPE;
914 return op_append_list(OP_LINESEQ, b, a);
917 #define parse_keyword_looprest() THX_parse_keyword_looprest(aTHX)
918 static OP *THX_parse_keyword_looprest(pTHX)
920 return newWHILEOP(0, 1, NULL, newSVOP(OP_CONST, 0, &PL_sv_yes),
921 parse_stmtseq(0), NULL, 1);
924 #define parse_keyword_scopelessblock() THX_parse_keyword_scopelessblock(aTHX)
925 static OP *THX_parse_keyword_scopelessblock(pTHX)
930 if(lex_peek_unichar(0) != '{'/*}*/) croak("syntax error");
932 body = parse_stmtseq(0);
933 c = lex_peek_unichar(0);
934 if(c != /*{*/'}' && c != /*[*/']' && c != /*(*/')') croak("syntax error");
939 #define parse_keyword_stmtasexpr() THX_parse_keyword_stmtasexpr(aTHX)
940 static OP *THX_parse_keyword_stmtasexpr(pTHX)
942 OP *o = parse_barestmt(0);
943 if (!o) o = newOP(OP_STUB, 0);
944 if (PL_hints & HINT_BLOCK_SCOPE) o->op_flags |= OPf_PARENS;
948 #define parse_keyword_stmtsasexpr() THX_parse_keyword_stmtsasexpr(aTHX)
949 static OP *THX_parse_keyword_stmtsasexpr(pTHX)
953 if(lex_peek_unichar(0) != '{'/*}*/) croak("syntax error");
955 o = parse_stmtseq(0);
957 if(lex_peek_unichar(0) != /*{*/'}') croak("syntax error");
959 if (!o) o = newOP(OP_STUB, 0);
960 if (PL_hints & HINT_BLOCK_SCOPE) o->op_flags |= OPf_PARENS;
964 #define parse_keyword_loopblock() THX_parse_keyword_loopblock(aTHX)
965 static OP *THX_parse_keyword_loopblock(pTHX)
967 return newWHILEOP(0, 1, NULL, newSVOP(OP_CONST, 0, &PL_sv_yes),
968 parse_block(0), NULL, 1);
971 #define parse_keyword_blockasexpr() THX_parse_keyword_blockasexpr(aTHX)
972 static OP *THX_parse_keyword_blockasexpr(pTHX)
974 OP *o = parse_block(0);
975 if (!o) o = newOP(OP_STUB, 0);
976 if (PL_hints & HINT_BLOCK_SCOPE) o->op_flags |= OPf_PARENS;
980 #define parse_keyword_swaplabel() THX_parse_keyword_swaplabel(aTHX)
981 static OP *THX_parse_keyword_swaplabel(pTHX)
983 OP *sop = parse_barestmt(0);
984 SV *label = parse_label(PARSE_OPTIONAL);
985 if (label) sv_2mortal(label);
986 return newSTATEOP(label ? SvUTF8(label) : 0,
987 label ? savepv(SvPVX(label)) : NULL,
991 #define parse_keyword_labelconst() THX_parse_keyword_labelconst(aTHX)
992 static OP *THX_parse_keyword_labelconst(pTHX)
994 return newSVOP(OP_CONST, 0, parse_label(0));
997 #define parse_keyword_arrayfullexpr() THX_parse_keyword_arrayfullexpr(aTHX)
998 static OP *THX_parse_keyword_arrayfullexpr(pTHX)
1000 return newANONLIST(parse_fullexpr(0));
1003 #define parse_keyword_arraylistexpr() THX_parse_keyword_arraylistexpr(aTHX)
1004 static OP *THX_parse_keyword_arraylistexpr(pTHX)
1006 return newANONLIST(parse_listexpr(0));
1009 #define parse_keyword_arraytermexpr() THX_parse_keyword_arraytermexpr(aTHX)
1010 static OP *THX_parse_keyword_arraytermexpr(pTHX)
1012 return newANONLIST(parse_termexpr(0));
1015 #define parse_keyword_arrayarithexpr() THX_parse_keyword_arrayarithexpr(aTHX)
1016 static OP *THX_parse_keyword_arrayarithexpr(pTHX)
1018 return newANONLIST(parse_arithexpr(0));
1021 #define parse_keyword_arrayexprflags() THX_parse_keyword_arrayexprflags(aTHX)
1022 static OP *THX_parse_keyword_arrayexprflags(pTHX)
1028 c = lex_peek_unichar(0);
1029 if (c != '!' && c != '?') croak("syntax error");
1030 lex_read_unichar(0);
1031 if (c == '?') flags |= PARSE_OPTIONAL;
1032 o = parse_listexpr(flags);
1033 return o ? newANONLIST(o) : newANONHASH(newOP(OP_STUB, 0));
1036 #define parse_keyword_DEFSV() THX_parse_keyword_DEFSV(aTHX)
1037 static OP *THX_parse_keyword_DEFSV(pTHX)
1039 return newDEFSVOP();
1042 #define sv_cat_c(a,b) THX_sv_cat_c(aTHX_ a, b)
1043 static void THX_sv_cat_c(pTHX_ SV *sv, U32 c) {
1044 char ds[UTF8_MAXBYTES + 1], *d;
1045 d = (char *)uvchr_to_utf8((U8 *)ds, c);
1047 sv_utf8_upgrade(sv);
1049 sv_catpvn(sv, ds, d - ds);
1052 #define parse_keyword_with_vars() THX_parse_keyword_with_vars(aTHX)
1053 static OP *THX_parse_keyword_with_vars(pTHX)
1058 OP *vardeclseq, *body;
1060 save_ix = block_start(TRUE);
1066 c = lex_peek_unichar(0);
1072 croak("unexpected EOF; expecting '{'");
1075 if (!isIDFIRST_uni(c)) {
1076 croak("unexpected '%c'; expecting an identifier", (int)c);
1079 varname = newSVpvs("$");
1080 if (lex_bufutf8()) {
1084 sv_cat_c(varname, c);
1085 lex_read_unichar(0);
1087 while (c = lex_peek_unichar(0), c != -1 && isIDCONT_uni(c)) {
1088 sv_cat_c(varname, c);
1089 lex_read_unichar(0);
1092 padoff = pad_add_name_sv(varname, padadd_NO_DUP_CHECK, NULL, NULL);
1095 OP *my_var = newOP(OP_PADSV, OPf_MOD | (OPpLVAL_INTRO << 8));
1096 my_var->op_targ = padoff;
1098 vardeclseq = op_append_list(
1116 c = lex_peek_unichar(0);
1121 body = parse_block(0);
1123 return block_end(save_ix, op_append_list(OP_LINESEQ, vardeclseq, body));
1126 #define parse_join_with_space() THX_parse_join_with_space(aTHX)
1127 static OP *THX_parse_join_with_space(pTHX)
1131 args = parse_listexpr(0);
1132 delim = newSVOP(OP_CONST, 0, newSVpvs(" "));
1133 return op_convert_list(OP_JOIN, 0, op_prepend_elem(OP_LIST, delim, args));
1138 #define keyword_active(hintkey_sv) THX_keyword_active(aTHX_ hintkey_sv)
1139 static int THX_keyword_active(pTHX_ SV *hintkey_sv)
1142 if(!GvHV(PL_hintgv)) return 0;
1143 he = hv_fetch_ent(GvHV(PL_hintgv), hintkey_sv, 0,
1144 SvSHARED_HASH(hintkey_sv));
1145 return he && SvTRUE(HeVAL(he));
1148 static int my_keyword_plugin(pTHX_
1149 char *keyword_ptr, STRLEN keyword_len, OP **op_ptr)
1151 if(keyword_len == 3 && strnEQ(keyword_ptr, "rpn", 3) &&
1152 keyword_active(hintkey_rpn_sv)) {
1153 *op_ptr = parse_keyword_rpn();
1154 return KEYWORD_PLUGIN_EXPR;
1155 } else if(keyword_len == 7 && strnEQ(keyword_ptr, "calcrpn", 7) &&
1156 keyword_active(hintkey_calcrpn_sv)) {
1157 *op_ptr = parse_keyword_calcrpn();
1158 return KEYWORD_PLUGIN_STMT;
1159 } else if(keyword_len == 9 && strnEQ(keyword_ptr, "stufftest", 9) &&
1160 keyword_active(hintkey_stufftest_sv)) {
1161 *op_ptr = parse_keyword_stufftest();
1162 return KEYWORD_PLUGIN_STMT;
1163 } else if(keyword_len == 12 &&
1164 strnEQ(keyword_ptr, "swaptwostmts", 12) &&
1165 keyword_active(hintkey_swaptwostmts_sv)) {
1166 *op_ptr = parse_keyword_swaptwostmts();
1167 return KEYWORD_PLUGIN_STMT;
1168 } else if(keyword_len == 8 && strnEQ(keyword_ptr, "looprest", 8) &&
1169 keyword_active(hintkey_looprest_sv)) {
1170 *op_ptr = parse_keyword_looprest();
1171 return KEYWORD_PLUGIN_STMT;
1172 } else if(keyword_len == 14 && strnEQ(keyword_ptr, "scopelessblock", 14) &&
1173 keyword_active(hintkey_scopelessblock_sv)) {
1174 *op_ptr = parse_keyword_scopelessblock();
1175 return KEYWORD_PLUGIN_STMT;
1176 } else if(keyword_len == 10 && strnEQ(keyword_ptr, "stmtasexpr", 10) &&
1177 keyword_active(hintkey_stmtasexpr_sv)) {
1178 *op_ptr = parse_keyword_stmtasexpr();
1179 return KEYWORD_PLUGIN_EXPR;
1180 } else if(keyword_len == 11 && strnEQ(keyword_ptr, "stmtsasexpr", 11) &&
1181 keyword_active(hintkey_stmtsasexpr_sv)) {
1182 *op_ptr = parse_keyword_stmtsasexpr();
1183 return KEYWORD_PLUGIN_EXPR;
1184 } else if(keyword_len == 9 && strnEQ(keyword_ptr, "loopblock", 9) &&
1185 keyword_active(hintkey_loopblock_sv)) {
1186 *op_ptr = parse_keyword_loopblock();
1187 return KEYWORD_PLUGIN_STMT;
1188 } else if(keyword_len == 11 && strnEQ(keyword_ptr, "blockasexpr", 11) &&
1189 keyword_active(hintkey_blockasexpr_sv)) {
1190 *op_ptr = parse_keyword_blockasexpr();
1191 return KEYWORD_PLUGIN_EXPR;
1192 } else if(keyword_len == 9 && strnEQ(keyword_ptr, "swaplabel", 9) &&
1193 keyword_active(hintkey_swaplabel_sv)) {
1194 *op_ptr = parse_keyword_swaplabel();
1195 return KEYWORD_PLUGIN_STMT;
1196 } else if(keyword_len == 10 && strnEQ(keyword_ptr, "labelconst", 10) &&
1197 keyword_active(hintkey_labelconst_sv)) {
1198 *op_ptr = parse_keyword_labelconst();
1199 return KEYWORD_PLUGIN_EXPR;
1200 } else if(keyword_len == 13 && strnEQ(keyword_ptr, "arrayfullexpr", 13) &&
1201 keyword_active(hintkey_arrayfullexpr_sv)) {
1202 *op_ptr = parse_keyword_arrayfullexpr();
1203 return KEYWORD_PLUGIN_EXPR;
1204 } else if(keyword_len == 13 && strnEQ(keyword_ptr, "arraylistexpr", 13) &&
1205 keyword_active(hintkey_arraylistexpr_sv)) {
1206 *op_ptr = parse_keyword_arraylistexpr();
1207 return KEYWORD_PLUGIN_EXPR;
1208 } else if(keyword_len == 13 && strnEQ(keyword_ptr, "arraytermexpr", 13) &&
1209 keyword_active(hintkey_arraytermexpr_sv)) {
1210 *op_ptr = parse_keyword_arraytermexpr();
1211 return KEYWORD_PLUGIN_EXPR;
1212 } else if(keyword_len == 14 && strnEQ(keyword_ptr, "arrayarithexpr", 14) &&
1213 keyword_active(hintkey_arrayarithexpr_sv)) {
1214 *op_ptr = parse_keyword_arrayarithexpr();
1215 return KEYWORD_PLUGIN_EXPR;
1216 } else if(keyword_len == 14 && strnEQ(keyword_ptr, "arrayexprflags", 14) &&
1217 keyword_active(hintkey_arrayexprflags_sv)) {
1218 *op_ptr = parse_keyword_arrayexprflags();
1219 return KEYWORD_PLUGIN_EXPR;
1220 } else if(keyword_len == 5 && strnEQ(keyword_ptr, "DEFSV", 5) &&
1221 keyword_active(hintkey_DEFSV_sv)) {
1222 *op_ptr = parse_keyword_DEFSV();
1223 return KEYWORD_PLUGIN_EXPR;
1224 } else if(keyword_len == 9 && strnEQ(keyword_ptr, "with_vars", 9) &&
1225 keyword_active(hintkey_with_vars_sv)) {
1226 *op_ptr = parse_keyword_with_vars();
1227 return KEYWORD_PLUGIN_STMT;
1228 } else if(keyword_len == 15 && strnEQ(keyword_ptr, "join_with_space", 15) &&
1229 keyword_active(hintkey_join_with_space_sv)) {
1230 *op_ptr = parse_join_with_space();
1231 return KEYWORD_PLUGIN_EXPR;
1233 return next_keyword_plugin(aTHX_ keyword_ptr, keyword_len, op_ptr);
1242 return PL_op->op_next;
1246 peep_xop(pTHX_ OP *o, OP *oldop)
1249 av_push(MY_CXT.xop_record, newSVpvf("peep:%"UVxf, PTR2UV(o)));
1250 av_push(MY_CXT.xop_record, newSVpvf("oldop:%"UVxf, PTR2UV(oldop)));
1254 filter_call(pTHX_ int idx, SV *buf_sv, int maxlen)
1258 int n = FILTER_READ(idx + 1, buf_sv, maxlen);
1262 p = SvPV_force_nolen(buf_sv);
1263 end = p + SvCUR(buf_sv);
1265 if (*p == 'o') *p = 'e';
1268 return SvCUR(buf_sv);
1272 myget_linear_isa(pTHX_ HV *stash, U32 level) {
1273 GV **gvp = (GV **)hv_fetchs(stash, "ISA", 0);
1274 PERL_UNUSED_ARG(level);
1275 return gvp && *gvp && GvAV(*gvp)
1277 : (AV *)sv_2mortal((SV *)newAV());
1281 XS_EXTERNAL(XS_XS__APItest__XSUB_XS_VERSION_undef);
1282 XS_EXTERNAL(XS_XS__APItest__XSUB_XS_VERSION_empty);
1283 XS_EXTERNAL(XS_XS__APItest__XSUB_XS_APIVERSION_invalid);
1285 static struct mro_alg mymro;
1287 static Perl_check_t addissub_nxck_add;
1290 addissub_myck_add(pTHX_ OP *op)
1292 SV **flag_svp = hv_fetchs(GvHV(PL_hintgv), "XS::APItest/addissub", 0);
1295 if (!(flag_svp && SvTRUE(*flag_svp) && (op->op_flags & OPf_KIDS) &&
1296 (aop = cBINOPx(op)->op_first) && (bop = OpSIBLING(aop)) &&
1297 !OpHAS_SIBLING(bop)))
1298 return addissub_nxck_add(aTHX_ op);
1299 flags = op->op_flags;
1300 op_sibling_splice(op, NULL, 1, NULL); /* excise aop */
1301 op_sibling_splice(op, NULL, 1, NULL); /* excise bop */
1302 op_free(op); /* free the empty husk */
1304 return newBINOP(OP_SUBTRACT, flags, aop, bop);
1307 static Perl_check_t old_ck_rv2cv;
1310 my_ck_rv2cv(pTHX_ OP *o)
1313 SV **flag_svp = hv_fetchs(GvHV(PL_hintgv), "XS::APItest/addunder", 0);
1316 if (flag_svp && SvTRUE(*flag_svp) && (o->op_flags & OPf_KIDS)
1317 && (aop = cUNOPx(o)->op_first) && aop->op_type == OP_CONST
1318 && aop->op_private & (OPpCONST_ENTERED|OPpCONST_BARE)
1319 && (ref = cSVOPx(aop)->op_sv) && SvPOK(ref) && SvCUR(ref)
1320 && *(SvEND(ref)-1) == 'o')
1322 SvGROW(ref, SvCUR(ref)+2);
1327 return old_ck_rv2cv(aTHX_ o);
1330 #include "const-c.inc"
1332 MODULE = XS::APItest PACKAGE = XS::APItest
1334 INCLUDE: const-xs.inc
1341 /* this only needs to compile and checks that assert() can be
1342 used this way syntactically */
1343 (void)(assert(x), 1);
1346 MODULE = XS::APItest::utf8 PACKAGE = XS::APItest::utf8
1349 bytes_cmp_utf8(bytes, utf8)
1358 b = (const U8 *)SvPVbyte(bytes, blen);
1359 u = (const U8 *)SvPVbyte(utf8, ulen);
1360 RETVAL = bytes_cmp_utf8(b, blen, u, ulen);
1365 test_utf8n_to_uvchr(s, len, flags)
1376 /* Call utf8n_to_uvchr() with the inputs. It always asks for the
1377 * actual length to be returned
1379 * Length to assume <s> is; not checked, so could have buffer overflow
1382 sv_2mortal((SV*)RETVAL);
1385 = utf8n_to_uvchr((U8*) SvPV(s, slen), SvUV(len), &retlen, SvUV(flags));
1387 /* Returns the return value in [0]; <retlen> in [1] */
1388 av_push(RETVAL, newSVuv(ret));
1389 if (retlen == (STRLEN) -1) {
1390 av_push(RETVAL, newSViv(-1));
1393 av_push(RETVAL, newSVuv(retlen));
1400 test_valid_utf8_to_uvchr(s)
1409 /* Call utf8n_to_uvchr() with the inputs. It always asks for the
1410 * actual length to be returned
1412 * Length to assume <s> is; not checked, so could have buffer overflow
1415 sv_2mortal((SV*)RETVAL);
1418 = valid_utf8_to_uvchr((U8*) SvPV(s, slen), &retlen);
1420 /* Returns the return value in [0]; <retlen> in [1] */
1421 av_push(RETVAL, newSVuv(ret));
1422 av_push(RETVAL, newSVuv(retlen));
1428 test_uvchr_to_utf8_flags(uv, flags)
1433 U8 dest[UTF8_MAXBYTES];
1437 /* Call uvchr_to_utf8_flags() with the inputs. */
1438 ret = uvchr_to_utf8_flags(dest, SvUV(uv), SvUV(flags));
1442 RETVAL = newSVpvn((char *) dest, ret - dest);
1447 MODULE = XS::APItest:Overload PACKAGE = XS::APItest::Overload
1450 amagic_deref_call(sv, what)
1454 /* The reference is owned by something else. */
1455 PUSHs(amagic_deref_call(sv, what));
1457 # I'd certainly like to discourage the use of this macro, given that we now
1458 # have amagic_deref_call
1461 tryAMAGICunDEREF_var(sv, what)
1469 tryAMAGICunDEREF(to_av);
1472 tryAMAGICunDEREF(to_cv);
1475 tryAMAGICunDEREF(to_gv);
1478 tryAMAGICunDEREF(to_hv);
1481 tryAMAGICunDEREF(to_sv);
1484 croak("Invalid value %d passed to tryAMAGICunDEREF_var", what);
1487 /* The reference is owned by something else. */
1490 MODULE = XS::APItest PACKAGE = XS::APItest::XSUB
1493 newXS("XS::APItest::XSUB::XS_VERSION_undef", XS_XS__APItest__XSUB_XS_VERSION_undef, __FILE__);
1494 newXS("XS::APItest::XSUB::XS_VERSION_empty", XS_XS__APItest__XSUB_XS_VERSION_empty, __FILE__);
1495 newXS("XS::APItest::XSUB::XS_APIVERSION_invalid", XS_XS__APItest__XSUB_XS_APIVERSION_invalid, __FILE__);
1498 XS_VERSION_defined(...)
1500 XS_VERSION_BOOTCHECK;
1504 XS_APIVERSION_valid(...)
1506 XS_APIVERSION_BOOTCHECK;
1514 for ( ; i < len; i++ ) {
1515 ST(i) = sv_2mortal( newSViv(i) );
1522 XSRETURN_IV(I32_MIN + 1);
1527 XSRETURN_UV( (U32)((1U<<31) + 1) );
1537 XSRETURN_PV("returned");
1542 XSRETURN_PVN("returned too much",8);
1564 MODULE = XS::APItest:Hash PACKAGE = XS::APItest::Hash
1572 uf.uf_val = rot13_key;
1576 sv_magic((SV*)hash, NULL, PERL_MAGIC_uvar, (char*)&uf, sizeof(uf));
1585 uf.uf_val = bitflip_key;
1589 sv_magic((SV*)hash, NULL, PERL_MAGIC_uvar, (char*)&uf, sizeof(uf));
1592 #define UTF8KLEN(sv, len) (SvUTF8(sv) ? -(I32)len : (I32)len)
1595 exists(hash, key_sv)
1603 key = SvPV(key_sv, len);
1604 RETVAL = hv_exists(hash, key, UTF8KLEN(key_sv, len));
1609 exists_ent(hash, key_sv)
1615 RETVAL = hv_exists_ent(hash, key_sv, 0);
1620 delete(hash, key_sv, flags = 0)
1629 key = SvPV(key_sv, len);
1630 /* It's already mortal, so need to increase reference count. */
1632 = SvREFCNT_inc(hv_delete(hash, key, UTF8KLEN(key_sv, len), flags));
1637 delete_ent(hash, key_sv, flags = 0)
1643 /* It's already mortal, so need to increase reference count. */
1644 RETVAL = SvREFCNT_inc(hv_delete_ent(hash, key_sv, flags, 0));
1649 store_ent(hash, key, value)
1659 result = hv_store_ent(hash, key, copy, 0);
1660 SvSetMagicSV(copy, value);
1665 /* It's about to become mortal, so need to increase reference count.
1667 RETVAL = SvREFCNT_inc(HeVAL(result));
1672 store(hash, key_sv, value)
1683 key = SvPV(key_sv, len);
1685 result = hv_store(hash, key, UTF8KLEN(key_sv, len), copy, 0);
1686 SvSetMagicSV(copy, value);
1691 /* It's about to become mortal, so need to increase reference count.
1693 RETVAL = SvREFCNT_inc(*result);
1698 fetch_ent(hash, key_sv)
1705 result = hv_fetch_ent(hash, key_sv, 0, 0);
1710 RETVAL = newSVsv(HeVAL(result));
1724 key = SvPV(key_sv, len);
1725 result = hv_fetch(hash, key, UTF8KLEN(key_sv, len), 0);
1730 RETVAL = newSVsv(*result);
1734 #if defined (hv_common)
1744 const char *key = NULL;
1752 if ((svp = hv_fetchs(params, "hv", 0))) {
1753 SV *const rv = *svp;
1755 croak("common passed a non-reference for parameter hv");
1756 hv = (HV *)SvRV(rv);
1758 if ((svp = hv_fetchs(params, "keysv", 0)))
1760 if ((svp = hv_fetchs(params, "keypv", 0))) {
1761 key = SvPV_const(*svp, klen);
1765 if ((svp = hv_fetchs(params, "action", 0)))
1766 action = SvIV(*svp);
1767 if ((svp = hv_fetchs(params, "val", 0)))
1768 val = newSVsv(*svp);
1769 if ((svp = hv_fetchs(params, "hash", 0)))
1772 if (hv_fetchs(params, "hash_pv", 0)) {
1774 PERL_HASH(hash, key, klen);
1776 if (hv_fetchs(params, "hash_sv", 0)) {
1780 const char *const p = SvPV(keysv, len);
1781 PERL_HASH(hash, p, len);
1785 result = (HE *)hv_common(hv, keysv, key, klen, flags, action, val, hash);
1790 RETVAL = newSVsv(HeVAL(result));
1799 test_freeent(&Perl_hv_free_ent);
1803 test_hv_delayfree_ent()
1805 test_freeent(&Perl_hv_delayfree_ent);
1809 test_share_unshare_pvn(input)
1818 pvx = SvPV(input, len);
1819 PERL_HASH(hash, pvx, len);
1820 p = sharepvn(pvx, len, hash);
1821 RETVAL = newSVpvn(p, len);
1822 unsharepvn(p, len, hash);
1826 #if PERL_VERSION >= 9
1829 refcounted_he_exists(key, level=0)
1834 croak("level must be zero, not %"IVdf, level);
1836 RETVAL = (cop_hints_fetch_sv(PL_curcop, key, 0, 0) != &PL_sv_placeholder);
1841 refcounted_he_fetch(key, level=0)
1846 croak("level must be zero, not %"IVdf, level);
1848 RETVAL = cop_hints_fetch_sv(PL_curcop, key, 0, 0);
1849 SvREFCNT_inc(RETVAL);
1856 test_force_keys(HV *hv)
1862 he = hv_iternext(hv);
1864 SV *sv = HeSVKEY_force(he);
1867 PUSHs(sv_mortalcopy(sv));
1868 he = hv_iternext(hv);
1873 sub TIEHASH { bless {}, $_[0] }
1874 sub STORE { $_[0]->{$_[1]} = $_[2] }
1875 sub FETCH { $_[0]->{$_[1]} }
1876 sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} }
1877 sub NEXTKEY { each %{$_[0]} }
1878 sub EXISTS { exists $_[0]->{$_[1]} }
1879 sub DELETE { delete $_[0]->{$_[1]} }
1880 sub CLEAR { %{$_[0]} = () }
1884 MODULE = XS::APItest:TempLv PACKAGE = XS::APItest::TempLv
1890 SV * const lv = newSV_type(SVt_PVLV);
1895 sv_magic(lv, NULL, PERL_MAGIC_substr, NULL, 0);
1897 LvTARG(lv) = SvREFCNT_inc_simple(sv);
1898 LvTARGOFF(lv) = len == 0 ? 0 : 1;
1899 LvTARGLEN(lv) = len < 2 ? 0 : len-2;
1902 ST(0) = sv_2mortal(lv);
1906 MODULE = XS::APItest::PtrTable PACKAGE = XS::APItest::PtrTable PREFIX = ptr_table_
1909 ptr_table_new(classname)
1910 const char * classname
1912 PUSHs(sv_setref_pv(sv_newmortal(), classname, (void*)ptr_table_new()));
1916 XS::APItest::PtrTable table
1918 ptr_table_free(table);
1921 ptr_table_store(table, from, to)
1922 XS::APItest::PtrTable table
1926 ptr_table_store(table, from, to);
1929 ptr_table_fetch(table, from)
1930 XS::APItest::PtrTable table
1933 RETVAL = PTR2UV(ptr_table_fetch(table, from));
1938 ptr_table_split(table)
1939 XS::APItest::PtrTable table
1942 ptr_table_clear(table)
1943 XS::APItest::PtrTable table
1945 MODULE = XS::APItest::AutoLoader PACKAGE = XS::APItest::AutoLoader
1950 RETVAL = newSVpvn_flags(SvPVX(cv), SvCUR(cv), SvUTF8(cv));
1958 PERL_UNUSED_ARG(items);
1959 RETVAL = newSVpvn_flags(SvPVX(cv), SvCUR(cv), SvUTF8(cv));
1964 MODULE = XS::APItest PACKAGE = XS::APItest
1969 mymro.resolve = myget_linear_isa;
1970 mymro.name = "justisa";
1974 Perl_mro_register(aTHX_ &mymro);
1979 RETVAL = PL_custom_ops;
1984 xop_custom_op_names ()
1986 PL_custom_op_names = newHV();
1987 RETVAL = PL_custom_op_names;
1992 xop_custom_op_descs ()
1994 PL_custom_op_descs = newHV();
1995 RETVAL = PL_custom_op_descs;
2002 XopENTRY_set(&my_xop, xop_name, "my_xop");
2003 XopENTRY_set(&my_xop, xop_desc, "XOP for testing");
2004 XopENTRY_set(&my_xop, xop_class, OA_UNOP);
2005 XopENTRY_set(&my_xop, xop_peep, peep_xop);
2006 Perl_custom_op_register(aTHX_ pp_xop, &my_xop);
2011 XopDISABLE(&my_xop, xop_name);
2012 XopDISABLE(&my_xop, xop_desc);
2013 XopDISABLE(&my_xop, xop_class);
2014 XopDISABLE(&my_xop, xop_peep);
2019 RETVAL = PTR2IV(&my_xop);
2026 RETVAL = PTR2IV(pp_xop);
2044 MY_CXT.xop_record = newAV();
2046 kid = newSVOP(OP_CONST, 0, newSViv(42));
2048 unop = (UNOP*)mkUNOP(OP_CUSTOM, kid);
2049 unop->op_ppaddr = pp_xop;
2050 unop->op_private = 0;
2051 unop->op_next = NULL;
2052 kid->op_next = (OP*)unop;
2054 av_push(MY_CXT.xop_record, newSVpvf("unop:%"UVxf, PTR2UV(unop)));
2055 av_push(MY_CXT.xop_record, newSVpvf("kid:%"UVxf, PTR2UV(kid)));
2057 av_push(MY_CXT.xop_record, newSVpvf("NAME:%s", OP_NAME((OP*)unop)));
2058 av_push(MY_CXT.xop_record, newSVpvf("DESC:%s", OP_DESC((OP*)unop)));
2059 av_push(MY_CXT.xop_record, newSVpvf("CLASS:%d", (int)OP_CLASS((OP*)unop)));
2061 PL_rpeepp(aTHX_ kid);
2066 RETVAL = MY_CXT.xop_record;
2067 MY_CXT.xop_record = NULL;
2072 xop_from_custom_op ()
2074 /* author note: this test doesn't imply Perl_custom_op_xop is or isn't public
2075 API or that Perl_custom_op_xop is known to be used outside the core */
2079 unop = (UNOP*)mkUNOP(OP_CUSTOM, NULL);
2080 unop->op_ppaddr = pp_xop;
2081 unop->op_private = 0;
2082 unop->op_next = NULL;
2084 xop = Perl_custom_op_xop(aTHX_ (OP *)unop);
2086 RETVAL = PTR2IV(xop);
2095 MY_CXT.sv = newSVpv("initial",0);
2097 MY_CXT.bhkav = get_av("XS::APItest::bhkav", GV_ADDMULTI);
2098 MY_CXT.bhk_record = 0;
2100 BhkENTRY_set(&bhk_test, bhk_start, blockhook_test_start);
2101 BhkENTRY_set(&bhk_test, bhk_pre_end, blockhook_test_pre_end);
2102 BhkENTRY_set(&bhk_test, bhk_post_end, blockhook_test_post_end);
2103 BhkENTRY_set(&bhk_test, bhk_eval, blockhook_test_eval);
2104 Perl_blockhook_register(aTHX_ &bhk_test);
2106 MY_CXT.cscgv = gv_fetchpvs("XS::APItest::COMPILE_SCOPE_CONTAINER",
2107 GV_ADDMULTI, SVt_PVAV);
2108 MY_CXT.cscav = GvAV(MY_CXT.cscgv);
2110 BhkENTRY_set(&bhk_csc, bhk_start, blockhook_csc_start);
2111 BhkENTRY_set(&bhk_csc, bhk_pre_end, blockhook_csc_pre_end);
2112 Perl_blockhook_register(aTHX_ &bhk_csc);
2114 MY_CXT.peep_recorder = newAV();
2115 MY_CXT.rpeep_recorder = newAV();
2117 MY_CXT.orig_peep = PL_peepp;
2118 MY_CXT.orig_rpeep = PL_rpeepp;
2120 PL_rpeepp = my_rpeep;
2127 PERL_UNUSED_VAR(items);
2128 MY_CXT.sv = newSVpv("initial_clone",0);
2129 MY_CXT.cscgv = gv_fetchpvs("XS::APItest::COMPILE_SCOPE_CONTAINER",
2130 GV_ADDMULTI, SVt_PVAV);
2131 MY_CXT.cscav = NULL;
2132 MY_CXT.bhkav = get_av("XS::APItest::bhkav", GV_ADDMULTI);
2133 MY_CXT.bhk_record = 0;
2134 MY_CXT.peep_recorder = newAV();
2135 MY_CXT.rpeep_recorder = newAV();
2141 printf("%5.3f\n",val);
2146 #ifdef HAS_LONG_DOUBLE
2157 #ifdef HAS_LONG_DOUBLE
2158 # if defined(PERL_PRIfldbl) && (LONG_DOUBLESIZE > DOUBLESIZE)
2159 long double val = 7.0;
2160 printf("%5.3" PERL_PRIfldbl "\n",val);
2163 printf("%5.3f\n",val);
2177 printf("%ld\n",val);
2183 printf("%5.3f\n",val);
2231 mXPUSHp("three", 5);
2259 # test_EXTEND(): excerise the EXTEND() macro.
2260 # After calling EXTEND(), it also does *(p+n) = NULL and
2261 # *PL_stack_max = NULL to allow valgrind etc to spot if the stack hasn't
2262 # actually been extended properly.
2264 # max_offset specifies the SP to use. It is treated as a signed offset
2265 # from PL_stack_max.
2266 # nsv is the SV holding the value of n indicating how many slots
2267 # to extend the stack by.
2268 # use_ss is a boolean indicating that n should be cast to a SSize_t
2271 test_EXTEND(max_offset, nsv, use_ss)
2276 SV **sp = PL_stack_max + max_offset;
2279 SSize_t n = (SSize_t)SvIV(nsv);
2288 *PL_stack_max = NULL;
2299 SV * miscsv = sv_newmortal();
2300 HV * hv = (HV*)sv_2mortal((SV*)newHV());
2302 i_sub = get_cv("i", 0);
2304 /* PUTBACK not needed since this sub was called with 0 args, and is calling
2305 0 args, so global SP doesn't need to be moved before a call_* */
2306 retcnt = call_sv((SV*)i_sub, 0); /* try a CV* */
2308 SP -= retcnt; /* dont care about return count, wipe everything off */
2309 sv_setpvs(miscsv, "i");
2311 retcnt = call_sv(miscsv, 0); /* try a PV */
2314 /* no add and SVt_NULL are intentional, sub i should be defined already */
2315 i_gv = gv_fetchpvn_flags("i", sizeof("i")-1, 0, SVt_NULL);
2317 retcnt = call_sv((SV*)i_gv, 0); /* try a GV* */
2320 /* the tests below are not declaring this being public API behavior,
2321 only current internal behavior, these tests can be changed in the
2322 future if necessery */
2324 retcnt = call_sv(&PL_sv_yes, 0); /* does nothing */
2328 retcnt = call_sv(&PL_sv_no, G_EVAL);
2332 errstr = SvPV_nolen(errsv);
2333 if(strnEQ(errstr, "Undefined subroutine &main:: called at",
2334 sizeof("Undefined subroutine &main:: called at") - 1)) {
2336 retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
2341 retcnt = call_sv(&PL_sv_undef, G_EVAL);
2345 errstr = SvPV_nolen(errsv);
2346 if(strnEQ(errstr, "Can't use an undefined value as a subroutine reference at",
2347 sizeof("Can't use an undefined value as a subroutine reference at") - 1)) {
2349 retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
2354 retcnt = call_sv((SV*)hv, G_EVAL);
2358 errstr = SvPV_nolen(errsv);
2359 if(strnEQ(errstr, "Not a CODE reference at",
2360 sizeof("Not a CODE reference at") - 1)) {
2362 retcnt = call_sv((SV*)i_sub, 0); /* call again to increase counter */
2368 call_sv(sv, flags, ...)
2374 for (i=0; i<items-2; i++)
2375 ST(i) = ST(i+2); /* pop first two args */
2379 i = call_sv(sv, flags);
2382 PUSHs(sv_2mortal(newSViv(i)));
2385 call_pv(subname, flags, ...)
2391 for (i=0; i<items-2; i++)
2392 ST(i) = ST(i+2); /* pop first two args */
2396 i = call_pv(subname, flags);
2399 PUSHs(sv_2mortal(newSViv(i)));
2402 call_argv(subname, flags, ...)
2409 for (i=0; i<items-2; i++)
2410 tmpary[i] = SvPV_nolen(ST(i+2)); /* ignore first two args */
2413 i = call_argv(subname, flags, tmpary);
2416 PUSHs(sv_2mortal(newSViv(i)));
2419 call_method(methname, flags, ...)
2425 for (i=0; i<items-2; i++)
2426 ST(i) = ST(i+2); /* pop first two args */
2430 i = call_method(methname, flags);
2433 PUSHs(sv_2mortal(newSViv(i)));
2436 newCONSTSUB(stash, name, flags, sv)
2442 newCONSTSUB_flags = 1
2446 const char *pv = SvPV(name, len);
2450 mycv = newCONSTSUB(stash, pv, SvOK(sv) ? SvREFCNT_inc(sv) : NULL);
2453 mycv = newCONSTSUB_flags(
2454 stash, pv, len, flags | SvUTF8(name), SvOK(sv) ? SvREFCNT_inc(sv) : NULL
2460 PUSHs( CvCONST(mycv) ? &PL_sv_yes : &PL_sv_no );
2461 PUSHs((SV*)CvGV(mycv));
2464 gv_init_type(namesv, multi, flags, type)
2471 const char * const name = SvPV_const(namesv, len);
2472 GV *gv = *(GV**)hv_fetch(PL_defstash, name, len, TRUE);
2474 if (SvTYPE(gv) == SVt_PVGV)
2475 Perl_croak(aTHX_ "GV is already a PVGV");
2476 if (multi) flags |= GV_ADDMULTI;
2479 gv_init(gv, PL_defstash, name, len, multi);
2482 gv_init_sv(gv, PL_defstash, namesv, flags);
2485 gv_init_pv(gv, PL_defstash, name, flags | SvUTF8(namesv));
2488 gv_init_pvn(gv, PL_defstash, name, len, flags | SvUTF8(namesv));
2491 XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
2494 gv_fetchmeth_type(stash, methname, type, level, flags)
2502 const char * const name = SvPV_const(methname, len);
2507 gv = gv_fetchmeth(stash, name, len, level);
2510 gv = gv_fetchmeth_sv(stash, methname, level, flags);
2513 gv = gv_fetchmeth_pv(stash, name, level, flags | SvUTF8(methname));
2516 gv = gv_fetchmeth_pvn(stash, name, len, level, flags | SvUTF8(methname));
2519 XPUSHs( gv ? MUTABLE_SV(gv) : &PL_sv_undef );
2522 gv_fetchmeth_autoload_type(stash, methname, type, level, flags)
2530 const char * const name = SvPV_const(methname, len);
2535 gv = gv_fetchmeth_autoload(stash, name, len, level);
2538 gv = gv_fetchmeth_sv_autoload(stash, methname, level, flags);
2541 gv = gv_fetchmeth_pv_autoload(stash, name, level, flags | SvUTF8(methname));
2544 gv = gv_fetchmeth_pvn_autoload(stash, name, len, level, flags | SvUTF8(methname));
2547 XPUSHs( gv ? MUTABLE_SV(gv) : &PL_sv_undef );
2550 gv_fetchmethod_flags_type(stash, methname, type, flags)
2560 gv = gv_fetchmethod_flags(stash, SvPVX_const(methname), flags);
2563 gv = gv_fetchmethod_sv_flags(stash, methname, flags);
2566 gv = gv_fetchmethod_pv_flags(stash, SvPV_nolen(methname), flags | SvUTF8(methname));
2570 const char * const name = SvPV_const(methname, len);
2571 gv = gv_fetchmethod_pvn_flags(stash, name, len, flags | SvUTF8(methname));
2575 gv = gv_fetchmethod_pvn_flags(stash, SvPV_nolen(methname),
2576 flags, SvUTF8(methname));
2578 XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
2581 gv_autoload_type(stash, methname, type, method)
2588 const char * const name = SvPV_const(methname, len);
2590 I32 flags = method ? GV_AUTOLOAD_ISMETHOD : 0;
2594 gv = gv_autoload4(stash, name, len, method);
2597 gv = gv_autoload_sv(stash, methname, flags);
2600 gv = gv_autoload_pv(stash, name, flags | SvUTF8(methname));
2603 gv = gv_autoload_pvn(stash, name, len, flags | SvUTF8(methname));
2606 XPUSHs( gv ? (SV*)gv : &PL_sv_undef);
2609 gv_const_sv(SV *name)
2614 HV *stash = gv_stashpv("main",0);
2615 HE *he = hv_fetch_ent(stash, name, 0, 0);
2616 gv = (GV *)HeVAL(he);
2621 RETVAL = gv_const_sv(gv);
2624 RETVAL = newSVsv(RETVAL);
2629 whichsig_type(namesv, type)
2634 const char * const name = SvPV_const(namesv, len);
2642 i = whichsig_sv(namesv);
2645 i = whichsig_pv(name);
2648 i = whichsig_pvn(name, len);
2651 XPUSHs(sv_2mortal(newSViv(i)));
2661 i = eval_sv(sv, flags);
2664 PUSHs(sv_2mortal(newSViv(i)));
2667 eval_pv(p, croak_on_error)
2673 PUSHs(eval_pv(p, croak_on_error));
2683 apitest_exception(throw_e)
2693 Perl_croak(aTHX_ "%s", SvPV_nolen(sv));
2696 Perl_croak(aTHX_ NULL);
2702 RETVAL = newRV_inc((SV*)PL_strtab);
2710 RETVAL = my_cxt_getint_p(aMY_CXT);
2719 my_cxt_setint_p(aMY_CXT_ i);
2726 ST(0) = how ? my_cxt_getsv_interp_context() : my_cxt_getsv_interp();
2734 SvREFCNT_dec(MY_CXT.sv);
2735 my_cxt_setsv_p(sv _aMY_CXT);
2739 sv_setsv_cow_hashkey_core()
2742 sv_setsv_cow_hashkey_notcore()
2745 sv_set_deref(SV *sv, SV *sv2, int which)
2749 const char *pv = SvPV(sv2,len);
2750 if (!SvROK(sv)) croak("Not a ref");
2753 case 0: sv_setsv(sv,sv2); break;
2754 case 1: sv_setpv(sv,pv); break;
2755 case 2: sv_setpvn(sv,pv,len); break;
2760 rmagical_cast(sv, type)
2766 if (!SvOK(sv) || !SvROK(sv) || !SvOK(type)) { XSRETURN_UNDEF; }
2768 if (SvTYPE(sv) != SVt_PVHV) { XSRETURN_UNDEF; }
2769 uf.uf_val = rmagical_a_dummy;
2772 if (SvTRUE(type)) { /* b */
2773 sv_magicext(sv, NULL, PERL_MAGIC_ext, &rmagical_b, NULL, 0);
2775 sv_magic(sv, NULL, PERL_MAGIC_uvar, (char *) &uf, sizeof(uf));
2783 if (!SvOK(sv) || !SvROK(sv)) { XSRETURN_UNDEF; }
2786 mXPUSHu(SvFLAGS(sv) & SVs_GMG);
2787 mXPUSHu(SvFLAGS(sv) & SVs_SMG);
2788 mXPUSHu(SvFLAGS(sv) & SVs_RMG);
2795 const PERL_CONTEXT *cx, *dbcx;
2800 cx = caller_cx(level, &dbcx);
2803 pv = CopSTASHPV(cx->blk_oldcop);
2804 ST(0) = pv ? sv_2mortal(newSVpv(pv, 0)) : &PL_sv_undef;
2805 gv = CvGV(cx->blk_sub.cv);
2806 ST(1) = isGV(gv) ? sv_2mortal(newSVpv(GvNAME(gv), 0)) : &PL_sv_undef;
2808 pv = CopSTASHPV(dbcx->blk_oldcop);
2809 ST(2) = pv ? sv_2mortal(newSVpv(pv, 0)) : &PL_sv_undef;
2810 gv = CvGV(dbcx->blk_sub.cv);
2811 ST(3) = isGV(gv) ? sv_2mortal(newSVpv(GvNAME(gv), 0)) : &PL_sv_undef;
2813 ST(4) = cop_hints_fetch_pvs(cx->blk_oldcop, "foo", 0);
2814 ST(5) = cop_hints_fetch_pvn(cx->blk_oldcop, "foo", 3, 0, 0);
2815 ST(6) = cop_hints_fetch_sv(cx->blk_oldcop,
2816 sv_2mortal(newSVpvs("foo")), 0, 0);
2818 hv = cop_hints_2hv(cx->blk_oldcop, 0);
2819 ST(7) = hv ? sv_2mortal(newRV_noinc((SV *)hv)) : &PL_sv_undef;
2828 ST (0) = newSVpv (Perl_sv_peek (aTHX_ sv), 0);
2834 sv_inc(get_sv("XS::APItest::BEGIN_called", GV_ADD|GV_ADDMULTI));
2839 sv_inc(get_sv("XS::APItest::CHECK_called", GV_ADD|GV_ADDMULTI));
2844 sv_inc(get_sv("XS::APItest::UNITCHECK_called", GV_ADD|GV_ADDMULTI));
2849 sv_inc(get_sv("XS::APItest::INIT_called", GV_ADD|GV_ADDMULTI));
2854 sv_inc(get_sv("XS::APItest::END_called", GV_ADD|GV_ADDMULTI));
2857 utf16_to_utf8 (sv, ...)
2860 utf16_to_utf8_reversed = 1
2865 I32 got; /* Gah, badly thought out APIs */
2867 if (ix) (void)SvPV_force_nolen(sv);
2868 source = (U8 *)SvPVbyte(sv, len);
2869 /* Optionally only convert part of the buffer. */
2873 /* Mortalise this right now, as we'll be testing croak()s */
2874 dest = sv_2mortal(newSV(len * 3 / 2 + 1));
2876 utf16_to_utf8_reversed(source, (U8 *)SvPVX(dest), len, &got);
2878 utf16_to_utf8(source, (U8 *)SvPVX(dest), len, &got);
2880 SvCUR_set(dest, got);
2881 SvPVX(dest)[got] = '\0';
2887 my_exit(int exitcode)
2897 s = SvPVbyte(sv, len);
2905 RETVAL = PL_sv_count;
2913 MY_CXT.bhk_record = on;
2915 av_clear(MY_CXT.bhkav);
2921 MAGIC *callmg, *uvarmg;
2923 sv = sv_2mortal(newSV(0));
2924 if (SvTYPE(sv) >= SVt_PVMG) croak_fail();
2925 if (SvMAGICAL(sv)) croak_fail();
2926 sv_magic(sv, &PL_sv_yes, PERL_MAGIC_checkcall, (char*)&callmg, 0);
2927 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2928 if (!SvMAGICAL(sv)) croak_fail();
2929 if (mg_find(sv, PERL_MAGIC_uvar)) croak_fail();
2930 callmg = mg_find(sv, PERL_MAGIC_checkcall);
2931 if (!callmg) croak_fail();
2932 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2934 sv_magic(sv, &PL_sv_no, PERL_MAGIC_uvar, (char*)&uvarmg, 0);
2935 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2936 if (!SvMAGICAL(sv)) croak_fail();
2937 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2938 uvarmg = mg_find(sv, PERL_MAGIC_uvar);
2939 if (!uvarmg) croak_fail();
2940 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2942 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2944 mg_free_type(sv, PERL_MAGIC_vec);
2945 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2946 if (!SvMAGICAL(sv)) croak_fail();
2947 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2948 if (mg_find(sv, PERL_MAGIC_uvar) != uvarmg) croak_fail();
2949 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2951 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2953 mg_free_type(sv, PERL_MAGIC_uvar);
2954 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2955 if (!SvMAGICAL(sv)) croak_fail();
2956 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2957 if (mg_find(sv, PERL_MAGIC_uvar)) croak_fail();
2958 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2960 sv_magic(sv, &PL_sv_no, PERL_MAGIC_uvar, (char*)&uvarmg, 0);
2961 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2962 if (!SvMAGICAL(sv)) croak_fail();
2963 if (mg_find(sv, PERL_MAGIC_checkcall) != callmg) croak_fail();
2964 uvarmg = mg_find(sv, PERL_MAGIC_uvar);
2965 if (!uvarmg) croak_fail();
2966 if (callmg->mg_obj != &PL_sv_yes || callmg->mg_ptr != (char*)&callmg)
2968 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2970 mg_free_type(sv, PERL_MAGIC_checkcall);
2971 if (SvTYPE(sv) < SVt_PVMG) croak_fail();
2972 if (!SvMAGICAL(sv)) croak_fail();
2973 if (mg_find(sv, PERL_MAGIC_uvar) != uvarmg) croak_fail();
2974 if (mg_find(sv, PERL_MAGIC_checkcall)) croak_fail();
2975 if (uvarmg->mg_obj != &PL_sv_no || uvarmg->mg_ptr != (char*)&uvarmg)
2977 mg_free_type(sv, PERL_MAGIC_uvar);
2978 if (SvMAGICAL(sv)) croak_fail();
2979 if (mg_find(sv, PERL_MAGIC_checkcall)) croak_fail();
2980 if (mg_find(sv, PERL_MAGIC_uvar)) croak_fail();
2983 test_op_contextualize()
2987 o = newSVOP(OP_CONST, 0, newSViv(0));
2988 o->op_flags &= ~OPf_WANT;
2989 o = op_contextualize(o, G_SCALAR);
2990 if (o->op_type != OP_CONST ||
2991 (o->op_flags & OPf_WANT) != OPf_WANT_SCALAR)
2994 o = newSVOP(OP_CONST, 0, newSViv(0));
2995 o->op_flags &= ~OPf_WANT;
2996 o = op_contextualize(o, G_ARRAY);
2997 if (o->op_type != OP_CONST ||
2998 (o->op_flags & OPf_WANT) != OPf_WANT_LIST)
3001 o = newSVOP(OP_CONST, 0, newSViv(0));
3002 o->op_flags &= ~OPf_WANT;
3003 o = op_contextualize(o, G_VOID);
3004 if (o->op_type != OP_NULL) croak_fail();
3015 troc_gv = gv_fetchpv("XS::APItest::test_rv2cv_op_cv", 0, SVt_PVGV);
3016 troc_cv = get_cv("XS::APItest::test_rv2cv_op_cv", 0);
3017 o = newCVREF(0, newGVOP(OP_GV, 0, troc_gv));
3018 if (rv2cv_op_cv(o, 0) != troc_cv) croak_fail();
3019 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV) != (CV*)troc_gv)
3021 o->op_private |= OPpENTERSUB_AMPER;
3022 if (rv2cv_op_cv(o, 0)) croak_fail();
3023 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3024 o->op_private &= ~OPpENTERSUB_AMPER;
3025 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3026 if (rv2cv_op_cv(o, RV2CVOPCV_MARK_EARLY) != troc_cv) croak_fail();
3027 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3029 o = newSVOP(OP_CONST, 0, newSVpv("XS::APItest::test_rv2cv_op_cv", 0));
3030 o->op_private = OPpCONST_BARE;
3032 if (rv2cv_op_cv(o, 0) != troc_cv) croak_fail();
3033 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV) != (CV*)troc_gv)
3035 o->op_private |= OPpENTERSUB_AMPER;
3036 if (rv2cv_op_cv(o, 0)) croak_fail();
3037 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3039 o = newCVREF(0, newSVOP(OP_CONST, 0, newRV_inc((SV*)troc_cv)));
3040 if (rv2cv_op_cv(o, 0) != troc_cv) croak_fail();
3041 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV) != (CV*)troc_gv)
3043 o->op_private |= OPpENTERSUB_AMPER;
3044 if (rv2cv_op_cv(o, 0)) croak_fail();
3045 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3046 o->op_private &= ~OPpENTERSUB_AMPER;
3047 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3048 if (rv2cv_op_cv(o, RV2CVOPCV_MARK_EARLY) != troc_cv) croak_fail();
3049 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3051 o = newCVREF(0, newUNOP(OP_RAND, 0, newSVOP(OP_CONST, 0, newSViv(0))));
3052 if (rv2cv_op_cv(o, 0)) croak_fail();
3053 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3054 o->op_private |= OPpENTERSUB_AMPER;
3055 if (rv2cv_op_cv(o, 0)) croak_fail();
3056 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3057 o->op_private &= ~OPpENTERSUB_AMPER;
3058 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3059 if (rv2cv_op_cv(o, RV2CVOPCV_MARK_EARLY)) croak_fail();
3060 if (cUNOPx(o)->op_first->op_private & OPpEARLY_CV) croak_fail();
3062 o = newUNOP(OP_RAND, 0, newSVOP(OP_CONST, 0, newSViv(0)));
3063 if (rv2cv_op_cv(o, 0)) croak_fail();
3064 if (rv2cv_op_cv(o, RV2CVOPCV_RETURN_NAME_GV)) croak_fail();
3068 test_cv_getset_call_checker()
3070 CV *troc_cv, *tsh_cv;
3071 Perl_call_checker ckfun;
3074 #define check_cc(cv, xckfun, xckobj) \
3076 cv_get_call_checker((cv), &ckfun, &ckobj); \
3077 if (ckfun != (xckfun)) croak_fail_ne(FPTR2DPTR(void *, ckfun), xckfun); \
3078 if (ckobj != (xckobj)) croak_fail_ne(FPTR2DPTR(void *, ckobj), xckobj); \
3080 troc_cv = get_cv("XS::APItest::test_rv2cv_op_cv", 0);
3081 tsh_cv = get_cv("XS::APItest::test_savehints", 0);
3082 check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
3083 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
3084 cv_set_call_checker(tsh_cv, Perl_ck_entersub_args_proto_or_list,
3086 check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
3087 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes);
3088 cv_set_call_checker(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
3089 check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
3090 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, &PL_sv_yes);
3091 cv_set_call_checker(tsh_cv, Perl_ck_entersub_args_proto_or_list,
3093 check_cc(troc_cv, THX_ck_entersub_args_scalars, &PL_sv_no);
3094 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
3095 cv_set_call_checker(troc_cv, Perl_ck_entersub_args_proto_or_list,
3097 check_cc(troc_cv, Perl_ck_entersub_args_proto_or_list, (SV*)troc_cv);
3098 check_cc(tsh_cv, Perl_ck_entersub_args_proto_or_list, (SV*)tsh_cv);
3099 if (SvMAGICAL((SV*)troc_cv) || SvMAGIC((SV*)troc_cv)) croak_fail();
3100 if (SvMAGICAL((SV*)tsh_cv) || SvMAGIC((SV*)tsh_cv)) croak_fail();
3104 cv_set_call_checker_lists(CV *cv)
3106 cv_set_call_checker(cv, THX_ck_entersub_args_lists, &PL_sv_undef);
3109 cv_set_call_checker_scalars(CV *cv)
3111 cv_set_call_checker(cv, THX_ck_entersub_args_scalars, &PL_sv_undef);
3114 cv_set_call_checker_proto(CV *cv, SV *proto)
3117 proto = SvRV(proto);
3118 cv_set_call_checker(cv, Perl_ck_entersub_args_proto, proto);
3121 cv_set_call_checker_proto_or_list(CV *cv, SV *proto)
3124 proto = SvRV(proto);
3125 cv_set_call_checker(cv, Perl_ck_entersub_args_proto_or_list, proto);
3128 cv_set_call_checker_multi_sum(CV *cv)
3130 cv_set_call_checker(cv, THX_ck_entersub_multi_sum, &PL_sv_undef);
3142 #define check_ph(EXPR) \
3143 do { if((EXPR) != &PL_sv_placeholder) croak("fail"); } while(0)
3144 #define check_iv(EXPR, EXPECT) \
3145 do { if(SvIV(EXPR) != (EXPECT)) croak("fail"); } while(0)
3146 #define msvpvs(STR) sv_2mortal(newSVpvs(STR))
3147 #define msviv(VALUE) sv_2mortal(newSViv(VALUE))
3148 a = cophh_new_empty();
3149 check_ph(cophh_fetch_pvn(a, "foo_1", 5, 0, 0));
3150 check_ph(cophh_fetch_pvs(a, "foo_1", 0));
3151 check_ph(cophh_fetch_pv(a, "foo_1", 0, 0));
3152 check_ph(cophh_fetch_sv(a, msvpvs("foo_1"), 0, 0));
3153 a = cophh_store_pvn(a, "foo_1abc", 5, 0, msviv(111), 0);
3154 a = cophh_store_pvs(a, "foo_2", msviv(222), 0);
3155 a = cophh_store_pv(a, "foo_3", 0, msviv(333), 0);
3156 a = cophh_store_sv(a, msvpvs("foo_4"), 0, msviv(444), 0);
3157 check_iv(cophh_fetch_pvn(a, "foo_1xyz", 5, 0, 0), 111);
3158 check_iv(cophh_fetch_pvs(a, "foo_1", 0), 111);
3159 check_iv(cophh_fetch_pv(a, "foo_1", 0, 0), 111);
3160 check_iv(cophh_fetch_sv(a, msvpvs("foo_1"), 0, 0), 111);
3161 check_iv(cophh_fetch_pvs(a, "foo_2", 0), 222);
3162 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3163 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3164 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3166 b = cophh_store_pvs(b, "foo_1", msviv(1111), 0);
3167 check_iv(cophh_fetch_pvs(a, "foo_1", 0), 111);
3168 check_iv(cophh_fetch_pvs(a, "foo_2", 0), 222);
3169 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3170 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3171 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3172 check_iv(cophh_fetch_pvs(b, "foo_1", 0), 1111);
3173 check_iv(cophh_fetch_pvs(b, "foo_2", 0), 222);
3174 check_iv(cophh_fetch_pvs(b, "foo_3", 0), 333);
3175 check_iv(cophh_fetch_pvs(b, "foo_4", 0), 444);
3176 check_ph(cophh_fetch_pvs(b, "foo_5", 0));
3177 a = cophh_delete_pvn(a, "foo_1abc", 5, 0, 0);
3178 a = cophh_delete_pvs(a, "foo_2", 0);
3179 b = cophh_delete_pv(b, "foo_3", 0, 0);
3180 b = cophh_delete_sv(b, msvpvs("foo_4"), 0, 0);
3181 check_ph(cophh_fetch_pvs(a, "foo_1", 0));
3182 check_ph(cophh_fetch_pvs(a, "foo_2", 0));
3183 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3184 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3185 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3186 check_iv(cophh_fetch_pvs(b, "foo_1", 0), 1111);
3187 check_iv(cophh_fetch_pvs(b, "foo_2", 0), 222);
3188 check_ph(cophh_fetch_pvs(b, "foo_3", 0));
3189 check_ph(cophh_fetch_pvs(b, "foo_4", 0));
3190 check_ph(cophh_fetch_pvs(b, "foo_5", 0));
3191 b = cophh_delete_pvs(b, "foo_3", 0);
3192 b = cophh_delete_pvs(b, "foo_5", 0);
3193 check_iv(cophh_fetch_pvs(b, "foo_1", 0), 1111);
3194 check_iv(cophh_fetch_pvs(b, "foo_2", 0), 222);
3195 check_ph(cophh_fetch_pvs(b, "foo_3", 0));
3196 check_ph(cophh_fetch_pvs(b, "foo_4", 0));
3197 check_ph(cophh_fetch_pvs(b, "foo_5", 0));
3199 check_ph(cophh_fetch_pvs(a, "foo_1", 0));
3200 check_ph(cophh_fetch_pvs(a, "foo_2", 0));
3201 check_iv(cophh_fetch_pvs(a, "foo_3", 0), 333);
3202 check_iv(cophh_fetch_pvs(a, "foo_4", 0), 444);
3203 check_ph(cophh_fetch_pvs(a, "foo_5", 0));
3204 a = cophh_store_pvs(a, "foo_1", msviv(11111), COPHH_KEY_UTF8);
3205 a = cophh_store_pvs(a, "foo_\xaa", msviv(123), 0);
3207 a = cophh_store_pvs(a, "foo_\xc2\xbb", msviv(456), COPHH_KEY_UTF8);
3209 /* On EBCDIC, we need to translate the UTF-8 in the ASCII test to the
3210 * equivalent UTF-EBCDIC for the code page. This is done at runtime
3211 * (with the helper function in this file). Therefore we can't use
3212 * cophhh_store_pvs(), as we don't have literal string */
3213 key_sv = sv_2mortal(newSVpvs("foo_"));
3214 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xbb"));
3215 key_name = SvPV(key_sv, key_len);
3216 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(456), COPHH_KEY_UTF8);
3219 a = cophh_store_pvs(a, "foo_\xc3\x8c", msviv(789), COPHH_KEY_UTF8);
3221 sv_setpvs(key_sv, "foo_");
3222 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc3\x8c"));
3223 key_name = SvPV(key_sv, key_len);
3224 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(789), COPHH_KEY_UTF8);
3227 a = cophh_store_pvs(a, "foo_\xd9\xa6", msviv(666), COPHH_KEY_UTF8);
3229 sv_setpvs(key_sv, "foo_");
3230 cat_utf8a2n(key_sv, STR_WITH_LEN("\xd9\xa6"));
3231 key_name = SvPV(key_sv, key_len);
3232 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(666), COPHH_KEY_UTF8);
3234 check_iv(cophh_fetch_pvs(a, "foo_1", 0), 11111);
3235 check_iv(cophh_fetch_pvs(a, "foo_1", COPHH_KEY_UTF8), 11111);
3236 check_iv(cophh_fetch_pvs(a, "foo_\xaa", 0), 123);
3238 check_iv(cophh_fetch_pvs(a, "foo_\xc2\xaa", COPHH_KEY_UTF8), 123);
3239 check_ph(cophh_fetch_pvs(a, "foo_\xc2\xaa", 0));
3241 sv_setpvs(key_sv, "foo_");
3242 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xaa"));
3243 key_name = SvPV(key_sv, key_len);
3244 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 123);
3245 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3247 check_iv(cophh_fetch_pvs(a, "foo_\xbb", 0), 456);
3249 check_iv(cophh_fetch_pvs(a, "foo_\xc2\xbb", COPHH_KEY_UTF8), 456);
3250 check_ph(cophh_fetch_pvs(a, "foo_\xc2\xbb", 0));
3252 sv_setpvs(key_sv, "foo_");
3253 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xbb"));
3254 key_name = SvPV(key_sv, key_len);
3255 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 456);
3256 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3258 check_iv(cophh_fetch_pvs(a, "foo_\xcc", 0), 789);
3260 check_iv(cophh_fetch_pvs(a, "foo_\xc3\x8c", COPHH_KEY_UTF8), 789);
3261 check_ph(cophh_fetch_pvs(a, "foo_\xc2\x8c", 0));
3263 sv_setpvs(key_sv, "foo_");
3264 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc3\x8c"));
3265 key_name = SvPV(key_sv, key_len);
3266 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 789);
3267 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3270 check_iv(cophh_fetch_pvs(a, "foo_\xd9\xa6", COPHH_KEY_UTF8), 666);
3271 check_ph(cophh_fetch_pvs(a, "foo_\xd9\xa6", 0));
3273 sv_setpvs(key_sv, "foo_");
3274 cat_utf8a2n(key_sv, STR_WITH_LEN("\xd9\xa6"));
3275 key_name = SvPV(key_sv, key_len);
3276 check_iv(cophh_fetch_pvn(a, key_name, key_len, 0, COPHH_KEY_UTF8), 666);
3277 check_ph(cophh_fetch_pvn(a, key_name, key_len, 0, 0));
3295 cop = &PL_compiling;
3296 Perl_cop_store_label(aTHX_ cop, "foo", 3, 0);
3297 label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
3298 if (strcmp(label,"foo")) croak("fail # cop_fetch_label label");
3299 if (len != 3) croak("fail # cop_fetch_label len");
3300 if (utf8) croak("fail # cop_fetch_label utf8");
3301 /* SMALL GERMAN UMLAUT A */
3302 Perl_cop_store_label(aTHX_ cop, "fo\xc3\xa4", 4, SVf_UTF8);
3303 label = Perl_cop_fetch_label(aTHX_ cop, &len, &utf8);
3304 if (strcmp(label,"fo\xc3\xa4")) croak("fail # cop_fetch_label label");
3305 if (len != 4) croak("fail # cop_fetch_label len");
3306 if (!utf8) croak("fail # cop_fetch_label utf8");
3319 #define msviv(VALUE) sv_2mortal(newSViv(VALUE))
3320 a = cophh_new_empty();
3321 a = cophh_store_pvs(a, "foo_0", msviv(999), 0);
3322 a = cophh_store_pvs(a, "foo_1", msviv(111), 0);
3323 a = cophh_store_pvs(a, "foo_\xaa", msviv(123), 0);
3325 a = cophh_store_pvs(a, "foo_\xc2\xbb", msviv(456), COPHH_KEY_UTF8);
3327 key_sv = sv_2mortal(newSVpvs("foo_"));
3328 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc2\xbb"));
3329 key_name = SvPV(key_sv, key_len);
3330 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(456), COPHH_KEY_UTF8);
3333 a = cophh_store_pvs(a, "foo_\xc3\x8c", msviv(789), COPHH_KEY_UTF8);
3335 sv_setpvs(key_sv, "foo_");
3336 cat_utf8a2n(key_sv, STR_WITH_LEN("\xc3\x8c"));
3337 key_name = SvPV(key_sv, key_len);
3338 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(789), COPHH_KEY_UTF8);
3341 a = cophh_store_pvs(a, "foo_\xd9\xa6", msviv(666), COPHH_KEY_UTF8);
3343 sv_setpvs(key_sv, "foo_");
3344 cat_utf8a2n(key_sv, STR_WITH_LEN("\xd9\xa6"));
3345 key_name = SvPV(key_sv, key_len);
3346 a = cophh_store_pvn(a, key_name, key_len, 0, msviv(666), COPHH_KEY_UTF8);
3348 a = cophh_delete_pvs(a, "foo_0", 0);
3349 a = cophh_delete_pvs(a, "foo_2", 0);
3350 RETVAL = cophh_2hv(a, 0);
3361 #define store_hint(KEY, VALUE) \
3362 sv_setiv_mg(*hv_fetchs(GvHV(PL_hintgv), KEY, 1), (VALUE))
3363 #define hint_ok(KEY, EXPECT) \
3364 ((svp = hv_fetchs(GvHV(PL_hintgv), KEY, 0)) && \
3365 (sv = *svp) && SvIV(sv) == (EXPECT) && \
3366 (sv = cop_hints_fetch_pvs(&PL_compiling, KEY, 0)) && \
3367 SvIV(sv) == (EXPECT))
3368 #define check_hint(KEY, EXPECT) \
3369 do { if (!hint_ok(KEY, EXPECT)) croak_fail(); } while(0)
3370 PL_hints |= HINT_LOCALIZE_HH;
3373 PL_hints &= HINT_INTEGER;
3374 store_hint("t0", 123);
3375 store_hint("t1", 456);
3376 if (PL_hints & HINT_INTEGER) croak_fail();
3377 check_hint("t0", 123); check_hint("t1", 456);
3380 if (PL_hints & HINT_INTEGER) croak_fail();
3381 check_hint("t0", 123); check_hint("t1", 456);
3382 PL_hints |= HINT_INTEGER;
3383 store_hint("t0", 321);
3384 if (!(PL_hints & HINT_INTEGER)) croak_fail();
3385 check_hint("t0", 321); check_hint("t1", 456);
3387 if (PL_hints & HINT_INTEGER) croak_fail();
3388 check_hint("t0", 123); check_hint("t1", 456);
3391 if (PL_hints & HINT_INTEGER) croak_fail();
3392 check_hint("t0", 123); check_hint("t1", 456);
3393 store_hint("t1", 654);
3394 if (PL_hints & HINT_INTEGER) croak_fail();
3395 check_hint("t0", 123); check_hint("t1", 654);
3397 if (PL_hints & HINT_INTEGER) croak_fail();
3398 check_hint("t0", 123); check_hint("t1", 456);
3409 PL_hints |= HINT_LOCALIZE_HH;
3412 sv_setiv_mg(*hv_fetchs(GvHV(PL_hintgv), "t0", 1), 123);
3413 if (SvIV(cop_hints_fetch_pvs(&PL_compiling, "t0", 0)) != 123)
3415 a = newHVhv(GvHV(PL_hintgv));
3417 sv_setiv_mg(*hv_fetchs(a, "t0", 1), 456);
3418 if (SvIV(cop_hints_fetch_pvs(&PL_compiling, "t0", 0)) != 123)
3420 b = hv_copy_hints_hv(a);
3422 sv_setiv_mg(*hv_fetchs(b, "t0", 1), 789);
3423 if (SvIV(cop_hints_fetch_pvs(&PL_compiling, "t0", 0)) != 789)
3432 #define iv_op(iv) newSVOP(OP_CONST, 0, newSViv(iv))
3433 #define check_op(o, expect) \
3435 if (strcmp(test_op_list_describe(o), (expect))) \
3436 croak("fail %s %s", test_op_list_describe(o), (expect)); \
3438 a = op_append_elem(OP_LIST, NULL, NULL);
3440 a = op_append_elem(OP_LIST, iv_op(1), a);
3441 check_op(a, "const(1).");
3442 a = op_append_elem(OP_LIST, NULL, a);
3443 check_op(a, "const(1).");
3444 a = op_append_elem(OP_LIST, a, iv_op(2));
3445 check_op(a, "list[pushmark.const(1).const(2).]");
3446 a = op_append_elem(OP_LIST, a, iv_op(3));
3447 check_op(a, "list[pushmark.const(1).const(2).const(3).]");
3448 a = op_append_elem(OP_LIST, a, NULL);
3449 check_op(a, "list[pushmark.const(1).const(2).const(3).]");
3450 a = op_append_elem(OP_LIST, NULL, a);
3451 check_op(a, "list[pushmark.const(1).const(2).const(3).]");
3452 a = op_append_elem(OP_LIST, iv_op(4), a);
3453 check_op(a, "list[pushmark.const(4)."
3454 "list[pushmark.const(1).const(2).const(3).]]");
3455 a = op_append_elem(OP_LIST, a, iv_op(5));
3456 check_op(a, "list[pushmark.const(4)."
3457 "list[pushmark.const(1).const(2).const(3).]const(5).]");
3458 a = op_append_elem(OP_LIST, a,
3459 op_append_elem(OP_LIST, iv_op(7), iv_op(6)));
3460 check_op(a, "list[pushmark.const(4)."
3461 "list[pushmark.const(1).const(2).const(3).]const(5)."
3462 "list[pushmark.const(7).const(6).]]");
3464 a = op_append_elem(OP_LINESEQ, iv_op(1), iv_op(2));
3465 check_op(a, "lineseq[const(1).const(2).]");
3466 a = op_append_elem(OP_LINESEQ, a, iv_op(3));
3467 check_op(a, "lineseq[const(1).const(2).const(3).]");
3469 a = op_append_elem(OP_LINESEQ,
3470 op_append_elem(OP_LIST, iv_op(1), iv_op(2)),
3472 check_op(a, "lineseq[list[pushmark.const(1).const(2).]const(3).]");
3474 a = op_prepend_elem(OP_LIST, NULL, NULL);
3476 a = op_prepend_elem(OP_LIST, a, iv_op(1));
3477 check_op(a, "const(1).");
3478 a = op_prepend_elem(OP_LIST, a, NULL);
3479 check_op(a, "const(1).");
3480 a = op_prepend_elem(OP_LIST, iv_op(2), a);
3481 check_op(a, "list[pushmark.const(2).const(1).]");
3482 a = op_prepend_elem(OP_LIST, iv_op(3), a);
3483 check_op(a, "list[pushmark.const(3).const(2).const(1).]");
3484 a = op_prepend_elem(OP_LIST, NULL, a);
3485 check_op(a, "list[pushmark.const(3).const(2).const(1).]");
3486 a = op_prepend_elem(OP_LIST, a, NULL);
3487 check_op(a, "list[pushmark.const(3).const(2).const(1).]");
3488 a = op_prepend_elem(OP_LIST, a, iv_op(4));
3489 check_op(a, "list[pushmark."
3490 "list[pushmark.const(3).const(2).const(1).]const(4).]");
3491 a = op_prepend_elem(OP_LIST, iv_op(5), a);
3492 check_op(a, "list[pushmark.const(5)."
3493 "list[pushmark.const(3).const(2).const(1).]const(4).]");
3494 a = op_prepend_elem(OP_LIST,
3495 op_prepend_elem(OP_LIST, iv_op(6), iv_op(7)), a);
3496 check_op(a, "list[pushmark.list[pushmark.const(6).const(7).]const(5)."
3497 "list[pushmark.const(3).const(2).const(1).]const(4).]");
3499 a = op_prepend_elem(OP_LINESEQ, iv_op(2), iv_op(1));
3500 check_op(a, "lineseq[const(2).const(1).]");
3501 a = op_prepend_elem(OP_LINESEQ, iv_op(3), a);
3502 check_op(a, "lineseq[const(3).const(2).const(1).]");
3504 a = op_prepend_elem(OP_LINESEQ, iv_op(3),
3505 op_prepend_elem(OP_LIST, iv_op(2), iv_op(1)));
3506 check_op(a, "lineseq[const(3).list[pushmark.const(2).const(1).]]");
3508 a = op_append_list(OP_LINESEQ, NULL, NULL);
3510 a = op_append_list(OP_LINESEQ, iv_op(1), a);
3511 check_op(a, "const(1).");
3512 a = op_append_list(OP_LINESEQ, NULL, a);
3513 check_op(a, "const(1).");
3514 a = op_append_list(OP_LINESEQ, a, iv_op(2));
3515 check_op(a, "lineseq[const(1).const(2).]");
3516 a = op_append_list(OP_LINESEQ, a, iv_op(3));
3517 check_op(a, "lineseq[const(1).const(2).const(3).]");
3518 a = op_append_list(OP_LINESEQ, iv_op(4), a);
3519 check_op(a, "lineseq[const(4).const(1).const(2).const(3).]");
3520 a = op_append_list(OP_LINESEQ, a, NULL);
3521 check_op(a, "lineseq[const(4).const(1).const(2).const(3).]");
3522 a = op_append_list(OP_LINESEQ, NULL, a);
3523 check_op(a, "lineseq[const(4).const(1).const(2).const(3).]");
3524 a = op_append_list(OP_LINESEQ, a,
3525 op_append_list(OP_LINESEQ, iv_op(5), iv_op(6)));
3526 check_op(a, "lineseq[const(4).const(1).const(2).const(3)."
3527 "const(5).const(6).]");
3529 a = op_append_list(OP_LINESEQ,
3530 op_append_list(OP_LINESEQ, iv_op(1), iv_op(2)),
3531 op_append_list(OP_LIST, iv_op(3), iv_op(4)));
3532 check_op(a, "lineseq[const(1).const(2)."
3533 "list[pushmark.const(3).const(4).]]");
3535 a = op_append_list(OP_LINESEQ,
3536 op_append_list(OP_LIST, iv_op(1), iv_op(2)),
3537 op_append_list(OP_LINESEQ, iv_op(3), iv_op(4)));
3538 check_op(a, "lineseq[list[pushmark.const(1).const(2).]"
3539 "const(3).const(4).]");
3548 #define check_ll(o, expect) \
3550 if (strNE(test_op_linklist_describe(o), (expect))) \
3551 croak("fail %s %s", test_op_linklist_describe(o), (expect)); \
3554 check_ll(o, ".const1");
3557 o = mkUNOP(OP_NOT, iv_op(1));
3558 check_ll(o, ".const1.not");
3561 o = mkUNOP(OP_NOT, mkUNOP(OP_NEGATE, iv_op(1)));
3562 check_ll(o, ".const1.negate.not");
3565 o = mkBINOP(OP_ADD, iv_op(1), iv_op(2));
3566 check_ll(o, ".const1.const2.add");
3569 o = mkBINOP(OP_ADD, mkUNOP(OP_NOT, iv_op(1)), iv_op(2));
3570 check_ll(o, ".const1.not.const2.add");
3573 o = mkUNOP(OP_NOT, mkBINOP(OP_ADD, iv_op(1), iv_op(2)));
3574 check_ll(o, ".const1.const2.add.not");
3577 o = mkLISTOP(OP_LINESEQ, iv_op(1), iv_op(2), iv_op(3));
3578 check_ll(o, ".const1.const2.const3.lineseq");
3581 o = mkLISTOP(OP_LINESEQ,
3582 mkBINOP(OP_ADD, iv_op(1), iv_op(2)),
3583 mkUNOP(OP_NOT, iv_op(3)),
3584 mkLISTOP(OP_SUBSTR, iv_op(4), iv_op(5), iv_op(6)));
3585 check_ll(o, ".const1.const2.add.const3.not"
3586 ".const4.const5.const6.substr.lineseq");
3589 o = mkBINOP(OP_ADD, iv_op(1), iv_op(2));
3591 o = mkBINOP(OP_SUBTRACT, o, iv_op(3));
3592 check_ll(o, ".const1.const2.add.const3.subtract");
3602 av_clear(MY_CXT.peep_recorder);
3603 av_clear(MY_CXT.rpeep_recorder);
3604 MY_CXT.peep_recording = 1;
3611 MY_CXT.peep_recording = 0;
3618 RETVAL = newRV_inc((SV *)MY_CXT.peep_recorder);
3627 RETVAL = newRV_inc((SV *)MY_CXT.rpeep_recorder);
3633 multicall_each: call a sub for each item in the list. Used to test MULTICALL
3638 multicall_each(block,...)
3647 I32 gimme = G_SCALAR;
3648 SV **args = &PL_stack_base[ax];
3654 cv = sv_2cv(block, &stash, &gv, 0);
3656 croak("multicall_each: not a subroutine reference");
3659 SAVESPTR(GvSV(PL_defgv));
3661 for(index = 1 ; index < items ; index++) {
3662 GvSV(PL_defgv) = args[index];
3671 multicall_return(): call the passed sub once in the specificed context
3672 and return whatever it returns
3677 multicall_return(block, context)
3687 I32 gimme = context;
3693 cv = sv_2cv(block, &stash, &gv, 0);
3695 croak("multicall_return not a subroutine reference");
3701 /* copy returned values into an array so they're not freed during
3712 av_push(av, SvREFCNT_inc(TOPs));
3716 for (p = PL_stack_base + 1; p <= SP; p++)
3717 av_push(av, SvREFCNT_inc(*p));
3723 size = AvFILLp(av) + 1;
3725 for (i = 0; i < size; i++)
3726 ST(i) = *av_fetch(av, i, FALSE);
3727 sv_2mortal((SV*)av);
3738 PerlInterpreter *interp = aTHX; /* The original interpreter */
3739 PerlInterpreter *interp_dup; /* The duplicate interpreter */
3740 int oldscope = 1; /* We are responsible for all scopes */
3742 interp_dup = perl_clone(interp, CLONEf_COPY_STACKS | CLONEf_CLONE_HOST );
3744 /* destroy old perl */
3745 PERL_SET_CONTEXT(interp);
3747 POPSTACK_TO(PL_mainstack);
3748 if (cxstack_ix >= 0) {
3750 cx_popblock(cxstack);
3753 PL_scopestack_ix = oldscope;
3756 perl_destruct(interp);
3759 /* switch to new perl */
3760 PERL_SET_CONTEXT(interp_dup);
3762 /* continue after 'clone_with_stack' */
3763 if (interp_dup->Iop)
3764 interp_dup->Iop = interp_dup->Iop->op_next;
3766 /* run with new perl */
3767 Perl_runops_standard(interp_dup);
3769 /* We may have additional unclosed scopes if fork() was called
3770 * from within a BEGIN block. See perlfork.pod for more details.
3771 * We cannot clean up these other scopes because they belong to a
3772 * different interpreter, but we also cannot leave PL_scopestack_ix
3773 * dangling because that can trigger an assertion in perl_destruct().
3775 if (PL_scopestack_ix > oldscope) {
3776 PL_scopestack[oldscope-1] = PL_scopestack[PL_scopestack_ix-1];
3777 PL_scopestack_ix = oldscope;
3780 perl_destruct(interp_dup);
3781 perl_free(interp_dup);
3783 /* call the real 'exit' not PerlProc_exit */
3788 #endif /* USE_ITHREDS */
3791 take_svref(SVREF sv)
3793 RETVAL = newRV_inc(sv);
3800 RETVAL = newRV_inc((SV*)av);
3807 RETVAL = newRV_inc((SV*)hv);
3815 RETVAL = newRV_inc((SV*)cv);
3825 stash = gv_stashpv("XS::APItest::TempLv", 0);
3827 meth = hv_fetchs(stash, "make_temp_mg_lv", 0);
3829 croak("lost method 'make_temp_mg_lv'");
3836 hintkey_rpn_sv = newSVpvs_share("XS::APItest/rpn");
3837 hintkey_calcrpn_sv = newSVpvs_share("XS::APItest/calcrpn");
3838 hintkey_stufftest_sv = newSVpvs_share("XS::APItest/stufftest");
3839 hintkey_swaptwostmts_sv = newSVpvs_share("XS::APItest/swaptwostmts");
3840 hintkey_looprest_sv = newSVpvs_share("XS::APItest/looprest");
3841 hintkey_scopelessblock_sv = newSVpvs_share("XS::APItest/scopelessblock");
3842 hintkey_stmtasexpr_sv = newSVpvs_share("XS::APItest/stmtasexpr");
3843 hintkey_stmtsasexpr_sv = newSVpvs_share("XS::APItest/stmtsasexpr");
3844 hintkey_loopblock_sv = newSVpvs_share("XS::APItest/loopblock");
3845 hintkey_blockasexpr_sv = newSVpvs_share("XS::APItest/blockasexpr");
3846 hintkey_swaplabel_sv = newSVpvs_share("XS::APItest/swaplabel");
3847 hintkey_labelconst_sv = newSVpvs_share("XS::APItest/labelconst");
3848 hintkey_arrayfullexpr_sv = newSVpvs_share("XS::APItest/arrayfullexpr");
3849 hintkey_arraylistexpr_sv = newSVpvs_share("XS::APItest/arraylistexpr");
3850 hintkey_arraytermexpr_sv = newSVpvs_share("XS::APItest/arraytermexpr");
3851 hintkey_arrayarithexpr_sv = newSVpvs_share("XS::APItest/arrayarithexpr");
3852 hintkey_arrayexprflags_sv = newSVpvs_share("XS::APItest/arrayexprflags");
3853 hintkey_DEFSV_sv = newSVpvs_share("XS::APItest/DEFSV");
3854 hintkey_with_vars_sv = newSVpvs_share("XS::APItest/with_vars");
3855 hintkey_join_with_space_sv = newSVpvs_share("XS::APItest/join_with_space");
3856 next_keyword_plugin = PL_keyword_plugin;
3857 PL_keyword_plugin = my_keyword_plugin;
3861 establish_cleanup(...)
3864 PERL_UNUSED_VAR(items);
3865 croak("establish_cleanup called as a function");
3869 CV *estcv = get_cv("XS::APItest::establish_cleanup", 0);
3870 cv_set_call_checker(estcv, THX_ck_entersub_establish_cleanup, (SV*)estcv);
3877 PERL_UNUSED_VAR(items);
3878 croak("postinc called as a function");
3883 filter_add(filter_call, NULL);
3887 CV *asscv = get_cv("XS::APItest::postinc", 0);
3888 cv_set_call_checker(asscv, THX_ck_entersub_postinc, (SV*)asscv);
3896 newRV_noinc(newSV(0)),
3897 gv_stashpvs("XS::APItest::TempObj",GV_ADD)
3898 ); /* Package defined in test script */
3903 fill_hash_with_nulls(HV *hv)
3907 for(; i < 1000; ++i) {
3908 HE *entry = hv_fetch_ent(hv, sv_2mortal(newSVuv(i)), 1, 0);
3909 SvREFCNT_dec(HeVAL(entry));
3910 HeVAL(entry) = NULL;
3916 RETVAL = newHVhv(hv);
3923 RETVAL = SvIsCOW(sv);
3931 PERL_UNUSED_VAR(items);
3932 croak("pad_scalar called as a function");
3936 CV *pscv = get_cv("XS::APItest::pad_scalar", 0);
3937 cv_set_call_checker(pscv, THX_ck_entersub_pad_scalar, (SV*)pscv);
3941 fetch_pad_names( cv )
3945 PADNAMELIST *pad_namelist;
3946 AV *retav = newAV();
3948 pad_namelist = PadlistNAMES(CvPADLIST(cv));
3950 for ( i = PadnamelistMAX(pad_namelist); i >= 0; i-- ) {
3951 PADNAME* name = PadnamelistARRAY(pad_namelist)[i];
3953 if (PadnameLEN(name)) {
3954 av_push(retav, newSVpadname(name));
3957 RETVAL = newRV_noinc((SV*)retav);
3969 u = find_rundefsv();
3970 pv = (U8*)SvPV(u, bytelen);
3971 RETVAL = SvUTF8(u) ? utf8_length(pv, pv+bytelen) : bytelen;
3978 (void)SvPV_nolen(sv);
3983 RETVAL = hv && HvENAME(hv)
3985 HvENAME(hv),HvENAMELEN(hv),
3986 (HvENAMEUTF8(hv) ? SVf_UTF8 : 0)
3993 xs_cmp(int a, int b)
3995 /* Odd sorting (odd numbers first), to make sure we are actually
3997 RETVAL = a % 2 != b % 2
3999 : a < b ? -1 : a == b ? 0 : 1;
4004 xs_cmp_undef(SV *a, SV *b)
4008 RETVAL = &PL_sv_undef;
4015 RETVAL = SvPVbyte_nolen(sv);
4022 RETVAL = SvPVutf8_nolen(sv);
4029 wrap_op_checker(OP_ADD, addissub_myck_add, &addissub_nxck_add);
4032 setup_rv2cv_addunderbar()
4034 wrap_op_checker(OP_RV2CV, my_ck_rv2cv, &old_ck_rv2cv);
4039 test_alloccopstash()
4041 RETVAL = PL_stashpad[alloccopstash(PL_defstash)] == PL_defstash;
4048 test_newFOROP_without_slab()
4051 const I32 floor = start_subparse(0,0);
4053 /* The slab allocator does not like CvROOT being set. */
4054 CvROOT(PL_compcv) = (OP *)1;
4055 o = newFOROP(0, 0, newOP(OP_PUSHMARK, 0), 0, 0);
4056 #ifdef PERL_OP_PARENT
4057 if (cLOOPx(cUNOPo->op_first)->op_last->op_sibparent
4058 != cUNOPo->op_first)
4060 Perl_warn(aTHX_ "Op parent pointer is stale");
4065 /* If we do not crash before returning, the test passes. */
4068 CvROOT(PL_compcv) = NULL;
4069 SvREFCNT_dec(PL_compcv);
4075 # provide access to CALLREGEXEC, except replace pointers within the
4076 # string with offsets from the start of the string
4079 callregexec(SV *prog, STRLEN stringarg, STRLEN strend, I32 minend, SV *sv, U32 nosave)
4086 strbeg = SvPV_force(sv, len);
4087 RETVAL = CALLREGEXEC((REGEXP *)prog,
4100 lexical_import(SV *name, CV *cv)
4107 "lexical_import can only be called at compile time");
4108 pl = CvPADLIST(PL_compcv);
4110 SAVESPTR(PL_comppad_name); PL_comppad_name = PadlistNAMES(pl);
4111 SAVESPTR(PL_comppad); PL_comppad = PadlistARRAY(pl)[1];
4112 SAVESPTR(PL_curpad); PL_curpad = PadARRAY(PL_comppad);
4113 off = pad_add_name_sv(sv_2mortal(newSVpvf("&%"SVf,name)),
4114 padadd_STATE, 0, 0);
4115 SvREFCNT_dec(PL_curpad[off]);
4116 PL_curpad[off] = SvREFCNT_inc(cv);
4122 sv_mortalcopy(SV *sv)
4124 RETVAL = SvREFCNT_inc(sv_mortalcopy(sv));
4132 alias_av(AV *av, IV ix, SV *sv)
4134 av_store(av, ix, SvREFCNT_inc(sv));
4137 cv_name(SVREF ref, ...)
4139 RETVAL = SvREFCNT_inc(cv_name((CV *)ref,
4140 items>1 && ST(1) != &PL_sv_undef
4143 items>2 ? SvUV(ST(2)) : 0));
4148 sv_catpvn(SV *sv, SV *sv2)
4152 const char *s = SvPV(sv2,len);
4153 sv_catpvn_flags(sv,s,len, SvUTF8(sv2) ? SV_CATUTF8 : SV_CATBYTES);
4160 OP *o = newLISTOP(OP_CUSTOM, 0, NULL, NULL);
4162 o = newOP(OP_CUSTOM, 0);
4164 o = newUNOP(OP_CUSTOM, 0, NULL);
4166 o = newUNOP_AUX(OP_CUSTOM, 0, NULL, NULL);
4168 o = newMETHOP(OP_CUSTOM, 0, newOP(OP_NULL,0));
4170 o = newMETHOP_named(OP_CUSTOM, 0, newSV(0));
4172 o = newBINOP(OP_CUSTOM, 0, NULL, NULL);
4174 o = newPMOP(OP_CUSTOM, 0);
4176 o = newSVOP(OP_CUSTOM, 0, newSV(0));
4180 lex_start(NULL, NULL, 0);
4182 I32 ix = start_subparse(FALSE,0);
4183 o = newPADOP(OP_CUSTOM, 0, newSV(0));
4189 o = newPVOP(OP_CUSTOM, 0, NULL);
4191 o = newLOGOP(OP_CUSTOM, 0, newOP(OP_NULL,0), newOP(OP_NULL,0));
4193 o = newLOOPEX(OP_CUSTOM, newOP(OP_NULL,0));
4201 test_sv_catpvf(SV *fmtsv)
4206 fmt = SvPV_nolen(fmtsv);
4207 sv = sv_2mortal(newSVpvn("", 0));
4208 sv_catpvf(sv, fmt, 5, 6, 7, 8);
4211 load_module(flags, name, ...)
4216 Perl_load_module(aTHX_ flags, SvREFCNT_inc(name), NULL);
4217 } else if (items == 3) {
4218 Perl_load_module(aTHX_ flags, SvREFCNT_inc(name), SvREFCNT_inc(ST(2)));
4220 Perl_croak(aTHX_ "load_module can't yet support %"IVdf" items", (IV)items);
4222 MODULE = XS::APItest PACKAGE = XS::APItest::AUTOLOADtest
4228 SV* class_and_method;
4230 PERL_UNUSED_ARG(items);
4231 class_and_method = GvSV(CvGV(cv));
4232 comms = get_sv("main::the_method", 1);
4233 if (class_and_method == NULL) {
4235 } else if (!SvOK(class_and_method)) {
4237 } else if (!SvPOK(class_and_method)) {
4240 sv_setsv(comms, class_and_method);
4246 MODULE = XS::APItest PACKAGE = XS::APItest::Magic
4251 sv_magic_foo(SV *sv, SV *thingy)
4255 sv_magicext(SvRV(sv), NULL, PERL_MAGIC_ext, ix ? &vtbl_bar : &vtbl_foo, (const char *)thingy, 0);
4262 MAGIC *mg = mg_findext(SvRV(sv), PERL_MAGIC_ext, ix ? &vtbl_bar : &vtbl_foo);
4263 RETVAL = mg ? SvREFCNT_inc((SV *)mg->mg_ptr) : &PL_sv_undef;
4268 sv_unmagic_foo(SV *sv)
4272 sv_unmagicext(SvRV(sv), PERL_MAGIC_ext, ix ? &vtbl_bar : &vtbl_foo);
4275 sv_magic(SV *sv, SV *thingy)
4277 sv_magic(SvRV(sv), NULL, PERL_MAGIC_ext, (const char *)thingy, 0);
4285 #define test_get_this_vtable(name) \
4286 want = (MGVTBL*)CAT2(&PL_vtbl_, name); \
4287 have = get_vtbl(CAT2(want_vtbl_, name)); \
4289 croak("fail %p!=%p for get_vtbl(want_vtbl_" STRINGIFY(name) ") at " __FILE__ " line %d", have, want, __LINE__)
4291 test_get_this_vtable(sv);
4292 test_get_this_vtable(env);
4293 test_get_this_vtable(envelem);
4294 test_get_this_vtable(sigelem);
4295 test_get_this_vtable(pack);
4296 test_get_this_vtable(packelem);
4297 test_get_this_vtable(dbline);
4298 test_get_this_vtable(isa);
4299 test_get_this_vtable(isaelem);
4300 test_get_this_vtable(arylen);
4301 test_get_this_vtable(mglob);
4302 test_get_this_vtable(nkeys);
4303 test_get_this_vtable(taint);
4304 test_get_this_vtable(substr);
4305 test_get_this_vtable(vec);
4306 test_get_this_vtable(pos);
4307 test_get_this_vtable(bm);
4308 test_get_this_vtable(fm);
4309 test_get_this_vtable(uvar);
4310 test_get_this_vtable(defelem);
4311 test_get_this_vtable(regexp);
4312 test_get_this_vtable(regdata);
4313 test_get_this_vtable(regdatum);
4314 #ifdef USE_LOCALE_COLLATE
4315 test_get_this_vtable(collxfrm);
4317 test_get_this_vtable(backref);
4318 test_get_this_vtable(utf8);
4320 RETVAL = PTR2UV(get_vtbl(-1));
4325 test_isBLANK_uni(UV ord)
4327 RETVAL = isBLANK_uni(ord);
4332 test_isBLANK_LC_uvchr(UV ord)
4334 RETVAL = isBLANK_LC_uvchr(ord);
4339 test_isBLANK_A(UV ord)
4341 RETVAL = isBLANK_A(ord);
4346 test_isBLANK_L1(UV ord)
4348 RETVAL = isBLANK_L1(ord);
4353 test_isBLANK_LC(UV ord)
4355 RETVAL = isBLANK_LC(ord);
4360 test_isBLANK_utf8(unsigned char * p)
4362 RETVAL = isBLANK_utf8(p);
4367 test_isBLANK_LC_utf8(unsigned char * p)
4369 RETVAL = isBLANK_LC_utf8(p);
4374 test_isVERTWS_uni(UV ord)
4376 RETVAL = isVERTWS_uni(ord);
4381 test_isVERTWS_utf8(unsigned char * p)
4383 RETVAL = isVERTWS_utf8(p);
4388 test_isUPPER_uni(UV ord)
4390 RETVAL = isUPPER_uni(ord);
4395 test_isUPPER_LC_uvchr(UV ord)
4397 RETVAL = isUPPER_LC_uvchr(ord);
4402 test_isUPPER_A(UV ord)
4404 RETVAL = isUPPER_A(ord);
4409 test_isUPPER_L1(UV ord)
4411 RETVAL = isUPPER_L1(ord);
4416 test_isUPPER_LC(UV ord)
4418 RETVAL = isUPPER_LC(ord);
4423 test_isUPPER_utf8(unsigned char * p)
4425 RETVAL = isUPPER_utf8( p);
4430 test_isUPPER_LC_utf8(unsigned char * p)
4432 RETVAL = isUPPER_LC_utf8( p);
4437 test_isLOWER_uni(UV ord)
4439 RETVAL = isLOWER_uni(ord);
4444 test_isLOWER_LC_uvchr(UV ord)
4446 RETVAL = isLOWER_LC_uvchr(ord);
4451 test_isLOWER_A(UV ord)
4453 RETVAL = isLOWER_A(ord);
4458 test_isLOWER_L1(UV ord)
4460 RETVAL = isLOWER_L1(ord);
4465 test_isLOWER_LC(UV ord)
4467 RETVAL = isLOWER_LC(ord);
4472 test_isLOWER_utf8(unsigned char * p)
4474 RETVAL = isLOWER_utf8( p);
4479 test_isLOWER_LC_utf8(unsigned char * p)
4481 RETVAL = isLOWER_LC_utf8( p);
4486 test_isALPHA_uni(UV ord)
4488 RETVAL = isALPHA_uni(ord);
4493 test_isALPHA_LC_uvchr(UV ord)
4495 RETVAL = isALPHA_LC_uvchr(ord);
4500 test_isALPHA_A(UV ord)
4502 RETVAL = isALPHA_A(ord);
4507 test_isALPHA_L1(UV ord)
4509 RETVAL = isALPHA_L1(ord);
4514 test_isALPHA_LC(UV ord)
4516 RETVAL = isALPHA_LC(ord);
4521 test_isALPHA_utf8(unsigned char * p)
4523 RETVAL = isALPHA_utf8( p);
4528 test_isALPHA_LC_utf8(unsigned char * p)
4530 RETVAL = isALPHA_LC_utf8( p);
4535 test_isWORDCHAR_uni(UV ord)
4537 RETVAL = isWORDCHAR_uni(ord);
4542 test_isWORDCHAR_LC_uvchr(UV ord)
4544 RETVAL = isWORDCHAR_LC_uvchr(ord);
4549 test_isWORDCHAR_A(UV ord)
4551 RETVAL = isWORDCHAR_A(ord);
4556 test_isWORDCHAR_L1(UV ord)
4558 RETVAL = isWORDCHAR_L1(ord);
4563 test_isWORDCHAR_LC(UV ord)
4565 RETVAL = isWORDCHAR_LC(ord);
4570 test_isWORDCHAR_utf8(unsigned char * p)
4572 RETVAL = isWORDCHAR_utf8( p);
4577 test_isWORDCHAR_LC_utf8(unsigned char * p)
4579 RETVAL = isWORDCHAR_LC_utf8( p);
4584 test_isALPHANUMERIC_uni(UV ord)
4586 RETVAL = isALPHANUMERIC_uni(ord);
4591 test_isALPHANUMERIC_LC_uvchr(UV ord)
4593 RETVAL = isALPHANUMERIC_LC_uvchr(ord);
4598 test_isALPHANUMERIC_A(UV ord)
4600 RETVAL = isALPHANUMERIC_A(ord);
4605 test_isALPHANUMERIC_L1(UV ord)
4607 RETVAL = isALPHANUMERIC_L1(ord);
4612 test_isALPHANUMERIC_LC(UV ord)
4614 RETVAL = isALPHANUMERIC_LC(ord);
4619 test_isALPHANUMERIC_utf8(unsigned char * p)
4621 RETVAL = isALPHANUMERIC_utf8( p);
4626 test_isALPHANUMERIC_LC_utf8(unsigned char * p)
4628 RETVAL = isALPHANUMERIC_LC_utf8( p);
4633 test_isALNUM_uni(UV ord)
4635 RETVAL = isALNUM_uni(ord);
4640 test_isALNUM_LC_uvchr(UV ord)
4642 RETVAL = isALNUM_LC_uvchr(ord);
4647 test_isALNUM_LC(UV ord)
4649 RETVAL = isALNUM_LC(ord);
4654 test_isALNUM_utf8(unsigned char * p)
4656 RETVAL = isALNUM_utf8( p);
4661 test_isALNUM_LC_utf8(unsigned char * p)
4663 RETVAL = isALNUM_LC_utf8( p);
4668 test_isDIGIT_uni(UV ord)
4670 RETVAL = isDIGIT_uni(ord);
4675 test_isDIGIT_LC_uvchr(UV ord)
4677 RETVAL = isDIGIT_LC_uvchr(ord);
4682 test_isDIGIT_utf8(unsigned char * p)
4684 RETVAL = isDIGIT_utf8( p);
4689 test_isDIGIT_LC_utf8(unsigned char * p)
4691 RETVAL = isDIGIT_LC_utf8( p);
4696 test_isDIGIT_A(UV ord)
4698 RETVAL = isDIGIT_A(ord);
4703 test_isDIGIT_L1(UV ord)
4705 RETVAL = isDIGIT_L1(ord);
4710 test_isDIGIT_LC(UV ord)
4712 RETVAL = isDIGIT_LC(ord);
4717 test_isOCTAL_A(UV ord)
4719 RETVAL = isOCTAL_A(ord);
4724 test_isOCTAL_L1(UV ord)
4726 RETVAL = isOCTAL_L1(ord);
4731 test_isIDFIRST_uni(UV ord)
4733 RETVAL = isIDFIRST_uni(ord);
4738 test_isIDFIRST_LC_uvchr(UV ord)
4740 RETVAL = isIDFIRST_LC_uvchr(ord);