diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2011-08-10 15:15:18 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2011-08-10 15:36:21 +0200 |
commit | f8ec7f6cb19c4cc27398bdc0482b531e601d4291 (patch) | |
tree | 52c06e88c413547579c9e804a5c78d96e46bd4ba /lib | |
parent | 8338fe4bfbc935e3cff059383dd07d419f58c696 (diff) | |
download | samba-f8ec7f6cb19c4cc27398bdc0482b531e601d4291.tar.gz samba-f8ec7f6cb19c4cc27398bdc0482b531e601d4291.tar.bz2 samba-f8ec7f6cb19c4cc27398bdc0482b531e601d4291.zip |
pytalloc: Use consistent prefix for functions, add ABI file.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/talloc/ABI/pytalloc-util-2.0.6.sigs | 5 | ||||
-rw-r--r-- | lib/talloc/pytalloc.c | 42 | ||||
-rw-r--r-- | lib/talloc/pytalloc.h | 36 | ||||
-rw-r--r-- | lib/talloc/pytalloc_util.c | 22 | ||||
-rw-r--r-- | lib/talloc/wscript | 3 |
5 files changed, 57 insertions, 51 deletions
diff --git a/lib/talloc/ABI/pytalloc-util-2.0.6.sigs b/lib/talloc/ABI/pytalloc-util-2.0.6.sigs new file mode 100644 index 0000000000..5f446ce7ac --- /dev/null +++ b/lib/talloc/ABI/pytalloc-util-2.0.6.sigs @@ -0,0 +1,5 @@ +pytalloc_CObject_FromTallocPtr: PyObject *(void *) +pytalloc_GetObjectType: PyTypeObject *(void) +pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *) +pytalloc_steal: PyObject *(PyTypeObject *, void *) +pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *) diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c index 614b81f057..62c6808825 100644 --- a/lib/talloc/pytalloc.c +++ b/lib/talloc/pytalloc.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. Python Talloc Module - Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2010 + Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2010-2011 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ void inittalloc(void); /* print a talloc tree report for a talloc python object */ -static PyObject *py_talloc_report_full(PyObject *self, PyObject *args) +static PyObject *pytalloc_report_full(PyObject *self, PyObject *args) { PyObject *py_obj = Py_None; PyTypeObject *type; @@ -36,20 +36,20 @@ static PyObject *py_talloc_report_full(PyObject *self, PyObject *args) talloc_report_full(NULL, stdout); } else { type = (PyTypeObject*)PyObject_Type(py_obj); - talloc_report_full(py_talloc_get_mem_ctx(py_obj), stdout); + talloc_report_full(pytalloc_get_mem_ctx(py_obj), stdout); } return Py_None; } /* enable null tracking */ -static PyObject *py_talloc_enable_null_tracking(PyObject *self) +static PyObject *pytalloc_enable_null_tracking(PyObject *self) { talloc_enable_null_tracking(); return Py_None; } /* return the number of talloc blocks */ -static PyObject *py_talloc_total_blocks(PyObject *self, PyObject *args) +static PyObject *pytalloc_total_blocks(PyObject *self, PyObject *args) { PyObject *py_obj = Py_None; PyTypeObject *type; @@ -63,15 +63,15 @@ static PyObject *py_talloc_total_blocks(PyObject *self, PyObject *args) type = (PyTypeObject*)PyObject_Type(py_obj); - return PyLong_FromLong(talloc_total_blocks(py_talloc_get_mem_ctx(py_obj))); + return PyLong_FromLong(talloc_total_blocks(pytalloc_get_mem_ctx(py_obj))); } static PyMethodDef talloc_methods[] = { - { "report_full", (PyCFunction)py_talloc_report_full, METH_VARARGS, + { "report_full", (PyCFunction)pytalloc_report_full, METH_VARARGS, "show a talloc tree for an object"}, - { "enable_null_tracking", (PyCFunction)py_talloc_enable_null_tracking, METH_NOARGS, + { "enable_null_tracking", (PyCFunction)pytalloc_enable_null_tracking, METH_NOARGS, "enable tracking of the NULL object"}, - { "total_blocks", (PyCFunction)py_talloc_total_blocks, METH_VARARGS, + { "total_blocks", (PyCFunction)pytalloc_total_blocks, METH_VARARGS, "return talloc block count"}, { NULL } }; @@ -79,9 +79,9 @@ static PyMethodDef talloc_methods[] = { /** * Default (but only slightly more useful than the default) implementation of Repr(). */ -static PyObject *py_talloc_default_repr(PyObject *obj) +static PyObject *pytalloc_default_repr(PyObject *obj) { - py_talloc_Object *talloc_obj = (py_talloc_Object *)obj; + pytalloc_Object *talloc_obj = (pytalloc_Object *)obj; PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj); return PyString_FromFormat("<%s talloc object at 0x%p>", @@ -91,9 +91,9 @@ static PyObject *py_talloc_default_repr(PyObject *obj) /** * Simple dealloc for talloc-wrapping PyObjects */ -static void py_talloc_dealloc(PyObject* self) +static void pytalloc_dealloc(PyObject* self) { - py_talloc_Object *obj = (py_talloc_Object *)self; + pytalloc_Object *obj = (pytalloc_Object *)self; assert(talloc_unlink(NULL, obj->talloc_ctx) != -1); obj->talloc_ctx = NULL; self->ob_type->tp_free(self); @@ -102,24 +102,24 @@ static void py_talloc_dealloc(PyObject* self) /** * Default (but only slightly more useful than the default) implementation of cmp. */ -static int py_talloc_default_cmp(PyObject *_obj1, PyObject *_obj2) +static int pytalloc_default_cmp(PyObject *_obj1, PyObject *_obj2) { - py_talloc_Object *obj1 = (py_talloc_Object *)_obj1, - *obj2 = (py_talloc_Object *)_obj2; + pytalloc_Object *obj1 = (pytalloc_Object *)_obj1, + *obj2 = (pytalloc_Object *)_obj2; if (obj1->ob_type != obj2->ob_type) return (obj1->ob_type - obj2->ob_type); - return ((char *)py_talloc_get_ptr(obj1) - (char *)py_talloc_get_ptr(obj2)); + return ((char *)pytalloc_get_ptr(obj1) - (char *)pytalloc_get_ptr(obj2)); } static PyTypeObject TallocObject_Type = { .tp_name = "talloc.Object", .tp_doc = "Python wrapper for a talloc-maintained object.", - .tp_basicsize = sizeof(py_talloc_Object), - .tp_dealloc = (destructor)py_talloc_dealloc, + .tp_basicsize = sizeof(pytalloc_Object), + .tp_dealloc = (destructor)pytalloc_dealloc, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_repr = py_talloc_default_repr, - .tp_compare = py_talloc_default_cmp, + .tp_repr = pytalloc_default_repr, + .tp_compare = pytalloc_default_cmp, }; void inittalloc(void) diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h index bfd9c2e017..2d2c57b789 100644 --- a/lib/talloc/pytalloc.h +++ b/lib/talloc/pytalloc.h @@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _PY_TALLOC_H_ -#define _PY_TALLOC_H_ +#ifndef _PYTALLOC_H_ +#define _PYTALLOC_H_ #include <Python.h> #include <talloc.h> @@ -27,30 +27,28 @@ typedef struct { PyObject_HEAD TALLOC_CTX *talloc_ctx; void *ptr; -} py_talloc_Object; +} pytalloc_Object; -PyTypeObject *PyTalloc_GetObjectType(void); -int PyTalloc_Check(PyObject *); +PyTypeObject *pytalloc_GetObjectType(void); +int pytalloc_Check(PyObject *); -/* Retrieve the pointer for a py_talloc_object. Like talloc_get_type() - * but for py_talloc_Objects. */ +/* Retrieve the pointer for a pytalloc_object. Like talloc_get_type() + * but for pytalloc_Objects. */ /* FIXME: Call PyErr_SetString(PyExc_TypeError, "expected " __STR(type) ") * when talloc_get_type() returns NULL. */ -#define py_talloc_get_type(py_obj, type) (talloc_get_type(py_talloc_get_ptr(py_obj), type)) +#define pytalloc_get_type(py_obj, type) (talloc_get_type(pytalloc_get_ptr(py_obj), type)) -#define py_talloc_get_ptr(py_obj) (((py_talloc_Object *)py_obj)->ptr) -#define py_talloc_get_mem_ctx(py_obj) ((py_talloc_Object *)py_obj)->talloc_ctx +#define pytalloc_get_ptr(py_obj) (((pytalloc_Object *)py_obj)->ptr) +#define pytalloc_get_mem_ctx(py_obj) ((pytalloc_Object *)py_obj)->talloc_ctx -PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr); -PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr); -PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr); -#define py_talloc_reference(py_type, talloc_ptr) py_talloc_reference_ex(py_type, talloc_ptr, talloc_ptr) +PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr); +PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr); +PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr); +#define pytalloc_reference(py_type, talloc_ptr) pytalloc_reference_ex(py_type, talloc_ptr, talloc_ptr) -#define py_talloc_new(type, typeobj) py_talloc_steal(typeobj, talloc_zero(NULL, type)) +#define pytalloc_new(type, typeobj) pytalloc_steal(typeobj, talloc_zero(NULL, type)) -PyObject *PyCObject_FromTallocPtr(void *); +PyObject *pytalloc_CObject_FromTallocPtr(void *); -PyObject *PyString_FromString_check_null(const char *ptr); - -#endif /* _PY_TALLOC_H_ */ +#endif /* _PYTALLOC_H_ */ diff --git a/lib/talloc/pytalloc_util.c b/lib/talloc/pytalloc_util.c index c8a7e6ac58..89a093b1ce 100644 --- a/lib/talloc/pytalloc_util.c +++ b/lib/talloc/pytalloc_util.c @@ -23,7 +23,7 @@ #include "pytalloc.h" #include <assert.h> -_PUBLIC_ PyTypeObject *PyTalloc_GetObjectType(void) +_PUBLIC_ PyTypeObject *pytalloc_GetObjectType(void) { static PyTypeObject *type = NULL; PyObject *mod; @@ -46,10 +46,10 @@ _PUBLIC_ PyTypeObject *PyTalloc_GetObjectType(void) /** * Import an existing talloc pointer into a Python object. */ -_PUBLIC_ PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, +_PUBLIC_ PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr) { - py_talloc_Object *ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0); + pytalloc_Object *ret = (pytalloc_Object *)py_type->tp_alloc(py_type, 0); ret->talloc_ctx = talloc_new(NULL); if (ret->talloc_ctx == NULL) { return NULL; @@ -65,9 +65,9 @@ _PUBLIC_ PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx /** * Import an existing talloc pointer into a Python object. */ -_PUBLIC_ PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr) +_PUBLIC_ PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr) { - return py_talloc_steal_ex(py_type, ptr, ptr); + return pytalloc_steal_ex(py_type, ptr, ptr); } @@ -76,15 +76,15 @@ _PUBLIC_ PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr) * original parent, and creating a reference to the object in the python * object */ -_PUBLIC_ PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr) +_PUBLIC_ PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr) { - py_talloc_Object *ret; + pytalloc_Object *ret; if (ptr == NULL) { Py_RETURN_NONE; } - ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0); + ret = (pytalloc_Object *)py_type->tp_alloc(py_type, 0); ret->talloc_ctx = talloc_new(NULL); if (ret->talloc_ctx == NULL) { return NULL; @@ -102,7 +102,7 @@ static void py_cobject_talloc_free(void *ptr) talloc_free(ptr); } -_PUBLIC_ PyObject *PyCObject_FromTallocPtr(void *ptr) +_PUBLIC_ PyObject *pytalloc_CObject_FromTallocPtr(void *ptr) { if (ptr == NULL) { Py_RETURN_NONE; @@ -110,9 +110,9 @@ _PUBLIC_ PyObject *PyCObject_FromTallocPtr(void *ptr) return PyCObject_FromVoidPtr(ptr, py_cobject_talloc_free); } -_PUBLIC_ int PyTalloc_Check(PyObject *obj) +_PUBLIC_ int pytalloc_Check(PyObject *obj) { - PyTypeObject *tp = PyTalloc_GetObjectType(); + PyTypeObject *tp = pytalloc_GetObjectType(); return PyObject_TypeCheck(obj, tp); } diff --git a/lib/talloc/wscript b/lib/talloc/wscript index 6c0019fd7e..c43c661823 100644 --- a/lib/talloc/wscript +++ b/lib/talloc/wscript @@ -110,6 +110,9 @@ def build(bld): public_deps='talloc', pyext=True, vnum=VERSION, + hide_symbols=True, + abi_directory='ABI', + abi_match='pytalloc_*', private_library=private_library, public_headers='pytalloc.h' ) |