From 7e66388cf395f86ca3aa206e8024ebf65074f93a Mon Sep 17 00:00:00 2001 From: Nihal Date: Wed, 13 Sep 2017 01:05:57 +0530 Subject: [PATCH] Fix director_basic test case - This fixes director_basic test case. Uses the new flow in director class methods. - It also correctly fixes the double free problem in director_detect. --- Lib/php/php.swg | 4 ++-- Source/Modules/php.cxx | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index beb20408e..5172cddef 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -411,7 +411,7 @@ SWIGTYPE &, SWIGTYPE && %{ - SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, ($owner)|2); + SWIG_SetZval($input, $needNewFlow, $owner, (void *)&$1, $1_descriptor, $zend_obj); %} %typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) @@ -450,7 +450,7 @@ %typemap(directorin) SWIGTYPE %{ - SWIG_SetPointerZval($input, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, 1|2); + SWIG_SetZval($input, $needNewFlow, $owner, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, $zend_obj); %} %typemap(out) void ""; diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index ba2e8556e..d9e45b995 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -3429,6 +3429,15 @@ done: if ((tm = Getattr(p, "tmap:directorin")) != 0) { String *parse = Getattr(p, "tmap:directorin:parse"); if (!parse) { + if (is_class(Getattr(p, "type"))) { + String *return_class_name = get_class_name(Getattr(p, "type")); + String *object_name = NewStringEmpty(); + Printf(object_name, "%s_object_new(SWIGTYPE_%s_ce)", return_class_name, return_class_name); + Replaceall(tm, "$zend_obj", object_name); + Replaceall(tm, "$needNewFlow", "1"); + } + Replaceall(tm, "$zend_obj", "NULL"); + Replaceall(tm, "$needNewFlow", "0"); String *input = NewStringf("&args[%d]", idx++); Setattr(p, "emit:directorinput", input); Replaceall(tm, "$input", input); @@ -3517,7 +3526,7 @@ done: char temp[24]; sprintf(temp, "%d", idx); Replaceall(tm, "$argnum", temp); - Replaceall(tm, "$needNewFlow", "1"); + Replaceall(tm, "$needNewFlow", Getattr(n, "feature:new") ? "1" : "0"); /* TODO check this */ if (Getattr(n, "wrap:disown")) {