Commit graph

74 commits

Author SHA1 Message Date
Olly Betts
2629764e3f Remove remnants of attempts to wrap to PHP global vars
This isn't really workable since PHP doesn't support intercepting
accesses to global variables (nor to static class properties, so
we can't wrap C/C++ global variables that way either).

The _get() and _set() function wrappers actually work and have
been generated for a very long time.
2021-04-17 05:59:18 +12:00
Olly Betts
dcdaaba7ba Eliminate $zend_obj typemap variable
We can just get the zend_class_entry from the swig_type_info when
we need it.
2021-04-16 13:13:24 +12:00
Olly Betts
451998f27b Fix in typemap for void** and void*&
Mark the parameter as "byref" and write back through the reference
after the call.

Adjust testcase argout to uncomment the part that's meant to test this,
and to remove lingering traces of PHP's old call-time pass-by-reference
(which was completely removed before PHP 7).

Fixes #1457
2021-04-14 17:05:19 +12:00
Olly Betts
836258b9d3 Fix some cases of converting PHP NULL to C++ NULL
Fixes testcase overload_null for PHP 8.0
2021-04-13 16:53:52 +12:00
Olly Betts
762a309373 Fix typemap formatting incosistencies 2021-04-13 10:31:22 +12:00
Olly Betts
0a72bfc630 Eliminate tempPointer variable 2021-04-13 10:18:47 +12:00
Olly Betts
60e7deda2c Eliminate non-standard $lower_param typemap variable 2021-04-13 10:03:03 +12:00
Olly Betts
d2eb06fbc0 Merge 2 functionally identical typemaps
The only difference is code formatting.
2021-04-13 09:53:14 +12:00
Olly Betts
5161acdd24 Eliminate direct reference to c_result in typemap
Typemaps should use $result.
2021-04-13 09:07:31 +12:00
Olly Betts
3f1286ba4f Use standard SWIG overload dispatch
Instead of having a slightly modified PHP-specific variant of
Swig_overload_dispatch we now advance the ParmList over the this
pointer.
2021-03-29 17:41:01 +13:00
Olly Betts
478bdcdfbf Whitespace tweaks 2021-03-26 16:41:28 +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
c882f39e3c [php] Fix misleadingly indented void* in typemap 2021-03-26 10:06:43 +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
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
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
60eccff4b7 [php] Fix typemap indentation (cosmetic) 2019-02-11 10:49:20 +13:00
William S Fulton
b7db45661a Fix overloading for non-pointers and NULL - Php 2018-12-30 12:00:49 +00: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
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
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
11e2f53840 Object Structure approach Code
Takes care of simple class wrapping with pointers, enum, values, variables, and inheritance.
2017-07-19 20:47:53 +05:30
William S Fulton
72ba741d1c Fix wrapping of references/pointers and qualifiers to member pointers
Also fix Go wrapping of member const function pointers.
2017-03-16 21:04:38 +00:00
Olly Betts
1169874f59 [PHP] Add support for PHP7.
PHP5's C extension API has changed substantially so you need to use
-php7 to specify you want PHP7 compatible wrappers.
Fixes https://github.com/swig/swig/issues/571
2016-11-30 13:05:59 +13:00
Olly Betts
a4015acaca [PHP] Fix out typemap for member function pointers
The existing typemap was just broken - it correctly created the resource
and then did nothing with it, and instead tried to register the member
pointer as a normal pointer, which is never going to work as it's larger
than a normal pointer.

Add cpp_basic_runme.php as a regression test for this.
2016-09-02 09:51:18 +12:00
William S Fulton
98a31ff633 Fix directorin SWIGTYPE typemaps to make a copy as these are used for pass by value.
Closes #434
2016-05-14 21:32:24 +01:00
William S Fulton
4b23f5d9d4 Consistent memory initialization in php typemaps.
Memory was only initialized in C and not C++ - potential bug?
2015-07-30 20:41:20 +01:00
Olly Betts
e12322df86 [PHP] Fix throwing a PHP exception through C++ from a subclassed
director method - PHP NULL gets returned by the subclassed method
in this case, so the directorout typemap needs to allow that (at
least if an exception is active).
2014-09-11 13:09:08 -03:00
Olly Betts
cecd89f66f [PHP] The usage of $input in PHP directorout typemaps has been
changed to be consistent with other languages.  The typemaps
provided by SWIG have been updated accordingly, but if you
have written your own directorout typemaps, you'll need to
update $input to &$input (or make equivalent changes).

*** POTENTIAL INCOMPATIBILITY  ***
2013-12-12 15:40:15 +13:00
William S Fulton
bcb7aee022 Merge branch 'master' into gsoc2009-matevz
Conflicts:
	Examples/Makefile.in
	Examples/guile/Makefile.in
	Lib/php/php.swg
	Makefile.in
	Source/CParse/parser.y
	configure.ac
2013-10-10 07:26:09 +01:00
Olly Betts
939fa86627 [PHP] Add missing directorin typemap for char* and char[] which
fixes director_string testcase failure.
2013-04-09 14:35:14 +12:00
William S Fulton
e805d5f925 Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up

Conflicts:
	Doc/Devel/engineering.html
	Examples/Makefile.in
	Lib/allegrocl/allegrocl.swg
	Lib/csharp/csharp.swg
	Lib/csharp/enums.swg
	Lib/csharp/enumsimple.swg
	Lib/csharp/enumtypesafe.swg
	Lib/java/java.swg
	Lib/python/pydocs.swg
	Lib/r/rtype.swg
	Source/Include/swigwarn.h
	Source/Modules/octave.cxx
	Source/Modules/python.cxx
	Source/Modules/ruby.cxx
	Source/Swig/scanner.c
	Source/Swig/stype.c
	Source/Swig/swig.h
	configure.ac
2013-01-28 07:01:37 +00:00
William S Fulton
d3769a1fd4 Add rvalue reference typemaps 2013-01-24 20:27:28 +00:00
William S Fulton
38f6156a93 Using C++11 enum classes with just a forward reference.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13013 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-23 22:15:37 +00:00
William S Fulton
4c898b023c The 'directorin' typemap now accepts , etc expansions instead of having to use workarounds - _name, _name etc.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12879 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-12-21 07:16:44 +00:00
Olly Betts
29190559f8 SWIG_ZTS_SetPointerZval() now interprets bit 1 in newobject as meaning (wrap
in a PHP class wrapper), rather than taking newobject==2 as meaning this,
so we can wrap new and existing objects in this way.

Handle wrapping classes in a C++ namespace being returned by director methods.

No need to force classname to lowercase as zend_lookup_class() does that
internally.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12723 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-05-30 06:47:47 +00:00
Olly Betts
4fbb9e24d6 [PHP] Add casts to the typemaps for long long and unsigned long
long to avoid issues when they are used with shorter types via
%apply.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12520 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-07 04:06:54 +00:00