Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: swig/Lib/python/pyinit.swg

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « swig/Lib/python/pyhead.swg ('k') | swig/Lib/python/pyiterators.swg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* ------------------------------------------------------------
2 * The start of the Python initialization function
3 * ------------------------------------------------------------ */
4
5 %insert(init) "swiginit.swg"
6
7 %init %{
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 /* Python-specific SWIG API */
14 #define SWIG_newvarlink() SWIG_Python_newvarlink()
15 #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
16 #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstan ts(d, constants)
17
18 /* -----------------------------------------------------------------------------
19 * global variable support code.
20 * ----------------------------------------------------------------------------- */
21
22 typedef struct swig_globalvar {
23 char *name; /* Name of global variable */
24 PyObject *(*get_attr)(void); /* Return the current value */
25 int (*set_attr)(PyObject *); /* Set the value */
26 struct swig_globalvar *next;
27 } swig_globalvar;
28
29 typedef struct swig_varlinkobject {
30 PyObject_HEAD
31 swig_globalvar *vars;
32 } swig_varlinkobject;
33
34 SWIGINTERN PyObject *
35 swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
36 #if PY_VERSION_HEX >= 0x03000000
37 return PyUnicode_InternFromString("<Swig global variables>");
38 #else
39 return PyString_FromString("<Swig global variables>");
40 #endif
41 }
42
43 SWIGINTERN PyObject *
44 swig_varlink_str(swig_varlinkobject *v) {
45 #if PY_VERSION_HEX >= 0x03000000
46 PyObject *str = PyUnicode_InternFromString("(");
47 PyObject *tail;
48 PyObject *joined;
49 swig_globalvar *var;
50 for (var = v->vars; var; var=var->next) {
51 tail = PyUnicode_FromString(var->name);
52 joined = PyUnicode_Concat(str, tail);
53 Py_DecRef(str);
54 Py_DecRef(tail);
55 str = joined;
56 if (var->next) {
57 tail = PyUnicode_InternFromString(", ");
58 joined = PyUnicode_Concat(str, tail);
59 Py_DecRef(str);
60 Py_DecRef(tail);
61 str = joined;
62 }
63 }
64 tail = PyUnicode_InternFromString(")");
65 joined = PyUnicode_Concat(str, tail);
66 Py_DecRef(str);
67 Py_DecRef(tail);
68 str = joined;
69 #else
70 PyObject *str = PyString_FromString("(");
71 swig_globalvar *var;
72 for (var = v->vars; var; var=var->next) {
73 PyString_ConcatAndDel(&str,PyString_FromString(var->name));
74 if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
75 }
76 PyString_ConcatAndDel(&str,PyString_FromString(")"));
77 #endif
78 return str;
79 }
80
81 SWIGINTERN int
82 swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
83 char *tmp;
84 PyObject *str = swig_varlink_str(v);
85 fprintf(fp,"Swig global variables ");
86 fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
87 SWIG_Python_str_DelForPy3(tmp);
88 Py_DECREF(str);
89 return 0;
90 }
91
92 SWIGINTERN void
93 swig_varlink_dealloc(swig_varlinkobject *v) {
94 swig_globalvar *var = v->vars;
95 while (var) {
96 swig_globalvar *n = var->next;
97 free(var->name);
98 free(var);
99 var = n;
100 }
101 }
102
103 SWIGINTERN PyObject *
104 swig_varlink_getattr(swig_varlinkobject *v, char *n) {
105 PyObject *res = NULL;
106 swig_globalvar *var = v->vars;
107 while (var) {
108 if (strcmp(var->name,n) == 0) {
109 res = (*var->get_attr)();
110 break;
111 }
112 var = var->next;
113 }
114 if (res == NULL && !PyErr_Occurred()) {
115 PyErr_SetString(PyExc_NameError,"Unknown C global variable");
116 }
117 return res;
118 }
119
120 SWIGINTERN int
121 swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
122 int res = 1;
123 swig_globalvar *var = v->vars;
124 while (var) {
125 if (strcmp(var->name,n) == 0) {
126 res = (*var->set_attr)(p);
127 break;
128 }
129 var = var->next;
130 }
131 if (res == 1 && !PyErr_Occurred()) {
132 PyErr_SetString(PyExc_NameError,"Unknown C global variable");
133 }
134 return res;
135 }
136
137 SWIGINTERN PyTypeObject*
138 swig_varlink_type(void) {
139 static char varlink__doc__[] = "Swig var link object";
140 static PyTypeObject varlink_type;
141 static int type_init = 0;
142 if (!type_init) {
143 const PyTypeObject tmp
144 = {
145 /* PyObject header changed in Python 3 */
146 #if PY_VERSION_HEX >= 0x03000000
147 PyVarObject_HEAD_INIT(&PyType_Type, 0)
148 #else
149 PyObject_HEAD_INIT(NULL)
150 0, /* Number of items in variable part (o b_size) */
151 #endif
152 (char *)"swigvarlink", /* Type name (tp_name) */
153 sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
154 0, /* Itemsize (tp_itemsize) */
155 (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
156 (printfunc) swig_varlink_print, /* Print (tp_print) */
157 (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
158 (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
159 0, /* tp_compare */
160 (reprfunc) swig_varlink_repr, /* tp_repr */
161 0, /* tp_as_number */
162 0, /* tp_as_sequence */
163 0, /* tp_as_mapping */
164 0, /* tp_hash */
165 0, /* tp_call */
166 (reprfunc) swig_varlink_str, /* tp_str */
167 0, /* tp_getattro */
168 0, /* tp_setattro */
169 0, /* tp_as_buffer */
170 0, /* tp_flags */
171 varlink__doc__, /* tp_doc */
172 0, /* tp_traverse */
173 0, /* tp_clear */
174 0, /* tp_richcompare */
175 0, /* tp_weaklistoffset */
176 #if PY_VERSION_HEX >= 0x02020000
177 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
178 #endif
179 #if PY_VERSION_HEX >= 0x02030000
180 0, /* tp_del */
181 #endif
182 #ifdef COUNT_ALLOCS
183 0,0,0,0 /* tp_alloc -> tp_next */
184 #endif
185 };
186 varlink_type = tmp;
187 /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
188 #if PY_VERSION_HEX < 0x03000000
189 varlink_type.ob_type = &PyType_Type;
190 #endif
191 type_init = 1;
192 }
193 return &varlink_type;
194 }
195
196 /* Create a variable linking object for use later */
197 SWIGINTERN PyObject *
198 SWIG_Python_newvarlink(void) {
199 swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_typ e());
200 if (result) {
201 result->vars = 0;
202 }
203 return ((PyObject*) result);
204 }
205
206 SWIGINTERN void
207 SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
208 swig_varlinkobject *v = (swig_varlinkobject *) p;
209 swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
210 if (gv) {
211 size_t size = strlen(name)+1;
212 gv->name = (char *)malloc(size);
213 if (gv->name) {
214 strncpy(gv->name,name,size);
215 gv->get_attr = get_attr;
216 gv->set_attr = set_attr;
217 gv->next = v->vars;
218 }
219 }
220 v->vars = gv;
221 }
222
223 SWIGINTERN PyObject *
224 SWIG_globals(void) {
225 static PyObject *_SWIG_globals = 0;
226 if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
227 return _SWIG_globals;
228 }
229
230 /* -----------------------------------------------------------------------------
231 * constants/methods manipulation
232 * ----------------------------------------------------------------------------- */
233
234 /* Install Constants */
235 SWIGINTERN void
236 SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
237 PyObject *obj = 0;
238 size_t i;
239 for (i = 0; constants[i].type; ++i) {
240 switch(constants[i].type) {
241 case SWIG_PY_POINTER:
242 obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
243 break;
244 case SWIG_PY_BINARY:
245 obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(consta nts[i].ptype));
246 break;
247 default:
248 obj = 0;
249 break;
250 }
251 if (obj) {
252 PyDict_SetItemString(d, constants[i].name, obj);
253 Py_DECREF(obj);
254 }
255 }
256 }
257
258 /* ----------------------------------------------------------------------------- */
259 /* Fix SwigMethods to carry the callback ptrs when needed */
260 /* ----------------------------------------------------------------------------- */
261
262 SWIGINTERN void
263 SWIG_Python_FixMethods(PyMethodDef *methods,
264 swig_const_info *const_table,
265 swig_type_info **types,
266 swig_type_info **types_initial) {
267 size_t i;
268 for (i = 0; methods[i].ml_name; ++i) {
269 const char *c = methods[i].ml_doc;
270 if (c && (c = strstr(c, "swig_ptr: "))) {
271 int j;
272 swig_const_info *ci = 0;
273 const char *name = c + 10;
274 for (j = 0; const_table[j].type; ++j) {
275 if (strncmp(const_table[j].name, name,
276 strlen(const_table[j].name)) == 0) {
277 ci = &(const_table[j]);
278 break;
279 }
280 }
281 if (ci) {
282 size_t shift = (ci->ptype) - types;
283 swig_type_info *ty = types_initial[shift];
284 size_t ldoc = (c - methods[i].ml_doc);
285 size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
286 char *ndoc = (char*)malloc(ldoc + lptr + 10);
287 if (ndoc) {
288 char *buff = ndoc;
289 void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
290 if (ptr) {
291 strncpy(buff, methods[i].ml_doc, ldoc);
292 buff += ldoc;
293 strncpy(buff, "swig_ptr: ", 10);
294 buff += 10;
295 SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
296 methods[i].ml_doc = ndoc;
297 }
298 }
299 }
300 }
301 }
302 }
303
304 #ifdef __cplusplus
305 }
306 #endif
307
308 /* ----------------------------------------------------------------------------- *
309 * Partial Init method
310 * ----------------------------------------------------------------------------- */
311
312 #ifdef __cplusplus
313 extern "C"
314 #endif
315
316 SWIGEXPORT
317 #if PY_VERSION_HEX >= 0x03000000
318 PyObject*
319 #else
320 void
321 #endif
322 SWIG_init(void) {
323 PyObject *m, *d;
324 #if PY_VERSION_HEX >= 0x03000000
325 static struct PyModuleDef SWIG_module = {
326 PyModuleDef_HEAD_INIT,
327 (char *) SWIG_name,
328 NULL,
329 -1,
330 SwigMethods,
331 NULL,
332 NULL,
333 NULL,
334 NULL
335 };
336 #endif
337
338 /* Fix SwigMethods to carry the callback ptrs when needed */
339 SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_in itial);
340
341 #if PY_VERSION_HEX >= 0x03000000
342 m = PyModule_Create(&SWIG_module);
343 #else
344 m = Py_InitModule((char *) SWIG_name, SwigMethods);
345 #endif
346 d = PyModule_GetDict(m);
347
348 SWIG_InitializeModule(0);
349 SWIG_InstallConstants(d,swig_const_table);
350
351 %}
352
OLDNEW
« no previous file with comments | « swig/Lib/python/pyhead.swg ('k') | swig/Lib/python/pyiterators.swg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698