@darabonba/python-generator 1.2.19 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +0 -158
- package/lib/builtin.js +818 -0
- package/lib/generator.js +2708 -0
- package/lib/helper.js +422 -0
- package/package.json +6 -5
- package/tests/expected/alias/setup.py +79 -0
- package/tests/expected/alias/tea_python_tests/__init__.py +1 -0
- package/tests/expected/alias/tea_python_tests/client.py +35 -0
- package/tests/expected/annotation/tea_python_tests/__init__.py +1 -0
- package/tests/expected/annotation/tea_python_tests/client.py +93 -0
- package/tests/expected/annotation/tea_python_tests/models.py +37 -0
- package/tests/expected/api/tea_python_tests/__init__.py +1 -0
- package/tests/expected/api/tea_python_tests/client.py +106 -0
- package/tests/expected/builtin/tea_python_tests/client.py +685 -0
- package/tests/expected/comment/tea_python_tests/__init__.py +1 -0
- package/tests/expected/comment/tea_python_tests/client.py +288 -0
- package/tests/expected/comment/tea_python_tests/models.py +195 -0
- package/tests/expected/complex/tea_python_tests/__init__.py +1 -0
- package/tests/expected/complex/tea_python_tests/client.py +1169 -0
- package/tests/expected/complex/tea_python_tests/exceptions.py +39 -0
- package/tests/expected/complex/tea_python_tests/models.py +570 -0
- package/tests/expected/const/tea_python_tests/__init__.py +1 -0
- package/tests/expected/const/tea_python_tests/client.py +14 -0
- package/{src/langs/python/files/setup.py.tmpl → tests/expected/empty/setup.py} +11 -11
- package/tests/expected/empty/tea_python_tests/__init__.py +1 -0
- package/tests/expected/empty/tea_python_tests/client.py +10 -0
- package/tests/expected/exec/tea_python_tests/__init__.py +1 -0
- package/tests/expected/exec/tea_python_tests/exec_client.py +21 -0
- package/tests/expected/function/tea_python_tests/__init__.py +1 -0
- package/tests/expected/function/tea_python_tests/client.py +64 -0
- package/tests/expected/import/setup.py +78 -0
- package/tests/expected/import/tea_python_tests/__init__.py +1 -0
- package/tests/expected/import/tea_python_tests/client.py +29 -0
- package/tests/expected/map/tea_python_tests/__init__.py +1 -0
- package/tests/expected/map/tea_python_tests/client.py +39 -0
- package/tests/expected/model/tea_python_tests/__init__.py +1 -0
- package/tests/expected/model/tea_python_tests/client.py +10 -0
- package/tests/expected/model/tea_python_tests/exceptions.py +28 -0
- package/tests/expected/model/tea_python_tests/models.py +780 -0
- package/tests/expected/multi/tea_python_tests/api.py +95 -0
- package/tests/expected/multi/tea_python_tests/client.py +40 -0
- package/tests/expected/multi/tea_python_tests/lib/util.py +19 -0
- package/tests/expected/multi/tea_python_tests/model/user.py +26 -0
- package/tests/expected/multi/tea_python_tests/model/user_exceptions.py +83 -0
- package/tests/expected/multi/tea_python_tests/model/user_models.py +145 -0
- package/tests/expected/statements/tea_python_tests/__init__.py +1 -0
- package/tests/expected/statements/tea_python_tests/client.py +86 -0
- package/tests/expected/super/tea_python_tests/__init__.py +1 -0
- package/tests/expected/super/tea_python_tests/client.py +16 -0
- package/tests/expected/typedef/setup.py +77 -0
- package/tests/expected/typedef/tea_python_tests/__init__.py +1 -0
- package/tests/expected/typedef/tea_python_tests/client.py +74 -0
- package/tests/expected/typedef/tea_python_tests/models.py +42 -0
- package/tests/fixtures/alias/Darafile +11 -0
- package/tests/fixtures/alias/libraries/Alias/Darafile +11 -0
- package/tests/fixtures/alias/libraries/Alias-Symbol/Darafile +11 -0
- package/tests/fixtures/builtin/Darafile +6 -0
- package/tests/fixtures/builtin/main.dara +333 -0
- package/tests/fixtures/complex/libraries/import.dara +18 -11
- package/tests/fixtures/complex/main.dara +452 -103
- package/tests/fixtures/import/libraries/Darafile +1 -1
- package/tests/fixtures/import/pack/Darafile +3 -0
- package/tests/fixtures/map/libraries/Darafile +3 -0
- package/tests/fixtures/map/libraries/import.dara +4 -0
- package/tests/fixtures/map/main.dara +17 -2
- package/tests/fixtures/model/.libraries.json +3 -0
- package/tests/fixtures/model/Darafile +5 -2
- package/tests/fixtures/model/libraries/Darafile +20 -0
- package/tests/fixtures/model/libraries/import.dara +27 -0
- package/tests/fixtures/model/main.dara +60 -42
- package/tests/fixtures/multi/.libraries.json +3 -0
- package/tests/fixtures/multi/Darafile +12 -0
- package/tests/fixtures/multi/api.dara +20 -0
- package/tests/fixtures/multi/lib/util.dara +5 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +68 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/main.tea +244 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/util.tea +2 -0
- package/tests/fixtures/multi/main.dara +32 -0
- package/tests/fixtures/multi/model/user.dara +35 -0
- package/tests/{python3.tests.js → main.tests.js} +107 -65
- package/tests/output/alias/setup.py +79 -0
- package/tests/output/alias/tea_python_tests/client.py +35 -0
- package/{src/langs/python2/files/setup.py.tmpl → tests/output/annotation/setup.py} +19 -24
- package/tests/output/annotation/tea_python_tests/client.py +93 -0
- package/tests/output/annotation/tea_python_tests/models.py +37 -0
- package/tests/output/api/setup.py +77 -0
- package/tests/output/api/tea_python_tests/client.py +106 -0
- package/tests/output/builtin/setup.py +77 -0
- package/tests/output/builtin/tea_python_tests/client.py +685 -0
- package/tests/output/comment/setup.py +77 -0
- package/tests/output/comment/tea_python_tests/client.py +288 -0
- package/tests/output/comment/tea_python_tests/models.py +195 -0
- package/tests/output/complex/setup.py +77 -0
- package/tests/output/complex/tea_python_tests/client.py +1169 -0
- package/tests/output/complex/tea_python_tests/exceptions.py +39 -0
- package/tests/output/complex/tea_python_tests/models.py +570 -0
- package/tests/output/const/setup.py +77 -0
- package/tests/output/const/tea_python_tests/client.py +14 -0
- package/tests/output/empty/setup.py +77 -0
- package/tests/output/empty/tea_python_tests/client.py +10 -0
- package/tests/output/exec/setup.py +77 -0
- package/tests/output/exec/tea_python_tests/exec_client.py +21 -0
- package/tests/output/function/setup.py +77 -0
- package/tests/output/function/tea_python_tests/client.py +64 -0
- package/tests/output/import/setup.py +78 -0
- package/tests/output/import/tea_python_tests/client.py +29 -0
- package/tests/output/map/setup.py +77 -0
- package/tests/output/map/tea_python_tests/client.py +39 -0
- package/tests/output/model/setup.py +77 -0
- package/tests/output/model/tea_python_tests/client.py +10 -0
- package/tests/output/model/tea_python_tests/exceptions.py +28 -0
- package/tests/output/model/tea_python_tests/models.py +780 -0
- package/tests/output/multi/setup.py +77 -0
- package/tests/output/multi/tea_python_tests/api.py +95 -0
- package/tests/output/multi/tea_python_tests/client.py +40 -0
- package/tests/output/multi/tea_python_tests/lib/util.py +19 -0
- package/tests/output/multi/tea_python_tests/model/user.py +26 -0
- package/tests/output/multi/tea_python_tests/model/user_exceptions.py +83 -0
- package/tests/output/multi/tea_python_tests/model/user_models.py +145 -0
- package/tests/output/statements/setup.py +77 -0
- package/tests/output/statements/tea_python_tests/client.py +86 -0
- package/tests/output/super/setup.py +77 -0
- package/tests/output/super/tea_python_tests/client.py +16 -0
- package/tests/output/typedef/setup.py +78 -0
- package/tests/output/typedef/tea_python_tests/client.py +74 -0
- package/tests/output/typedef/tea_python_tests/models.py +42 -0
- package/src/generator.js +0 -231
- package/src/langs/common/combinator.js +0 -193
- package/src/langs/common/config.js +0 -60
- package/src/langs/common/enum.js +0 -179
- package/src/langs/common/items.js +0 -551
- package/src/langs/common/package_info.js +0 -53
- package/src/langs/python/combinator.js +0 -1898
- package/src/langs/python/config.js +0 -169
- package/src/langs/python/files/.gitignore.tmpl +0 -5
- package/src/langs/python/files/__init__.py.tmpl +0 -1
- package/src/langs/python/package_info.js +0 -78
- package/src/langs/python2/combinator.js +0 -1770
- package/src/langs/python2/config.js +0 -162
- package/src/langs/python2/files/.gitignore.tmpl +0 -5
- package/src/langs/python2/files/__init__.py.tmpl +0 -1
- package/src/langs/python2/package_info.js +0 -78
- package/src/lib/debug.js +0 -55
- package/src/lib/emitter.js +0 -95
- package/src/lib/helper.js +0 -207
- package/src/resolver/base.js +0 -282
- package/src/resolver/client.js +0 -1013
- package/src/resolver/model.js +0 -159
- package/tests/common.tests.js +0 -244
- package/tests/lib.tests.js +0 -269
- package/tests/python2.tests.js +0 -283
- package/tests/resolver.tests.js +0 -434
|
@@ -2,104 +2,257 @@ import Source;
|
|
|
2
2
|
|
|
3
3
|
extends Source;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type @protocol = string
|
|
6
|
+
type @pathname = string
|
|
7
|
+
type @Strs = [ string ]
|
|
8
|
+
type @compleList = [[string]]
|
|
9
|
+
type @endpointMap = map[string]string
|
|
7
10
|
type @configs = [ Source.Config ];
|
|
8
11
|
|
|
9
|
-
init(
|
|
10
|
-
super(
|
|
11
|
-
@configs[0] =
|
|
12
|
+
init(sourceConfig: Source.Config){
|
|
13
|
+
super(sourceConfig);
|
|
14
|
+
@configs[0] = sourceConfig;
|
|
15
|
+
var test : Source = new Source(sourceConfig);
|
|
16
|
+
printData(sourceConfig, 'test');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exception Err1 = {
|
|
20
|
+
data: map[string]string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exception Err2 = {
|
|
24
|
+
accessErrMessage: string
|
|
12
25
|
}
|
|
13
26
|
|
|
27
|
+
|
|
14
28
|
model ComplexRequest = {
|
|
15
29
|
accessKey: string,
|
|
16
30
|
body: readable(name='Body', example='Body', description='Body'),
|
|
17
31
|
strs: [ string ](name='Strs', example='Strs', description='Strs'),
|
|
32
|
+
mapList: [ map[string]any ](name='mapList', example='mapList', description='mapList', deprecated=false),
|
|
18
33
|
header: {
|
|
19
|
-
content: string(name='Content', example='Content
|
|
34
|
+
content: string(name='Content', example='Content
|
|
35
|
+
|
|
36
|
+
test example
|
|
37
|
+
test example11', signed='true', description='The ID of the security group to which you want to assign the instance. Instances in the same security group can communicate with each other. The maximum number of instances that a security group can contain depends on the type of the security group. For more information, see the "Security group limits" section in [Limits](https://help.aliyun.com/document_detail/25412.html#SecurityGroupQuota).
|
|
38
|
+
|
|
39
|
+
>Notice: The network type of the new instance must be the same as that of the security group specified by the `SecurityGroupId` parameter. For example, if the specified security group is of the VPC type, the new instance is also of the VPC type and you must specify `VSwitchId`.
|
|
40
|
+
|
|
41
|
+
If you do not use `LaunchTemplateId` or `LaunchTemplateName` to specify a launch template, you must specify SecurityGroupId. Take note of the following items:
|
|
42
|
+
|
|
43
|
+
* You can set `SecurityGroupId` to specify a single security group or set `SecurityGroupIds.N` to specify one or more security groups. However, you cannot specify both `SecurityGroupId` and `SecurityGroupIds.N`.
|
|
44
|
+
* If `NetworkInterface.N.InstanceType` is set to `Primary`, you cannot specify `SecurityGroupId` or `SecurityGroupIds.N` but can specify `NetworkInterface.N.SecurityGroupId` or `NetworkInterface.N.SecurityGroupIds.N`.', nullable=true, checkBlank=true, sensitive=false)
|
|
20
45
|
}(description='header', name='header'),
|
|
21
|
-
Num: number,
|
|
22
46
|
configs: {
|
|
23
47
|
key: string,
|
|
24
48
|
value: [ string ],
|
|
25
49
|
extra: map[string] string
|
|
26
50
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
]
|
|
51
|
+
num: number(name='num', nullable=false, checkBlank=false, sensitive=true),
|
|
52
|
+
i64: int64,
|
|
53
|
+
f64: double,
|
|
54
|
+
b: boolean,
|
|
55
|
+
f32: float,
|
|
56
|
+
f64List: [ double ],
|
|
57
|
+
floatList: [ float ],
|
|
58
|
+
booleantList: [ boolean ],
|
|
59
|
+
i32: int32,
|
|
60
|
+
stringList: [ string ],
|
|
61
|
+
intList: [ integer ],
|
|
62
|
+
int32List: [ int32 ],
|
|
63
|
+
int16List: [ int16 ],
|
|
64
|
+
int64List: [ int64 ],
|
|
65
|
+
longList: [ long ],
|
|
66
|
+
uint64List: [ uint64 ],
|
|
67
|
+
uint32List: [ uint32 ],
|
|
68
|
+
uint16List: [ uint16 ],
|
|
69
|
+
u64: uint64,
|
|
70
|
+
u32: uint32,
|
|
71
|
+
u16: uint16,
|
|
72
|
+
obj: object,
|
|
73
|
+
any: any,
|
|
74
|
+
byt: bytes,
|
|
75
|
+
req: $Request,
|
|
76
|
+
resp: $Response,
|
|
77
|
+
map: map[string]string,
|
|
78
|
+
numMap: map[string]number,
|
|
79
|
+
modelMap: map[string]Source.Request,
|
|
80
|
+
request: Source.Request,
|
|
81
|
+
client: Source,
|
|
82
|
+
instance: Source.Request.instance,
|
|
44
83
|
from: string(name='from', description='test keywords'),
|
|
45
84
|
self: string(name='self', description='test keywords'),
|
|
46
85
|
print: string(name='print', description='test keywords'),
|
|
47
86
|
exec: string(name='exec', description='test keywords'),
|
|
87
|
+
str: string(name='srt', description='test keywords'),
|
|
88
|
+
part?: [
|
|
89
|
+
{
|
|
90
|
+
partNumber?: string(description='PartNumber', name='PartNumber')
|
|
91
|
+
}
|
|
92
|
+
](description='Part', name='Part', deprecated=true),
|
|
48
93
|
}
|
|
49
94
|
|
|
50
|
-
|
|
51
|
-
|
|
95
|
+
model Response {
|
|
96
|
+
instance: ComplexRequest.part,
|
|
52
97
|
}
|
|
53
98
|
|
|
54
|
-
|
|
55
|
-
|
|
99
|
+
async function hello(request: object, strs: [ string ], complexList: [[string]]): [ string ] {
|
|
100
|
+
var a : [[string]] = null;
|
|
101
|
+
return array1();
|
|
56
102
|
}
|
|
57
103
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (x && y || !z) {
|
|
63
|
-
x = y;
|
|
64
|
-
}
|
|
65
|
-
// to map test.
|
|
66
|
-
var req = new Source.Request{};
|
|
67
|
-
var m = callToMap(req);
|
|
68
|
-
|
|
104
|
+
static async function print(reqeust: $Request, reqs: [ ComplexRequest ], response: $Response, val: map[string]string): Source.Request;
|
|
105
|
+
|
|
106
|
+
static function intToInt32(a: int32):void;
|
|
107
|
+
api Complex1(request: ComplexRequest, sourceClient: Source): Source.RuntimeObject {
|
|
69
108
|
var name = 'complex';
|
|
70
|
-
var
|
|
71
|
-
var
|
|
109
|
+
var read : readable = null;
|
|
110
|
+
var byt : bytes = null;
|
|
72
111
|
var moduleModelMapVal: map[string] Source.RuntimeObject = {};
|
|
73
112
|
var moduleMapVal: map[string] Source = {};
|
|
74
113
|
var modelMapVal: map[string] ComplexRequest = {};
|
|
75
114
|
var subModelMapVal: map[string] ComplexRequest.header = {};
|
|
115
|
+
var reqMap : map[string]ComplexRequest = null;
|
|
116
|
+
var mapString = {
|
|
117
|
+
str = request.accessKey,
|
|
118
|
+
};
|
|
119
|
+
var inte : integer = 1;
|
|
120
|
+
var a : integer = 1;
|
|
121
|
+
var b : int32 = null;
|
|
122
|
+
b = a;
|
|
123
|
+
var c : int32 = a;
|
|
124
|
+
intToInt32(a);
|
|
125
|
+
var mapVal = {
|
|
126
|
+
read = read,
|
|
127
|
+
test = '{"test":"ok"}',
|
|
128
|
+
b = request.b,
|
|
129
|
+
num = request.num,
|
|
130
|
+
u16 = request.u16,
|
|
131
|
+
u32 = request.u32,
|
|
132
|
+
u64 = request.u64,
|
|
133
|
+
u16List = request.uint16List,
|
|
134
|
+
u32List = request.uint32List,
|
|
135
|
+
u64List = request.uint64List,
|
|
136
|
+
i64List = request.int64List,
|
|
137
|
+
i16List = request.int16List,
|
|
138
|
+
i32List = request.int32List,
|
|
139
|
+
intList = request.intList,
|
|
140
|
+
stringList = request.stringList,
|
|
141
|
+
i32 = request.i32,
|
|
142
|
+
booleantList = request.booleantList,
|
|
143
|
+
floatList = request.floatList,
|
|
144
|
+
float64List = request.f64List,
|
|
145
|
+
f32 = request.f32,
|
|
146
|
+
f64 = request.f64,
|
|
147
|
+
i64 = request.i64,
|
|
148
|
+
};
|
|
149
|
+
var abool = true;
|
|
150
|
+
var req = new ComplexRequest{
|
|
151
|
+
b = false,
|
|
152
|
+
num = 10,
|
|
153
|
+
i32 = a,
|
|
154
|
+
intList = [10,11],
|
|
155
|
+
int16List = [10, 11],
|
|
156
|
+
int32List = [10, 11],
|
|
157
|
+
int64List = [10, 11],
|
|
158
|
+
longList = [10L, 11L],
|
|
159
|
+
floatList = [ 0.1f, 0.2f ],
|
|
160
|
+
stringList = ['10','11'],
|
|
161
|
+
booleantList = [ true, false ],
|
|
162
|
+
};
|
|
163
|
+
var longList : [long] = [
|
|
164
|
+
432435L
|
|
165
|
+
];
|
|
166
|
+
var anyList : [any] = [
|
|
167
|
+
432435L,
|
|
168
|
+
"str",
|
|
169
|
+
true,
|
|
170
|
+
10,
|
|
171
|
+
0.1f
|
|
172
|
+
];
|
|
173
|
+
var floatMap : map[string]float = {
|
|
174
|
+
key1 = 0.1f,
|
|
175
|
+
key2 = 0.2
|
|
176
|
+
};
|
|
177
|
+
var doubleMap : map[string]double = {
|
|
178
|
+
key1 = 0.1d,
|
|
179
|
+
key2 = 0.2d
|
|
180
|
+
};
|
|
181
|
+
var intMap : map[string]integer = {
|
|
182
|
+
key1 = 1,
|
|
183
|
+
key2 = 2
|
|
184
|
+
};
|
|
185
|
+
var longMap : map[string]long = {
|
|
186
|
+
key1 = 1,
|
|
187
|
+
key2 = 2
|
|
188
|
+
};
|
|
189
|
+
var int16Map : map[string]int16 = {
|
|
190
|
+
key1 = 1,
|
|
191
|
+
key2 = 2
|
|
192
|
+
};
|
|
193
|
+
var int32Map : map[string]int32 = {
|
|
194
|
+
key1 = 1,
|
|
195
|
+
key2 = 2
|
|
196
|
+
};
|
|
197
|
+
var int64Map : map[string]int64 = {
|
|
198
|
+
key1 = 1,
|
|
199
|
+
key2 = 2
|
|
200
|
+
};
|
|
201
|
+
var anyMap : map[string]any = {
|
|
202
|
+
key1 = 0.1,
|
|
203
|
+
key2 = 1,
|
|
204
|
+
key3 = 'test',
|
|
205
|
+
key4 = true,
|
|
206
|
+
key5 = ['test', 1, true, ['test']],
|
|
207
|
+
key6 = [
|
|
208
|
+
{
|
|
209
|
+
a = "test",
|
|
210
|
+
b = 1,
|
|
211
|
+
c = true,
|
|
212
|
+
d = ['test'],
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
for (var itemTmp : anyList) {
|
|
218
|
+
$Logger.info(`${itemTmp}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
for (var item : ["1","2"]) {
|
|
222
|
+
var anyMap : map[string]string = {};
|
|
223
|
+
anyMap[item] = 'test';
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
@Strs = request.strs;
|
|
227
|
+
@protocol = 'test';
|
|
228
|
+
@endpointMap[@protocol];
|
|
229
|
+
@endpointMap['test'] = 'ok';
|
|
230
|
+
request.strs = @Strs;
|
|
76
231
|
__request.protocol = @protocol;
|
|
77
|
-
__request.port =
|
|
232
|
+
__request.port = request.num;
|
|
78
233
|
__request.method = 'GET';
|
|
79
234
|
__request.pathname = `/${@pathname}`;
|
|
80
|
-
__request.query =
|
|
235
|
+
__request.query = {
|
|
81
236
|
date = '2019',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
from = 'test',
|
|
237
|
+
name = __request.method,
|
|
238
|
+
};
|
|
239
|
+
var tmp = {
|
|
240
|
+
...__request.query,
|
|
241
|
+
...__request.headers,
|
|
242
|
+
...__request,
|
|
89
243
|
};
|
|
90
|
-
Complex3(from);
|
|
91
244
|
} returns {
|
|
92
|
-
if (true && true)
|
|
245
|
+
if (true && true){
|
|
93
246
|
return null;
|
|
94
|
-
} else if
|
|
247
|
+
} else if(Source.judgeStr("test") || false){
|
|
95
248
|
return new Source.RuntimeObject{};
|
|
96
249
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
hello(
|
|
100
|
-
hello(null, null);
|
|
101
|
-
Complex3(null);
|
|
250
|
+
sourceClient.printData(request, '1');
|
|
251
|
+
hello(request, ["1","2"], null);
|
|
252
|
+
hello(null, null, null);
|
|
102
253
|
return {};
|
|
254
|
+
Complex3(null, 'test');
|
|
255
|
+
return null;
|
|
103
256
|
} runtime {
|
|
104
257
|
timeouted = 'retry'
|
|
105
258
|
}
|
|
@@ -107,32 +260,44 @@ api complex1(request: ComplexRequest, client: Source): Source.RuntimeObject {
|
|
|
107
260
|
api Complex2(request: ComplexRequest, str: [ string ], val: map[string]string): object {
|
|
108
261
|
var name = 'complex';
|
|
109
262
|
var config = new Source.Config{};
|
|
110
|
-
var
|
|
263
|
+
var sourceClient = new Source(config);
|
|
264
|
+
var configArray : [Source.Config] = [config];
|
|
265
|
+
sourceClient.printData(request, '1');
|
|
111
266
|
__request.protocol = 'HTTP';
|
|
112
267
|
__request.port = 80;
|
|
113
268
|
__request.method = 'GET';
|
|
114
269
|
__request.pathname = '/';
|
|
115
|
-
__request.query =
|
|
270
|
+
__request.query = {
|
|
116
271
|
date = '2019',
|
|
117
|
-
version = __module.version,
|
|
118
272
|
protocol = __request.protocol,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
119
275
|
|
|
120
|
-
|
|
121
|
-
|
|
276
|
+
api ComplexMap(): map[string]any {
|
|
277
|
+
} runtime {
|
|
278
|
+
|
|
122
279
|
}
|
|
123
280
|
|
|
124
|
-
api Complex3(request: ComplexRequest): ComplexRequest {
|
|
125
|
-
|
|
126
|
-
__request.protocol =
|
|
281
|
+
api Complex3(request: ComplexRequest, name: string): ComplexRequest {
|
|
282
|
+
name = 'complex';
|
|
283
|
+
__request.protocol = templateString();
|
|
127
284
|
__request.port = 80;
|
|
128
285
|
__request.method = 'GET';
|
|
129
286
|
__request.pathname = '/';
|
|
130
|
-
__request.
|
|
287
|
+
__request.body = 'body';
|
|
288
|
+
__request.query = {
|
|
131
289
|
date = '2019',
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
290
|
+
};
|
|
291
|
+
var tmp : ComplexRequest = null;
|
|
292
|
+
tmp = returnModel();
|
|
293
|
+
name = @protocol;
|
|
135
294
|
} returns {
|
|
295
|
+
var x = false;
|
|
296
|
+
var y = true;
|
|
297
|
+
var z = false;
|
|
298
|
+
if (x && y || !z) {
|
|
299
|
+
x = y;
|
|
300
|
+
}
|
|
136
301
|
var resp = __response;
|
|
137
302
|
var req = new Source.Request{
|
|
138
303
|
accesskey = request.accessKey,
|
|
@@ -141,17 +306,80 @@ api Complex3(request: ComplexRequest): ComplexRequest {
|
|
|
141
306
|
array0(request);
|
|
142
307
|
req.accesskey = 'accesskey';
|
|
143
308
|
req.accesskey = request.accessKey;
|
|
144
|
-
|
|
309
|
+
printNull();
|
|
310
|
+
throwsFunc();
|
|
311
|
+
__response.statusCode;
|
|
145
312
|
Source.array(request, '1');
|
|
146
|
-
Source.asyncFunc();
|
|
147
313
|
return {
|
|
148
314
|
...__request.query
|
|
149
315
|
};
|
|
150
316
|
}
|
|
151
317
|
|
|
318
|
+
static function assignWithArray() throws: void {
|
|
319
|
+
var list : [ string ] = null;
|
|
320
|
+
list = [ "test" ];
|
|
321
|
+
|
|
322
|
+
var str : string = null;
|
|
323
|
+
str = throwsFunc();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function mapAcess(): any {
|
|
327
|
+
var tmp : map[string]any = {
|
|
328
|
+
protocol = @endpointMap[@protocol]
|
|
329
|
+
};
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
async function exprFunc(): [ string ] {
|
|
335
|
+
if (!true) {
|
|
336
|
+
|
|
337
|
+
}
|
|
338
|
+
var num = 10;
|
|
339
|
+
var req = new ComplexRequest{};
|
|
340
|
+
var mapVal : map[string]any = {
|
|
341
|
+
num = 10,
|
|
342
|
+
client = Source,
|
|
343
|
+
strs = array1(),
|
|
344
|
+
str = `string${num}`,
|
|
345
|
+
str1 = `string${req.accessKey}`,
|
|
346
|
+
};
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
static async function printNull(): void {
|
|
351
|
+
try {
|
|
352
|
+
var str = templateString();
|
|
353
|
+
} catch(e) {
|
|
354
|
+
|
|
355
|
+
} finally {
|
|
356
|
+
var final = 'ok';
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
static async function testTryWithComplexReturnType(): Source.Request {
|
|
361
|
+
try {
|
|
362
|
+
var str = templateString();
|
|
363
|
+
} catch(e) {
|
|
364
|
+
|
|
365
|
+
} finally {
|
|
366
|
+
var final = 'ok';
|
|
367
|
+
}
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static async function testTryWithComplexReturnTypeWithOutCat(): Source.Request {
|
|
372
|
+
try {
|
|
373
|
+
var str = templateString();
|
|
374
|
+
} catch(e) {
|
|
375
|
+
var sim = 'a';
|
|
376
|
+
} finally {
|
|
377
|
+
var final = 'ok';
|
|
378
|
+
}
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
|
|
152
382
|
static function array0(req: object): [ any ] {
|
|
153
|
-
var temp = new Source.Config{};
|
|
154
|
-
var anyArr : [Source.Config] = [temp];
|
|
155
383
|
return [];
|
|
156
384
|
}
|
|
157
385
|
|
|
@@ -159,29 +387,93 @@ static function array1(): [ string ] {
|
|
|
159
387
|
return ["1"];
|
|
160
388
|
}
|
|
161
389
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var anyArr : [Source.Config] = [temp];
|
|
165
|
-
return [[anyArr]];
|
|
390
|
+
async function templateString(): string {
|
|
391
|
+
return `/${@protocol}`;
|
|
166
392
|
}
|
|
167
393
|
|
|
168
|
-
|
|
394
|
+
function intOp(a: integer): void {
|
|
395
|
+
var b = a;
|
|
396
|
+
var tmp: map[string]integer = {
|
|
397
|
+
first = a
|
|
398
|
+
};
|
|
399
|
+
b++;
|
|
400
|
+
++b;
|
|
401
|
+
b--;
|
|
402
|
+
--b;
|
|
403
|
+
tmp.a++;
|
|
404
|
+
++tmp.a;
|
|
405
|
+
tmp.a--;
|
|
406
|
+
--tmp.a;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function throwsFunc() throws: string {
|
|
169
410
|
return `/${@protocol}`;
|
|
170
411
|
}
|
|
171
412
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
413
|
+
function throwsFunc1() throws: string {
|
|
414
|
+
return '';
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function throwsFunc2() throws: void {
|
|
418
|
+
throw {
|
|
419
|
+
code = '',
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function throwsFunc3() throws: string {
|
|
424
|
+
throw {
|
|
425
|
+
code = '',
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function getInt(num: int32): int32 {
|
|
430
|
+
return num;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function returnFunc(): string {
|
|
434
|
+
var index: int32 = 0;
|
|
435
|
+
var i = getInt(index);
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function returnFunc1(cfg: Source.Config): Source {
|
|
440
|
+
var config = new Source.Config{};
|
|
441
|
+
return new Source(config);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function returnFunc2(): map[string]any {
|
|
445
|
+
var tmp = {
|
|
446
|
+
subMap = 'ok',
|
|
447
|
+
};
|
|
448
|
+
var mapVal = {
|
|
449
|
+
test = tmp,
|
|
450
|
+
};
|
|
451
|
+
if (Source.judgeStr("test")) {
|
|
452
|
+
return mapVal['test'];
|
|
453
|
+
} else {
|
|
454
|
+
var body : readable = null;
|
|
455
|
+
return {
|
|
456
|
+
body = body,
|
|
457
|
+
...tmp
|
|
458
|
+
};
|
|
182
459
|
}
|
|
183
460
|
}
|
|
184
461
|
|
|
462
|
+
function returnModel(): ComplexRequest {
|
|
463
|
+
return new ComplexRequest{};
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function emptyFunc(): void;
|
|
467
|
+
|
|
468
|
+
api noReturn(): void {
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function Error(e: $Error): $Error {
|
|
472
|
+
var tmp : $Error = null;
|
|
473
|
+
var c : class = null;
|
|
474
|
+
return e;
|
|
475
|
+
}
|
|
476
|
+
|
|
185
477
|
static function arrayAccess(): string {
|
|
186
478
|
var configs = ['a', 'b', 'c'];
|
|
187
479
|
var config = configs[0];
|
|
@@ -196,14 +488,17 @@ static function arrayAccess2(): string {
|
|
|
196
488
|
return config;
|
|
197
489
|
}
|
|
198
490
|
|
|
199
|
-
static function arrayAccess3(request: ComplexRequest
|
|
491
|
+
static function arrayAccess3(request: ComplexRequest): string {
|
|
492
|
+
var req = new Source.Request{};
|
|
493
|
+
arrayAccess4([req]);
|
|
200
494
|
var configVal = request.configs.value[0];
|
|
201
|
-
var val = request.configs.value[index];
|
|
202
|
-
var i0 = 0;
|
|
203
|
-
val = request.configs.value[i0];
|
|
204
495
|
return configVal;
|
|
205
496
|
}
|
|
206
497
|
|
|
498
|
+
static function arrayAccess4(requests: [ Source.Request ]): string {
|
|
499
|
+
return '';
|
|
500
|
+
}
|
|
501
|
+
|
|
207
502
|
static function arrayAssign(config: string): [ string ] {
|
|
208
503
|
var configs = ['a', 'b', 'c'];
|
|
209
504
|
configs[3] = config;
|
|
@@ -220,8 +515,6 @@ static function arrayAssign2(config: string): [ string ] {
|
|
|
220
515
|
|
|
221
516
|
static function arrayAssign3(request: ComplexRequest, config: string): void {
|
|
222
517
|
request.configs.value[0] = config;
|
|
223
|
-
var i0 = 0;
|
|
224
|
-
request.configs.value[i0] = config;
|
|
225
518
|
}
|
|
226
519
|
|
|
227
520
|
static function mapAccess(request: ComplexRequest): string {
|
|
@@ -229,11 +522,8 @@ static function mapAccess(request: ComplexRequest): string {
|
|
|
229
522
|
return configInfo;
|
|
230
523
|
}
|
|
231
524
|
|
|
232
|
-
static function mapAccess2(request: Source.Request
|
|
525
|
+
static function mapAccess2(request: Source.Request): string {
|
|
233
526
|
var configInfo = request.configs.extra['name'];
|
|
234
|
-
var configValue = request.configs.extra[key];
|
|
235
|
-
var i0 = key;
|
|
236
|
-
configValue = request.configs.extra[i0];
|
|
237
527
|
return configInfo;
|
|
238
528
|
}
|
|
239
529
|
|
|
@@ -246,12 +536,35 @@ static function mapAccess3(): string {
|
|
|
246
536
|
return data.configs['value'];
|
|
247
537
|
}
|
|
248
538
|
|
|
539
|
+
static function mapAccess4(request: ComplexRequest): string {
|
|
540
|
+
var key : string = 'name';
|
|
541
|
+
var model = request.modelMap[key];
|
|
542
|
+
var configInfo = request.configs.extra[key];
|
|
543
|
+
return configInfo;
|
|
544
|
+
}
|
|
545
|
+
|
|
249
546
|
static function mapAssign(request: ComplexRequest, name: string): void {
|
|
250
547
|
request.configs.extra['name'] = name;
|
|
251
|
-
var
|
|
252
|
-
|
|
548
|
+
var key : string = 'name';
|
|
549
|
+
name = key;
|
|
550
|
+
request.configs.extra[key] = name;
|
|
551
|
+
name = request.configs.extra['name'];
|
|
552
|
+
request.map[key] = name;
|
|
553
|
+
request.numMap[key] = 1;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
static function arrayimport2(request: [ Source.Request ]): string {
|
|
557
|
+
return '';
|
|
253
558
|
}
|
|
254
559
|
|
|
560
|
+
static async function defaultReturn(): void {
|
|
561
|
+
if (true) {
|
|
562
|
+
|
|
563
|
+
} else {
|
|
564
|
+
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
255
568
|
static function strFmt(): void {
|
|
256
569
|
var s = 'strtest';
|
|
257
570
|
var s1 = ` % 1${s}`;
|
|
@@ -268,6 +581,42 @@ static function strFmt(): void {
|
|
|
268
581
|
var fs3 = `${} ${s}`;
|
|
269
582
|
}
|
|
270
583
|
|
|
271
|
-
|
|
272
|
-
|
|
584
|
+
async function multiTryCatch(a: number): void {
|
|
585
|
+
try {
|
|
586
|
+
if(a > 0) {
|
|
587
|
+
throw new Err1 {
|
|
588
|
+
name = "str",
|
|
589
|
+
code = "str",
|
|
590
|
+
data = {
|
|
591
|
+
key1 = "str",
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
} else if(a == 0) {
|
|
595
|
+
throw new Err2 {
|
|
596
|
+
name = "str",
|
|
597
|
+
code = "str",
|
|
598
|
+
accessErrMessage = "str2",
|
|
599
|
+
};
|
|
600
|
+
} else if(a == -10) {
|
|
601
|
+
throw new Source.Err3 {
|
|
602
|
+
name = "str",
|
|
603
|
+
code = "str",
|
|
604
|
+
};
|
|
605
|
+
} else {
|
|
606
|
+
throw new $Error{
|
|
607
|
+
name = "str",
|
|
608
|
+
code = "str",
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
} catch(err: Err1) {
|
|
612
|
+
$Logger.log(err.name);
|
|
613
|
+
} catch(err: Err2) {
|
|
614
|
+
$Logger.log(err.name);
|
|
615
|
+
} catch(err: Source.Err3) {
|
|
616
|
+
$Logger.log(err.name);
|
|
617
|
+
} catch(err) {
|
|
618
|
+
$Logger.log(err.name);
|
|
619
|
+
} finally {
|
|
620
|
+
var final = 'ok';
|
|
621
|
+
}
|
|
273
622
|
}
|