Commit Graph

3482 Commits

Author SHA1 Message Date
Erez Geva be5efafc1d [R] Fix use of %typemap(rtypecheck). 2023-05-23 09:49:31 +12:00
Erez Geva 7b9b5565b3 Add D language typemaps
- "char *STRING, size_t LENGTH"
 - argc and argv multi-argument

Fixes #2552

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2023-05-20 16:17:00 +12:00
Erez Geva eaabe152b3 [D] Fix to support recent D releases
Fixes #56
Fixes #2538
Fixes #2570
2023-05-20 15:22:12 +12:00
Olly Betts 707aaa8b3b Stop defining SWIGOPT_* preprocessor symbols
SWIG no longer defines preprocessor symbols corresponding to
command line options (e.g. `-module blah` was resulting in
`SWIGOPT_MODULE` being set to `blah`).  This feature was added in
2001 so that "[m]odules can look for these symbols to alter their
code generation if needed", but it's never been used for that
purpose in over 20 years, and has never been documented outside of
CHANGES.

Closes: #2595
2023-05-19 11:59:43 +12:00
Olly Betts da8d7f0ec3 Define __STDC__ to 1 rather than an empty value
The new value matches how C/C++ compilers define __STDC__.
2023-05-18 12:45:31 +12:00
Olly Betts de1327fb15 Allow defining __cplusplus on the command line
The default value for __cplusplus is now 199711L rather than defining
it to have the value __cplusplus.

