00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _PYTALLOC_H_
00021 #define _PYTALLOC_H_
00022
00023 #include <Python.h>
00024 #include <talloc.h>
00025
00026 typedef struct {
00027 PyObject_HEAD
00028 TALLOC_CTX *talloc_ctx;
00029 void *ptr;
00030 } pytalloc_Object;
00031
00032
00033 PyTypeObject *pytalloc_GetObjectType(void);
00034
00035
00036 int pytalloc_Check(PyObject *);
00037
00038
00039
00040
00041
00042
00043 #define pytalloc_get_type(py_obj, type) (talloc_get_type(pytalloc_get_ptr(py_obj), type))
00044
00045 #define pytalloc_get_ptr(py_obj) (((pytalloc_Object *)py_obj)->ptr)
00046 #define pytalloc_get_mem_ctx(py_obj) ((pytalloc_Object *)py_obj)->talloc_ctx
00047
00048 PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
00049 PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr);
00050 PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
00051 #define pytalloc_reference(py_type, talloc_ptr) pytalloc_reference_ex(py_type, talloc_ptr, talloc_ptr)
00052
00053 #define pytalloc_new(type, typeobj) pytalloc_steal(typeobj, talloc_zero(NULL, type))
00054
00055 #if PY_MAJOR_VERSION < 3
00056 PyObject *pytalloc_CObject_FromTallocPtr(void *);
00057 #endif
00058
00059 #endif