Skip to content

Commit ba9a8de

Browse files
fix: emplacement bug in host function return values
1 parent 30e2829 commit ba9a8de

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Diff for: extism/extism.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,34 @@ def _map_ret(xs) -> List[Tuple[ValType, Callable[[Any, Any, Any], Any]]]:
327327
]
328328

329329
if xs == int:
330-
return [(ValType.I64, lambda _, slot, value: slot.assign(value))]
330+
return [
331+
(
332+
ValType.I64,
333+
lambda plugin, slot, value: plugin.return_bytes(
334+
slot, value.to_bytes(length=8, byteorder="little")
335+
),
336+
)
337+
]
331338

332339
if xs == float:
333-
return [(ValType.F64, lambda _, slot, value: slot.assign(value))]
340+
return [
341+
(
342+
ValType.F64,
343+
lambda plugin, slot, value: plugin.return_bytes(
344+
slot, value.to_bytes(length=8, byteorder="little")
345+
),
346+
)
347+
]
334348

335349
if xs == bool:
336-
return [(ValType.I32, lambda _, slot, value: slot.assign(value))]
350+
return [
351+
(
352+
ValType.I32,
353+
lambda plugin, slot, value: plugin.return_bytes(
354+
slot, value.to_bytes(length=4, byteorder="little")
355+
),
356+
)
357+
]
337358

338359
if get_origin(xs) == tuple:
339360
return functools.reduce(lambda lhs, rhs: lhs + _map_ret(rhs), get_args(xs), [])

0 commit comments

Comments
 (0)