def _get_property(self, prop_name, prop_type): """Return the value of the given property name. :param str prop_name: The name of the property. :param SendPropType prop_type: The type of the property. """ # Is the given property not valid? if prop_name not in self.template.properties: # Raise an exception... raise NameError( '"{}" is not a valid property for temp entity "{}".'.format( prop_name, self.name)) # Get the property data... prop, offset, type_name = self.template.properties[prop_name] # Are the prop types matching? if prop.type != prop_type: # Raise an exception... raise TypeError('"{}" is not of type "{}".'.format( prop_name, prop_type)) # Is the property an array? if prop_type == SendPropType.ARRAY: # Return an array instance... return Array(manager, False, type_name, get_object_pointer(self) + offset, prop.length) # Is the given type not supported? if prop_type not in _supported_property_types: # Raise an exception... raise TypeError('"{}" is not supported.'.format(prop_type)) # Is the type native? if Type.is_native(type_name): # Return the value... return getattr(get_object_pointer(self), 'get_' + type_name)(offset) # Otherwise else: # Make the object and return it... return make_object(manager.get_class(type_name), get_object_pointer(self) + offset) # Raise an exception... raise ValueError('Unable to get the value of "{}".'.format(prop_name))
def fget(ptr): """Get the dynamic pointer array.""" return Array(self, True, type_name, ptr.get_pointer(offset), length)
def fget(ptr): """Get the static pointer array.""" return Array(self, True, type_name, ptr + offset, length)
def fget(ptr): """Get the dynamic instance array.""" return Array(self, False, type_name, ptr.get_pointer(offset), length)
def fget(ptr): """Get the static instance array.""" return Array(self, False, type_name, ptr + offset, length)
def mem_write(path, pointer, length): data = Array(manager, False, Type.UCHAR, pointer, length) with open(path, "wb") as file: file.write(bytes([i for i in data]))
def mem_print(pointer, length): data = Array(manager, False, Type.UCHAR, pointer, length) print(' '.join("{:02X}".format(i) for i in data))