Class: AutoC::UserDefinedType
- Inherits:
-
Type
show all
- Defined in:
- lib/autoc/type.rb
Overview
UserDefinedType represents a user-defined custom type.
Constant Summary
Instance Attribute Summary
Attributes inherited from Type
#type, #type_ref
Instance Method Summary
(collapse)
Methods inherited from Type
#==, #abort, #assert, #calloc, coerce, #extern, #free, #hash, #inline, #malloc, #method_missing, #private?, #public?, #static, #static?, #write_decls, #write_defs, #write_intf
Methods inherited from Code
#attach, #priority, #source_size, #write_decls, #write_defs, #write_intf
Constructor Details
Returns a new instance of UserDefinedType
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
# File 'lib/autoc/type.rb', line 318
def initialize(opt)
opt = {:type => opt} if opt.is_a?(::Symbol) || opt.is_a?(::String)
if opt.is_a?(Hash)
t = opt[:type].nil? ? raise("type is not specified") : opt[:type].to_s
else
raise "argument must be a Symbol, String or Hash"
end
super(t)
@prefix = AutoC.c_id(opt[:prefix]) unless opt[:prefix].nil?
@deps = []; @deps << PublicDeclaration.new(opt[:forward]) unless opt[:forward].nil?
define_callable(:ctor, opt) {def call(obj) "((#{obj}) = 0)" end}
define_callable(:dtor, opt) {def call(obj) end}
define_callable(:copy, opt) {def call(dst, src) "((#{dst}) = (#{src}))" end}
define_callable(:equal, opt) {def call(lt, rt) "((#{lt}) == (#{rt}))" end}
define_callable(:less, opt) {def call(lt, rt) "((#{lt}) < (#{rt}))" end}
define_callable(:identify, opt) {def call(obj) "((size_t)(#{obj}))" end}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class AutoC::Type
Instance Method Details
- (Boolean) comparable?
344
|
# File 'lib/autoc/type.rb', line 344
def comparable?; !@equal.nil? end
|
- (Boolean) constructible?
336
|
# File 'lib/autoc/type.rb', line 336
def constructible?; !@ctor.nil? && @ctor.parameters.size == 1 end
|
- (Boolean) copyable?
342
|
# File 'lib/autoc/type.rb', line 342
def copyable?; !@copy.nil? end
|
- (Boolean) destructible?
340
|
# File 'lib/autoc/type.rb', line 340
def destructible?; !@dtor.nil? end
|
- (Object) entities
314
|
# File 'lib/autoc/type.rb', line 314
def entities; super.concat(@deps) end
|
- (Boolean) hashable?
348
|
# File 'lib/autoc/type.rb', line 348
def hashable?; !@identify.nil? end
|
- (Boolean) initializable?
338
|
# File 'lib/autoc/type.rb', line 338
def initializable?; !@ctor.nil? end
|
- (Boolean) orderable?
346
|
# File 'lib/autoc/type.rb', line 346
def orderable?; !@less.nil? end
|
- (Object) prefix
316
|
# File 'lib/autoc/type.rb', line 316
def prefix; @prefix.nil? ? super : @prefix end
|
- (Object) write_impls(stream, define)
356
|
# File 'lib/autoc/type.rb', line 356
def write_impls(stream, define) end
|
- (Object) write_intf_decls(stream, declare, define)
354
|
# File 'lib/autoc/type.rb', line 354
def write_intf_decls(stream, declare, define) end
|
- (Object) write_intf_types(stream)
The methods below are left empty as the user-defined types have no implementation on their own
352
|
# File 'lib/autoc/type.rb', line 352
def write_intf_types(stream) end
|