Commit 138a51f2 authored by Thomas Applencourt's avatar Thomas Applencourt
Browse files

Support enum

parent fe234414
Pipeline #12818 failed with stage
......@@ -5,20 +5,16 @@ OPENCL_MODEL = YAML::load_file(OPENCL_MODEL_LOCATION)
def is_unsigned(type)
# object are size_t
if OPENCL_MODEL["objects"].include?(type)
return true
end
return true if OPENCL_MODEL["objects"].include?(type)
bottom = OPENCL_MODEL["type_map"].fetch(type, type)
["unsigned int","uintptr_t", "size_t","cl_uint","cl_ulong", "cl_ushort"].include?(bottom)
end
def parse_field(field)
d= {}
# This is ugly, we should change the opencl_model format
# to handle struct and ctf_struct properly
d[:name] = field["name"] if field["name"]
case field["lttng"]
when "ctf_integer", "ctf_integer_hex", "ctf_enum"
when "ctf_integer", "ctf_integer_hex"
d[:class] = is_unsigned(field["type"]) ? "unsigned" : "signed"
d[:class_properties] = {preferred_display_base: 16} if field["lttng"] == "ctf_integer_hex"
when "ctf_string", "ctf_sequence_text"
......@@ -26,9 +22,14 @@ def parse_field(field)
when "ctf_sequence","ctf_array"
d[:class] = "array_dynamic"
d[:field] = parse_field( {"lttng" => "ctf_integer", "type" => d["type"]})
when "ctf_sequence_hex"
when "ctf_sequence_hex"
d[:class] = "array_dynamic"
d[:field] = parse_field( {"lttng" => "ctf_integer_hex", "type" => d["type"] })
when "ctf_enum"
d[:class] = is_unsigned(field["type"]) ? "enumeration_unsigned" : "enumeration_signed"
enum_type = field["enum_type"]
d[:mapping] = OPENCL_MODEL["lttng_enums"][enum_type][:values].map {
|f| {label: f[:name], integer_range_set: f[:value] } }
end
d
......
......@@ -17,7 +17,7 @@ def create_datastructure(trace_class, l)
def populate_enumeration_class(field,d)
populate_integer_field_class(field,d)
d[:mapping].each{ |f| field.add_mapping(f[:label], f[:interger_range_set]) }
d[:mapping].each{ |f| field.add_mapping(f[:label], f[:integer_range_set]) }
end
# Callbacks
......@@ -74,7 +74,6 @@ def create_datastructure(trace_class, l)
end
bottom_aliases = ['bool',
'bit_array',
'enumeration_signed',
'real_single_precision','real_single', 'single','single_precision',
'real_double_precision','read_double', 'double','double_precision']
create_callback_aliases(bottom_aliases, "bottom")
......@@ -141,11 +140,11 @@ def populate_field(field, field_value)
when :BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD
element_field_class_type = field.get_class.element_field_class.get_type
if field_value.nil?
length = 0
length = 0
elsif field_value[:length]
length = field_value[:length]
length = field_value[:length]
elsif field_value[:values]
length = field_value[:values].length
length = field_value[:values].length
end
field.length = length
field.length.times{ |i| populate_field(field[i], field_value[:values].nil? ? nil : field_value[:values][i] ) }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment