Changes between Initial Version and Version 7 of Ticket #218

Show
Ignore:
Timestamp:
04/20/09 10:58:53 (6 years ago)
Author:
bacek
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #218

    • Property status changed from new to assigned
    • Property component changed from none to core
    • Property platform changed from to all
    • Property milestone changed from to 1.0
    • Property owner set to whiteknight
  • Ticket #218 – description

    initial v7  
    1 I would expect the following code to print out 'a' twice, once for each type. 
     1This patch solves the ticket. But I'm not sure how "kosher" is it. 
    22 
    33{{{ 
    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 
     4diff --git a/src/pmc/fixedpmcarray.pmc b/src/pmc/fixedpmcarray.pmc 
     5index 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. 
    3237}}} 
    33  
    34 Instead, it generates: 
    35  
    36 {{{ 
    37 a 
    38 Method 'sort' not found for invocant of class 'RPA' 
    39 current instr.: 'sortme' pc 53 (foo.pir:21) 
    40 called from Sub 'main' pc 25 (foo.pir:10) 
    41 }}} 
    42  
    43 sort is a method on FixedPMCArray; it's inherited by ResizablePMCArray. It is apparently then NOT inherited by my PIR level subclass.