summaryrefslogtreecommitdiff
path: root/swig/zypp.i
blob: 53b781da0bc0226e1d7325e78c97bb5c58771001 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
%module zypp

/* set this to 0 (zero) to only create a subset of the bindings
 * for testing
 */
#define PRODUCTION 1

#ifdef SWIGPERL5
%{
   #undef NORMAL
   #undef readdir
   #undef Fflush
   #undef Mkdir
   #undef strerror
%}
#endif

// stuff swig seems to be unable to parse
#define BOOST_NOEXCEPT
#define BOOST_NO_CXX11_NOEXCEPT
#define BOOST_NO_CXX11_RVALUE_REFERENCES
#define BOOST_NO_CXX11_SMART_PTR
#define constexpr

%{
/* Includes the header in the wrapper code */
#ifdef SWIGRUBY
#define REG_EXTENDED 1
#define REG_ICASE (REG_EXTENDED << 1)
#define REG_NEWLINE (REG_ICASE << 1)
#define REG_NOSUB (REG_NEWLINE << 1)
#endif

/*
 * type definitions to keep the C code generic
 */

#if defined(SWIGPYTHON)
#define Target_Null_p(x) (x == Py_None)
#define Target_INCREF(x) Py_INCREF(x)
#define Target_DECREF(x) Py_DECREF(x)
#define Target_True Py_True
#define Target_False Py_False
#define Target_Null Py_None
#define Target_Type PyObject*
#define Target_Bool(x) PyBool_FromLong(x)
#define Target_WChar(x) PyInt_FromLong(x)
#define Target_Int(x) PyInt_FromLong(x)
#define Target_String(x) PyString_FromString(x)
#define Target_Real(x) Py_None
#define Target_Array() PyList_New(0)
#define Target_SizedArray(len) PyList_New(len)
#define Target_Append(x,y) PyList_Append(x,y)
#define Target_DateTime(x) Py_None
#include <Python.h>
#define TARGET_THREAD_BEGIN_BLOCK SWIG_PYTHON_THREAD_BEGIN_BLOCK
#define TARGET_THREAD_END_BLOCK SWIG_PYTHON_THREAD_END_BLOCK
#define TARGET_THREAD_BEGIN_ALLOW SWIG_PYTHON_THREAD_BEGIN_ALLOW
#define TARGET_THREAD_END_ALLOW SWIG_PYTHON_THREAD_END_ALLOW
#endif

#if defined(SWIGRUBY)
#define Target_Null_p(x) NIL_P(x)
#define Target_INCREF(x)
#define Target_DECREF(x)
#define Target_True Qtrue
#define Target_False Qfalse
#define Target_Null Qnil
#define Target_Type VALUE
#define Target_Bool(x) ((x)?Qtrue:Qfalse)
#define Target_WChar(x) INT2FIX(x)
#define Target_Int(x) INT2FIX(x)
#define Target_String(x) rb_str_new2(x)
#define Target_Real(x) rb_float_new(x)
#define Target_Array() rb_ary_new()
#define Target_SizedArray(len) rb_ary_new2(len)
#define Target_Append(x,y) rb_ary_push(x,y)
#define Target_DateTime(x) Qnil
#define TARGET_THREAD_BEGIN_BLOCK do {} while(0)
#define TARGET_THREAD_END_BLOCK do {} while(0)
#define TARGET_THREAD_BEGIN_ALLOW do {} while(0)
#define TARGET_THREAD_END_ALLOW do {} while(0)
#include <ruby.h>
#endif

#if defined(SWIGPERL)
#define TARGET_THREAD_BEGIN_BLOCK do {} while(0)
#define TARGET_THREAD_END_BLOCK do {} while(0)
#define TARGET_THREAD_BEGIN_ALLOW do {} while(0)
#define TARGET_THREAD_END_ALLOW do {} while(0)

SWIGINTERNINLINE SV *SWIG_From_long  SWIG_PERL_DECL_ARGS_1(long value);
SWIGINTERNINLINE SV *SWIG_FromCharPtr(const char *cptr);
SWIGINTERNINLINE SV *SWIG_From_double  SWIG_PERL_DECL_ARGS_1(double value);

#define Target_Null_p(x) (x == NULL)
#define Target_INCREF(x)
#define Target_DECREF(x)
#define Target_True (&PL_sv_yes)
#define Target_False (&PL_sv_no)
#define Target_Null NULL
#define Target_Type SV *
#define Target_Bool(x) (x)?Target_True:Target_False
#define Target_WChar(x) NULL
#define Target_Int(x) SWIG_From_long(x)
#define Target_String(x) SWIG_FromCharPtr(x)
#define Target_Real(x) SWIG_From_double(x)
#define Target_Array() (SV *)newAV()
#define Target_SizedArray(len) (SV *)newAV()
#define Target_Append(x,y) av_push(((AV *)(x)), y)
#define Target_DateTime(x) NULL
#include <perl.h>
#include <EXTERN.h>
#endif


#include <sstream>
#undef seed // don't know where it comes from, but it conflicts with <random>
#include "zypp/base/PtrTypes.h"
#include "zypp/base/ReferenceCounted.h"
#include "zypp/Edition.h"
#include "zypp/Pathname.h"
#include "zypp/ResTraits.h"
#include "zypp/ZYppFactory.h"
#include "zypp/ZYpp.h"

#include "zypp/ResObjects.h"
#include "zypp/Target.h"
#include "zypp/target/TargetImpl.h"
#include "zypp/MediaSetAccess.h"
#include "zypp/ResFilters.h"
#include "zypp/OnMediaLocation.h"
#include "zypp/Repository.h"
#include "zypp/ServiceInfo.h"
#include "zypp/RepoManager.h"
#include "zypp/repo/RepoType.h"
#include "zypp/repo/PackageProvider.h"
#include "zypp/TmpPath.h"
#include "zypp/Resolver.h"
#include "legacy/GetResolvablesToInsDel.h"

#include "zypp/Product.h"

using namespace boost;
using namespace zypp;
using namespace zypp::repo;
using namespace zypp::resfilter;
using namespace zypp::filesystem;

typedef std::list<std::string> StringList;

%}

