本文簡要介紹ruby語言中 Fiddle::CParser.parse_ctype
的用法。
用法
parse_ctype(ty, tymap=nil)
給定 C 類型 ty
的 String
,返回相應的 Fiddle
常量。
ty
也可以接受 C 類型字符串的 Array
,並將在相應的 Array
中返回。
如果提供了 Hash
tymap
,則ty
應該是key,value是要查找的C類型。
例子:
require 'fiddle/import'
include Fiddle::CParser
#=> Object
parse_ctype('int')
#=> Fiddle::TYPE_INT
parse_ctype('double diff')
#=> Fiddle::TYPE_DOUBLE
parse_ctype('unsigned char byte')
#=> -Fiddle::TYPE_CHAR
parse_ctype('const char* const argv[]')
#=> -Fiddle::TYPE_VOIDP
相關用法
- Ruby CParser.parse_signature用法及代碼示例
- Ruby CParser.parse_struct_signature用法及代碼示例
- Ruby CParser模塊用法及代碼示例
- 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 Class類用法及代碼示例
- Ruby CMath cos()用法及代碼示例
- Ruby Complex.arg用法及代碼示例
- Ruby CSV.table用法及代碼示例
- Ruby CSV.force_quotes?用法及代碼示例
- Ruby CSV.unconverted_fields?用法及代碼示例
- Ruby ComposedSet類用法及代碼示例
- Ruby C.handle_constants用法及代碼示例
- Ruby Continuation類用法及代碼示例
- Ruby Closure類用法及代碼示例
- Ruby CStructEntity.[]用法及代碼示例
- Ruby Complex.abs2用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 CParser.parse_ctype。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。