Commit graph

936 commits

Author SHA1 Message Date
Zackery Spytz
4e57c5536d Fix wrapping of virtual comparison operators with directors
Closes #1642.
2020-06-05 10:25:20 -06:00
William S Fulton
f68d0c6da3
Merge pull request #1788 from mcfarljm/Issue-1757
Fix for missing space after \endlink in doxygen
2020-05-28 22:25:53 +01:00
Vadim Zeitlin
6c5d00bd0d Ignore ambiguous variable names error from pycodestyle 2.6
This error is given for any use of variable called "l" (and also "I" and
"O", but we don't seem to have any of those) and it doesn't seem to be
worth changing this variable name in the tests code, as it's really not
that meaningful there anyhow, so just disable the warning to let the CI
builds, which now use pycodestyle 2.6, instead of 2.5 which didn't have
this error and which is still the latest available in Debian Sid, pass.
2020-05-22 16:17:45 +02:00
John McFarland
61dbc4b50c Fix for missing space after \endlink in doxygen
The "endlink" command is processed in processWordCommands, which by
default skips space occuring after the command, which is intended for
removing leading space from a command argument.  For "end" commands,
we don't want to do this.  Note that certain end commands such as
"endcode" aren't processed by processWordCommands (believe
addCommandUnique ends up handling them).

Update usage of \link in doxygen_translate_all_tags.i to test handling
of space after \endlink.

Tweaking some of the usage in doxygen_misc_constructs.i to remove what
seems to be an extra space from the input (otherwise we would need to
add an extra space to the expected output).
2020-05-02 18:42:55 -05:00
William S Fulton
fc2f0204ba Port Ruby test of vector<shared_ptr<>> to Python
This test code tests the upcast code:
  swig_assert_equal_simple(-1, base_num2([Derived(7)]))
Although there is no explicit memory leak fix test, it does at least run the code.

Handling of None needs fixing in Python (it is working in Ruby)
Note that the Ruby implementation has a partial template specialization
for shared_ptr, whereas the Python implementation is in the generic
code!

Issue #1512
2020-02-13 19:21:30 +00:00
William S Fulton
a01e8474f6 Fixing setting this in Python when using __slots__
Don't attempt to use the class's __dict__ for setting 'this' when
a user has extended a class with:
    __slots__ = ['this'].
Was segfaulting. Now we fall back to a simple PyObject_SetAttr if the
usual approach to setting 'this' in __dict__ does not work.

Closes #1673 Closes #1674
2020-02-06 07:08:16 +00:00
William S Fulton
0c00daf3a1 Merge branch 'autodoc-doxygen-fix'
* autodoc-doxygen-fix:
  Fix crash in Python backend when using empty docstrings
2020-01-31 18:57:47 +00:00
Vadim Zeitlin
e14532ce52 Fix crash in Python backend when using empty docstrings
Due to confusion in build_combined_docstring(), we could call
DohDelete() on the "feature:docstring" string, which resulted in a crash
when trying to use it later.

Fix this and simplify the code at the same time by ensuring that we
always use a copy of "feature:docstring" if it's not empty or don't use
it at all if it's empty -- like this we don't have to check for its
length each time before using it.

Closes #1648.
2020-01-30 16:11:18 +01:00
William S Fulton
7405bd6a88 Minor tweak to director_wstring_runme.py test 2020-01-28 20:35:29 +00:00
William S Fulton
45963937d5 Test shared_ptr upcasts in Python 2020-01-24 19:54:29 +00:00
William S Fulton
7051753fdf Correct recently expanded testcase from a merge for doxygen default parameter support 2020-01-16 19:49:16 +00:00
William S Fulton
aa59c81205 Merge branch 'Issue-1643'
* Issue-1643:
  Fix pydoc null pointer dereference with missing arg type
2020-01-16 18:54:47 +00:00
William S Fulton
55d36e3fd3 Merge branch 'Issue-1632'
* Issue-1632:
  Minor workaround in doxygen_basic_translate_style3 test
  Add new test doxygen_basic_translate_style3.i
  Fix for newline handling in doxygen "///" style comments
