Commit graph

1,750 commits

Author SHA1 Message Date
Vadim Zeitlin
8d9f3e88b2 Expand special variables in cxxcode typemap
This makes the typemap much more useful, as it can now reference the
name of the class it is being expanded for and the type of the C pointer
used by it (in principle, the latter could be recovered by using
decltype(), but this results in rather verbose code inside static
methods where a dummy pointer to the type must be constructed first, so
using another special variable seems like a simpler solution).
2021-12-07 20:54:28 +01:00
Vadim Zeitlin
e2d32f33b2 Add support for "cxxcode" typemap
This allows injecting arbitrary code into the generated C++ classes and
can be useful for defining extra constructors or operators, for example.
2021-12-07 20:54:28 +01:00
Vadim Zeitlin
fd11a591a3 Add cxx{in,out}type typemaps and use them for std::string
This makes using returning strings much simpler to use from C++ code as
the returned pointers don't have to be deleted manually -- although, of
course, this does require an extra allocation and copy and so should be
avoided for the very long strings.

Add a new runtime test showing how simple and convenient it is to use
the functions working with string using the C++ wrappers now.
2021-12-07 20:54:28 +01:00
Vadim Zeitlin
7c46ff1b6e Add "cxxheader" section to allow injecting extra C++ declarations
This can also be used to include extra C++ headers.

Document this section as well as the already existing "cheader" one.
2021-12-06 16:50:17 +01:00
Vadim Zeitlin
579c343d5f Represent enums as enums, not int, if possible
Use enum types instead of int for the enum-valued parameters and
function return values, this is more type-safe and clear for the users
of the library.

Change cpp_enum unit test to use C++ to check that C++ enum wrappers
can at least be compiled, but still use C API in it.

Note that enum whose underlying type is bigger than int still don't
work, but this is no different from what it was before, so just document
this limitation but don't do anything else about it for now.

This commit is best viewed ignoring whitespace-only changes.
2021-11-30 02:22:25 +01:00
Vadim Zeitlin
c3b262c2f7 Merge branch 'master' into C
Merge with the latest master to resolve (trivial) conflict in the
GitHub workflow file.
2021-11-27 00:20:19 +01:00
William S Fulton
a39c2695f2
Merge pull request #2100 from rex4539/typos
Fix typos
2021-11-24 18:41:26 +00:00
Vadim Zeitlin
0483e4017c Start adding C++ wrappers generation
Disable them for the test suite, as plenty things don't work yet, but
there is already more than enough code to not want to add even more
fixes to the same commit.
2021-11-23 01:29:26 +01:00
William S Fulton
9f8e9109be Update CI system wrt experimental languages 2021-11-17 22:18:06 +00:00
Dimitris Apostolou
f586d920f7
Fix typos 2021-11-17 07:07:02 +02:00
Vadim Zeitlin
e8f9bdba80 Remove wrapper aliases generation and use -namespace in the tests
The -namespace option provides a better way of using the wrapped API, so
drop the optional wrapper generation, which is useless when this option
is used and just generates many lines of unwanted junk in the header.

Update the test suite and the examples to compensate to not rely on
being able to define SWIG_DEFINE_WRAPPER_ALIASES and add -namespace
option to all C++ tests, as it's done for C# test suite, and update them
to use the correct prefix and also use the accessors for the global
variables rather than using them directly, as this is impossible when
namespace prefix is used (it would have been possible to define a
preprocessor symbol corresponding to the real variable name, but it's
arguably not worth it).

fixup! Remove wrapper aliases generation and use -namespace in the tests
2021-11-10 02:11:59 +01:00
Vadim Zeitlin
6833ead6ed Add -namespace option to use unique prefix for all wrappers
Using this option allows to prefix all exported symbols (functions,
enums and enum elements) with a prefix based on the given namespace.

