Commit Graph

113 Commits

Author SHA1 Message Date
William S Fulton 22a8088a98 Fix -Wunused-variable warning in Lua and Octave wrappers
Add bool output parameter to Swig_overload_dispatch to say when it has
generated code that will use the typecheck typemap code to help Lua and
Octave to not emit unused argv[] arrays.

Alas, resorted to warning suppression for deficient cpp11_initializer_list
typecheck typemap in cpp11_std_initializer_list testcase.
2025-06-23 21:39:49 +01:00
William S Fulton 4bf9547982 Fix -Wunused-variable warning for overloaded methods in Octave
Fixes testcases: cpp11_director_using_constructor and cpp11_using_constructor.
2025-06-23 21:39:49 +01:00
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
William S Fulton 09001ee302 Add $isvoid special variable expansion for directors
Complete the removal of Ruby's output_helper macro and replacement
with SWIG_AppendOutput for director typemaps.
Requires $isvoid special variable support in director code.
2024-10-06 15:00:37 +01: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 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
William S Fulton 3be670e8db Fix assertion handling upcasting when using %shared_ptr on some templates.
A different approach is taken for supporting casting smart pointers up the
inheritance hierarchy. We no longer try to replace the underlying pointer type,
provided in the 'feature:smartptr', with the base class type. Such as morphing
'std::shared_ptr<(Derived)>' into 'std::shared_ptr<(Base)>'. Instead, we simply
use 'feature:smartptr' from the base class. This is more reliable than trying to
pattern match the pointer type in the feature. The base class must of course
also have the 'feature:smartptr' set, and this is still checked for as before.
The feature is now parsed in one place and stored in the parse tree in the
new 'smart' attribute for handling by the target languages.

Fix also improves the handling of the type parsed in 'feature:smartptr' in that
the type is now normalized and resolved in the scope of the class it is attached
to.

Closes #2768
2024-01-30 22:24:42 +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
William S Fulton 84542f6b59 Replace Language::directorsEnabled() with Swig_directors_enabled()
For use outside of the target languages for forthcoming commits
which move adding default constructors/destructors from Language
to Allocate.
2023-07-12 18:44:42 +01: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 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 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
William S Fulton ee9e436971 Fix -Wmisleading-indentation in Octave wrappers 2022-09-20 22:31:50 +01:00
Olly Betts f5e2d044df Remove set but not used variables
Highlighted by clang-15 warnings such as:

warning: variable 'index' set but not used [-Wunused-but-set-variable]
2022-06-30 12:52:37 +12:00
Olly Betts b2c58115d7 Fix previous commit
Revert changes inadvertently included, and fix `=` to `==`.
2022-03-20 19:44:23 +13:00
Olly Betts 029ddab8b5 [ci] Try to fix failing appveyor python builds 2022-03-20 18:42:50 +13: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 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 0bf846f56f Eliminate unused Printf args 2021-04-13 10:43:51 +12:00
Karl Wette d9c94848ec octave.cxx: fix exception raising for newer Octave versions
- Since (at least) Octave 5.1.0, the Octave error() function now raises a C++
  exception, which if uncaught immediately exits a SWIG wrapper function,
  bypassing any cleanup code that may appear after a "fail:" label.
- This patch adds a "try { ... } catch(...) { }" block around the contents of
  SWIG wrapper functions to first execute the cleanup code before rethrowing any
  exception raised.
- It is backward compatible with earlier versions of Octave where error() does
  not raise an exception, which will still branch to the "fail:" block to
  execute cleanup code if an error is encountered.
2020-05-31 06:43:15 +10:00
Karl Wette e67f125582 octave.cxx: add missing return statement before "fail:" label 2020-05-31 06:43:15 +10:00
Karl Wette f6286a1b19 octave.cxx: this belongs in the code (as opposed to definition) section 2020-05-31 06:43:15 +10:00
Karl Wette 99bb5dcc70 octave.cxx: remote whitespaces 2020-05-31 06:43:15 +10:00
Karl Wette 66f4f7de8e octave.cxx: replace Printf() with Append() for consistency 2020-05-31 06:43:15 +10:00
Vadim Zeitlin cd526caed4 Harmonize parameters in autodoc in Ruby and Octave with Python
Backport changes to Python version of make_autodocParmList() to Ruby and
Octave modules, which use similar code.

In particular, this improves handling of parameters clashing with the
language keywords/reserved words for these languages as well.
2019-01-21 01:08:45 +01:00
William S Fulton 027a38c71c Remove -cppcast and -nocppcast command line options
The -cppcast option is still turned on by default. The -nocppcast option
to turn off the use of c++ casts (const_cast, static_cast etc) has been
removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts
instead of C++ casts for C++ wrappers.

