Refactor code to rename class entry variables and ConvertPtr to work with wrapped objects.
- Rename class entry variables to SWIGTYPE_class_ce - Refactor factory code to use SWIGTYPE_class_ce to create objects - Refactor ConvertPtr to work of wrapped class objects.
This commit is contained in:
parent
9fea6fc5ac
commit
4252b31f8f
4 changed files with 27 additions and 36 deletions
|
|
@ -12,18 +12,18 @@
|
|||
unsigned char,
|
||||
signed char,
|
||||
enum SWIGTYPE
|
||||
"zend_declare_class_constant_long($class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, $value);";
|
||||
"zend_declare_class_constant_long(SWIGTYPE_$class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, $value);";
|
||||
|
||||
%typemap(classconsttab) bool
|
||||
"zend_declare_class_constant_bool($class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, $value);";
|
||||
"zend_declare_class_constant_bool(SWIGTYPE_$class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, $value);";
|
||||
|
||||
%typemap(classconsttab) float,
|
||||
double
|
||||
"zend_declare_class_constant_double($class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, $value);";
|
||||
"zend_declare_class_constant_double(SWIGTYPE_$class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, $value);";
|
||||
|
||||
%typemap(classconsttab) char,
|
||||
string
|
||||
"zend_declare_class_constant_string($class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, \"$value\");";
|
||||
"zend_declare_class_constant_string(SWIGTYPE_$class_ce, \"$const_name\", sizeof(\"$const_name\") - 1, \"$value\");";
|
||||
|
||||
%typemap(consttab) int,
|
||||
unsigned int,
|
||||
|
|
|
|||
|
|
@ -95,14 +95,7 @@ if (!dcast) {
|
|||
Type *dobj = dynamic_cast<Type *>($1);
|
||||
if (dobj) {
|
||||
dcast = 1;
|
||||
zend_object *std = NULL;
|
||||
if ($newobj) {
|
||||
zend_class_entry *ce = zend_lookup_class(zend_string_init("Type", sizeof("Type")-1, 0));
|
||||
std = ce->create_object(ce);
|
||||
}
|
||||
else {
|
||||
std = $zend_obj;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}%enddef
|
||||
|
|
|
|||
|
|
@ -196,6 +196,13 @@ SWIG_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags) {
|
|||
return SWIG_ConvertResourceData(p, type_name, ty);
|
||||
}
|
||||
|
||||
#define SWIG_Z_FETCH_OBJ_P(zv) php_fetch_object(Z_OBJ_P(zv))
|
||||
|
||||
static inline
|
||||
swig_object_wrapper * php_fetch_object(zend_object *obj) {
|
||||
return (swig_object_wrapper *)((char *)obj - XtOffsetOf(swig_object_wrapper, std));
|
||||
}
|
||||
|
||||
/* We allow passing of a RESOURCE pointing to the object or an OBJECT whose
|
||||
_cPtr is a resource pointing to the object */
|
||||
static int
|
||||
|
|
@ -211,17 +218,15 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
if (ht) {
|
||||
zval * _cPtr = zend_hash_str_find(ht, "_cPtr", sizeof("_cPtr") - 1);
|
||||
if (_cPtr) {
|
||||
if (zend_hash_str_exists(ht, "SWIG_classWrapper", sizeof("SWIG_classWrapper") - 1)) {
|
||||
*ptr = SWIG_Z_FETCH_OBJ_P(z)->ptr;
|
||||
return (*ptr == NULL ? -1 : 0);
|
||||
}
|
||||
if (Z_TYPE_P(_cPtr) == IS_INDIRECT) {
|
||||
_cPtr = Z_INDIRECT_P(_cPtr);
|
||||
}
|
||||
if (Z_TYPE_P(_cPtr) == IS_RESOURCE) {
|
||||
zval *zv;
|
||||
if (!zend_hash_str_exists(ht, "SWIG_classWrapper", sizeof("SWIG_classWrapper") - 1))
|
||||
zv = _cPtr;
|
||||
else
|
||||
zv = z;
|
||||
|
||||
*ptr = SWIG_ConvertResourcePtr(zv, ty, flags);
|
||||
*ptr = SWIG_ConvertResourcePtr(_cPtr, ty, flags);
|
||||
return (*ptr == NULL ? -1 : 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -239,13 +244,6 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#define SWIG_Z_FETCH_OBJ_P(zv) php_fetch_object(Z_OBJ_P(zv))
|
||||
|
||||
static inline
|
||||
swig_object_wrapper * php_fetch_object(zend_object *obj) {
|
||||
return (swig_object_wrapper *)((char *)obj - XtOffsetOf(swig_object_wrapper, std));
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_generalize_object(zval *zval_obj, void *ptr, int class_obj, int userNewObj ,swig_type_info *type) {
|
||||
swig_object_wrapper *obj = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue