本文简要介绍ruby语言中 Fiddle::Function类
的用法。
说明
C 函数的表示
例子
‘strcpy’
@libc = Fiddle.dlopen "/lib/libc.so.6" #=> #<Fiddle::Handle:0x00000001d7a8d8> f = Fiddle::Function.new( @libc['strcpy'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOIDP) #=> #<Fiddle::Function:0x00000001d8ee00> buff = "000" #=> "000" str = f.call(buff, "123") #=> #<Fiddle::Pointer:0x00000001d0c380 ptr=0x000000018a21b8 size=0 free=0x00000000000000> str.to_s => "123"
ABI 检查
@libc = Fiddle.dlopen "/lib/libc.so.6"
#=> #<Fiddle::Handle:0x00000001d7a8d8>
f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
#=> #<Fiddle::Function:0x00000001d8ee00>
f.abi == Fiddle::Function::DEFAULT
#=> true
相关用法
- Ruby Float arg()用法及代码示例
- Ruby File.identical?用法及代码示例
- Ruby Fiber.schedule用法及代码示例
- Ruby Float fdiv()用法及代码示例
- Ruby Float quo()用法及代码示例
- Ruby Float angle()用法及代码示例
- Ruby FileUtils.mkdir用法及代码示例
- Ruby Float divmod()用法及代码示例
- Ruby Float.self - other用法及代码示例
- Ruby Float.rationalize用法及代码示例
- Ruby Float.truncate用法及代码示例
- Ruby FileUtils.compare_file用法及代码示例
- Ruby FileUtils.options_of用法及代码示例
- Ruby File.dirname用法及代码示例
- Ruby Formatter.random_bytes用法及代码示例
- Ruby Float prev_float()用法及代码示例
- Ruby FileUtils.ln_s用法及代码示例
- Ruby Float round()用法及代码示例
- Ruby Float denominator()用法及代码示例
- Ruby Float numerator()用法及代码示例
- Ruby Float absolute()用法及代码示例
- Ruby Float to_i()用法及代码示例
- Ruby Fiddle.dlwrap用法及代码示例
- Ruby Float nan?()用法及代码示例
- Ruby File.directory?用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Function类。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。