Commit Graph

24941 Commits

Author SHA1 Message Date
Olly Betts f66a81fcb4 Fix extension of filename in comments in examples 2024-09-16 16:51:44 +12:00
Olly Betts 9cba248bec Straighten out handling of integer constants
This provides a generic framework to aid converting C/C++ integer and
boolean literals to target language literals, replacing custom code in
several target language backends (and fixing some bugs in that code).
2024-09-16 16:10:02 +12:00
Olly Betts 9c8186745b No need to NULL check before Copy() 2024-09-16 15:33:35 +12:00
Olly Betts be608b81a2 Set stringval to 0 for more cases
I can't see a way any of these can cause a problem in practice, but
it's easier to reason if we're consistent about doing this.
2024-09-16 15:30:36 +12:00
Olly Betts 1b0900b511 Use ECHO_PROGRESS for C errors testcases too
Extends #2929
2024-09-16 13:21:36 +12:00
Olly Betts 4cc18abc11 Use ECHO_PROGRESS in the errors test suite too
Extends #2929
2024-09-16 13:06:22 +12:00
Olly Betts ea60dd86d9 [c] Remove redundant setting of ECHO_PROGRESS
ECHO_PROGRESS was merged as a generic feature by #2929.
2024-09-16 13:05:52 +12:00
Olly Betts 31eed9210b Document complex.i in the manual
Fixes #2560
2024-09-16 12:49:46 +12:00
Olly Betts 31c242520b Improve stringval comment 2024-09-16 08:46:45 +12:00
Olly Betts 8890e31c78 Add CHANGES.current entry
Closes #2835
2024-09-15 10:04:24 +12:00
Olly Betts e02efe25db Merge branch 'fbo/indus_doc_csharp' 2024-09-15 09:59:05 +12:00
Olly Betts 149e2ced7c CHANGES.current: Tweak most recent entry
Use the PHP type names rather than the C API symbols for them, and
specify the bug number at the start like we conventionally do.
2024-09-15 08:49:02 +12:00
Olly Betts e6e3cf6c81 Fix HTML markup problems 2024-09-15 08:29:47 +12:00
William S Fulton 9bf4842002 C++ reference errors when passing in a 'NULL' change of behaviour.
Most languages now use "NullReferenceError" in the error message
where they previously used "ValueError". Also exception changes:

Guile:    "swig-null-reference-error" instead of "swig-value-error"
MzScheme: "swig-null-reference-error" instead of "swig-value-error"
PHP:      zend_ce_type_error instead of zend_ce_value_error
Python:   Consistently raises TypeError instead of a mix of ValueError
          and TypeError.
Ruby:     Consistently raises NullReferenceError instead of a mix of
          ArgumentError and NullReferenceErrorError.

The consistent raising of a TypeError instead of ValueError for Python
ensures that incorrectly passing 'None' into a C++ reference argument
will correctly convert the error into a NotImplemented error for
the rich comparisons implementations per PEP 207. Fixes #2987

Note that the li_constraints checking implementation for the NONNULL
typemap for pointers also makes the same error change from
SWIG_ValueError to SWIG_NullReferenceError.

The D typemaps use SWIG_DNullReferenceException instead of
SWIG_DIllegalArgumentException, although this ultimately has no change
as the same D Exception is still thrown.
2024-09-14 13:03:36 +01:00
frederic.bon 3d14204513 Clean of code and fix in doxygen C# generation 2024-09-13 12:18:01 +02:00
frederic.bon 006a0fdc2e Fix in Csharp doxygen test 2024-09-13 12:17:54 +02:00
frederic.bon f638291e60 Add chapter about C# doxygen documentation 2024-09-13 12:17:45 +02:00
Olly Betts acbaa3a757 Fix typo in preproc_constants.i testcase
We were testing 0xFF + 2 a second time instead of testing 0xFF - 2.
2024-09-13 15:12:57 +12:00
Olly Betts be81e1825e Add CHANGES entry for C target language 2024-09-13 15:12:09 +12:00
Olly Betts 4ea006c4f4 Merge branch 'master' into C 2024-09-13 12:31:14 +12:00
Olly Betts 974ad73346 Remove types from tokens which don't need a type 2024-09-13 12:26:42 +12:00
Olly Betts 60969956a1 Tweak check example
Fix the incorrect parameter name in the shown generated code (the
second arg1 should be arg2), and include the parameter name in the
message.
2024-09-13 10:18:08 +12:00
Olly Betts f176f03412 Declare result before emitting check typemaps
Otherwise the code won't be valid C90.
2024-09-13 10:18:00 +12:00
Olly Betts cce4f3ac93 Use -fPIC when compiling C++ for shared library
I missed this when I fixed the C case.
2024-09-13 10:13:12 +12:00
Olly Betts 4d2ba48b75 Improve error for unexpected token
Report "Unexpected token" rather than "Illegal token" since this
error fires for certain valid C/C++ tokens when used in an invalid way
(as well as `@` and `$`, but it's reasonable to report these as
"unexpected" too).

Also we now exit after this error rather than trying to continue
parsing, which used to just lead to a potentially confusing second
error.

For example instead of:

  c_unexpected_token.i:1: Error: Illegal token '/='.
  c_unexpected_token.i:1: Error: Syntax error - possibly a missing semicolon (';').

we now report:

  c_unexpected_token.i:1: Error: Unexpected token '/='.
2024-09-13 09:39:10 +12:00
Olly Betts 0295771ab9 Drop bogus handling of SWIG_TOKEN_COMMENT in yylex
SWIG_TOKEN_COMMENT is a token value from scanner.c, but we're switching
on a parser token value here.