2020-01-16 07:19:29 +00:00
William S Fulton
00b47d4d1d Merge branch 'doxy/commands'
* doxy/commands:
  Update documentation for doxygen tags
  Fix doxygen translation of \p command for python
  Fix doxygen handling of \em tag for python
  Minor formatting updates to doxygen docs
  Reformat tag lists in doxygen documentation
  Add doxygen_code_blocks_runme.java
  Special handling for python doctest code blocks
  Add new doxygen test doxygen_code_blocks
  Handle doxygen code command with language option
  Improve doxygen parser handling of \code content
  Flag optional arguments in doxygen pydoc output
  Add parameter direction to doxygen pydoc output
  Support doxygen \param[] commands
2020-01-14 18:36:50 +00:00
William S Fulton
67e8334ac8 Python -builtin constructors silently ignored keyword arguments.
Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments"
exception is thrown if keyword arguments are used. Hence constructors and normal
methods/functions behave in the same way.

Closes issue #1595
2020-01-13 19:26:22 +00:00
John McFarland
e46e1655cd Minor workaround in doxygen_basic_translate_style3 test
With the "///" doxygen comment style, comments within a code block do
not get handled correctly.  Modifying the test to remove this case and
adding a note about it for future reference.
2019-11-02 10:43:52 -05:00
John McFarland
feea39f352 Add new test doxygen_basic_translate_style3.i
This is used to test the "///" style of doxygen comments.  Previously,
newlines in these doxygen comments were not handled correctly.
2019-11-02 10:43:52 -05:00
William S Fulton
cb5d7398b5 Fix bug in Python builtin support for keyword args
The fix is when using kwargs feature or -keyword.
The fix is in the argument error checking when wrapping zero
argument constructors only. Supplied keyword args were silently
ignored.

Issue #1595
2019-11-01 19:46:42 +00:00
John McFarland
f99eb0058b Fix pydoc null pointer dereference with missing arg type
Processing doxygen @param comments for a parameter whose name did not
appear in the function declaration would cause a segfault due to a
null pointer dereference.

Adding test cases for both variadic function (no specified arguments)
and @param comment that references an argument that is not named in
the function prototype.  Both of these cases previously segfaulted.
2019-10-27 18:19:42 -05:00
John McFarland
f8ed9d71a7 Fix doxygen translation of \p command for python
Doxygen writes this using typewriter font, so wrap in `` for python
2019-09-15 10:59:03 -05:00
John McFarland
c11172587c Fix doxygen handling of \em tag for python
In doxygen, \em is used for italics, so it should be wrapped in "*".
2019-09-15 10:59:03 -05:00
John McFarland
4a5a86ba91 Special handling for python doctest code blocks
A doctest code block begins with ">>>" and is not indented.  Identify
these in doxygen comments and treat them accordingly.  Also add check
to padCodeAndVerbatimBlocks for these because Sphinx requires an empty
line before.

Add test case to doxygen_code_blocks.i.
2019-08-07 17:04:12 -05:00
John McFarland
5230afb3e1 Add new doxygen test doxygen_code_blocks
This does somewhat more detailed testing of the code block parsing,
and also exercises the language identification of python doctest
features.  For now, it is only tested by python (javadoc translation
may not correctly handle some of the characters that are used here).
2019-08-07 16:55:38 -05:00
John McFarland
fd33bdf8a5 Flag optional arguments in doxygen pydoc output
If the parameter has a default value, add the string ", optional" to
the parameter type description in the translated python comments.
Three examples with default values were already present in the test
cases, so their expected python output has been updated accordingly.
2019-08-07 16:42:39 -05:00
John McFarland
36f0e9919f Add parameter direction to doxygen pydoc output
For doxygen comments that specify parameter direction (i.e.,
\param[in], \param[out], and \param[in,out]), the direction is
appended to the type definition in the generated Python documentation.

