summaryrefslogtreecommitdiffstats
path: root/rtemsqual/interface.py
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-06-09 11:25:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-07-03 10:22:45 +0200
commit3fe8ae0e012ca84fb5dad76f705661025fdfcd97 (patch)
tree2cbf7cea05a8a649c5beb3f1165200fb5f44ef1c /rtemsqual/interface.py
parentcontent: Fix CContent.close_for_loop() (diff)
downloadrtems-central-3fe8ae0e012ca84fb5dad76f705661025fdfcd97.tar.bz2
interface: Use CContent.function()
Diffstat (limited to 'rtemsqual/interface.py')
-rw-r--r--rtemsqual/interface.py37
1 files changed, 10 insertions, 27 deletions
diff --git a/rtemsqual/interface.py b/rtemsqual/interface.py
index 4915ffbf..0230ac3f 100644
--- a/rtemsqual/interface.py
+++ b/rtemsqual/interface.py
@@ -328,36 +328,19 @@ class Node:
return f"#define {name}"
def _get_function_definition(self, item: Item, definition: Any) -> Lines:
- body = definition["body"]
- ret = self.substitute_code(definition["return"])
- if body:
- ret = "static inline " + ret
+ content = CContent()
name = item["name"]
- space = "" if ret.endswith("*") else " "
- if definition["params"]:
- params = [
- self.substitute_code(param) for param in definition["params"]
- ]
- param_line = ", ".join(params)
- line = f"{ret}{space}{name}({param_line})"
- if len(line) > 79:
- line = f"{ret}{space}{name}"
- param_block = ",\n ".join(params)
- line = f"{ret}{space}{name}(\n {param_block}\n)"
- else:
- line = f"{ret}{space}{name}(void)"
- if len(line) > 79:
- line = f"{ret}\n{name}(void)"
+ ret = self.substitute_code(definition["return"])
+ params = [
+ self.substitute_code(param) for param in definition["params"]
+ ]
+ body = definition["body"]
if body:
- body_lines = self.substitute_code("\n ".join(
- body.strip("\n").split("\n")))
- line = f"""{line}
-{{
- {body_lines}
-}}"""
+ with content.function("static inline " + ret, name, params):
+ content.add(self.substitute_code(body))
else:
- line += ";"
- return line
+ content.declare_function(ret, name, params)
+ return content.lines
def _get_macro_definition(self, item: Item, definition: Any) -> Lines:
name = item["name"]