@@ -79,11 +79,11 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
79
79
has_field_names = type_has_field_names (t )
80
80
81
81
if has_field_names :
82
- template = "%(type_name)s {\n %(body)s\n }"
83
- separator = ", \n "
82
+ template = "%(type_name)s {\n %(body)s\n }"
83
+ separator = ", \n "
84
84
else :
85
- template = "%(type_name)s(%(body)s)"
86
- separator = ", "
85
+ template = "%(type_name)s(%(body)s)"
86
+ separator = ", "
87
87
88
88
if type_name .startswith ("(" ):
89
89
# this is a tuple, so don't print the type name
@@ -125,20 +125,20 @@ def print_enum_val(val, internal_dict):
125
125
if last_separator_index == - 1 :
126
126
return "<invalid enum encoding: %s>" % first_variant_name
127
127
128
- second_last_separator_index = first_variant_name .rfind ("$" , 0 , last_separator_index )
129
- if second_last_separator_index == - 1 :
130
- return "<invalid enum encoding: %s>" % first_variant_name
128
+ start_index = len ("RUST$ENCODED$ENUM$" )
131
129
132
- # Extract index of the discriminator field
130
+ # Extract indices of the discriminator field
133
131
try :
134
- disr_field_index = first_variant_name [second_last_separator_index + 1 :
135
- last_separator_index ]
136
- disr_field_index = int (disr_field_index )
132
+ disr_field_indices = first_variant_name [start_index :
133
+ last_separator_index ]. split ( "$" )
134
+ disr_field_indices = [ int (index ) for index in dis_field_indices ]
137
135
except :
138
136
return "<invalid enum encoding: %s>" % first_variant_name
139
137
140
138
# Read the discriminant
141
- disr_val = val .GetChildAtIndex (0 ).GetChildAtIndex (disr_field_index )
139
+ disr_val = val .GetChildAtIndex (0 )
140
+ for index in disr_field_indices :
141
+ disr_val = disr_val .GetChildAtIndex (disr_field_index )
142
142
143
143
# If the discriminant field is a fat pointer we have to consider the
144
144
# first word as the true discriminant
0 commit comments