-
Notifications
You must be signed in to change notification settings - Fork 0
/
functionwrapper.cpp
executable file
·71 lines (52 loc) · 1.52 KB
/
functionwrapper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <functionwrapper.h>
#include <QStringListIterator>
QString functionwrapper(QString funcdecl, bool asInterface)
{
QString scope = "public";
if (getFirstLetter(funcdecl) == ".")
{
scope = "private";
funcdecl = ignoreFirstLetter(funcdecl);
};
if (getFirstLetter(funcdecl) == "#")
{
scope = "protected";
funcdecl = ignoreFirstLetter(funcdecl);
};
if (asInterface)
{
scope = "public";
};
QStringList formal_variables;
QStringList declaration;
QStringList comments;
QString methodname = funcdecl;
QString vars = "";
QStringList comments_for_vars;
QString v;
if (funcdecl.contains('@'))
{
formal_variables = funcdecl.split('@')[1].split('-');
methodname = funcdecl.split('@')[0];
QStringListIterator fv (formal_variables);
while (fv.hasNext())
{
v = fv.next();
declaration.append('$'+v);
comments_for_vars.append("* @param $"+v);
};
vars = declaration.join(',');
};
comments.append("/**");
comments.append("*");
comments.append("* Autocomment for "+methodname);
comments.append(comments_for_vars.join("\r\n"));
comments.append("*\r\n");
comments.append("*/\r\n");
QString w = ";";
if (!asInterface)
{
w = "{ }";
};
return comments.join("\r\n")+"\t " + scope + " function "+methodname+"( " + vars + " )"+ w + ";\r\n";
}