Commit Graph

141 Commits

Author SHA1 Message Date
William S Fulton 86498e46c6 Remove -xmllang option used with -xml
which had no effect on the output.
2024-10-15 08:59:51 +01:00
Olly Betts 7a8c9fdfa8 Straighten out handling of char and string constants
Fixes #904
Fixes #1907
Fixes #2579
Fixes #2990
2024-08-17 16:12:45 +12:00
William S Fulton 2c70a912a6 Add $isvoid special variable
The $isvoid special variable expands to 1 if the
wrapped function has a void return, otherwise expands to 0.

In the implementation, use a consistent variable name, returntype,
for a node's "type" attribute.

Issue #2907
2024-06-15 23:13:12 +01:00
PaulObermeier 472e9dd154 Replace nullptr with NULL
When replacing nullptr by NULL, SWIG 4.2.0 can still be compiled with gcc 4.9.X (ex. Debian Jessie).
2024-01-15 22:42:54 +00:00
William S Fulton c0b36721a3 Replace Language::is_assignable with Language::is_immutable
Avoids confusion with newly created Allocate::is_assignable.
Language::is_immutable is just a wrapper around the
"feature:immutable" flag since previous commit.

is_mutable rename wip
2023-09-07 07:01:37 +01:00
Momtchil Momtchev 55207d5e52 handle `"tmap:in" == NULL`
Even if this can't really happen in practice
2023-08-09 08:24:48 +12:00
Olly Betts afd4c87b33 Merge branch 'napi-tm-in-duped'
Closes: #2653
2023-08-02 12:20:19 +12:00
William S Fulton ad09c09040 Javascript - ignore constructor renaming
Improve the constructor rename detection and attempts to ignore it.
This has not worked previously, but the recent addition of the
template_templated_constructors testcase resulted in code that did not
compile.

These are the testcases that are affected as they attempt to use a
renamed constructor:
  constructor_rename
  conversion_ns_template
  overload_rename
  template_templated_constructors
2023-07-24 19:38:13 +01:00
Momtchil Momtchev 574882654a guard against applying in typemaps twice 2023-07-07 17:56:40 +02:00
William S Fulton 2822df9aa2 Cosmetic formatting after using make beautify 2023-06-28 07:30:40 +01:00
Momtchil Momtchev ceed54758a Javascript Node-API support added
Closes #2545
2023-06-28 07:24:51 +01:00
Momtchil Momtchev 721a4808b8 remove hacks and implement default arguments 2023-05-31 13:22:35 +02:00
Momtchil Momtchev d25b288d8c fix a copy & paste blunder 2023-05-23 18:05:58 +12:00
Momtchil Momtchev 2dfa6d6b84 support check typemaps in JS 2023-05-11 23:09:19 +02: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
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 46f7501d94 Cleanup SWIG_VERSION definition
Add Swig_obligatory_macros which must be called by each
target language to define SWIG_VERSION correctly
in the generated code, as well as the language specific
macro SWIGXXX where XXX is the target language name.

Drop the #ifdef SWIGXXX that was previously generated -
I can't see the point of this and if users are defining
this macro somehow, then users will need to change this

Closes #1050
2022-10-13 19:47:43 +01:00
Olly Betts 631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
Olly Betts 4ac3c87a29 Sort out predefined SWIG-specific macros
Ensure that SWIG_VERSION is defined both at SWIG-time and in the
generated C/C++ wrapper code (it was only defined in the wrapper
for some target languages previously).

SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers
to match behaviour for all other target languages.

Stop defining SWIGVERSION in the wrapper.  This only happened as a
side-effect of how SWIG_VERSION was defined but was never documented and
is redundant.

The new testcase also checks that SWIG is defined at SWIG-time but not
in the generated wrapper, and that exactly one of a list of
target-language specific macros is defined.

Fixes #1050
2022-10-05 12:40:15 +13:00
William S Fulton 1db04bf322 Improvements to the -debug command line options
The debug command line options that display parse tree nodes
(-debug-module, -debug-top, -debug-symtabs) now display previously hidden
linked list pointers which are useful for debugging parse trees.

Added new command line option -debug-quiet. This suppresses the display
of most linked list pointers and symbol table pointers in the parse tree nodes.

The keys in the parse tree node are now shown in alphabetical order.
2022-03-25 23:34:52 +00:00
Olly Betts 55377bdc08 Add DOH Exit() and SetExitHandler()
Exit() is a wrapper for exit() by default, but SetExitHandler() allows
specifying a function to call instead.

This means that failures within DOH (e.g. Malloc() failing due to lack
of memory) will now perform cleanup such as removing output files.

This commit also cleans up exit statuses so SWIG should now reliably
exit with status 0 if the run was successful and status 1 if there was
an error (or a warning and -Werror was in effect).

