Eliminate $zend_obj typemap variable
We can just get the zend_class_entry from the swig_type_info when we need it.
This commit is contained in:
parent
c4ff1ed7cb
commit
dcdaaba7ba
4 changed files with 15 additions and 24 deletions
|
|
@ -95,8 +95,7 @@ if (!dcast) {
|
|||
Type *dobj = dynamic_cast<Type *>($1);
|
||||
if (dobj) {
|
||||
dcast = 1;
|
||||
zend_object *std = $descriptor(Type)##_ce->create_object($descriptor(Type)##_ce);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, SWIG_as_voidptr(dobj), $descriptor(Type *), std);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, SWIG_as_voidptr(dobj), $descriptor(Type *));
|
||||
}
|
||||
}%enddef
|
||||
|
||||
|
|
@ -105,6 +104,6 @@ if (!dcast) {
|
|||
int dcast = 0;
|
||||
%formacro(%_factory_dispatch, Types)
|
||||
if (!dcast) {
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, SWIG_as_voidptr($1), $descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, SWIG_as_voidptr($1), $descriptor);
|
||||
}
|
||||
}%enddef
|
||||
|
|
|
|||
|
|
@ -371,12 +371,12 @@
|
|||
SWIGTYPE &,
|
||||
SWIGTYPE &&
|
||||
%{
|
||||
SWIG_SetZval($result, $needNewFlow, $owner, (void *)result, $1_descriptor, $zend_obj);
|
||||
SWIG_SetZval($result, $needNewFlow, $owner, (void *)result, $1_descriptor);
|
||||
%}
|
||||
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, (void *)*$1, $*1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, (void *)*$1, $*1_descriptor);
|
||||
%}
|
||||
|
||||
%typemap(directorin) SWIGTYPE *,
|
||||
|
|
@ -384,7 +384,7 @@
|
|||
SWIGTYPE &,
|
||||
SWIGTYPE &&
|
||||
%{
|
||||
SWIG_SetZval($input, $needNewFlow, $owner, (void *)&$1, $1_descriptor, $zend_obj);
|
||||
SWIG_SetZval($input, $needNewFlow, $owner, (void *)&$1, $1_descriptor);
|
||||
%}
|
||||
|
||||
%typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
|
||||
|
|
@ -411,19 +411,19 @@
|
|||
#ifdef __cplusplus
|
||||
{
|
||||
$&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1);
|
||||
SWIG_SetZval(return_value, $needNewFlow, 1, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, 1, (void *)resultobj, $&1_descriptor);
|
||||
}
|
||||
#else
|
||||
{
|
||||
$&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
|
||||
memcpy(resultobj, &$1, sizeof($1_type));
|
||||
SWIG_SetZval(return_value, $needNewFlow, 1, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, 1, (void *)resultobj, $&1_descriptor);
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(directorin) SWIGTYPE
|
||||
%{
|
||||
SWIG_SetZval($input, $needNewFlow, 1, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval($input, $needNewFlow, 1, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor);
|
||||
%}
|
||||
|
||||
%typemap(out) void "";
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
}
|
||||
|
||||
static void
|
||||
SWIG_SetZval(zval *zv, int newFlow, int newobject, void *ptr, swig_type_info *type, zend_object *std) {
|
||||
SWIG_SetZval(zval *zv, int newFlow, int newobject, void *ptr, swig_type_info *type) {
|
||||
if (!ptr) {
|
||||
ZVAL_NULL(zv);
|
||||
return;
|
||||
|
|
@ -209,8 +209,10 @@ SWIG_SetZval(zval *zv, int newFlow, int newobject, void *ptr, swig_type_info *ty
|
|||
|
||||
if (newFlow) {
|
||||
swig_object_wrapper *obj;
|
||||
if (newFlow == 1)
|
||||
ZVAL_OBJ(zv,std);
|
||||
if (newFlow == 1) {
|
||||
zend_class_entry *ce = (zend_class_entry*)type->clientdata;
|
||||
ZVAL_OBJ(zv, ce->create_object(ce));
|
||||
}
|
||||
obj = SWIG_Z_FETCH_OBJ_P(zv);
|
||||
obj->ptr = ptr;
|
||||
obj->newobject = newobject;
|
||||
|
|
|
|||
|
|
@ -1450,12 +1450,6 @@ public:
|
|||
Replaceall(tm, "$result", constructor ? (constructorRenameOverload ? "return_value" : "ZEND_THIS") : "return_value");
|
||||
Replaceall(tm, "$owner", newobject ? "1" : "0");
|
||||
Replaceall(tm, "$needNewFlow", retType_valid ? (constructor ? (constructorRenameOverload ? "1" : "2") : (valid_wrapped_class ? "1" : "0")) : "0");
|
||||
if (retType_class) {
|
||||
String *retZend_obj = NewStringEmpty();
|
||||
Printf(retZend_obj, "%s_object_new(SWIGTYPE_%s_ce)", retType_class, retType_class);
|
||||
Replaceall(tm, "$zend_obj", retType_valid ? (constructor ? (constructorRenameOverload ? retZend_obj : "NULL") : (valid_wrapped_class ? retZend_obj : "NULL")) : "NULL");
|
||||
}
|
||||
Replaceall(tm, "$zend_obj", "NULL");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name);
|
||||
|
|
@ -2138,14 +2132,10 @@ public:
|
|||
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");
|
||||
} else {
|
||||
Replaceall(tm, "$needNewFlow", "0");
|
||||
}
|
||||
Replaceall(tm, "$zend_obj", "NULL");
|
||||
Replaceall(tm, "$needNewFlow", "0");
|
||||
String *input = NewStringf("&args[%d]", idx++);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue