Class: Babeltrace2::BTFieldClass::Array::Dynamic

Inherits:
Babeltrace2::BTFieldClass::Array show all
Defined in:
lib/babeltrace2/trace-ir/field-class.rb

Defined Under Namespace

Modules: WithLengthField

Constant Summary

Constants inherited from Babeltrace2::BTFieldClass

IntegerSigned, IntegerUnsigned, RealDoublePrecision, RealSinglePrecision, TYPE_MAP

Instance Attribute Summary

Attributes inherited from Babeltrace2::BTObject

#handle

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Babeltrace2::BTFieldClass::Array

#get_element_field_class, #to_h

Methods inherited from Babeltrace2::BTFieldClass

#from_h, from_handle, #get_type, #get_user_attributes, #set_user_attributes, #to_h, #type_is, #user_attributes=

Methods inherited from Babeltrace2::BTSharedObject

inherited

Methods inherited from Babeltrace2::BTObject

#==, #to_ptr

Constructor Details

#initialize(handle = nil, retain: true, auto_release: true, trace_class: nil, element_field_class: nil, length_field_class: nil) ⇒ Dynamic

Returns a new instance of Dynamic.



899
900
901
902
903
904
905
906
907
908
909
910
911
912
# File 'lib/babeltrace2/trace-ir/field-class.rb', line 899

def initialize(handle = nil, retain: true, auto_release: true,
               trace_class: nil, element_field_class: nil, length_field_class: nil)
  if handle
    self.extend(WithLengthField) if Babeltrace2.bt_field_class_get_type(handle) ==
      :BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD
    super(handle, retain: retain, auto_release: auto_release)
  else
    handle = Babeltrace2.bt_field_class_array_dynamic_create(
               trace_class, element_field_class, length_field_class)
    raise Babeltrace2.process_error if handle.null?
    self.extend(WithLengthField) if length_field_class
    super(handle, retain: false)
  end
end

Class Method Details

.from_h(trace_class, h, stream_class_h = nil) ⇒ Object



914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
# File 'lib/babeltrace2/trace-ir/field-class.rb', line 914

def self.from_h(trace_class, h, stream_class_h = nil)
  if (stream_class_h && h[:length_field_path])
    length_field_class = BTStreamClass.locate_field_class( 
      BTFieldPath.path_from_s_to_h(h[:length_field_path]), stream_class_h)
  else
    length_field_class = nil
  end
  o = self.new(trace_class: trace_class,
    element_field_class: BTFieldClass.from_h(trace_class,
                                             h[:element_field_class],
                                             stream_class_h),
    length_field_class: length_field_class).from_h(h)
  h[:bt_field_class] = o
  o
end