Fixes #2591
2023-05-18 12:45:31 +12:00
Olly Betts ca25fa6c4e Define all predefined symbols after option parsing
We want -U to act consistently on predefined symbols and we can't
predefine all symbols before option parsing (since some rely on
options (-c++ defines __cplusplus, -python defines SWIGPYTHON,
etc) so handle them all after.
2023-05-18 12:45:31 +12:00
Olly Betts 51647c02b4 Relocate comment to where it makes sense 2023-05-18 12:45:31 +12:00
Olly Betts fba4a82865 Add new -U command line option
This undefines a preprocessor symbol.

See #2591
2023-05-18 12:45:31 +12:00
Olly Betts b8e756de4c Clean up handling of -D a little 2023-05-18 08:44:25 +12:00
Olly Betts 87a84672d6 Improve --help output for -D
Show that it takes an optional value.
2023-05-18 08:42:44 +12:00
Olly Betts 0102ff3369 Remove duplicate defining of __cplusplus 2023-05-18 08:31:16 +12:00
William S Fulton ec1a29c72e More maintainable warning message 2023-05-17 20:59:17 +01:00
Olly Betts af87945aea Clean up double spaces between words in comments 2023-05-16 09:55:49 +12:00
Olly Betts e5650d8fa4 Emit extra message for missing typecheck typemap
This has been reported too many times (#2404 #2528 #2581 recently) so
explain that this may break dispatch and link to the relevant
documentation.
2023-05-16 09:35:35 +12:00
Olly Betts 8a9628e2b9 Use strchr/Strchr for single character searches
This can be more efficient than using strstr/Strstr with a single
character search string.

GCC is able to optimise strstr() with a single character literal
search string to strchr(), but clang doesn't, and likely no compiler
can for Strstr() (unless some sort of inter-object optimisation such
as LTO is used) since the literal string is in a different source file
to the strstr() call.
2023-05-15 16:19:17 +12:00
Momtchil Momtchev 2dfa6d6b84 support check typemaps in JS 2023-05-11 23:09:19 +02:00
Olly Betts b1388bcbf9 Parse storage class more flexibly
Previously we had a hard-coded list of allowed combinations in the
grammar, but this suffers from combinatorial explosion, and results
in a vague `Syntax error in input` error for invalid (and missing)
combinations.

This means we now support a number of cases which are valid C++
but weren't supported.

Fixes #302
Fixes #2079 (friend constexpr)
Fixes #2474 (virtual explicit)
2023-05-11 13:54:30 +12:00
Olly Betts 0fa2ab8945 Removed unused default parameter value 2023-05-08 15:45:12 +12:00
Olly Betts 15b739d60e [PHP] Wrap method with both static and non-static overloads
We now wrap this as a non-static method in PHP, which means the static
form only callable via an object.

Previously this case could end up wrapped as static or non-static
in PHP.  If it was wrapped as static, attempting to call non-static
overloaded forms would crash with a segmentation fault.

See #2544
2023-05-08 15:44:24 +12:00
Olly Betts ece7ba0218 [D] Fix typo in -d2 option description 2023-05-04 13:18:26 +12:00
Erez Geva 63b1293e1a Drop D version 1
See #2538
2023-05-04 13:18:10 +12:00
Olly Betts 2860e28bd5 Fix typo: "temporal" which should be "temporary" 2023-04-27 10:35:22 +12:00
Momtchil Momtchev df2ef48ed7 try to ninja fix jsc
I don't have access to jsc atm
2023-04-26 18:26:31 +02:00
Momtchil Momtchev edd55210bb take into account numinputs when counting arguments 2023-04-26 18:23:53 +02:00
Olly Betts b508598a42 [js] Turn on C++ output for node too
Nodejs is like V8 and needs C++ output enabled when wrapping C code.

The testsuite was masking this bug by using SWIG options
`-v8 -DBUILDING_NODE_EXTENSION=1` rather than `-node` when testing
with nodejs, while the javascript examples currently all seem to all get
processed with -c++.
2023-04-22 13:33:46 +12:00
Momtchil Momtchev 64516bb2a3 use the renamed name when creating a constant 2023-04-22 08:51:27 +12:00
Olly Betts 9873ff107a Remove remaining traces of PHP7 support
The bulk of this was already removed in
e3b112c69c.
2023-04-20 13:45:30 +12:00
Clément DAVID e351d7faee scilab: add a gateway xml v6 with full function names 2023-04-20 07:34:19 +12:00
Olly Betts e3b112c69c Remove support for PHP7
PHP7 security support ended 2022-11-28 so it doesn't make sense to
include support for it in the SWIG 4.2.x release series.
2023-04-14 17:38:01 +12:00
William S Fulton 7dccbf8694 Duplicate parameter name handling improvements
When a method with duplicate parameter names is wrapped such as:

  void fn_3parms(int p_a, int p_a, double p_c);

Previously all duplicate parameter names were changed in order to
provide unique parameter names:
  void fn_3parms(int arg0, int arg1, double p_c)
Now the parameter names changed are just the 2nd and subsequent duplicate
parameter names:
  void fn_3parms(int p_a, int arg1, double p_c)
2023-02-18 16:28:33 +00:00
William S Fulton 1341df17fb Improved variadic parameter names expansion
Number the variadic parm names instead of not naming them.

Such as:
  template<typename... T> int variadicmix1(T... t) { return 20; }
  %template(variadicmix1) variadicmix1<A,B,C>;

Used to expand to:
  int variadicmix1(A T, B arg1, C arg2)
now:
  int variadicmix1(A t1, B t2, C t3)

Also test for generating duplicate parameter names which required
a fix in R. Also results in a few minor changes to parameter names
in generated R code.
2023-02-18 14:16:29 +00:00
Julien Schueller 2cc4f51f9a Avoid unused parameter self warning 2023-01-27 11:17:30 +13:00
William S Fulton c5e02bf327 Ocaml name mangling fix
Fixes testcase template_expr which was resulting in OCaml syntax errors.
2022-11-29 08:04:37 +00:00
William S Fulton 29bc7492a2 SwigType * handling corrections - Python builtin mangling
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Swig_string_mangle() takes a generic String *, but it was calling
functions that require SwigType *. Swig_string_mangle_type() is
now provided for SwigType *.

The previous commit is a pre-requisite in order to prevent duplicate
symbols from being generated in the C++ wrappers.
2022-11-18 19:44:00 +00:00
William S Fulton 4729cf2b1f Duplicate class template instantiations via %template changes
Named duplicate class template instantiations now issue a warning and are ignored.
Duplicate empty class template instantiations are quietly ignored.

The test cases are fixed for this new behaviour.

This commit is a pre-requisite for the near future so that the Python
builtin wrappers can correctly use the SwigType_namestr function without
generating duplicate symbol names.
2022-11-18 19:35:47 +00:00
William S Fulton 777fd2c280 Minor refactor of D, C#, Java director code
for overloaded methods. Fixes regression (crash) in director_ignore D
testcase since string mangling names change.
2022-11-12 16:30:25 +00:00
William S Fulton 46f2778412 Consolidate name mangling functions
Swig_string_mangle      => Swig_name_mangle_string
Swig_name_mangle        => Swig_name_mangle_string
Swig_string_mangle_type => Swig_name_mangle_type
2022-11-12 09:18:19 +00:00
William S Fulton 3364c18d06 Remove unused code in mzscheme.cxx 2022-11-12 09:06:26 +00:00
William S Fulton 6a9be797e1 SwigType * handling corrections - mangling
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Swig_string_mangle() takes a generic String *, but it was calling
functions that require SwigType *. Swig_string_mangle_type() is
now provided for SwigType *r. The special template handling
on types now occurs in this function.
2022-11-12 06:42:36 +00:00
William S Fulton 2acdfd77e9 SwigType * handling corrections
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Required reworking code that adds a fake inheritance for smart pointers
using the smartptr feature. Swig_smartptr_upcast() added as a support
function for this.
2022-11-09 22:11:27 +00:00
William S Fulton 973590ff91 R rtypecheck typemaps
Further switch to use rtypecheck typemaps instead of hard coded logic.
The full switch to typemaps is deferred until swig-4.2 as it can't be fully
backwards compatible. For now a warning is provided to help the
transition. It provides the full typemap that should be placed into
a user's interface file, for example:

%typemap("rtype") int32_t * "integer"
void testmethod(int32_t * i);
void testmethod();

If there is no rtypecheck typemap for int32_t *, the warning shown is:

example.i:7: Warning 750: Optional rtypecheck code is deprecated. Add the
following typemap to fix as the next version of SWIG will not work without it:
%typemap("rtypecheck") int32_t * %{ (is.integer($arg) || is.numeric($arg)) %}

The warning is shown for any code that previously used "numeric", "integer" or
"character" for the rtype typemap. Copying the rtypecheck typemap as
shown into the user interface file will provide the appropriate fix and
the warning will disappear. This is important to do as swig-4.2 will
not be able to provide this helpful warning.
2022-11-05 08:40:26 +00:00
William S Fulton d6d83f4df4 Overloading fixes for R and rtypecheck typemap
- Fix for special variable $argtype expansion in rtypecheck typemap.
- Remove unnecessary () brackets when using rtypecheck typemap for
  single parameter functions.
- Add rtypecheck typemaps for shared_ptr so that NULL can be used
  in overloaded functions taking shared_ptr.
2022-11-05 08:40:26 +00:00
William S Fulton f2da4f2ade Improve R wrapper error message calling overloaded methods
when incorrect types passed are passed to the overloaded methods.

Old unhelpful error message:
  Error in f(...) : could not find function "f"

Example of new improved error message:
  Error in use_count(k) :
    cannot find overloaded function for use_count with argtypes (NULL)
2022-11-05 08:40:19 +00:00
Olly Betts df716b8f00 Document that -php7 is for PHP 7 *or later*
This was already in the manual, but not in -help output.

Fixes #2420
2022-10-31 13:41:10 +13:00
William S Fulton a5b4a4389c Merge branch 'rfix-cleaned-up'
* rfix-cleaned-up:
  Whitespace cleanup in R testcase
  R shared_ptr fixes
  align implementation of smartname to r class name
  enable test for pointerreftest fixed by 752b7e8
  switched implementation reference from java to python
  fixes from code review
  enable li_boost_shared_ptr in r-test-suite
  typo in comment
  fix naming of RClass when template of a shared_ptr
2022-10-24 19:39:34 +01:00
William S Fulton 6c4dcbb8fe R shared_ptr fixes
Fix problems in shared_ptr wrappers where the class names were
not consistent when using the shared_ptr template or the actual
underlying type. Move $R_class substitution to typemaps.

Issue #2386
2022-10-24 19:37:56 +01:00
William S Fulton 4a8f7a9c46 Visual C++ warning fixes 2022-10-24 18:43:31 +01:00
AndLLA 0fec14ba34 align implementation of smartname to r class name 2022-10-24 18:20:10 +01:00
AndLLA b885c22f11 fixes from code review 2022-10-24 18:20:10 +01:00