As the code currently is this case will never get taken since the parser
token value which gets allocated the same numeric value as
SWIG_TOKEN_COMMENT is TYPE_SIGNED, which isn't returned by yylook(), but
there's potential for compilation error if this token number was
allocated to a token which is another case in this switch, or for
incorrect behaviour if if this token number was allocated to a token
which yylook() can return which should take the default case in this
switch.

Comments are actually removed by the preprocessor, so we don't need to
concern ourselves with them here.
2024-09-13 08:25:53 +12:00
Olly Betts 46b76a47e9 Restrict use of loc token type
`INCLUDE`, `IMPORT` and `INSERT` don't need a token type, while
`includetype` doesn't use `filename` or `line` and its `type`
is better represented by an enum (which is more efficient to
compare and helps prevent it getting an invalid value).

This also means loc no longer needs a `type` field.
2024-09-13 07:47:43 +12:00
Olly Betts bc83e1bca3 Fix incorrect comment 2024-09-13 07:28:59 +12:00
Olly Betts df6f9bd1d7 [C#] Document how to hide internals with attribute
Closes #2810
2024-09-13 07:23:22 +12:00
Olly Betts a268c71607 Remove remains of %nestedworkaround
Also the nestedworkaround feature it uses - both were deprecated over 10
years ago in SWIG 3.0.0.  Since then uses of these have done nothing
except emit a warning.
2024-09-12 14:41:24 +12:00
Olly Betts ff444c93f3 Fix compilation with PHP 8.0 2024-09-12 14:07:00 +12:00
Olly Betts cf22ed2e7b Ensure struct Decl is always fully initialised
See #2995
2024-09-12 13:55:32 +12:00
Olly Betts 151f915fd7 Fix compilation with MSVC 2024-09-12 13:28:41 +12:00
Olly Betts 384125609e Ensure struct Define is always fully initialised
See #2995
2024-09-12 12:01:50 +12:00
Olly Betts a179fb6e86 Fix some incorrect comments in the parser 2024-09-12 11:12:10 +12:00
Olly Betts c4fffb50b5 Restrict where we allow a bitfield width specifier
This was being handled in the wrong place in the grammar leading to
SWIG accepting nonsensical uses.  The new handling isn't perfect
(not least because C++20 added support for a bitfield with an
initialiser) but it's much less wrong than it was.
2024-09-12 10:58:22 +12:00
Olly Betts 8038a949ed Remove Examples/xml
These examples aren't hooked up to `make check-xml-examples`, and
runnning `make -C Examples/xml` fails showing more than 10000 lines
of differences from the expected output (and has done for years).

Shipping them in their current state is just pointless bloat.

See #2213
2024-09-12 09:24:56 +12:00
Olly Betts d57ba7f26d Lookup _get and _set methods more efficiently
We now avoid creating a temporary zval holding the method name of
the _get or _set method - only a temporary zend_string is needed
which is lighter weight.

See #2809
2024-09-12 09:09:29 +12:00
William S Fulton 15c218493d Merge branch 'master' of git+ssh://github.com/swig/swig
* 'master' of git+ssh://github.com/swig/swig:
  Fix qualify of "enum class" enumerator names
  [perl] Fix C++11 enum class wrapping with -const
  [python] Adjust wording around supported versions
  [js] Document versions we actually support
  Fix JS keyword rename test to actually test for renaming
2024-09-11 21:29:35 +01:00
Olly Betts 4067991010 [ci] Test C target language with C++20 too 2024-09-12 07:36:27 +12:00
Olly Betts 6553f24d83 Wording improvements in C chapter 2024-09-12 07:32:30 +12:00
Olly Betts b144a5aae5 Fix HTML markup issues 2024-09-12 07:32:30 +12:00
Olly Betts c896c2e838 Eliminate unnecessary "easily"
It doesn't add anything, but risks making the reader feel stupid if they
don't immediately understand or can't just make it work.

Building shared libraries is not "easy" and there are a number of
pitfalls (like not passing "-fPIC" which this example was failing to do,
so it would fail on x86-64 with a fairly cryptic error message...)
2024-09-12 07:29:17 +12:00
Olly Betts ed6bc6a3d9 Use -fPIC when compiling for shared library
While shared objects with non-PIC code work on some architectures
(notably x86), unless code is always PIC on that arch (not true for x86)
doing so requires runtime relocations, which prevents the object
actually being shared, and means such segments can't be marked as
read-only.
2024-09-12 07:22:11 +12:00
Olly Betts 6a8bf52eb2 Say ISO C not ANSI C
See #890
2024-09-12 07:21:45 +12:00
Olly Betts 2aa04bc88d Fix missing newline at end of files 2024-09-12 07:21:45 +12:00
William S Fulton cbff768feb Add the %interface_additional macro
New macro added to the family of %interface macros. This new macro
is for adding additional interfaces for the generated interface to
extend/derive from.

Closes #1188
2024-09-11 20:05:30 +01:00
Vadim Zeitlin a183c7c980 Fix mangling overloaded functions in C API
A previous merge of master used a wrong function in get_mangled_type():
we need Swig_name_mangle_type() and not Swig_name_mangle_string() here,
as it's more readable and, more importantly, backwards-compatible and
doesn't change the identifiers used in the generated C API.
2024-09-11 14:50:33 +02:00
William S Fulton f93cf07015 C# runtime test %interface regression fix for multiple inheritance and common bases
C# runtime testing for 61dffc06d1
2024-09-11 08:04:18 +01:00
Olly Betts 06cb7a122c Fix qualify of "enum class" enumerator names
Fix incorrect inclusion of "enum " when qualifying C++11 "enum class"
enumerator names.

Fixes #197
Fixes #675
Fixes #1677
Fixes #2047
Closes #3013
2024-09-11 17:42:34 +12:00