def __init__(self, dictionary): # Call the parent constructor Variable.__init__(self, dictionary) self.private_format = 'gchar *' self.public_format = self.private_format if 'fixed-size' in dictionary: self.is_fixed_size = True # Fixed-size strings self.needs_dispose = False self.length_prefix_size = 0 self.fixed_size = dictionary['fixed-size'] self.max_size = '' else: self.is_fixed_size = False # Variable-length strings in heap self.needs_dispose = True if 'size-prefix-format' in dictionary: if dictionary['size-prefix-format'] == 'guint8': self.length_prefix_size = 8 elif dictionary['size-prefix-format'] == 'guint16': self.length_prefix_size = 16 else: raise ValueError('Invalid size prefix format (%s): not guint8 or guint16' % dictionary['size-prefix-format']) # Strings which are given as the full value of a TLV and which don't have # a explicit 'size-prefix-format' will NOT have a length prefix elif 'type' in dictionary and dictionary['type'] == 'TLV': self.length_prefix_size = 0 else: # Default to UINT8 self.length_prefix_size = 8 self.fixed_size = '' self.max_size = dictionary['max-size'] if 'max-size' in dictionary else ''
def __init__(self, dictionary, struct_type_name, container_type): # Call the parent constructor Variable.__init__(self, dictionary) # The public format of the struct is built directly from the suggested # struct type name self.public_format = utils.build_camelcase_name(struct_type_name) self.private_format = self.public_format self.element_type = self.public_format self.container_type = container_type # Load members of this struct self.members = [] for member_dictionary in dictionary['contents']: member = {} member['name'] = utils.build_underscore_name( member_dictionary['name']) member['object'] = VariableFactory.create_variable( member_dictionary, struct_type_name + ' ' + member['name'], self.container_type) # Specify that the variable will be defined in the public header member['object'].flag_public() self.members.append(member) # We'll need to dispose if at least one of the members needs it for member in self.members: if member['object'].needs_dispose == True: self.needs_dispose = True
def __init__(self, dictionary, array_element_type, container_type): # Call the parent constructor Variable.__init__(self, dictionary) self.private_format = 'GArray *' self.public_format = self.private_format self.fixed_size = 0 self.name = dictionary['name'] # The array and its contents need to get disposed self.needs_dispose = True # We need to know whether the variable comes in an Input container or in # an Output container, as we should not dump the element clear() helper method # if the variable is from an Input container. self.container_type = container_type # Load variable type of this array if 'name' in dictionary['array-element']: self.array_element = VariableFactory.create_variable( dictionary['array-element'], array_element_type + ' ' + dictionary['array-element']['name'], self.container_type) else: self.array_element = VariableFactory.create_variable( dictionary['array-element'], '', self.container_type) # Load variable type for the array size prefix if 'size-prefix-format' in dictionary: # We do NOT allow 64-bit types as array sizes (GArray won't support them) if dictionary['size-prefix-format'] not in [ 'guint8', 'guint16', 'guint32' ]: raise ValueError( 'Invalid size prefix format (%s): not guint8 or guint16 or guint32' % dictionary['size-prefix-format']) default_array_size = {'format': dictionary['size-prefix-format']} self.array_size_element = VariableFactory.create_variable( default_array_size, '', self.container_type) elif 'fixed-size' in dictionary: # fixed-size arrays have no size element, obviously self.fixed_size = dictionary['fixed-size'] if int(self.fixed_size) == 0 or int(self.fixed_size) > 512: raise ValueError( 'Fixed array size %s out of bounds (not between 0 and 512)' % self.fixed_size) else: # Default to 'guint8' if no explicit array size given default_array_size = {'format': 'guint8'} self.array_size_element = VariableFactory.create_variable( default_array_size, '', self.container_type) # Load variable type for the sequence prefix if 'sequence-prefix-format' in dictionary: sequence = {'format': dictionary['sequence-prefix-format']} self.array_sequence_element = VariableFactory.create_variable( sequence, '', self.container_type) else: self.array_sequence_element = ''
def __init__(self, dictionary, struct_type_name, container_type): # Call the parent constructor Variable.__init__(self, dictionary) # The public format of the struct is built directly from the suggested # struct type name self.public_format = utils.build_camelcase_name(struct_type_name) self.private_format = self.public_format self.container_type = container_type # Load members of this struct self.members = [] for member_dictionary in dictionary["contents"]: member = {} member["name"] = utils.build_underscore_name(member_dictionary["name"]) member["object"] = VariableFactory.create_variable( member_dictionary, struct_type_name + " " + member["name"], self.container_type ) self.members.append(member) # We'll need to dispose if at least one of the members needs it for member in self.members: if member["object"].needs_dispose == True: self.needs_dispose = True
def __init__(self, name, type, variables, virtual_direction=None, size=0): """ Name: Group Description: Used to hold a group with several literals with information. """ self.variables = variables self.size = size Variable.__init__(self, name, type, virtual_direction, None)
def __init__(self, tag, nombre, descripcion, valorMuyBajo, valorBajo, valorAlto, valorMuyAlto): Variable.__init__(self, tag=tag, nombre=nombre, descripcion=descripcion) self.__valorMuyAlto = valorMuyAlto self.__valorAlto = valorAlto self.__valorBajo = valorBajo self.__valorMuyBajo = valorMuyBajo
def __init__(self, dictionary): # Call the parent constructor Variable.__init__(self, dictionary) self.guint_sized_size = '' if self.format == "guint-sized": if 'guint-size' not in dictionary: raise RuntimeError('Format \'guint-sized\' requires \'guint-size\' parameter') else: self.guint_sized_size = dictionary['guint-size'] self.private_format = 'guint64' self.public_format = 'guint64' else: self.private_format = self.format self.public_format = dictionary['public-format'] if 'public-format' in dictionary else self.private_format
def __init__(self, dictionary, array_element_type, container_type): # Call the parent constructor Variable.__init__(self, dictionary) self.private_format = 'GArray *' self.public_format = self.private_format self.fixed_size = 0 self.name = dictionary['name'] # The array and its contents need to get disposed self.needs_dispose = True # We need to know whether the variable comes in an Input container or in # an Output container, as we should not dump the element clear() helper method # if the variable is from an Input container. self.container_type = container_type # Load variable type of this array if 'name' in dictionary['array-element']: self.array_element = VariableFactory.create_variable(dictionary['array-element'], array_element_type + ' ' + dictionary['array-element']['name'], self.container_type) else: self.array_element = VariableFactory.create_variable(dictionary['array-element'], '', self.container_type) # Load variable type for the array size prefix if 'size-prefix-format' in dictionary: # We do NOT allow 64-bit types as array sizes (GArray won't support them) if dictionary['size-prefix-format'] not in [ 'guint8', 'guint16', 'guint32' ]: raise ValueError('Invalid size prefix format (%s): not guint8 or guint16 or guint32' % dictionary['size-prefix-format']) default_array_size = { 'format' : dictionary['size-prefix-format'] } self.array_size_element = VariableFactory.create_variable(default_array_size, '', self.container_type) elif 'fixed-size' in dictionary: # fixed-size arrays have no size element, obviously self.fixed_size = dictionary['fixed-size'] if int(self.fixed_size) == 0 or int(self.fixed_size) > 512: raise ValueError('Fixed array size %s out of bounds (not between 0 and 512)' % self.fixed_size) else: # Default to 'guint8' if no explicit array size given default_array_size = { 'format' : 'guint8' } self.array_size_element = VariableFactory.create_variable(default_array_size, '', self.container_type) # Load variable type for the sequence prefix if 'sequence-prefix-format' in dictionary: sequence = { 'format' : dictionary['sequence-prefix-format'] } self.array_sequence_element = VariableFactory.create_variable(sequence, '', self.container_type) else: self.array_sequence_element = ''
def __init__(self, dictionary): # Call the parent constructor Variable.__init__(self, dictionary) self.private_format = 'gchar *' self.public_format = self.private_format self.element_type = 'utf8' if 'fixed-size' in dictionary: self.is_fixed_size = True # Fixed-size strings self.needs_dispose = False self.length_prefix_size = 0 self.n_size_prefix_bytes = 0 self.fixed_size = dictionary['fixed-size'] self.max_size = '' else: self.is_fixed_size = False self.fixed_size = '-1' # Variable-length strings in heap self.needs_dispose = True if 'size-prefix-format' in dictionary: if dictionary['size-prefix-format'] == 'guint8': self.length_prefix_size = 8 self.n_size_prefix_bytes = 1 elif dictionary['size-prefix-format'] == 'guint16': self.length_prefix_size = 16 self.n_size_prefix_bytes = 2 else: raise ValueError( 'Invalid size prefix format (%s): not guint8 or guint16' % dictionary['size-prefix-format']) # Strings which are given as the full value of a TLV and which don't have # a explicit 'size-prefix-format' will NOT have a length prefix elif 'type' in dictionary and dictionary['type'] == 'TLV': self.length_prefix_size = 0 self.n_size_prefix_bytes = 0 else: # Default to UINT8 self.length_prefix_size = 8 self.n_size_prefix_bytes = 1 self.max_size = dictionary[ 'max-size'] if 'max-size' in dictionary else ''
def __init__(self, dictionary, sequence_type_name, container_type): # Call the parent constructor Variable.__init__(self, dictionary) self.container_type = container_type # Load members of this sequence self.members = [] for member_dictionary in dictionary['contents']: member = {} member['name'] = utils.build_underscore_name(member_dictionary['name']) member['object'] = VariableFactory.create_variable(member_dictionary, sequence_type_name + ' ' + member_dictionary['name'], self.container_type) self.members.append(member) # TODO: do we need this? # We'll need to dispose if at least one of the members needs it for member in self.members: if member['object'].needs_dispose == True: self.needs_dispose = True
def __init__(self, dictionary, sequence_type_name, container_type): # Call the parent constructor Variable.__init__(self, dictionary) self.container_type = container_type # Load members of this sequence self.members = [] for member_dictionary in dictionary['contents']: member = {} member['name'] = utils.build_underscore_name(member_dictionary['name']) member['object'] = VariableFactory.create_variable(member_dictionary, sequence_type_name + ' ' + member['name'], self.container_type) self.members.append(member) # TODO: do we need this? # We'll need to dispose if at least one of the members needs it for member in self.members: if member['object'].needs_dispose == True: self.needs_dispose = True
def __init__(self, _type): Variable.__init__(self, _type)
def __init__(self,param): Variable.__init__(self,param.variable_decleration) self.IN = param.IN