~ubuntu-branches/ubuntu/edgy/swig1.3/edgy

« back to all changes in this revision

Viewing changes to Lib/python/pyrun.swg

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2005-01-10 09:48:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050110094852-axi555axhj1brbwq
Tags: 1.3.22-5ubuntu2
Build using python2.4 and pike7.6. Closes: #4146.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***********************************************************************
2
 
 * python.swg
 
2
 * pyrun.swg
3
3
 *
4
4
 *     This file contains the runtime support for Python modules
5
5
 *     and includes code for managing global variables and pointer
8
8
 * Author : David Beazley (beazley@cs.uchicago.edu)
9
9
 ************************************************************************/
10
10
 
11
 
#include "Python.h"
12
 
 
13
11
#ifdef __cplusplus
14
12
extern "C" {
15
13
#endif
45
43
  SWIG_Python_NewPointerObj(p, type, flags)
46
44
#define SWIG_MustGetPtr(p, type, argnum, flags) \
47
45
  SWIG_Python_MustGetPtr(p, type, argnum, flags)
48
 
 
 
46
 
49
47
/* Python-specific SWIG API */
50
48
#define SWIG_newvarlink() \
51
49
  SWIG_Python_newvarlink()
58
56
#define SWIG_InstallConstants(d, constants) \
59
57
  SWIG_Python_InstallConstants(d, constants)
60
58
 
 
59
typedef double (*py_objasdbl_conv)(PyObject *obj);
 
60
 
61
61
#ifdef SWIG_NOINCLUDE
62
62
 
63
63
SWIGIMPORT(int)               SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int);
69
69
SWIGIMPORT(PyObject *)        SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *);
70
70
SWIGIMPORT(void)              SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]);
71
71
 
 
72
 
72
73
#else
73
74
 
 
75
 
74
76
/* -----------------------------------------------------------------------------
75
77
 * global variable support code.
76
78
 * ----------------------------------------------------------------------------- */
134
136
 
135
137
statichere PyTypeObject varlinktype = {
136
138
  PyObject_HEAD_INIT(0)              
137
 
  0,
138
 
  (char *)"swigvarlink",              /* Type name    */
139
 
  sizeof(swig_varlinkobject),         /* Basic size   */
140
 
  0,                                  /* Itemsize     */
141
 
  0,                                  /* Deallocator  */ 
142
 
  (printfunc) swig_varlink_print,     /* Print        */
143
 
  (getattrfunc) swig_varlink_getattr, /* get attr     */
144
 
  (setattrfunc) swig_varlink_setattr, /* Set attr     */
145
 
  0,                                  /* tp_compare   */
146
 
  (reprfunc) swig_varlink_repr,       /* tp_repr      */    
 
139
  0,                                  /* Number of items in variable part (ob_size) */
 
140
  (char *)"swigvarlink",              /* Type name (tp_name) */
 
141
  sizeof(swig_varlinkobject),         /* Basic size (tp_basicsize) */
 
142
  0,                                  /* Itemsize (tp_itemsize) */
 
143
  0,                                  /* Deallocator (tp_dealloc) */ 
 
144
  (printfunc) swig_varlink_print,     /* Print (tp_print) */
 
145
  (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
 
146
  (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
 
147
  0,                                  /* tp_compare */
 
148
  (reprfunc) swig_varlink_repr,       /* tp_repr */
147
149
  0,                                  /* tp_as_number */
148
 
  0,                                  /* tp_as_mapping*/
149
 
  0,                                  /* tp_hash      */
 
150
  0,                                  /* tp_as_sequence */
 
151
  0,                                  /* tp_as_mapping */
 
152
  0,                                  /* tp_hash */
 
153
  0,                                  /* tp_call */
 
154
  0,                                  /* tp_str */
 
155
  0,                                  /* tp_getattro */
 
156
  0,                                  /* tp_setattro */
 
157
  0,                                  /* tp_as_buffer */
 
158
  0,                                  /* tp_flags */
 
159
  0,                                  /* tp_doc */
 
160
  0,                                  /* tp_traverse */
 
161
  0,                                  /* tp_clear */
 
162
  0,                                  /* tp_richcompare */
 
163
  0,                                  /* tp_weaklistoffset */
 
164
#if PY_VERSION_HEX >= 0x02020000
 
165
  0,                                  /* tp_iter */
 
166
  0,                                  /* tp_iternext */
 
167
  0,                                  /* tp_methods */
 
168
  0,                                  /* tp_members */
 
169
  0,                                  /* tp_getset */
 
170
  0,                                  /* tp_base */
 
171
  0,                                  /* tp_dict */
 
172
  0,                                  /* tp_descr_get */
 
173
  0,                                  /* tp_descr_set */
 
174
  0,                                  /* tp_dictoffset */
 
175
  0,                                  /* tp_init */
 
176
  0,                                  /* tp_alloc */
 
177
  0,                                  /* tp_new */
 
178
  0,                                  /* tp_free */
 
179
  0,                                  /* tp_is_gc */
 
180
  0,                                  /* tp_bases */
 
181
  0,                                  /* tp_mro */
 
182
  0,                                  /* tp_cache */
 
183
  0,                                  /* tp_subclasses */
 
184
  0,                                  /* tp_weaklist */
 
185
#endif
 
186
#if PY_VERSION_HEX >= 0x02030200
 
187
  0,                                  /* tp_del */
 
188
#endif
 
189
#ifdef COUNT_ALLOCS
 
190
  /* these must be last */
 
191
  0,                                  /* tp_alloc */
 
192
  0,                                  /* tp_free */
 
193
  0,                                  /* tp_maxalloc */
 
194
  0,                                  /*  tp_next */
 
195
#endif
150
196
};
151
197
 
152
198
/* Create a variable linking object for use later */
220
266
      goto type_error;
221
267
    }
222
268
  } 
223
 
  c = PyString_AsString(obj);
 
269
  c = PyString_AS_STRING(obj);
224
270
  /* Pointer values must start with leading underscore */
225
271
  if (*c != '_') {
226
272
    *ptr = (void *) 0;
248
294
  }
249
295
 
250
296
  if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
251
 
    PyObject *zero = PyInt_FromLong(0);
252
 
    PyObject_SetAttrString(pyobj,(char*)"thisown",zero);
253
 
    Py_DECREF(zero);
 
297
    PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False);
254
298
  }
255
299
  return 0;
256
300
 
257
301
type_error:
 
302
  PyErr_Clear();
258
303
  if (flags & SWIG_POINTER_EXCEPTION) {
259
304
    if (ty && c) {
260
 
      char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c));
261
 
      sprintf(temp,"Type error. Got %s, expected %s", c, ty->name);
262
 
      PyErr_SetString(PyExc_TypeError, temp);
263
 
      free((char *) temp);
 
305
      PyErr_Format(PyExc_TypeError, 
 
306
                   "Type error. Got %s, expected %s",
 
307
                   c, ty->name);
264
308
    } else {
265
309
      PyErr_SetString(PyExc_TypeError,"Expected a pointer");
266
310
    }
283
327
  char  *c = 0;
284
328
 
285
329
  if ((!obj) || (!PyString_Check(obj))) goto type_error;
286
 
  c = PyString_AsString(obj);
 
330
  c = PyString_AS_STRING(obj);
287
331
  /* Pointer values must start with leading underscore */
288
332
  if (*c != '_') goto type_error;
289
333
  c++;
298
342
 
299
343
  if (flags) {
300
344
    if (ty && c) {
301
 
      char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c));
302
 
      sprintf(temp,"Type error. Got %s, expected %s", c, ty->name);
303
 
      PyErr_SetString(PyExc_TypeError, temp);
304
 
      free((char *) temp);
 
345
      PyErr_Format(PyExc_TypeError, 
 
346
                   "Type error. Got %s, expected %s",
 
347
                   c, ty->name);
305
348
    } else {
306
349
      PyErr_SetString(PyExc_TypeError,"Expected a pointer");
307
350
    }
338
381
    Py_DECREF(args);
339
382
    if (inst) {
340
383
      if (own) {
341
 
        PyObject *n = PyInt_FromLong(1);
342
 
        PyObject_SetAttrString(inst,(char*)"thisown",n);
343
 
        Py_DECREF(n);
 
384
        PyObject_SetAttrString(inst,(char*)"thisown",Py_True);
344
385
      }
345
386
      robj = inst;
346
387
    }
373
414
      obj = PyFloat_FromDouble(constants[i].dvalue);
374
415
      break;
375
416
    case SWIG_PY_STRING:
376
 
      obj = PyString_FromString((char *) constants[i].pvalue);
 
417
      if (constants[i].pvalue) {
 
418
        obj = PyString_FromString((char *) constants[i].pvalue);
 
419
      } else {
 
420
        Py_INCREF(Py_None);
 
421
        obj = Py_None;
 
422
      }
377
423
      break;
378
424
    case SWIG_PY_POINTER:
379
425
      obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);