pineforge-codegen 1.13.0__tar.gz → 1.14.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.
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/CHANGELOG.md +10 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/PKG-INFO +1 -1
- pineforge_codegen-1.14.0/VERSION +1 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/base.py +10 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/call_handlers.py +12 -34
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/types.py +8 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/value_bindings.py +6 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/base.py +2 -2
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/checked_settings.py +6 -5
- pineforge_codegen-1.14.0/pineforge_codegen/codegen/color_constants.py +14 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/emit_top.py +89 -58
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/helpers.py +2 -1
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/host_members.py +1 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/input.py +33 -51
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/ta.py +203 -10
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/tables.py +3 -23
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/tv_string_units.py +81 -1
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/visit_call.py +68 -6
- pineforge_codegen-1.14.0/pineforge_codegen/color_constants.py +126 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/diagnostics_catalog.json +1 -0
- pineforge_codegen-1.14.0/pineforge_codegen/input_defaults.py +32 -0
- pineforge_codegen-1.13.0/VERSION +0 -1
- pineforge_codegen-1.13.0/pineforge_codegen/codegen/color_constants.py +0 -89
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/.gitignore +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/CONTRIBUTING.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/LEGAL.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/LICENSE +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/README.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/PUBLIC_CONTRACT.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/ci.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/codegen-coverage-gaps.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/engine-main-ci.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/pine-cap-activation.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/reference/adding-a-pine-function.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/reference/conventions.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/reference/file-map.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/reference/known-codegen-quirks.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/reference/pipeline.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/docs/reference/support-contracts.md +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/__init__.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/__init__.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/callable_history_names.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/contracts.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/diagnostics.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/operators.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/qualifiers.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/tables.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/v6_forms.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/array_binding.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/ast_nodes.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/block_locals.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/builtin_constants.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/builtin_keywords.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/__init__.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/array_field_width.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/array_slice.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/ascii.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/bool_text.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/capabilities.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/capacities.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/closed_trade_fold.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/collection_history.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/constant_fold.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/constant_values.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/drawing.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/endless_for.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/for_loops.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/graph_journal.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/helpers_syminfo.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/history_sharing.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/id_sites.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/order_shapes.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/retained_alias.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/run_stops.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/security.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/session_market.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/strategy_declaration.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/timeframe_values.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/tv_number_format.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/types.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/visit_expr.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/visit_stmt.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/collection_history.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/cpp_allowlist.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/cpp_names.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/diagnostic_codes.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/drawing_all.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/errors.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/external_requests.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/finite_ta_length.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/function_overloads.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/input_keys.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/intrinsic_binding.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/lexer.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/library_inline.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/library_modules.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/library_v5.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/limits.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/loop_types.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/matrix_overloads.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/method_binding.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/parser.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/pine_libraries.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/pine_spelling.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/pragmas.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/reference_casts.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/request_discovery.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/request_feed_inventory.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/security_contexts.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/session_reads.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/signatures.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/support_checker.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/symbols.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/timeframe_token_cli.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/tokens.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/tv_input_choices.py +0 -0
- {pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pyproject.toml +0 -0
|
@@ -22,6 +22,16 @@ supported as exact pairs; on the 0.x line they are independent. See the
|
|
|
22
22
|
|
|
23
23
|
## Unreleased (next release)
|
|
24
24
|
|
|
25
|
+
- Generated EMA, TSI, KC, KCW and MACD calls use the paired engine's checked
|
|
26
|
+
source adapters for fixed, input and simple lengths, including helper and
|
|
27
|
+
requested-context copies and precalculation. Invalid lengths are checked
|
|
28
|
+
when the call executes, including with an unavailable source. Keltner calls
|
|
29
|
+
restore their existing seeding context if validation throws. Requires the
|
|
30
|
+
`PineEma`, `PineTsi`, `PineKc`, `PineKcw` and `PineMacd` APIs in
|
|
31
|
+
`pineforge/source/pine_ta_length.hpp`; regenerate C++ and relink.
|
|
32
|
+
|
|
33
|
+
- `ta.sma` accepts supported lengths that vary by bar, including lengths from inline inputs, local variables, and loop counters. Unsupported lengths that depend on `var` or `varip` still report an error, and tuple declarations that reuse a parameter name in the same function body are rejected before C++ is generated. This also fixes Unicode handling in `str.match` and `na` separators in `str.split`.
|
|
34
|
+
- `strategy.convert_to_account` and `strategy.convert_to_symbol` now warn in the run report and return the input unchanged, still in its original currency, when no conversion rate is available ([#376](https://github.com/pineforge-4pass/pineforge-codegen-oss/issues/376)).
|
|
25
35
|
- Strategy sizing constants retain their string values in expressions, aliases
|
|
26
36
|
and helper calls. Host order and risk settings convert these values to their
|
|
27
37
|
numeric representation only at the setting boundary.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pineforge-codegen
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.14.0
|
|
4
4
|
Summary: PineScript v6 to C++ transpiler that targets the pineforge-engine runtime.
|
|
5
5
|
Project-URL: Homepage, https://github.com/pineforge-4pass/pineforge-codegen-oss
|
|
6
6
|
Project-URL: Issues, https://github.com/pineforge-4pass/pineforge-codegen-oss/issues
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.14.0
|
|
@@ -5894,6 +5894,16 @@ class Analyzer(CallHandlers, DiagnosticsHelper, TypeHelper):
|
|
|
5894
5894
|
return size, tuple(element_types)
|
|
5895
5895
|
|
|
5896
5896
|
def _visit_TupleAssign(self, node: TupleAssign) -> PineType:
|
|
5897
|
+
# The callable's outermost body shares its parameter scope in C++.
|
|
5898
|
+
# A nested Pine block is a separate scope, and "_" binds nothing.
|
|
5899
|
+
if self._enclosing_func_params and not self._block_node_stack:
|
|
5900
|
+
parameters = self._enclosing_func_params[-1]
|
|
5901
|
+
for name in node.names:
|
|
5902
|
+
if name != "_" and name in parameters:
|
|
5903
|
+
self._error(
|
|
5904
|
+
f"Tuple declaration for '{name}' collides with a parameter in the same callable scope.",
|
|
5905
|
+
node.loc,
|
|
5906
|
+
)
|
|
5897
5907
|
val_type = self._visit(node.value)
|
|
5898
5908
|
lower_types = (node.value.annotations or {}).get(
|
|
5899
5909
|
"lower_tf_tuple_element_types", (),
|
{pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/call_handlers.py
RENAMED
|
@@ -70,6 +70,7 @@ from ..ast_nodes import (
|
|
|
70
70
|
Ternary, TupleAssign, TupleLiteral, UnaryOp, VarDecl, NaLiteral,
|
|
71
71
|
)
|
|
72
72
|
from ..method_binding import bind_function_defaults
|
|
73
|
+
from ..input_defaults import plain_input_default, plain_input_type
|
|
73
74
|
from ..loop_types import FLOAT_REASSIGNMENT, has_fractional_int_value
|
|
74
75
|
from ..pine_spelling import sub_outside_literals
|
|
75
76
|
from ..external_requests import FEED_LOWERING, LOWERING_ANNOTATION
|
|
@@ -1139,48 +1140,25 @@ class CallHandlers:
|
|
|
1139
1140
|
|
|
1140
1141
|
def _handle_input_call(self, node: FuncCall) -> PineType:
|
|
1141
1142
|
"""Handle input() calls without qualifier."""
|
|
1142
|
-
|
|
1143
|
-
if
|
|
1144
|
-
defval = node.args[0]
|
|
1143
|
+
defval = plain_input_default(node)
|
|
1144
|
+
if defval is not None:
|
|
1145
1145
|
self._visit(defval)
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
if isinstance(defval, BoolLiteral):
|
|
1154
|
-
return PineType.BOOL
|
|
1155
|
-
if isinstance(defval, Identifier):
|
|
1156
|
-
# input(close) => source input
|
|
1157
|
-
self._validate_plain_input_source(defval, node)
|
|
1146
|
+
static_type = plain_input_type(
|
|
1147
|
+
defval, is_bound=self._value_bindings.has_value_binding)
|
|
1148
|
+
if static_type is not None and static_type != PineType.COLOR:
|
|
1149
|
+
return static_type
|
|
1150
|
+
if isinstance(defval, Identifier):
|
|
1151
|
+
self._validate_plain_input_source(defval, node)
|
|
1152
|
+
if node.args:
|
|
1158
1153
|
sym = self._symbols.resolve(defval.name)
|
|
1159
|
-
if sym
|
|
1160
|
-
return sym.pine_type
|
|
1161
|
-
return PineType.FLOAT
|
|
1162
|
-
# Check kwargs for defval
|
|
1163
|
-
if "defval" in node.kwargs:
|
|
1164
|
-
defval = node.kwargs["defval"]
|
|
1165
|
-
self._visit(defval)
|
|
1166
|
-
if isinstance(defval, Identifier):
|
|
1167
|
-
self._validate_plain_input_source(defval, node)
|
|
1168
|
-
if isinstance(defval, NumberLiteral):
|
|
1169
|
-
if isinstance(defval.value, float):
|
|
1170
|
-
return PineType.FLOAT
|
|
1171
|
-
return PineType.INT
|
|
1172
|
-
if isinstance(defval, StringLiteral):
|
|
1173
|
-
return PineType.STRING
|
|
1174
|
-
if isinstance(defval, BoolLiteral):
|
|
1175
|
-
return PineType.BOOL
|
|
1154
|
+
return sym.pine_type if sym is not None else PineType.FLOAT
|
|
1176
1155
|
|
|
1177
|
-
# Visit remaining args
|
|
1178
1156
|
for arg in node.args[1:]:
|
|
1179
1157
|
self._visit(arg)
|
|
1180
1158
|
for val in node.kwargs.values():
|
|
1181
1159
|
self._visit(val)
|
|
1182
1160
|
|
|
1183
|
-
return PineType.FLOAT
|
|
1161
|
+
return static_type or PineType.FLOAT
|
|
1184
1162
|
|
|
1185
1163
|
def _merge_input_params(self, member: str | None, node: FuncCall) -> dict[str, Any]:
|
|
1186
1164
|
"""Positional + kwargs merged like codegen (for input.* validation)."""
|
|
@@ -48,6 +48,7 @@ from ..ast_nodes import (
|
|
|
48
48
|
from ..errors import Phase
|
|
49
49
|
from ..limits import iter_ast_nodes
|
|
50
50
|
from ..builtin_constants import builtin_constant, is_builtin_enum
|
|
51
|
+
from ..input_defaults import plain_input_default, plain_input_type
|
|
51
52
|
from ..matrix_overloads import matrix_sum_has_rhs
|
|
52
53
|
from ..reference_casts import na_reference_cast_kind
|
|
53
54
|
from ..symbols import (
|
|
@@ -57,6 +58,7 @@ from ..symbols import (
|
|
|
57
58
|
unify_type_specs,
|
|
58
59
|
)
|
|
59
60
|
from .operators import join_value_types, reference_value_type
|
|
61
|
+
from .value_bindings import ValueBindings
|
|
60
62
|
|
|
61
63
|
# Drawing-objects-as-data type names (spec §4.1). Defined locally — the
|
|
62
64
|
# analyzer must not import from ``codegen`` (codegen imports analyzer, so the
|
|
@@ -578,6 +580,12 @@ class TypeHelper:
|
|
|
578
580
|
if exact is not None:
|
|
579
581
|
return exact
|
|
580
582
|
cal = value.callee
|
|
583
|
+
if isinstance(cal, Identifier) and cal.name == "input":
|
|
584
|
+
kind = plain_input_type(
|
|
585
|
+
plain_input_default(value), is_bound=ValueBindings.has_value_binding)
|
|
586
|
+
if kind == PineType.COLOR:
|
|
587
|
+
# Keep the semantic color distinct from its int64 storage.
|
|
588
|
+
return TypeSpec.primitive(kind.value)
|
|
581
589
|
if (isinstance(cal, Identifier) and cal.name in ("line", "box")
|
|
582
590
|
and len(value.args) == 1 and not value.kwargs
|
|
583
591
|
and isinstance(value.args[0], NaLiteral)):
|
{pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/analyzer/value_bindings.py
RENAMED
|
@@ -137,6 +137,12 @@ class ValueBindings(DiagnosticsHelper):
|
|
|
137
137
|
return None
|
|
138
138
|
return BindingInfo(use.binding.kind, use.binding.callable)
|
|
139
139
|
|
|
140
|
+
@staticmethod
|
|
141
|
+
def has_value_binding(node: Identifier) -> bool:
|
|
142
|
+
"""Whether a namespace-shaped receiver names an authored value."""
|
|
143
|
+
use = (node.annotations or {}).get(_VALUE_USE)
|
|
144
|
+
return isinstance(use, _ValueUse) and use.binding is not None
|
|
145
|
+
|
|
140
146
|
@staticmethod
|
|
141
147
|
def declaration_of(node: Identifier) -> tuple[int, str] | None:
|
|
142
148
|
"""Read an authored variable declaration without visiting its use."""
|
|
@@ -7236,7 +7236,7 @@ class CodeGen(CallVisitor, ExprVisitor, StmtVisitor, TopLevelEmitter, SecurityEm
|
|
|
7236
7236
|
runtime_args, any_runtime = self._ta_run_ctor_args(site)
|
|
7237
7237
|
if any_runtime:
|
|
7238
7238
|
resets.append(
|
|
7239
|
-
f"{site.member_name} = {site
|
|
7239
|
+
f"{site.member_name} = {self._ta_fixed_cpp_type(site)}({', '.join(runtime_args)});"
|
|
7240
7240
|
)
|
|
7241
7241
|
|
|
7242
7242
|
# Security-context TA copies. Normally these share the ctor args of
|
|
@@ -7328,7 +7328,7 @@ class CodeGen(CallVisitor, ExprVisitor, StmtVisitor, TopLevelEmitter, SecurityEm
|
|
|
7328
7328
|
runtime_args.append(rendered)
|
|
7329
7329
|
if any_runtime:
|
|
7330
7330
|
resets.append(
|
|
7331
|
-
f"{variant['member_name']} = {site
|
|
7331
|
+
f"{variant['member_name']} = {self._ta_fixed_cpp_type(site)}({', '.join(runtime_args)});"
|
|
7332
7332
|
)
|
|
7333
7333
|
|
|
7334
7334
|
return resets
|
{pineforge_codegen-1.13.0 → pineforge_codegen-1.14.0}/pineforge_codegen/codegen/checked_settings.py
RENAMED
|
@@ -180,10 +180,11 @@ def emit_settings_members(emitter, lines: list[str], constructor: list[str]) ->
|
|
|
180
180
|
"get_input_double": "float", "get_input_bool": "bool",
|
|
181
181
|
"get_input_string": "string",
|
|
182
182
|
}[getter]
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
#
|
|
183
|
+
family = emitter._input_scalar_family(node, func_name, namespace)
|
|
184
|
+
kind = emitter._FORM_TYPE.get(family, value_type)
|
|
185
|
+
if family == "color":
|
|
186
|
+
# Preserve the typed color ABI: an integer descriptor with the
|
|
187
|
+
# historical UI kind. The Python/JSON manifest uses "color".
|
|
187
188
|
kind = "string"
|
|
188
189
|
options = []
|
|
189
190
|
numeric_options = []
|
|
@@ -280,7 +281,7 @@ def emit_settings_members(emitter, lines: list[str], constructor: list[str]) ->
|
|
|
280
281
|
manifest["options"] = [_string_setting_value(option) for option in options]
|
|
281
282
|
elif value_type == "enum":
|
|
282
283
|
manifest["options"] = [_string_setting_value(option) for option in options]
|
|
283
|
-
elif
|
|
284
|
+
elif family == "color":
|
|
284
285
|
if color_default is not None:
|
|
285
286
|
manifest["default"] = color_default
|
|
286
287
|
elif namespace == "input" and kind in ("int", "float", "bool"):
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""The C++ spelling of a packed Pine color literal."""
|
|
2
|
+
|
|
3
|
+
from ..color_constants import (
|
|
4
|
+
COLOR_PARAMETERS as COLOR_PARAMETERS,
|
|
5
|
+
color_argb_digits,
|
|
6
|
+
color_arguments as color_arguments,
|
|
7
|
+
literal_color_value as literal_color_value,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def color_literal_to_int64(value: str) -> str:
|
|
12
|
+
"""Lower #RRGGBB / #RRGGBBAA to the existing 0xAARRGGBBLL spelling."""
|
|
13
|
+
digits = color_argb_digits(value)
|
|
14
|
+
return f"0x{digits}LL" if digits is not None else "0"
|
|
@@ -161,8 +161,13 @@ class TopLevelEmitter:
|
|
|
161
161
|
lines.append('#include <pineforge/ta.hpp>')
|
|
162
162
|
lines.extend(['#if __has_include(<pineforge/checked_settings.hpp>)',
|
|
163
163
|
'#include <pineforge/checked_settings.hpp>', '#endif'])
|
|
164
|
-
if self._ta_uses_dynamic_lengths()
|
|
164
|
+
if self._ta_uses_dynamic_lengths() or any(
|
|
165
|
+
site.class_name in self._TA_CHECKED_CLASSES
|
|
166
|
+
for site in self.ctx.ta_call_sites
|
|
167
|
+
):
|
|
165
168
|
lines.append('#include <pineforge/source/pine_ta_length.hpp>')
|
|
169
|
+
if self._has_checked_precalculated_ta():
|
|
170
|
+
lines.extend(('#include <pineforge/run_failure.hpp>', '#include <exception>'))
|
|
166
171
|
lines.append('#include <pineforge/math.hpp>')
|
|
167
172
|
lines.append('#include <pineforge/series.hpp>')
|
|
168
173
|
lines.append('#include <pineforge/na.hpp>')
|
|
@@ -284,16 +289,33 @@ class TopLevelEmitter:
|
|
|
284
289
|
def _emit_ta_compat_shims(self, lines: list[str]) -> None:
|
|
285
290
|
"""Emit source-level adapters for TA1 arguments and anchored forms.
|
|
286
291
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
TA1 engine and the previous engine while keeping the Pine call-site
|
|
290
|
-
shape identical. The old branch deliberately preserves the historical
|
|
291
|
-
lowering; it is only selected when the corresponding macro is absent.
|
|
292
|
+
Keltner calls require the paired checked source API. Other TA1
|
|
293
|
+
adapters retain their existing feature-macro compatibility branches.
|
|
292
294
|
"""
|
|
293
295
|
classes = {
|
|
294
296
|
site.class_name for site in getattr(self.ctx, "ta_call_sites", ())
|
|
295
297
|
}
|
|
296
298
|
|
|
299
|
+
if any(
|
|
300
|
+
self._ta_member_cpp_type(site) == "_PFSeriesSma"
|
|
301
|
+
for index, site in enumerate(getattr(self.ctx, "ta_call_sites", ()))
|
|
302
|
+
if index not in getattr(self, "_dead_ta_indices", set())
|
|
303
|
+
):
|
|
304
|
+
# ta.sma with a series length: the engine's SeriesSma, which
|
|
305
|
+
# takes the length on every call (``_ta_dynamic_plan``).
|
|
306
|
+
lines.extend([
|
|
307
|
+
"class _PFSeriesSma {",
|
|
308
|
+
" pineforge::source::SeriesSma impl_;",
|
|
309
|
+
"public:",
|
|
310
|
+
" double compute(double src, double length)"
|
|
311
|
+
" { return impl_.compute(src, length); }",
|
|
312
|
+
" double recompute(double src, double length)"
|
|
313
|
+
" { return impl_.recompute(src, length); }",
|
|
314
|
+
" void observe_owned_storage(pineforge::OwnedStorage& out) const noexcept"
|
|
315
|
+
" { impl_.observe_owned_storage(out); }",
|
|
316
|
+
"};",
|
|
317
|
+
"",
|
|
318
|
+
])
|
|
297
319
|
if "_PFALMA" in classes:
|
|
298
320
|
lines.extend([
|
|
299
321
|
"#ifdef PF_ALMA_HAS_FLOOR",
|
|
@@ -318,59 +340,37 @@ class TopLevelEmitter:
|
|
|
318
340
|
"",
|
|
319
341
|
])
|
|
320
342
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
" ta::KCResult compute(double src, double high, double low, double close)"
|
|
330
|
-
" { bool _pf_prior = ta::ema_na_warmup_flag(); ta::ema_na_warmup_flag() = true; auto _pf_out = impl_.compute(src, high, low, close); ta::ema_na_warmup_flag() = _pf_prior; return _pf_out; }",
|
|
331
|
-
" ta::KCResult recompute(double src, double high, double low, double close)"
|
|
332
|
-
" { bool _pf_prior = ta::ema_na_warmup_flag(); ta::ema_na_warmup_flag() = true; auto _pf_out = impl_.recompute(src, high, low, close); ta::ema_na_warmup_flag() = _pf_prior; return _pf_out; }",
|
|
333
|
-
"};",
|
|
334
|
-
"#else",
|
|
335
|
-
"class _PFKC {",
|
|
336
|
-
" ta::KC impl_;",
|
|
337
|
-
"public:",
|
|
338
|
-
" _PFKC(int length, double mult, bool = true) : impl_(length, mult) {}",
|
|
339
|
-
" ta::KCResult compute(double src, double high, double low, double close)"
|
|
340
|
-
" { bool _pf_prior = ta::ema_na_warmup_flag(); ta::ema_na_warmup_flag() = true; auto _pf_out = impl_.compute(src, high, low, close); ta::ema_na_warmup_flag() = _pf_prior; return _pf_out; }",
|
|
341
|
-
" ta::KCResult recompute(double src, double high, double low, double close)"
|
|
342
|
-
" { bool _pf_prior = ta::ema_na_warmup_flag(); ta::ema_na_warmup_flag() = true; auto _pf_out = impl_.recompute(src, high, low, close); ta::ema_na_warmup_flag() = _pf_prior; return _pf_out; }",
|
|
343
|
-
"};",
|
|
344
|
-
"#endif",
|
|
345
|
-
"",
|
|
346
|
-
])
|
|
347
|
-
|
|
348
|
-
if "_PFKCW" in classes:
|
|
343
|
+
# Keep the fixed declarations visible to the generated-name census.
|
|
344
|
+
for declaration, adapter, result in (
|
|
345
|
+
("class _PFKC {", "PineKc", "ta::KCResult"),
|
|
346
|
+
("class _PFKCW {", "PineKcw", "double"),
|
|
347
|
+
):
|
|
348
|
+
shim = declaration.split()[1]
|
|
349
|
+
if shim not in classes:
|
|
350
|
+
continue
|
|
349
351
|
lines.extend([
|
|
350
|
-
|
|
351
|
-
"
|
|
352
|
-
" ta::KCW impl_;",
|
|
352
|
+
declaration,
|
|
353
|
+
f" pineforge::source::{adapter} impl_;",
|
|
353
354
|
"public:",
|
|
354
|
-
"
|
|
355
|
+
f" {shim}(int length, double mult, bool use_true_range = true)"
|
|
355
356
|
" : impl_(length, mult, use_true_range) {}",
|
|
356
|
-
"
|
|
357
|
-
" {
|
|
358
|
-
" double recompute(double src, double high, double low, double close)"
|
|
359
|
-
" { bool _pf_prior = ta::ema_na_warmup_flag(); ta::ema_na_warmup_flag() = true; auto _pf_out = impl_.recompute(src, high, low, close); ta::ema_na_warmup_flag() = _pf_prior; return _pf_out; }",
|
|
360
|
-
"};",
|
|
361
|
-
"#else",
|
|
362
|
-
"class _PFKCW {",
|
|
363
|
-
" ta::KCW impl_;",
|
|
364
|
-
"public:",
|
|
365
|
-
" _PFKCW(int length, double mult, bool = true) : impl_(length, mult) {}",
|
|
366
|
-
" double compute(double src, double high, double low, double close)"
|
|
367
|
-
" { bool _pf_prior = ta::ema_na_warmup_flag(); ta::ema_na_warmup_flag() = true; auto _pf_out = impl_.compute(src, high, low, close); ta::ema_na_warmup_flag() = _pf_prior; return _pf_out; }",
|
|
368
|
-
" double recompute(double src, double high, double low, double close)"
|
|
369
|
-
" { bool _pf_prior = ta::ema_na_warmup_flag(); ta::ema_na_warmup_flag() = true; auto _pf_out = impl_.recompute(src, high, low, close); ta::ema_na_warmup_flag() = _pf_prior; return _pf_out; }",
|
|
370
|
-
"};",
|
|
371
|
-
"#endif",
|
|
372
|
-
"",
|
|
357
|
+
" void observe_owned_storage(pineforge::OwnedStorage& out) const noexcept"
|
|
358
|
+
" { impl_.observe_owned_storage(out); }",
|
|
373
359
|
])
|
|
360
|
+
for method in ("compute", "recompute"):
|
|
361
|
+
lines.extend([
|
|
362
|
+
f" {result} {method}(double src, double high, double low, double close) {{",
|
|
363
|
+
# Preserve the existing Keltner seeding context on both
|
|
364
|
+
# success and argument-validation exceptions.
|
|
365
|
+
" struct _pf_seed_scope {",
|
|
366
|
+
" bool _pf_prior = ta::ema_na_warmup_flag();",
|
|
367
|
+
" _pf_seed_scope() { ta::ema_na_warmup_flag() = true; }",
|
|
368
|
+
" ~_pf_seed_scope() { ta::ema_na_warmup_flag() = _pf_prior; }",
|
|
369
|
+
" } _pf_seed;",
|
|
370
|
+
f" return impl_.{method}(src, high, low, close);",
|
|
371
|
+
" }",
|
|
372
|
+
])
|
|
373
|
+
lines.extend(["};", ""])
|
|
374
374
|
|
|
375
375
|
if "_PFAnchoredVWAP" in classes:
|
|
376
376
|
lines.extend([
|
|
@@ -3056,10 +3056,20 @@ class TopLevelEmitter:
|
|
|
3056
3056
|
if _ti not in self._dead_ta_indices
|
|
3057
3057
|
)
|
|
3058
3058
|
|
|
3059
|
+
def _has_checked_precalculated_ta(self) -> bool:
|
|
3060
|
+
"""Whether replay can reach an execution-checked EMA-family length."""
|
|
3061
|
+
return any(
|
|
3062
|
+
site.class_name in self._TA_CHECKED_CLASSES
|
|
3063
|
+
and self._ta_site_uses_precalc(site)
|
|
3064
|
+
for _ti, site in enumerate(self.ctx.ta_call_sites)
|
|
3065
|
+
if _ti not in self._dead_ta_indices
|
|
3066
|
+
)
|
|
3067
|
+
|
|
3059
3068
|
def _emit_precalculate_and_run(self, lines: list[str]) -> None:
|
|
3060
3069
|
if not self._has_precalculated_ta():
|
|
3061
3070
|
return
|
|
3062
3071
|
|
|
3072
|
+
checked_precalc = self._has_checked_precalculated_ta()
|
|
3063
3073
|
replayed_source_series: list[str] = []
|
|
3064
3074
|
for stmt in self.ctx.ast.body:
|
|
3065
3075
|
if not isinstance(stmt, VarDecl):
|
|
@@ -3092,7 +3102,7 @@ class TopLevelEmitter:
|
|
|
3092
3102
|
continue
|
|
3093
3103
|
if self._ta_site_uses_precalc(site):
|
|
3094
3104
|
run_args, _any_runtime = self._ta_run_ctor_args(site)
|
|
3095
|
-
lines.append(f" {site.member_name} = {site
|
|
3105
|
+
lines.append(f" {site.member_name} = {self._ta_fixed_cpp_type(site)}({', '.join(run_args)});")
|
|
3096
3106
|
|
|
3097
3107
|
# Clear series
|
|
3098
3108
|
lines.append("")
|
|
@@ -3108,6 +3118,9 @@ class TopLevelEmitter:
|
|
|
3108
3118
|
|
|
3109
3119
|
# Start precalculation loop
|
|
3110
3120
|
lines.append("")
|
|
3121
|
+
if checked_precalc:
|
|
3122
|
+
lines.append(" try {")
|
|
3123
|
+
replay_start = len(lines)
|
|
3111
3124
|
lines.append(" for (int i = 0; i < n; ++i) {")
|
|
3112
3125
|
|
|
3113
3126
|
# Push OHLCV into series
|
|
@@ -3201,6 +3214,23 @@ class TopLevelEmitter:
|
|
|
3201
3214
|
self._precalc_loop_active = False
|
|
3202
3215
|
|
|
3203
3216
|
lines.append(" }")
|
|
3217
|
+
if checked_precalc:
|
|
3218
|
+
for index in range(replay_start, len(lines)):
|
|
3219
|
+
lines[index] = " " + lines[index] if lines[index] else ""
|
|
3220
|
+
lines.extend([
|
|
3221
|
+
" _use_precalc = true;",
|
|
3222
|
+
" } catch (const std::exception& _pf_precalc_error) {",
|
|
3223
|
+
" const auto* _pf_precalc_failure =",
|
|
3224
|
+
" dynamic_cast<const pineforge::RunFailureInfo*>(&_pf_precalc_error);",
|
|
3225
|
+
" if (!_pf_precalc_failure ||",
|
|
3226
|
+
" _pf_precalc_failure->run_failure_code() !=",
|
|
3227
|
+
" pineforge::RunFailureCode::pine_invalid_argument) throw;",
|
|
3228
|
+
" // The real bar path checks the length at the original call.",
|
|
3229
|
+
])
|
|
3230
|
+
for _ti, site in enumerate(self.ctx.ta_call_sites):
|
|
3231
|
+
if _ti not in self._dead_ta_indices and self._ta_site_uses_precalc(site):
|
|
3232
|
+
lines.append(f" _precalc_{site.member_name}.clear();")
|
|
3233
|
+
lines.append(" }")
|
|
3204
3234
|
|
|
3205
3235
|
# Reset indicators and series for the real backtest run
|
|
3206
3236
|
lines.append("")
|
|
@@ -3209,7 +3239,7 @@ class TopLevelEmitter:
|
|
|
3209
3239
|
continue
|
|
3210
3240
|
if self._ta_site_uses_precalc(site):
|
|
3211
3241
|
run_args, _any_runtime = self._ta_run_ctor_args(site)
|
|
3212
|
-
lines.append(f" {site.member_name} = {site
|
|
3242
|
+
lines.append(f" {site.member_name} = {self._ta_fixed_cpp_type(site)}({', '.join(run_args)});")
|
|
3213
3243
|
|
|
3214
3244
|
for field_name in sorted(self.ctx.series_bar_fields):
|
|
3215
3245
|
lines.append(f" _s_{field_name}.clear();")
|
|
@@ -3222,7 +3252,8 @@ class TopLevelEmitter:
|
|
|
3222
3252
|
lines.append(" _src_ohlc4_.clear(); _src_hlcc4_.clear();")
|
|
3223
3253
|
|
|
3224
3254
|
lines.append("")
|
|
3225
|
-
|
|
3255
|
+
if not checked_precalc:
|
|
3256
|
+
lines.append(" _use_precalc = true;")
|
|
3226
3257
|
lines.append(" }")
|
|
3227
3258
|
lines.append("")
|
|
3228
3259
|
|
|
@@ -461,12 +461,13 @@ CPP_EMITTER_NAMES = frozenset("""
|
|
|
461
461
|
_pf_tv_trim _pf_tv_increment_digits _pf_tv_decimal _pf_tv_pattern
|
|
462
462
|
_pf_tv_number_style
|
|
463
463
|
_pf_u16_length _pf_u16_pos _pf_u16_decode _pf_u16_encode _pf_u16_substr
|
|
464
|
+
_pf_u8_decode_points _pf_u8_match
|
|
464
465
|
_security_helper_series_ _security_helper_series_str_
|
|
465
466
|
_use_precalc _var_initialized _ta_initialized_ _inputs_initialized_
|
|
466
467
|
_pf_lines_ _pf_boxes_ _pf_labels_ _pf_linefills_
|
|
467
468
|
_PFPolyline _pf_polyline_next_id_
|
|
468
469
|
_pf_script_state_checkpoint_ _PFScriptState _PFForeignEmaSeeding
|
|
469
|
-
_PFALMA _PFKC _PFKCW _PFAnchoredVWAP _PFAnchoredVWAPBands
|
|
470
|
+
_PFALMA _PFKC _PFKCW _PFAnchoredVWAP _PFAnchoredVWAPBands _PFSeriesSma
|
|
470
471
|
_PFPivotPointLevels _PFArrayField _PFTvFormatValue
|
|
471
472
|
_PFCollectionTraits _PFArrayHistoryValue _PFCollectionHistory
|
|
472
473
|
_pf_collection_history_changed kLoopTimeLimitMs kTvFloatStepEnd
|
|
@@ -29,6 +29,8 @@ from ..ast_nodes import (
|
|
|
29
29
|
VarDecl,
|
|
30
30
|
)
|
|
31
31
|
from .. import signatures as sigs
|
|
32
|
+
from ..analyzer.value_bindings import ValueBindings
|
|
33
|
+
from ..input_defaults import plain_input_default, plain_input_type
|
|
32
34
|
from ..pine_spelling import expr_start, global_input_calls, input_binding_names
|
|
33
35
|
from ..symbols import PineType
|
|
34
36
|
from .color_constants import literal_color_value
|
|
@@ -77,7 +79,7 @@ class InputHelper:
|
|
|
77
79
|
if namespace == "input" and func_name in sigs.INPUT_FUNCTIONS:
|
|
78
80
|
param_names = sigs.get_param_names("input", func_name)
|
|
79
81
|
elif func_name == "input" and namespace is None:
|
|
80
|
-
|
|
82
|
+
return plain_input_default(node)
|
|
81
83
|
if param_names:
|
|
82
84
|
merged = list(node.args)
|
|
83
85
|
for i, pname in enumerate(param_names):
|
|
@@ -390,7 +392,8 @@ class InputHelper:
|
|
|
390
392
|
"""
|
|
391
393
|
default = self._get_input_default(node)
|
|
392
394
|
func_name, namespace = self._resolve_callee(node.callee)
|
|
393
|
-
|
|
395
|
+
family = self._input_scalar_family(node, func_name, namespace)
|
|
396
|
+
getter = self._input_type_to_getter(family, namespace)
|
|
394
397
|
string_input = namespace == "input" and getter == "get_input_string"
|
|
395
398
|
if string_input:
|
|
396
399
|
default = self._string_input_argument(default)
|
|
@@ -409,8 +412,10 @@ class InputHelper:
|
|
|
409
412
|
# An input's default stays a C string, cut at its first NUL as the
|
|
410
413
|
# settings receipt documents; the manifest equals both.
|
|
411
414
|
cpp = self._unsized_std_string(cpp)
|
|
412
|
-
color =
|
|
413
|
-
|
|
415
|
+
color = None
|
|
416
|
+
if family == "color":
|
|
417
|
+
binding_check = ValueBindings.has_value_binding if namespace is None else None
|
|
418
|
+
color = literal_color_value(default, is_bound=binding_check)
|
|
414
419
|
return cpp, color
|
|
415
420
|
|
|
416
421
|
def _string_input_argument(self, expr, *, refuse_unproven: bool = True):
|
|
@@ -437,42 +442,27 @@ class InputHelper:
|
|
|
437
442
|
"or write the literal in the call.",
|
|
438
443
|
)
|
|
439
444
|
|
|
440
|
-
def
|
|
441
|
-
|
|
442
|
-
|
|
445
|
+
def _input_scalar_family(self, node: FuncCall, func_name: str | None,
|
|
446
|
+
namespace: str | None) -> str | None:
|
|
447
|
+
"""Typed input spelling or the proven static overload of bare input."""
|
|
448
|
+
if namespace == "input":
|
|
449
|
+
return func_name
|
|
450
|
+
if namespace is None and func_name == "input":
|
|
451
|
+
kind = plain_input_type(
|
|
452
|
+
self._get_input_default(node), is_bound=ValueBindings.has_value_binding)
|
|
453
|
+
return kind.value if kind is not None else None
|
|
454
|
+
return None
|
|
443
455
|
|
|
444
456
|
_GETTER_CPP_TYPE = {
|
|
445
|
-
"get_input_bool": "bool", "get_input_int": "int",
|
|
457
|
+
"get_input_bool": "bool", "get_input_int": "int", "get_input_int64": "int64_t",
|
|
446
458
|
"get_input_string": "std::string", "get_input_double": "double",
|
|
447
459
|
}
|
|
448
460
|
|
|
449
461
|
def _input_getter_for_call(self, node: FuncCall, func_name: str | None,
|
|
450
462
|
namespace: str | None) -> str:
|
|
451
|
-
"""
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
v6: ``input("x")`` is a string input, ``input(3)`` an int one and
|
|
455
|
-
``input(true)`` a bool one (lab tv tape te_generic_input: its
|
|
456
|
-
``str.tostring(n / 2)`` reads "1.5" and its string input spells the
|
|
457
|
-
order comments). The static getter table cannot see the default, so
|
|
458
|
-
the getter follows the default's literal type here. This matters for
|
|
459
|
-
TA lengths too: ``input(15)`` must route to ``get_input_int`` so the
|
|
460
|
-
RMA/EMA ctor receives an int."""
|
|
461
|
-
getter = self._input_type_to_getter(func_name, namespace)
|
|
462
|
-
if func_name == "input" and namespace is None:
|
|
463
|
-
default = self._get_input_default(node)
|
|
464
|
-
if isinstance(default, BoolLiteral):
|
|
465
|
-
getter = "get_input_bool"
|
|
466
|
-
elif isinstance(default, NumberLiteral):
|
|
467
|
-
if isinstance(default.value, bool):
|
|
468
|
-
getter = "get_input_bool"
|
|
469
|
-
elif isinstance(default.value, int):
|
|
470
|
-
getter = "get_input_int"
|
|
471
|
-
else:
|
|
472
|
-
getter = "get_input_double"
|
|
473
|
-
elif isinstance(default, StringLiteral):
|
|
474
|
-
getter = "get_input_string"
|
|
475
|
-
return getter
|
|
463
|
+
"""Use the same getter for explicit and proven generic scalar types."""
|
|
464
|
+
return self._input_type_to_getter(
|
|
465
|
+
self._input_scalar_family(node, func_name, namespace), namespace)
|
|
476
466
|
|
|
477
467
|
def _generic_input_cpp_type(self, node: FuncCall) -> str:
|
|
478
468
|
"""The C++ storage of a generic ``input(...)`` value: its getter's
|
|
@@ -619,25 +609,17 @@ class InputHelper:
|
|
|
619
609
|
if default_node is not None
|
|
620
610
|
else None
|
|
621
611
|
)
|
|
622
|
-
|
|
623
|
-
|
|
612
|
+
family = self._input_scalar_family(node, func_name, namespace)
|
|
613
|
+
if family is not None:
|
|
614
|
+
form_type = self._FORM_TYPE.get(family, "string")
|
|
624
615
|
else:
|
|
625
|
-
#
|
|
626
|
-
#
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
#
|
|
631
|
-
|
|
632
|
-
form_type = "bool"
|
|
633
|
-
elif isinstance(default_val, int):
|
|
634
|
-
form_type = "int"
|
|
635
|
-
elif isinstance(default_val, float):
|
|
636
|
-
form_type = "float"
|
|
637
|
-
elif isinstance(default_val, str):
|
|
638
|
-
form_type = "string"
|
|
639
|
-
else:
|
|
640
|
-
form_type = "string"
|
|
616
|
+
# Keep historical manifest values for defaults without a proven
|
|
617
|
+
# scalar overload (including signed numbers and native sources).
|
|
618
|
+
form_type = {bool: "bool", int: "int", float: "float"}.get(
|
|
619
|
+
type(default_val), "string")
|
|
620
|
+
if family == "color" and namespace is None:
|
|
621
|
+
# The checked-settings descriptor supplies the packed value.
|
|
622
|
+
default_val = None
|
|
641
623
|
entry: dict = {
|
|
642
624
|
"title": title,
|
|
643
625
|
"type": form_type,
|