[KinoSearch] Subclassable Highlighter

Marvin Humphrey marvin at rectangular.com
Tue Jan 29 23:16:49 PST 2008




On Jan 29, 2008, at 6:05 PM, Father Chrysostomos wrote:

> And attached is a HeatMap implementation, only partly tested.

This looks about right, so I went ahead and committed it as r2969,  
without either serious review or any tests.

> BTW, if the overload problem is getting in your way, you can apply  
> this quick fix for now:
>
> bless $self, ref $self if $] < 5.01; # kludge to be replaced later

I think I have it solved.  In 5.8.8, it's the ref that carries the  
SVf_AMAGIC flag, while in 5.10.0, it's the inner object.  KS objects,  
on creation, keep the inner Perl object around, increment its  
refcount by 1, and discard the outer ref.  Then, when we need a Perl  
object for them, Kino_Obj_To_Native gets called:

     void*
     kino_Obj_to_native(kino_Obj *self)
     {
         return newRV_inc((SV*)self->ref.native);
     }

For whatever reason, newRV_inc hasn't been setting the SVf_AMAGIC  
flag, even when the class has overload magic.  The solution is to  
override To_Native for the Doc class:

     void*
     kino_Doc_to_native(kino_Doc *self)
     {
         SV *perl_obj = kino_Obj_to_native((kino_Obj*)self); /* SUPER */
     #if PERL_VERSION < 9
         /* In perl 5.8, the OVERLOAD magic flag is carried in the  
ref, while in
          * 5.10, it is carried in the inner object. */
         SvAMAGIC_on(perl_obj);
     #endif
         return perl_obj;
     }

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/



_______________________________________________
KinoSearch mailing list
KinoSearch at rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch




More information about the kinosearch mailing list