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

« back to all changes in this revision

Viewing changes to Lib/swigrun.swg

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2009-11-15 14:00:28 UTC
  • mfrom: (1.2.9 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091115140028-me7amr2rie8zz1xn
Tags: 1.3.40-2ubuntu1
* Merge from Debian testing (LP: #356529), remaining changes:
  - Drop libchicken-dev from the build-depends (it's in universe)
  - Remove Pike from package description and from configure flags
  - drop "--without-mzscheme", we don't have it in our build-depends
  - use php-config5
  - Clean Runtime/ as well.
  - debian/rules (clean): Remove Lib/ocaml/swigp4.ml.
* debian/rules: Remove hardcoded python version.
* Remove upper limit for python from Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -----------------------------------------------------------------------------
2
2
 * swigrun.swg
3
3
 *
4
 
 * This file contains generic CAPI SWIG runtime support for pointer
 
4
 * This file contains generic C API SWIG runtime support for pointer
5
5
 * type checking.
6
6
 * ----------------------------------------------------------------------------- */
7
7
 
20
20
 
21
21
/*
22
22
  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
23
 
  creating a static or dynamic library from the swig runtime code.
24
 
  In 99.9% of the cases, swig just needs to declare them as 'static'.
 
23
  creating a static or dynamic library from the SWIG runtime code.
 
24
  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
25
25
  
26
 
  But only do this if is strictly necessary, ie, if you have problems
27
 
  with your compiler or so.
 
26
  But only do this if strictly necessary, ie, if you have problems
 
27
  with your compiler or suchlike.
28
28
*/
29
29
 
30
30
#ifndef SWIGRUNTIME
51
51
/* 
52
52
   Flags/methods for returning states.
53
53
   
54
 
   The swig conversion methods, as ConvertPtr, return and integer 
 
54
   The SWIG conversion methods, as ConvertPtr, return and integer 
55
55
   that tells if the conversion was successful or not. And if not,
56
56
   an error code can be returned (see swigerrors.swg for the codes).
57
57
   
58
58
   Use the following macros/flags to set or process the returning
59
59
   states.
60
60
   
61
 
   In old swig versions, you usually write code as:
 
61
   In old versions of SWIG, code such as the following was usually written:
62
62
 
63
63
     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
64
64
       // success code
66
66
       //fail code
67
67
     }
68
68
 
69
 
   Now you can be more explicit as:
 
69
   Now you can be more explicit:
70
70
 
71
71
    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
72
72
    if (SWIG_IsOK(res)) {
75
75
      // fail code
76
76
    }
77
77
 
78
 
   that seems to be the same, but now you can also do
 
78
   which is the same really, but now you can also do
79
79
 
80
80
    Type *ptr;
81
81
    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
93
93
    
94
94
   I.e., now SWIG_ConvertPtr can return new objects and you can
95
95
   identify the case and take care of the deallocation. Of course that
96
 
   requires also to SWIG_ConvertPtr to return new result values, as
 
96
   also requires SWIG_ConvertPtr to return new result values, such as
97
97
 
98
98
      int SWIG_ConvertPtr(obj, ptr,...) {         
99
99
        if (<obj is ok>) {                             
111
111
 
112
112
   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
113
113
   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
114
 
   swig errors code.
 
114
   SWIG errors code.
115
115
 
116
116
   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
117
117
   allows to return the 'cast rank', for example, if you have this
125
125
      fooi(1)   // cast rank '0'
126
126
 
127
127
   just use the SWIG_AddCast()/SWIG_CheckState()
128
 
 
129
 
 
130
 
 */
 
128
*/
 
129
 
131
130
#define SWIG_OK                    (0) 
132
131
#define SWIG_ERROR                 (-1)
133
132
#define SWIG_IsOK(r)               (r >= 0)
152
151
#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
153
152
#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
154
153
 
155
 
 
156
154
/* Cast-Rank Mode */
157
155
#if defined(SWIG_CASTRANK_MODE)
158
156
#  ifndef SWIG_TypeRank
175
173
#endif
176
174
 
177
175
 
178
 
 
179
 
 
180
176
#include <string.h>
181
177
 
182
178
#ifdef __cplusplus
273
269
}
274
270
 
275
271
 
276
 
/* think of this as a c++ template<> or a scheme macro */
277
 
#define SWIG_TypeCheck_Template(comparison, ty)         \
278
 
  if (ty) {                                             \
279
 
    swig_cast_info *iter = ty->cast;                    \
280
 
    while (iter) {                                      \
281
 
      if (comparison) {                                 \
282
 
        if (iter == ty->cast) return iter;              \
283
 
        /* Move iter to the top of the linked list */   \
284
 
        iter->prev->next = iter->next;                  \
285
 
        if (iter->next)                                 \
286
 
          iter->next->prev = iter->prev;                \
287
 
        iter->next = ty->cast;                          \
288
 
        iter->prev = 0;                                 \
289
 
        if (ty->cast) ty->cast->prev = iter;            \
290
 
        ty->cast = iter;                                \
291
 
        return iter;                                    \
292
 
      }                                                 \
293
 
      iter = iter->next;                                \
294
 
    }                                                   \
295
 
  }                                                     \
296
 
  return 0
297
 
 
298
272
/*
299
273
  Check the typename
300
274
*/
301
275
SWIGRUNTIME swig_cast_info *
302
276
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
303
 
  SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
 
277
  if (ty) {
 
278
    swig_cast_info *iter = ty->cast;
 
279
    while (iter) {
 
280
      if (strcmp(iter->type->name, c) == 0) {
 
281
        if (iter == ty->cast)
 
282
          return iter;
 
283
        /* Move iter to the top of the linked list */
 
284
        iter->prev->next = iter->next;
 
285
        if (iter->next)
 
286
          iter->next->prev = iter->prev;
 
287
        iter->next = ty->cast;
 
288
        iter->prev = 0;
 
289
        if (ty->cast) ty->cast->prev = iter;
 
290
        ty->cast = iter;
 
291
        return iter;
 
292
      }
 
293
      iter = iter->next;
 
294
    }
 
295
  }
 
296
  return 0;
304
297
}
305
298
 
306
 
/* Same as previous function, except strcmp is replaced with a pointer comparison */
 
299
/* 
 
300
  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
 
301
*/
307
302
SWIGRUNTIME swig_cast_info *
308
 
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
309
 
  SWIG_TypeCheck_Template(iter->type == from, into);
 
303
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
 
304
  if (ty) {
 
305
    swig_cast_info *iter = ty->cast;
 
306
    while (iter) {
 
307
      if (iter->type == from) {
 
308
        if (iter == ty->cast)
 
309
          return iter;
 
310
        /* Move iter to the top of the linked list */
 
311
        iter->prev->next = iter->next;
 
312
        if (iter->next)
 
313
          iter->next->prev = iter->prev;
 
314
        iter->next = ty->cast;
 
315
        iter->prev = 0;
 
316
        if (ty->cast) ty->cast->prev = iter;
 
317
        ty->cast = iter;
 
318
        return iter;
 
319
      }
 
320
      iter = iter->next;
 
321
    }
 
322
  }
 
323
  return 0;
310
324
}
311
325
 
312
326
/*