[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Tue Sep 21 12:47:07 MDT 2010


The branch, master has been updated
       via  049c4fa pytalloc: Add default compare function.
      from  1d90227 s3: Remove a pointless if-statement

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 049c4fa04dcee5a6083630b0464b715c5ca531cd
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Sep 21 00:40:17 2010 -0700

    pytalloc: Add default compare function.

-----------------------------------------------------------------------

Summary of changes:
 lib/talloc/pytalloc.c                |   15 ++++++++++++++-
 lib/talloc/pytalloc.h                |    1 +
 pidl/lib/Parse/Pidl/Samba4/Python.pm |    1 +
 3 files changed, 16 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c
index 054704f..bea6961 100644
--- a/lib/talloc/pytalloc.c
+++ b/lib/talloc/pytalloc.c
@@ -88,7 +88,7 @@ PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, voi
 }
 
 /**
- * Default (but slightly more useful than the default) implementation of Repr().
+ * Default (but only slightly more useful than the default) implementation of Repr().
  */
 PyObject *py_talloc_default_repr(PyObject *obj)
 {
@@ -99,6 +99,19 @@ PyObject *py_talloc_default_repr(PyObject *obj)
 				   type->tp_name, talloc_obj->ptr);
 }
 
+/**
+ * Default (but only slightly more useful than the default) implementation of cmp.
+ */
+int py_talloc_default_cmp(PyObject *_obj1, PyObject *_obj2)
+{
+	py_talloc_Object *obj1 = (py_talloc_Object *)_obj1,
+					 *obj2 = (py_talloc_Object *)_obj2;
+	if (obj1->ob_type != obj2->ob_type)
+		return (obj1->ob_type - obj2->ob_type);
+
+	return (py_talloc_get_ptr(obj1) - py_talloc_get_ptr(obj2));
+}
+
 static void py_cobject_talloc_free(void *ptr)
 {
 	talloc_free(ptr);
diff --git a/lib/talloc/pytalloc.h b/lib/talloc/pytalloc.h
index 4782756..b17977a 100644
--- a/lib/talloc/pytalloc.h
+++ b/lib/talloc/pytalloc.h
@@ -55,5 +55,6 @@ PyObject *py_talloc_default_repr(PyObject *py_obj);
 PyObject *PyCObject_FromTallocPtr(void *);
 
 PyObject *PyString_FromString_check_null(const char *ptr);
+int py_talloc_default_cmp(PyObject *obj1, PyObject *obj2);
 
 #endif /* _PY_TALLOC_H_ */
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index ed43ba4..bc56f17 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -325,6 +325,7 @@ sub PythonStruct($$$$$$)
 	$self->pidl(".tp_dealloc = py_talloc_dealloc,");
 	$self->pidl(".tp_getset = $getsetters,");
 	$self->pidl(".tp_repr = py_talloc_default_repr,");
+	$self->pidl(".tp_compare = py_talloc_default_cmp,");
 	if ($docstring) {
 		$self->pidl(".tp_doc = $docstring,");
 	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list