summaryrefslogtreecommitdiffstats
path: root/src/CodeParser
diff options
context:
space:
mode:
authorRowan Goemans <RB.Goemans@student.han.nl>2017-11-05 01:52:33 +0100
committerChristoph Schlosser <christophschlosser@users.noreply.github.com>2017-11-05 18:45:08 +0100
commitec691aad83da0adcf13986fd3d24b213ef963116 (patch)
tree94a784cb7ae739c2df953cdc824ef3226a48f6d5 /src/CodeParser
parent1c5cce4d4d8af15bbd293956814a0fd0cb1f5313 (diff)
downloaddoxdocgen-ec691aad83da0adcf13986fd3d24b213ef963116.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')
-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());
}