On Sat, 8 Sep 2007, Steve Fink wrote:
What error message are you getting?

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

I added this to xs/Vector3.xs :

bool
equals(lobj, robj, swap)
    Vector3 * lobj
    Vector3 * robj
    IV        swap
  OVERLOAD: ==
  CODE:
    RETVAL = (*lobj == *robj);
  OUTPUT:
    RETVAL

(Note: I couldn't figure out the correct syntax
either from the documentation nor from *attempting*
to read the code for `xsubpp`.)

When I do `make`, the error is :

Ogre.c: In function 'void XS_Ogre__Animation_nil(PerlInterpreter*, CV*)':
Ogre.c:11158: error: 'ax' was not declared in this scope
Ogre.c: In function 'void boot_Ogre(PerlInterpreter*, CV*)':
Ogre.c:11180: error: cannot convert 'sv' to 'SV*' for argument '3' to 'void Perl_sv_setsv_flags(PerlInterpreter*, SV*, SV*, I32)'
make: *** [Ogre.o] Error 1


In Ogre.c, I find :

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


Note that it has generated OVERLOAD stuff for
the package Ogre::Animation, not Ogre::Vector3 !

Then :

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
    );
    /* 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, "$") ;


Thinking that it might be due to how I use INCLUDE to drag
in the xs/*.xs files from Ogre.xs,
I put the contents of Vector3.xs into Ogre.xs.
The same error results during `make`,
but this time the class is correctly Ogre::Animation.

I also tried explicit INCLUDEs for every file,
instead of the script that currently INCLUDEs them.

I didn't try putting the content of all xs/*.xs files
into Ogre.xs in order to rule out that it's just
the fact that INCLUDE is used anywhere.
I hope it isn't necessary to put all the XS in one file..



If anything in the overloaded function is not in your typemap, the
generated C code is completely bogus (syntactically incorrect.)

It's very delicate, XS...

Reply via email to