Commit graph

208 commits

Author SHA1 Message Date
Olly Betts
4aff93942a Improve arginfo generation
Fixes some failing examples and testcases.
2021-03-26 15:34:29 +13:00
Olly Betts
f77113ea71 php: Eliminate SWIG_ZEND_NAMED_FE
It existed to work around const-correctness issues in older versions of
PHP's C API.  It's conceivable user code might be using it, but unlikely
and the switch to creating classes via the API is a natural time for a
compatibility break.
2021-03-26 13:58:02 +13:00
Olly Betts
2ba0f82720 Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-03-26 12:00:59 +13:00
Olly Betts
b840911410 Remove outdated FIXME/TODO from php.cxx
See #1529
2021-03-26 11:18:07 +13:00
Olly Betts
8ded9d8dae Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-03-25 17:45:17 +13:00
Olly Betts
d15fe23c5f Merge branch 'gsoc2017-php7-classes-via-c-api' of https://github.com/nihal95/swig into gsoc2017-php7-classes-via-c-api 2021-03-25 16:25:33 +13:00
Olly Betts
786efd0ae0 Eliminate irrelevant formatting differences from master 2021-03-24 11:59:25 +13:00
Olly Betts
3584c7d49c Add initial support for PHP8
Testcase director_overload2 is failing, but the rest of the testsuite
passes.
2021-03-19 19:30:27 +13:00
Olly Betts
2e7da86b2c php: Fix overloaded directed methods with non-void return
We were treating  such methods like constructors and assigning to the
internal _cPtr, which just seems bizarrely wrong.

