codegen-2 2.12.2__tar.gz → 2.13.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.12.2 → codegen_2-2.13.0}/PKG-INFO +1 -1
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/models/ast.py +3 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/models/statement.py +7 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/pyproject.toml +1 -1
- {codegen_2-2.12.2 → codegen_2-2.13.0}/LICENSE +0 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/README.md +0 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/__init__.py +0 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/models/__init__.py +0 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/models/expr.py +0 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/models/program.py +0 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/models/types.py +0 -0
- {codegen_2-2.12.2 → codegen_2-2.13.0}/codegen/models/var.py +0 -0
|
@@ -101,6 +101,7 @@ class AST:
|
|
|
101
101
|
return_type: Optional[Expr] = None,
|
|
102
102
|
is_async: bool = False,
|
|
103
103
|
is_static: bool = False,
|
|
104
|
+
modifiers: Optional[Sequence[Literal["get", "set"]]] = None,
|
|
104
105
|
comment: str = "",
|
|
105
106
|
):
|
|
106
107
|
"""Define a function. The input variables are deferred vars as they are created for this function (i.e., must not be predefined prior to this function)"""
|
|
@@ -115,6 +116,7 @@ class AST:
|
|
|
115
116
|
var.name, var.key, grandchild_id, var.force_name, var.type
|
|
116
117
|
)
|
|
117
118
|
)
|
|
119
|
+
|
|
118
120
|
return self._add_stmt(
|
|
119
121
|
DefFuncStatement(
|
|
120
122
|
name,
|
|
@@ -129,6 +131,7 @@ class AST:
|
|
|
129
131
|
return_type,
|
|
130
132
|
is_async,
|
|
131
133
|
is_static,
|
|
134
|
+
modifiers or [],
|
|
132
135
|
comment,
|
|
133
136
|
)
|
|
134
137
|
)
|
|
@@ -90,6 +90,9 @@ class DefFuncStatement(Statement):
|
|
|
90
90
|
return_type: Optional[Expr] = None
|
|
91
91
|
is_async: bool = False
|
|
92
92
|
is_static: bool = False
|
|
93
|
+
# modifiers to the function such as get or set, usually appear after the static, function definition, async keywords.
|
|
94
|
+
# to mark this function as a getter or setter.
|
|
95
|
+
modifiers: Sequence[Literal["get", "set"]] = field(default_factory=list)
|
|
93
96
|
comment: str = ""
|
|
94
97
|
|
|
95
98
|
def to_python(self):
|
|
@@ -99,6 +102,7 @@ class DefFuncStatement(Statement):
|
|
|
99
102
|
if self.is_async:
|
|
100
103
|
sig = "async " + sig
|
|
101
104
|
sig = sig + ":"
|
|
105
|
+
|
|
102
106
|
if self.is_static:
|
|
103
107
|
sig = "@staticmethod\n" + sig
|
|
104
108
|
if self.comment != "":
|
|
@@ -121,6 +125,9 @@ class DefFuncStatement(Statement):
|
|
|
121
125
|
if self.is_static:
|
|
122
126
|
keyword += "static "
|
|
123
127
|
|
|
128
|
+
if len(self.modifiers) > 0:
|
|
129
|
+
keyword += " ".join(self.modifiers) + " "
|
|
130
|
+
|
|
124
131
|
sig = (
|
|
125
132
|
keyword
|
|
126
133
|
+ f"{self.name}({', '.join([arg[0].to_typescript() + " = " + arg[1].to_typescript() if isinstance(arg, tuple) else arg.to_typescript() for arg in self.args])})"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|