codegen-2 2.7.0__py3-none-any.whl → 2.7.2__py3-none-any.whl
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/models/expr.py +3 -0
- codegen/models/statement.py +16 -4
- {codegen_2-2.7.0.dist-info → codegen_2-2.7.2.dist-info}/METADATA +1 -1
- {codegen_2-2.7.0.dist-info → codegen_2-2.7.2.dist-info}/RECORD +6 -6
- {codegen_2-2.7.0.dist-info → codegen_2-2.7.2.dist-info}/WHEEL +1 -1
- {codegen_2-2.7.0.dist-info → codegen_2-2.7.2.dist-info}/LICENSE +0 -0
codegen/models/expr.py
CHANGED
|
@@ -266,6 +266,9 @@ class PredefinedFn:
|
|
|
266
266
|
def to_python(self):
|
|
267
267
|
return f"[{', '.join([item.to_python() for item in self.items])}]"
|
|
268
268
|
|
|
269
|
+
def to_typescript(self):
|
|
270
|
+
return f"[{', '.join([item.to_typescript() for item in self.items])}]"
|
|
271
|
+
|
|
269
272
|
@dataclass
|
|
270
273
|
class dict(Expr):
|
|
271
274
|
items: Sequence[tuple[Expr, Expr]]
|
codegen/models/statement.py
CHANGED
|
@@ -100,7 +100,7 @@ class DefFuncStatement(Statement):
|
|
|
100
100
|
sig = "async " + sig
|
|
101
101
|
sig = sig + ":"
|
|
102
102
|
if self.is_static:
|
|
103
|
-
sig = "
|
|
103
|
+
sig = "@staticmethod\n" + sig
|
|
104
104
|
if self.comment != "":
|
|
105
105
|
sig = (
|
|
106
106
|
sig
|
|
@@ -185,6 +185,8 @@ class DefClassVarStatement(Statement):
|
|
|
185
185
|
type: Optional[str]
|
|
186
186
|
# value of the variable
|
|
187
187
|
value: Optional[Expr] = None
|
|
188
|
+
# whether this variable is static
|
|
189
|
+
is_static: bool = False
|
|
188
190
|
|
|
189
191
|
def to_python(self):
|
|
190
192
|
if self.type is None:
|
|
@@ -196,10 +198,20 @@ class DefClassVarStatement(Statement):
|
|
|
196
198
|
return f"{self.name}: {self.type} = {self.value.to_python()}"
|
|
197
199
|
|
|
198
200
|
def to_typescript(self):
|
|
199
|
-
|
|
201
|
+
mod = ""
|
|
202
|
+
if self.is_static:
|
|
203
|
+
mod = "static "
|
|
204
|
+
else:
|
|
205
|
+
# static variable don't require type
|
|
206
|
+
assert self.type is not None
|
|
207
|
+
if self.type is not None:
|
|
208
|
+
type = f": {self.type}"
|
|
209
|
+
else:
|
|
210
|
+
type = ""
|
|
211
|
+
|
|
200
212
|
if self.value is None:
|
|
201
|
-
return f"{self.name}
|
|
202
|
-
return f"{self.name}
|
|
213
|
+
return f"{mod}{self.name}{type};"
|
|
214
|
+
return f"{mod}{self.name}{type} = {self.value.to_typescript()};"
|
|
203
215
|
|
|
204
216
|
|
|
205
217
|
@dataclass
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
codegen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
codegen/models/__init__.py,sha256=j__FrDdGOILIo9jqEDElL3YP69h0xkL2SqrMxSqgpTc,457
|
|
3
3
|
codegen/models/ast.py,sha256=qq1xeWCMbTUXoOXszVYYPTaN-eiPJHdoTbsYbz5MKUo,10518
|
|
4
|
-
codegen/models/expr.py,sha256=
|
|
4
|
+
codegen/models/expr.py,sha256=TjCDeNhwYKuVtIB0eIRNYQ5cLBC1QGajkGQniKPp4y4,11084
|
|
5
5
|
codegen/models/program.py,sha256=mrvtOp9WpaZ6B5KOGpFFLBXMtSCo-BpuGCEgipUuBV8,5062
|
|
6
|
-
codegen/models/statement.py,sha256=
|
|
6
|
+
codegen/models/statement.py,sha256=fnhs9g40l_yHeSpUmvohJdL4G6IbMtnC1Yik5axmLhI,8874
|
|
7
7
|
codegen/models/types.py,sha256=Dl-wzGB1viA7EZj2CuTrZe1F133Q6ENVr_yRqxhde8M,178
|
|
8
8
|
codegen/models/var.py,sha256=sOzDrqJHkAgA2Tqhh6IelW3dDe2o7us6HPjaRBVKmCQ,2722
|
|
9
|
-
codegen_2-2.7.
|
|
10
|
-
codegen_2-2.7.
|
|
11
|
-
codegen_2-2.7.
|
|
12
|
-
codegen_2-2.7.
|
|
9
|
+
codegen_2-2.7.2.dist-info/LICENSE,sha256=Ea6itrykT9pvPGd0Kgl6FbrqdDwKswPZJmXMFVjUBqw,1064
|
|
10
|
+
codegen_2-2.7.2.dist-info/METADATA,sha256=XemQZ6UDbMMAey9OMKkRNDN0DVSq41MvWTTFyuEWc_c,487
|
|
11
|
+
codegen_2-2.7.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
12
|
+
codegen_2-2.7.2.dist-info/RECORD,,
|
|
File without changes
|