1 ################################################################################ 2 # 3 # Copyright (c) 2002-2020 Marcus Holland-Moritz. All rights reserved. 4 # This program is free software; you can redistribute it and/or modify 5 # it under the same terms as Perl itself. 6 # 7 ################################################################################ 8 9 10 ################################################################################ 11 # 12 # METHOD: Include / Define / Assert 13 # 14 # WRITTEN BY: Marcus Holland-Moritz ON: Mar 2002 15 # CHANGED BY: ON: 16 # 17 ################################################################################ 18 19 void 20 CBC::Include(...) 21 ALIAS: 22 Define = 1 23 Assert = 2 24 25 PREINIT: 26 CBC_METHOD_VAR; 27 LinkedList list; 28 int hasRval; 29 SV *rval, *inval; 30 31 PPCODE: 32 switch (ix) 33 { 34 case 1: /* Define */ 35 CBC_METHOD_SET("Define"); 36 list = THIS->cfg.defines; 37 break; 38 case 2: /* Assert */ 39 CBC_METHOD_SET("Assert"); 40 list = THIS->cfg.assertions; 41 break; 42 default: /* Include */ 43 CBC_METHOD_SET("Include"); 44 list = THIS->cfg.includes; 45 break; 46 } 47 48 CT_DEBUG_METHOD; 49 50 hasRval = GIMME_V != G_VOID && items <= 1; 51 52 if (GIMME_V == G_VOID && items <= 1) 53 { 54 WARN_VOID_CONTEXT; 55 XSRETURN_EMPTY; 56 } 57 58 if (items > 1 && !SvROK(ST(1))) 59 { 60 int i; 61 inval = NULL; 62 63 for (i = 1; i < items; i++) 64 { 65 if (SvROK(ST(i))) 66 Perl_croak(aTHX_ "Argument %d to %s must not be a reference", i, method); 67 68 LL_push(list, string_new_fromSV(aTHX_ ST(i))); 69 } 70 } 71 else 72 { 73 if (items > 2) 74 Perl_croak(aTHX_ "Invalid number of arguments to %s", method); 75 76 inval = items == 2 ? ST(1) : NULL; 77 } 78 79 if (inval != NULL || hasRval) 80 handle_string_list(aTHX_ method, list, inval, hasRval ? &rval : NULL); 81 82 if (hasRval) 83 ST(0) = sv_2mortal(rval); 84 85 reset_preprocessor(&THIS->cpi); 86 87 XSRETURN(1); 88 89 90