Refactor declarations inside if-else block.
- This is to support C90
This commit is contained in:
parent
d1f7ad5af5
commit
6c3f5155b2
3 changed files with 46 additions and 44 deletions
|
|
@ -99,10 +99,9 @@
|
||||||
/* If exit was via exception, PHP NULL is returned so skip the conversion. */
|
/* If exit was via exception, PHP NULL is returned so skip the conversion. */
|
||||||
if (!EG(exception)) {
|
if (!EG(exception)) {
|
||||||
if ($needNewFlow) {
|
if ($needNewFlow) {
|
||||||
swig_object_wrapper *obj = SWIG_Z_FETCH_OBJ_P(result);
|
tmp = ($&1_ltype) &SWIG_Z_FETCH_OBJ_P(result)->ptr;
|
||||||
tmp = ($&1_ltype) &obj->ptr;
|
|
||||||
c_result = *tmp;
|
c_result = *tmp;
|
||||||
obj->newobject = 0;
|
SWIG_Z_FETCH_OBJ_P(result)->newobject = 0;
|
||||||
} else {
|
} else {
|
||||||
if (SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL)
|
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");
|
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
|
||||||
|
|
@ -146,7 +145,7 @@
|
||||||
%typemap(in) SWIGTYPE *const& ($*ltype temp)
|
%typemap(in) SWIGTYPE *const& ($*ltype temp)
|
||||||
%{
|
%{
|
||||||
if ($needNewFlow) {
|
if ($needNewFlow) {
|
||||||
void *tempPointer = $obj_value;
|
tempPointer = $obj_value;
|
||||||
$1 = ($1_ltype) &tempPointer;
|
$1 = ($1_ltype) &tempPointer;
|
||||||
} else {
|
} else {
|
||||||
if (SWIG_ConvertPtr(&$input, (void **) &temp, $*1_descriptor, 0) < 0) {
|
if (SWIG_ConvertPtr(&$input, (void **) &temp, $*1_descriptor, 0) < 0) {
|
||||||
|
|
|
||||||
|
|
@ -254,16 +254,17 @@ SWIG_pack_zval(zval *zv, void *ptr, int userNewObj) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SWIG_generalize_object(zval *zval_obj, void *ptr, int userNewObj ,swig_type_info *type) {
|
SWIG_generalize_object(zval *zval_obj, void *ptr, int userNewObj ,swig_type_info *type) {
|
||||||
SWIG_pack_zval(zval_obj, ptr, userNewObj);
|
zval tempZval;
|
||||||
|
HashTable *ht = 0;
|
||||||
|
|
||||||
HashTable *ht = Z_OBJ_HT_P(zval_obj)->get_properties(zval_obj);
|
SWIG_pack_zval(zval_obj, ptr, userNewObj);
|
||||||
|
ht = Z_OBJ_HT_P(zval_obj)->get_properties(zval_obj);
|
||||||
|
|
||||||
if(ht) {
|
if(ht) {
|
||||||
zval zv;
|
ZVAL_RES(&tempZval,zend_register_resource(ptr,*(int *)(type->clientdata)));
|
||||||
ZVAL_RES(&zv,zend_register_resource(ptr,*(int *)(type->clientdata)));
|
zend_hash_str_add(ht, "_cPtr", sizeof("_cPtr") - 1, &tempZval);
|
||||||
zend_hash_str_add(ht, "_cPtr", sizeof("_cPtr") - 1, &zv);
|
ZVAL_TRUE(&tempZval);
|
||||||
ZVAL_TRUE(&zv);
|
zend_hash_str_add(ht, "SWIG_classWrapper", sizeof("SWIG_classWrapper") - 1, &tempZval);
|
||||||
zend_hash_str_add(ht, "SWIG_classWrapper", sizeof("SWIG_classWrapper") - 1, &zv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,9 @@ static void print_creation_free_wrapper(int item_index) {
|
||||||
|
|
||||||
Printf(s_header, "/* Garbage Collection Method for class %s */\n",class_name);
|
Printf(s_header, "/* Garbage Collection Method for class %s */\n",class_name);
|
||||||
Printf(s_header, "void %s_free_storage(zend_object *object) {\n",class_name);
|
Printf(s_header, "void %s_free_storage(zend_object *object) {\n",class_name);
|
||||||
Printf(s_header, " if(!object)\n\t return;\n");
|
Printf(s_header, " swig_object_wrapper *obj = 0;\n\n");
|
||||||
Printf(s_header, " swig_object_wrapper *obj = (swig_object_wrapper *)php_fetch_object(object);\n");
|
Printf(s_header, " if(!object)\n\t return;\n\n");
|
||||||
|
Printf(s_header, " obj = (swig_object_wrapper *)php_fetch_object(object);\n\n");
|
||||||
Printf(s_header, " if(!obj->newobject)\n\t return;\n");
|
Printf(s_header, " if(!obj->newobject)\n\t return;\n");
|
||||||
|
|
||||||
if (need_free) {
|
if (need_free) {
|
||||||
|
|
@ -1155,7 +1156,7 @@ public:
|
||||||
Printf(f->code, "PHP_METHOD(%s,__set) {\n",class_name);
|
Printf(f->code, "PHP_METHOD(%s,__set) {\n",class_name);
|
||||||
|
|
||||||
Printf(f->code, " swig_object_wrapper *arg = (swig_object_wrapper *)SWIG_Z_FETCH_OBJ_P(getThis());\n");
|
Printf(f->code, " swig_object_wrapper *arg = (swig_object_wrapper *)SWIG_Z_FETCH_OBJ_P(getThis());\n");
|
||||||
Printf(f->code, " zval args[2];\n zend_string *arg2 = 0;\n\n");
|
Printf(f->code, " zval args[2];\n zval tempZval;\n zend_string *arg2 = 0;\n\n");
|
||||||
Printf(f->code, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n");
|
Printf(f->code, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n");
|
||||||
Printf(f->code, "\tWRONG_PARAM_COUNT;\n}\n\n");
|
Printf(f->code, "\tWRONG_PARAM_COUNT;\n}\n\n");
|
||||||
Printf(f->code, " if(!arg) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n\n");
|
Printf(f->code, " if(!arg) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n\n");
|
||||||
|
|
@ -1190,7 +1191,7 @@ public:
|
||||||
Printf(f->code, "PHP_METHOD(%s,__get) {\n",class_name);
|
Printf(f->code, "PHP_METHOD(%s,__get) {\n",class_name);
|
||||||
|
|
||||||
Printf(f->code, " swig_object_wrapper *arg = (swig_object_wrapper *)SWIG_Z_FETCH_OBJ_P(getThis());\n", class_name);
|
Printf(f->code, " swig_object_wrapper *arg = (swig_object_wrapper *)SWIG_Z_FETCH_OBJ_P(getThis());\n", class_name);
|
||||||
Printf(f->code, " zval args[1];\n zend_string *arg2 = 0;\n\n");
|
Printf(f->code, " zval args[1];\n zval tempZval;\n zend_string *arg2 = 0;\n\n");
|
||||||
Printf(f->code, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
Printf(f->code, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
||||||
Printf(f->code, "\tWRONG_PARAM_COUNT;\n}\n\n");
|
Printf(f->code, "\tWRONG_PARAM_COUNT;\n}\n\n");
|
||||||
Printf(f->code, " if(!arg) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n\n");
|
Printf(f->code, " if(!arg) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n\n");
|
||||||
|
|
@ -1224,7 +1225,7 @@ public:
|
||||||
Printf(f->code, "PHP_METHOD(%s,__isset) {\n",class_name);
|
Printf(f->code, "PHP_METHOD(%s,__isset) {\n",class_name);
|
||||||
|
|
||||||
Printf(f->code, " swig_object_wrapper *arg = (swig_object_wrapper *)SWIG_Z_FETCH_OBJ_P(getThis());\n", class_name);
|
Printf(f->code, " swig_object_wrapper *arg = (swig_object_wrapper *)SWIG_Z_FETCH_OBJ_P(getThis());\n", class_name);
|
||||||
Printf(f->code, " zval args[1];\n zend_string *arg2 = 0;\n\n");
|
Printf(f->code, " zval args[1];\n zval tempZval;\n zend_string *arg2 = 0;\n\n");
|
||||||
Printf(f->code, " int newSize = 1;\nchar *method_name = 0;\n\n");
|
Printf(f->code, " int newSize = 1;\nchar *method_name = 0;\n\n");
|
||||||
Printf(f->code, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
Printf(f->code, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
||||||
Printf(f->code, "\tWRONG_PARAM_COUNT;\n}\n\n");
|
Printf(f->code, "\tWRONG_PARAM_COUNT;\n}\n\n");
|
||||||
|
|
@ -1275,12 +1276,12 @@ public:
|
||||||
String *v_name = GetChar(n, "name");
|
String *v_name = GetChar(n, "name");
|
||||||
|
|
||||||
Printf(magic_set, "\nelse if (strcmp(arg2->val,\"%s\") == 0) {\n",v_name);
|
Printf(magic_set, "\nelse if (strcmp(arg2->val,\"%s\") == 0) {\n",v_name);
|
||||||
Printf(magic_set, "zval zv;\nZVAL_STRING(&zv, \"%s_set\");\n",v_name);
|
Printf(magic_set, "ZVAL_STRING(&tempZval, \"%s_set\");\n",v_name);
|
||||||
Printf(magic_set, "CALL_METHOD_PARAM_1(zv, return_value, getThis(),args[1]);\n}\n\n");
|
Printf(magic_set, "CALL_METHOD_PARAM_1(tempZval, return_value, getThis(),args[1]);\n}\n\n");
|
||||||
|
|
||||||
Printf(magic_get, "\nelse if (strcmp(arg2->val,\"%s\") == 0) {\n",v_name);
|
Printf(magic_get, "\nelse if (strcmp(arg2->val,\"%s\") == 0) {\n",v_name);
|
||||||
Printf(magic_get, "zval zv;\nZVAL_STRING(&zv, \"%s_get\");\n",v_name);
|
Printf(magic_get, "ZVAL_STRING(&tempZval, \"%s_get\");\n",v_name);
|
||||||
Printf(magic_get, "CALL_METHOD(zv, return_value, getThis());\n}\n");
|
Printf(magic_get, "CALL_METHOD(tempZval, return_value, getThis());\n}\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1470,22 +1471,20 @@ public:
|
||||||
int num_required = emit_num_required(l);
|
int num_required = emit_num_required(l);
|
||||||
numopt = num_arguments - num_required;
|
numopt = num_arguments - num_required;
|
||||||
|
|
||||||
//if (wrapperType == directorconstructor)
|
|
||||||
//num_arguments++;
|
|
||||||
|
|
||||||
if (num_arguments > 0) {
|
if (num_arguments > 0) {
|
||||||
String *args = NewStringEmpty();
|
String *args = NewStringEmpty();
|
||||||
//if (wrapperType == directorconstructor)
|
Printf(args, "zval args[%d]", num_arguments);
|
||||||
//Wrapper_add_local(f, "arg0", "zval * arg0;");
|
Wrapper_add_local(f, "tempPointer", "void *tempPointer = 0");
|
||||||
if ((wrapperType == memberfn || wrapperType == membervar)) {
|
if ((wrapperType == memberfn || wrapperType == membervar)) {
|
||||||
num_arguments--; //To remove This Pointer
|
num_arguments--; //To remove This Pointer
|
||||||
Printf(args, "arg1 = (%s *)((SWIG_Z_FETCH_OBJ_P(getThis()))->ptr);\n", class_type);
|
|
||||||
}
|
}
|
||||||
Printf(args, "zval args[%d]", num_arguments);
|
|
||||||
Wrapper_add_local(f, "args", args);
|
Wrapper_add_local(f, "args", args);
|
||||||
Delete(args);
|
Delete(args);
|
||||||
args = NULL;
|
args = NULL;
|
||||||
}
|
}
|
||||||
|
if (wrapperType == directorconstructor) {
|
||||||
|
Wrapper_add_local(f, "arg0", "zval *arg0 = getThis()");
|
||||||
|
}
|
||||||
|
|
||||||
// This generated code may be called:
|
// This generated code may be called:
|
||||||
// 1) as an object method, or
|
// 1) as an object method, or
|
||||||
|
|
@ -1517,8 +1516,6 @@ public:
|
||||||
}
|
}
|
||||||
Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n");
|
Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n");
|
||||||
}
|
}
|
||||||
if (wrapperType == directorconstructor)
|
|
||||||
Printf(f->code, "zval * arg0 = getThis();\n \n");
|
|
||||||
|
|
||||||
/* Now convert from PHP to C variables */
|
/* Now convert from PHP to C variables */
|
||||||
// At this point, argcount if used is the number of deliberately passed args
|
// At this point, argcount if used is the number of deliberately passed args
|
||||||
|
|
@ -2782,7 +2779,7 @@ done:
|
||||||
Append(class_types, class_type);
|
Append(class_types, class_type);
|
||||||
Append(class_need_free, "0");
|
Append(class_need_free, "0");
|
||||||
|
|
||||||
Printf(s_oinit, "\nzend_class_entry SWIGTYPE_%s_internal_ce;\n", class_name);
|
Printf(s_oinit, "\n{\n zend_class_entry SWIGTYPE_%s_internal_ce;\n", class_name);
|
||||||
|
|
||||||
// namespace code to introduce namespaces into wrapper classes.
|
// namespace code to introduce namespaces into wrapper classes.
|
||||||
//if (nameSpace != NULL)
|
//if (nameSpace != NULL)
|
||||||
|
|
@ -2872,7 +2869,7 @@ done:
|
||||||
|
|
||||||
Printf(s_oinit, " SWIGTYPE_%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, " 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);
|
Printf(s_oinit, " %s_object_handlers.clone_obj = NULL;\n}\n\n", class_name);
|
||||||
|
|
||||||
classnode = n;
|
classnode = n;
|
||||||
Language::classHandler(n);
|
Language::classHandler(n);
|
||||||
|
|
@ -3185,12 +3182,17 @@ done:
|
||||||
Printf(f->def, "/* to typecast and do the actual destruction */\n");
|
Printf(f->def, "/* to typecast and do the actual destruction */\n");
|
||||||
Printf(f->def, "static void %s(zend_resource *res, const char *type_name) {\n", destructorname);
|
Printf(f->def, "static void %s(zend_resource *res, const char *type_name) {\n", destructorname);
|
||||||
|
|
||||||
Printf(f->def, "\n\nif(%d) {\n", newClassObject ? 1 : 0);
|
Wrapper_add_localv(f, "value", "swig_object_wrapper *value = 0", NIL);
|
||||||
Printf(f->def, "return;\n}\n");
|
Wrapper_add_localv(f, "ptr", "void *ptr = 0", NIL);
|
||||||
|
Wrapper_add_localv(f, "newobject", "int newobject = 0", NIL);
|
||||||
|
|
||||||
Wrapper_add_localv(f, "value", "swig_object_wrapper *value=(swig_object_wrapper *) res->ptr", NIL);
|
|
||||||
Wrapper_add_localv(f, "ptr", "void *ptr=value->ptr", NIL);
|
Printf(f->code, "if(%d) {\n", newClassObject ? 1 : 0);
|
||||||
Wrapper_add_localv(f, "newobject", "int newobject=value->newobject", NIL);
|
Printf(f->code, "return;\n}\n\n");
|
||||||
|
|
||||||
|
Printf(f->code, "value=(swig_object_wrapper *) res->ptr;\n");
|
||||||
|
Printf(f->code, "ptr=value->ptr;\n");
|
||||||
|
Printf(f->code, "newobject=value->newobject;\n\n");
|
||||||
|
|
||||||
emit_parameter_variables(l, f);
|
emit_parameter_variables(l, f);
|
||||||
emit_attach_parmmaps(l, f);
|
emit_attach_parmmaps(l, f);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue