# Ahh now we are getting to the meat and potatoes of this monster. # Most of this mess is generated by h2xs, but let's see what else we got. #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" # This line being ABOVE the "MODULE =" line is critical, as everything above that line is treated as pure C++ # Anything below it is in XS macro land. #include "SimpleLib/Simple.h" using namespace std; MODULE = Simple PACKAGE = Simple # The constructor. Kind of looks like C++ here. I pass in an "int". Simple * Simple::new( y ) int y # I have no idea how "SimplePtr" became a valid keyword, but somehow the XS engine realizes that it is the return type of the constructor. # It's magic to me, for now. MODULE = Simple PACKAGE = SimplePtr # Here is some basic XS, the documentation on this is covered pretty well in "Extending and Embedding Perl", specifically chapters 2 and 6. int Simple::add(x) int x OUTPUT: RETVAL string Simple::get_string(z) string z OUTPUT: RETVAL StringMap Simple::getMap(myMap) StringMap myMap OUTPUT: RETVAL StringVector Simple::getVec(myVec) StringVector myVec OUTPUT: RETVAL