Commit graph

4,057 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
97733543e2 Fix directorout typemap for const TYPE &
Previous we were returning a pointer or reference to a local
variable.
2021-04-15 12:50:32 +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
3b43a7bf9b Refactor to eliminate SWIG_ConvertResourcePtr() 2021-04-13 13:22:03 +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
9987d7168a Implement type-checking of wrapped objects
The testsuite now all passes (with PHP 7.4 at least)
2021-04-12 17:29:39 +12:00
Olly Betts
8fd2a1cb75 Fix mixed declarations and code
SWIG still aims to generate C90-compatible code.
2021-04-05 17:35:58 +12:00
Olly Betts
f0e0f7e391 Rename userNewObj to newobject
Better to use the same name we use elsewhere.
2021-04-05 17:30:43 +12:00
Olly Betts
40da8bcbb6 php: Wrap classes using only swig_object_wrapper
We no longer use PHP resources to wrap classes, and the proxy classes no
longer has a _cPtr property.
2021-04-04 07:45:20 +12:00
Olly Betts
e0cffb81dd Eliminate SWIG_classWrapper property
Instead set the _cPtr property to PHP NULL to signal that this object
uses swig_object_wrapper.
2021-04-01 15:10:10 +13:00
Olly Betts
5838f10aa0 wrap fake class constants via C API 2021-04-01 14:40:32 +13:00
Olly Betts
c863ca8b1f Use zstring access macros
These are likely to be more future-proof than accessing struct members
directly.
2021-03-29 18:18:37 +13:00
Olly Betts
f56d8ce103 Fix memory leak in director upcall check 2021-03-29 18:17:19 +13:00
Olly Betts
5482a02dd4 Fix handling of strongly-typed enums
Testcase cpp11_strongly_typed_enumerations.cpptest now passes.
2021-03-29 17:53:05 +13: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
4b055c343d Fix compatibility with PHP8 2021-03-28 19:46:51 +13:00
Olly Betts
b45bd65dbc Add compatibility for PHP 7.3 and earlier 2021-03-28 06:58:46 +13:00
Olly Betts
dfa5353f27 Eliminate extras hash table
This was used to store custom properties, but we can just ask the PHP
object to store them like it normally would, after checking for our
custom pseudo-properties.
2021-03-27 19:57:37 +13:00
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
56d7435573 Merge branch 'php8-support'
Fixes #1929, Fixes #1978
2021-03-21 10:57:35 +13:00
Andy Polyakov
1eebc2335a Lib/java/arrays_java.i: use actual C/C++ type in JAVA_ARRAYS_TYPEMAPS.
long long[] map was using JNI type as C/C++ type. General spirit of
JAVA_ARRAYS_TYPEMAPS is to cast individual array elements, not to
rely on potentially incompatible pointer casts.
2021-03-19 16:29:48 +01:00
Andy Polyakov
971e1154af Lib/java/javahead.swg: clean up jlong handling.
As for __int64 definition. __int64 is a non-standard Visual-C-specific
type used in win32/jni_md.h. It is defined by other Win32 compilers in
one way or another, obviously for compatibility. It's more appropriate
to give the compiler a chance to make necessary arrangements instead
of reinventing the wheel. This, giving a chance, can be achieved by
including virtually any standard header. Since jni.h includes stdio.h,
defining __int64 in javahead.swg is redundant. Since doing so actually
triggers compilation errors on MinGW if a system header is included
in the %begin section, it's arguably appropriate to omit it.

As for #undef _LP64 removal. Undefining a pre-defined macro, which
_LP64 is, is bad style, and if followed by inclusion of systems
headers, it's actually error-prone. Log suggests that it was added
to resolve a warning. I'm inclined to believe that it rather was a
misunderstanding of some kind. Or a bug in warning subsystem of
some particular compiler version, in which case it would have been
more appropriate to advise users to ignore the warning.
2021-03-19 16:29:48 +01: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
Olly Betts
4e0997cd5a Conditionalise math.i for PHP
PHP already provides all the wrapped constants and all the wrapped
functions except fabs() (PHP provides abs() instead).  Rewrapping
the constants causes warnings or errors (depending on PHP version)
and the rewrapped functions seem to be hidden by the built-in
versions, so only wrap fabs() for PHP.

(Even a wrapper for fabs() seems of little use since abs() is already
provided, but really math.i seems of little use more generally since
any general purpose programming language will provide its own maths
functions and constants - the key motivation here is to eliminate
warnings and errors from running the testsuite.)
2021-03-17 09:43:15 +13:00
William S Fulton
3f391478c4 Merge branch 'v8-context-aware-race-free-preparation'
* v8-context-aware-race-free-preparation:
  Lib/javascript/v8: use ::Cast instead of To* when possible.
  Lib/javascript/v8/javascriptrun.swg: clean up pre-processor conditions.
  Lib/javascript/jsc/javascriptinit.swg: shortcut JSGlobalContextRef casts.
  Examples/test-suite/grouping.i: resolve compiler warning.
2021-03-11 22:48:38 +00:00
William S Fulton
6aef217438 Add Javascript (JSC) support for type conversion
Fix types_directive testcase to ensure the %types code is actually
called and not just cast from one type to the other.
2021-03-11 20:18:58 +00:00
William S Fulton
04b46cc8a3 Javascript type conversion support
Add testcase for previous commit.
Add missing assert for future type conversions support that will use
the heap instead of pointer casts (for smart pointer type conversions).

Closes #1963
2021-03-11 20:10:13 +00:00
Andy Polyakov
2870e750f0 Lib/javascript/v8: use ::Cast instead of To* when possible.
If type is checked with Is*, it's safe to use corresponding ::Cast,
which is more optimal.
2021-03-10 14:51:08 +01:00
Andy Polyakov
b56814ce08 Lib/javascript/v8/javascriptrun.swg: clean up pre-processor conditions.
Harmonize javascriptcode.swg javascripthelpers.swg and clarify
documentation.
2021-03-10 14:51:08 +01:00