1 /* libcomps - C alternative to yum.comps library
2  * Copyright (C) 2013 Jindrich Luza
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to  Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
17  * USA
18  */
19 
20 #ifndef PYCOMPS_TYPES_H
21 #define PYCOMPS_TYPES_H
22 
23 #include "libcomps/comps_objlist.h"
24 #include "libcomps/comps_objdict.h"
25 
26 typedef COMPS_Object* (*PyCOMPS_in_itemconvert)(PyObject*);
27 typedef PyObject* (*PyCOMPS_out_itemconvert)(COMPS_Object*);
28 
29 typedef struct PyCOMPS_ItemInfo {
30     PyTypeObject ** itemtypes;
31     PyCOMPS_in_itemconvert *in_convert_funcs;
32     PyCOMPS_out_itemconvert out_convert_func;
33     int (*pre_checker)(COMPS_Object*);
34     unsigned item_types_len;
35     size_t props_offset;
36 } PyCOMPS_ItemInfo;
37 
38 typedef struct PyCOMPS_Sequence {
39     PyObject_HEAD
40     COMPS_ObjList *list;
41     PyCOMPS_ItemInfo *it_info;
42 } PyCOMPS_Sequence;
43 
44 typedef struct PyCOMPS_SeqIter{
45     PyObject_HEAD
46     COMPS_ObjListIt *it;
47     PyCOMPS_Sequence *seq;
48 } PyCOMPS_SeqIter;
49 
50 typedef struct PyCOMPS_Dict {
51     PyObject_HEAD
52     COMPS_ObjDict *dict;
53     PyCOMPS_ItemInfo *it_info;
54 } PyCOMPS_Dict;
55 
56 typedef struct PyCOMPS_MDict {
57     PyObject_HEAD
58     COMPS_ObjMDict *dict;
59     PyCOMPS_ItemInfo *it_info;
60 } PyCOMPS_MDict;
61 
62 typedef struct PyCOMPS_DictIter{
63     PyObject_HEAD
64     COMPS_ObjListIt *it;
65     COMPS_HSListItem *hsit;
66     COMPS_ObjList *objlist;
67     COMPS_HSList *hslist;
68     PyObject* (*out_func)(COMPS_HSListItem *hsit);
69 } PyCOMPS_DictIter;
70 
71 typedef struct PyCOMPS_MDictIter{
72     PyObject_HEAD
73     COMPS_ObjListIt *it;
74     COMPS_HSListItem *hsit;
75     COMPS_ObjList *objlist;
76     COMPS_HSList *hslist;
77     PyObject* (*out_func)(COMPS_HSListItem *hsit);
78 } PyCOMPS_MDictIter;
79 
80 extern PyTypeObject PyCOMPS_GIDsType;
81 extern PyTypeObject PyCOMPS_GIDType;
82 
83 extern PyTypeObject PyCOMPS_SeqType;
84 extern PyTypeObject PyCOMPS_SeqIterType;
85 
86 extern PyTypeObject PyCOMPS_DictType;
87 extern PyTypeObject PyCOMPS_DictIterType;
88 
89 extern PyTypeObject PyCOMPS_MDictType;
90 extern PyTypeObject PyCOMPS_MDictIterType;
91 #endif
92