Previously in some situations SWIG would try to exit with the status set
to the number of errors encountered, but that's problematic - for
example if there were 256 errors this would result in exit status 0 on
most platforms.  Also some error statuses have special meanings e.g.
those defined by <sysexits.h>.

Also SWIG/Javascript tried to exit with status -1 in a few places (which
typically results in exit status 255).
2022-03-06 12:33:54 +13:00
Olly Betts b5dbcb4ece Rename `free` variable to `jsfree`
The collision with free() is a latent problem.
2022-03-03 12:23:41 +13:00
William S Fulton d2e9b80be3 Merge branch 'using-declarations' into upstream-master
* using-declarations:
  Typo fixes
  Fix warning suppression for WARN_PARSE_USING_UNDEF
  Using declarations fix in symbol tables
  Revert recent using-declarations code changes

Conflicts:
	CHANGES.current
2022-02-20 17:04:56 +00:00
William S Fulton 1b0a9ccfc5 Typo fixes 2022-02-20 16:45:11 +00:00
Olly Betts fd6c0255a2 Remove superfluous semicolons 2022-02-15 14:00:12 +13:00
Olly Betts 7ec2f89fe2
Remove redundant NULL checks before free()/delete (#2184)
Remove redundant NULL checks before free()/delete

The ISO C and C++ standards guarantee that it's safe to call these
on a NULL pointer, so it's not necessary for the calling code to
also check.

Fixes https://sourceforge.net/p/swig/feature-requests/70/
2022-01-29 22:03:48 +13:00
Dimitris Apostolou f586d920f7
Fix typos 2021-11-17 07:07:02 +02:00
Olly Betts f198ff0a43 Fix more "allows to" and other typos 2021-04-21 15:54:46 +12:00
William S Fulton e71f781140
Apply suggestions from code review
Print errors to stderr instead of stdout
2020-10-07 22:06:47 +01:00
Alistair Delva 4d844a8dc2 javascript: replace exceptions with SWIG_exit
When building SWIG for Android, there is no support for C++ exceptions.

In the cases there is "Illegal state", it seems more like an internal
error, so we can replace the throw calls with a debug print and exit
immediately.

Closes #1858
2020-08-13 07:55:35 -07:00
Chris Walker 025269f121 Dev Checkpoint 201908200213 2019-08-20 02:13:50 -06:00
Chris Walker 2c2e638d89 Dev Checkpoint 201906252210 2019-06-25 22:10:46 -06:00
TekuConcept ff19363abf Add JS Native Wrapper API 2019-05-08 15:36:46 -06:00
luz.paz 6f69830321 follow-up typos 2018-05-17 10:26:00 -04:00
luz.paz 60dfa31a67 Misc. typos
found via `codespell` and `grep`
2018-05-17 10:04:23 -04:00
William S Fulton 2171f52635 Javascript %nspace fix in generated C++ code
When using %nspace on namespaces that are more than two levels deep.
Fixes cpp17_nspace_nested_namespaces testcase.
2018-05-15 22:22:10 +01:00
William S Fulton 57a89f987d Fix %import and %fragment forced inclusion to not generate code. 2017-06-03 18:37:05 +01:00
William S Fulton 08688d7d9d Add support for "ret" typemap where missing and improve documentation on it. 2016-09-29 08:07:26 +01:00
William S Fulton c6f8aadc64 Cosmetic corrections - Mac OS X 2015-08-02 20:14:20 +01:00
William S Fulton 59ff3e6a3a C90 fixes for Javascript JSC 2015-02-11 23:32:45 +00:00
Jason Turner fa36b6228e Fix function naming conflict with class overloads.
This fix takes into account the classname while generating overload
handlers.

Example:

If you have two classes:

  class A {
    public:
      void doSomething(int);
      void doSomething(double);
  };

  class B {
    public:
      void doSomething(int);
      void doSomething(double);
  };

Before this patch, the overload handlers for A::doSomething and
B::doSomething create conflicting names and function redefinition errors
are caused.

After the patch, the overload handlers are named classname_doSomething
and no longer conflict.

This is might not the best way to implement this, but it
solves a critical problem on large projects, and specifically can affect
operator overloads that are being wrapped.
2014-06-06 18:24:22 +02:00
William S Fulton b531956467 Warning fixes compiling with Visual Studio 2014-05-27 21:55:17 +01:00
Oliver Buchtala 0c42158723 Javascript: preparations for using Language::getNSpace(). 2014-05-19 00:20:19 +02:00
William S Fulton a6e5e97157 Javascript cosmetic changes 2014-05-01 19:41:17 +01:00
William S Fulton 5792e97a44 Javascript: ensure banner appears before %begin code 2014-05-01 18:13:35 +01:00
Oliver Buchtala 7a7faab765 Fix bug and regression in javascript namespace generator. 2014-04-27 00:34:49 +02:00
Oliver Buchtala d81fe244e3 Prettify generated output in JS emitters. 2014-04-27 00:34:19 +02:00