/* prevent swig from creating a type called 'Target_Type' */
#if defined(SWIGRUBY)
#define Target_Type VALUE
#endif
#if defined(SWIGPYTHON)
#define Target_Type PyObject*
#endif
#if defined(SWIGPERL)
#define Target_Type SV *
#endif

#ifdef SWIGRUBY
%include "ruby/std_list.i"
%include "ruby/std_set.i"
%include "ruby/ruby.i"
#endif

#ifdef SWIGPYTHON
%include "std_list.i"
%include "std_set.i"
%include "python/python.i"
#endif

#ifdef SWIGPERL5
%include "std_list.i"
%include "perl5/perl.i"
#endif

#define VERSION ZYPP_VERSION

/* These include files are pending to be cleaned up from C++ cruft */
#if PRODUCTION /* set 0 for testing, these files still carry the full C++ cruft */

%nodefault ByKind;

%rename("+") "operator+";
%rename("<<") "operator<<";
%rename("!=") "operator!=";
%rename("!") "operator!";
%rename("==") "operator==";

namespace zypp {
  namespace base {
    // silence 'Nothing known about class..' warning
    class  ReferenceCounted {};
  }
}

%include "std_string.i"
%include "stl.i"

#ifdef BOOST_SMARTPTR_INCLUDE_DIR
%import <boost/smart_ptr/scoped_ptr.hpp>
%import <boost/smart_ptr/shared_ptr.hpp>
%import <boost/smart_ptr/weak_ptr.hpp>
%import <boost/smart_ptr/intrusive_ptr.hpp>
#else
%import <boost/scoped_ptr.hpp>
%import <boost/shared_ptr.hpp>
%import <boost/weak_ptr.hpp>
%import <boost/intrusive_ptr.hpp>
#endif
%import <zypp/base/PtrTypes.h>
%import <zypp/base/Flags.h>

%include "IdStringType.i"
%include "Pathname.i"
%include "ByteCount.i"
%include "Url.i"
%include "NeedAType.i"
%include "Edition.i"
%include "Kind.i"
%include "CheckSum.i"
%include "Date.i"
%include "Changelog.i"
%include "Dep.i"
%include "Capability.i"
%include "Capabilities.i"
%include "CapMatch.i"
%include "OnMediaLocation.i"
%include "Resolvable.i"
%include "RepoType.i"
%include "RepoInfo.i"
%include "Repository.i"
%include "ServiceInfo.i"
%include "ResTraits.i"
%include "ResStatus.i"
%include "ResObject.i"
%include "VendorSupportOptions.i"
%include "Package.i"
%include "PackageProvider.i"
%include "Patch.i"
%include "Pattern.i"
%include "Product.i"
%include "SrcPackage.i"
%include "RepoStatus.i"
%include "RepoManager.i"
%include "PublicKey.i"
%include "KeyRing.i"
%include "Target.i"
%include "MediaSetAccess.i"
%include "PoolItem.i"
%include "ResPool.i"
%include "ZYppCommitPolicy.i"
%include "ZYppCommitResult.i"
%include "TmpPath.i"
%include "Resolver.i"
%include "ZConfig.i"

//just simple files, where we need default ctor
%include <zypp/repo/RepoProvideFile.h>
%include <zypp/repo/DeltaCandidates.h>

%ignore zypp::ZYpp::setTextLocale;
%ignore zypp::ZYpp::getTextLocale;
%ignore zypp::ZYpp::setRequestedLocales;
%ignore zypp::ZYpp::getRequestedLocales;
%ignore zypp::ZYpp::getAvailableLocales;
%ignore zypp::ZYpp::architecture;
%ignore zypp::ZYpp::setArchitecture;
%ignore zypp::ZYpp::applyLocks;

%include <zypp/ZYpp.h>

%include "ZYppFactory.i"
#endif

%include "Arch.i"
%include "Callbacks.i"

//
// helper
//
%{
#include <zypp/base/LogControl.h>
%}
%inline %{
  namespace zypp
  {
    void setZyppLogfile( const std::string & file_r )
    {
      base::LogControl::instance().logfile( file_r );
    }
  }
%}