diff options
Diffstat (limited to 'ext/fiddle/closure.c')
-rw-r--r-- | ext/fiddle/closure.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index 48520997bc..542d978395 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -224,11 +224,55 @@ to_i(VALUE self) void Init_fiddle_closure() { +#if 0 + mFiddle = rb_define_module("Fiddle"); /* let rdoc know about mFiddle */ +#endif + + /* + * Document-class: Fiddle::Closure + * + * == Description + * + * An FFI closure wrapper, for handling callbacks. + * + * == Example + * + * closure = Class.new(Fiddle::Closure) { + * def call + * 10 + * end + * }.new(Fiddle::TYPE_INT, []) + * => #<#<Class:0x0000000150d308>:0x0000000150d240> + * func = Fiddle::Function.new(closure, [], Fiddle::TYPE_INT) + * => #<Fiddle::Function:0x00000001516e58> + * func.call + * => 10 + */ cFiddleClosure = rb_define_class_under(mFiddle, "Closure", rb_cObject); rb_define_alloc_func(cFiddleClosure, allocate); + /* + * Document-method: new + * + * call-seq: new(ret, *args, abi = Fiddle::DEFAULT) + * + * Construct a new Closure object. + * + * * +ret+ is the C type to be returned + * * +args+ are passed the callback + * * +abi+ is the abi of the closure + * + * If there is an error in preparing the ffi_cif or ffi_prep_closure, + * then a RuntimeError will be raised. + */ rb_define_method(cFiddleClosure, "initialize", initialize, -1); + + /* + * Document-method: to_i + * + * Returns the memory address for this closure + */ rb_define_method(cFiddleClosure, "to_i", to_i, 0); } /* vim: set noet sw=4 sts=4 */ |