| 2069 | /* Convert a pointer value */ |
| 2070 | |
| 2071 | SWIGRUNTIME int |
| 2072 | SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { |
| 2073 | int res; |
| 2074 | SwigPyObject *sobj; |
| 2075 | int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; |
| 2076 | |
| 2077 | if (!obj) |
| 2078 | return SWIG_ERROR; |
| 2079 | if (obj == Py_None && !implicit_conv) { |
| 2080 | if (ptr) |
| 2081 | *ptr = 0; |
| 2082 | return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; |
| 2083 | } |
| 2084 | |
| 2085 | res = SWIG_ERROR; |
| 2086 | |
| 2087 | sobj = SWIG_Python_GetSwigThis(obj); |
| 2088 | if (own) |
| 2089 | *own = 0; |
| 2090 | while (sobj) { |
| 2091 | void *vptr = sobj->ptr; |
| 2092 | if (ty) { |
| 2093 | swig_type_info *to = sobj->ty; |
| 2094 | if (to == ty) { |
| 2095 | /* no type cast needed */ |
| 2096 | if (ptr) *ptr = vptr; |
| 2097 | break; |
| 2098 | } else { |
| 2099 | swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); |
| 2100 | if (!tc) { |
| 2101 | sobj = (SwigPyObject *)sobj->next; |
| 2102 | } else { |
| 2103 | if (ptr) { |
| 2104 | int newmemory = 0; |
| 2105 | *ptr = SWIG_TypeCast(tc,vptr,&newmemory); |
| 2106 | if (newmemory == SWIG_CAST_NEW_MEMORY) { |
| 2107 | assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ |
| 2108 | if (own) |
| 2109 | *own = *own | SWIG_CAST_NEW_MEMORY; |
| 2110 | } |
| 2111 | } |
| 2112 | break; |
| 2113 | } |
| 2114 | } |
| 2115 | } else { |
| 2116 | if (ptr) *ptr = vptr; |
| 2117 | break; |
| 2118 | } |
| 2119 | } |
| 2120 | if (sobj) { |
| 2121 | if (own) |
| 2122 | *own = *own | sobj->own; |
| 2123 | if (flags & SWIG_POINTER_DISOWN) { |
| 2124 | sobj->own = 0; |
| 2125 | } |
| 2126 | res = SWIG_OK; |
| 2127 | } else { |
| 2128 | if (implicit_conv) { |
nothing calls this directly
no test coverage detected