Note that (global) variables can't be exported directly when using the
global namespace prefix, even if they are of C-compatible type.
2021-11-10 00:53:39 +01:00
William S Fulton
7a65f028f8 Update docs - python static members access
[skip-ci]
2021-10-20 11:53:18 +01:00
Vadim Zeitlin
2f6f6df211 Generate wrapper aliases only if requested and not by default
Defining the aliases by default results in conflicts when including
headers from multiple modules as e.g. SWIG_PendingException_get() is
defined in all of them, and could also easily result in other unwanted
clashes, so make this opt-in and update the examples and tests relying
on using the wrappers without the module prefix to define
SWIG_DEFINE_WRAPPER_ALIASES explicitly.
2021-10-20 01:57:20 +02:00
Vadim Zeitlin
45bb179407 Expand "$null" in typemaps in C backend too
This is used in some exception-related typemaps, both in SWIG itself
(although they're not used with C backend currently) and outside of it.
2021-10-07 22:03:47 +02:00
Vadim Zeitlin
b5a8ccffa3 Explicitly refuse to wrap vararg functions
They were not supported currently, but processing them resulted in just
a warning about missing ctype typemap and generated uncompilable code.

Give an error and don't generate any code at all now, which is more
clear and helpful.

Also exclude the part of kwargs_feature test using varargs from C test
suite.
2021-10-04 22:09:12 +02:00
Vadim Zeitlin
ac4f3c78be Merge branch 'master' into C
Merge with the latest master before making more changes.
2021-10-04 16:03:36 +02:00
Julien Schueller
42ed181e08 [CMake] Add option to enable pcre
Closes #2031, #2065.
2021-10-03 16:32:11 +02:00
Ian Lance Taylor
4461c443cf remove Go -no-cgo option
It only worked for Go versions before 1.5, which is more than five
years ago and long-unsupported.
2021-09-14 13:59:21 -07:00
Olly Betts
a2fc5ecaff Fix "dobule" typos in docs
Fixes #2043.
2021-07-06 10:56:48 +12:00
Olly Betts
11bb422bd3 [Pike] Remove code for Pike
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
12f3a85916 [Modula3] Remove code for Modula3
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
5f38f9cc78 [Chicken] Remove code for Chicken
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
353baebfcf [Allegrocl] Remove code for Allegro Common Lisp
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-13 10:38:40 +12:00
Olly Betts
4ca4283d33 Update PHP docs for recent changes 2021-05-06 16:02:37 +12:00
Olly Betts
2de563a32e Update details of PHP undefined constants
Since PHP 8.0 these now give an error.
2021-05-04 14:20:28 +12:00
Olly Betts
32283991c5 Don't generate a .php wrapper file by default
It's now only generated if something to put in it is specified via:

%pragma(php) include=...

or

%pragma(php) code=...
2021-05-04 14:14:56 +12:00
Olly Betts
f227e5fae4 Document extension=modulename
This works for PHP >= 7.2 and is the recommended method now as it
avoids having to specify a filename which varies between platforms.
2021-05-04 08:05:04 +12:00
Olly Betts
586eb24efe php: Stop using dl()
With modern PHP it only works with the CLI version of PHP, so it's
better to direct users to load the extension via "extension=" in
php.ini.

Suggested by ferdynator in #1529.
2021-05-03 18:42:28 +12:00
Olly Betts
c87047fd39 Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-05-03 16:17:02 +12:00
Olly Betts
9ddc9dceb7 Remove support for $source and $target
These were officially deprecated in 2001, and attempts to use them have
resulted in a warning (including a pointer to what to update them to)
for most if not all of that time.

Fixes #1984
2021-04-30 10:20:14 +12:00
Olly Betts
50426aae20 Make PHP directors work more like other languages
A PHP exception now gets translated to a C++ exception to skips over C++
code to get back to PHP, avoiding the need to gate every directorout
typemap on EG(exception).
2021-04-22 14:40:21 +12:00
Olly Betts
3e8373b09a Merge branch 'master' into gsoc2017-php7-classes-via-c-api 2021-04-21 16:05:24 +12:00
Olly Betts
f198ff0a43 Fix more "allows to" and other typos 2021-04-21 15:54:46 +12:00
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
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
e54d44c4be php: Omit closing ?> in manual and examples
PSR-12 says "The closing ?> tag MUST be omitted from files containing
only PHP".
2021-03-23 11:47:19 +13:00
Olly Betts
56d7435573 Merge branch 'php8-support'
Fixes #1929, Fixes #1978
2021-03-21 10:57:35 +13:00
Olly Betts
4c3e85fbd4 Clarify what SWIGPHP7 means 2021-03-21 10:43:06 +13:00
Erik Smistad
45c015b631 Added windows build instructions for MSYS2 2021-03-19 22:31:32 +00: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
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
William S Fulton
e0be0f7517 html chapter numbering fix 2021-03-02 00:13:56 +00:00
William S Fulton
27f29aef2c CMake documentation tweaks 2021-03-02 00:12:46 +00:00
William S Fulton
3f63848940 Move CMake chapter 2021-03-01 23:55:28 +00:00
William S Fulton
3231dd3619 Merge branch 'windows-cmake-doc'
* windows-cmake-doc:
  Remove duplicate and update to nuget installs
  Remove duplicate section
  Add link on main Contents page
  Add CMake build steps on Windows
2021-03-01 23:52:25 +00:00
William S Fulton
c3c4ec1e88 html link corrections 2021-02-24 22:07:36 +00:00
sethg
f0bf789db0 Remove duplicate and update to nuget installs 2021-02-23 13:16:07 +01:00
sethg
a1fdfe7d65 Remove duplicate section 2021-02-23 12:49:30 +01:00
sethg
da33383ea2 Add link on main Contents page 2021-02-23 00:38:41 +01:00