From 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 29 Apr 2024 06:41:38 +0200 Subject: Adding upstream version 1.0.1. Signed-off-by: Daniel Baumann --- test cases/cython/1 basic/libdir/cstorer.pxd | 9 +++++++++ test cases/cython/1 basic/libdir/meson.build | 8 ++++++++ test cases/cython/1 basic/libdir/storer.c | 24 ++++++++++++++++++++++++ test cases/cython/1 basic/libdir/storer.h | 16 ++++++++++++++++ test cases/cython/1 basic/libdir/storer.pyx | 16 ++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 test cases/cython/1 basic/libdir/cstorer.pxd create mode 100644 test cases/cython/1 basic/libdir/meson.build create mode 100644 test cases/cython/1 basic/libdir/storer.c create mode 100644 test cases/cython/1 basic/libdir/storer.h create mode 100644 test cases/cython/1 basic/libdir/storer.pyx (limited to 'test cases/cython/1 basic/libdir') diff --git a/test cases/cython/1 basic/libdir/cstorer.pxd b/test cases/cython/1 basic/libdir/cstorer.pxd new file mode 100644 index 0000000..7b730fc --- /dev/null +++ b/test cases/cython/1 basic/libdir/cstorer.pxd @@ -0,0 +1,9 @@ + +cdef extern from "storer.h": + ctypedef struct Storer: + pass + + Storer* storer_new(); + void storer_destroy(Storer *s); + int storer_get_value(Storer *s); + void storer_set_value(Storer *s, int v); diff --git a/test cases/cython/1 basic/libdir/meson.build b/test cases/cython/1 basic/libdir/meson.build new file mode 100644 index 0000000..144bb1f --- /dev/null +++ b/test cases/cython/1 basic/libdir/meson.build @@ -0,0 +1,8 @@ +slib = py3.extension_module( + 'storer', + 'storer.pyx', + 'storer.c', + dependencies : py3_dep +) + +pydir = meson.current_build_dir() diff --git a/test cases/cython/1 basic/libdir/storer.c b/test cases/cython/1 basic/libdir/storer.c new file mode 100644 index 0000000..0199bb8 --- /dev/null +++ b/test cases/cython/1 basic/libdir/storer.c @@ -0,0 +1,24 @@ +#include"storer.h" +#include + +struct _Storer { + int value; +}; + +Storer* storer_new() { + Storer *s = malloc(sizeof(struct _Storer)); + s->value = 0; + return s; +} + +void storer_destroy(Storer *s) { + free(s); +} + +int storer_get_value(Storer *s) { + return s->value; +} + +void storer_set_value(Storer *s, int v) { + s->value = v; +} diff --git a/test cases/cython/1 basic/libdir/storer.h b/test cases/cython/1 basic/libdir/storer.h new file mode 100644 index 0000000..6f5bc6f --- /dev/null +++ b/test cases/cython/1 basic/libdir/storer.h @@ -0,0 +1,16 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _Storer Storer; + +Storer* storer_new(); +void storer_destroy(Storer *s); +int storer_get_value(Storer *s); +void storer_set_value(Storer *s, int v); + +#ifdef __cplusplus +} +#endif diff --git a/test cases/cython/1 basic/libdir/storer.pyx b/test cases/cython/1 basic/libdir/storer.pyx new file mode 100644 index 0000000..ed551dc --- /dev/null +++ b/test cases/cython/1 basic/libdir/storer.pyx @@ -0,0 +1,16 @@ +cimport cstorer + +cdef class Storer: + cdef cstorer.Storer* _c_storer + + def __cinit__(self): + self._c_storer = cstorer.storer_new() + + def __dealloc__(self): + cstorer.storer_destroy(self._c_storer) + + cpdef int get_value(self): + return cstorer.storer_get_value(self._c_storer) + + cpdef set_value(self, int value): + cstorer.storer_set_value(self._c_storer, value) -- cgit v1.2.3