Scott Lanning
2007-09-07 09:40:38 UTC
Hello extension interfacers,
I'm doing bindings for a C++ library,
and I have many problems/questions, of which this is one.
I've tried following the docs for "The OVERLOAD: Keyword"
in `perldoc perlxs`; however, I don't really understand
the syntax for it:
SV *
cmp (lobj, robj, swap)
My_Module_obj lobj
My_Module_obj robj
IV swap
OVERLOAD: cmp <=>
{ /* function defined here */}
I always get weird errors suggesting a parsing problem.
Here's a final bizarre attempt to mimic the above:
bool
cmp(lobj, robj, swap)
Vector3 * lobj
Vector3 * robj
IV swap
OVERLOAD: ==
{
RETVAL = (*lobj == *robj);
}
Before that I'd tried also with
Vector3::cmp(lobj, robj, swap)
and without the curly braces but with CODE and OUTPUT blocks.
I ended up just making an `eq_xs' function and using
that with `use overload' from the Perl module,
but for no particular reason I think I'd prefer
to do it all from XS if possible.
I'm doing bindings for a C++ library,
and I have many problems/questions, of which this is one.
I've tried following the docs for "The OVERLOAD: Keyword"
in `perldoc perlxs`; however, I don't really understand
the syntax for it:
SV *
cmp (lobj, robj, swap)
My_Module_obj lobj
My_Module_obj robj
IV swap
OVERLOAD: cmp <=>
{ /* function defined here */}
I always get weird errors suggesting a parsing problem.
Here's a final bizarre attempt to mimic the above:
bool
cmp(lobj, robj, swap)
Vector3 * lobj
Vector3 * robj
IV swap
OVERLOAD: ==
{
RETVAL = (*lobj == *robj);
}
Before that I'd tried also with
Vector3::cmp(lobj, robj, swap)
and without the curly braces but with CODE and OUTPUT blocks.
I ended up just making an `eq_xs' function and using
that with `use overload' from the Perl module,
but for no particular reason I think I'd prefer
to do it all from XS if possible.