Hello,
I want to define class in xs file. Create it in perl and call some of it's functions.
I do like it's described in perlxsdoc:
XS file:
class color { public: color(); ~color(); }; MODULE = Mytest PACKAGE = Mytest void color::DESTROY() color * color::new()
I also create a typemap file:
1. TYPEMAP 2. color * O_OBJECT 3. 4. OUTPUT 5. # The Perl object is blessed into 'CLASS', which should be a 6. # char* having the name of the package for the blessing. 7. O_OBJECT 8. sv_setref_pv( $arg, CLASS, (void*)$var ); 9. 10. INPUT 11. O_OBJECT 12. if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) 13. $var = ($type)SvIV((SV*)SvRV( $arg )); 14. else{ 15. warn( \"${Package}::$func_name() -- $var is not a blessed SV ref +erence\" ); 16. XSRETURN_UNDEF; 17. }
Then in perl file I write:
But I get an error : Cannot locate object method "new" via package color (perhaps you forgot to load color&)my $x = new color();
What's wrong here?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |