1
1
/* -----------------------------------------------------------------------------
4
* This file contains generic CAPI SWIG runtime support for pointer
4
* This file contains generic C API SWIG runtime support for pointer
6
6
* ----------------------------------------------------------------------------- */
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'.
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.
30
30
#ifndef SWIGRUNTIME
52
52
Flags/methods for returning states.
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).
58
58
Use the following macros/flags to set or process the returning
61
In old swig versions, you usually write code as:
61
In old versions of SWIG, code such as the following was usually written:
63
63
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
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
81
81
int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
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
98
98
int SWIG_ConvertPtr(obj, ptr,...) {
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
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
276
/* think of this as a c++ template<> or a scheme macro */
277
#define SWIG_TypeCheck_Template(comparison, ty) \
279
swig_cast_info *iter = ty->cast; \
282
if (iter == ty->cast) return iter; \
283
/* Move iter to the top of the linked list */ \
284
iter->prev->next = iter->next; \
286
iter->next->prev = iter->prev; \
287
iter->next = ty->cast; \
289
if (ty->cast) ty->cast->prev = iter; \
299
273
Check the typename
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);
278
swig_cast_info *iter = ty->cast;
280
if (strcmp(iter->type->name, c) == 0) {
281
if (iter == ty->cast)
283
/* Move iter to the top of the linked list */
284
iter->prev->next = iter->next;
286
iter->next->prev = iter->prev;
287
iter->next = ty->cast;
289
if (ty->cast) ty->cast->prev = iter;
306
/* Same as previous function, except strcmp is replaced with a pointer comparison */
300
Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
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) {
305
swig_cast_info *iter = ty->cast;
307
if (iter->type == from) {
308
if (iter == ty->cast)
310
/* Move iter to the top of the linked list */
311
iter->prev->next = iter->next;
313
iter->next->prev = iter->prev;
314
iter->next = ty->cast;
316
if (ty->cast) ty->cast->prev = iter;