Warning: everything here is subject to change. I am just picking names and moving code around arbitrarily, more as a proof of concept.
In Mac OS X:
pudge% perl -Iblib/arch -Iblib/lib -MMac::Carbon -MMac::Memory -wle '$x = new Handle "abc"; print $x->get(0, -1); $y = new Handle ("x" x 2**30); print Mac::Carbon::Error(); print $y->size'
Can't call method "size" on an undefined value at -e line 1.
In MacPerl on Classic, to look up the error:
print $^E = -116
Size check failed (OS error -116)
So I got everything to compile and work. It'd be nice to have Error() be $^E, but that isn't likely for right now, as I believe it needs core support, and even then, I don't know if it would be feasible (are Carbon/Cocoa values compatible? how do you tell them apart, if not?). If they are the same, great, I can set $^E now via SETERRNO, and perhaps add the needed support later to get the text of the error message, and in the meantime supply a function to look up the text of the error message.
I am probably going to implement the missing C functions in Mac::Carbon (name, like everything else, subject to change), and require Mac::Carbon be loaded at the beginning of all other modules that need it. That'll work.
So the next step is to implement those missing GUSI functions and compile more extensions.
I'll need to redo most of this, though; I am modifying the generated C files, because MacPerl uses a custom xsubpp, and these
Again, this is all subject to change.