@pineforge/codegen-pyodide 0.10.2 → 0.10.4

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.
@@ -495,6 +495,11 @@ class StmtVisitor:
495
495
  )
496
496
  previous_input_name = self._current_input_var_name
497
497
  self._current_input_var_name = node.name
498
+ # A ``var`` int array that stores epoch milliseconds is declared
499
+ # ``std::vector<int64_t>``; its one-shot constructor here must
500
+ # spell the same type (visit_call array.new_* / array.from).
501
+ previous_ctor_target = getattr(self, "_array_ctor_target_name", None)
502
+ self._array_ctor_target_name = node.name
498
503
  try:
499
504
  type_spec = info.get("type_spec")
500
505
  target_cpp_type = info.get("drawing_cpp")
@@ -535,6 +540,7 @@ class StmtVisitor:
535
540
  init_cpp = self._visit_expr(node.value)
536
541
  finally:
537
542
  self._current_input_var_name = previous_input_name
543
+ self._array_ctor_target_name = previous_ctor_target
538
544
  if info.get("drawing_cpp") is None:
539
545
  init_cpp = self._typed_na_init(
540
546
  init_cpp, member_name, info["ptype"]
@@ -618,13 +624,19 @@ class StmtVisitor:
618
624
  func_name, namespace = self._resolve_callee(node.value.callee)
619
625
  if namespace == "array" and func_name in ARRAY_NEW_CTORS | {"new", "from", "copy", "slice"}:
620
626
  captured = self._callable_collection_bindings.get(id(node))
621
- spec = (
627
+ spec = self._widen_array_spec_for_name(
628
+ node.name,
622
629
  captured
623
630
  if captured is not None and captured.kind == "array"
624
631
  else self._type_spec_from_expr(node.value)
625
- or self._array_spec_for_name(node.name)
632
+ or self._array_spec_for_name(node.name),
626
633
  )
627
- init = self._visit_expr(node.value)
634
+ previous_target = getattr(self, "_array_ctor_target_name", None)
635
+ self._array_ctor_target_name = node.name
636
+ try:
637
+ init = self._visit_expr(node.value)
638
+ finally:
639
+ self._array_ctor_target_name = previous_target
628
640
  self._array_vars.add(node.name)
629
641
  self._collection_types.setdefault(node.name, spec)
630
642
  cpp_type = self._type_spec_to_cpp(spec)
@@ -75,7 +75,9 @@ def method_receiver_type_name(spec: TypeSpec | None) -> str | None:
75
75
  if spec is None:
76
76
  return None
77
77
  if spec.kind in {"primitive", "udt"}:
78
- return spec.name
78
+ # A wide (epoch-millisecond) element is still Pine ``int`` to the
79
+ # source: a user method declared on ``array<int>`` binds to it.
80
+ return "int" if spec.name == "int64" else spec.name
79
81
  if spec.kind == "array" and spec.element is not None:
80
82
  element = method_receiver_type_name(spec.element)
81
83
  return f"array<{element}>" if element is not None else None
@@ -106,7 +108,7 @@ def method_receiver_cpp_token(
106
108
 
107
109
  if spec is not None:
108
110
  if spec.kind in {"primitive", "udt"} and spec.name:
109
- return spec.name
111
+ return "int" if spec.name == "int64" else spec.name
110
112
  if spec.kind == "array" and spec.element is not None:
111
113
  return f"array_{method_receiver_cpp_token(spec.element)}"
112
114
  if spec.kind == "map" and spec.key is not None and spec.value is not None:
Binary file
package/release.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "codegen": "0.10.2",
2
+ "codegen": "0.10.4",
3
3
  "pyodide": "314.0.0",
4
4
  "python": "3.14.0",
5
5
  "emscripten": "emscripten_5_0_3",
6
- "sha256": "97ebb8d0b14c32d3c88b9521c8f13150ee9cb9e3859227af970ec4dcbfa6bf71"
6
+ "sha256": "e7a19fd012b73cf37ca6a76c06c2c047b63840717aad3f25c22e0f25db468d48"
7
7
  }
package/tables.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "CODEGEN_VERSION": "0.10.2",
2
+ "CODEGEN_VERSION": "0.10.4",
3
3
  "TA_CLASS_MAP_KEYS": [
4
4
  "sma",
5
5
  "ema",
Binary file