diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-15 23:48:59 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-15 23:48:59 +0000 |
commit | 87ff4b24ae4911bda46a5426024959c278da69b2 (patch) | |
tree | 4598a48b30055b1824cadc12354c3d4e259a07f8 /ext/fiddle/closure.c | |
parent | 8977d3e30c225ba17e6ed542875b320d3d8bd3e1 (diff) | |
download | ruby-87ff4b24ae4911bda46a5426024959c278da69b2.tar.gz |
* ext/.document (fiddle): Remove duplicate entry
* ext/fiddle: Complete documentation of Fiddle. Patch by Vincent
Batts. [#5192]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 */ |