Class: Hornetseye::GCCType
Instance Method Summary collapse
- #identifier ⇒ Object
- #identifiers ⇒ Object
-
#initialize(typecode) ⇒ GCCType
constructor
A new instance of GCCType.
- #r2c ⇒ Object
Constructor Details
#initialize(typecode) ⇒ GCCType
Returns a new instance of GCCType.
22 23 24 |
# File 'lib/multiarray/gcctype.rb', line 22 def initialize( typecode ) @typecode = typecode end |
Instance Method Details
#identifier ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/multiarray/gcctype.rb', line 26 def identifier case @typecode when nil 'void' when BOOL 'char' when BYTE 'char' when UBYTE 'unsigned char' when SINT 'short int' when USINT 'unsigned short int' when INT 'int' when UINT 'unsigned int' when SFLOAT 'float' when DFLOAT 'double' else if @typecode < Pointer_ 'void *' elsif @typecode < INDEX_ 'int' else raise "No identifier available for #{@typecode.inspect}" end end end |
#identifiers ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/multiarray/gcctype.rb', line 59 def identifiers if @typecode < Composite GCCType.new( @typecode.element_type ).identifiers * @typecode.num_elements else [ GCCType.new( @typecode ).identifier ] end end |
#r2c ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/multiarray/gcctype.rb', line 67 def r2c case @typecode when BOOL [ lambda { |expr| "( #{expr} ) != Qfalse" } ] when BYTE, UBYTE, SINT, USINT, INT, UINT [ lambda { |expr| "NUM2INT( #{expr} )" } ] when SFLOAT, DFLOAT [ lambda { |expr| "NUM2DBL( #{expr} )" } ] else if @typecode < Pointer_ [ lambda { |expr| "(#{identifier})mallocToPtr( #{expr} )" } ] elsif @typecode < Composite GCCType.new( @typecode.element_type ).r2c * @typecode.num_elements else raise "No conversion available for #{@typecode.inspect}" end end end |