-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerator.py.cpp
More file actions
73 lines (70 loc) · 2.85 KB
/
generator.py.cpp
File metadata and controls
73 lines (70 loc) · 2.85 KB
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
72
73
#include <iostream>
#include <fstream>
using namespace std;
int main() {
string s = "\n"
"\n"
"f = open(\"Util.java\", \"w\")\n"
"\n"
"java_types = [\n"
" \"boolean\",\n"
" \"char\",\n"
" \"byte\",\n"
" \"short\",\n"
" \"int\",\n"
" \"long\",\n"
" \"float\",\n"
" \"double\"\n"
"]\n"
"\n"
"class_start = \"\"\"\n"
"public class Util \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t{\n"
"\n"
"\"\"\"\n"
"\n"
"f.write(class_start)\n"
"\n"
"method_template = \"\"\"\n"
"\\tpublic static void print(\n"
"\\t\\t%s\n"
"\\t) \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t{\n"
"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t/*\n"
"\\t\\t\\\"\\\"\\\"\n"
"\\t%s\n"
"\\t\\t\\\"\\\"\\\"\n"
"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t*/\n"
"\\t%s\n"
"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\n"
"\"\"\"\n"
"\n"
"\n"
"for java_type in java_types:\n"
" for i in range(64):\n"
" parameters = [\"arg\" + str(j) for j in range(i + 1)]\n"
" method_signature = [java_type + \" \" + param for param in parameters]\n"
" method_signature_formatted = \",\\n\\t\\t\".join(method_signature)\n"
"\n"
" method_docstring = (\"\\tPrints the %ss %s\\n\" % (java_type, \" \".join(parameters)))\n"
" method_docstring += \"\\n\\t\\tArgs:\\n\"\n"
"\n"
" method_body = \"\"\n"
"\n"
" for param in parameters:\n"
" print_lines = \"\"\"\\tSystem.out.print(%s)\\t\\t\\t\\t\\t\\t\\t\\t;\\n\\t\\tSystem.out.print(\" \")\\t\\t\\t\\t\\t\\t\\t\\t;\n"
" \"\"\" % param\n"
"\n"
" method_body += print_lines\n"
" method_docstring += \"\\t\\t\\t%s (%s): %s to be printed.\\n\" % (param, java_type, java_type)\n"
"\n"
" method_docstring += \"\\n\\t\\tReturns:\\n\\t\\t\\tNone\"\n"
" f.write(method_template % (method_signature_formatted, method_docstring, method_body))\n"
"f.write(\"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\")\n"
"\n"
"f.close()\n"
"";
ofstream outputFile;
outputFile.open("generator.py");
outputFile << s;
outputFile.close();
return 0;
}