interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / evidence / native-bindings / omega_native.py

46 lines · 2498 bytes Raw Blame History
1# Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).
2# ctypes declarations for libomega_native.so beside this file. Regenerate it; do not edit it.
3# Status: 0 done; 1..14 the Omega trap code; 32 argument refused (None, wrong length, misaligned,
4# overlap); 33 reentry; 34 bad runtime entry; 35 no stack. The result (a ctypes.c_uint64 passed with
5# ctypes.byref) is written only on status 0. A scalar is an int in 0 .. 2**64-1 (a long is passed as its
6# two's-complement bits); anything else raises ctypes.ArgumentError, nothing is truncated. An array is a
7# ctypes array of its element type (bytes for a view uchar) then its element count; an edit array must
8# be writable, so bytes are refused there.
9import ctypes, os
10OMEGA_OK, OMEGA_BAD_ARG, OMEGA_REENTRY, OMEGA_BAD_RT, OMEGA_NO_STACK = 0, 32, 33, 34, 35
11lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), "libomega_native.so"))
12class _u64:
13 @classmethod
14 def from_param(cls, v):
15 if type(v) is not int or v < 0 or v > 18446744073709551615:
16 raise ValueError("omega scalar: an int in 0 .. 2**64-1 expected, got %r" % (v,))
17 return ctypes.c_uint64(v)
18_res = ctypes.POINTER(ctypes.c_uint64)
19_a3 = ctypes.POINTER(ctypes.c_uint64) # edit ulong: a writable ctypes array of c_uint64
20_a4 = ctypes.POINTER(ctypes.c_uint64) # view ulong: a ctypes array of c_uint64
21_a5 = ctypes.POINTER(ctypes.c_ubyte) # edit uchar: a writable ctypes array of c_ubyte
22_a6 = ctypes.c_char_p # view uchar: bytes, or a ctypes array of c_char
23# fn madd a ulong b ulong c ulong to ulong
24omega_madd = lib.omega_madd
25omega_madd.argtypes = [_res, _u64, _u64, _u64]
26omega_madd.restype = ctypes.c_uint32
27# fn smadd a long b long c long to long
28omega_smadd = lib.omega_smadd
29omega_smadd.argtypes = [_res, _u64, _u64, _u64]
30omega_smadd.restype = ctypes.c_uint32
31# fn fill buf edit ulong 4 k ulong to ulong
32omega_fill = lib.omega_fill
33omega_fill.argtypes = [_res, _a3, _u64, _u64]
34omega_fill.restype = ctypes.c_uint32
35# fn spin n ulong to ulong
36omega_spin = lib.omega_spin
37omega_spin.argtypes = [_res, _u64]
38omega_spin.restype = ctypes.c_uint32
39# fn mix a ulong b long c view uchar 3 d edit uchar 2 e view ulong 2 f ulong to void
40omega_mix = lib.omega_mix
41omega_mix.argtypes = [_res, _u64, _u64, _a6, _u64, _a5, _u64, _a4, _u64, _u64]
42omega_mix.restype = ctypes.c_uint32
43# fn big n ulong to ulong
44omega_big = lib.omega_big
45omega_big.argtypes = [_res, _u64]
46omega_big.restype = ctypes.c_uint32