2020-03-22 16:40:18 +01:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
# Copyright (C) 2020 Daniel Thompson
|
|
|
|
|
2020-02-08 08:49:38 +01:00
|
|
|
def const(fn):
|
|
|
|
return fn
|
|
|
|
|
|
|
|
def native(fn):
|
|
|
|
return fn
|
|
|
|
|
|
|
|
def viper(fn):
|
|
|
|
def ptr8(buf):
|
|
|
|
return buf
|
|
|
|
|
2020-04-08 22:50:42 +02:00
|
|
|
def ptr16(buf):
|
2020-04-17 18:19:01 +02:00
|
|
|
return memoryview(buf).cast('b').cast('H')
|
2020-04-08 22:50:42 +02:00
|
|
|
|
2020-04-17 18:19:01 +02:00
|
|
|
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
|
2020-02-08 08:49:38 +01:00
|
|
|
fn.__globals__['ptr8'] = ptr8
|
2020-04-08 22:50:42 +02:00
|
|
|
fn.__globals__['ptr16'] = ptr16
|
2020-04-17 18:19:01 +02:00
|
|
|
fn.__globals__['ptr32'] = ptr32
|
2020-02-08 08:49:38 +01:00
|
|
|
|
|
|
|
return fn
|
2020-01-31 20:36:55 +01:00
|
|
|
|