Commit graph

171 commits

Author SHA1 Message Date
Olly Betts
c03679acef Improve how we allocate swig_object_wrapper
Use zend_object_alloc() and put the zend_object member last so that
Zend can put object properties after it.
2021-03-26 17:15:34 +13:00
Olly Betts
d87b3fb745 Add FIXME comment
This looks to be the reason why testcases overload_null and
overload_polymorphic are failing.
2021-03-26 16:45:14 +13:00
Olly Betts
0da436aa83 Simplify assignment 2021-03-26 16:41:39 +13:00
Olly Betts
478bdcdfbf Whitespace tweaks 2021-03-26 16:41:28 +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
3fba8e7daa php: Trim trailing whitespace from PHP typemaps 2021-03-26 10:19:57 +13:00
Olly Betts
c882f39e3c [php] Fix misleadingly indented void* in typemap 2021-03-26 10:06:43 +13:00
Olly Betts
76c2c4675b [PHP] Update PHP keyword list
Add PHP keywords 'fn' (added in 7.4) and 'match' (added in 8.0) to the
list SWIG knows to automatically rename.
2021-03-26 08:24:40 +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
351f981952 [php] Fix SWIG_ZEND_CONSTANT_SET_FLAGS for PHP < 7.3 2021-03-24 12:15:39 +13:00
Olly Betts
9f84ca8a00 [php] Fix function constants for PHP 7.3
The code we were generating no longer compiled.
2021-03-24 12:15:39 +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
71475b0af9 Improve PHP object creation
Reportedly the code we were using in the directorin case gave segfaults
in PHP 7.2 and later - we've been unable to reproduce these, but the new
approach is also simpler and should be bit faster too.

Fixes #1527, #1975
2021-03-19 08:45:33 +13:00
Olly Betts
b7dedecfdd php: Fix char* typecheck typemap to accept Null
The corresponding in typemap already does.

Fixes #1655, reported by CJSlominski.
2021-03-19 08:34:15 +13:00
William S Fulton
52063a732b Consistent parameter names for std::pair 2019-02-14 22:44:27 +00:00
William S Fulton
6d27ead9c0 Add STL container copy constructors where missing
Also provide consistent copy constructor declarations.
2019-02-14 18:53:05 +00:00
William S Fulton
e26f6bb4e2 Add missing typedefs to std::vector + typedef corrections
Tests for std::vector of pointers added which check
 std::vector<T*>::const_reference and std::vector<T*>::reference
usage which gave compilation errors in Python and Perl which had
specialized these vectors incorrectly.
2019-02-13 22:46:28 +00:00
William S Fulton
a47c2553f5 Add missing typedefs to std::pair 2019-02-13 22:46:28 +00:00
William S Fulton
9dd33e6367 Add missing typedefs to std::map 2019-02-13 22:46:27 +00:00
William S Fulton
6d0c495fd0 Add missing parameter names in STL container wrappers
Mostly in STL copy constructors.

Best to have parameter names as they make their way into the wrappers in
some target languages.
2019-02-13 22:45:47 +00:00
William S Fulton
8c207dd3a9 Merge branch 'master' of git+ssh://github.com/swig/swig
* 'master' of git+ssh://github.com/swig/swig:
  [Python] Fix some errors in the documentation for -threads
  Fixed typo in Perl5 docs.
  Update PHP testsuite for vadz's new cars
  [php] Whitespace improvements in generated C/C++ code
  Fix hardcoded _v in PHP typecheck typemaps
2019-02-12 18:53:46 +00:00
William S Fulton
68e86614ff Create a consistent stl.i library file
Same file now for all languages except R which is still missing std_map.i.
Recent Java changes adding in std_set.i removed.
2019-02-12 18:46:05 +00:00
Olly Betts
950473d77e [php] Whitespace improvements in generated C/C++ code 2019-02-12 10:14:25 +13:00
Olly Betts
3499675cb0 Fix hardcoded _v in PHP typecheck typemaps
This should be $1, which ends up substituted with _v so this does
not actually affect behaviour.
2019-02-12 09:29:41 +13:00
Olly Betts
a0720885bd Remove PHP-specific avoidance of uninitialised variable
This code is no longer needed since
ebd37155a8 addressed this more
generically.
2019-02-11 10:49:20 +13:00
Olly Betts
60eccff4b7 [php] Fix typemap indentation (cosmetic) 2019-02-11 10:49:20 +13:00
Olly Betts
ab754b0c65 [PHP] Fix access to already released memory
Fix access to already released memory during PHP module  shutdown, which
often didn't cause visible problems, but could result in segmentation
faults, bus errors, etc.  Fixes #1170, reported by Jitka Plesníková.
2019-02-09 17:08:21 +13:00
Olly Betts
ce1936eb5b [php] Fix SWIG_ZEND_CONSTANT_SET_FLAGS for PHP < 7.3 2019-02-08 16:58:22 +13:00
Olly Betts
89c6c01c40 [php] Fix function constants for PHP 7.3
The code we were generating no longer compiled.
2019-02-08 14:58:01 +13:00
William S Fulton
b7db45661a Fix overloading for non-pointers and NULL - Php 2018-12-30 12:00:49 +00:00
Alexander Gabriel
ccbc16f810 PHP: Make reserved keywords to reserved function only (#1335)
[php] Make Keywords which are functions reserved functions
2018-10-29 08:41:16 +13:00
William S Fulton
ca287ae13b Add support for non-default compare template argument in std::map wrappers 2018-10-09 19:44:00 +01: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
Nihal
6c3f5155b2 Refactor declarations inside if-else block.
- This is to support C90
2017-09-23 12:13:20 +05:30
Olly Betts
0185b6114f Fix memory leaks in SWIGTYPE typemaps
The "out" and "directorin" typemaps allocate a new object, but weren't
specifying that this object should be owned.
2017-09-14 09:32:16 +12:00
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
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
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
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
Olly Betts
74a4cc8786 [php] Fix reported descriptor in typemap error message
The affected typemap is %typemap(in) SWIGTYPE *DISOWN, where the
error message was referring to $&1_descriptor but the descriptor
actually used by the typemap is $1_descriptor.
2017-08-09 11:37:03 +12:00
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
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