Refactor SWIG_SetZval to simplify the arguments. Solve constructor rename bug
- Refactor SWIG_SetZval. - Fix the Renamed constructor - turn into static factory method bug. Conflicts: Source/Modules/php.cxx
This commit is contained in:
parent
aa180f2c4d
commit
9c40bbdb85
4 changed files with 48 additions and 38 deletions
|
|
@ -96,7 +96,7 @@ if (!dcast) {
|
|||
if (dobj) {
|
||||
dcast = 1;
|
||||
zend_object *std = $descriptor(Type)##_ce->create_object($descriptor(Type)##_ce);
|
||||
SWIG_SetZval(return_value, $classZv, $owner, $newobj, $c_obj, SWIG_as_voidptr(dobj), $descriptor(Type *), std);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, SWIG_as_voidptr(dobj), $descriptor(Type *), std);
|
||||
}
|
||||
}%enddef
|
||||
|
||||
|
|
@ -105,6 +105,6 @@ if (!dcast) {
|
|||
int dcast = 0;
|
||||
%formacro(%_factory_dispatch, Types)
|
||||
if (!dcast) {
|
||||
SWIG_SetZval(return_value, $classZv, $owner, $newobj, $c_obj, SWIG_as_voidptr($1), $descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, SWIG_as_voidptr($1), $descriptor, $zend_obj);
|
||||
}
|
||||
}%enddef
|
||||
|
|
|
|||
|
|
@ -396,12 +396,12 @@
|
|||
SWIGTYPE &,
|
||||
SWIGTYPE &&
|
||||
%{
|
||||
SWIG_SetZval($result, $classZv, $owner, $newobj, $c_obj, (void *)result, $1_descriptor, $zend_obj);
|
||||
SWIG_SetZval($result, $needNewFlow, $owner, (void *)result, $1_descriptor, $zend_obj);
|
||||
%}
|
||||
|
||||
%typemap(out) SWIGTYPE *const&
|
||||
%{
|
||||
SWIG_SetZval(return_value, $classZv, $owner, $newobj, $c_obj, (void *)*$1, $*1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, (void *)*$1, $*1_descriptor, $zend_obj);
|
||||
%}
|
||||
|
||||
%typemap(directorin) SWIGTYPE *,
|
||||
|
|
@ -436,13 +436,13 @@
|
|||
#ifdef __cplusplus
|
||||
{
|
||||
$&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1);
|
||||
SWIG_SetZval(return_value, $classZv, $owner, $newobj, $c_obj, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
}
|
||||
#else
|
||||
{
|
||||
$&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
|
||||
memcpy(resultobj, &$1, sizeof($1_type));
|
||||
SWIG_SetZval(return_value, $classZv, $owner, $newobj, $c_obj, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
SWIG_SetZval(return_value, $needNewFlow, $owner, (void *)resultobj, $&1_descriptor, $zend_obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -245,14 +245,19 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
}
|
||||
|
||||
static void
|
||||
SWIG_generalize_object(zval *zval_obj, void *ptr, int class_obj, int userNewObj ,swig_type_info *type) {
|
||||
SWIG_pack_zval(zval *zv, void *ptr, int userNewObj) {
|
||||
swig_object_wrapper *obj = NULL;
|
||||
obj = (swig_object_wrapper *) SWIG_Z_FETCH_OBJ_P(zv);
|
||||
obj->ptr = ptr;
|
||||
obj->newobject = userNewObj;
|
||||
}
|
||||
|
||||
HashTable * ht = NULL;
|
||||
static void
|
||||
SWIG_generalize_object(zval *zval_obj, void *ptr, int userNewObj ,swig_type_info *type) {
|
||||
SWIG_pack_zval(zval_obj, ptr, userNewObj);
|
||||
|
||||
HashTable *ht = Z_OBJ_HT_P(zval_obj)->get_properties(zval_obj);
|
||||
|
||||
obj = (swig_object_wrapper *) SWIG_Z_FETCH_OBJ_P(zval_obj);
|
||||
obj->ptr = (void *)ptr;
|
||||
ht = Z_OBJ_HT_P(zval_obj)->get_properties(zval_obj);
|
||||
if(ht) {
|
||||
zval zv;
|
||||
ZVAL_RES(&zv,zend_register_resource(ptr,*(int *)(type->clientdata)));
|
||||
|
|
@ -260,32 +265,23 @@ SWIG_generalize_object(zval *zval_obj, void *ptr, int class_obj, int userNewObj
|
|||
ZVAL_TRUE(&zv);
|
||||
zend_hash_str_add(ht, "SWIG_classWrapper", sizeof("SWIG_classWrapper") - 1, &zv);
|
||||
}
|
||||
obj->newobject = userNewObj;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_SetZval( zval *zv, zval *class_zv, int userNewObj ,int object, int class_obj ,void *ptr, swig_type_info *type, zend_object *std) {
|
||||
|
||||
if (class_obj == 1) {
|
||||
SWIG_generalize_object(class_zv, ptr, class_obj, userNewObj ,type);
|
||||
return;
|
||||
}
|
||||
SWIG_SetZval( zval *zv, int newFlow, int userNewObj, void *ptr, swig_type_info *type, zend_object *std) {
|
||||
|
||||
if (!ptr) {
|
||||
ZVAL_NULL(zv);
|
||||
return;
|
||||
}
|
||||
|
||||
if (object == 1) {
|
||||
ZVAL_OBJ(zv,std);
|
||||
SWIG_generalize_object(zv, ptr, class_obj, userNewObj, type);
|
||||
if (newFlow) {
|
||||
if (newFlow == 1)
|
||||
ZVAL_OBJ(zv,std);
|
||||
SWIG_generalize_object(zv, ptr, userNewObj, type);
|
||||
}
|
||||
|
||||
if (object == 2) {
|
||||
int newobj = class_obj;
|
||||
if (class_obj == 2)
|
||||
newobj = 1;
|
||||
SWIG_SetPointerZval(zv,ptr,type,newobj);
|
||||
else {
|
||||
SWIG_SetPointerZval(zv, ptr, type, userNewObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue