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.
We need to strip qualifiers before checking the type is `bool`.
This mainly affects Python. In Ruby there's equivalent code, but
it is only use to generate documentation comments.
Fixes#3052
Documentation comments now use `true` and `false` for bool parameter
default values, instead of `True` and `False` (which are the Python
names and wrong for Ruby!)
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.
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).
* Improve mutex for director use:
- Use C++ 11 mutex and lock classes.
Most compilers support C++ 11 by default.
Leave Win32 and POSIX support for older compiler.
- Use a single file for Python and Ruby.
- Use macro also for guard definition instead of using '#ifdef'.
- Rename old '__THREAD__' to 'SWIG_THREADS' to
avoid collide with other libraries.
- Remove the use of '__PTHREAD__' as it may collide with other libraries.
- Remove mutex from OCaml, as it is not used in Director class.
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
* Fixes follow @wsfulton.
Improve description of director_guard.swg.
Remove duplicate line.
Change to SWIG_GUARD_DEFINITION and SWIG_GUARD_DECLARATION
as full English words are much more easily understood
than abbreviations.
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
---------
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
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
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
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
Parser no longer checks for a declared constructor when handling a
using declaration in order to correct the name as it won't find
implicitly declared constructors. Now it checks that a using
declaration is for something that looks like a constructor instead
by checking the immediate base classes for allowed constructors.
These features were all deprecated in 1.3.26 (October 9, 2005)
or before (many long before), so all more than 17 years and 3 new major
versions ago which seems more than enough time for users to have stopped
using them, especially as most emit a deprecation warning if used.
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
Resolve the return type to correctly determine if the type is a pointer or
reference to a director class.
SwigType_refptr_count_return() recently added as a simpler fix is no
longer needed.
The conventional approach of using the "type" rather than "decl" to
analyse the return type is used instead too.
Issue #1823
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).
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
This involves properly counting the number of references and pointers in the return
type of a function and only generate unwrapping code if this number is 1.
For template instances some post-processing code is added to fix the 'decl' and
'type' attributes of functions if changed in an unfavorable way during template
expansion.
This commit fixes swig#1811.
The macros for casting function pointers are now fully described and also
clarify why the macros act transparently for C even before Ruby 2.7.
In addition, an "if (CPlusPlus)" was removed in the code generator for
global variables in order to keep the distinction between C and C++ in
one place, which is at the definition of said macros.
This commit fixes the signatures of various callback methods
and cleans up the macro definitions used for casting callbacks.
Note that the transparent version of the macro RUBY_METHOD_FUNC
is currently masked behind RUBY_DEVEL, see commit
1d91feaf13
In order to still support strict signature checking and prevent
nasty deprecation warnings, the use of RUBY_METHOD_FUNC had to
be replaced with VALUEFUNC.
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.
The docstring was not encapsulated within /* */ comments.
The implementation had code for autodoc strings being either single or
multi-line and then adding extra newlines. However, in practice only multi-line
autodoc string are ever generated, so this bit of code handling was removed.
The docstring feature does not attempt to add newlines depending on the
existence of newlines in the docstring.
Closes#538
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.
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.
Using the %alias directive on native C functions causes swig to segfault due to
a dereference of klass (which is NULL for native C functions) in the
defineAliases function of the Ruby module. This commit adds support for an alias
of native C functions for both separate module as well as global functions, as
well as three test cases for the %alias directive of the Ruby module.
Fixes:
mod.i
%module ruby_alias
%alias get_my_name "nickname,fullname";
%inline %{
const char *get_my_name(){
return "Chester Tester";
}
%}
$ swig -ruby mod.i
Segmentation fault
Signed-off-by: Joel Anderson <joelanderson333@gmail.com>
- 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.
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.
* tamuratak-master:
Revert introduction of minor memory leak in Ruby wrappers
ruby: use nodeType attribute to determine whether functions are constructors. get return type each time.