add %delobject, which is the equivalent of %newobject but for functions that delete an element. This allows to properly disown the argument, as the %newobject directive allows to 'own' the object
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8318 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3f9632722a
commit
9fb217b048
4 changed files with 13 additions and 0 deletions
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%newobject create_Foo;
|
%newobject create_Foo;
|
||||||
|
%delobject delete_Foo;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
Foo *create_Foo() {
|
Foo *create_Foo() {
|
||||||
return new Foo();
|
return new Foo();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public:
|
||||||
class Foo;
|
class Foo;
|
||||||
|
|
||||||
%newobject new_Foo;
|
%newobject new_Foo;
|
||||||
|
%delobject delete_Foo;
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
class Bar : public Foo {
|
class Bar : public Foo {
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,12 @@
|
||||||
#define %nonewobject %feature("new","0")
|
#define %nonewobject %feature("new","0")
|
||||||
#define %clearnewobject %feature("new","")
|
#define %clearnewobject %feature("new","")
|
||||||
|
|
||||||
|
/* the %delobject directive */
|
||||||
|
|
||||||
|
#define %delobject %feature("del")
|
||||||
|
#define %nodelobject %feature("del","0")
|
||||||
|
#define %cleardelobject %feature("del","")
|
||||||
|
|
||||||
/* the %refobject/%unrefobject directives */
|
/* the %refobject/%unrefobject directives */
|
||||||
|
|
||||||
#define %refobject %feature("ref")
|
#define %refobject %feature("ref")
|
||||||
|
|
|
||||||
|
|
@ -918,6 +918,10 @@ int
|
||||||
Language::functionHandler(Node *n) {
|
Language::functionHandler(Node *n) {
|
||||||
Parm *p;
|
Parm *p;
|
||||||
p = Getattr(n,"parms");
|
p = Getattr(n,"parms");
|
||||||
|
if (GetFlag(n,"feature:del")) {
|
||||||
|
/* the method acts like a delete operator, ie, we need to disown the parameter */
|
||||||
|
if (p) Setattr(p,"wrap:disown","1");
|
||||||
|
}
|
||||||
if (!CurrentClass) {
|
if (!CurrentClass) {
|
||||||
globalfunctionHandler(n);
|
globalfunctionHandler(n);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue