* commit '62b603768164e50af4c236fa2e8929cbb46b2ae9':
Also fix docstrings when using Python with -builtin option
Pass overloaded function itself to add_method() for clarity
Fix Python docstring for overloads with some Doxygen comments
Use the recently added find_overload_with_docstring() in builtin case
too.
Note that this relies on the parent commit as add_method() must be
called with the last function in the overload set, and not the last but
one, for find_overload_with_docstring() to work correctly.
Alternatively, we could change find_overload_with_docstring() to look at
all elements of the overload set, not just the preceding, but also the
following ones. However it seems better to keep things simpler and only
call it for the last one.
It's unclear why did we pass the previous element of the overload set
when calling add_method() from dispatchFunction() but it seems that it
was done just to avoid passing anything at all if this function was not
overloaded, presumably because whatever add_method() does if the "node"
argument is not null was already done from elsewhere in this case.
Unfortunately, add_method() doesn't document when should this argument
be null and when it shouldn't be, so it's just guesswork, but at least
the test suite still passes after this change which makes the code a bit
more clear.
And now we use the properties of this node itself in add_method() when
the function is overloaded instead of, completely inexplicably, using
the properties of another overloaded function (which was probably mostly
fine in practice until now because most overloaded functions have the
same properties anyhow).
The existing code didn't work correctly if the last element of the
overload set didn't have a Doxygen comment: in this case, no docstring
was generated at all.
Fix this by trying to find any overload with a Doxygen comment, as
Python docstring is common for all of them: add a helper function to do
it and use it for both all kinds of ordinary functions (global, member
and static) and __init__ functions generated for C++ ctors, as docstring
was generated in the same wrong way for all of them in different places.
Note that currently the overloads without Doxygen comments are not
documented at all at Python level, as saying "there exist other
overloads but there is no documentation for them" doesn't seem very
useful and there doesn't seem anything else that we could do.
Add a new unit test for testing all the different combinations of
overloaded functions with and without Doxygen comments.
* 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
Don't generate calls to
SWIGPY_BINARYFUNC_CLOSURE(_wrap___lshift__)
for the 'global' function wrappers for the friend functions.
Only occurred when a friend class is within a namespace due to the
renames in pyopers.swg, such as:
%rename(__lshift__) *::operator<<;
The rename was intended for member functions but was also being attached
to friends that are within a namespace.
Since this was first added, the -py3 option has been dropped
and the Stable ABI is known as exactly that, not the Python3 Stable ABI.
Document the new option and turn on c++20 testing for it to cover
std::filesystem and std::string_view testing which are affected
* py3-stable-abi:
Add CI build using -py3-stable-abi option
Make Python buffer typemaps compatible with limited API
Don't use PyUnicode_AsUTF8() when python limited API is used
Make directors implementation for Python work with limited API
Support using stable Python ABI
Conflicts:
.github/workflows/ci.yml
Lib/python/pyhead.swg
Lib/python/pyrun.swg
Source/Modules/python.cxx
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
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.
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.
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
If a "docstring" feature is present it will still override a Doxygen comment.
If the "autodoc" feature is also present, the combined "autodoc" and "docstring"
will override the Doxygen comment. If no "docstring" is present then the
"autodoc" feature will not be generated when there is a Doxygen comment.
This way the "autodoc" feature can be specified and used to provide documentation
for 'missing' Doxygen comments.
Closes#1635