Here's a Ruby interface to STAF. The actual connection
is done in STAFHandle.c, but STAFCommand.rb is a more
Ruby-like (I hope)
way of going about it. To compile it:
/* get handles to those classes.
the handles must be based on the STAF module, since that's
where the classes are defined. */
rb_eSTAFException = rb_const_get(module, rb_intern("STAFException"));
rb_eSTAFInvalidObjectException = rb_const_get(module, rb_intern("STAFInvalidObjectException"));
rb_eSTAFInvalidParmException = rb_const_get(module, rb_intern("STAFInvalidParmException"));
rb_eSTAFBaseOSErrorException = rb_const_get(module, rb_intern("STAFBaseOSErrorException"));
rb_cSTAFResult = rb_const_get(module, rb_intern("STAFResult"));
Ruby/STAF library
Logged In: YES
user_id=2195695
Originator: NO
For build the wrapper on Windows platform, I modified some content in STAFHandle.c.
Just for referral if you're trying to build this via VS2005.
__declspec(dllexport) void Init_STAFHandle()
{
/* define a module named 'STAF' */
VALUE module = rb_define_module("STAF");
/* require helper classes */
rb_require("staf/STAFException.rb");
rb_require("staf/STAFResult.rb");
/* get handles to those classes.
the handles must be based on the STAF module, since that's
where the classes are defined. */
rb_eSTAFException = rb_const_get(module, rb_intern("STAFException"));
rb_eSTAFInvalidObjectException = rb_const_get(module, rb_intern("STAFInvalidObjectException"));
rb_eSTAFInvalidParmException = rb_const_get(module, rb_intern("STAFInvalidParmException"));
rb_eSTAFBaseOSErrorException = rb_const_get(module, rb_intern("STAFBaseOSErrorException"));
rb_cSTAFResult = rb_const_get(module, rb_intern("STAFResult"));
/* define the STAFHandle class */
rb_cSTAFHandle = rb_define_class_under(module, "STAFHandle", rb_cObject);
rb_define_singleton_method(rb_cSTAFHandle, "new", (VALUE (__cdecl *)(...))sh_new, -1);
rb_define_method(rb_cSTAFHandle, "initialize", (VALUE (__cdecl *)(...))sh_init, -1);
rb_define_method(rb_cSTAFHandle, "submit", (VALUE (__cdecl *)(...))sh_submit, 3);
rb_define_method(rb_cSTAFHandle, "to_s", (VALUE (__cdecl *)(...))sh_tos, 0);
}
FWIW, I've written a new set of Ruby bindings for STAF. Unlike the attached patch, it fully supports marshalling and unmarshalling. It can be found at
https://bitbucket.org/asomers/staf4ruby and
https://rubygems.org/gems/staf4ruby/versions/0.1.2
Though it could also be merged into STAF itself, if STAF's maintainers so choose.
Thank you for contributing your work to enhance STAF.