Tizen 2.1 base
[external/libzypp-bindings.git] / swig / zypp.i
1 %module zypp
2
3 /* set this to 0 (zero) to only create a subset of the bindings
4  * for testing
5  */
6 #define PRODUCTION 1
7
8 #ifdef SWIGPERL5
9 %{
10    #undef NORMAL
11    #undef readdir
12    #undef Fflush
13    #undef Mkdir
14    #undef strerror
15 %}
16 #endif
17
18 %{
19 /* Includes the header in the wrapper code */
20 #ifdef SWIGRUBY
21 #define REG_EXTENDED 1
22 #define REG_ICASE (REG_EXTENDED << 1)
23 #define REG_NEWLINE (REG_ICASE << 1)
24 #define REG_NOSUB (REG_NEWLINE << 1)
25 #endif
26
27 /*
28  * type definitions to keep the C code generic
29  */
30  
31 #if defined(SWIGPYTHON)
32 #define Target_Null_p(x) (x == Py_None)
33 #define Target_INCREF(x) Py_INCREF(x)
34 #define Target_DECREF(x) Py_DECREF(x)
35 #define Target_True Py_True
36 #define Target_False Py_False
37 #define Target_Null Py_None
38 #define Target_Type PyObject*
39 #define Target_Bool(x) PyBool_FromLong(x)
40 #define Target_WChar(x) PyInt_FromLong(x)
41 #define Target_Int(x) PyInt_FromLong(x)
42 #define Target_String(x) PyString_FromString(x)
43 #define Target_Real(x) Py_None
44 #define Target_Array() PyList_New(0)
45 #define Target_SizedArray(len) PyList_New(len)
46 #define Target_Append(x,y) PyList_Append(x,y)
47 #define Target_DateTime(x) Py_None
48 #include <Python.h>
49 #define TARGET_THREAD_BEGIN_BLOCK SWIG_PYTHON_THREAD_BEGIN_BLOCK
50 #define TARGET_THREAD_END_BLOCK SWIG_PYTHON_THREAD_END_BLOCK
51 #define TARGET_THREAD_BEGIN_ALLOW SWIG_PYTHON_THREAD_BEGIN_ALLOW
52 #define TARGET_THREAD_END_ALLOW SWIG_PYTHON_THREAD_END_ALLOW
53 #endif
54
55 #if defined(SWIGRUBY)
56 #define Target_Null_p(x) NIL_P(x)
57 #define Target_INCREF(x) 
58 #define Target_DECREF(x) 
59 #define Target_True Qtrue
60 #define Target_False Qfalse
61 #define Target_Null Qnil
62 #define Target_Type VALUE
63 #define Target_Bool(x) ((x)?Qtrue:Qfalse)
64 #define Target_WChar(x) INT2FIX(x)
65 #define Target_Int(x) INT2FIX(x)
66 #define Target_String(x) rb_str_new2(x)
67 #define Target_Real(x) rb_float_new(x)
68 #define Target_Array() rb_ary_new()
69 #define Target_SizedArray(len) rb_ary_new2(len)
70 #define Target_Append(x,y) rb_ary_push(x,y)
71 #define Target_DateTime(x) Qnil
72 #define TARGET_THREAD_BEGIN_BLOCK do {} while(0)
73 #define TARGET_THREAD_END_BLOCK do {} while(0)
74 #define TARGET_THREAD_BEGIN_ALLOW do {} while(0)
75 #define TARGET_THREAD_END_ALLOW do {} while(0)
76 #include <ruby.h>
77 #include <rubyio.h>
78 #endif
79
80 #if defined(SWIGPERL)
81 #define TARGET_THREAD_BEGIN_BLOCK do {} while(0)
82 #define TARGET_THREAD_END_BLOCK do {} while(0)
83 #define TARGET_THREAD_BEGIN_ALLOW do {} while(0)
84 #define TARGET_THREAD_END_ALLOW do {} while(0)
85
86 SWIGINTERNINLINE SV *SWIG_From_long  SWIG_PERL_DECL_ARGS_1(long value);
87 SWIGINTERNINLINE SV *SWIG_FromCharPtr(const char *cptr);
88 SWIGINTERNINLINE SV *SWIG_From_double  SWIG_PERL_DECL_ARGS_1(double value);
89
90 #define Target_Null_p(x) (x == NULL)
91 #define Target_INCREF(x) 
92 #define Target_DECREF(x) 
93 #define Target_True (&PL_sv_yes)
94 #define Target_False (&PL_sv_no)
95 #define Target_Null NULL
96 #define Target_Type SV *
97 #define Target_Bool(x) (x)?Target_True:Target_False
98 #define Target_WChar(x) NULL
99 #define Target_Int(x) SWIG_From_long(x)
100 #define Target_String(x) SWIG_FromCharPtr(x)
101 #define Target_Real(x) SWIG_From_double(x)
102 #define Target_Array() (SV *)newAV()
103 #define Target_SizedArray(len) (SV *)newAV()
104 #define Target_Append(x,y) av_push(((AV *)(x)), y)
105 #define Target_DateTime(x) NULL
106 #include <perl.h>
107 #include <EXTERN.h>
108 #endif
109
110
111 #include <sstream>
112 #include "zypp/base/PtrTypes.h"
113 #include "zypp/base/ReferenceCounted.h"
114 #include "zypp/Edition.h"
115 #include "zypp/Pathname.h"
116 #include "zypp/ResTraits.h"
117 #include "zypp/ZYppFactory.h"
118 #include "zypp/ZYpp.h"
119
120 #include "zypp/ResObjects.h"
121 #include "zypp/Target.h"
122 #include "zypp/target/TargetImpl.h"
123 #include "zypp/MediaSetAccess.h"
124 #include "zypp/ResFilters.h"
125 #include "zypp/OnMediaLocation.h"
126 #include "zypp/Repository.h"
127 #include "zypp/ServiceInfo.h"
128 #include "zypp/RepoManager.h"
129 #include "zypp/repo/RepoType.h"
130 #include "zypp/TmpPath.h"
131 #include "zypp/Resolver.h"
132 #include "zypp/pool/GetResolvablesToInsDel.h"
133
134 #include "zypp/Product.h"
135
136 using namespace boost;
137 using namespace zypp;
138 using namespace zypp::repo;
139 using namespace zypp::resfilter;
140 using namespace zypp::filesystem;
141
142 typedef std::list<std::string> StringList;
143
144 %}
145
146 /* prevent swig from creating a type called 'Target_Type' */
147 #if defined(SWIGRUBY)
148 #define Target_Type VALUE
149 #endif
150 #if defined(SWIGPYTHON)
151 #define Target_Type PyObject*
152 #endif
153 #if defined(SWIGPERL)
154 #define Target_Type SV *
155 #endif
156
157 #ifdef SWIGRUBY
158 %include "ruby/std_list.i"
159 %include "ruby/std_set.i"
160 %include "ruby/ruby.i"
161 #endif
162
163 #ifdef SWIGPYTHON
164 %include "std_list.i"
165 %include "std_set.i"
166 %include "python/python.i"
167 #endif
168
169 #ifdef SWIGPERL5
170 %include "std_list.i"
171 %include "perl5/perl.i"
172 #endif
173
174 #define VERSION ZYPP_VERSION
175
176 /* These include files are pending to be cleaned up from C++ cruft */
177 #if PRODUCTION /* set 0 for testing, these files still carry the full C++ cruft */
178
179 %nodefault ByKind;
180
181 %rename("+") "operator+";
182 %rename("<<") "operator<<";
183 %rename("!=") "operator!=";
184 %rename("!") "operator!";
185 %rename("==") "operator==";
186
187 namespace zypp {
188   namespace base {
189     // silence 'Nothing known about class..' warning
190     class  ReferenceCounted {};
191   }
192 }
193
194 %include "std_string.i"
195 %include "stl.i"
196
197 #ifdef BOOST_SMARTPTR_INCLUDE_DIR
198 %import <boost/smart_ptr/scoped_ptr.hpp>
199 %import <boost/smart_ptr/shared_ptr.hpp>
200 %import <boost/smart_ptr/weak_ptr.hpp>
201 %import <boost/smart_ptr/intrusive_ptr.hpp>
202 #else
203 %import <boost/scoped_ptr.hpp>
204 %import <boost/shared_ptr.hpp>
205 %import <boost/weak_ptr.hpp>
206 %import <boost/intrusive_ptr.hpp>
207 #endif
208 %import <zypp/base/PtrTypes.h>
209 %import <zypp/base/Flags.h>
210
211 %include "IdStringType.i"
212 %include "Pathname.i"
213 %include "ByteCount.i"
214 %include "Url.i"
215 %include "NeedAType.i"
216 %include "Edition.i"
217 %include "Kind.i"
218 %include "CheckSum.i"
219 %include "Date.i"
220 %include "Dep.i"
221 %include "Capability.i"
222 %include "Capabilities.i"
223 %include "CapMatch.i"
224 %include "OnMediaLocation.i"
225 %include "Resolvable.i"
226 %include "RepoType.i"
227 %include "RepoInfo.i"
228 %include "ServiceInfo.i"
229 %include "ResTraits.i"
230 %include "ResStatus.i"
231 %include "ResObject.i"
232 %include "Package.i"
233 %include "Patch.i"
234 %include "Pattern.i"
235 %include "Product.i"
236 %include "SrcPackage.i"
237 %include "Repository.i"
238 %include "RepoStatus.i"
239 %include "RepoManager.i"
240 %include "PublicKey.i"
241 %include "KeyRing.i"
242 %include "Target.i"
243 %include "MediaSetAccess.i"
244 %include "PoolItem.i"
245 %include "ResPool.i"
246 %include "ZYppCommitPolicy.i"
247 %include "ZYppCommitResult.i"
248 %include "TmpPath.i"
249 %include "Resolver.i"
250 %include "ZConfig.i"
251
252 %ignore zypp::ZYpp::setTextLocale;
253 %ignore zypp::ZYpp::getTextLocale;
254 %ignore zypp::ZYpp::setRequestedLocales;
255 %ignore zypp::ZYpp::getRequestedLocales;
256 %ignore zypp::ZYpp::getAvailableLocales;
257 %ignore zypp::ZYpp::architecture;
258 %ignore zypp::ZYpp::setArchitecture;
259 %ignore zypp::ZYpp::applyLocks;
260
261 %include <zypp/ZYpp.h>
262
263 %include "ZYppFactory.i"
264 #endif
265
266 %include "Arch.i"
267 %include "Callbacks.i"
268
269 //
270 // helper
271 //
272 %{
273 #include <zypp/base/LogControl.h>
274 %}
275 %inline %{
276   namespace zypp
277   {
278     void setZyppLogfile( const std::string & file_r )
279     {
280       base::LogControl::instance().logfile( file_r );
281     }
282   }
283 %}