Updated expected python output for doxygen test case.
2019-08-07 16:42:39 -05:00
John McFarland
eb11c025c7 Support doxygen \param[] commands
Recognize \param[in], \param[out], and \param[in,out].  Currently they
are all treated the same as \param, but the information is now
available for inclusion in the translated comments.  This is done
using new utility functions getBaseCommand and getEndOfWordCommand,
which will also generalize to treatment of code command options,
e.g. \code{.py}.  Preliminary treatment of the extended version of
\code is already in place in these functions.

Added examples of all three new \param commands to the
doxygen_translate_all_tags test and updated the python and java
expected output.
2019-08-07 16:42:24 -05:00
William S Fulton
86cb3a9532 Python STL container method overloading fix
Fix method overloading of methods that take STL containers of different types.
Due to some error handling that was not cleared during typehecking.
2019-08-06 19:36:14 +01:00
William S Fulton
a9a7b03ba6 Split testcases li_std_wstring.i and li_std_wstring_inherit.i
Not many languages have support for std_wstring.i, so disable testing
for these languages until added.
2019-07-22 19:05:21 +01:00
William S Fulton
5131096b80 li_std_wstring test rename to li_std_wstring_inherit
This testcase was only run in Ruby and Python and implements an
obscure feature where a C++ class inherits from a std::wstring.

The li_std_wstring test is left in place to be modified in next commit
for more regular wstring testing across all languages.
2019-07-18 19:49:50 +01:00
William S Fulton
c8b1eed8ce Merge branch 'annotation_quoting'
* annotation_quoting:
  Examples: Unify string quoting in the Python sources
  Test-suite: Unify string quoting in the Python sources
  Tools: Unify string quoting in the Python sources
  Generator: Unify string quoting in generated Python sources
  Generator: Remove trailing whitespaces in the Python module
2019-07-18 07:23:06 +01:00
Dmitry D. Chernov
fa5f519bf9 Test-suite: Unify string quoting in the Python sources 2019-07-14 12:58:21 +10:00
John McFarland
85a4c7ffc0 Doxygen comment parsing fix for empty lines in code/verbatim blocks
Fix how end of paragraph is identified when parsing \code and
\verbatim blocks that appear within a paragraph and contain an empty
line.  Previously this would generate a warning for unexpected end of
doxygen comments, and it could generate a segfault due to
dereferencing an invalid iterator value.

The doxygen_basic_translate.i and doxygen_basic_translate_style2.i
tests have been updated to serve as regression tests for this
behavior.  Prior to this fix, inclusion of the empty code block line
in this context produced a segfault.
2019-07-06 11:30:46 -05:00
John McFarland
daad5d664d Ensure empty line before code and math blocks in doxygen pydoc
Sphinx requires an empty line before code and math blocks, whereas
doxygen does not.  This update ensures that a blank line is included
before generated code and math blocks in the pydoc output.  This is
done by post-processing the docstring line by line to check whether
any newlines need to be added.  This way, if the original doxygen
source already includes an empty line before a block, an additional
unnecessary empty line is not added.

Updating the expected test output for doxygen_basic_translate, which
now adds the necessary empty line before the code block.  Adding
further test cases to doxygen_translate_all_tags to explicitly verify
that a newline is added in the pydoc output before both code and math
blocks that appear within a paragraph.

Additionally, empty lines previously appearing at the beginning of the
generated docstrings are now removed.  This does not alter the
behavior of the tests.
2019-06-18 17:12:08 -05:00
John McFarland
3476565665 Remove extra newline before code block in doxygen python output
Remove a newline character that was added to the translated comments
prior to the code block.  This way the structure of the pydoc output
more closely resembles that of the original doxygen comments.
Updating tests accordingly.
2019-05-27 13:06:32 -05:00
John McFarland
64b2113e66 Correction to recently added doxygen python test case
The _runme.py code for the recently added test case was using
references to an old module name for the test case, which was later
changed but not updated in the runme file.
2019-05-26 07:52:57 -05:00
John McFarland
0395c48124 Adjust expected python output for doxygen style2 test
Observed that with this second comment style, there is no line break
after the function overload headings in the translated
comments. Updating the test results accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
91a90b8d27 Adding test for second doxygen comment style
This style looks like:

/** Line 1
 *  Line 2
 */

This is needed to verify fixes to some of the indentation in the
translated comments.

The test is copied from doxygen_basic_translate.i.  One adjustment was
made to change the comment style on the last function that left out
the intermediate "*" characters.  This does not produce correct output
when combined with this style of starting the text on the first
comment line.

Test results are copied directly from doxygen_basic_translate.  A
minor difference in the Python results will be updated in a subsequent
commit.
2019-05-25 16:25:54 -05:00
John McFarland
08fc4a02b4 Eliminate extra newlines around doxygen python block math
Eliminate extra leading and trailing newlines around the \f[ and \f{
block math commands for doxygen comment translation for python.
Update tests accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
c52bed2e66 Eliminate extra newlines in doxygen python \verbatim blocks
Eliminate extra leading and trailing newlines present in translated
doxygen \verbatim comments for python.  Updating doxygen python tests
accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
321cb096a8 Remove extra newline from end of doxygen python \code command
Remove the extra newline at the end of translation of doxygen \code
\endcode command for Python.  Update test output accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
3d64a2c037 Remove extra newline in beginning of doxygen python \code command
If \code is used as a block command (probably the main use case), an
extra newline was included in the translated Python comments.  This is
now removed and doxygen python test case output updated.
2019-05-25 16:14:02 -05:00
John McFarland
e62c88883f Fix python doxygen indentation for inline \code command
If \code was used inline, it produced an extra indent versus block
usage.  This extra indent was also stored in the test output.  This
update resolves this by simply removing a space that was being added
unnecessarily in handleTagVerbatim.  Updating test case output
accordingly.
2019-05-25 16:11:20 -05:00
William S Fulton
cedf4a2c2f More python std::list testing 2019-03-25 18:54:08 +00:00
William S Fulton
826f1448b8 Fix Python low-level static member setters.
The low-level API for setting static member variables stopped working
when the fastunpack option was turned on by default. The PyMethodDef
setup requires METH_O, not METH_VARARGS with fastunpack.
2019-03-20 21:44:34 +00:00
William S Fulton
2bb5eeef91 Improve Python static member variable testing
Double check the values are being set in the C++ layer via a function call to C++ layer.
2019-03-20 21:10:28 +00:00
William S Fulton
bc0645ce2b Merge branch 'ZackerySpytz-director-classes-final-methods'
* ZackerySpytz-director-classes-final-methods:
  Warning tweaks for destructors that are final in director classes
  Documentation for directors and virtual final methods
  Fixes for final destructors in director classes
  Warning fix for final destructor in directors
  Remove a useless warning filter
  Fix the handling of director classes with final methods
2019-03-03 15:12:53 +00:00
William S Fulton
83ea2280e2 Fix Python compile errors with overloading and varargs
Fixes wrapping overloaded functions/constructors where a vararg
function is declared after a non-vararg function.
This is a long standing bug in the Python layer exposed since fastunpack
was turned on by default.
2019-02-25 19:27:23 +00:00
Zackery Spytz
c3d652c785 Fix the handling of director classes with final methods
Generated SwigDirector_* classes were attempting to override
methods marked as final.

In addition, give a warning if the destructor of a director class is
final.

Closes #564.
2019-02-22 06:28:53 -07:00
William S Fulton
1f46d9b7b9 Fix regression parsing gcc preprocessor linemarkers
These are preprocessor statement in the form:

 # linenum filename flags

Closes #1475
2019-02-19 21:32:04 +00:00
William S Fulton
9038a9987d Add std::vector back reference test 2019-02-18 21:39:17 +00:00