Ticket #1682: tt1682.diff

File tt1682.diff, 8.0 KB (added by jkeenan, 11 years ago)

Eliminate VTABLE_substr; rename substr_str to substr

  • docs/embed.pod

    diff --git a/docs/embed.pod b/docs/embed.pod
    index 84df8c4..14f001c 100644
    a b  
    13791379 
    13801380=item C<Parrot_PMC_substr> 
    13811381 
    1382 =item C<Parrot_PMC_substr_str> 
    1383  
    13841382=item C<Parrot_PMC_subtract> 
    13851383 
    13861384=item C<Parrot_PMC_subtract_float> 
  • docs/pdds/pdd17_pmc.pod

    diff --git a/docs/pdds/pdd17_pmc.pod b/docs/pdds/pdd17_pmc.pod
    index 1f1431c..3e2f5a4 100644
    a b  
    13561356 
    13571357=item substr 
    13581358 
    1359   void substr(INTERP, PMC *self, INTVAL offset, INTVAL length, PMC *dest) 
    1360   STRING* substr_str(INTERP, PMC *self, INTVAL offset, INTVAL length) 
     1359  STRING* substr(INTERP, PMC *self, INTVAL offset, INTVAL length) 
    13611360 
    13621361Extracts the string starting at I<offset> with size I<length> and return 
    13631362it as a PMC in I<dest> or as a string return value. 
  • docs/pdds/pdd28_strings.pod

    diff --git a/docs/pdds/pdd28_strings.pod b/docs/pdds/pdd28_strings.pod
    index b7ec5c2..6eb16b2 100644
    a b  
    702702=item substr 
    703703 
    704704Extract a substring of a given length starting from a given offset (in 
    705 graphemes) and store the result in the string argument. 
    706  
    707 =item substr_str 
    708  
    709 Extract a substring of a given length starting from a given offset (in 
    710705graphemes) and return the string. 
    711706 
    712707=item exists_keyed 
  • src/ops/core_ops.c

    diff --git a/src/ops/core_ops.c b/src/ops/core_ops.c
    index 53512e1..fcd4c35 100644
    a b  
    2039720397 
    2039820398opcode_t * 
    2039920399Parrot_substr_s_p_i_i(opcode_t *cur_opcode, PARROT_INTERP) { 
    20400     SREG(1) = VTABLE_substr_str(interp, PREG(2), IREG(3), IREG(4)); 
     20400    SREG(1) = VTABLE_substr(interp, PREG(2), IREG(3), IREG(4)); 
    2040120401    PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); 
    2040220402    return (opcode_t *)cur_opcode + 5; 
    2040320403} 
    2040420404 
    2040520405opcode_t * 
    2040620406Parrot_substr_s_p_ic_i(opcode_t *cur_opcode, PARROT_INTERP) { 
    20407     SREG(1) = VTABLE_substr_str(interp, PREG(2), ICONST(3), IREG(4)); 
     20407    SREG(1) = VTABLE_substr(interp, PREG(2), ICONST(3), IREG(4)); 
    2040820408    PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); 
    2040920409    return (opcode_t *)cur_opcode + 5; 
    2041020410} 
    2041120411 
    2041220412opcode_t * 
    2041320413Parrot_substr_s_p_i_ic(opcode_t *cur_opcode, PARROT_INTERP) { 
    20414     SREG(1) = VTABLE_substr_str(interp, PREG(2), IREG(3), ICONST(4)); 
     20414    SREG(1) = VTABLE_substr(interp, PREG(2), IREG(3), ICONST(4)); 
    2041520415    PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); 
    2041620416    return (opcode_t *)cur_opcode + 5; 
    2041720417} 
    2041820418 
    2041920419opcode_t * 
    2042020420Parrot_substr_s_p_ic_ic(opcode_t *cur_opcode, PARROT_INTERP) { 
    20421     SREG(1) = VTABLE_substr_str(interp, PREG(2), ICONST(3), ICONST(4)); 
     20421    SREG(1) = VTABLE_substr(interp, PREG(2), ICONST(3), ICONST(4)); 
    2042220422    PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); 
    2042320423    return (opcode_t *)cur_opcode + 5; 
    2042420424} 
  • src/ops/string.ops

    diff --git a/src/ops/string.ops b/src/ops/string.ops
    index d3ce85f..4e6ce44 100644
    a b  
    261261} 
    262262 
    263263inline op substr(out STR, invar PMC, in INT, in INT) :base_core { 
    264     $1 = VTABLE_substr_str(interp, $2, $3, $4); 
     264    $1 = VTABLE_substr(interp, $2, $3, $4); 
    265265} 
    266266 
    267267inline op replace(out STR, in STR, in INT, in INT, in STR) :base_core { 
  • src/pmc/scalar.pmc

    diff --git a/src/pmc/scalar.pmc b/src/pmc/scalar.pmc
    index 79bf4d3..8c35b9b 100644
    a b  
    819819 
    820820/* 
    821821 
    822 =item C<STRING *substr_str(INTVAL offset, INTVAL length)> 
     822=item C<STRING *substr(INTVAL offset, INTVAL length)> 
    823823 
    824824Returns the substring of length C<length> of the scalar starting at 
    825825C<offset>. 
     
    828828 
    829829*/ 
    830830 
    831     VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { 
     831    VTABLE STRING *substr(INTVAL offset, INTVAL length) { 
    832832        return STRING_substr(INTERP, VTABLE_get_string(INTERP, SELF), 
    833833                offset, length); 
    834834    } 
  • src/pmc/string.pmc

    diff --git a/src/pmc/string.pmc b/src/pmc/string.pmc
    index 289d0f4..7967e50 100644
    a b  
    345345 
    346346/* 
    347347 
    348 =item C<void substr(INTVAL offset, INTVAL length, PMC *dest)> 
    349  
    350 Extracts the substring starting at C<offset>, with size 
    351 C<length>, and places it in C<dest>. 
    352  
    353 =cut 
    354  
    355 */ 
    356     VTABLE void substr(INTVAL offset, INTVAL length, PMC *dest) { 
    357         STRING *str_val, *s2; 
    358         GET_ATTR_str_val(INTERP, SELF, str_val); 
    359         s2 = STRING_substr(INTERP, str_val, offset, length); 
    360         VTABLE_set_string_native(INTERP, dest, s2); 
    361     } 
    362  
    363 /* 
    364  
    365 =item C<STRING *substr_str(INTVAL offset, INTVAL length)> 
     348=item C<STRING *substr(INTVAL offset, INTVAL length)> 
    366349 
    367350Extracts the substring starting at C<offset>, with size 
    368351C<length>, and returns it. 
     
    370353=cut 
    371354 
    372355*/ 
    373     VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { 
     356    VTABLE STRING *substr(INTVAL offset, INTVAL length) { 
    374357        STRING *str_val; 
    375358        GET_ATTR_str_val(INTERP, SELF, str_val); 
    376359        return STRING_substr(INTERP, str_val, offset, length); 
  • src/pmc/stringbuilder.pmc

    diff --git a/src/pmc/stringbuilder.pmc b/src/pmc/stringbuilder.pmc
    index 8310749..24f864c 100644
    a b  
    309309 
    310310/* 
    311311 
    312 =item C<VTABLE substr_str()> 
     312=item C<VTABLE substr()> 
    313313 
    314314=cut 
    315315 
    316316*/ 
    317317 
    318     VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { 
     318    VTABLE STRING *substr(INTVAL offset, INTVAL length) { 
    319319        STRING *buffer; 
    320320        GET_ATTR_buffer(INTERP, SELF, buffer); 
    321321        /* We must clone here becase we can reallocate buffer behind the scene... */ 
  • src/vtable.tbl

    diff --git a/src/vtable.tbl b/src/vtable.tbl
    index 6691e70..52b6289 100644
    a b  
    206206void i_repeat(PMC* value) :write 
    207207void i_repeat_int(INTVAL value) :write 
    208208 
    209 void substr(INTVAL offset, INTVAL length, PMC* dest) 
    210 STRING* substr_str(INTVAL offset, INTVAL length) 
     209STRING* substr(INTVAL offset, INTVAL length) 
    211210 
    212211[EXISTS] 
    213212INTVAL exists_keyed(PMC* key) 
  • t/src/extend_vtable.t

    diff --git a/t/src/extend_vtable.t b/t/src/extend_vtable.t
    index ad70267..c5dc563 100644
    a b  
    1010 
    1111plan skip_all => 'src/parrot_config.o does not exist' unless -e catfile(qw/src parrot_config.o/); 
    1212 
    13 plan tests => 139; 
     13plan tests => 138; 
    1414 
    1515=head1 NAME 
    1616 
     
    458458 
    459459     Parrot_PMC_assign_string_native(interp, pmc_string, string); 
    460460 
    461      Parrot_PMC_substr(interp, pmc_string, 0, 2, pmc_string2); 
    462      Parrot_printf(interp, "%P\n", pmc_string2); 
    463 CODE 
    464 FO 
    465 Done! 
    466 OUTPUT 
    467  
    468 extend_vtable_output_is(<<'CODE', <<'OUTPUT', "Parrot_PMC_substr_str" ); 
    469      string  = createstring(interp, "FOO"); 
    470  
    471      Parrot_PMC_assign_string_native(interp, pmc_string, string); 
    472  
    473      string2 = Parrot_PMC_substr_str(interp, pmc_string, 0, 1); 
     461     string2 = Parrot_PMC_substr(interp, pmc_string, 0, 1); 
    474462     Parrot_printf(interp, "%S\n", string2); 
    475463CODE 
    476464F 
  • tools/dev/vtablize.pl

    diff --git a/tools/dev/vtablize.pl b/tools/dev/vtablize.pl
    index c9da536..b4ea8e1 100755
    a b  
    182182s/^(\s*)(PMC\s+\*repeat_int\(INTVAL\s+\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; 
    183183s/^(\s*)(void\s+i_repeat\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; 
    184184s/^(\s*)(void\s+i_repeat_int\(INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; 
    185 s/^(\s*)(void\s+substr\(INTVAL\s+\w*,\s+INTVAL\s+\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; 
    186 s/^(\s*)(STRING\s+\*substr_str\(INTVAL\s+\w*,\s+INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; 
     185s/^(\s*)(STRING\s+\*substr\(INTVAL\s+\w*,\s+INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; 
    187186s/^(\s*)(INTVAL\s+exists_keyed\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; 
    188187s/^(\s*)(INTVAL\s+exists_keyed_int\(INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; 
    189188s/^(\s*)(INTVAL\s+exists_keyed_str\(STRING\s+\*\w*\)\s+{)/$1VTABLE $2/;