This a revert of commit fc79264a48f186f8bbd367e91fa9dbf9758aa092:
"Revert "Remove -cppcast and -nocppcast command line options""

The Scilab and Javascript casting problems are now fixed, so -cppcast
is now switched on as default.
2018-11-13 07:36:09 +00:00
William S Fulton fc79264a48 Revert "Remove -cppcast and -nocppcast command line options"
This reverts commit c06f2b4497.

More work to be done as it breaks Scilab and Javascript tests.
2018-11-06 17:22:05 +00:00
William S Fulton c06f2b4497 Remove -cppcast and -nocppcast command line options
The -cppcast option is still turned on by default. The -nocppcast option
to turn off the use of c++ casts (const_cast, static_cast etc) has been
removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts
instead of C++ casts for C++ wrappers.
2018-11-06 10:26:06 +00:00
luz.paz 6f69830321 follow-up typos 2018-05-17 10:26:00 -04:00
William S Fulton ae044c1c2f Generation of director method declarations fixes
- Fixes generation of director method declarations containing C++11 ref-qualifiers.
- Fixes generation of director method declarations returning more complex types such
  as const ref pointers.
- Rewrite Swig_method_call to use more up to date code in the core.
2017-10-23 18:55:14 +01:00
William S Fulton 3f8b8fe734 Enhancements for directorin typemaps
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }

The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
2017-10-16 19:28:27 +01:00
William S Fulton ebd37155a8 Fix potential use of uninitialized variables in directors 2017-05-13 22:40:59 +01:00
Christophe Duvernois 4777a0ad3c #526 : propagate c++11 noexcept to director classes 2017-04-27 23:37:15 +02:00
William S Fulton a91d1b5a42 Remove unused kwnames generated variable in Ruby wrappers
This seems to be from some left over Python kwargs / unfinished kwargs support
2016-05-28 00:45:24 +01:00
Petre Eftime 0a07cd4c30 Prevent redefinition warnings when compiling with SWIG<module> defined
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
2015-12-22 14:33:21 +02:00
William S Fulton ec8a5c71cb Fixes for Octave and missing -Wmissing-field-initializers in swig_octave_member 2015-12-19 16:21:22 +00:00
William S Fulton faeaacf112 smartptr feature support - factor out common code 2015-09-25 22:57:59 +01:00
Olly Betts 01d0ee86e0 Fix C&P references to Python in comments 2015-03-27 12:40:42 +13:00
Olly Betts 7ba0652677 Create director_common.swg for language-indep code
Move -DSWIG_DIRECTOR_STATIC handling there, so this is now supported for
all languages with director support, not just Python and PHP.
2015-03-12 19:51:11 +13:00
Jeremy 2696a6e0ff Updated usage string for -cppcast/-nocppcast in octave.cxx 2015-01-09 14:51:44 -05:00
Jeremy e301457a43 Attempting fixes for Octave shared_ptr support 2015-01-05 10:53:06 -05:00
William S Fulton 376ebc2d85 Revert "Octave: whitespace/indentation/style cleanup of octave.cxx"
This reverts commit 5ac475cbcd.

Reverting a series of Octave commits for re-applying again without
incorrect whitespace changes.
2014-10-09 19:34:06 +01:00
William S Fulton 23373e9ffd Revert "Octave: cleanup/restructure library files"
This reverts commit bf12d76d03.

Reverting a series of Octave commits for re-applying again without
incorrect whitespace changes.
2014-10-09 19:34:02 +01:00
William S Fulton a9c9c9c848 Revert "Octave: remove unused field SwigOctClass::constructor_doc"
This reverts commit afa9affcd9.

Reverting a series of Octave commits for re-applying again without
incorrect whitespace changes.
2014-10-09 19:33:40 +01:00
Karl Wette afa9affcd9 Octave: remove unused field SwigOctClass::constructor_doc 2014-10-05 20:54:20 +02:00
Karl Wette bf12d76d03 Octave: cleanup/restructure library files
- Restructure runtime code into declarations, function
  and class definitions, and initialisation code
- Rename internal functions/types to follow SWIG_Octave...
  or SwigOct... naming styles
- Style/comment/whitespace cleanups
2014-10-04 19:18:32 +02:00
Karl Wette 5ac475cbcd Octave: whitespace/indentation/style cleanup of octave.cxx
- Used "astyle -A10 -s2 -N -p -H -U -k1" for style cleanup
- Replaced NewString("") with NewStringEmpty()
- Used 'w' instead of 'f' for Wrapper() objects
2014-10-04 13:29:46 +02:00
Karl Wette ecf28da5a9 Octave: remove deprecated -global/-noglobal command-line arguments 2014-05-29 23:42:55 +02:00