codegen-2 2.11.0__tar.gz → 2.12.0__tar.gz
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.
- {codegen_2-2.11.0 → codegen_2-2.12.0}/PKG-INFO +1 -1
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/models/expr.py +2 -2
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/models/statement.py +26 -4
- {codegen_2-2.11.0 → codegen_2-2.12.0}/pyproject.toml +1 -1
- {codegen_2-2.11.0 → codegen_2-2.12.0}/LICENSE +0 -0
- {codegen_2-2.11.0 → codegen_2-2.12.0}/README.md +0 -0
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/__init__.py +0 -0
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/models/__init__.py +0 -0
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/models/ast.py +0 -0
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/models/program.py +0 -0
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/models/types.py +0 -0
- {codegen_2-2.11.0 → codegen_2-2.12.0}/codegen/models/var.py +0 -0
|
@@ -164,10 +164,10 @@ class ExprAwait(Expr):
|
|
|
164
164
|
expr: Expr
|
|
165
165
|
|
|
166
166
|
def to_python(self):
|
|
167
|
-
return f"await {self.expr.to_python()}"
|
|
167
|
+
return f"(await {self.expr.to_python()})"
|
|
168
168
|
|
|
169
169
|
def to_typescript(self):
|
|
170
|
-
return f"await {self.expr.to_typescript()}"
|
|
170
|
+
return f"(await {self.expr.to_typescript()})"
|
|
171
171
|
|
|
172
172
|
|
|
173
173
|
@dataclass
|
|
@@ -80,7 +80,7 @@ class ImportStatement(Statement):
|
|
|
80
80
|
return f"import {{ {attr} as {self.alias} }} from '{module}';"
|
|
81
81
|
return f"import {{ {attr} }} from '{module}';"
|
|
82
82
|
else:
|
|
83
|
-
raise NotImplementedError()
|
|
83
|
+
raise NotImplementedError(self)
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
@dataclass
|
|
@@ -202,8 +202,8 @@ class DefClassVarStatement(Statement):
|
|
|
202
202
|
if self.is_static:
|
|
203
203
|
mod = "static "
|
|
204
204
|
else:
|
|
205
|
-
# static variable don't require type
|
|
206
|
-
assert self.type is not None
|
|
205
|
+
# static variable don't require type, but non-static do
|
|
206
|
+
assert self.type is not None, self
|
|
207
207
|
if self.type is not None:
|
|
208
208
|
type = f": {self.type}"
|
|
209
209
|
else:
|
|
@@ -214,6 +214,24 @@ class DefClassVarStatement(Statement):
|
|
|
214
214
|
return f"{mod}{self.name}{type} = {self.value.to_typescript()};"
|
|
215
215
|
|
|
216
216
|
|
|
217
|
+
@dataclass
|
|
218
|
+
class DefEnumValueStatement(Statement):
|
|
219
|
+
"""Statement to define an enum value"""
|
|
220
|
+
|
|
221
|
+
# name of the variable
|
|
222
|
+
name: str
|
|
223
|
+
# value of the variable
|
|
224
|
+
value: Optional[Expr] = None
|
|
225
|
+
|
|
226
|
+
def to_python(self):
|
|
227
|
+
raise NotImplementedError()
|
|
228
|
+
|
|
229
|
+
def to_typescript(self):
|
|
230
|
+
if self.value is None:
|
|
231
|
+
return f"{self.name},"
|
|
232
|
+
return f"{self.name} = {self.value.to_typescript()},"
|
|
233
|
+
|
|
234
|
+
|
|
217
235
|
@dataclass
|
|
218
236
|
class AssignStatement(Statement):
|
|
219
237
|
var: Var | Expr
|
|
@@ -239,7 +257,11 @@ class SingleExprStatement(Statement):
|
|
|
239
257
|
expr: Expr
|
|
240
258
|
|
|
241
259
|
def to_python(self):
|
|
242
|
-
|
|
260
|
+
stmt = self.expr.to_python()
|
|
261
|
+
if stmt[0] == "(" and stmt[-1] == ")":
|
|
262
|
+
# remove parentheses if they are not needed
|
|
263
|
+
stmt = stmt[1:-1]
|
|
264
|
+
return stmt
|
|
243
265
|
|
|
244
266
|
def to_typescript(self):
|
|
245
267
|
return self.expr.to_typescript()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|