summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-01-27 17:45:22 +0100
committerJulian Andres Klode <jak@debian.org>2010-01-27 17:45:22 +0100
commit748f5005026e2698c7e9ff7e98f6a7799567c60e (patch)
tree6e4666a2f3918f783896c3db7fae3e8968629e5b /python
parentd24964f86e1108f88d55a9580bbd6d2e482562dd (diff)
downloadpython-apt-748f5005026e2698c7e9ff7e98f6a7799567c60e.tar.gz
Remove inline functions from the C++ API, export them instead (part 1)
Diffstat (limited to 'python')
-rw-r--r--python/apt_pkgmodule.cc35
-rw-r--r--python/apt_pkgmodule.h36
-rw-r--r--python/python-apt.h276
3 files changed, 244 insertions, 103 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index e77fd3ca..d2472395 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -527,36 +527,67 @@ static PyMethodDef methods[] =
static struct _PyAptPkgAPIStruct API = {
&PyAcquire_Type, // acquire_type
&PyAcquire_FromCpp, // acquire_fromcpp
+ &PyAcquire_ToCpp, // acquire_tocpp
&PyAcquireFile_Type, // acquirefile_type
+ &PyAcquireFile_ToCpp, // acquirefile_tocpp
&PyAcquireItem_Type, // acquireitem_type
+ &PyAcquireItem_ToCpp, // acquireitem_type
&PyAcquireItemDesc_Type, // acquireitemdesc_type
+ &PyAcquireItemDesc_ToCpp, // acquireitemdesc_tocpp
&PyAcquireWorker_Type, // acquireworker_type
+ &PyAcquireWorker_ToCpp, // acquireworker_tocpp
&PyActionGroup_Type, // actiongroup_type
+ &PyActionGroup_ToCpp, // actiongroup_type
&PyCache_Type, // cache_type
- &PyCacheFile_Type, // cachefile_type
+ &PyCache_ToCpp, // cache_tocpp
+ &PyCacheFile_Type, // cachefile_type
+ &PyCacheFile_ToCpp, // cachefile_tocpp
&PyCdrom_Type, // cdrom_type
+ &PyCdrom_ToCpp, // cdrom_tocpp
&PyConfiguration_Type, // configuration_type
+ &PyConfiguration_ToCpp, // configuration_tocpp
&PyDepCache_Type, // depcache_type
+ &PyDepCache_ToCpp, // depcache_tocpp
&PyDependency_Type, // dependency_type
+ &PyDependency_ToCpp, // dependency_type
&PyDependencyList_Type, // dependencylist_type
+ 0, // FIXME: dependencylist_tocpp
&PyDescription_Type, // description_type
+ &PyDescription_ToCpp, // description_tocpp
&PyHashes_Type, // hashes_type
+ &PyHashes_ToCpp, // hashes_tocpp
&PyHashString_Type, // hashstring_type
+ &PyHashString_ToCpp, // hashstring_tocpp
&PyIndexRecords_Type, // indexrecords_type
+ &PyIndexRecords_ToCpp, // indexrecords_tocpp
&PyMetaIndex_Type, // metaindex_type
+ &PyMetaIndex_ToCpp, // metaindex_tocpp
&PyPackage_Type, // package_type
+ &PyPackage_ToCpp, // package_tocpp
&PyPackageFile_Type, // packagefile_type
- &PyIndexFile_Type, // packageindexfile_type
+ &PyPackageFile_ToCpp, // packagefile_tocpp
+ &PyIndexFile_Type, // packageindexfile_type
+ &PyIndexFile_ToCpp, // packageindexfile_tocpp
&PyPackageList_Type, // packagelist_type
+ 0, // FIXME: packagelist_tocpp
&PyPackageManager_Type, // packagemanager_type
+ &PyPackageManager_ToCpp, // packagemanager_type
&PyPackageRecords_Type, // packagerecords_type
+ 0, // FIXME: packagerecords_tocpp
&PyPolicy_Type, // policy_type
+ &PyPolicy_ToCpp, // policy_tocpp
&PyProblemResolver_Type, // problemresolver_type
+ &PyProblemResolver_ToCpp, // problemresolver_tocpp
&PySourceList_Type, // sourcelist_type
+ &PySourceList_ToCpp, // sourcelist_tocpp
&PySourceRecords_Type, // sourcerecords_type
+ 0, // sourcerecords_tocpp
&PyTagFile_Type, // tagfile_type
+ &PyTagFile_ToCpp, // tagfile_tocpp
&PyTagSection_Type, // tagsection_type
+ &PyTagSection_ToCpp, // tagsection_tocpp
&PyVersion_Type, // version_type
+ &PyVersion_ToCpp, // version_tocpp
};
diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h
index ec6cf10e..a22a25f0 100644
--- a/python/apt_pkgmodule.h
+++ b/python/apt_pkgmodule.h
@@ -13,6 +13,7 @@
#include <Python.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/acquire-item.h>
+#include "generic.h"
// Configuration Stuff
#define Configuration_Check(op) ((op)->ob_type == &PyConfiguration_Type)
@@ -122,8 +123,41 @@ extern PyTypeObject PyAcquireWorker_Type;
extern PyTypeObject PySystemLock_Type;
extern PyTypeObject PyFileLock_Type;
+// Functions to be exported in the public API.
PyObject *PyAcquire_FromCpp(pkgAcquire *fetcher, bool Delete);
-PyObject *PyAcquireItem_FromCpp(pkgAcquire::Item *item, bool Delete, PyObject *owner);
+# define PyAcquire_ToCpp GetCpp<pkgAcquire*>
+# define PyAcquireFile_ToCpp GetCpp<pkgAcqFile*>
+# define PyAcquireItem_ToCpp GetCpp<pkgAcquire::Item*>
+# define PyAcquireItemDesc_ToCpp GetCpp<pkgAcquire::ItemDesc*>
+# define PyAcquireWorker_ToCpp GetCpp<pkgAcquire::Worker*>
+# define PyActionGroup_ToCpp GetCpp<pkgDepCache::ActionGroup*>
+# define PyCache_ToCpp GetCpp<pkgCache*>
+# define PyCacheFile_ToCpp GetCpp<pkgCacheFile*>
+# define PyCdrom_ToCpp GetCpp<pkgCdrom>
+# define PyConfiguration_ToCpp GetCpp<Configuration*>
+# define PyDepCache_ToCpp GetCpp<pkgDepCache*>
+# define PyDependency_ToCpp GetCpp<pkgCache::DepIterator>
+# define PyDependencyList_ToCpp GetCpp<RDepListStruct> // TODO
+# define PyDescription_ToCpp GetCpp<pkgCache::DescIterator>
+# define PyHashes_ToCpp GetCpp<Hashes>
+# define PyHashString_ToCpp GetCpp<HashString*>
+# define PyIndexRecords_ToCpp GetCpp<indexRecords*>
+# define PyMetaIndex_ToCpp GetCpp<metaIndex*>
+# define PyPackage_ToCpp GetCpp<pkgCache::PkgIterator>
+# define PyPackageFile_ToCpp GetCpp<pkgCache::PkgFileIterator>
+# define PyIndexFile_ToCpp GetCpp<pkgIndexFile*>
+# define PyPackageList_ToCpp GetCpp<PkgListStruct> // TODO
+# define PyPackageManager_ToCpp GetCpp<pkgPackageManager*>
+# define PyPackageRecords_ToCpp GetCpp<PkgRecordsStruct> // TODO
+# define PyPolicy_ToCpp GetCpp<pkgPolicy*>
+# define PyProblemResolver_ToCpp GetCpp<pkgProblemResolver*>
+# define PySourceList_ToCpp GetCpp<pkgSourceList*>
+# define PySourceRecords_ToCpp GetCpp<PkgSrcRecordsStruct> // TODO
+# define PyTagFile_ToCpp GetCpp<pkgTagFile>
+# define PyTagSection_ToCpp GetCpp<pkgTagSection>
+# define PyVersion_ToCpp GetCpp<pkgCache::VerIterator>
+
+
#include "python-apt.h"
#endif
diff --git a/python/python-apt.h b/python/python-apt.h
index 6f688c93..7b34c249 100644
--- a/python/python-apt.h
+++ b/python/python-apt.h
@@ -1,7 +1,7 @@
/*
* python-apt.h - Header file for the public interface.
*
- * Copyright 2009 Julian Andres Klode <jak@debian.org>
+ * Copyright 2009-2010 Julian Andres Klode <jak@debian.org>
*
* 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
@@ -23,103 +23,120 @@
#define PYTHON_APT_H
#include <Python.h>
#include "generic.h"
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/acquire-item.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/version.h>
+#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cachefile.h>
+#include <apt-pkg/tagfile.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/cdrom.h>
+#include <apt-pkg/algorithms.h>
+#include <apt-pkg/hashes.h>
+
+typedef PyObject *ActionGroupF(pkgDepCache::ActionGroup *);
+typedef pkgDepCache::ActionGroup*& ActionGroupT(PyObject *self);
struct _PyAptPkgAPIStruct {
+ // apt_pkg.Acquire (pkgAcquire*)
PyTypeObject *acquire_type;
- PyObject* (*acquire_fromcpp)(pkgAcquire *acquire, bool Delete);
+ PyObject* (*acquire_fromcpp)(pkgAcquire *acquire, bool Delete);
+ pkgAcquire*& (*acquire_tocpp)(PyObject *self);
+ // apt_pkg.AcquireFile
PyTypeObject *acquirefile_type;
+ pkgAcqFile*& (*acquirefile_tocpp)(PyObject *self);
+ // apt_pkg.AcquireItem
PyTypeObject *acquireitem_type;
+ pkgAcquire::Item*& (*acquireitem_tocpp)(PyObject *self);
+ // apt_pkg.AcquireItemDesc
PyTypeObject *acquireitemdesc_type;
+ pkgAcquire::ItemDesc*& (*acquireitemdesc_tocpp)(PyObject *self);
+
PyTypeObject *acquireworker_type;
+ pkgAcquire::Worker*& (*acquireworker_tocpp)(PyObject *self);
+
PyTypeObject *actiongroup_type;
+ pkgDepCache::ActionGroup*& (*actiongroup_tocpp)(PyObject *self);
+
PyTypeObject *cache_type;
+ pkgCache*& (*cache_tocpp)(PyObject *self);
+
PyTypeObject *cachefile_type;
+ pkgCacheFile*& (*cachefile_tocpp)(PyObject *self);
+
PyTypeObject *cdrom_type;
+ pkgCdrom& (*cdrom_tocpp)(PyObject *self);
+
PyTypeObject *configuration_type;
+ Configuration*& (*configuration_tocpp)(PyObject *self);
+
PyTypeObject *depcache_type;
+ pkgDepCache*& (*depcache_tocpp)(PyObject *self);
+
PyTypeObject *dependency_type;
+ pkgCache::DepIterator& (*dependency_tocpp)(PyObject *self);
+
PyTypeObject *dependencylist_type;
+ void *dependencylist_tocpp; // FIXME: need packagelist_tocpp
+
PyTypeObject *description_type;
+ pkgCache::DescIterator& (*description_tocpp)(PyObject *self);
+
PyTypeObject *hashes_type;
+ Hashes& (*hashes_tocpp)(PyObject *self);
+
PyTypeObject *hashstring_type;
+ HashString*& (*hashstring_tocpp)(PyObject *self);
+
PyTypeObject *indexrecords_type;
+ indexRecords*& (*indexrecords_tocpp)(PyObject *self);
+
PyTypeObject *metaindex_type;
+ metaIndex*& (*metaindex_tocpp)(PyObject *self);
+
PyTypeObject *package_type;
+ pkgCache::PkgIterator& (*package_tocpp)(PyObject *self);
+
PyTypeObject *packagefile_type;
+ pkgCache::PkgFileIterator& (*packagefile_tocpp)(PyObject *self);
+
PyTypeObject *packageindexfile_type;
+ pkgIndexFile*& (*packageindexfile_tocpp)(PyObject *self);
+
PyTypeObject *packagelist_type;
+ void *packagelist_tocpp; // FIXME: need packagelist_tocpp
+
PyTypeObject *packagemanager_type;
+ pkgPackageManager*& (*packagemanager_tocpp)(PyObject *self);
+
PyTypeObject *packagerecords_type;
+ void *packagerecords_tocpp; // FIXME: need packagerecords_tocpp
+
PyTypeObject *policy_type;
+ pkgPolicy*& (*policy_tocpp)(PyObject *self);
+
PyTypeObject *problemresolver_type;
+ pkgProblemResolver*& (*problemresolver_tocpp)(PyObject *self);
+
PyTypeObject *sourcelist_type;
+ pkgSourceList*& (*sourcelist_tocpp)(PyObject *self);
+
PyTypeObject *sourcerecords_type;
+ void *sourcerecords_tocpp; // FIXME: need sourcerecords_tocpp
+
PyTypeObject *tagfile_type;
+ pkgTagFile& (*tagfile_tocpp)(PyObject *self);
+
PyTypeObject *tagsection_type;
+ pkgTagSection& (*tagsection_tocpp)(PyObject *self);
+
PyTypeObject *version_type;
+ pkgCache::VerIterator& (*version_tocpp)(PyObject *self);
};
-# ifndef APT_PKGMODULE_H
-# define PyAcquire_Type *(_PyAptPkg_API->acquire_type)
-# define PyAcquireFile_Type *(_PyAptPkg_API->acquirefile_type)
-# define PyAcquireItem_Type *(_PyAptPkg_API->acquireitem_type)
-# define PyAcquireItemDesc_Type *(_PyAptPkg_API->acquireitemdesc_type)
-# define PyAcquireWorker_Type *(_PyAptPkg_API->acquireworker_type)
-# define PyActionGroup_Type *(_PyAptPkg_API->actiongroup_type)
-# define PyCache_Type *(_PyAptPkg_API->cache_type)
-# define PyCacheFile_Type *(_PyAptPkg_API->cachefile_type)
-# define PyCdrom_Type *(_PyAptPkg_API->cdrom_type)
-# define PyConfiguration_Type *(_PyAptPkg_API->configuration_type)
-# define PyDepCache_Type *(_PyAptPkg_API->depcache_type)
-# define PyDependency_Type *(_PyAptPkg_API->dependency_type)
-# define PyDependencyList_Type *(_PyAptPkg_API->dependencylist_type)
-# define PyDescription_Type *(_PyAptPkg_API->description_type)
-# define PyHashes_Type *(_PyAptPkg_API->hashes_type)
-# define PyHashString_Type *(_PyAptPkg_API->hashstring_type)
-# define PyIndexRecords_Type *(_PyAptPkg_API->indexrecords_type)
-# define PyMetaIndex_Type *(_PyAptPkg_API->metaindex_type)
-# define PyPackage_Type *(_PyAptPkg_API->package_type)
-# define PyPackageFile_Type *(_PyAptPkg_API->packagefile_type)
-# define PyIndexFile_Type *(_PyAptPkg_API->packageindexfile_type)
-# define PyPackageList_Type *(_PyAptPkg_API->packagelist_type)
-# define PyPackageManager_Type *(_PyAptPkg_API->packagemanager_type)
-# define PyPackageRecords_Type *(_PyAptPkg_API->packagerecords_type)
-# define PyPolicy_Type *(_PyAptPkg_API->policy_type)
-# define PyProblemResolver_Type *(_PyAptPkg_API->problemresolver_type)
-# define PySourceList_Type *(_PyAptPkg_API->sourcelist_type)
-# define PySourceRecords_Type *(_PyAptPkg_API->sourcerecords_type)
-# define PyTagFile_Type *(_PyAptPkg_API->tagfile_type)
-# define PyTagSection_Type *(_PyAptPkg_API->tagsection_type)
-# define PyVersion_Type *(_PyAptPkg_API->version_type)
-
-// Creating
-
-static struct _PyAptPkgAPIStruct *_PyAptPkg_API;
-
-static int import_apt_pkg(void) {
-# if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1
- _PyAptPkg_API = (_PyAptPkgAPIStruct *)PyCapsule_Import("apt_pkg._C_API", 0);
- return (_PyAptPkg_API != NULL) ? 0 : -1;
-# else
-
- PyObject *module = PyImport_ImportModule("apt_pkg");
-
- if (module == NULL) {
- return -1;
- }
- if (module != NULL) {
- PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API");
- if (c_api_object == NULL)
- return -1;
- if (PyCObject_Check(c_api_object))
- _PyAptPkg_API = (struct _PyAptPkgAPIStruct *)PyCObject_AsVoidPtr(c_api_object);
- Py_DECREF(c_api_object);
- }
- return 0;
-# endif // PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1
-}
-# endif // APT_PKGMODULE_H
-
// Checking macros.
# define PyAcquire_Check(op) PyObject_TypeCheck(op, &PyAcquire_Type)
# define PyAcquireFile_Check(op) PyObject_TypeCheck(op, &PyAcquireFile_Type)
@@ -141,7 +158,7 @@ static int import_apt_pkg(void) {
# define PyMetaIndex_Check(op) PyObject_TypeCheck(op, &PyMetaIndex_Type)
# define PyPackage_Check(op) PyObject_TypeCheck(op, &PyPackage_Type)
# define PyPackageFile_Check(op) PyObject_TypeCheck(op, &PyPackageFile_Type)
-# define PyIndexFile_Check(op) PyObject_TypeCheck(op, &PyIndexFile_Type)
+# define PyIndexFile_Check(op) PyObject_TypeCheck(op, &PyIndexFile_Type)
# define PyPackageList_Check(op) PyObject_TypeCheck(op, &PyPackageList_Type)
# define PyPackageManager_Check(op) PyObject_TypeCheck(op, &PyPackageManager_Type)
# define PyPackageRecords_Check(op) PyObject_TypeCheck(op, &PyPackageRecords_Type)
@@ -173,7 +190,7 @@ static int import_apt_pkg(void) {
# define PyMetaIndex_CheckExact(op) (op->op_type == &PyMetaIndex_Type)
# define PyPackage_CheckExact(op) (op->op_type == &PyPackage_Type)
# define PyPackageFile_CheckExact(op) (op->op_type == &PyPackageFile_Type)
-# define PyIndexFile_CheckExact(op) (op->op_type == &PyIndexFile_Type)
+# define PyIndexFile_CheckExact(op) (op->op_type == &PyIndexFile_Type)
# define PyPackageList_CheckExact(op) (op->op_type == &PyPackageList_Type)
# define PyPackageManager_CheckExact(op) (op->op_type == &PyPackageManager_Type)
# define PyPackageRecords_CheckExact(op) (op->op_type == &PyPackageRecords_Type)
@@ -185,38 +202,98 @@ static int import_apt_pkg(void) {
# define PyTagSection_CheckExact(op) (op->op_type == &PyTagSection_Type)
# define PyVersion_CheckExact(op) (op->op_type == &PyVersion_Type)
-// Get the underlying C++ reference or pointer from the Python object.
-# define PyAcquire_ToCpp GetCpp<pkgAcquire*>
-# define PyAcquireFile_ToCpp GetCpp<pkgAcqFile*>
-# define PyAcquireItem_ToCpp GetCpp<pkgAcquire::Item*>
-# define PyAcquireItemDesc_ToCpp GetCpp<pkgAcquire::ItemDesc*>
-# define PyAcquireWorker_ToCpp GetCpp<pkgAcquire::Worker*>
-# define PyActionGroup_ToCpp GetCpp<pkgDepCache::ActionGroup*>
-# define PyCache_ToCpp GetCpp<pkgCache*>
-# define PyCacheFile_ToCpp GetCpp<pkgCacheFile*>
-# define PyCdrom_ToCpp GetCpp<pkgCdrom>
-# define PyConfiguration_ToCpp GetCpp<Configuration*>
-# define PyDepCache_ToCpp GetCpp<pkgDepCache*>
-# define PyDependency_ToCpp GetCpp<pkgCache::DepIterator>
-//# define PyDependencyList_ToCpp GetCpp<RDepListStruct> // NOT EXPORTED
-# define PyDescription_ToCpp GetCpp<pkgCache::DescIterator>
-# define PyHashes_ToCpp GetCpp<Hashes>
-# define PyHashString_ToCpp GetCpp<HashString*>
-# define PyIndexRecords_ToCpp GetCpp<indexRecords*>
-# define PyMetaIndex_ToCpp GetCpp<metaIndex*>
-# define PyPackage_ToCpp GetCpp<pkgCache::PkgIterator>
-# define PyPackageFile_ToCpp GetCpp<pkgCache::PkgFileIterator>
-# define PyIndexFile_ToCpp GetCpp<pkgIndexFile*>
-//# define PyPackageList_ToCpp GetCpp<PkgListStruct> // NOT EXPORTED.
-# define PyPackageManager_ToCpp GetCpp<pkgPackageManager*>
-//# define PyPackageRecords_ToCpp GetCpp<PkgRecordsStruct> // NOT EXPORTED
-# define PyPolicy_ToCpp GetCpp<pkgPolicy*>
-# define PyProblemResolver_ToCpp GetCpp<pkgProblemResolver*>
-# define PySourceList_ToCpp GetCpp<pkgSourceList*>
-//# define PySourceRecords_ToCpp GetCpp<PkgSrcRecordsStruct> // NOT EXPORTED
-# define PyTagFile_ToCpp GetCpp<pkgTagFile>
-# define PyTagSection_ToCpp GetCpp<pkgTagSection>
-# define PyVersion_ToCpp GetCpp<pkgCache::VerIterator>
+# ifndef APT_PKGMODULE_H
+static struct _PyAptPkgAPIStruct *_PyAptPkg_API;
+
+static int import_apt_pkg(void) {
+# if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1
+ _PyAptPkg_API = (_PyAptPkgAPIStruct *)PyCapsule_Import("apt_pkg._C_API", 0);
+ return (_PyAptPkg_API != NULL) ? 0 : -1;
+# else
+
+ PyObject *module = PyImport_ImportModule("apt_pkg");
+
+ if (module == NULL) {
+ return -1;
+ }
+ if (module != NULL) {
+ PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API");
+ if (c_api_object == NULL)
+ return -1;
+ if (PyCObject_Check(c_api_object))
+ _PyAptPkg_API = (struct _PyAptPkgAPIStruct *)PyCObject_AsVoidPtr(c_api_object);
+ Py_DECREF(c_api_object);
+ }
+ return 0;
+# endif // PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1
+}
+
+# define PyAcquire_Type *(_PyAptPkg_API->acquire_type)
+# define PyAcquireFile_Type *(_PyAptPkg_API->acquirefile_type)
+# define PyAcquireItem_Type *(_PyAptPkg_API->acquireitem_type)
+# define PyAcquireItemDesc_Type *(_PyAptPkg_API->acquireitemdesc_type)
+# define PyAcquireWorker_Type *(_PyAptPkg_API->acquireworker_type)
+# define PyActionGroup_Type *(_PyAptPkg_API->actiongroup_type)
+# define PyCache_Type *(_PyAptPkg_API->cache_type)
+# define PyCacheFile_Type *(_PyAptPkg_API->cachefile_type)
+# define PyCdrom_Type *(_PyAptPkg_API->cdrom_type)
+# define PyConfiguration_Type *(_PyAptPkg_API->configuration_type)
+# define PyDepCache_Type *(_PyAptPkg_API->depcache_type)
+# define PyDependency_Type *(_PyAptPkg_API->dependency_type)
+# define PyDependencyList_Type *(_PyAptPkg_API->dependencylist_type)
+# define PyDescription_Type *(_PyAptPkg_API->description_type)
+# define PyHashes_Type *(_PyAptPkg_API->hashes_type)
+# define PyHashString_Type *(_PyAptPkg_API->hashstring_type)
+# define PyIndexRecords_Type *(_PyAptPkg_API->indexrecords_type)
+# define PyMetaIndex_Type *(_PyAptPkg_API->metaindex_type)
+# define PyPackage_Type *(_PyAptPkg_API->package_type)
+# define PyPackageFile_Type *(_PyAptPkg_API->packagefile_type)
+# define PyIndexFile_Type *(_PyAptPkg_API->packageindexfile_type)
+# define PyPackageList_Type *(_PyAptPkg_API->packagelist_type)
+# define PyPackageManager_Type *(_PyAptPkg_API->packagemanager_type)
+# define PyPackageRecords_Type *(_PyAptPkg_API->packagerecords_type)
+# define PyPolicy_Type *(_PyAptPkg_API->policy_type)
+# define PyProblemResolver_Type *(_PyAptPkg_API->problemresolver_type)
+# define PySourceList_Type *(_PyAptPkg_API->sourcelist_type)
+# define PySourceRecords_Type *(_PyAptPkg_API->sourcerecords_type)
+# define PyTagFile_Type *(_PyAptPkg_API->tagfile_type)
+# define PyTagSection_Type *(_PyAptPkg_API->tagsection_type)
+# define PyVersion_Type *(_PyAptPkg_API->version_type)
+// Code
+# define PyAcquire_ToCpp _PyAptPkg_API->acquire_tocpp
+# define PyAcquireFile_ToCpp _PyAptPkg_API->acquirefile_tocpp
+# define PyAcquireItem_ToCpp _PyAptPkg_API->acquireitem_tocpp
+# define PyAcquireItemDesc_ToCpp _PyAptPkg_API->acquireitemdesc_tocpp
+# define PyAcquireWorker_ToCpp _PyAptPkg_API->acquireworker_tocpp
+# define PyActionGroup_ToCpp _PyAptPkg_API->actiongroup_tocpp
+# define PyCache_ToCpp _PyAptPkg_API->cache_tocpp
+# define PyCacheFile_ToCpp _PyAptPkg_API->cachefile_tocpp
+# define PyCdrom_ToCpp _PyAptPkg_API->cdrom_tocpp
+# define PyConfiguration_ToCpp _PyAptPkg_API->configuration_tocpp
+# define PyDepCache_ToCpp _PyAptPkg_API->depcache_tocpp
+# define PyDependency_ToCpp _PyAptPkg_API->dependency_tocpp
+# define PyDependencyList_ToCpp _PyAptPkg_API->dependencylist_tocpp // NULL
+# define PyDescription_ToCpp _PyAptPkg_API->description_tocpp
+# define PyHashes_ToCpp _PyAptPkg_API->hashes_tocpp
+# define PyHashString_ToCpp _PyAptPkg_API->hashstring_tocpp
+# define PyIndexRecords_ToCpp _PyAptPkg_API->indexrecords_tocpp
+# define PyMetaIndex_ToCpp _PyAptPkg_API->metaindex_tocpp
+# define PyPackage_ToCpp _PyAptPkg_API->package_tocpp
+# define PyPackageFile_ToCpp _PyAptPkg_API->packagefile_tocpp
+# define PyIndexFile_ToCpp _PyAptPkg_API->packageindexfile_tocpp
+# define PyPackageList_ToCpp _PyAptPkg_API->packagelist_tocpp // NULL
+# define PyPackageManager_ToCpp _PyAptPkg_API->packagemanager_tocpp
+# define PyPackageRecords_ToCpp _PyAptPkg_API->packagerecords_tocpp
+# define PyPolicy_ToCpp _PyAptPkg_API->policy_tocpp
+# define PyProblemResolver_ToCpp _PyAptPkg_API->problemresolver_tocpp
+# define PySourceList_ToCpp _PyAptPkg_API->sourcelist_tocpp
+# define PySourceRecords_ToCpp _PyAptPkg_API->sourcerecords_tocpp // NULL
+# define PyTagFile_ToCpp _PyAptPkg_API->tagfile_tocpp
+# define PyTagSection_ToCpp _PyAptPkg_API->tagsection_tocpp
+# define PyVersion_ToCpp _PyAptPkg_API->version_tocpp
+// Get the C++ object
+# define PyAcquire_FromCpp _PyAptPkg_API->acquire_fromcpp
+# endif // APT_PKGMODULE_H
// Template using a simpler version of from cpp
template<class Cpp>
@@ -227,9 +304,7 @@ inline CppPyObject<Cpp> *FromCpp(PyTypeObject *pytype, Cpp const &obj, bool Dele
return Obj;
}
-# ifndef APT_PKGMODULE_H
-# define PyAcquire_FromCpp _PyAptPkg_API->acquire_fromcpp
-#endif
+
# define PyAcquireFile_FromCpp(...) FromCpp<pkgAcqFile*>(&PyAcquireFile_Type, ##__VA_ARGS__)
# define PyAcquireItem_FromCpp(...) FromCpp<pkgAcquire::Item*>(&PyAcquireItem_Type,##__VA_ARGS__)
# define PyAcquireItemDesc_FromCpp(...) FromCpp<pkgAcquire::ItemDesc*>(&PyAcquireItemDesc_Type,##__VA_ARGS__)
@@ -261,3 +336,4 @@ inline CppPyObject<Cpp> *FromCpp(PyTypeObject *pytype, Cpp const &obj, bool Dele
# define PyTagSection_FromCpp(...) FromCpp<pkgTagSection>(&PyTagSection_Type,##__VA_ARGS__)
# define PyVersion_FromCpp(...) FromCpp<pkgCache::VerIterator>(&PyVersion_Type,##__VA_ARGS__)
#endif
+