Class: AutoC::UserDefinedType
Defined Under Namespace
Classes: PublicDeclaration
Constant Summary
Constants inherited from Type
Instance Attribute Summary
Attributes inherited from Type
Instance Method Summary collapse
- #copy(dst, src) ⇒ Object
- #ctor(obj) ⇒ Object
- #dtor(obj) ⇒ Object
-
#entities ⇒ Object
PublicDeclaration.
- #equal(lt, rt) ⇒ Object
- #identify(obj) ⇒ Object
-
#initialize(opt) ⇒ UserDefinedType
constructor
A new instance of UserDefinedType.
- #less(lt, rt) ⇒ Object
Methods inherited from Type
#abort, #assert, #calloc, #extern, #free, #inline, #malloc, #method_missing, #static, #write_decls, #write_defs, #write_exported_declarations, #write_exported_types, #write_implementations, #write_intf
Methods inherited from Code
#attach, #priority, #source_size, #write_decls, #write_defs, #write_intf
Constructor Details
#initialize(opt) ⇒ UserDefinedType
Returns a new instance of UserDefinedType.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/autoc/type.rb', line 152 def initialize(opt) @deps = [] v = :public if [Symbol, String].include?(opt.class) t = opt elsif opt.is_a?(Hash) t = opt[:type].nil? ? raise("type is not specified") : opt[:type] [:ctor, :dtor, :copy, :equal, :less, :identify].each do |key| instance_variable_set("@#{key}".to_sym, opt[key].to_s) unless opt[key].nil? end @deps << PublicDeclaration.new(opt[:forward]) unless opt[:forward].nil? optv = opt[:visibility] v = optv.nil? ? :public : optv else raise "failed to decode the argument" end super(t, v) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AutoC::Type
Instance Method Details
#copy(dst, src) ⇒ Object
179 180 181 |
# File 'lib/autoc/type.rb', line 179 def copy(dst, src) @copy.nil? ? "(#{dst} = #{src})" : "#{@copy}(#{dst}, #{src})" end |
#ctor(obj) ⇒ Object
171 172 173 |
# File 'lib/autoc/type.rb', line 171 def ctor(obj) @ctor.nil? ? "(#{obj} = 0)" : "#{@ctor}(#{obj})" end |
#dtor(obj) ⇒ Object
175 176 177 |
# File 'lib/autoc/type.rb', line 175 def dtor(obj) @dtor.nil? ? nil : "#{@dtor}(#{obj})" end |
#entities ⇒ Object
PublicDeclaration
150 |
# File 'lib/autoc/type.rb', line 150 def entities; super + @deps end |
#equal(lt, rt) ⇒ Object
183 184 185 |
# File 'lib/autoc/type.rb', line 183 def equal(lt, rt) @equal.nil? ? "(#{lt} == #{rt})" : "#{@equal}(#{lt}, #{rt})" end |
#identify(obj) ⇒ Object
191 192 193 |
# File 'lib/autoc/type.rb', line 191 def identify(obj) @identify.nil? ? "(size_t)(#{obj})" : "#{@identify}(#{obj})" end |
#less(lt, rt) ⇒ Object
187 188 189 |
# File 'lib/autoc/type.rb', line 187 def less(lt, rt) @less.nil? ? "(#{lt} < #{rt})" : "#{@less}(#{lt}, #{rt})" end |