diff --git a/docs/embed.pod b/docs/embed.pod
index 84df8c4..14f001c 100644
a
|
b
|
|
1379 | 1379 | |
1380 | 1380 | =item C<Parrot_PMC_substr> |
1381 | 1381 | |
1382 | | =item C<Parrot_PMC_substr_str> |
1383 | | |
1384 | 1382 | =item C<Parrot_PMC_subtract> |
1385 | 1383 | |
1386 | 1384 | =item C<Parrot_PMC_subtract_float> |
diff --git a/docs/pdds/pdd17_pmc.pod b/docs/pdds/pdd17_pmc.pod
index 1f1431c..3e2f5a4 100644
a
|
b
|
|
1356 | 1356 | |
1357 | 1357 | =item substr |
1358 | 1358 | |
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) |
1361 | 1360 | |
1362 | 1361 | Extracts the string starting at I<offset> with size I<length> and return |
1363 | 1362 | it as a PMC in I<dest> or as a string return value. |
diff --git a/docs/pdds/pdd28_strings.pod b/docs/pdds/pdd28_strings.pod
index b7ec5c2..6eb16b2 100644
a
|
b
|
|
702 | 702 | =item substr |
703 | 703 | |
704 | 704 | Extract 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 |
710 | 705 | graphemes) and return the string. |
711 | 706 | |
712 | 707 | =item exists_keyed |
diff --git a/src/ops/core_ops.c b/src/ops/core_ops.c
index 53512e1..fcd4c35 100644
a
|
b
|
|
20397 | 20397 | |
20398 | 20398 | opcode_t * |
20399 | 20399 | Parrot_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)); |
20401 | 20401 | PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); |
20402 | 20402 | return (opcode_t *)cur_opcode + 5; |
20403 | 20403 | } |
20404 | 20404 | |
20405 | 20405 | opcode_t * |
20406 | 20406 | Parrot_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)); |
20408 | 20408 | PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); |
20409 | 20409 | return (opcode_t *)cur_opcode + 5; |
20410 | 20410 | } |
20411 | 20411 | |
20412 | 20412 | opcode_t * |
20413 | 20413 | Parrot_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)); |
20415 | 20415 | PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); |
20416 | 20416 | return (opcode_t *)cur_opcode + 5; |
20417 | 20417 | } |
20418 | 20418 | |
20419 | 20419 | opcode_t * |
20420 | 20420 | Parrot_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)); |
20422 | 20422 | PARROT_GC_WRITE_BARRIER(interp, CURRENT_CONTEXT(interp)); |
20423 | 20423 | return (opcode_t *)cur_opcode + 5; |
20424 | 20424 | } |
diff --git a/src/ops/string.ops b/src/ops/string.ops
index d3ce85f..4e6ce44 100644
a
|
b
|
|
261 | 261 | } |
262 | 262 | |
263 | 263 | inline 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); |
265 | 265 | } |
266 | 266 | |
267 | 267 | inline op replace(out STR, in STR, in INT, in INT, in STR) :base_core { |
diff --git a/src/pmc/scalar.pmc b/src/pmc/scalar.pmc
index 79bf4d3..8c35b9b 100644
a
|
b
|
|
819 | 819 | |
820 | 820 | /* |
821 | 821 | |
822 | | =item C<STRING *substr_str(INTVAL offset, INTVAL length)> |
| 822 | =item C<STRING *substr(INTVAL offset, INTVAL length)> |
823 | 823 | |
824 | 824 | Returns the substring of length C<length> of the scalar starting at |
825 | 825 | C<offset>. |
… |
… |
|
828 | 828 | |
829 | 829 | */ |
830 | 830 | |
831 | | VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { |
| 831 | VTABLE STRING *substr(INTVAL offset, INTVAL length) { |
832 | 832 | return STRING_substr(INTERP, VTABLE_get_string(INTERP, SELF), |
833 | 833 | offset, length); |
834 | 834 | } |
diff --git a/src/pmc/string.pmc b/src/pmc/string.pmc
index 289d0f4..7967e50 100644
a
|
b
|
|
345 | 345 | |
346 | 346 | /* |
347 | 347 | |
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)> |
366 | 349 | |
367 | 350 | Extracts the substring starting at C<offset>, with size |
368 | 351 | C<length>, and returns it. |
… |
… |
|
370 | 353 | =cut |
371 | 354 | |
372 | 355 | */ |
373 | | VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { |
| 356 | VTABLE STRING *substr(INTVAL offset, INTVAL length) { |
374 | 357 | STRING *str_val; |
375 | 358 | GET_ATTR_str_val(INTERP, SELF, str_val); |
376 | 359 | return STRING_substr(INTERP, str_val, offset, length); |
diff --git a/src/pmc/stringbuilder.pmc b/src/pmc/stringbuilder.pmc
index 8310749..24f864c 100644
a
|
b
|
|
309 | 309 | |
310 | 310 | /* |
311 | 311 | |
312 | | =item C<VTABLE substr_str()> |
| 312 | =item C<VTABLE substr()> |
313 | 313 | |
314 | 314 | =cut |
315 | 315 | |
316 | 316 | */ |
317 | 317 | |
318 | | VTABLE STRING *substr_str(INTVAL offset, INTVAL length) { |
| 318 | VTABLE STRING *substr(INTVAL offset, INTVAL length) { |
319 | 319 | STRING *buffer; |
320 | 320 | GET_ATTR_buffer(INTERP, SELF, buffer); |
321 | 321 | /* We must clone here becase we can reallocate buffer behind the scene... */ |
diff --git a/src/vtable.tbl b/src/vtable.tbl
index 6691e70..52b6289 100644
a
|
b
|
|
206 | 206 | void i_repeat(PMC* value) :write |
207 | 207 | void i_repeat_int(INTVAL value) :write |
208 | 208 | |
209 | | void substr(INTVAL offset, INTVAL length, PMC* dest) |
210 | | STRING* substr_str(INTVAL offset, INTVAL length) |
| 209 | STRING* substr(INTVAL offset, INTVAL length) |
211 | 210 | |
212 | 211 | [EXISTS] |
213 | 212 | INTVAL exists_keyed(PMC* key) |
diff --git a/t/src/extend_vtable.t b/t/src/extend_vtable.t
index ad70267..c5dc563 100644
a
|
b
|
|
10 | 10 | |
11 | 11 | plan skip_all => 'src/parrot_config.o does not exist' unless -e catfile(qw/src parrot_config.o/); |
12 | 12 | |
13 | | plan tests => 139; |
| 13 | plan tests => 138; |
14 | 14 | |
15 | 15 | =head1 NAME |
16 | 16 | |
… |
… |
|
458 | 458 | |
459 | 459 | Parrot_PMC_assign_string_native(interp, pmc_string, string); |
460 | 460 | |
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); |
474 | 462 | Parrot_printf(interp, "%S\n", string2); |
475 | 463 | CODE |
476 | 464 | F |
diff --git a/tools/dev/vtablize.pl b/tools/dev/vtablize.pl
index c9da536..b4ea8e1 100755
a
|
b
|
|
182 | 182 | s/^(\s*)(PMC\s+\*repeat_int\(INTVAL\s+\w*,\s+PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; |
183 | 183 | s/^(\s*)(void\s+i_repeat\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; |
184 | 184 | s/^(\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/; |
| 185 | s/^(\s*)(STRING\s+\*substr\(INTVAL\s+\w*,\s+INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; |
187 | 186 | s/^(\s*)(INTVAL\s+exists_keyed\(PMC\s+\*\w*\)\s+{)/$1VTABLE $2/; |
188 | 187 | s/^(\s*)(INTVAL\s+exists_keyed_int\(INTVAL\s+\w*\)\s+{)/$1VTABLE $2/; |
189 | 188 | s/^(\s*)(INTVAL\s+exists_keyed_str\(STRING\s+\*\w*\)\s+{)/$1VTABLE $2/; |