本文簡要介紹ruby語言中 Fiddle::Closure類
的用法。
說明
FFI 閉包包裝器,用於處理回調。
示例
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
相關用法
- Ruby ClosedError類用法及代碼示例
- Ruby Class類用法及代碼示例
- Ruby Class.superclass用法及代碼示例
- Ruby Class.inherited用法及代碼示例
- Ruby Class.new用法及代碼示例
- Ruby Class.allocate用法及代碼示例
- Ruby Class.file用法及代碼示例
- Ruby Class.subclasses用法及代碼示例
- Ruby CStructEntity.[]=用法及代碼示例
- Ruby Context.save_history=用法及代碼示例
- Ruby CSV.header_convert用法及代碼示例
- Ruby Constants模塊用法及代碼示例
- Ruby CMath tanh()用法及代碼示例
- Ruby CSV.skip_lines用法及代碼示例
- Ruby CGI.new用法及代碼示例
- Ruby Comparable.between?用法及代碼示例
- Ruby CGI.print用法及代碼示例
- Ruby CGI.http_header用法及代碼示例
- Ruby CMath cos()用法及代碼示例
- Ruby Complex.arg用法及代碼示例
- Ruby CSV.table用法及代碼示例
- Ruby CSV.force_quotes?用法及代碼示例
- Ruby CParser模塊用法及代碼示例
- Ruby CSV.unconverted_fields?用法及代碼示例
- Ruby ComposedSet類用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 Closure類。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。