|
62 | 62 | * SP-owned copy of the obtained value.
|
63 | 63 | * ------------------------------------------------------------------------- */
|
64 | 64 | %typemap(in, noblock=1, fragment="SWIG_check_sp_nonnull") CONST TYPE ($&1_type argp = 0) {
|
65 |
| - SWIG_check_sp_nonnull($input, "$1_ltype", "$fclassname", "$decl", return $null) |
66 |
| - argp = $input->cptr ? %static_cast($input->cptr, SWIGSP__*)->get() : NULL; |
| 65 | + SWIG_check_sp_nonnull($input->cptr, "$1_ltype", "$fclassname", "$decl", return $null) |
| 66 | + argp = static_cast<SWIGSP__*>($input->cptr)->get(); |
67 | 67 | $1 = *argp;
|
68 | 68 | }
|
69 | 69 | %typemap(out, noblock=1) CONST TYPE {
|
|
76 | 76 | * cmemflags, but the result is always a new self-owned shared pointer.
|
77 | 77 | * ------------------------------------------------------------------------- */
|
78 | 78 | %typemap(in, noblock=1) CONST TYPE * (SWIGSP__* smartarg) {
|
79 |
| - smartarg = %static_cast($input->cptr, SWIGSP__*); |
80 |
| - $1 = smartarg ? %const_cast(smartarg->get(), TYPE*) : NULL; |
| 79 | + smartarg = (SWIGSP__*)($input->cptr); |
| 80 | + $1 = smartarg ? (TYPE*)(smartarg->get()) : NULL; |
81 | 81 | }
|
82 | 82 |
|
| 83 | +// Replace call to "delete (Foo*) arg1;" with call to delete the *shared |
| 84 | +// pointer*: decrement the reference count instead of forcing the object to |
| 85 | +// be destroyed and causing a double-delete. |
| 86 | +%feature("unref") TYPE |
| 87 | +%{ (void)$self; delete smart$self; %} |
| 88 | + |
83 | 89 | // The string "SWIG_NO_NULL_DELETER_$owner" is replaced by the macro
|
84 | 90 | // SWIG_NO_NULL_DELETER_1 if a raw pointer is being emitted via %newobject
|
85 | 91 | // (for a shared pointer this macro is empty);
|
|
93 | 99 | }
|
94 | 100 |
|
95 | 101 | /* -------------------------------------------------------------------------
|
96 |
| - * Original class by reference. Same as by pointer, but with null checks. |
| 102 | + * Original class by reference. Add null checks. |
97 | 103 | * ------------------------------------------------------------------------- */
|
98 |
| -%typemap(in, noblock=1, fragment="SWIG_check_sp_nonnull") CONST TYPE& (SWIGSP__* smartarg) { |
99 |
| - SWIG_check_sp_nonnull($input, "$1_ltype", "$fclassname", "$decl", return $null) |
100 |
| - smartarg = %static_cast($input->cptr, SWIGSP__*); |
101 |
| - $1 = %const_cast(smartarg->get(), TYPE*); |
| 104 | +%typemap(in, noblock=1, fragment="SWIG_check_sp_nonnull") CONST TYPE & { |
| 105 | + SWIG_check_sp_nonnull($input->cptr, "$1_ltype", "$fclassname", "$decl", return $null) |
| 106 | + $1 = (TYPE*)static_cast<SWIGSP__*>($input->cptr)->get(); |
102 | 107 | }
|
103 | 108 |
|
| 109 | +%typemap(in) CONST TYPE &ASSIGNMENT_OTHER = SWIGTYPE *ASSIGNMENT_SELF; |
| 110 | + |
104 | 111 | // Output value is never null. Because we're allocating a shared pointer, we set the memory ownership to MOVE so that the *SP*
|
105 | 112 | // will be properly deallocated. But we also must use a null deleter so that when the SP is deleted the corresponding memory
|
106 | 113 | // will not be.
|
|
113 | 120 | * SP by value
|
114 | 121 | * ------------------------------------------------------------------------- */
|
115 | 122 | %typemap(in, noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<CONST TYPE > {
|
116 |
| - if ($input->cptr) $1 = *%static_cast($input->cptr, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<CONST TYPE >*); |
| 123 | + if ($input->cptr) $1 = *static_cast<SWIG_SHARED_PTR_QNAMESPACE::shared_ptr<CONST TYPE >*>($input->cptr); |
117 | 124 | }
|
118 | 125 |
|
119 | 126 | %typemap(out, noblock=1) SWIGSP__ {
|
120 |
| - $result.cptr = %new_copy($1, SWIGSP__); |
| 127 | + $result.cptr = SWIG_SHARED_PTR_NOT_NULL($1) ? %new_copy($1, SWIGSP__) : NULL; |
121 | 128 | $result.cmemflags = SWIG_MEM_OWN | SWIG_MEM_RVALUE;
|
122 | 129 | }
|
123 | 130 |
|
124 | 131 | /* -------------------------------------------------------------------------
|
125 | 132 | * SP by reference
|
126 | 133 | * ------------------------------------------------------------------------- */
|
127 | 134 | %typemap(in, noblock=1) SWIGSP__& ($*1_ltype tempnull) {
|
128 |
| - $1 = $input->cptr ? %static_cast($input->cptr, $1_ltype) : &tempnull; |
| 135 | + $1 = $input->cptr ? static_cast<$1_ltype >($input->cptr) : &tempnull; |
129 | 136 | }
|
130 | 137 |
|
131 | 138 | %typemap(out, noblock=1) SWIGSP__& {
|
132 |
| - $result.cptr = SWIG_SHARED_PTR_NOT_NULL(*$1) ? %new_copy(*$1, SWIGSP__) : 0; |
| 139 | + $result.cptr = SWIG_SHARED_PTR_NOT_NULL(*$1) ? %new_copy(*$1, SWIGSP__) : NULL; |
133 | 140 | $result.cmemflags = SWIG_MEM_OWN | SWIG_MEM_RVALUE;
|
134 | 141 | }
|
135 | 142 |
|
136 | 143 | /* -------------------------------------------------------------------------
|
137 | 144 | * SP by pointer
|
138 | 145 | * ------------------------------------------------------------------------- */
|
139 | 146 | %typemap(in, noblock=1) SWIGSP__ * ($*1_ltype tempnull) {
|
140 |
| - $1 = $input->cptr ? %static_cast($input->cptr, $1_ltype) : &tempnull; |
| 147 | + $1 = $input->cptr ? static_cast<$1_ltype >($input->cptr) : &tempnull; |
141 | 148 | }
|
142 | 149 |
|
143 | 150 | %typemap(out, noblock=1, fragment="SWIG_null_deleter") SWIGSP__ * {
|
144 |
| - $result.cptr = ($1 && SWIG_SHARED_PTR_NOT_NULL(*$1)) ? %new_copy(*$1, SWIGSP__) : 0; |
| 151 | + $result.cptr = ($1 && SWIG_SHARED_PTR_NOT_NULL(*$1)) ? %new_copy(*$1, SWIGSP__) : NULL; |
145 | 152 | $result.cmemflags = SWIG_MEM_OWN | SWIG_MEM_RVALUE;
|
146 | 153 | }
|
147 | 154 |
|
|
158 | 165 | #error "typemaps for $1_type not available"
|
159 | 166 | %}
|
160 | 167 |
|
161 |
| -/* ------------------------------------------------------------------------- |
162 |
| - * Replace call to "delete (Foo*) arg1;" with call to delete the *shared |
163 |
| - * pointer* (so decrement the reference count instead of forcing the object to |
164 |
| - * be destroyed and causing a double-delete) |
165 |
| - */ |
166 |
| - |
167 |
| -%feature("unref") TYPE |
168 |
| -%{ (void)$self; delete smart$self; %} |
169 |
| - |
170 | 168 | /* -------------------------------------------------------------------------
|
171 | 169 | * Instantiate shared pointer
|
172 | 170 | */
|
|
0 commit comments