Fixes #1900
2021-03-18 10:58:44 +13:00
William S Fulton
2cf075558c Replace all exit() with SWIG_exit()
For consistent cleanup on error
2019-07-31 00:08:49 +01:00
Frederik Schubert
b3a3c4f09e Don't add a closing php-tag
This PR removes the closing `?>` PHP tag from generated files. [PSR-2](https://www.php-fig.org/psr/psr-2/) states:

> The closing `?>` tag MUST be omitted from files containing only PHP.

A problem might occur if files with any character after the closing tag are used with `include` or `require`. It might trigger an output and disallow HTTP header manipulation. See the popular [_headers already sent_](https://stackoverflow.com/a/8028987/1847340) debate on SO.
2019-05-22 11:35:08 +12:00
Olly Betts
950473d77e [php] Whitespace improvements in generated C/C++ code 2019-02-12 10:14:25 +13:00
Olly Betts
123eabf200 [PHP] Wrap renamed constructor as static method
Previously it was wrapped as a non-static method, which results in
a diagnostic from PHP if called as a static method.
2019-02-09 12:51:45 +13:00
Olly Betts
3f9ebb31b9 [PHP] Don't generate code referencing undefined $r
This could happen in overloaded methods which returned void and took at
least one const std::string& parameter.
2019-02-08 18:09:52 +13:00
William S Fulton
df86ec5af6 Consistent use of target language version of options
If a version number is supported by the target language prefer to show it in the -help.
For example, -perl5 instead of -perl.
2019-02-05 19:18:46 +00:00
William S Fulton
29d30bd319 Consistent implementation for disabled languages
The deprecated php4 and php5 use the new Disabled language handling
recently implemented for a consistent implementation
2019-02-05 19:04:59 +00:00
Olly Betts
d7ac8581b1 [php] Drop support for long-deprecated %pragma(php4)
Finally removed support for %pragma(php4) which was deprecated back in
2008.  The replacement is %pragma(php), which has been supported since
at least 2005.
2018-06-07 18:09:14 +12:00
Olly Betts
d6d5db122b Remove support for PHP5
PHP5 is no longer actively supported by the PHP developers and security
support for it ends completely at the end of 2018, so it doesn't make
sense to include support for it in the upcoming SWIG 4.0.0 release.

See #701.
2018-06-07 18:09:03 +12:00
Olly Betts
224bb9e023 [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals
This should make the generated code work with PHP 7.2.0.
2017-12-08 15:50:14 +13:00
William S Fulton
ae044c1c2f Generation of director method declarations fixes
- Fixes generation of director method declarations containing C++11 ref-qualifiers.
- Fixes generation of director method declarations returning more complex types such
  as const ref pointers.
- Rewrite Swig_method_call to use more up to date code in the core.
2017-10-23 18:55:14 +01:00
William S Fulton
3f8b8fe734 Enhancements for directorin typemaps
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }

The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
2017-10-16 19:28:27 +01:00
Olly Betts
0c56d0cb72 [PHP] Fix incorrect wrapper code generation
Fix code generated when there's a combination of overloading, parameters
with a default value and %newobject.  Fixes
https://sourceforge.net/p/swig/bugs/1350/
2017-10-09 10:40:27 +13:00
Nihal
6c3f5155b2 Refactor declarations inside if-else block.
- This is to support C90
2017-09-23 12:13:20 +05:30
Nihal
d1f7ad5af5 Fix evil_diamond_prop test case.
- This fixes the problem of no reaching parent class variables.

Note: Any extra variables set by __set function are stored in the parent class's extras
hastable under swig_object_wrapper.
2017-09-22 09:26:17 +05:30
Nihal
7e66388cf3 Fix director_basic test case
- This fixes director_basic test case. Uses the new flow in director class methods.
- It also correctly fixes the double free problem in director_detect.
2017-09-14 01:23:18 +05:30
Nihal
9451f52f74 Fix global_scope_types test case.
- Problem with Dingaling ambiguous class/struct.
2017-09-13 00:41:35 +05:30
Nihal
98d1a2f8c5 Fix bug in *const& "in" typemaps.
- Refactored the reference check logic to Lib files.
2017-09-13 00:41:03 +05:30
Nihal
f054f76544 Bug Fix Director upcall functions to return object pointers
- Refactor php.swg to adhere to checkstyle
2017-09-03 10:29:18 +05:30
Nihal
38f282d847 Fix class-constant bug.
- zend_declare_class_constant ends up having "" values.
2017-09-02 11:02:10 +05:30
Nihal
e11b4711a7 Remove abstarct on Directed methods to allow dispatch pass through 2017-09-01 00:21:17 +05:30
Nihal
a8db1e4aa6 Remove all checks of ':' on name attribute.
- Remove use of getWrapperMethodName
2017-09-01 00:19:56 +05:30
Nihal
0343a01a8c Refactor checks/use of ':' with name attribute 2017-08-28 13:06:07 +05:30
Nihal
e4f56a8ed5 Fix operator_overload test-case
- Friend function is not under class methods.
- Also fix friend function overloading.
2017-08-28 12:22:28 +05:30
Nihal
9c40bbdb85 Refactor SWIG_SetZval to simplify the arguments. Solve constructor rename bug
- Refactor SWIG_SetZval.
- Fix the Renamed constructor - turn into static factory method bug.

Conflicts:
	Source/Modules/php.cxx
2017-08-28 11:22:51 +05:30
Nihal
aa180f2c4d Refactor code and adhere to codestyle/checkstyle.
- Remove noproxy processing code.
2017-08-28 04:07:40 +05:30
Nihal
4252b31f8f Refactor code to rename class entry variables and ConvertPtr to work with wrapped objects.
- Rename class entry variables to SWIGTYPE_class_ce
- Refactor factory code to use SWIGTYPE_class_ce to create objects
- Refactor ConvertPtr to work of wrapped class objects.
2017-08-20 01:54:07 +05:30
Nihal
9fea6fc5ac Refactor code and solve few test cases.
- Change the need of runtime check on old or new flow at wrapper generation time.
- Change the check on add ZEND_ACC_ABSTRACT to GetFlag(n, "abstract") && Swig_directorclass(Swig_methodclass(n))
  - workaround to solve abstract testcases at the moment.
- Remove redundant code in class handler for getting namespaces (Not the correct approact) and use of zend_register_class_alias_ex.
- Refactor choosing of class name to use sym:name by default.
2017-08-18 09:02:47 +05:30
Nihal
a687b020e2 Refactor code and change change enum_scope_template test to use class enums. Fix few test cases.
- Change enum_scope_template test to use class enums.
- Move the conversion of void* of ptr in swig wrapper to class pointer to Lib files.
- Synchronize between old and new flow. Old flow to accept newly created objects,
with the use of a new property SWIG_classWrapper to newly created objects.
- ZEND_BEGIN_ARG_INFO_EX to hold exact number of arguments required.
- Fix the constructor overloading bug in the in-house Swig_class_overload_dispatch function
- Add helper function to check if the class is wrapped.
- Add ZEND_ACC_ABSTRACT to virtual functions to make the class abstract.
- Change how wname is selected for staticmemberfn.
- Helper function to get names without namespace getNameWithoutNamespace.
- Fix bugs on class entry level at class handler.
  - Move all entry level code to class handler from class decleration.
  - Checking if base.item is null before using it.
  - Check if the parent class is wrapped before using its class entry.
2017-08-18 08:54:05 +05:30
Nihal
da53351cac Refactor code and introduce some functionalities.
Code Refactor
- Refactor code for return type of SWIGTYPE
- Workaround for Namespaced classes.
- Refactor code of SWIG_SetZval to take care of objects in class constructor.
- Introduce SWIG_generalize_object to generalize each object to swig object wrapper.
- Catch feature:immutable instead of feature:warnfilter - 462 for missing setter.
- Refactor code to create PHP objects for all instances of value, reference and pointer return types of C++ objects.
- Introduce getAccessMode to get the Access Mode of a method for generating Wrapper.
- Refactor free_object creation to include need_free condition. This is to check if there is a need to free. (Virtual Protected Destructors)
- Support for feature:exceptionclass. Extends class Exception.
- Improve condition check in Director class constructor to distinguish between, extended class creation or not.
  Swig::Director::swig_is_overridden_method is used.
2017-08-12 10:11:47 +05:30
Nihal
a930743932 Refactor Code and Support phpinterfaces, factory dispatch
- rewire return of type SWIGTYPE
- {NULL, NULL, NULL} to ZEND_FE_END
- feature:warnfilter - 462 of missing setter
- refactor code of return type (replaced)
- support conversion_operator
2017-08-04 23:13:19 +05:30
Nihal
67fb198b73 SWIG Director Support with Class Structure. Refactor Code to support rename.
Refactor Code
- Support Director Classes.
- %rename support of class names and method names.
- Creation and destruction methods after inline code.
- Test case check::function return true. - Needs Fixup
2017-08-01 11:01:15 +05:30
Nihal
6b8aae188f Refactor Code.
- Support different return types of pointers. - Fixup
- Support the rename functionality in class names.
- Redirect the resource destructor to the class desctructor if its a class resource - Object pointers.
2017-07-23 09:54:23 +05:30
Nihal
4c55919975 Refactor Code to use swig_object_wrapper for wrapping classes.
And use void * to store class pointers.
2017-07-19 22:52:46 +05:30
Nihal
b38e6d9584 Remove SWIG_Get_Type function usage in class constants.
Add class constant typemaps. (classconsttab)
2017-07-19 20:49:40 +05:30
Nihal
a71b349204 Add overload Support.
Use in house SWIG_overload_dispatch for class overloaded methods.
2017-07-19 20:49:37 +05:30
Nihal
290198495f Support Disown functionality.
Creating newobject variable under struct which stores this pointer.
Using that to implement Disown.
2017-07-19 20:49:33 +05:30
Nihal
4458040975 Refactor Code: Change Approach to emit necessary code for pointer params.
Use in typemap.
2017-07-19 20:49:26 +05:30
Nihal
c6cfad2aab Remove SWIG_Get_Type in magic getter and setter methods.
Use respective getter and setter methods.
2017-07-19 20:49:22 +05:30
Nihal
de31666c3a Fixup: Remove TRMS Stuff (Not used in PHP7).
Remove Cmp of class_name with NULL.
Reuse code to find "_get" (getters) methods of member variables.
2017-07-19 20:48:50 +05:30
Nihal
58aff09ebe Add magic methods support (__get, __set, and __isset) inherently to the extensions.
This to to maintain compatibility and consistency.
2017-07-19 20:48:46 +05:30