Commit graph

313 commits

Author SHA1 Message Date
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
Nihal
42f012b2d1 Bug Fix of double freeing. It used to create a new object for all get commands of class/struct pointers.
Now creating only if newobject is lit, or else creating a basic zend object to return to user.
2017-07-19 20:48:27 +05:30
Nihal
9addd37640 Use pre-exisiting function is_class to check a valid class/struct defenition. 2017-07-19 20:48:24 +05:30
Nihal
ce04574059 Add support to access static member variables in different way.
This is to keep compatibility and consistency with the older way.
Shape::nshapes static variable's setter and getter methods can be
accessed by Shape::nshapes(10),Shape::nshapes() respectively.
2017-07-19 20:48:19 +05:30
Nihal
4de2f257f9 Using wname variable for function name generated in .cxx or .c wrapper.
This is to ensure compatibility and consistency
2017-07-19 20:48:15 +05:30
Nihal
5e001d5288 Add class constants support to access class enums and class constants.
"flat" constants changed to class constatns.
Example: Foo_IMPULSE -> Foo::IMPULSE
2017-07-19 20:48:01 +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
Nihal
251d25346d Fix OUTPUT Typemap not having return statement bug in PHP wrapper. 2017-06-28 09:47:33 +12:00
Olly Betts
9a0180c56c Merge pull request #970 from nihal95/master
Adds pragma version directive for php5 and php7.  Fixes #360.
2017-05-16 17:47:35 +12:00
William S Fulton
ebd37155a8 Fix potential use of uninitialized variables in directors 2017-05-13 22:40:59 +01:00
Nihal
eb9e72f3b2 Add new pragma to specify version to PHP5 and PHP7 extensions.
See issue #360, feature request to have version in php5 and php7 extensions.
2017-05-08 11:43:38 +05:30
Christophe Duvernois
4777a0ad3c #526 : propagate c++11 noexcept to director classes 2017-04-27 23:37:15 +02:00
Olly Betts
0aac18b2a1 [PHP] destroy_globals function is empty, so drop
We can just pass NULL instead.
2016-12-30 16:02:01 +13:00
Olly Betts
36ee653d3b Omit module functions when there's no code
MSHUTDOWN, RINIT, RSHUTDOWN and MINFO are often empty, so check and
omit them if this is the case, and set the module structure entry to
NULL instead.  Reduces code size, number of external functions on the
module, and runtime overhead a little (RINIT and RSHUTDOWN are called
on every request when used with a webserver).
2016-12-30 15:36:08 +13:00
Olly Betts
cf60bb8895 [php7] Drop special code for PHP < 5.4 2016-12-30 14:56:53 +13:00
Olly Betts
4a2ede0820 [PHP7] Remove lingering generated ZTS code
ZTS is gone in PHP7 so these are dead code.
2016-12-30 12:41:19 +13:00
Olly Betts
2b4c1cdd5e Fix "set but not used" warning 2016-12-13 11:40:45 +13:00
Olly Betts
2aa2219f28 Fix reference example under PHP 7.1
PHP 7.1 no longer supports calling methods with fewer parameters
than declared, so we need to generate __construct() with default
values for all but the first parameter.
2016-12-06 11:01:55 +13:00
Olly Betts
da1dd2ffd2 [PHP] Pick a default dtor which can't collide 2016-12-01 15:09:53 +13:00
Olly Betts
76a98b0b1a [PHP] Emit at most one copy of the default dtor
Can reduce the wrapper source size significantly, though at least
with recent GCC the stripped compiled size seems unchanged.
2016-12-01 14:21:29 +13:00
Olly Betts
659116a1b2 Fix memory leaks introduced by previous commit 2016-12-01 14:04:10 +13:00
Olly Betts
4993991d28 [PHP] Only emit one copy of each distinct arginfo
Previously we emitted a separate one for every wrapped function,
but typically many functions have the same number of parameters
and combinations of parameters passed by reference or not.

