Fix directorout SWIGTYPE typemaps
This commit is contained in:
parent
a6a52f2f79
commit
837dfa1e7e
3 changed files with 46 additions and 7 deletions
|
|
@ -99,6 +99,12 @@ namespace Swig {
|
|||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
|
||||
void swig_acquire_ownership_obj(void *vptr, int own) const {
|
||||
if (vptr && own) {
|
||||
swig_owner[vptr] = new GCItem_Object(own);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* base class for director exceptions */
|
||||
|
|
|
|||
|
|
@ -93,8 +93,8 @@
|
|||
|
||||
%typemap(directorout) SWIGTYPE ($&1_ltype tmp)
|
||||
%{
|
||||
if (SWIG_ConvertPtr($input, (void **) &tmp, $1_descriptor, 0) < 0 || tmp == NULL) {
|
||||
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
|
||||
if (SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) {
|
||||
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
|
||||
}
|
||||
$result = *tmp;
|
||||
%}
|
||||
|
|
@ -107,6 +107,15 @@
|
|||
}
|
||||
%}
|
||||
|
||||
%typemap(directorout) SWIGTYPE * (swig_owntype own),
|
||||
SWIGTYPE [] (swig_owntype own)
|
||||
%{
|
||||
if (SWIG_ConvertPtrAndOwn($input, (void **)&$result, $1_descriptor, SWIG_POINTER_DISOWN, &own) < 0) {
|
||||
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
|
||||
}
|
||||
swig_acquire_ownership_obj((void*)$result, own);
|
||||
%}
|
||||
|
||||
%typemap(in) SWIGTYPE &,
|
||||
SWIGTYPE &&
|
||||
%{
|
||||
|
|
@ -115,6 +124,15 @@
|
|||
}
|
||||
%}
|
||||
|
||||
%typemap(directorout) SWIGTYPE & ($1_ltype tmp),
|
||||
SWIGTYPE && ($1_ltype tmp)
|
||||
%{
|
||||
if (SWIG_ConvertPtr($input, (void **) &tmp, $1_descriptor, 0) < 0 || tmp == NULL) {
|
||||
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
|
||||
}
|
||||
$result = tmp;
|
||||
%}
|
||||
|
||||
%typemap(in) SWIGTYPE *const& ($*ltype temp)
|
||||
%{
|
||||
if (SWIG_ConvertPtr(&$input, (void **) &temp, $*1_descriptor, 0) < 0) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* PHP runtime library
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define swig_owntype int
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -130,7 +132,7 @@ SWIG_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject) {
|
|||
This is called by SWIG_ConvertPtr which gets the type name from the
|
||||
swig_object_wrapper. */
|
||||
static void *
|
||||
SWIG_ConvertPtrData(void * p, const char *type_name, swig_type_info *ty) {
|
||||
SWIG_ConvertPtrData(void * p, const char *type_name, swig_type_info *ty, int *own) {
|
||||
swig_cast_info *tc;
|
||||
void *result = 0;
|
||||
|
||||
|
|
@ -149,14 +151,21 @@ SWIG_ConvertPtrData(void * p, const char *type_name, swig_type_info *ty) {
|
|||
if (tc) {
|
||||
int newmemory = 0;
|
||||
result = SWIG_TypeCast(tc, p, &newmemory);
|
||||
assert(!newmemory); /* newmemory handling not yet implemented */
|
||||
if (newmemory == SWIG_CAST_NEW_MEMORY) {
|
||||
assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
|
||||
if (own)
|
||||
*own |= SWIG_CAST_NEW_MEMORY;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* We wrap C/C++ pointers as PHP objects. */
|
||||
static int
|
||||
SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
||||
SWIG_ConvertPtrAndOwn(zval *z, void **ptr, swig_type_info *ty, int flags, swig_owntype *own) {
|
||||
if (own)
|
||||
*own = 0;
|
||||
|
||||
if (z == NULL) {
|
||||
*ptr = 0;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
|
|
@ -165,11 +174,12 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
switch (Z_TYPE_P(z)) {
|
||||
case IS_OBJECT: {
|
||||
swig_object_wrapper *value = SWIG_Z_FETCH_OBJ_P(z);
|
||||
*ptr = SWIG_ConvertPtrData(value->ptr, value->type->name, ty, own);
|
||||
if (*ptr == NULL) return SWIG_ERROR;
|
||||
if (flags & SWIG_POINTER_DISOWN) {
|
||||
value->newobject = 0;
|
||||
}
|
||||
*ptr = SWIG_ConvertPtrData(value->ptr, value->type->name, ty);
|
||||
return (*ptr == NULL ? SWIG_ERROR : SWIG_OK);
|
||||
return SWIG_OK;
|
||||
}
|
||||
case IS_NULL:
|
||||
*ptr = 0;
|
||||
|
|
@ -179,6 +189,11 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
||||
return SWIG_ConvertPtrAndOwn(z, ptr, ty, flags, 0);
|
||||
}
|
||||
|
||||
static const char const_name[] = "swig_runtime_data_type_pointer";
|
||||
static swig_module_info *SWIG_Php_GetModule() {
|
||||
zval *pointer = zend_get_constant_str(const_name, sizeof(const_name) - 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue