sonolus.py 0.3.0__py3-none-any.whl → 0.3.1__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.

Potentially problematic release.


This version of sonolus.py might be problematic. Click here for more details.

sonolus/script/num.py CHANGED
@@ -114,10 +114,11 @@ class _Num(Value, metaclass=_NumMeta):
114
114
  return Num(self.data)
115
115
 
116
116
  def _set_(self, value: Self):
117
+ value = Num._accept_(value)
117
118
  if ctx():
118
119
  match self.data:
119
120
  case BackingValue():
120
- ctx().add_statements(self.data.write(value))
121
+ self.data.write(value.ir())
121
122
  case BlockPlace():
122
123
  ctx().check_writable(self.data)
123
124
  ctx().add_statements(IRSet(self.data, value.ir()))
sonolus/script/stream.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import cast, dataclass_transform
4
4
 
5
- from sonolus.backend.ir import IRExpr, IRInstr, IRPureInstr
5
+ from sonolus.backend.ir import IRExpr, IRInstr, IRPureInstr, IRConst
6
6
  from sonolus.backend.mode import Mode
7
7
  from sonolus.backend.ops import Op
8
8
  from sonolus.script.internal.context import ctx
@@ -42,7 +42,7 @@ class _StreamDataField(SonolusDescriptor):
42
42
  self.type_ = type_
43
43
 
44
44
  def _get(self):
45
- return self.type_._from_backing_source_(lambda offset: _StreamBacking(self.offset, Num(offset)))
45
+ return self.type_._from_backing_source_(lambda offset: _SparseStreamBacking(self.offset, Num(offset)))
46
46
 
47
47
  def __get__(self, instance, owner):
48
48
  _check_can_read_or_write_stream()
@@ -150,6 +150,30 @@ class _StreamBacking(BackingValue):
150
150
  ctx().add_statement(IRInstr(Op.StreamSet, [self.id.ir(), self.index.ir(), value]))
151
151
 
152
152
 
153
+ class _SparseStreamBacking(BackingValue):
154
+ id: Num
155
+ index: Num
156
+
157
+ def __init__(self, stream_id: int, index: Num):
158
+ super().__init__()
159
+ self.id = Num._accept_(stream_id)
160
+ self.index = Num._accept_(index)
161
+
162
+ def read(self) -> IRExpr:
163
+ """Read the value from the stream."""
164
+ _check_can_read_stream()
165
+ return IRPureInstr(Op.StreamGetValue, [self.id.ir(), self.index.ir()])
166
+
167
+ def write(self, value: IRExpr) -> None:
168
+ """Write the value to the stream."""
169
+ _check_can_write_stream()
170
+ ctx().add_statements(
171
+ IRInstr(Op.StreamSet, [self.id.ir(), self.index.ir(), value]),
172
+ IRInstr(Op.StreamSet, [self.id.ir(), (self.index - 0.5).ir(), IRConst(0)]),
173
+ IRInstr(Op.StreamSet, [self.id.ir(), (self.index + 0.5).ir(), IRConst(0)]),
174
+ )
175
+
176
+
153
177
  class Stream[T](Record, BackingValue):
154
178
  """Represents a stream.
155
179
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sonolus.py
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Sonolus engine development in Python
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -49,7 +49,7 @@ sonolus/script/interval.py,sha256=IYNgJx0ngREnEVu_yMAu0MrA_Q7mZuToT8U3fbdb3Sc,91
49
49
  sonolus/script/iterator.py,sha256=OHnIOKRchzVCMaN33Tubo6EzqV61ZYUxDWIJ2S5G6iQ,4590
50
50
  sonolus/script/level.py,sha256=wR23xk-NOcW_JMRb3R12sqIXCLSZL-7cM3y7IpMF1J0,6333
51
51
  sonolus/script/metadata.py,sha256=ttRK27eojHf3So50KQJ-8yj3udZoN1bli5iD-knaeLw,753
52
- sonolus/script/num.py,sha256=x8KSAGK4iwj92nTvJ54X5H6ZmLUEnyUmND5g0YkDbgc,14749
52
+ sonolus/script/num.py,sha256=Eniv447z8LIAkiZK9Cr_35ZXPnb7Dvy_3c9yq1INoYs,14768
53
53
  sonolus/script/options.py,sha256=ZD9I898wMrpPQ8IyuDoYef804rZzhSvPoC_0bxovIec,8245
54
54
  sonolus/script/particle.py,sha256=oeVQF01xOeW2BEn04ZK1ZOP2HGvQzxBJCpITFjy9woQ,8353
55
55
  sonolus/script/pointer.py,sha256=IH2_a0XE76uG_UyYM9jAYIf7qZ5LhUNc9ksXDIvAPZA,1511
@@ -59,7 +59,7 @@ sonolus/script/quad.py,sha256=TwmQEsa7_UDSly4uXjN9RRQBVu7Qc_-rpDvhy6cy3KQ,10109
59
59
  sonolus/script/record.py,sha256=ouS5f7HVjH60esC0ryVOJL4q7Lt48CHokspgdf2kiH4,11742
60
60
  sonolus/script/runtime.py,sha256=MIGqDqNitlI6vFtZ2SP32D6LCLJ3RAuGKSxKKl-1tJw,20303
61
61
  sonolus/script/sprite.py,sha256=CMcRAZ2hejXnaBmY2_n1_rj6hGOgPP5zEW-BpyaEVOY,16256
62
- sonolus/script/stream.py,sha256=CIPTwRPRx_oIWXxmCkmh5HcXBhw38hsfF4O5pcuQ8b4,19136
62
+ sonolus/script/stream.py,sha256=5LmQXRmNUiYln67krgocXhiS09dU5BXQuo29CqJk1TE,19989
63
63
  sonolus/script/text.py,sha256=wxujIgKYcCfl2AD2_Im8g3vh0lDEHYwTSRZg9wsBPEU,13402
64
64
  sonolus/script/timing.py,sha256=ZR0ypV2PIoDCMHHGOMfCeezStCsBQdzomdqaz5VKex0,2981
65
65
  sonolus/script/transform.py,sha256=iFY51p6Q0_VlAjlGCDxB14Vj5NlvAB_9VNzDjHeaxDs,10884
@@ -84,8 +84,8 @@ sonolus/script/internal/range.py,sha256=lrTanQFHU7RuQxSSPwDdoC30Y8FnHGxcP1Ahditu
84
84
  sonolus/script/internal/transient.py,sha256=d6iYhM9f6DPUX5nkYQGm-x0b9XEfZUmB4AtUNnyhixo,1636
85
85
  sonolus/script/internal/tuple_impl.py,sha256=vjXmScLVdeTkDn3t9fgIRqtW31iwngnaP2rmA6nlsLw,3431
86
86
  sonolus/script/internal/value.py,sha256=gQVNQD_xGpgrN4-UXFDmWRZCJCe8wPZ_wYv4QoPRJkM,5379
87
- sonolus_py-0.3.0.dist-info/METADATA,sha256=p45irB_drbeGk58GpNSTg1m6spbsFpPdnTT_JUjHaRc,302
88
- sonolus_py-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
89
- sonolus_py-0.3.0.dist-info/entry_points.txt,sha256=oTYspY_b7SA8TptEMTDxh4-Aj-ZVPnYC9f1lqH6s9G4,54
90
- sonolus_py-0.3.0.dist-info/licenses/LICENSE,sha256=JEKpqVhQYfEc7zg3Mj462sKbKYmO1K7WmvX1qvg9IJk,1067
91
- sonolus_py-0.3.0.dist-info/RECORD,,
87
+ sonolus_py-0.3.1.dist-info/METADATA,sha256=txzVSPgkG_eIzWqlChZcQ5RTrh6l6Juk_m8-UmFgOG8,302
88
+ sonolus_py-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
89
+ sonolus_py-0.3.1.dist-info/entry_points.txt,sha256=oTYspY_b7SA8TptEMTDxh4-Aj-ZVPnYC9f1lqH6s9G4,54
90
+ sonolus_py-0.3.1.dist-info/licenses/LICENSE,sha256=JEKpqVhQYfEc7zg3Mj462sKbKYmO1K7WmvX1qvg9IJk,1067
91
+ sonolus_py-0.3.1.dist-info/RECORD,,