On Thu, Feb 24, 2000 at 04:05:20PM +0000, Hugo wrote: > This XS code: > > int > MyClass::method() > > .. checks the THIS argument like this: > > if (sv_derived_from(ST(0), "MyClassPtr")) { > IV tmp = SvIV((SV*)SvRV(ST(0))); > THIS = INT2PTR(MyClass *,tmp); > } > else > croak("THIS is not of type MyClassPtr"); > > .. which is a problem, since the method will be invoked by perl on a > MyClass object, not on a MyClassPtr object. I'm not sure what the right > solution is for this - has anyone successfully used this type of > invocation? (I note that it does not appear to be documented in perlxs.) I think the method may also be invoked on a MyClassPtr if the typemap says "MyClass * T_PTROBJ". The problem comes with an API that uses both pointers to structs and passing of whole structs. So the typemap has MyClass * T_PTROBJ MyClass T_OPAQUE_STRUCT For example MyStruct foo(); int bar(MyStruct *); There seems to be an "impeadance mismatch" between the way T_PTROBJ and T_OPAQUE_STRUCT. Ideally it should be easy to create a T_PTROBJ style blessed ref from a T_OPAQUE_STRUCT style blessed ref, but it's not. Tim.Thread Previous