Class: AutoC::Type Abstract
- Inherits:
-
Object
- Object
- AutoC::Type
- Defined in:
- lib/autoc/type.rb
Overview
Instance Attribute Summary collapse
-
#signature ⇒ Object
readonly
C side type signature.
Class Method Summary collapse
Instance Method Summary collapse
-
#comparable? ⇒ Boolean
Test whether the type has a well-defined test for content equality against another value of the same type.
-
#constructible? ⇒ Boolean
Test whether the type can be constructed, with either default or parametrized initialization.
-
#copy ⇒ String
abstract
Synthesize the source side code to create an instance in place of the
value
initializing it with a contents of theorigin
instance (the copy constructor). -
#copyable? ⇒ Boolean
Test whether the type can be created from an instance of the same type (cloned).
-
#custom_constructible? ⇒ Boolean
Test whether the type has a custom constructor which accepts a number of parameters.
-
#custom_create ⇒ String
abstract
Synthesize the source side code to create an instance in place of the
value
and and initialize it with suppliedargs
(the custom constructor). -
#default_constructible? ⇒ Boolean
Test whether the type has a default (parameterless) constructor.
-
#default_create ⇒ String
abstract
Synthesize the source side code to create an instance in place of the
value
and perform its default initialization (the default constructor). -
#destroy ⇒ String
abstract
Synthesize the source side code to destroy the instance in place of the
value
(the destructor). -
#destructible? ⇒ Boolean
Test whether the type has a non-trivial destructor.
-
#hashable? ⇒ Boolean
Test whether the type’s values which can be the elements of hash-based containers.
-
#initialize(signature) ⇒ Type
constructor
A new instance of Type.
- #inspect ⇒ Object
-
#orderable? ⇒ Boolean
Test whether the type can be compared for less-equal-more against another value of the same type.
- #to_s ⇒ Object
- #to_type ⇒ Object
Constructor Details
#initialize(signature) ⇒ Type
Returns a new instance of Type.
15 |
# File 'lib/autoc/type.rb', line 15 def initialize(signature) = @signature = signature.to_s |
Instance Attribute Details
#signature ⇒ Object (readonly)
C side type signature
11 12 13 |
# File 'lib/autoc/type.rb', line 11 def signature @signature end |
Class Method Details
.abstract(method) ⇒ Object
13 |
# File 'lib/autoc/type.rb', line 13 def self.abstract(method) = remove_method(method) |
Instance Method Details
#comparable? ⇒ Boolean
Test whether the type has a well-defined test for content equality against another value of the same type. This implementation looks up the #equal method.
104 |
# File 'lib/autoc/type.rb', line 104 def comparable? = respond_to?(:equal) |
#constructible? ⇒ Boolean
Test whether the type can be constructed, with either default or parametrized initialization. This implementation queries #custom_constructible? and #default_constructible?.
92 |
# File 'lib/autoc/type.rb', line 92 def constructible? = custom_constructible? || default_constructible? |
#copy ⇒ String
Synthesize the source side code to create an instance in place of the value
initializing it with a contents of the origin
instance (the copy constructor).
Original contents of the value
is overwritten. The contents of the source
is left intact.
68 |
# File 'lib/autoc/type.rb', line 68 abstract def copy(value, source) = ABSTRACT |
#copyable? ⇒ Boolean
Test whether the type can be created from an instance of the same type (cloned). This implementation looks up the #copy method.
100 |
# File 'lib/autoc/type.rb', line 100 def copyable? = respond_to?(:copy) |
#custom_constructible? ⇒ Boolean
Test whether the type has a custom constructor which accepts a number of parameters. This implementation looks up the #custom_create method.
88 |
# File 'lib/autoc/type.rb', line 88 def custom_constructible? = respond_to?(:custom_create) |
#custom_create ⇒ String
Synthesize the source side code to create an instance in place of the value
and and initialize it with supplied args
(the custom constructor).
The args
elements are expected to be of the AutoC::Type type.
Original contents of the value
is overwritten.
49 |
# File 'lib/autoc/type.rb', line 49 abstract def custom_create(value, *args) = ABSTRACT |
#default_constructible? ⇒ Boolean
Test whether the type has a default (parameterless) constructor. This implementation looks up the #default_create method.
84 |
# File 'lib/autoc/type.rb', line 84 def default_constructible? = respond_to?(:default_create) |
#default_create ⇒ String
Synthesize the source side code to create an instance in place of the value
and perform its default initialization (the default constructor).
Original contents of the value
is overwritten.
36 |
# File 'lib/autoc/type.rb', line 36 abstract def default_create(value) = ABSTRACT |
#destroy ⇒ String
Synthesize the source side code to destroy the instance in place of the value
(the destructor).
56 |
# File 'lib/autoc/type.rb', line 56 abstract def destroy(value) = ABSTRACT |
#destructible? ⇒ Boolean
Test whether the type has a non-trivial destructor. This implementation looks up the #destroy method.
96 |
# File 'lib/autoc/type.rb', line 96 def destructible? = respond_to?(:destroy) |
#hashable? ⇒ Boolean
Test whether the type’s values which can be the elements of hash-based containers.
112 |
# File 'lib/autoc/type.rb', line 112 def hashable? = comparable? && respond_to?(:hash_code) |
#inspect ⇒ Object
21 |
# File 'lib/autoc/type.rb', line 21 def inspect = "#{signature} <#{self.class}>" |
#orderable? ⇒ Boolean
Test whether the type can be compared for less-equal-more against another value of the same type. Orderable type’s values can be sorted and put into tree-based containers. For the type to be comparable this implementation looks up the #compare method.
109 |
# File 'lib/autoc/type.rb', line 109 def orderable? = respond_to?(:compare) |
#to_s ⇒ Object
19 |
# File 'lib/autoc/type.rb', line 19 def to_s = signature |
#to_type ⇒ Object
17 |
# File 'lib/autoc/type.rb', line 17 def to_type = self |