From bfd914a5d1d09712b6763457440ba30f35b34d05 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Fri, 17 Apr 2020 17:19:01 +0100 Subject: [PATCH] boards: simulator: Add ptr32 support --- wasp/boards/simulator/micropython.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wasp/boards/simulator/micropython.py b/wasp/boards/simulator/micropython.py index 804f514..66f1fd5 100644 --- a/wasp/boards/simulator/micropython.py +++ b/wasp/boards/simulator/micropython.py @@ -12,12 +12,17 @@ def viper(fn): return buf def ptr16(buf): - return memoryview(buf).cast('H') + return memoryview(buf).cast('b').cast('H') - # This is a bit of a hack since the scope for ptr8 won't be right - # but it does mean no changes to the client + def ptr32(buf): + return memoryview(buf).cast('b').cast('I') + + # This is a bit of a hack since the scopes don't exactly match where + # they would be in micropython but for the simple cases it does mean + # no changes to the client fn.__globals__['ptr8'] = ptr8 fn.__globals__['ptr16'] = ptr16 + fn.__globals__['ptr32'] = ptr32 return fn