mirror of
https://github.com/SK8-ENGINE/skate-3-rust-engine.git
synced 2026-10-26 19:47:44 +00:00
19 lines
812 B
Python
19 lines
812 B
Python
"""Optional bundled native RefPack backend; source-only tools retain Python."""
|
|
import ctypes
|
|
from pathlib import Path
|
|
|
|
_library=None
|
|
for path in (Path(__file__).with_name('refpack.dll'),Path(__file__).resolve().parents[2]/'target/native/refpack.dll'):
|
|
if path.is_file():
|
|
_library=ctypes.CDLL(str(path))
|
|
_library.skate_refpack.argtypes=[ctypes.c_char_p,ctypes.c_size_t,ctypes.c_void_p,ctypes.c_size_t,ctypes.c_size_t,ctypes.c_bool]
|
|
_library.skate_refpack.restype=ctypes.c_int
|
|
break
|
|
|
|
def decode(data,size,start,early=False):
|
|
if _library is None:return None
|
|
output=ctypes.create_string_buffer(size)
|
|
if _library.skate_refpack(data,len(data),output,size,start,early):
|
|
raise ValueError('Malformed RefPack command or declared output size')
|
|
return output.raw
|