From: <ol...@us...> - 2008-07-02 05:55:25
|
Revision: 10626 http://swig.svn.sourceforge.net/swig/?rev=10626&view=rev Author: olly Date: 2008-07-01 22:55:18 -0700 (Tue, 01 Jul 2008) Log Message: ----------- [PHP4] Support for PHP4 has been removed. The PHP developers are no longer making new PHP4 releases, and won't even be patching critical security issues after 2008-08-08. Modified Paths: -------------- trunk/CHANGES.current trunk/Source/Modules/php4.cxx trunk/Source/Modules/swigmain.cxx Modified: trunk/CHANGES.current =================================================================== --- trunk/CHANGES.current 2008-07-02 04:56:11 UTC (rev 10625) +++ trunk/CHANGES.current 2008-07-02 05:55:18 UTC (rev 10626) @@ -2,6 +2,11 @@ ============================= 2008-07-02: olly + [PHP4] Support for PHP4 has been removed. The PHP developers are + no longer making new PHP4 releases, and won't even be patching + critical security issues after 2008-08-08. + +2008-07-02: olly [Python] Import the C extension differently for Python 2.6 and later so that an implicit relative import doesn't produce a deprecation warning for 2.6 and a failure for 2.7 and later. Modified: trunk/Source/Modules/php4.cxx =================================================================== --- trunk/Source/Modules/php4.cxx 2008-07-02 04:56:11 UTC (rev 10625) +++ trunk/Source/Modules/php4.cxx 2008-07-02 05:55:18 UTC (rev 10626) @@ -13,11 +13,9 @@ * Short term: * * Sort out auto-renaming of method and class names which are reserved - * words (e.g. empty, clone, exception, etc.) vs -php4/-php5 in some - * sane way. + * words (e.g. empty, clone, exception, etc.) * - * Sort out wrapping of static member variables in OO PHP5 (which first may - * mean we need to sort them out for PHP4!) + * Sort out wrapping of static member variables in OO PHP5. * * Medium term: * @@ -50,7 +48,7 @@ #include <errno.h> static const char *usage = (char *) "\ -PHP Options (available with -php4 or -php5)\n\ +PHP Options (available with -php5)\n\ -cppext - cpp file extension (default to .cpp)\n\ -noproxy - Don't generate proxy classes.\n\ -prefix <prefix> - Prepend <prefix> to all class names in PHP5 wrappers\n\ @@ -116,9 +114,6 @@ static Hash *shadow_get_vars; static Hash *shadow_set_vars; -#define NATIVE_CONSTRUCTOR 1 -#define ALTERNATIVE_CONSTRUCTOR 2 -static int native_constructor = 0; static Hash *zend_types = 0; static int shadow = 1; @@ -295,11 +290,7 @@ } Preprocessor_define((void *) "SWIGPHP 1", 0); - if (php_version == 4) { - Preprocessor_define((void *) "SWIGPHP4 1", 0); - } else if (php_version == 5) { - Preprocessor_define((void *) "SWIGPHP5 1", 0); - } + Preprocessor_define((void *) "SWIGPHP5 1", 0); SWIG_typemap_lang("php4"); /* DB: Suggest using a language configuration file */ SWIG_config_file("php4.swg"); @@ -609,9 +600,8 @@ Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n"); Printf(f_phpcode, " if (!dl('php_%s.dll')) return;\n", module); Printf(f_phpcode, " } else {\n"); - Printf(f_phpcode, " // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.\n"); - Printf(f_phpcode, " // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.\n"); - Printf(f_phpcode, " if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') {\n"); + Printf(f_phpcode, " // PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'.\n"); + Printf(f_phpcode, " if (PHP_SHLIB_SUFFIX === 'dylib') {\n"); Printf(f_phpcode, " if (!dl('%s.so')) return;\n", module); Printf(f_phpcode, " } else {\n"); Printf(f_phpcode, " if (!dl('%s.'.PHP_SHLIB_SUFFIX)) return;\n", module); @@ -852,10 +842,6 @@ /* Just need to append function names to function table to register with PHP. */ void create_command(String *cname, String *iname) { // This is for the single main zend_function_entry record - if (shadow && php_version == 4) { - if (wrapperType != standard) - return; - } Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname); String * s = cs_entry; if (!s) s = s_entry; @@ -872,8 +858,6 @@ String *tmp = NewStringEmpty(); String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs); - int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4); - /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); @@ -890,13 +874,7 @@ Printf(f->code, "argc = ZEND_NUM_ARGS();\n"); - if (has_this_ptr) { - Printf(f->code, "argv[0] = &this_ptr;\n"); - Printf(f->code, "zend_get_parameters_array_ex(argc,argv+1);\n"); - Printf(f->code, "argc++;\n"); - } else { - Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); - } + Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); Replaceall(dispatch, "$args", "self,args"); @@ -945,8 +923,6 @@ int numopt; String *tm; Wrapper *f; - bool mvr = (shadow && php_version == 4 && wrapperType == membervar); - bool mvrset = (mvr && (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0)); String *wname; int overloaded = 0; @@ -971,40 +947,18 @@ if (overname) { Printf(wname, "%s", overname); } - // if PHP4, shadow and variable wrapper we want to snag the main contents - // of this function to stick in to the property handler... - if (mvr) { - String *php_function_name = NewString(iname); - if (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0) { - Setattr(shadow_set_vars, php_function_name, name); - } - if (Strcmp(iname, Swig_name_get(Swig_name_member(shadow_classname, name))) == 0) { - Setattr(shadow_get_vars, php_function_name, name); - } - Delete(php_function_name); - } - f = NewWrapper(); numopt = 0; String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); - if (mvr) { // do prop[gs]et header - if (mvrset) { - Printf(f->def, "static int _wrap_%s(zend_property_reference *property_reference, pval *value) {\n", iname); - } else { - Printf(f->def, "static pval _wrap_%s(zend_property_reference *property_reference) {\n", iname); - } - } else { - // regular header - // Not issued for overloaded functions or static member variables. - if (!overloaded && wrapperType != staticmembervar) { - create_command(iname, wname); - } - Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); + // Not issued for overloaded functions or static member variables. + if (!overloaded && wrapperType != staticmembervar) { + create_command(iname, wname); } + Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); emit_parameter_variables(l, f); /* Attach standard typemaps */ @@ -1018,10 +972,8 @@ int num_required = emit_num_required(l); numopt = num_arguments - num_required; - int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4); - - if (num_arguments - has_this_ptr > 0) { - String *args = NewStringf("zval **args[%d]", num_arguments - has_this_ptr); + if (num_arguments > 0) { + String *args = NewStringf("zval **args[%d]", num_arguments); Wrapper_add_local(f, "args", args); Delete(args); args = NULL; @@ -1036,34 +988,17 @@ Printf(f->code, "SWIG_ResetError();\n"); - if (has_this_ptr) - Printf(f->code, "/* This function uses a this_ptr*/\n"); - - if (native_constructor) { - if (native_constructor == NATIVE_CONSTRUCTOR) { - Printf(f->code, "/* NATIVE Constructor */\n"); - } else { - Printf(f->code, "/* ALTERNATIVE Constructor */\n"); - } - } - - if (mvr && !mvrset) { - Wrapper_add_local(f, "_return_value", "zval _return_value"); - Wrapper_add_local(f, "return_value", "zval *return_value=&_return_value"); - } - if (numopt > 0) { // membervariable wrappers do not have optional args Wrapper_add_local(f, "arg_count", "int arg_count"); Printf(f->code, "arg_count = ZEND_NUM_ARGS();\n"); Printf(f->code, "if(arg_count<%d || arg_count>%d ||\n", num_required, num_arguments); Printf(f->code, " zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)\n"); Printf(f->code, "\tWRONG_PARAM_COUNT;\n\n"); - } else if (!mvr) { - int num = num_arguments - has_this_ptr; - if (num == 0) { + } else { + if (num_arguments == 0) { Printf(f->code, "if(ZEND_NUM_ARGS() != 0) {\n"); } else { - Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num, num); + Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num_arguments, num_arguments); } Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); } @@ -1089,19 +1024,7 @@ SwigType *pt = Getattr(p, "type"); - if (mvr) { // do we assert that numargs=2, that i<2 - if (i == 0) { - source = NewString("&(property_reference->object)"); - } else { - source = NewString("&value"); - } - } else { - if (i == 0 && has_this_ptr) { - source = NewString("&this_ptr"); - } else { - source = NewStringf("args[%d]", i - has_this_ptr); - } - } + source = NewStringf("args[%d]", i); String *ln = Getattr(p, "lname"); @@ -1183,24 +1106,6 @@ Replaceall(tm, "$result", "return_value"); Replaceall(tm, "$owner", newobject ? "1" : "0"); Printf(f->code, "%s\n", tm); - // Are we returning a wrapable object? - if (shadow && php_version == 4 && is_shadow(d) && (SwigType_type(d) != T_ARRAY)) { - // Make object. - Printf(f->code, "{\n/* Wrap this return value */\n"); - Printf(f->code, "zval *_cPtr;\n"); - Printf(f->code, "ALLOC_ZVAL(_cPtr);\n"); - Printf(f->code, "*_cPtr = *return_value;\n"); - Printf(f->code, "INIT_ZVAL(*return_value);\n"); - if (native_constructor == NATIVE_CONSTRUCTOR) { - Printf(f->code, "add_property_zval(this_ptr,\"" SWIG_PTR "\",_cPtr);\n"); - } else { - String *shadowrettype = GetShadowReturnType(n); - Printf(f->code, "object_init_ex(return_value,ptr_ce_swig_%s);\n", shadowrettype); - Delete(shadowrettype); - Printf(f->code, "add_property_zval(return_value,\"" SWIG_PTR "\",_cPtr);\n"); - } - Printf(f->code, "}\n"); - } } 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); } @@ -1228,17 +1133,8 @@ Delete(tm); } + Printf(f->code, "return;\n"); - if (mvr) { - if (!mvrset) { - Printf(f->code, "return _return_value;\n"); - } else { - Printf(f->code, "return SUCCESS;\n"); - } - } else { - Printf(f->code, "return;\n"); - } - /* Error handling code */ Printf(f->code, "fail:\n"); Printv(f->code, cleanup, NIL); @@ -1638,8 +1534,8 @@ Setattr(seen, "this", seen); /* We use $r to store the return value, so disallow that as a parameter * name in case the user uses the "call-time pass-by-reference" feature - * (it's deprecated and off by default in PHP5 and even later PHP4 - * versions apparently, but we want to be maximally portable). + * (it's deprecated and off by default in PHP5, but we want to be + * maximally portable). */ Setattr(seen, "r", seen); @@ -2018,21 +1914,13 @@ current_class = n; // String *use_class_name=SwigType_manglestr(SwigType_ltype(t)); - if (shadow && php_version == 4) { + if (shadow) { char *rename = GetChar(n, "sym:name"); if (!addSymbol(rename, n)) return SWIG_ERROR; shadow_classname = NewString(rename); - cs_entry = NewStringEmpty(); - Printf(cs_entry, "/* Function entries for %s */\n", shadow_classname); - Printf(cs_entry, "static zend_function_entry %s_functions[] = {\n", shadow_classname); - if (Strcmp(shadow_classname, module) == 0) { - Printf(stderr, "class name cannot be equal to module name: %s\n", module); - SWIG_exit(1); - } - shadow_get_vars = NewHash(); shadow_set_vars = NewHash(); @@ -2054,43 +1942,6 @@ String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Php4.\n", proxyclassname, baseclassname); - base = Next(base); - } - } - } - - /* Write out class init code */ - Printf(s_vdecl, "static zend_class_entry ce_swig_%s;\n", shadow_classname); - Printf(s_vdecl, "static zend_class_entry* ptr_ce_swig_%s=NULL;\n", shadow_classname); - } else if (shadow && php_version == 5) { - char *rename = GetChar(n, "sym:name"); - - if (!addSymbol(rename, n)) - return SWIG_ERROR; - shadow_classname = NewString(rename); - - shadow_get_vars = NewHash(); - shadow_set_vars = NewHash(); - - /* Deal with inheritance */ - List *baselist = Getattr(n, "bases"); - if (baselist) { - Iterator base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - base = Next(base); - if (base.item) { - /* Warn about multiple inheritance for additional base class(es) */ - while (base.item) { - if (GetFlag(base.item, "feature:ignore")) { - base = Next(base); - continue; - } - String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); - String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); - Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number, "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname); base = Next(base); } @@ -2102,223 +1953,13 @@ Language::classHandler(n); classnode = 0; - if (shadow && php_version == 4) { + if (shadow) { DOH *key; - String *s_propget = NewStringEmpty(); - String *s_propset = NewStringEmpty(); List *baselist = Getattr(n, "bases"); Iterator ki, base; - // If no constructor was generated (abstract class) we had better - // generate a constructor that raises an error about instantiating - // abstract classes - if (Getattr(n, "abstract") && constructors == 0) { - // have to write out fake constructor which raises an error when called - abstractConstructorHandler(n); - } - - Printf(s_oinit, "/* Define class %s */\n", shadow_classname); - Printf(s_oinit, "INIT_OVERLOADED_CLASS_ENTRY(ce_swig_%s,\"%(lower)s\",%s_functions,", shadow_classname, shadow_classname, shadow_classname); - Printf(s_oinit, "NULL,_wrap_propget_%s,_wrap_propset_%s);\n", shadow_classname, shadow_classname); - - // ******** Write property SET handlers - Printf(s_header, "static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); - Printf(s_header, "static int _propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); - - Printf(s_propset, "static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value) { \n", shadow_classname); - Printf(s_propset, " zval * _value;\n"); - Printf(s_propset, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propset, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propset, " if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", shadow_classname); - Printf(s_propset, " /* set it ourselves as it is %s */\n", shadow_classname); - Printf(s_propset, " MAKE_STD_ZVAL(_value);\n"); - Printf(s_propset, " *_value=*value;\n"); - Printf(s_propset, " INIT_PZVAL(_value);\n"); - Printf(s_propset, " zval_copy_ctor(_value);\n"); - Printf(s_propset, - " return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value);\n"); - Printf(s_propset, "}\n"); - Printf(s_propset, "static int _propset_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); - - if (baselist) { base = First(baselist); - } else { - base.item = NULL; - } - - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - - ki = First(shadow_set_vars); - key = ki.key; - - // Print function header; we only need to find property name if there - // are properties for this class to look up... - if (key || !base.item) { // or if we are base class and set it ourselves - Printf(s_propset, " /* get the property name */\n"); - Printf(s_propset, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propset, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propset, " char *propname=Z_STRVAL_P(&(property->element));\n"); - } else { - if (base.item) { - Printf(s_propset, " /* No extra properties for subclass %s */\n", shadow_classname); - } else { - Printf(s_propset, " /* No properties for base class %s */\n", shadow_classname); - } - } - - while (ki.key) { - key = ki.key; - Printf(s_propset, " if (strcmp(propname,\"%s\")==0) return _wrap_%s(property_reference, value);\n", ki.item, key); - - ki = Next(ki); - } - - // If the property wasn't in this class, try the handlers of each base - // class (if any) in turn until we succeed in setting the property or - // have tried all base classes. - if (base.item) { - Printf(s_propset, " /* Try base class(es) */\n"); - while (base.item) { - Printf(s_propset, " if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", GetChar(base.item, "sym:name")); - - base = Next(base); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - } - } - Printf(s_propset, " return FAILURE;\n}\n\n"); - - // ******** Write property GET handlers - Printf(s_header, "static pval _wrap_propget_%s(zend_property_reference *property_reference);\n", shadow_classname); - Printf(s_header, "static int _propget_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); - - Printf(s_propget, "static pval _wrap_propget_%s(zend_property_reference *property_reference) {\n", shadow_classname); - Printf(s_propget, " pval result;\n"); - Printf(s_propget, " pval **_result;\n"); - Printf(s_propget, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propget, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propget, " result.type = IS_NULL;\n"); - Printf(s_propget, " if (_propget_%s(property_reference, &result)==SUCCESS) return result;\n", shadow_classname); - Printf(s_propget, " /* return it ourselves */\n"); - Printf(s_propget, - " if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) {\n"); - Printf(s_propget, " zval *_value;\n"); - Printf(s_propget, " MAKE_STD_ZVAL(_value);"); - Printf(s_propget, " *_value=**_result;\n"); - Printf(s_propget, " INIT_PZVAL(_value);\n"); - Printf(s_propget, " zval_copy_ctor(_value);\n"); - Printf(s_propget, " return *_value;\n"); - Printf(s_propget, " }\n"); - Printf(s_propget, " result.type = IS_NULL;\n"); - Printf(s_propget, " return result;\n"); - Printf(s_propget, "}\n"); - Printf(s_propget, "static int _propget_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); - - if (baselist) { - base = First(baselist); - } else { - base.item = NULL; - } - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - ki = First(shadow_get_vars); - - key = ki.key; - - // Print function header; we only need to find property name if there - // are properties for this class to look up... - if (key || !base.item) { // or if we are base class... - Printf(s_propget, " /* get the property name */\n"); - Printf(s_propget, " zend_llist_element *element = property_reference->elements_list->head;\n"); - Printf(s_propget, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); - Printf(s_propget, " char *propname=Z_STRVAL_P(&(property->element));\n"); - } else { - if (base.item) { - Printf(s_propget, " /* No extra properties for subclass %s */\n", shadow_classname); - } else { - Printf(s_propget, " /* No properties for base class %s */\n", shadow_classname); - } - } - - while (ki.key) { - key = ki.key; - Printf(s_propget, " if (strcmp(propname,\"%s\")==0) {\n", ki.item); - Printf(s_propget, " *value=_wrap_%s(property_reference);\n", key); - Printf(s_propget, " return SUCCESS;\n"); - Printf(s_propget, " }\n"); - - ki = Next(ki); - } - - // If the property wasn't in this class, try the handlers of each base - // class (if any) in turn until we succeed in setting the property or - // have tried all base classes. - if (base.item) { - Printf(s_propget, " /* Try base class(es). */\n"); - while (base.item) { - Printf(s_propget, " if (_propget_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", GetChar(base.item, "sym:name")); - - base = Next(base); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - } - } - Printf(s_propget, " return FAILURE;\n}\n\n"); - - // wrappers generated now... - - // add wrappers to output code - Printf(s_wrappers, "/* property handler for class %s */\n", shadow_classname); - Printv(s_wrappers, s_propget, s_propset, NIL); - - // Save class in class table - if (baselist) { - base = First(baselist); - } else { - base.item = NULL; - } - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - - if (base.item) { - Printf(s_oinit, - "if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,&ce_swig_%s,NULL TSRMLS_CC))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", - shadow_classname, shadow_classname, GetChar(base.item, "sym:name"), shadow_classname); - } else { - Printf(s_oinit, - "if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,NULL,NULL TSRMLS_CC))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", - shadow_classname, shadow_classname, shadow_classname); - } - Printf(s_oinit, "\n"); - - // Write the enum initialisation code in a static block - // These are all the enums defined within the C++ class. - - Delete(shadow_classname); - shadow_classname = NULL; - - Delete(shadow_set_vars); - shadow_set_vars = NULL; - Delete(shadow_get_vars); - shadow_get_vars = NULL; - - Printv(all_cs_entry, cs_entry, " { NULL, NULL, NULL}\n};\n", NIL); - Delete(cs_entry); - cs_entry = NULL; - } else if (shadow && php_version == 5) { - DOH *key; - List *baselist = Getattr(n, "bases"); - Iterator ki, base; - - if (baselist) { - base = First(baselist); while (base.item && GetFlag(base.item, "feature:ignore")) { base = Next(base); } @@ -2434,21 +2075,10 @@ * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - wrapperType = memberfn; this->Language::memberfunctionHandler(n); wrapperType = standard; - // Only declare the member function if - // we are doing shadow classes, and the function - // is not overloaded, or if it is overloaded, it is the dispatch function. - if (shadow && php_version == 4 && (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling"))) { - char *realname = iname ? iname : name; - String *php_function_name = Swig_name_member(shadow_classname, realname); - create_command(realname, Swig_name_wrapper(php_function_name)); - } return SWIG_OK; } @@ -2457,7 +2087,6 @@ * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { - wrapperType = membervar; Language::membervariableHandler(n); wrapperType = standard; @@ -2470,7 +2099,6 @@ * ------------------------------------------------------------ */ virtual int staticmembervariableHandler(Node *n) { - wrapperType = staticmembervar; Language::staticmembervariableHandler(n); wrapperType = standard; @@ -2492,12 +2120,13 @@ * would be available in php as Example::ncount() */ - // If the variable is const, then it's wrapped as a constant with set/get functions. + // If the variable is const, then it's wrapped as a constant with set/get + // functions. if (SwigType_isconst(type)) return SWIG_OK; - // This duplicates the logic from Language::variableWrapper() to test if the set wrapper - // is made. + // This duplicates the logic from Language::variableWrapper() to test if + // the set wrapper is made. int assignable = is_assignable(n); if (assignable) { String *tm = Swig_typemap_lookup("globalin", n, name, 0); @@ -2542,20 +2171,10 @@ * ------------------------------------------------------------ */ virtual int staticmemberfunctionHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - wrapperType = staticmemberfn; Language::staticmemberfunctionHandler(n); wrapperType = standard; - if (shadow && php_version == 4) { - String *symname = Getattr(n, "sym:name"); - char *realname = iname ? iname : name; - String *php_function_name = Swig_name_member(shadow_classname, realname); - create_command(symname, Swig_name_wrapper(php_function_name)); - } - return SWIG_OK; } @@ -2605,54 +2224,20 @@ return NewStringf("%s", tms); } - int abstractConstructorHandler(Node *n) { - String *iname = GetChar(n, "sym:name"); - if (shadow && php_version == 4) { - Wrapper *f = NewWrapper(); - - String *wname = NewStringf("_wrap_new_%s", iname); - create_command(iname, wname); - - Printf(f->def, "ZEND_NAMED_FUNCTION(_wrap_new_%s) {\n", iname); - Printf(f->def, " zend_error(E_ERROR,\"Cannot create swig object type: %s as the underlying class is abstract\");\n", iname); - Printf(f->def, "}\n\n"); - Wrapper_print(f, s_wrappers); - DelWrapper(f); - Delete(wname); - } + int abstractConstructorHandler(Node *) { return SWIG_OK; } + /* ------------------------------------------------------------ * constructorHandler() * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - - if (shadow && php_version == 4) { - if (iname && strcmp(iname, Char(shadow_classname)) == 0) { - native_constructor = NATIVE_CONSTRUCTOR; - } else { - native_constructor = ALTERNATIVE_CONSTRUCTOR; - } - } else { - native_constructor = 0; - } constructors++; wrapperType = constructor; Language::constructorHandler(n); wrapperType = standard; - if (shadow && php_version == 4) { - if (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling")) { - char *realname = iname ? iname : name; - String *php_function_name = Swig_name_construct(realname); - create_command(realname, Swig_name_wrapper(php_function_name)); - } - } - - native_constructor = 0; return SWIG_OK; } @@ -2763,9 +2348,14 @@ } return maininstance; } + extern "C" Language *swig_php4(void) { - return new_swig_php(4); + Printf(stderr, "*** -php4 is no longer supported.\n" + "*** Either upgrade to PHP5 or use SWIG 1.3.36 or earlier.\n"); + SWIG_exit(EXIT_FAILURE); + return NULL; // To avoid compiler warnings. } + extern "C" Language *swig_php5(void) { return new_swig_php(5); } Modified: trunk/Source/Modules/swigmain.cxx =================================================================== --- trunk/Source/Modules/swigmain.cxx 2008-07-02 04:56:11 UTC (rev 10625) +++ trunk/Source/Modules/swigmain.cxx 2008-07-02 05:55:18 UTC (rev 10626) @@ -74,8 +74,8 @@ {"-octave", swig_octave, "Octave"}, {"-perl", swig_perl5, "Perl"}, {"-perl5", swig_perl5, 0}, - {"-php", swig_php4, 0}, - {"-php4", swig_php4, "PHP4"}, + {"-php", swig_php5, 0}, + {"-php4", swig_php4, 0}, {"-php5", swig_php5, "PHP5"}, {"-pike", swig_pike, "Pike"}, {"-python", swig_python, "Python"}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |