blob: fcd651969fabedeca499e0abd1ec6cc51fbebaa8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/** Base of ResTraits. Defines the Resolvable::Kind type. */
/*struct ResolvableTraits
{
typedef KindOf<Resolvable> KindType;
};*/
/** ResTraits. Defines common types and the Kind value. */
template<typename _Res>
struct ResTraits
{
typedef intrusive_ptr<_Res> PtrType;
typedef intrusive_ptr<const _Res> constPtrType;
};
%template(ResTraitsResolvable) ResTraits<Resolvable>;
%template(ResObject_constPtr) intrusive_ptr<const ResObject>;
%template(ResObject_Ptr) intrusive_ptr<ResObject>;
// Common definitions for all Resolvable types
// - *_Ptr and *_constPtr
// - isKind* to test whether a ResObject/PoolItem is
// of a specific kind.
// - asKind* to convert a ResObject/PoolItem into a
// specific *_constPtr.
%define %STUFF(X)
typedef intrusive_ptr<const X> X##_constPtr;
typedef intrusive_ptr<X> X##_Ptr;
%template(X##_constPtr) intrusive_ptr<const X>;
%template(X##_Ptr) intrusive_ptr<X>;
bool isKind##X( const Resolvable::constPtr & p );
bool isKind##X( const PoolItem & p );
X##_constPtr asKind##X( const Resolvable::constPtr & p );
X##_constPtr asKind##X( const PoolItem & p );
%header
{
inline bool isKind##X( const Resolvable::constPtr & p )
{ return isKind<X>( p ); }
inline bool isKind##X( const PoolItem & p )
{ return isKind<X>( p.resolvable() ); }
inline X::constPtr asKind##X( const Resolvable::constPtr & p )
{ return asKind<X>( p ); }
inline X::constPtr asKind##X( const PoolItem & p )
{ return asKind<X>( p.resolvable() ); }
}
#if defined(SWIGPYTHON)
%pythoncode
{
def KindOf##X():
return KindOfResolvable( #X )
}
#endif
%enddef
%STUFF(Package)
%STUFF(Patch)
%STUFF(SrcPackage)
%STUFF(Pattern)
%STUFF(Product)
|