From 0da8d00a6edbd7e57f9734be72fa8caa5ddf24b3 Mon Sep 17 00:00:00 2001 From: doomchild Date: Tue, 25 May 2010 15:37:40 -0500 Subject: [PATCH] added definitions for base callbacks --- dfhack/python/c api/util.py | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/dfhack/python/c api/util.py b/dfhack/python/c api/util.py index d81b01ede..4f3f06958 100644 --- a/dfhack/python/c api/util.py +++ b/dfhack/python/c api/util.py @@ -12,3 +12,55 @@ def _allocate_array(t_type, count): ptr = addressof(arr) return (arr, ptr) + +def _alloc_int_buffer(count): + a = _allocate_array(c_int, count) + + return a[1] + +alloc_int_buffer = CFUNCTYPE(POINTER(c_int), c_uint)(_alloc_int_buffer) + +def _alloc_uint_buffer(count): + a = _allocate_array(c_uint, count) + + return a[1] + +alloc_uint_buffer = CFUNCTYPE(POINTER(c_uint), c_uint)(_alloc_uint_buffer) + +def _alloc_short_buffer(count): + a = _allocate_array(c_short, count) + + return a[1] + +alloc_short_buffer = CFUNCTYPE(POINTER(c_short), c_uint)(_alloc_short_buffer) + +def _alloc_ushort_buffer(count): + a = _allocate_array(c_ushort, count) + + return a[1] + +alloc_ushort_buffer = CFUNCTYPE(POINTER(c_ushort), c_uint)(_alloc_ushort_buffer) + +def _alloc_byte_buffer(count): + a = _allocate_array(c_byte, count) + + return a[1] + +alloc_byte_buffer = CFUNCTYPE(POINTER(c_byte), c_uint)(_alloc_byte_buffer) + +def _alloc_ubyte_buffer(count): + a = _allocate_array(c_ubyte, count) + + return a[1] + +alloc_ubyte_buffer = CFUNCTYPE(POINTER(c_ubyte), c_uint)(_alloc_ubyte_buffer) + +def _alloc_char_buffer(count): + c = create_string_buffer(count) + + ptr = c_void_p() + ptr = addressof(c) + + return ptr + +alloc_char_buffer = CFUNCTYPE(POINTER(c_char), c_uint)(_alloc_char_buffer)