Class: CExtractorTypes::CModule

Inherits:
Struct
  • Object
show all
Defined in:
lib/ceedling/c_extractor/c_extractor_types.rb

Overview

Data class representing all extracted content of C module

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variable_declarations: [], function_definitions: [], function_declarations: [], macro_definitions: [], type_definitions: [], aggregate_definitions: [], element_sequence: []) ⇒ CModule

Constructor to set unassigned fields to empty arrays for convenience



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 34

def initialize(
    variable_declarations: [],
    function_definitions: [],
    function_declarations: [],
    macro_definitions: [],
    type_definitions: [],
    aggregate_definitions: [],
    element_sequence: []
  )
  super
end

Instance Attribute Details

#aggregate_definitionsObject

Returns the value of attribute aggregate_definitions

Returns:

  • (Object)

    the current value of aggregate_definitions



23
24
25
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 23

def aggregate_definitions
  @aggregate_definitions
end

#element_sequenceObject

Returns the value of attribute element_sequence

Returns:

  • (Object)

    the current value of element_sequence



23
24
25
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 23

def element_sequence
  @element_sequence
end

#function_declarationsObject

Returns the value of attribute function_declarations

Returns:

  • (Object)

    the current value of function_declarations



23
24
25
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 23

def function_declarations
  @function_declarations
end

#function_definitionsObject

Returns the value of attribute function_definitions

Returns:

  • (Object)

    the current value of function_definitions



23
24
25
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 23

def function_definitions
  @function_definitions
end

#macro_definitionsObject

Returns the value of attribute macro_definitions

Returns:

  • (Object)

    the current value of macro_definitions



23
24
25
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 23

def macro_definitions
  @macro_definitions
end

#type_definitionsObject

Returns the value of attribute type_definitions

Returns:

  • (Object)

    the current value of type_definitions



23
24
25
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 23

def type_definitions
  @type_definitions
end

#variable_declarationsObject

Returns the value of attribute variable_declarations

Returns:

  • (Object)

    the current value of variable_declarations



23
24
25
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 23

def variable_declarations
  @variable_declarations
end

Instance Method Details

#+(other) ⇒ Object

Concatenate two CModule instances. element_sequence preserves first operand's items before second operand's items, maintaining source-before-header ordering regardless of line numbers.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ceedling/c_extractor/c_extractor_types.rb', line 49

def +(other)
  CModule.new(
    variable_declarations: (self.variable_declarations + other.variable_declarations),
    function_definitions:  (self.function_definitions  + other.function_definitions),
    function_declarations: (self.function_declarations + other.function_declarations),
    macro_definitions:     (self.macro_definitions     + other.macro_definitions),
    type_definitions:      (self.type_definitions      + other.type_definitions),
    aggregate_definitions: (self.aggregate_definitions + other.aggregate_definitions),
    element_sequence:      (self.element_sequence      + other.element_sequence)
  )
end