diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-06-09 14:11:15 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-07-03 10:22:45 +0200 |
commit | 91461b9d42f6b6f462c91302e564ed6288c33bc8 (patch) | |
tree | 4fadbe591bc476071f06996832cb21f6a2b7b6bd /rtemsqual/content.py | |
parent | content: Add CContent().function() (diff) | |
download | rtems-central-91461b9d42f6b6f462c91302e564ed6288c33bc8.tar.bz2 |
content: Add CContent.call_function()
Diffstat (limited to 'rtemsqual/content.py')
-rw-r--r-- | rtemsqual/content.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/rtemsqual/content.py b/rtemsqual/content.py index fd73348a..f4679351 100644 --- a/rtemsqual/content.py +++ b/rtemsqual/content.py @@ -633,6 +633,33 @@ class CContent(Content): self.add(",\n".join(params)) self.add(f"){semicolon}") + def call_function(self, + ret: Optional[str], + name: str, + params: Optional[List[str]] = None) -> None: + """ Adds a function call. """ + if ret: + space = " " + else: + ret = "" + space = "" + if params: + param_line = "( " + ", ".join(params) + " )" + else: + param_line = "()" + line = f"{ret}{space}{name}{param_line};" + if len(self._indent) + len(line) > 79: + if params: + self._function(ret, name, params, param_line, space, ";") + elif ret: + self.add(ret) + with self.indent(): + self.add(f"{name}();") + else: + self.add(f"{name}();") + else: + self.add(line) + def declare_function(self, ret: str, name: str, |