#218: can't sort a PIR subclass of an RPA.
--------------------+-------------------------------------------------------
Reporter: coke | Owner: whiteknight
Type: bug | Status: assigned
Priority: normal | Milestone: 1.1
Component: core | Version:
Severity: high | Keywords: tcl blocker
Lang: | Patch:
Platform: all |
--------------------+-------------------------------------------------------
Description changed by bacek:
Old description:
> This patch solves the ticket. But I'm not sure how "kosher" is it.
>
> {{{
> diff --git a/src/pmc/fixedpmcarray.pmc b/src/pmc/fixedpmcarray.pmc
> index 6eb6e9f..4146ca4 100644
> --- a/src/pmc/fixedpmcarray.pmc
> +++ b/src/pmc/fixedpmcarray.pmc
> @@ -47,7 +47,7 @@ Sort this array, optionally using the provided cmp_func
> const INTVAL n = SELF.elements();
>
> if (n > 1)
> - Parrot_quicksort(interp, (void **)PMC_array(SELF), n,
> cmp_func);
> + Parrot_quicksort(interp, (void **)SELF.get_pointer(), n,
> cmp_func);
> }
>
> /*
> @@ -144,6 +144,19 @@ fixed sized array).
>
> /*
>
> +=item C<void *get_pointer()>
> +
> +Get pointer to stored data. Used in sort method.
> +
> +=cut
> +
> +*/
> +
> + VTABLE void * get_pointer() {
> + return PMC_array(SELF);
> + }
> +/*
> +
> =item C<INTVAL get_integer()>
>
> Returns the number of elements in the array.
> }}}
New description:
I would expect the following code to print out 'a' twice, once for each
type.
This patch solves the ticket. But I'm not sure how "kosher" is it.
{{{
.sub main
sortme('ResizablePMCArray')
$P1 = get_class 'ResizablePMCArray'
$P0 = subclass $P1, 'RPA'
sortme('RPA')
.end
.sub sortme
.param string type
$P0 = new type
$P0[0]='z'
$P0[1]='a'
.local pmc comparator
comparator = get_global 'ascii'
$P0.'sort'(comparator)
$S0 = $P0[0]
say $S0
.end
.sub ascii
.param string a
.param string b
$I0 = cmp_str a,b
.return($I0)
.end
}}}
Instead, it generates:
{{{
a
Method 'sort' not found for invocant of class 'RPA'
current instr.: 'sortme' pc 53 (foo.pir:21)
called from Sub 'main' pc 25 (foo.pir:10)
}}}
sort is a method on FixedPMCArray; it's inherited by esizablePMCArray. It
is apparently then NOT inherited by my PIR level subclass.
--
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/218#comment:8>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets