summaryrefslogtreecommitdiffstats
path: root/src/CodeParser/CParser/CParser.ts
diff options
context:
space:
mode:
authorRowan Goemans <RB.Goemans@student.han.nl>2017-11-05 01:52:33 +0100
committerRowan Goemans <RB.Goemans@student.han.nl>2017-11-05 01:52:33 +0100
commitfb85979bfbda9a3df4138635217d471c50955740 (patch)
tree94a784cb7ae739c2df953cdc824ef3226a48f6d5 /src/CodeParser/CParser/CParser.ts
parent4006396da4c0d6040d78d88033d0b1fd166edbbf (diff)
downloaddoxdocgen-fb85979bfbda9a3df4138635217d471c50955740.tar.gz
-- Added support for void function no return get generated for them.
-- Added support for return of void pointers. They will get generated. -- Added support for return a pointer to a bool. There an extra return is added in addtion to "true" and "false". "null".
Diffstat (limited to 'src/CodeParser/CParser/CParser.ts')
-rw-r--r--src/CodeParser/CParser/CParser.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/CodeParser/CParser/CParser.ts b/src/CodeParser/CParser/CParser.ts
index 6de9ae0..942b65f 100644
--- a/src/CodeParser/CParser/CParser.ts
+++ b/src/CodeParser/CParser/CParser.ts
@@ -240,13 +240,27 @@ export default class CParser implements ICodeParser {
returnArg.Type.nodes = [];
}
+ // Check if return type is a pointer
+ const ptrReturnIndex = returnArg.Type.nodes
+ .findIndex((n) => n instanceof Token && n.Type === TokenType.Pointer);
+
+ // Special case for void functions.
+ const voidReturnIndex = returnArg.Type.nodes
+ .findIndex((n) => n instanceof Token && n.Type === TokenType.Symbol && n.Value === "void");
+
// Special case for bool return type.
const boolReturnIndex: number = returnArg.Type.nodes
.findIndex((n) => n instanceof Token && n.Type === TokenType.Symbol && n.Value === "bool");
+
if (boolReturnIndex !== -1) {
retVals.push("true");
retVals.push("false");
- } else {
+ if (ptrReturnIndex !== -1) {
+ retVals.push("null");
+ }
+ } else if (voidReturnIndex !== -1 && ptrReturnIndex !== -1) {
+ retVals.push(returnArg.Type.Yield());
+ } else if (voidReturnIndex === -1 && returnArg.Type.nodes.length > 0) {
retVals.push(returnArg.Type.Yield());
}