diff options
author | Håkon Vågsether <haakonsv@gmail.com> | 2017-07-24 19:54:26 +0200 |
---|---|---|
committer | Andrej Rode <mail@andrejro.de> | 2018-11-23 00:51:15 +0100 |
commit | bac53b29f7008b33667a7c2c481ace02d73f3264 (patch) | |
tree | 409803943b08f5ff7d85e567c49ab94e6f545174 /grc/core/blocks/_build.py | |
parent | 8dc5fa49dc4c669c28ffb1216625ae92475c4ec9 (diff) |
Add C++ generation
Diffstat (limited to 'grc/core/blocks/_build.py')
-rw-r--r-- | grc/core/blocks/_build.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/grc/core/blocks/_build.py b/grc/core/blocks/_build.py index 0c41d1ae70..bed0f6934a 100644 --- a/grc/core/blocks/_build.py +++ b/grc/core/blocks/_build.py @@ -33,7 +33,7 @@ from ._templates import MakoTemplates def build(id, label='', category='', flags='', documentation='', value=None, asserts=None, - parameters=None, inputs=None, outputs=None, templates=None, **kwargs): + parameters=None, inputs=None, outputs=None, templates=None, cpp_templates=None, **kwargs): block_id = id cls = type(str(block_id), (Block,), {}) @@ -63,6 +63,17 @@ def build(id, label='', category='', flags='', documentation='', callbacks=templates.get('callbacks', []), var_make=templates.get('var_make', ''), ) + + cpp_templates = cpp_templates or {} + cls.cpp_templates = MakoTemplates( + includes=cpp_templates.get('includes', ''), + make=cpp_templates.get('make', ''), + callbacks=cpp_templates.get('callbacks', []), + var_make=cpp_templates.get('var_make', ''), + link=cpp_templates.get('link', []), + translations=cpp_templates.get('translations', []), + declarations=cpp_templates.get('declarations', ''), + ) # todo: MakoTemplates.compile() to check for errors cls.value = _single_mako_expr(value, block_id) @@ -149,4 +160,3 @@ def _validate_option_attributes(param_data, block_id): if key in dir(str): del param_data['option_attributes'][key] send_warning('{} - option_attribute "{}" overrides str, ignoring'.format(block_id, key)) - |