in reply to Re^3: Overload '+=' with XSub
in thread Overload '+=' with XSub
Also:#define Inline_Stack_Push(x) XPUSHs(x)
In Inline::C, we have to Inline_Stack_Return(x) if we wish to return anything from a 'void' function. Since Inline::C and XS are essentially one and the same thing, I expected that we would have to explicitly XSRETURN(x) from an XSub (if we wanted to return anything).#define Inline_Stack_Return(x) XSRETURN(x)
but still got the same failure with the '+=" operator. (Again, when explicitly calling overload_add_eq($obj, $addon, 0); there's no problem.)void overload_add_eq(SV * obj, SV * addon, SV * third) { dXSARGS; Card* c = (Card *)SvIV(SvRV(obj)); c->value += SvIV(addon); XPUSHs(obj); }
and that worked fine with the '+=' overloading ... and no increase to the refcount !!! It also worked fine when I explicitly called overload_add_eq($obj, $addon, 0);(This might even constitute "progress".)void overload_add_eq(SV * obj, SV * addon, SV * third) { dXSARGS; Card* c = (Card *)SvIV(SvRV(obj)); c->value += SvIV(addon); XPUSHs(obj); XSRETURN(1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Overload '+=' with XSub
by Anno (Deacon) on Mar 29, 2007 at 17:30 UTC |