This change significantly reduces both the size of the generated
wrapper, and of the compiled PHP extension module (e.g. by ~6% for
the stripped extension module for Xapian's PHP7 bindings).
2016-12-01 13:05:41 +13:00
Olly Betts
75a00cd15e [PHP7] Make default C++ extension .cxx
This is SWIG's default for every language except PHP, and now is a
good time to make this change so that once we drop PHP5 support, we'll
have the same default everywhere.  It's easy to override the default
with -cppext cxx to get the PHP5 behaviour.
2016-11-30 13:27:13 +13: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
1adfe2f537 [PHP] Fix code generated for feature("director:except")
Previously the return value of call_user_function() was ignored and we
checked an uninitialised value instead.  Fixes #627.  Based on patch
from Sergey Seroshtan.
2016-09-25 14:42:04 +13:00
Olly Betts
26bbc96d58 Arrange to return after calling zend_throw_exception()
Fixes github issue#240.
2016-09-16 17:54:02 +12:00
William S Fulton
ac495d5c66 Merge branch 'char-escaping'
* char-escaping:
  Add missing string_constant.i testcase
  changes file update for char wrappers
  C# char wrappers fixes for enum values, static const member char values and %csconst
  D testing added for %dmanifestconst and char constants
  Fix wrapping D constants using %dmanifestconst
  Php fix for enum value of '\0'
  Fix static const char member variables wrappers with %javaconst(1).
  Expand char testing in enums and %constant
  Java char changes file update
  Java enum and static member variable escaping fix for chars
  Add tests for enum values and static const member variables chars containing escape sequences
  Minor documentation tweak

Conflicts:
	CHANGES.current
2016-03-12 23:27:51 +00:00
William S Fulton
539aca58a5 Php fix for enum value of '\0' 2016-03-12 00:26:49 +00:00
William S Fulton
21ee09fc19 Multiple inheritance warning wording tweak 2016-03-06 10:45:39 +00:00
Petre Eftime
0a07cd4c30 Prevent redefinition warnings when compiling with SWIG<module> defined
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
2015-12-22 14:33:21 +02:00
William S Fulton
6a61f8271f Php fix for -Wmissing-field-initializers warning
Use ZEND_FE_END (introduced sometime around 5.2) to obtain the correct
number of arguments for zend_function_entry. Fallback to the original
3 argument initializer if not defined, however, this will not fix the
initializer warning though for some older versions of PHP.
2015-12-19 16:21:23 +00:00
William S Fulton
edcdaaec16 Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
Nils Gladitz
925cec3a82 Add a space between literal and string macro
In C++11 a space between a literal and string macro is required.
2015-07-03 20:59:23 +01:00
Olly Betts
7ba0652677 Create director_common.swg for language-indep code
Move -DSWIG_DIRECTOR_STATIC handling there, so this is now supported for
all languages with director support, not just Python and PHP.
2015-03-12 19:51:11 +13:00
Olly Betts
b3003f1f9f [PHP] When wrapping a returned resource as an object, check if all
cases wrap it in the same class, and if so eliminate the pointless
switch statement wrapper we previously generated.
2015-01-23 13:56:13 +13:00
Olly Betts
0dd685bad2 Fix PHP crash in director_finalizer 2015-01-14 15:38:55 +13:00
Olly Betts
ea5be4e508 Fix PHP backend for default_args testcase 2015-01-14 10:44:54 +13:00
Olly Betts
682b4dd843 [PHP] Fix segfault in director upcall check
Manifest only when using PHP built with ZTS enabled.
2015-01-12 13:53:01 +13:00
William S Fulton
06e361dbf2 Fix linux gcc warnings and strtol corrections 2015-01-11 17:30:25 +00:00
Olly Betts
cd16059c66 Provide -cppext as a general command line option
Provide -cppext as a general command line option for setting the
extension used for generated C++ files (previously it was specific
to the PHP backend).  Deprecate the equivalent -suffix option
provided by the Ocaml backend, but continue to support that for
now.
2015-01-08 10:54:37 +13:00
Olly Betts
1a99212c2c [PHP] Add support for specifying any PHP interfaces a wrapped class
implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
2014-09-12 12:48:37 -03:00
Olly Betts
14c2cf3407 PHP: Fix memory leak if a director method is passed Null for self 2014-08-29 16:28:00 -03:00
Olly Betts
73bb909bae [PHP] The generated __isset() method now returns true for read-only properties. 2014-05-01 14:37:58 +12:00
Olly Betts
36be36d618 Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
Olly Betts
f563069e7b [PHP] Fix wrapping director constructors with default parameters with a ZTS-enabled build of PHP. 2014-04-03 10:38:19 +13:00
Olly Betts
2a3981289d [PHP] Pass the ZTS context we already have to avoid needing to
call TSRMLS_FETCH, which is relatively expensive.
2014-04-02 23:35:59 +13:00