Method: MrubyBridgeSignaturePluginModule#gen_preamble_struct

Defined in:
lib/tecsgen/plugin/lib/MrubyBridgeSignaturePluginModule.rb

#gen_preamble_struct(file, b_singleton, ct_name, global_ct_name) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/tecsgen/plugin/lib/MrubyBridgeSignaturePluginModule.rb', line 65

def gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
  tag = ct_name
  structType = @@struct_list[ tag ]
  file.print <<EOT
/* struct #{tag} */
STRUCT_CLASS( #{tag} )
EOT
  structType.get_members_decl.get_items.each{ |d|
    type = d.get_type.get_original_type
    case type
    when IntType, CIntType
      bit_size = type.get_bit_size
      case bit_size
      when -11, -1
        tType = "Char"
        ttype = "char"
      when -2
        tType = "Short"
        ttype = "short"
      when -3
        tType = "Int"
        ttype = "int"
      when -4
        tType = "Long"
        ttype = "long"
      when -5
        tType = "IntPtr"
        ttype = "intptr"
      when 8, 16, 32, 64
        tType = "Int#{bit_size}"
        ttype = "int#{bit_size}"
      else
        raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: cannot handle bit_size #{bit_size}"
      end
      file.print "MEMBER_GET_SET_INT( #{tag}, #{d.get_name}, #{tType}, #{ttype} )\n"
    when FloatType, CFloatType
      file.print "MEMBER_GET_SET_FLOAT( #{tag}, #{d.get_name} )\n"
    else
      raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: cannot handle type"
    end
  }
end