Class: Babeltrace2Gen::BTEntryClass
- Inherits:
-
Object
- Object
- Babeltrace2Gen::BTEntryClass
- Defined in:
- lib/metababel/bt2_trace_class_generator.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Default, IntegerSigned, String
Constant Summary collapse
- BT_MATCH_ATTRS =
%i[name type]
Constants included from BTPrinter
Babeltrace2Gen::BTPrinter::INDENT_INCREMENT
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #bt_get_variable(arg_variables = {}) ⇒ Object
- #get_getter(trace:, arg_variables:) ⇒ Object
- #get_setter(trace:, arg_variables:) ⇒ Object
-
#initialize(parent:, name:, type:) ⇒ BTEntryClass
constructor
A new instance of BTEntryClass.
Methods included from BTMatch
Methods included from BTPrinter
context, #name_sanitized, pr, #scope
Constructor Details
#initialize(parent:, name:, type:) ⇒ BTEntryClass
Returns a new instance of BTEntryClass.
1002 1003 1004 1005 1006 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 1002 def initialize(parent:, name:, type:) @parent = parent @name = name @type = type end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
1000 1001 1002 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 1000 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
1000 1001 1002 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 1000 def type @type end |
Class Method Details
.from_h(parent, model) ⇒ Object
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 1008 def self.from_h(parent, model) type = model.fetch(:type, nil) is_match_model = parent.rec_trace_class.match raise "No type in #{model}" unless type || is_match_model h = { 'string' => BTEntryClass::String, 'integer_signed' => BTEntryClass::IntegerSigned }.freeze raise "Type #{type} not supported" unless h.include?(type) || is_match_model h.include?(type) ? h[type].from_h(parent, model) : BTEntryClass::Default.from_h(parent, model) end |
Instance Method Details
#bt_get_variable(arg_variables = {}) ⇒ Object
1034 1035 1036 1037 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 1034 def bt_get_variable(arg_variables = {}) var = GeneratedArg.new(self.class.instance_variable_get(:@bt_type), @name) arg_variables.fetch_append('outputs', var) end |
#get_getter(trace:, arg_variables:) ⇒ Object
1022 1023 1024 1025 1026 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 1022 def get_getter(trace:, arg_variables:) var_name = bt_get_variable(arg_variables).name pr "const bt_value *#{var_name}_value = bt_trace_borrow_environment_entry_value_by_name_const(#{trace}, \"#{var_name}\");" pr "#{var_name} = bt_value_#{@type}_get(#{var_name}_value);" end |
#get_setter(trace:, arg_variables:) ⇒ Object
1028 1029 1030 1031 1032 |
# File 'lib/metababel/bt2_trace_class_generator.rb', line 1028 def get_setter(trace:, arg_variables:) var_name = bt_get_variable(arg_variables).name bt_type_set = self.class.instance_variable_get(:@bt_type_set) pr "bt_trace_set_environment_entry_#{bt_type_set}(#{trace}, \"#{var_name}\", #{var_name});" end |