Commit graph

4,876 commits

Author SHA1 Message Date
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
569ac5ec4f Handle doxygen code command with language option
Previously, code blocks were always written to the pydoc output with
"code-block:: c++", and use of language options (e.g., \code{.py}) was
not supported.  Now the option provided to the doxygen code command is
checked, and several basic cases are handled (python, java, and c),
defaulting otherwise to C++ as before (handling for additional cases
can easily be added).
2019-08-07 16:55:38 -05:00
John McFarland
fcf30940cd Improve doxygen parser handling of \code content
Set the m_isVerbatimText flag in the parser for code commands.  This
allows some additional special characters to appear within the code
block (in particular, the ">" character).
2019-08-07 16:55:35 -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
3cc4b21163 Parameter name expansion fix for template functions.
Fix regression in 4.0.0 where a template function containing a parameter
with the same name as the function name led to the parameter name used in the
target language being incorrectly modified.

Closes #1602
2019-08-01 19:46:16 +01:00
William S Fulton
2cf075558c Replace all exit() with SWIG_exit()
For consistent cleanup on error
2019-07-31 00:08:49 +01:00
William S Fulton
b36ae64185 Remove all generated files on error.
Previously generated files were not removed,
potentially breaking Makefiles using file dependencies, especially when
-Werror (warnings as errors) was used.
2019-07-31 00:08:49 +01:00
William S Fulton
f69da524f0 Exit code change when using -Werror
Exit code is now sum of all errors, not just warnings as errors.
I'm can't think why the exit code wasn't like this in the first
place.
2019-07-31 00:08:49 +01:00
William S Fulton
98f29f8ad9 Remove deprecated DohClose in DOH 2019-07-31 00:08:49 +01:00
Vadim Zeitlin
0ff6893b2d Make Python module source non-executable again
0f88f9997c (probably accidentally) changed
this file to be executable, undo this as it doesn't make sense for a
source file to have this mode.

