Merge remote-tracking branch 'nihaln/checkout_code' into gsoc2017-php7-classes-via-c-api

Fixes #1072
This commit is contained in:
Olly Betts 2017-08-20 09:00:43 +12:00
commit 88c2e96444
15 changed files with 144 additions and 663 deletions

View file

@ -1,26 +0,0 @@
cd class
make
cd ../constants
make
cd ../disown
make
cd ../overloading
make
cd ../pragmas
make
cd ../variables
make
cd ../cpointer
make
cd ../enum
make
cd ../funcptr
make
cd ../pointer
make
cd ../proxy
make
cd ../simple
make
cd ../value
make

View file

@ -3,8 +3,10 @@
require "tests.php";
require "add_link.php";
// No new functions, except the flat functions
check::functions(array(new_foo,foo_blah));
check::classes(array(Foo));
check::classmethods(Foo,array(__construct,__set,__isset,__get,blah));
$foo=new foo();
check::is_a($foo,foo);

View file

@ -3,11 +3,8 @@
require "tests.php";
require "arrays_global.php";
check::functions(array(test_a,test_b));
check::functions(array(test_a,test_b,new_simplestruct,new_material));
check::classes(array(arrays_global,SimpleStruct,Material));
check::classmethods(SimpleStruct,array(__construct,__set,__isset,__get,double_field_set,double_field_get));
check::classmethods(Material,array(__construct,__set,__isset,__get));
// The size of array_c is 2, but the last byte is \0, so we can only store a
// single byte string in it.
check::set(array_c,"Z");

View file

@ -3,11 +3,8 @@
require "tests.php";
require "arrays_global_twodim.php";
check::functions(array(fn_taking_arrays,get_2d_array));
check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
check::classes(array(arrays_global_twodim,SimpleStruct,Material));
check::classmethods(SimpleStruct,array(__construct,__set,__isset,__get,double_field_set,double_field_get));
check::classmethods(Material,array(__construct,__set,__isset,__get));
$a1=array(10,11,12,13);
$a2=array(14,15,16,17);
$a=array($a1,$a2);

View file

@ -3,10 +3,10 @@
require "tests.php";
require "arrays_scope.php";
// New functions
check::functions(array(new_bar,bar_blah));
// New classes
check::classes(array(arrays_scope,Bar));
// New functions
check::classmethods(Bar,array(__construct,__set,__isset,__get,blah));
$bar=new bar();

View file

@ -3,11 +3,10 @@
require "tests.php";
require "casts.php";
// No new functions
check::functions(array(new_a,a_hello,new_b));
// No new classes
check::classes(array(A,B));
// New functions
check::classmethods(A,array(__construct,__set,__isset,__get,hello));
check::classmethods(B,array(__construct,__set,__isset,__get,hello));
// now new vars
check::globals(array());

View file

@ -3,13 +3,8 @@
require "tests.php";
require "class_ignore.php";
check::functions(array(do_blah));
check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo));
check::classes(array(class_ignore,Bar,Boo,Far,Hoo));
// New functions
check::classmethods(Bar,array(__construct,__set,__isset,__get,blah));
check::classmethods(Boo,array(__construct,__set,__isset,__get,away));
check::classmethods(Far,array(__construct,__set,__isset,__get));
check::classmethods(Hoo,array(__construct,__set,__isset,__get));
// No new vars
check::globals(array());

View file

@ -3,15 +3,10 @@
require "tests.php";
require "cpp_basic.php";
// New Functions
check::functions(array(get_func1_ptr,get_func2_ptr,test_func_ptr));
// New functions
check::functions(array(foo_func1,foo_func2,foo___str__,foosubsub___str__,bar_test,bar_testfoo,get_func1_ptr,get_func2_ptr,test_func_ptr,fl_window_show));
// New classes
check::classes(array(cpp_basic,Foo,FooSub,FooSubSub,Bar,Fl_Window));
// New Class functions
check::classmethods(Foo,array(__construct,__set,__isset,__get,func1,func2,__str__));
check::classmethods(foosubsub,array(__construct,__set,__isset,__get,__str__));
check::classmethods(bar,array(__construct,__set,__isset,__get,test,testfoo));
check::classmethods(Fl_Window,array(__construct,__set,__isset,__get,show));
$f = new Foo(3);
$f->func_ptr = get_func1_ptr();

View file

@ -4,12 +4,12 @@ require "enum_scope_template.php";
check::classes(array("enum_scope_template", "TreeInt"));
check::functions(array("chops","treeint_chops"));
check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
check::equal(1,TreeInt_Fir,"1==TreeInt_Fir");
check::equal(2,TreeInt_Cedar,"2==TreeInt_Cedar");
check::equal(TreeInt_Oak,chops(TreeInt_Oak),"TreeInt_Oak==chops(TreeInt_Oak)");
check::equal(TreeInt_Fir,chops(TreeInt_Fir),"TreeInt_Fir==chops(TreeInt_Fir)");
check::equal(TreeInt_Cedar,chops(TreeInt_Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)");
check::equal(0,TreeInt::Oak,"0==TreeInt_Oak");
check::equal(1,TreeInt::Fir,"1==TreeInt_Fir");
check::equal(2,TreeInt::Cedar,"2==TreeInt_Cedar");
check::equal(TreeInt::Oak,chops(TreeInt::Oak),"TreeInt_Oak==chops(TreeInt_Oak)");
check::equal(TreeInt::Fir,chops(TreeInt::Fir),"TreeInt_Fir==chops(TreeInt_Fir)");
check::equal(TreeInt::Cedar,chops(TreeInt::Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)");
check::done();
?>

View file

@ -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,

View file

@ -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

View file

@ -85,8 +85,8 @@
/* Object passed by value. Convert to a pointer */
%typemap(in) SWIGTYPE ($&1_ltype tmp)
%{
if (zend_lookup_class(zend_string_init("$lower_param",sizeof("$lower_param")-1,0))) {
$1 = *$obj_value;
if ($needNewFlow) {
$1 = *(($1_ltype *)$obj_value);
}
else {
if (SWIG_ConvertPtr(&$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL)
@ -108,8 +108,8 @@
%typemap(in) SWIGTYPE *,
SWIGTYPE []
%{
if (zend_lookup_class(zend_string_init("$lower_param",sizeof("$lower_param")-1,0))) {
$1 = $obj_value;
if ($needNewFlow) {
$1 = ($1_ltype) $obj_value;
}
else {
if (SWIG_ConvertPtr(&$linput, (void **) &$1, $1_descriptor, 0) < 0)
@ -119,8 +119,8 @@
%typemap(in) SWIGTYPE &
%{
if (zend_lookup_class(zend_string_init("$lower_param",sizeof("$lower_param")-1,0))) {
$1 = $obj_value;
if ($needNewFlow) {
$1 = ($1_ltype) $obj_value;
}
else {
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL)
@ -130,8 +130,8 @@
%typemap(in) SWIGTYPE &&
%{
if (zend_lookup_class(zend_string_init("$lower_param",sizeof("$lower_param")-1,0))) {
$1 = $obj_value;
if ($needNewFlow) {
$1 = ($1_ltype) $obj_value;
}
else {
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
@ -142,15 +142,20 @@
%typemap(in) SWIGTYPE *const& ($*ltype temp)
%{
if (SWIG_ConvertPtr(&$input, (void **) &temp, $*1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor");
if ($needNewFlow) {
$1 = ($1_ltype) $obj_value;
}
else {
if (SWIG_ConvertPtr(&$input, (void **) &temp, $*1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor");
}
$1 = ($1_ltype)&temp;
}
%}
%typemap(in) SWIGTYPE *DISOWN
%{
if (zend_lookup_class(zend_string_init("$lower_param",sizeof("$lower_param")-1,0))) {
if ($needNewFlow) {
SWIG_Z_FETCH_OBJ_P(&$input)->newobject = 0;
$1 = ($lower_param *)SWIG_Z_FETCH_OBJ_P(&$input)->ptr;
}

View file

@ -185,9 +185,24 @@ SWIG_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags) {
type_name=zend_rsrc_list_get_rsrc_type(Z_RES_P(z));
if (!type_name) {
if (Z_TYPE_P(z) == IS_OBJECT) {
HashTable * ht = Z_OBJ_HT_P(z)->get_properties(z);
zval * _cPtr = zend_hash_str_find(ht, "_cPtr", sizeof("_cPtr") - 1);
type_name=zend_rsrc_list_get_rsrc_type(Z_RES_P(_cPtr));
}
}
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
@ -203,6 +218,10 @@ 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);
}
@ -225,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;
@ -245,6 +257,8 @@ SWIG_generalize_object(zval *zval_obj, void *ptr, int class_obj, int userNewObj
zval zv;
ZVAL_RES(&zv,zend_register_resource(ptr,*(int *)(type->clientdata)));
zend_hash_str_add(ht, "_cPtr", sizeof("_cPtr") - 1, &zv);
ZVAL_TRUE(&zv);
zend_hash_str_add(ht, "SWIG_classWrapper", sizeof("SWIG_classWrapper") - 1, &zv);
}
obj->newobject = userNewObj;
}
@ -252,7 +266,7 @@ SWIG_generalize_object(zval *zval_obj, void *ptr, int class_obj, int 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) {
if (class_obj == 1) {
SWIG_generalize_object(class_zv, ptr, class_obj, userNewObj ,type);
return;
}
@ -268,7 +282,10 @@ SWIG_SetZval( zval *zv, zval *class_zv, int userNewObj ,int object, int class_ob
}
if (object == 2) {
SWIG_SetPointerZval(zv,ptr,type,class_obj);
int newobj = class_obj;
if (class_obj == 2)
newobj = 1;
SWIG_SetPointerZval(zv,ptr,type,newobj);
}
}

View file

@ -152,7 +152,7 @@ static void print_creation_free_wrapper(int item_index) {
need_free = true;
Printf(s_header, "/* class entry for %s */\n",class_name);
Printf(s_header, "zend_class_entry *%s_ce;\n\n",class_name);
Printf(s_header, "zend_class_entry *SWIGTYPE_%s_ce;\n\n",class_name);
Printf(s_header, "/* class object handlers for %s */\n",class_name);
Printf(s_header, "zend_object_handlers %s_object_handlers;\n\n",class_name);
@ -182,6 +182,7 @@ static void print_creation_free_wrapper(int item_index) {
Printf(s_header, "zend_object * %s_object_new(zend_class_entry *ce) {\n",class_name);
Printf(s_header, " swig_object_wrapper *obj = (swig_object_wrapper *)ecalloc(1,sizeof(swig_object_wrapper) + zend_object_properties_size(ce));\n");
Printf(s_header, " zend_object_std_init(&obj->std, ce);\n");
//Printf(s_header, " object_properties_init(&obj->std, ce);\n");
Printf(s_header, " %s_object_handlers.offset = XtOffsetOf(swig_object_wrapper, std);\n",class_name);
Printf(s_header, " %s_object_handlers.free_obj = %s_free_storage;\n",class_name,class_name);
Printf(s_header, " %s_object_handlers.dtor_obj = %s_destroy_object;\n",class_name,class_name);
@ -797,10 +798,11 @@ public:
Append(arginfo_code, GetFlag(p, "tmap:in:byref") ? "1" : "0");
}
int numberOfParams = Len(arginfo_code);
if (!GetFlag(arginfo_used, arginfo_code)) {
// Not had this one before, so emit it.
SetFlag(arginfo_used, arginfo_code);
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 0)\n", arginfo_code);
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, %d)\n", arginfo_code, numberOfParams);
for (const char * p = Char(arginfo_code); *p; ++p) {
Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%c)\n", *p);
}
@ -875,6 +877,8 @@ public:
String *f = NewString("");
int constructorOverload = (Cmp(Getattr(n, "nodeType"), "constructor") == 0);
/* Get a list of methods ranked by precedence values and argument count */
List *dispatch = Swig_overload_rank(n, true);
int nfunc = Len(dispatch);
@ -887,10 +891,12 @@ public:
bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0;
int num_required = emit_num_required(pi)-1;
int num_arguments = emit_num_arguments(pi)-1;
if (GetFlag(n, "wrap:this")) {
if (constructorOverload) {
num_required++;
num_arguments++;
}
if (num_arguments > *maxargs)
*maxargs = num_arguments;
@ -907,7 +913,8 @@ public:
int num_braces = 0;
j = 0;
Parm *pj = pi;
pj = nextSibling(pj);
if (!constructorOverload && pj)
pj = nextSibling(pj);
while (pj) {
if (checkAttribute(pj, "tmap:in:numinputs", "0")) {
pj = Getattr(pj, "tmap:in:next");
@ -967,15 +974,11 @@ public:
/* ------------------------------------------------------------
* dispatchFunction()
* ------------------------------------------------------------ */
void dispatchFunction(Node *n) {
void dispatchFunction(Node *n, int constructor) {
/* Last node in overloaded chain */
int maxargs;
String *tmp = NewStringEmpty();
if (Swig_directorclass(n) && wrapperType == directorconstructor) {
/* We have an extra 'this' parameter. */
SetFlag(n, "wrap:this");
}
String *dispatch = NULL;
@ -991,8 +994,10 @@ public:
String *wname = NULL;
String *modes = NULL;
if (class_name)
wname = getWrapperMethodName(Getattr(n, "name"), symname);
if (constructor)
wname = NewString("__construct");
else if (class_name)
wname = getWrapperMethodName(class_name, symname);
else
wname = Swig_name_wrapper(symname);
@ -1068,6 +1073,16 @@ public:
return r;
}
/* Helper function to check if class is wrapped */
bool is_class_wrapped(String *className) {
Iterator iterate;
for (iterate = First(classes); iterate.item; iterate = Next(iterate)) {
if (Cmp(iterate.item, className) == 0)
return true;
}
return false;
}
/* Is special return type */
bool is_param_type_pointer(SwigType *t) {
@ -1097,7 +1112,7 @@ public:
if (!GetFlag(arginfo_used, arginfo_code)) {
// Not had this one before, so emit it.
SetFlag(arginfo_used, arginfo_code);
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 0)\n", arginfo_code);
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 1)\n", arginfo_code);
for (const char * p = Char(arginfo_code); *p; ++p) {
Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%c)\n", *p);
}
@ -1111,7 +1126,7 @@ public:
if (!GetFlag(arginfo_used, arginfo_code)) {
// Not had this one before, so emit it.
SetFlag(arginfo_used, arginfo_code);
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 0)\n", arginfo_code);
Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 2)\n", arginfo_code);
for (const char * p = Char(arginfo_code); *p; ++p) {
Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%c)\n", *p);
}
@ -1198,7 +1213,7 @@ public:
Printf(f->code, " newSize += arg2->len + strlen(\"_get\");\nmethod_name = (char *)malloc(newSize);\n");
Printf(f->code, " strcpy(method_name,arg2->val);\nstrcat(method_name,\"_get\");\n\n");
Printf(magic_isset, "\nelse if (zend_hash_exists(&%s_ce->function_table, zend_string_init(method_name, newSize-1, 0))) {\n",class_name);
Printf(magic_isset, "\nelse if (zend_hash_exists(&SWIGTYPE_%s_ce->function_table, zend_string_init(method_name, newSize-1, 0))) {\n",class_name);
Printf(magic_isset, "RETVAL_TRUE;\n}\n");
Printf(f->code, "if (!arg2) {\n RETVAL_FALSE;\n}\n",magic_set);
@ -1277,10 +1292,13 @@ public:
modes = getAccessMode(Getattr(n, "access"));
if (constructor) {
Append(modes,"| ZEND_ACC_CTOR");
Append(modes, " | ZEND_ACC_CTOR");
}
else if (wrapperType == staticmemberfn || Cmp(Getattr(n, "storage"),"static") == 0)
Append(modes,"| ZEND_ACC_STATIC");
Append(modes, " | ZEND_ACC_STATIC");
if (GetFlag(n, "abstract") && Swig_directorclass(Swig_methodclass(n)))
Append(modes, " | ZEND_ACC_ABSTRACT");
if (Getattr(n, "sym:overloaded")) {
overloaded = 1;
@ -1335,9 +1353,13 @@ public:
}
}
else if (wrapperType == staticmemberfn) {
char *ptr = Char(iname);
ptr+= strlen(Char(iname)) - strlen(strrchr(GetChar(n, "name"),':') + 1);
wname = (String*) ptr;
if (Char(Strchr(name, ':'))) {
char *ptr = Char(iname);
ptr+= strlen(Char(iname)) - strlen(strrchr(GetChar(n, "name"),':') + 1);
wname = (String*) ptr;
}
else
wname = iname;
}
else {
if (class_name) {
@ -1485,13 +1507,11 @@ public:
}
String *paramType_class = NULL;
String *paramType_type = NULL;
bool paramType_valid = is_class(pt);
SwigType *resolved = SwigType_typedef_resolve_all(pt);
if (paramType_valid) {
paramType_class = get_class_name(pt);
paramType_type = Getattr(get_class_node(pt), "classtype");
Chop(paramType_class);
}
@ -1514,9 +1534,10 @@ public:
Printf(param_zval, "getThis()");
else
Printf(param_zval, "&%s", source);
Printf(param_value, "(%s *) SWIG_Z_FETCH_OBJ_P(%s)->ptr", paramType_type , param_zval);
Printf(param_value, "%sSWIG_Z_FETCH_OBJ_P(%s)->ptr", SwigType_isreference(pt) ? "&" : "", param_zval);
Replaceall(tm, "$obj_value", param_value);
}
Replaceall(tm, "$needNewFlow", paramType_valid ? (is_class_wrapped(paramType_class) ? "1" : "0") : "0");
String *temp_obj = NewStringEmpty();
Printf(temp_obj, "&%s", ln);
Replaceall(tm, "$obj_value", is_param_type_pointer(resolved ? resolved : pt) ? "NULL" : temp_obj); // Adding this to compile. It won't reach this if $obj_val is required.
@ -1579,6 +1600,7 @@ public:
// Replaceall(tm,"$input",Getattr(p,"lname"));
Replaceall(tm, "$target", "return_value");
Replaceall(tm, "$result", "return_value");
Replaceall(tm, "$classFlag", "0");
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
Replaceall(tm, "$input", Getattr(p, "emit:input"));
Printv(outarg, tm, "\n", NIL);
@ -1602,10 +1624,12 @@ public:
String *retType_class = NULL;
bool retType_valid = is_class(d);
bool valid_wrapped_class = false;
if (retType_valid) {
retType_class = get_class_name(d);
Chop(retType_class);
valid_wrapped_class = is_class_wrapped(retType_class);
}
/* emit function call */
@ -1617,15 +1641,16 @@ public:
Replaceall(tm, "$target", "return_value");
Replaceall(tm, "$result", "return_value");
Replaceall(tm, "$owner", newobject ? "1" : "0");
Replaceall(tm, "$needNewFlow", retType_valid ? (valid_wrapped_class ? "1" : "0") : "0");
Replaceall(tm, "$classZv", constructor ? "getThis()" : "NULL");
if (retType_class) {
String *retZend_obj = NewStringEmpty();
Printf(retZend_obj, "%s_object_new(%s_ce)", retType_class, retType_class);
Replaceall(tm, "$zend_obj", retType_valid ? (constructor ? "NULL" : retZend_obj) : "NULL");
Printf(retZend_obj, "%s_object_new(SWIGTYPE_%s_ce)", retType_class, retType_class);
Replaceall(tm, "$zend_obj", retType_valid ? (constructor ? "NULL" : (valid_wrapped_class ? retZend_obj : "NULL")) : "NULL");
}
Replaceall(tm, "$zend_obj", "NULL");
Replaceall(tm, "$newobj", retType_valid ? "1" : "2");
Replaceall(tm, "$c_obj", constructor? "1" : "0");
Replaceall(tm, "$newobj", retType_valid ? (valid_wrapped_class ? "1" : "2") : "2");
Replaceall(tm, "$c_obj", newobject? (valid_wrapped_class ? (constructor ? "1" : "0") : "2") : "0");
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);
@ -1681,7 +1706,7 @@ public:
wname = NULL;
if (overloaded && !Getattr(n, "sym:nextSibling")) {
dispatchFunction(n);
dispatchFunction(n, constructor);
}
// Handle getters and setters.
@ -2677,23 +2702,9 @@ done:
virtual int classDeclaration(Node *n) {
if (!Getattr(n, "feature:onlychildren")) {
String *className = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
Setattr(n, "php:proxy", symname);
if (className != symname)
class_name = symname;
else
class_name = className;
if (Len(classes) != 0)
Printf(all_cs_entry, " ZEND_FE_END\n};\n\n");
Printf(all_cs_entry, "static zend_function_entry class_%s_functions[] = {\n", class_name);
Append(classes,class_name);
}
return Language::classDeclaration(n);
}
@ -2706,6 +2717,15 @@ done:
return present_name;
}
/* Helper method to get names without namespace
*/
String *getNameWithoutNamespace(char *name) {
char *returnName = Char(strrchr(name, ':'));
if (!returnName)
return NULL;
return NewString(returnName + 1);
}
/* ------------------------------------------------------------
* classHandler()
* ------------------------------------------------------------ */
@ -2713,27 +2733,29 @@ done:
virtual int classHandler(Node *n) {
constructors = 0;
current_class = n;
String *className = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
String *nameSpace = NULL;
String *baseClassExtend = NULL;
bool exceptionClassFlag = false;
//check for namespaces
if (Strstr(className, ":"))
nameSpace = getNameSpace(GetChar(n, "name"));
class_name = symname;
if (Len(classes) != 0)
Printf(all_cs_entry, " ZEND_FE_END\n};\n\n");
Printf(all_cs_entry, "static zend_function_entry class_%s_functions[] = {\n", class_name);
class_type = Getattr(n, "classtype");
Append(classes,class_name);
Append(class_types, class_type);
Append(class_need_free, "0");
Printf(s_oinit, "\nzend_class_entry %s_internal_ce;\n", class_name);
Printf(s_oinit, "\nzend_class_entry SWIGTYPE_%s_internal_ce;\n", class_name);
// namespace code to introduce namespaces into wrapper classes.
//if (nameSpace != NULL)
//Printf(s_oinit, "INIT_CLASS_ENTRY(%s_internal_ce, \"%s\\\\%s\", class_%s_functions);\n", class_name, nameSpace ,class_name, class_name);
//else
Printf(s_oinit, "INIT_CLASS_ENTRY(%s_internal_ce, \"%s\", class_%s_functions);\n", class_name, class_name, class_name);
Printf(s_oinit, "INIT_CLASS_ENTRY(SWIGTYPE_%s_internal_ce, \"%s\", class_%s_functions);\n", class_name, class_name, class_name);
if (shadow) {
char *rename = GetChar(n, "sym:name");
@ -2752,7 +2774,8 @@ done:
while (base.item && GetFlag(base.item, "feature:ignore")) {
base = Next(base);
}
baseClassExtend = Getattr(base.item, "sym:name");
if (base.item)
baseClassExtend = Getattr(base.item, "sym:name");
base = Next(base);
if (base.item) {
/* Warn about multiple inheritance for additional base class(es) */
@ -2779,18 +2802,15 @@ done:
baseClassExtend = NewString(class_name);
Append(baseClassExtend, "_Exception");
Printf(s_oinit, "zend_class_entry *%s_ce = zend_lookup_class(zend_string_init(\"Exception\", sizeof(\"Exception\") - 1, 0));\n", baseClassExtend);
Printf(s_oinit, "zend_class_entry *SWIGTYPE_%s_ce = zend_lookup_class(zend_string_init(\"Exception\", sizeof(\"Exception\") - 1, 0));\n", baseClassExtend);
exceptionClassFlag = true;
}
if (baseClassExtend) {
Printf(s_oinit, "%s_ce = zend_register_internal_class_ex(&%s_internal_ce, %s_ce);\n", class_name , class_name, baseClassExtend);
if (baseClassExtend && (exceptionClassFlag || is_class_wrapped(baseClassExtend))) {
Printf(s_oinit, "SWIGTYPE_%s_ce = zend_register_internal_class_ex(&SWIGTYPE_%s_internal_ce, SWIGTYPE_%s_ce);\n", class_name , class_name, baseClassExtend);
}
else {
Printf(s_oinit, "%s_ce = zend_register_internal_class(&%s_internal_ce);\n", class_name , class_name);
}
if (Cmp(symname,className) != 0) {
Printf(s_oinit, "zend_register_class_alias_ex(\"%s\",sizeof(\"%s\"),%s_ce);\n\n",symname, symname, symname);
Printf(s_oinit, "SWIGTYPE_%s_ce = zend_register_internal_class(&SWIGTYPE_%s_internal_ce);\n", class_name , class_name);
}
{
@ -2814,11 +2834,11 @@ done:
}
Chop(append_interface);
Replaceall(append_interface, " ", ",");
Printf(s_oinit, "zend_class_implements(%s_ce, %d, %s);\n", class_name, num_interfaces, append_interface);
Printf(s_oinit, "zend_class_implements(SWIGTYPE_%s_ce, %d, %s);\n", class_name, num_interfaces, append_interface);
}
}
Printf(s_oinit, "%s_ce->create_object = %s_object_new;\n", class_name, class_name);
Printf(s_oinit, "SWIGTYPE_%s_ce->create_object = %s_object_new;\n", class_name, class_name);
Printf(s_oinit, "memcpy(&%s_object_handlers,zend_get_std_object_handlers(), sizeof(zend_object_handlers));\n", class_name);
Printf(s_oinit, "%s_object_handlers.clone_obj = NULL;\n\n", class_name);

View file

@ -1,513 +0,0 @@
checking php test-suite
checking php testcase callback (with run test)
checking php testcase li_factory (with run test)
checking php testcase php_iterator (with run test)
checking php testcase php_namewarn_rename
checking php testcase php_pragma (with run test)
checking php testcase abstract_access
checking php testcase abstract_inherit (with run test)
checking php testcase abstract_inherit_ok (with run test)
checking php testcase abstract_signature
checking php testcase abstract_typedef
checking php testcase abstract_typedef2
checking php testcase abstract_virtual
checking php testcase access_change
checking php testcase add_link (with run test)
checking php testcase aggregate
checking php testcase allowexcept
checking php testcase allprotected
checking php testcase allprotected_not
checking php testcase anonymous_bitfield
checking php testcase apply_signed_char
checking php testcase apply_strings
checking php testcase argout (with run test)
checking php testcase array_member
checking php testcase array_typedef_memberin
checking php testcase arrayref
checking php testcase arrays_dimensionless
checking php testcase arrays_global (with run test)
checking php testcase arrays_global_twodim (with run test)
checking php testcase arrays_scope (with run test)
checking php testcase autodoc
checking php testcase bloody_hell
checking php testcase bools
checking php testcase catches
checking php testcase cast_operator
checking php testcase casts (with run test)
checking php testcase char_binary
checking php testcase char_strings (with run test)
checking php testcase chartest
checking php testcase class_forward
checking php testcase class_ignore (with run test)
checking php testcase class_scope_weird
checking php testcase compactdefaultargs
checking php testcase const_const_2
checking php testcase constant_directive
checking php testcase constant_pointers
checking php testcase constover
checking php testcase constructor_copy
checking php testcase constructor_exception
checking php testcase constructor_explicit
checking php testcase constructor_ignore
checking php testcase constructor_rename
checking php testcase constructor_value
checking php testcase contract
checking php testcase conversion (with run test)
checking php testcase conversion_namespace (with run test)
checking php testcase conversion_ns_template (with run test)
checking php testcase conversion_operators
checking php testcase cplusplus_throw
checking php testcase cpp_basic (with run test)
checking php testcase cpp_enum
checking php testcase cpp_namespace
checking php testcase cpp_nodefault
checking php testcase cpp_static (with run test)
checking php testcase cpp_typedef
checking php testcase curiously_recurring_template_pattern
checking php testcase default_args
checking php testcase default_arg_values
checking php testcase default_constructor
checking php testcase defvalue_constructor
checking php testcase derived_byvalue
checking php testcase derived_nested
checking php testcase destructor_reprotected
checking php testcase director_abstract (with run test)
checking php testcase director_alternating
checking php testcase director_basic (with run test)
checking php testcase director_binary_string
checking php testcase director_classes
checking php testcase director_classic (with run test)
checking php testcase director_constructor
checking php testcase director_default (with run test)
checking php testcase director_detect (with run test)
checking php testcase director_enum (with run test)
checking php testcase director_exception (with run test)
checking php testcase director_extend (with run test)
checking php testcase director_finalizer (with run test)
checking php testcase director_frob (with run test)
checking php testcase director_ignore
checking php testcase director_keywords
checking php testcase director_namespace_clash
checking php testcase director_nested (with run test)
checking php testcase director_nspace
checking php testcase director_nspace_director_name_collision
checking php testcase director_overload
checking php testcase director_overload2
checking php testcase director_pass_by_value (with run test)
checking php testcase director_primitives
checking php testcase director_property
checking php testcase director_protected (with run test)
checking php testcase director_protected_overloaded
checking php testcase director_redefined
checking php testcase director_ref
checking php testcase director_smartptr
checking php testcase director_unroll (with run test)
checking php testcase director_using
checking php testcase director_void
checking php testcase director_wombat
checking php testcase disown
checking php testcase dynamic_cast
checking php testcase empty
checking php testcase enum_ignore
checking php testcase enum_plus
checking php testcase enum_rename
checking php testcase enum_scope_template (with run test)
checking php testcase enum_template
checking php testcase enum_thorough
checking php testcase enum_var
checking php testcase equality
checking php testcase evil_diamond (with run test)
checking php testcase evil_diamond_ns (with run test)
checking php testcase evil_diamond_prop (with run test)
checking php testcase exception_classname
checking php testcase exception_order (with run test)
checking php testcase extend
checking php testcase extend_constructor_destructor
checking php testcase extend_default
checking php testcase extend_placement
checking php testcase extend_special_variables
checking php testcase extend_template (with run test)
checking php testcase extend_template_method
checking php testcase extend_template_ns (with run test)
checking php testcase extend_typedef_class
checking php testcase extern_c
checking php testcase extern_namespace
checking php testcase extern_throws
checking php testcase expressions
checking php testcase features
checking php testcase fragments
checking php testcase friends
checking php testcase friends_template
checking php testcase funcptr_cpp
checking php testcase fvirtual
checking php testcase global_namespace
checking php testcase global_ns_arg
checking php testcase global_scope_types
checking php testcase global_vars
checking php testcase grouping (with run test)
checking php testcase ignore_parameter (with run test)
checking php testcase import_fragments
checking php testcase import_nomodule (with run test)
checking php testcase inherit
checking php testcase inherit_member
checking php testcase inherit_missing
checking php testcase inherit_same_name
checking php testcase inherit_target_language
checking php testcase inherit_void_arg
checking php testcase inline_initializer
checking php testcase insert_directive
checking php testcase keyword_rename
checking php testcase kind
checking php testcase kwargs_feature
checking php testcase langobj
checking php testcase li_attribute
checking php testcase li_attribute_template
checking php testcase li_boost_shared_ptr
checking php testcase li_boost_shared_ptr_template
checking php testcase li_boost_shared_ptr_attribute
checking php testcase li_carrays_cpp (with run test)
checking php testcase li_cdata_cpp
checking php testcase li_cpointer_cpp
checking php testcase li_std_auto_ptr
checking php testcase li_stdint
checking php testcase li_swigtype_inout
checking php testcase li_typemaps
checking php testcase li_typemaps_apply
checking php testcase li_windows
checking php testcase long_long_apply
checking php testcase memberin_extend
checking php testcase member_funcptr_galore
checking php testcase member_pointer
checking php testcase member_pointer_const
checking php testcase member_template
checking php testcase minherit
checking php testcase minherit2
checking php testcase mixed_types
checking php testcase multiple_inheritance
checking php testcase multiple_inheritance_abstract
checking php testcase multiple_inheritance_interfaces
checking php testcase multiple_inheritance_nspace
checking php testcase multiple_inheritance_shared_ptr
checking php testcase name_cxx
checking php testcase name_warnings
checking php testcase namespace_class
checking php testcase namespace_enum
checking php testcase namespace_extend
checking php testcase namespace_forward_declaration
checking php testcase namespace_nested
checking php testcase namespace_spaces
checking php testcase namespace_template
checking php testcase namespace_typedef_class
checking php testcase namespace_typemap
checking php testcase namespace_union
checking php testcase namespace_virtual_method
checking php testcase nspace
checking php testcase nspace_extend
checking php testcase naturalvar
checking php testcase naturalvar_more
checking php testcase naturalvar_onoff
checking php testcase nested_class
checking php testcase nested_directors
checking php testcase nested_comment
checking php testcase nested_ignore
checking php testcase nested_scope
checking php testcase nested_template_base
checking php testcase nested_workaround
checking php testcase newobject1 (with run test)
checking php testcase null_pointer
checking php testcase operator_overload
checking php testcase operator_overload_break
checking php testcase operator_pointer_ref
checking php testcase operbool
checking php testcase ordering
checking php testcase overload_arrays
checking php testcase overload_bool
checking php testcase overload_copy
checking php testcase overload_extend
checking php testcase overload_method
checking php testcase overload_numeric
checking php testcase overload_polymorphic
checking php testcase overload_rename (with run test)
checking php testcase overload_return_type (with run test)
checking php testcase overload_simple
checking php testcase overload_subtype
checking php testcase overload_template
checking php testcase overload_template_fast
checking php testcase pointer_reference (with run test)
checking php testcase preproc_constants (with run test)
checking php testcase primitive_ref (with run test)
checking php testcase private_assign
checking php testcase proxycode
checking php testcase protected_rename
checking php testcase pure_virtual
checking php testcase redefined
checking php testcase redefined_not
checking php testcase refcount
checking php testcase reference_global_vars
checking php testcase register_par
checking php testcase rename1
checking php testcase rename2
checking php testcase rename3
checking php testcase rename4
checking php testcase rename_rstrip_encoder
checking php testcase rename_scope (with run test)
checking php testcase rename_simple
checking php testcase rename_strip_encoder
checking php testcase rename_pcre_encoder
checking php testcase rename_pcre_enum
checking php testcase rename_predicates
checking php testcase rename_wildcard
checking php testcase restrict_cplusplus
checking php testcase return_const_value
checking php testcase return_value_scope
checking php testcase rname
checking php testcase samename
checking php testcase sizet
checking php testcase smart_pointer_const
checking php testcase smart_pointer_const2
checking php testcase smart_pointer_const_overload
checking php testcase smart_pointer_extend
checking php testcase smart_pointer_ignore
checking php testcase smart_pointer_member
checking php testcase smart_pointer_multi
checking php testcase smart_pointer_multi_typedef
checking php testcase smart_pointer_namespace
checking php testcase smart_pointer_namespace2
checking php testcase smart_pointer_not
checking php testcase smart_pointer_overload
checking php testcase smart_pointer_protected
checking php testcase smart_pointer_rename (with run test)
checking php testcase smart_pointer_simple
checking php testcase smart_pointer_static
checking php testcase smart_pointer_template_const_overload
checking php testcase smart_pointer_template_defaults_overload
checking php testcase smart_pointer_templatemethods
checking php testcase smart_pointer_templatevariables
checking php testcase smart_pointer_typedef
checking php testcase special_variables
checking php testcase special_variable_attributes
checking php testcase special_variable_macros
checking php testcase static_array_member
checking php testcase static_const_member
checking php testcase static_const_member_2
checking php testcase string_constants
checking php testcase struct_initialization_cpp
checking php testcase struct_value
checking php testcase swig_exception (with run test)
checking php testcase symbol_clash
checking php testcase template_arg_replace
checking php testcase template_arg_scope
checking php testcase template_arg_typename (with run test)
checking php testcase template_array_numeric
checking php testcase template_basic
checking php testcase template_base_template
checking php testcase template_classes
checking php testcase template_const_ref
checking php testcase template_construct (with run test)
checking php testcase template_templated_constructors
checking php testcase template_default
checking php testcase template_default2
checking php testcase template_default_arg
checking php testcase template_default_arg_overloaded
checking php testcase template_default_arg_overloaded_extend
checking php testcase template_default_arg_virtual_destructor
checking php testcase template_default_cache
checking php testcase template_default_class_parms
checking php testcase template_default_class_parms_typedef
checking php testcase template_default_inherit
checking php testcase template_default_qualify
checking php testcase template_default_vw
checking php testcase template_enum
checking php testcase template_enum_ns_inherit
checking php testcase template_enum_typedef
checking php testcase template_explicit
checking php testcase template_extend1
checking php testcase template_extend2
checking php testcase template_extend_overload
checking php testcase template_extend_overload_2
checking php testcase template_forward
checking php testcase template_inherit
checking php testcase template_inherit_abstract
checking php testcase template_int_const
checking php testcase template_keyword_in_type
checking php testcase template_methods
checking php testcase template_namespace_forward_declaration
checking php testcase template_using_directive_and_declaration_forward
checking php testcase template_nested
checking php testcase template_nested_typemaps
checking php testcase template_ns
checking php testcase template_ns2
checking php testcase template_ns3
checking php testcase template_ns4
checking php testcase template_ns_enum
checking php testcase template_ns_enum2
checking php testcase template_ns_inherit
checking php testcase template_ns_scope
checking php testcase template_partial_arg
checking php testcase template_partial_specialization
checking php testcase template_partial_specialization_typedef
checking php testcase template_qualifier
checking php testcase template_ref_type
checking php testcase template_rename
checking php testcase template_retvalue
checking php testcase template_specialization
checking php testcase template_specialization_defarg
checking php testcase template_specialization_enum
checking php testcase template_static
checking php testcase template_tbase_template
checking php testcase template_template_parameters
checking php testcase template_typedef
checking php testcase template_typedef_class_template
checking php testcase template_typedef_cplx
checking php testcase template_typedef_cplx2
checking php testcase template_typedef_cplx3
checking php testcase template_typedef_cplx4
checking php testcase template_typedef_cplx5
checking php testcase template_typedef_funcptr
checking php testcase template_typedef_inherit
checking php testcase template_typedef_ns
checking php testcase template_typedef_ptr
checking php testcase template_typedef_rec
checking php testcase template_typedef_typedef
checking php testcase template_typemaps
checking php testcase template_typemaps_typedef
checking php testcase template_typemaps_typedef2
checking php testcase template_using
checking php testcase template_virtual
checking php testcase template_whitespace
checking php testcase threads
checking php testcase threads_exception (with run test)
checking php testcase throw_exception
checking php testcase typedef_array_member
checking php testcase typedef_class
checking php testcase typedef_funcptr
checking php testcase typedef_inherit
checking php testcase typedef_mptr
checking php testcase typedef_reference (with run test)
checking php testcase typedef_scope
checking php testcase typedef_sizet
checking php testcase typedef_struct_cpp
checking php testcase typedef_typedef
checking php testcase typemap_arrays
checking php testcase typemap_array_qualifiers
checking php testcase typemap_delete
checking php testcase typemap_directorout
checking php testcase typemap_documentation
checking php testcase typemap_global_scope
checking php testcase typemap_manyargs
checking php testcase typemap_namespace
checking php testcase typemap_ns_using (with run test)
checking php testcase typemap_numinputs
checking php testcase typemap_template
checking php testcase typemap_template_parm_typedef
checking php testcase typemap_out_optimal
checking php testcase typemap_qualifier_strip
checking php testcase typemap_variables
checking php testcase typemap_various
checking php testcase typename
checking php testcase types_directive
checking php testcase unicode_strings
checking php testcase union_scope
checking php testcase using1 (with run test)
checking php testcase using2 (with run test)
checking php testcase using_composition
checking php testcase using_directive_and_declaration
checking php testcase using_directive_and_declaration_forward
checking php testcase using_extend
checking php testcase using_inherit
checking php testcase using_namespace
checking php testcase using_namespace_loop
checking php testcase using_pointers
checking php testcase using_private
checking php testcase using_protected
checking php testcase valuewrapper
checking php testcase valuewrapper_base (with run test)
checking php testcase valuewrapper_const
checking php testcase valuewrapper_opaque
checking php testcase varargs
checking php testcase varargs_overload
checking php testcase variable_replacement
checking php testcase virtual_destructor
checking php testcase virtual_poly
checking php testcase virtual_vs_nonvirtual_base (with run test)
checking php testcase voidtest
checking php testcase wallkw
checking php testcase wrapmacro (with run test)
checking php testcase director_string (with run test)
checking php testcase ignore_template_constructor
checking php testcase li_std_combinations
checking php testcase li_std_deque
checking php testcase li_std_except
checking php testcase li_std_except_as_class
checking php testcase li_std_map
checking php testcase li_std_pair
checking php testcase li_std_pair_using
checking php testcase li_std_string (with run test)
checking php testcase li_std_vector
checking php testcase li_std_vector_enum
checking php testcase li_std_vector_member_var (with run test)
checking php testcase li_std_vector_ptr
checking php testcase smart_pointer_inherit
checking php testcase template_typedef_fnc
checking php testcase template_type_namespace
checking php testcase template_opaque
checking php testcase arrays (with run test)
checking php testcase bom_utf8
checking php testcase c_delete
checking php testcase c_delete_function
checking php testcase char_constant
checking php testcase const_const
checking php testcase constant_expr
checking php testcase empty_c
checking php testcase enums
checking php testcase enum_forward
checking php testcase enum_macro
checking php testcase enum_missing
checking php testcase extern_declaration
checking php testcase funcptr
checking php testcase function_typedef
checking php testcase global_functions
checking php testcase immutable_values
checking php testcase inctest
checking php testcase infinity
checking php testcase integers
checking php testcase keyword_rename_c
checking php testcase lextype
checking php testcase li_carrays (with run test)
checking php testcase li_cdata
checking php testcase li_cmalloc
checking php testcase li_constraints
checking php testcase li_cpointer
checking php testcase li_math
checking php testcase long_long
checking php testcase memberin_extend_c
checking php testcase name
checking php testcase nested
checking php testcase nested_extend_c
checking php testcase nested_structs
checking php testcase newobject2
checking php testcase overload_extend_c
checking php testcase overload_extend2
checking php testcase preproc
checking php testcase preproc_constants_c (with run test)
checking php testcase preproc_defined
checking php testcase preproc_include
checking php testcase preproc_line_file
checking php testcase ret_by_value
checking php testcase simple_array
checking php testcase sizeof_pointer
checking php testcase sneaky1
checking php testcase string_simple
checking php testcase struct_rename
checking php testcase struct_initialization
checking php testcase typedef_struct
checking php testcase typemap_subst
checking php testcase union_parameter
checking php testcase unions
checking php testcase clientdata_prop
checking php testcase imports
checking php testcase import_stl
checking php testcase packageoption
checking php testcase mod
checking php testcase template_typedef_import
checking php testcase multi_import