From 45cdd4f2c6b04bfdfd37ef0e1a6358b29680afb8 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 19 Apr 2009 15:17:32 +0200 Subject: * python/*.cc: Export all types and add a __new__() method to them. Some names may be changed before the release, but this is a good draft. --- python/pkgrecords.cc | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'python/pkgrecords.cc') diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 978de6b7..1cccfce2 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -132,13 +132,25 @@ static PyGetSetDef PkgRecordsGetSet[] = { {} }; +static PyObject *PkgRecordsNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) +{ + PyObject *Owner; + char *kwlist[] = {"cache",0}; + if (PyArg_ParseTupleAndKeywords(Args,kwds,"O!",kwlist,&PkgCacheType, + &Owner) == 0) + return 0; + + return HandleErrors(CppOwnedPyObject_NEW(Owner,type, + GetCpp(Owner))); +} + PyTypeObject PkgRecordsType = { PyObject_HEAD_INIT(&PyType_Type) #if PY_MAJOR_VERSION < 3 0, // ob_size #endif - "pkgRecords", // tp_name + "apt_pkg.PackageRecords", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods @@ -168,17 +180,22 @@ PyTypeObject PkgRecordsType = PkgRecordsMethods, // tp_methods 0, // tp_members PkgRecordsGetSet, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + PkgRecordsNew, // tp_new }; /*}}}*/ + + PyObject *GetPkgRecords(PyObject *Self,PyObject *Args) { - PyObject *Owner; - if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0) - return 0; - - return HandleErrors(CppOwnedPyObject_NEW(Owner,&PkgRecordsType, - GetCpp(Owner))); + return PkgRecordsNew(&PkgRecordsType,Args,0); } -- cgit v1.2.3