Class: AutoC::Type Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/autoc/type.rb

Overview

This class is abstract.

Direct Known Subclasses

Composite, Primitive

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#signatureObject (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.

Returns:

  • (Boolean)


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?.

Returns:

  • (Boolean)


92
# File 'lib/autoc/type.rb', line 92

def constructible? = custom_constructible? || default_constructible?

#copyString

This method is abstract.

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.

Parameters:

  • value (String | Symbol)

    source side storage designation where the instance is to be created

  • source (String | Symbol)

    source side storage designation taken as the origin for the copying operation

Returns:

  • (String)

    source side code snippet



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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


88
# File 'lib/autoc/type.rb', line 88

def custom_constructible? = respond_to?(:custom_create)

#custom_createString

This method is abstract.

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.

Parameters:

  • value (String | Symbol)

    source side storage designation where the instance is to be created

  • args (Array)

    list of types to be supplied to the constructor

Returns:

  • (String)

    source side code snippet



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.

Returns:

  • (Boolean)


84
# File 'lib/autoc/type.rb', line 84

def default_constructible? = respond_to?(:default_create)

#default_createString

This method is abstract.

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.

Parameters:

  • value (String | Symbol)

    source side storage designation where the instance is to be created

Returns:

  • (String)

    source side code snippet



36
# File 'lib/autoc/type.rb', line 36

abstract def default_create(value) = ABSTRACT

#destroyString

This method is abstract.

Synthesize the source side code to destroy the instance in place of the value (the destructor).

Parameters:

  • value (String | Symbol)

    source side storage designation for the instance to be destroyed

Returns:

  • (String)

    source side code snippet



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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


112
# File 'lib/autoc/type.rb', line 112

def hashable? = comparable? && respond_to?(:hash_code)

#inspectObject



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.

Returns:

  • (Boolean)


109
# File 'lib/autoc/type.rb', line 109

def orderable? = respond_to?(:compare)

#to_sObject



19
# File 'lib/autoc/type.rb', line 19

def to_s = signature

#to_typeObject



17
# File 'lib/autoc/type.rb', line 17

def to_type = self