2 cpscript TYP name count1 type name ... count2 type name
10 count1 = int(sys.argv[3])
16 reqType[j] = sys.argv[i];
17 reqName[j] = sys.argv[i+1];
18 reqDesc[j] = sys.argv[i+2];
20 count2 = int(sys.argv[i])
26 repType[j] = sys.argv[i];
27 repName[j] = sys.argv[i+1];
28 repDesc[j] = sys.argv[i+2];
31 sys.stdout.write(
"/** Format a " + cmdType +
" control packet (request).\n");
32 for i
in range(count1) :
33 sys.stdout.write(
" * @param " + reqName[i] +
" " + reqDesc[i] +
"\n")
34 sys.stdout.write(
" * @param snum is the sequence number for the "
36 sys.stdout.write(
" */\n")
37 sys.stdout.write(
"void CtlPkt::fmt" + cmdName +
"(")
38 for i
in range(count1) :
39 if i != 0 : sys.stdout.write(
", ")
40 sys.stdout.write(reqType[i] +
" " + reqName[i])
41 sys.stdout.write(
", int64_t snum) {\n")
42 sys.stdout.write(
"\ttype = " + cmdType +
"; mode = REQUEST; seqNum = snum;\n")
43 sys.stdout.write(
"\tsetup();\n\t")
44 for i
in range(count1) :
45 sys.stdout.write(
"put(" + reqName[i] +
"); ")
46 if (count1 > 0) : sys.stdout.write(
"\n\t")
47 sys.stdout.write(
"paylen = next - payload;\n}\n\n")
49 sys.stdout.write(
"/** Extract a " + cmdType +
" control packet (request).\n");
50 for i
in range(count1) :
51 sys.stdout.write(
" * @param " + reqName[i] +
" " + reqDesc[i] +
"\n")
52 sys.stdout.write(
" * @return true if the extracted packet passes"
54 sys.stdout.write(
" */\n")
55 sys.stdout.write(
"bool CtlPkt::xtr" + cmdName +
"(")
56 for i
in range(count1) :
57 if i != 0 : sys.stdout.write(
", ")
58 sys.stdout.write(reqType[i] +
"& " + reqName[i])
59 sys.stdout.write(
") {\n\treturn\ttype == " + cmdType
60 +
" && mode == REQUEST\n\t\t");
61 for i
in range(count1) :
62 sys.stdout.write(
"&& get(" + reqName[i] +
") ")
63 if (count1 > 0) : sys.stdout.write(
"\n\t\t")
64 sys.stdout.write(
"&& paylen >= (next - payload);\n}\n\n");
66 sys.stdout.write(
"/** Format a " + cmdType +
" control packet reply.\n");
67 for i
in range(count2) :
68 sys.stdout.write(
" * @param " + repName[i] +
" " + repDesc[i] +
"\n")
69 sys.stdout.write(
" * @param snum is the sequence number for the "
70 +
"reply (optional)\n")
71 sys.stdout.write(
" */\n")
72 sys.stdout.write(
"void CtlPkt::fmt" + cmdName +
"Reply(")
73 for i
in range(count2) :
74 if i != 0 : sys.stdout.write(
", ")
75 sys.stdout.write(repType[i] +
" " + repName[i])
76 if count2 > 0 : sys.stdout.write(
", ")
77 sys.stdout.write(
"int64_t snum) {\n")
78 sys.stdout.write(
"\ttype = " + cmdType +
"; mode = POS_REPLY; "
79 +
"\n\tif (snum != 0) seqNum = snum;\n")
80 sys.stdout.write(
"\tsetup();\n\t")
81 for i
in range(count2) :
82 sys.stdout.write(
"put(" + repName[i] +
"); ")
83 if (count2 > 0) : sys.stdout.write(
"\n\t")
84 sys.stdout.write(
"paylen = next - payload;\n}\n\n")
86 sys.stdout.write(
"/** Extract a " + cmdType +
" control packet reply.\n");
87 for i
in range(count2) :
88 sys.stdout.write(
" * @param " + repName[i] +
" " + repDesc[i] +
"\n")
89 sys.stdout.write(
" * @return true if the extracted packet passes"
91 sys.stdout.write(
" */\n")
92 sys.stdout.write(
"bool CtlPkt::xtr" + cmdName +
"Reply(")
93 for i
in range(count2) :
94 if i != 0 : sys.stdout.write(
", ")
95 sys.stdout.write(repType[i] +
"& " + repName[i])
96 sys.stdout.write(
") {\n\treturn\ttype == " + cmdType
97 +
" && mode == REQUEST\n\t\t");
98 for i
in range(count2) :
99 sys.stdout.write(
"&& get(" + repName[i] +
") ")
100 if (count2 > 0) : sys.stdout.write(
"\n\t\t")
101 sys.stdout.write(
"&& paylen >= (next - payload);\n}\n\n");