Beispiel #1
0
    def _create_function(self, port):
        function = FunctionImplementation(port.functions['read'])

        data_type = self._types.get(port['data_type'])
        if data_type.passed_by() == TypeCollection.PASS_BY_POINTER:
            function.add_input_assert('value', 'value != NULL')

        return function
Beispiel #2
0
    def create_component_functions(self, port):
        prototype = port.functions['constant']
        data_type = self._types.get(port['data_type'])

        function = FunctionImplementation(prototype)

        constant_value = data_type.render_value(port['value'])
        if data_type.passed_by() == TypeCollection.PASS_BY_VALUE:
            function.set_return_statement(constant_value)
        else:
            function.add_input_assert('value', 'value != NULL')
            function.add_body(f'*value = {constant_value};')

        return {'constant': function}
Beispiel #3
0
    def create_component_functions(self, port):
        prototype = port.functions['constant']
        data_type = self._types.get(port['data_type'])

        function = FunctionImplementation(prototype)
        function.add_input_assert('index', f'index < {port["count"]}')

        constant_value = ',\n'.join(map(data_type.render_value, port['value']))
        function.add_body(
            f'static const {data_type.name} constant[{port["count"]}] = {{\n'
            f'{indent(constant_value)}\n'
            f'}};')
        if data_type.passed_by() == TypeCollection.PASS_BY_VALUE:
            function.set_return_statement('constant[index]')
        else:
            function.add_input_assert('value', 'value != NULL')
            function.add_body('*value = constant[index];')

        return {'constant': function}
Beispiel #4
0
    def _create_function(port):
        function = FunctionImplementation(port.functions['read'])
        function.add_input_assert('value', 'value != NULL')

        return function