+ def get_vla_field_length_name(self, path):
+ return "%s_%s_array_size" % ("_".join(path), self.name)
+
+ def get_alloc_vla_param_names(self, path):
+ if self.is_vla():
+ result = [self.get_vla_field_length_name(path)]
+ else:
+ result = []
+ if self.type.has_vla():
+ t = self.type.get_alloc_vla_param_names(path + [self.name])
+ result.extend(t)
+ return result
+
+ def get_vla_calc_size_code(self, prefix, path):
+ if self.is_vla():
+ result = ["sizeof(%s.%s[0]) * %s" % (
+ ".".join([prefix] + path),
+ self.name,
+ self.get_vla_field_length_name(path))]
+ else:
+ result = []
+ if self.type.has_vla():
+ t = self.type.get_vla_calc_size_code(prefix, path + [self.name])
+ result.extend(t)
+ return result
+
+ def get_vla_assign_code(self, prefix, path):
+ result = []
+ if self.is_vla():
+ result.append("%s.%s = %s" % (
+ ".".join([prefix] + path),
+ self.nelem_field.name,
+ self.get_vla_field_length_name(path)))
+ if self.type.has_vla():
+ t = self.type.get_vla_assign_code(prefix, path + [self.name])
+ result.extend(t)
+ return result
+
+
+class CAlias(CField):
+ def get_c_name(self):
+ return "vapi_type_%s" % self.name
+
+ def get_c_def(self):
+ if self.len is not None:
+ return "typedef %s vapi_type_%s[%d];" % (self.type.get_c_name(), self.name, self.len)
+ else:
+ return "typedef %s vapi_type_%s;" % (self.type.get_c_name(), self.name)
+ #return "typedef %s" % super(CAlias, self).get_c_def()
+
+ # def needs_byte_swap
+