| 4 | | .sub main |
| 5 | | sortme('ResizablePMCArray') |
| 6 | | |
| 7 | | $P1 = get_class 'ResizablePMCArray' |
| 8 | | $P0 = subclass $P1, 'RPA' |
| 9 | | |
| 10 | | sortme('RPA') |
| 11 | | |
| 12 | | .end |
| 13 | | |
| 14 | | .sub sortme |
| 15 | | .param string type |
| 16 | | $P0 = new type |
| 17 | | $P0[0]='z' |
| 18 | | $P0[1]='a' |
| 19 | | .local pmc comparator |
| 20 | | comparator = get_global 'ascii' |
| 21 | | $P0.'sort'(comparator) |
| 22 | | $S0 = $P0[0] |
| 23 | | say $S0 |
| 24 | | .end |
| 25 | | |
| 26 | | .sub ascii |
| 27 | | .param string a |
| 28 | | .param string b |
| 29 | | $I0 = cmp_str a,b |
| 30 | | .return($I0) |
| 31 | | .end |
| | 4 | diff --git a/src/pmc/fixedpmcarray.pmc b/src/pmc/fixedpmcarray.pmc |
| | 5 | index 6eb6e9f..4146ca4 100644 |
| | 6 | --- a/src/pmc/fixedpmcarray.pmc |
| | 7 | +++ b/src/pmc/fixedpmcarray.pmc |
| | 8 | @@ -47,7 +47,7 @@ Sort this array, optionally using the provided cmp_func |
| | 9 | const INTVAL n = SELF.elements(); |
| | 10 | |
| | 11 | if (n > 1) |
| | 12 | - Parrot_quicksort(interp, (void **)PMC_array(SELF), n, cmp_func); |
| | 13 | + Parrot_quicksort(interp, (void **)SELF.get_pointer(), n, cmp_func); |
| | 14 | } |
| | 15 | |
| | 16 | /* |
| | 17 | @@ -144,6 +144,19 @@ fixed sized array). |
| | 18 | |
| | 19 | /* |
| | 20 | |
| | 21 | +=item C<void *get_pointer()> |
| | 22 | + |
| | 23 | +Get pointer to stored data. Used in sort method. |
| | 24 | + |
| | 25 | +=cut |
| | 26 | + |
| | 27 | +*/ |
| | 28 | + |
| | 29 | + VTABLE void * get_pointer() { |
| | 30 | + return PMC_array(SELF); |
| | 31 | + } |
| | 32 | +/* |
| | 33 | + |
| | 34 | =item C<INTVAL get_integer()> |
| | 35 | |
| | 36 | Returns the number of elements in the array. |