Class: Babeltrace2Gen::BTFieldClass::Array::Static
- Inherits:
-
Babeltrace2Gen::BTFieldClass::Array
- Object
- Babeltrace2Gen::BTFieldClass
- Babeltrace2Gen::BTFieldClass::Array
- Babeltrace2Gen::BTFieldClass::Array::Static
- Extended by:
- Babeltrace2Gen::BTFromH
- Defined in:
- lib/metababel/bt2_trace_class_generator.rb
Constant Summary
Constants inherited from Babeltrace2Gen::BTFieldClass
Constants included from Babeltrace2Gen::BTPrinter
Babeltrace2Gen::BTPrinter::INDENT_INCREMENT
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Attributes inherited from Babeltrace2Gen::BTFieldClass::Array
Attributes inherited from Babeltrace2Gen::BTFieldClass
#cast_type, #cast_type_is_struct, #type
Attributes included from Babeltrace2Gen::BTLocator
Instance Method Summary collapse
- #get_declarator(trace_class:, variable:) ⇒ Object
- #get_getter(field:, arg_variables:) ⇒ Object
- #get_setter(field:, arg_variables:) ⇒ Object
-
#initialize(parent:, element_field_class:, length:) ⇒ Static
constructor
A new instance of Static.
Methods included from Babeltrace2Gen::BTFromH
Methods inherited from Babeltrace2Gen::BTFieldClass
Methods included from Babeltrace2Gen::BTMatch
Methods included from Babeltrace2Gen::BTPrinter
context, #name_sanitized, pr, #scope
Methods included from Babeltrace2Gen::BTLocator
#rec_event_class, #rec_member_class, #rec_stream_class, #rec_trace_class, #resolve_path
Constructor Details
#initialize(parent:, element_field_class:, length:) ⇒ Static
Returns a new instance of Static.
677 678 679 680 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 677 def initialize(parent:, element_field_class:, length:) @length = length super(parent: parent, element_field_class: element_field_class) end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
675 676 677 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 675 def length @length end |
Instance Method Details
#get_declarator(trace_class:, variable:) ⇒ Object
682 683 684 685 686 687 688 689 690 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 682 def get_declarator(trace_class:, variable:) element_field_class_variable = "#{variable}_field_class" scope do pr "bt_field_class *#{element_field_class_variable};" @element_field_class.get_declarator(trace_class: trace_class, variable: element_field_class_variable) pr "#{variable} = bt_field_class_array_static_create(#{trace_class}, #{element_field_class_variable}, #{@length});" pr "bt_field_class_put_ref(#{element_field_class_variable});" end end |
#get_getter(field:, arg_variables:) ⇒ Object
703 704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 703 def get_getter(field:, arg_variables:) length = @length usr_var = bt_get_variable(arg_variables, is_array: true) pr "#{usr_var.name} = (#{usr_var.type}) malloc(#{length} * sizeof(#{usr_var.name}));" pr "for(uint64_t _i=0; _i < #{length} ; _i++)" scope do v = "#{field}_e" pr "const bt_field* #{v} = bt_field_array_borrow_element_field_by_index_const(#{field}, _i);" arg_variables.fetch_append('internal', GeneratedArg.new('', "#{usr_var.name}[_i]")) @element_field_class.get_getter(field: v, arg_variables: arg_variables) end end |
#get_setter(field:, arg_variables:) ⇒ Object
692 693 694 695 696 697 698 699 700 701 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 692 def get_setter(field:, arg_variables:) usr_var = bt_get_variable(arg_variables, is_array: true) pr "for(uint64_t _i=0; _i < #{@length} ; _i++)" scope do v = "#{field}_e" pr "bt_field* #{v} = bt_field_array_borrow_element_field_by_index(#{field}, _i);" arg_variables.fetch_append('internal', GeneratedArg.new('', "#{usr_var.name}[_i]")) @element_field_class.get_setter(field: v, arg_variables: arg_variables) end end |