From 3e2c070395d2fef232ab60d075194091f7b46b35 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 12 Dec 2008 13:31:42 +0100 Subject: Allow overriding repr function for pidl-defined types. --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pidl/lib/Parse') diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 2c64f06aa4..2664275934 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -295,6 +295,10 @@ sub PythonStruct($$$$$$) $self->pidl_hdr("#define $name\_Check(op) PyObject_TypeCheck(op, &$name\_Type)\n"); $self->pidl_hdr("#define $name\_CheckExact(op) ((op)->ob_type == &$name\_Type)\n"); $self->pidl_hdr("\n"); + $self->pidl("#ifndef ".uc("py_$name\_repr")); + $self->pidl("#define ".uc("py_$name\_repr") . " py_talloc_default_repr"); + $self->pidl("#endif"); + $self->pidl(""); my $docstring = ($self->DocString($d, $name) or "NULL"); my $typeobject = "$name\_Type"; $self->pidl("PyTypeObject $typeobject = {"); @@ -304,7 +308,7 @@ sub PythonStruct($$$$$$) $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),"); $self->pidl(".tp_dealloc = py_talloc_dealloc,"); $self->pidl(".tp_getset = $getsetters,"); - $self->pidl(".tp_repr = py_talloc_default_repr,"); + $self->pidl(".tp_repr = ".uc("py_$name\_repr").","); $self->pidl(".tp_doc = $docstring,"); $self->pidl(".tp_methods = $py_methods,"); $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,"); -- cgit