On Mon, 2007-09-10 at 11:15 +0200, Scott Lanning wrote:

> I think it's a bug (or lack of C++ functionality) in xsubpp,
> but I'm not ruling out a self-introduced problem.  :)

Yep, xsubpp's OVERLOAD support is broken.

Here's what's lacking:

> XS(XS_Ogre__Animation_nil); /* prototype to pass -Wmissing-prototypes */
> XS(XS_Ogre__Animation_nil)
> {
      dXSARGS;
      PERL_UNUSED_VAR (items);
>     XSRETURN_EMPTY;       <--- line 11158
> }

> XS(boot_Ogre); /* prototype to pass -Wmissing-prototypes */
> XS(boot_Ogre)
> {
>      dXSARGS;
>      char* file = __FILE__;
> 
>      XS_VERSION_BOOTCHECK ;
> 
>      {
>          CV * cv ;
> 
>      /* register the overloading (type 'A') magic */
>      PL_amagic_generation++;
>      /* The magic for overload gets a GV* via gv_fetchmeth as */
>      /* mentioned above, and looks in the SV* slot of it for */
>      /* the "fallback" status. */
>      sv_setsv(          <----  line 11180
>          get_sv( "Ogre::Animation::()", TRUE ),
>          PL_sv_undef
           &PL_sv_undef
>      );
>      /* Making a sub named "Ogre::Animation::()" allows the package */
>      /* to be findable via fetchmethod(), and causes */
>      /* overload::Overloaded("Ogre::Animation") to return true. */
>      newXS("Ogre::Animation::()", XS_Ogre__Animation_nil, file);
>          cv = newXS("Ogre::TFO_NONE", XS_Ogre_TFO_NONE, file);
>          XSANY.any_i32 = 0 ;
>          sv_setpv((SV*)cv, "$") ;

Oh, and I just stumbled upon
<http://rt.cpan.org/Public/Bug/Display.html?id=31533> which is about
this problem and which suggests the exact same fixes.

As a workaround, I suggest removing the OVERLOAD stuff from your XS code
and putting something like this in your .pm file:

package Ogre::Animation;

use overload
        '==' => sub { \&Ogre::Animation::cmp },
        fallback => 1;

-- 
Bye,
-Torsten

Reply via email to