Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-bridge/blob/main/evidence/native-bindings/omega_native.py # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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. 9 import ctypes, os 10 OMEGA_OK, OMEGA_BAD_ARG, OMEGA_REENTRY, OMEGA_BAD_RT, OMEGA_NO_STACK = 0, 32, 33, 34, 35 11 lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), "libomega_native.so")) 12 class _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 24 omega_madd = lib.omega_madd 25 omega_madd.argtypes = [_res, _u64, _u64, _u64] 26 omega_madd.restype = ctypes.c_uint32 27 # fn smadd a long b long c long to long 28 omega_smadd = lib.omega_smadd 29 omega_smadd.argtypes = [_res, _u64, _u64, _u64] 30 omega_smadd.restype = ctypes.c_uint32 31 # fn fill buf edit ulong 4 k ulong to ulong 32 omega_fill = lib.omega_fill 33 omega_fill.argtypes = [_res, _a3, _u64, _u64] 34 omega_fill.restype = ctypes.c_uint32 35 # fn spin n ulong to ulong 36 omega_spin = lib.omega_spin 37 omega_spin.argtypes = [_res, _u64] 38 omega_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 40 omega_mix = lib.omega_mix 41 omega_mix.argtypes = [_res, _u64, _u64, _a6, _u64, _a5, _u64, _a4, _u64, _u64] 42 omega_mix.restype = ctypes.c_uint32 43 # fn big n ulong to ulong 44 omega_big = lib.omega_big 45 omega_big.argtypes = [_res, _u64] 46 omega_big.restype = ctypes.c_uint32