git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11434 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8ec7035eee
commit
0249eea389
53 changed files with 2838 additions and 66 deletions
|
|
@ -13,6 +13,7 @@ extern "C" {
|
|||
#include "zend.h"
|
||||
#include "zend_API.h"
|
||||
#include "php.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
|
||||
#ifdef ZEND_RAW_FENTRY
|
||||
/* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */
|
||||
|
|
@ -84,6 +85,7 @@ typedef struct {
|
|||
static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; }
|
||||
|
||||
#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC)
|
||||
#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
|
||||
|
||||
static void
|
||||
SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) {
|
||||
|
|
@ -101,7 +103,31 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject
|
|||
value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper));
|
||||
value->ptr=ptr;
|
||||
value->newobject=newobject;
|
||||
ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata));
|
||||
if (newobject <= 1) {
|
||||
ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata));
|
||||
} else {
|
||||
value->newobject = 0;
|
||||
zval *resource;
|
||||
MAKE_STD_ZVAL(resource);
|
||||
ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata));
|
||||
zend_class_entry **ce = NULL;
|
||||
zval *classname;
|
||||
MAKE_STD_ZVAL(classname);
|
||||
/* _p_Foo -> Foo */
|
||||
ZVAL_STRING(classname, (char*)type->name+3, 1);
|
||||
/* class names are stored in lowercase */
|
||||
php_strtolower(Z_STRVAL_PP(&classname), Z_STRLEN_PP(&classname));
|
||||
if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &ce TSRMLS_CC) != SUCCESS) {
|
||||
/* class does not exists */
|
||||
object_init(z);
|
||||
} else {
|
||||
object_init_ex(z, *ce);
|
||||
}
|
||||
z->refcount = 1;
|
||||
z->is_ref = 1;
|
||||
zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL);
|
||||
FREE_ZVAL(classname);
|
||||
}
|
||||
return;
|
||||
}
|
||||
zend_error(E_ERROR, "Type: %s not registered with zend",type->name);
|
||||
|
|
@ -156,7 +182,7 @@ SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) {
|
|||
char *type_name;
|
||||
|
||||
value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type);
|
||||
if ( flags && SWIG_POINTER_DISOWN ) {
|
||||
if ( flags & SWIG_POINTER_DISOWN ) {
|
||||
value->newobject = 0;
|
||||
}
|
||||
p = value->ptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue