Browse Source

Fix returned pointer with caca types.

tags/v0.99.beta20
alxf 8 years ago
parent
commit
dcc7dca749
4 changed files with 24 additions and 1 deletions
  1. +6
    -0
      python/caca/canvas.py
  2. +8
    -0
      python/caca/display.py
  3. +5
    -0
      python/caca/dither.py
  4. +5
    -1
      python/caca/font.py

+ 6
- 0
python/caca/canvas.py View File

@@ -21,6 +21,11 @@ from caca import _lib, utf8_to_utf32, utf32_to_utf8
from caca import _PYTHON3, _str_to_bytes, _bytes_to_str from caca import _PYTHON3, _str_to_bytes, _bytes_to_str
from caca.font import _Font from caca.font import _Font



class _CanvasStruct(ctypes.Structure):
pass


class _Canvas(object): class _Canvas(object):
""" Model for Canvas objects. """ Model for Canvas objects.
""" """
@@ -61,6 +66,7 @@ class Canvas(_Canvas):
pointer -- pointer to libcaca canvas pointer -- pointer to libcaca canvas
""" """
_lib.caca_create_canvas.argtypes = [ctypes.c_int, ctypes.c_int] _lib.caca_create_canvas.argtypes = [ctypes.c_int, ctypes.c_int]
_lib.caca_create_canvas.restype = ctypes.POINTER(_CanvasStruct)


if pointer is None: if pointer is None:
try: try:


+ 8
- 0
python/caca/display.py View File

@@ -19,6 +19,10 @@ import ctypes
from caca import _lib, _PYTHON3, _str_to_bytes from caca import _lib, _PYTHON3, _str_to_bytes
from caca.canvas import _Canvas, Canvas from caca.canvas import _Canvas, Canvas


class _DisplayStruct(ctypes.Structure):
pass


class _Display(object): class _Display(object):
""" Model for Display objects. """ Model for Display objects.
""" """
@@ -57,11 +61,15 @@ class Display(_Display):


if driver is None: if driver is None:
_lib.caca_create_display.argtypes = [_Canvas] _lib.caca_create_display.argtypes = [_Canvas]
_lib.caca_create_display.restype = ctypes.POINTER(_DisplayStruct)
self._dp = _lib.caca_create_display(cv) self._dp = _lib.caca_create_display(cv)
else: else:
_lib.caca_create_display_with_driver.argtypes = [ _lib.caca_create_display_with_driver.argtypes = [
_Canvas, ctypes.c_char_p _Canvas, ctypes.c_char_p
] ]
_lib.caca_create_display_with_driver.restype = ctypes.POINTER(
_DisplayStruct
)
if _PYTHON3 and isinstance(driver, str): if _PYTHON3 and isinstance(driver, str):
driver = _str_to_bytes(driver) driver = _str_to_bytes(driver)




+ 5
- 0
python/caca/dither.py View File

@@ -19,6 +19,10 @@ import ctypes
from caca import _lib from caca import _lib
from caca.canvas import _Canvas from caca.canvas import _Canvas



class _DitherStruct(ctypes.Structure):
pass

class _Dither(object): class _Dither(object):
""" Model for Dither object. """ Model for Dither object.
""" """
@@ -66,6 +70,7 @@ class Dither(_Dither):
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint,
] ]
_lib.caca_create_dither.restype = ctypes.POINTER(_DitherStruct)


self._dither = _lib.caca_create_dither(bpp, width, height, pitch, self._dither = _lib.caca_create_dither(bpp, width, height, pitch,
rmask, gmask, bmask, amask) rmask, gmask, bmask, amask)


+ 5
- 1
python/caca/font.py View File

@@ -19,6 +19,10 @@ import errno


from caca import _lib, _PYTHON3, _str_to_bytes from caca import _lib, _PYTHON3, _str_to_bytes



class _FontStruct(ctypes.Structure):
pass

class _Font(object): class _Font(object):
""" Model for Font object. """ Model for Font object.
""" """
@@ -62,7 +66,7 @@ class Font(_Font):
else: else:
raise FontError("Unsupported method") raise FontError("Unsupported method")


_lib.caca_load_font.restype = ctypes.c_int
_lib.caca_load_font.restype = ctypes.POINTER(_FontStruct)


if _PYTHON3: if _PYTHON3:
font = _str_to_bytes(font) font = _str_to_bytes(font)


Loading…
Cancel
Save