See #1242.
2019-07-24 20:10:35 +02: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
c20b6f5b0e Generator: Unify string quoting in generated Python sources 2019-07-14 11:08:17 +10:00
Dmitry D. Chernov
9f79fb5216 Generator: Remove trailing whitespaces in the Python module 2019-07-14 11:06:10 +10:00
Vadim Zeitlin
c321aca2b4 Fix missing value for first item of enums with trailing comma
The value of the first item of an enum with a trailing comma after its
last item was not correctly initialized to 0 any more after the changes
of 74adaa5738 (see #1515) because "_last"
attribute was not set correctly in this case.

Do set it for the last item when it's followed by a comma too and add
more unit tests checking for this.

Closes #1566.
2019-07-11 17:15:38 +02:00
William S Fulton
42f5e2da41 Merge branch 'doxy/segfault'
* doxy/segfault:
  Add iterator safety check in DoxygenParser::parse
  Doxygen comment parsing fix for empty lines in code/verbatim blocks
2019-07-11 07:08:51 +01:00
William S Fulton
aea7a6d30f Merge branch 'patch-1'
* patch-1:
  nested_inheritance_interface testcase enhancement
  Add nested_inheritance_interface test for csharp
  Fix class name for nested classes
  Add nested_inheritance_interface test
  Fix class name for nested classes

Conflicts:
	CHANGES.current
2019-07-09 19:37:35 +01:00
Isaac Pascual Monells
63497c8d0e Fix class name for nested classes 2019-07-08 12:49:00 +02:00
John McFarland
841d4b5fb9 Add iterator safety check in DoxygenParser::parse
If the code called by DoxygenParser::parse does not behave correctly,
it may move the iterator m_tokenListIt past the value endParsingIndex.
This was not caught by the previous checks and could lead to
dereferencing an invalid m_tokenListIt iterator value (and segfault).
This is now protected against by using a less than check in the while
loop instead of not equals.  A warning is also printed if
endParsingIndex is exceeded.
2019-07-06 11:30:56 -05: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
William S Fulton
1204297a1b Merge branch 'doxy/space'
* doxy/space:
  Ensure empty line before code and math blocks in doxygen pydoc
  Remove extra newline before code block in doxygen python output
  Clarify python doxygen code block indentation handling
  Cleanup of pydoc translator newline trimming
  Correction to recently added doxygen python test case
  Adjust expected python output for doxygen style2 test
  Adding test for second doxygen comment style
  Fix bug in doxygen python code block indent
  Eliminate extra newlines around doxygen python block math
  Eliminate extra newlines in doxygen python \verbatim blocks
  Remove extra newline from end of doxygen python \code command
  Remove extra newline in beginning of doxygen python \code command
  Fix python doxygen indentation for inline \code command
2019-06-28 19:50:39 +01:00
William S Fulton
b58995c89e $arg and $input were incorrectly substituted in the argout typemap
when two or more arguments were present.

Closes #1559
2019-06-28 08:09:47 +01:00
Isaac Pascual Monells
22c27cf216
Fix class name for nested classes
The feature %interface_impl from swiginterface.i differ on generated function
name from JNI wrapper class when using nested classes without flatnested.
2019-06-27 15:39:37 +02:00
William S Fulton
4301fa548d Remove some legacy cruft from Python proxy class
These methods are no longer used:
_swig_getattr
_swig_setattr
_swig_setattr_nondynamic
2019-06-27 07:40:49 +01: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
luz.paz
87695dacb1 Misc. documentation and source comment typo fixes
Found via `codespell -q 3 -L uint,od,objext,ba,cmo,bae,ans,struc,fo,clos,goin,upto,thru`
Revert changes in previous commit
2019-05-28 11:41:22 +12: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
08ac56b7f2 Clarify python doxygen code block indentation handling
Clarify usage and comments for the codeIndent string, the intent of
which was not clear after recent updates.
2019-05-26 08:19:07 -05:00
John McFarland
0c6930d966 Cleanup of pydoc translator newline trimming
Simplify python doxygen translation code by using functions to erase
leading and trailing newlines.  No change to logic.
2019-05-26 07:52:57 -05:00
John McFarland
98ae66b6fc Fix bug in doxygen python code block indent
If a certain doxygen comment style was used that included an
additional space, then translated Python comment code block indent was
not correct (it included the extra space).  This doxygen comment style
was not previously represented in the test cases; a new test case will
be added 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
Frederik Schubert
b3a3c4f09e Don't add a closing php-tag
This PR removes the closing `?>` PHP tag from generated files. [PSR-2](https://www.php-fig.org/psr/psr-2/) states:

> The closing `?>` tag MUST be omitted from files containing only PHP.

A problem might occur if files with any character after the closing tag are used with `include` or `require`. It might trigger an output and disallow HTTP header manipulation. See the popular [_headers already sent_](https://stackoverflow.com/a/8028987/1847340) debate on SO.
2019-05-22 11:35:08 +12:00
Zackery Spytz
2f48bec666 Merge remote-tracking branch 'upstream/master' into OCaml-INPUT-OUTPUT-INOUT-primitives 2019-05-08 14:05:02 -06:00
William S Fulton
11b54b0cbd Fix command line error handling to work like in 3.0.12
Output is once again:

  $ swig -versioon
  Unable to find option or file '-versioon', Use 'swig -help' for more information.

instead of

  $ swig -versioon
  No target language specified
2019-04-25 23:13:51 +01:00
Ian Lance Taylor
8a1c09e280 Fix Go tests to run in module mode
Stop using relative imports and add a go.mod file.

Tested against Go 1.6 through Go pre-1.13, and gccgo.
2019-04-24 21:43:38 -07:00
William S Fulton
fbed720b98 Merge branch 'enum-trailing-comma-doxygen'
* enum-trailing-comma-doxygen:
  Fix parsing of enums with trailing comma with -doxygen
2019-04-24 08:08:18 +01:00
Vadim Zeitlin
74adaa5738 Fix parsing of enums with trailing comma with -doxygen
To correctly parse Doxygen post-comments after the trailing comma,
switch to right recursion in "enumlist" production rule definition: this
does consume more stack space when parsing, but makes the rules much
easier to write and to understand and hopefully shouldn't result in any
problems with real code (which shouldn't have thousands of enums items
in it).

Closes #1514.
2019-04-20 13:52:56 +02:00
Vadim Zeitlin
01a2cd27e7 Don't crash if type is not available in Python Doxygen code
Fix crash if "@return" Doxygen tag was used on a node without any return
type (such as a class, for example). Ignoring it might not be the best
thing to do, but it's definitely better than crashing and it's not
really clear what else could be done anyhow.

Closes #1516.
2019-04-20 13:52:05 +02:00
Ian Lance Taylor
77f075b6e8 When generating Go code, make -cgo the default.
Add new -no-cgo option to disable the default.
Keep -cgo as a no-op for existing users.
2019-04-19 12:49:56 -07:00
William S Fulton
65a7fafd84 Fix minor whitespace regression in Java generated code 2019-04-18 20:27:14 +01:00
William S Fulton
831fae3c69 Add the parameters typemap attribute to D and Java destructor wrapper typemaps
Added to the javadestruct, javadestruct_derived, ddispose, ddispose_derived
typemaps to mirror enhanced flexibility in the csdisposing and
csdisposing_derived (C#) typemaps. If provided the contents are generated
as the delete/dispose method's parameters declaration.
2019-04-08 19:20:50 +01:00
William S Fulton
06462acdf9 Fix C# CA1063 warning by implementing the recommended Dispose methods.
Previously just the Dispose() method was generated.
Now the Dispose() and Dispose(bool disposing) methods are generated.
Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived"
typemaps are being used. Details in #421 on Github. SWIG will error out if one of
the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example
error message:

  foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove
  it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the
  csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps.

Closes #421
2019-04-08 19:20:45 +01:00
William S Fulton
39599f2112 Always use fastunpack for Python swigconstant wrappers 2019-03-21 21:17:21 +00:00