Implement support for SWIGTYPE* DISOWN typemap
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7381 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6982a6adc6
commit
509a391877
3 changed files with 21 additions and 4 deletions
|
|
@ -120,6 +120,14 @@ SWIG_Ruby_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)
|
|||
Data_Get_Struct(obj, void, *ptr);
|
||||
}
|
||||
|
||||
/* Check to see if the input object is giving up ownership
|
||||
of the underlying C struct or C++ object. If so, then
|
||||
set the free function to nil so that the C struct
|
||||
is not freed when the Ruby object goes out of scope.*/
|
||||
if (flags & SWIG_POINTER_DISOWN) {
|
||||
RDATA(obj)->dfree = 0;
|
||||
}
|
||||
|
||||
/* Do type-checking if type info was provided */
|
||||
if (ty) {
|
||||
if (ty->clientdata) {
|
||||
|
|
|
|||
|
|
@ -2,21 +2,24 @@
|
|||
|
||||
%typemap(in) SWIGTYPE *,
|
||||
SWIGTYPE []
|
||||
"SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);"
|
||||
"SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, $disown);"
|
||||
|
||||
%typemap(in) SWIGTYPE *DISOWN
|
||||
"SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN);"
|
||||
|
||||
/* Additional check for null references */
|
||||
%typemap(in) SWIGTYPE &
|
||||
"SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1); if ($1 == NULL) rb_raise(rb_eTypeError, \"null reference\");"
|
||||
"SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, $disown); if ($1 == NULL) rb_raise(rb_eTypeError, \"null reference\");"
|
||||
|
||||
/* Object passed by value. Convert to a pointer */
|
||||
%typemap(in) SWIGTYPE {
|
||||
$&1_ltype ptr;
|
||||
SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 1);
|
||||
SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, $disown);
|
||||
if (ptr) $1 = *ptr;
|
||||
}
|
||||
|
||||
/* Pointer to a class member */
|
||||
%typemap(in) SWIGTYPE (CLASS::*) "SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor, 1);";
|
||||
%typemap(in) SWIGTYPE (CLASS::*) "SWIG_ConvertPacked($input, (void *) &$1, sizeof($1_type), $1_descriptor, $disown);";
|
||||
|
||||
/* --- Output typemaps --- */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue