From 252675a5788059dbcc49b175b56fa6c6a35ef74a Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij <jelmer@samba.org>
Date: Sun, 13 Jan 2008 16:44:42 +0100
Subject: python: Add some utility functions for working with Python objects
 based on talloc pointers. (This used to be commit
 9366ddba92e192cd88e12eafba4a90af8c266f1c)

---
 source4/scripting/python/pytalloc.h | 43 +++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 source4/scripting/python/pytalloc.h

(limited to 'source4/scripting/python/pytalloc.h')

diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h
new file mode 100644
index 0000000000..93f6b48d82
--- /dev/null
+++ b/source4/scripting/python/pytalloc.h
@@ -0,0 +1,43 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+   
+   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
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _PY_TALLOC_H_
+#define _PY_TALLOC_H_
+
+#include <Python.h>
+
+typedef struct {
+	PyObject_HEAD
+	void *talloc_ptr;
+} py_talloc_Object;
+
+/* Deallocate a py_talloc_Object */
+void py_talloc_dealloc(PyObject* self);
+
+/* Retrieve the pointer for a py_talloc_object. Like talloc_get_type() 
+ * but for py_talloc_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_Object *)py_obj)->talloc_ptr, type)
+
+PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr);
+
+#endif /* _PY_TALLOC_H_ */
-- 
cgit 


From f7a0ef04f00cd44845bcee0a171e4cc05a545350 Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij <jelmer@samba.org>
Date: Sun, 13 Jan 2008 18:38:12 +0100
Subject: pidl/python: Support repr() for python types. (This used to be commit
 cf3664594d3540db20d32bc844f18e20abfa0d96)

---
 source4/scripting/python/pytalloc.h | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'source4/scripting/python/pytalloc.h')

diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h
index 93f6b48d82..735829bfcb 100644
--- a/source4/scripting/python/pytalloc.h
+++ b/source4/scripting/python/pytalloc.h
@@ -40,4 +40,7 @@ void py_talloc_dealloc(PyObject* self);
 
 PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr);
 
+/* Sane default implementation of reprfunc. */
+PyObject *py_talloc_default_repr(PyObject *py_obj);
+
 #endif /* _PY_TALLOC_H_ */
-- 
cgit 


From bfab9862fcdd657a1bddafde49cdd182f89fcf8b Mon Sep 17 00:00:00 2001
From: Jelmer Vernooij <jelmer@samba.org>
Date: Sun, 13 Jan 2008 20:41:34 +0100
Subject: python: Allow wrapping pointers within talloc'ed memory that are not
 talloc contexts. (This used to be commit
 9c038a74113fb55ed5eb12a7d0ae4a46bad9050c)

---
 source4/scripting/python/pytalloc.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'source4/scripting/python/pytalloc.h')

diff --git a/source4/scripting/python/pytalloc.h b/source4/scripting/python/pytalloc.h
index 735829bfcb..aad5840a67 100644
--- a/source4/scripting/python/pytalloc.h
+++ b/source4/scripting/python/pytalloc.h
@@ -24,7 +24,8 @@
 
 typedef struct {
 	PyObject_HEAD
-	void *talloc_ptr;
+	TALLOC_CTX *talloc_ctx;
+	void *ptr;
 } py_talloc_Object;
 
 /* Deallocate a py_talloc_Object */
@@ -36,9 +37,13 @@ void py_talloc_dealloc(PyObject* self);
 /* 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_Object *)py_obj)->talloc_ptr, type)
+	talloc_get_type(py_talloc_get_ptr(py_obj), type)
 
-PyObject *py_talloc_import(PyTypeObject *py_type, void *ptr);
+#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
+
+PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
+#define py_talloc_import(py_type, talloc_ptr) py_talloc_import_ex(py_type, talloc_ptr, talloc_ptr)
 
 /* Sane default implementation of reprfunc. */
 PyObject *py_talloc_default_repr(PyObject *py_obj);
-- 
cgit