Implement support for SWIGTYPE* DISOWN typemap
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7381 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
82e3ec30dc
commit
43015f7aca
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);
|
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 */
|
/* Do type-checking if type info was provided */
|
||||||
if (ty) {
|
if (ty) {
|
||||||
if (ty->clientdata) {
|
if (ty->clientdata) {
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,24 @@
|
||||||
|
|
||||||
%typemap(in) SWIGTYPE *,
|
%typemap(in) SWIGTYPE *,
|
||||||
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 */
|
/* Additional check for null references */
|
||||||
%typemap(in) SWIGTYPE &
|
%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 */
|
/* Object passed by value. Convert to a pointer */
|
||||||
%typemap(in) SWIGTYPE {
|
%typemap(in) SWIGTYPE {
|
||||||
$&1_ltype ptr;
|
$&1_ltype ptr;
|
||||||
SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 1);
|
SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, $disown);
|
||||||
if (ptr) $1 = *ptr;
|
if (ptr) $1 = *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pointer to a class member */
|
/* 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 --- */
|
/* --- Output typemaps --- */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -724,6 +724,12 @@ public:
|
||||||
Replaceall(tm,"$target",ln);
|
Replaceall(tm,"$target",ln);
|
||||||
Replaceall(tm,"$source",source);
|
Replaceall(tm,"$source",source);
|
||||||
Replaceall(tm,"$input",source);
|
Replaceall(tm,"$input",source);
|
||||||
|
if (Getattr(p,"wrap:disown") || (Getattr(p,"tmap:in:disown"))) {
|
||||||
|
Replaceall(tm,"$disown","SWIG_POINTER_DISOWN");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Replaceall(tm,"$disown","0");
|
||||||
|
}
|
||||||
Setattr(p,"emit:input",Copy(source));
|
Setattr(p,"emit:input",Copy(source));
|
||||||
Printf(f->code,"%s\n", tm);
|
Printf(f->code,"%s\n", tm);
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p,"tmap:in:next");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue