Initial commit of cluster_c.pyx
This commit is contained in:
parent
cdf032cede
commit
3c955eba06
2 changed files with 42 additions and 1 deletions
41
py/hexagram/cluster_c.pyx
Normal file
41
py/hexagram/cluster_c.pyx
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
from cpython.ref cimport PyObject, PyTypeObject, Py_INCREF
|
||||||
|
|
||||||
|
from hexagram.cluster import Cluster
|
||||||
|
|
||||||
|
cdef extern from "linux/can.h":
|
||||||
|
cdef struct can_frame:
|
||||||
|
pass
|
||||||
|
|
||||||
|
cdef extern from "cairo.h":
|
||||||
|
ctypedef struct cairo_t:
|
||||||
|
pass
|
||||||
|
|
||||||
|
cdef extern from "py3cairo.h":
|
||||||
|
cdef PyObject *PycairoContext_FromContext(cairo_t *ctx, PyTypeObject *type, PyObject *base)
|
||||||
|
|
||||||
|
ctypedef struct Pycairo_CAPI_t:
|
||||||
|
pass
|
||||||
|
|
||||||
|
cdef extern Pycairo_CAPI_t *Pycairo_CAPI
|
||||||
|
|
||||||
|
cdef extern from *:
|
||||||
|
"""
|
||||||
|
#define ctx_type (Pycairo_CAPI->Context_Type)
|
||||||
|
"""
|
||||||
|
cdef extern PyTypeObject *ctx_type
|
||||||
|
|
||||||
|
cdef class hexagram_cluster_py:
|
||||||
|
cdef object _obj
|
||||||
|
|
||||||
|
def __cinit__(self, double rpm_min, double rpm_redline, double rpm_max):
|
||||||
|
self._obj = <object>Cluster(rpm_min, rpm_redline, rpm_max)
|
||||||
|
|
||||||
|
cdef draw_bg(self, cairo_t *cr):
|
||||||
|
ctx = <object>PycairoContext_FromContext(cr, ctx_type, NULL)
|
||||||
|
|
||||||
|
self._obj.draw_bg(ctx)
|
||||||
|
|
||||||
|
cdef draw_fg(self, cairo_t *cr):
|
||||||
|
ctx = <object>PycairoContext_FromContext(cr, ctx_type, NULL)
|
||||||
|
|
||||||
|
self._obj.draw_fg(ctx)
|
2
setup.py
2
setup.py
|
@ -14,7 +14,7 @@ setup(
|
||||||
ext_modules = cythonize(
|
ext_modules = cythonize(
|
||||||
Extension(
|
Extension(
|
||||||
"*", ["py/hexagram/*.pyx"],
|
"*", ["py/hexagram/*.pyx"],
|
||||||
include_dirs = ["./include", "/usr/include/cairo"]
|
include_dirs = ["./include", "/usr/include/cairo", "/usr/include/pycairo"]
|
||||||
), language_level = 3,
|
), language_level = 3,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue