Commit graph

916 commits

Author SHA1 Message Date
Vadim Zeitlin
bb01e06a6a Make Python parameters types hyperlinks in the doc strings.
It is very useful to be able to click on the parameter types in a function
documentation to go to this parameter description, so always use hyperlink
markup for the parameters of class types, even if not all of them are
necessarily documented -- Sphinx doesn't seem to complain about links to
unknown classes.
2014-08-22 17:45:23 +02:00
Vadim Zeitlin
8b83976f4c Fix arguments of @param, @return etc translations to Python.
For the parameter documentation to be really taken as such, in its entirety,
by Sphinx, it must be indented relative to the :param: tag. Do this by
appending an extra indent after every line of the output and work around the
unnecessary indent of the last line by removing the trailing whitespace.

This required updating the existing tests and removing the expected but not
present any more whitespace from them, but as trailing whitespace in the
documentation is at best insignificant (and at worst harmful) anyhow, this is
not a big price to pay for simpler translator code.
2014-08-22 17:45:22 +02:00
Vadim Zeitlin
14ba3b8dd4 Preserve relative indentation when parsing Doxygen comments.
This is important to preserve the structure of the lists which appear
correctly in Python output without any additional effort if the indentation is
lost.

It is also makes the behaviour consistent for

	/**
	 *
	 *
	 */

comments and those without the asterisks in the middle lines, as now the
indentation is preserved in both cases while it was only preserved when the
asterisks were present previously.
2014-08-22 17:45:22 +02:00
Vadim Zeitlin
ea1d56da67 Use Sphinx-friendly formatting for overloaded functions documentation.
Sphinx doesn't allow sections inside the function documentation and gives tons
of SEVERE warnings for them, so while just emphasizing the "Overload" header
is not ideal, it is better than before because at least the string "Overload"
itself appears in the Sphinx-generated output.
2014-08-22 17:45:22 +02:00
Vadim Zeitlin
eaf63ba47d Add poor man trailing white space detection to Doxygen Python tests.
Show that there is trailing white space in the output in an ugly but
functional way, as without this it's impossible to determine what is the
actual change at all.
2014-08-22 17:45:22 +02:00
Vadim Zeitlin
dd4c680a02 Use Python-ish, not C++, parameter types in Python documentation.
Using C++ types in documentation for Python users is more harmful than
useless, so use Python types whenever possible and allow defining "doctype"
typemap to customize this for the user-defined types.
2014-08-22 17:45:22 +02:00
Vadim Zeitlin
b96dd8bb97 Implement translation of Doxygen formulae to Sphinx notation.
This allows to automatically have nicely looking formulae in HTML output when
using Sphinx with e.g. sphinx.ext.mathjax extension.
2014-08-22 17:45:21 +02:00
Vadim Zeitlin
15b369028f Allow using enum elements as default values for Python functions.
Enum values are just (integer) constants in Python and so can be used as the
function default values just as well as literal numbers, account for this when
checking whether function parameters can be represented in Python.

Also rename is_primitive_defaultargs() to is_representable_as_pyargs() to
describe better what this function does.
2014-08-17 01:08:32 +02:00
Vadim Zeitlin
7d2743a0bb Use reST inline markup in PyDocConverter instead of Markdown.
reST is standard Python markup, so use *...*, ``...`` and so on instead of
_..._, '...' etc.

No other changes even though the mapping of some Doxygen tags to markup used
for them seems suspicions (e.g. \var almost certainly should be the same as
\em).
2014-08-13 16:11:30 +02:00
Vadim Zeitlin
b374aad0da Use Sphinx-compatible docstring format in PyDocConverter.
Use the more or less standard :param:, :type:, :return: and :raises: in the
function/methods descriptions.

Update the output expected from the Python tests accordingly.
2014-08-13 16:11:30 +02:00
Vadim Zeitlin
329d64bb04 Show the diff when a Doxygen test fails.
This is much more readable than just dumping the expected output and the
actual result produced by SWIG, especially for longer Doxygen comments.

Remove the bunch of commented out code and also do not save the results
in the file, this is not very useful as it's not even clear which test the
files correspond to and annoying when these files are left over later. If
anybody really uses this functionality, it ought to be optional.
2014-08-13 16:11:30 +02:00
Vadim Zeitlin
6cce652762 Merge latest master into doxygen branch again.
Update Doxygen-specific Python unit tests to work with the new indentation.

Update one of Doxygen-specific Java tests to still build with the new handling
of srcdir.
2014-08-13 16:11:21 +02:00
Julien Schueller
11b5a61879 Check multi-module examples. Dont use sed. 2014-06-10 08:59:55 +02:00
Julien Schueller
7a4cef998c Enable pep8 check 2014-06-07 13:10:27 +02:00
Karl Wette
b8026cc02f Fix cleaning of Python runme.py scripts for in-source-tree builds 2014-05-29 14:40:50 +02:00
Karl Wette
cc0738bbda Fully clean Python examples and test-suite 2014-05-29 02:29:27 +02:00
Harvey Falcic
91e93838fc unicode_strings test: manually check values instead of using assert 2014-05-24 18:00:04 -04:00
Harvey Falcic
ab527b0e4b unicode_strings_runme.py: fix version check
Python 3.0.1 shouldn't pass.
2014-05-24 17:57:16 -04:00
Harvey Falcic
2533d0210f unicode_strings test: check return values 2014-05-24 16:50:33 -04:00
Harvey Falcic
5c5dfc106f Python unicode_strings test case: restrict to Python > 3.0
Also adjust the test method names and content to match the docs.
2014-05-24 15:39:53 -04:00
Harvey Falcic
791f070e66 Add "unicode_strings" test case for new Python 3 behavior 2014-05-23 15:40:01 -04:00
William S Fulton
2b5499a262 Slight simplification of test-suite build for new out-of-source changes
Provide default SRCDIR and SCRIPTDIR variables in common.mk and override
only where needed.
2014-05-15 23:11:07 +01:00
Vadim Zeitlin
f6ba7b9148 Make Doxygen unit test supporting module Python3-friendly.
Add parentheses around print argument to make the same code work in both
Python2 and Python3.
2014-05-15 01:01:31 +02:00
Karl Wette
f574a34155 Allow examples and test-suite to be built out of source tree
- Examples/Makefile.in rules use SRCDIR as the relative source directory

- ./config.status replicates Examples/ source directory tree in build
  directory, and copies each Makefile to build directory, prefixed with
  a header which sets SRCDIR to source directory

- Examples/test-suite/.../Makefile.in set SRCDIR from Autoconf-set srcdir

- Examples/test-suite/errors/Makefile.in needs to filter out source
  directory from SWIG error messages

- Lua: embedded interpreters are passed location of run-time test

- Python: copy run-time scripts to build directory because of 2to3
  conversion; import_packages example copies __init__.py from source
  directory; test-suite sets SCRIPTDIR to location of run-time tests

- Javascript: binding.gyp renamed to binding.gyp.in so that $srcdir
  can be substituted with SRCDIR; removed './' from require() statements
  so that NODE_PATH can be used to point Node.js to build directory
2014-05-11 23:21:10 +02:00
Vadim Zeitlin
c5e5978287 Merge with the master again.
Bring in the recent JavaScript changes.
2014-05-07 23:25:33 +02:00
Karl Wette
d5b765d388 Whitespace cleanup of all Makefiles*
- some of the %.clean rules in the test-suite Makefiles were using a single tab
  as an empty rule, dangerous! I've replaced these with the safer '@exit 0'.
2014-05-02 20:06:11 +02:00
Vadim Zeitlin
1ebd2334b8 Merge branch 'master' into doxygen
Merge with ~3.0.1 sources from master.
2014-04-30 18:37:57 +02:00
William S Fulton
0fdfa3b6ce Add runtime test for commit 7a96fba836 2014-03-31 19:29:19 +01:00
William S Fulton
e5f928e97a Add metaprogramming type_traits example in C++11 documentation 2014-03-14 01:57:16 +00:00
William S Fulton
01ce992f5d C++11 result_of testcase 2014-03-14 01:57:16 +00:00
William S Fulton
504c2030bb Change in default behaviour wrapping C++ bool for Python.
Only a Python True or False will now work for C++ bool parameters.
This fixes overloading bool with other types.
2014-03-08 12:04:19 +00:00
William S Fulton
4fb940d913 Further fixes when using type() when using -builtin to include module name
Using type() on a builtin type should include the package and module
name, see http://docs.python.org/2/c-api/typeobj.html
2014-03-01 23:26:27 +00:00
William S Fulton
a3a0535229 Add testcase and info on python -builtin missing argument count check 2014-03-01 16:44:01 +00:00
William S Fulton
c5911cc08d Add %$isextendmember for %rename of members added via %extend 2014-02-18 23:21:46 +00:00
William S Fulton
9cbd742b66 Fix %$ismember %rename predicate for members added via %extend
Bug reported was incorrect renaming of PHP built-in functions, such as
next. See PHPFN in phpkw.swg.

Add some tests for the %rename predicates.
2014-02-18 07:30:55 +00:00
William S Fulton
844695b674 Fix typedef_typedef test 2014-02-06 19:31:31 +00:00
William S Fulton
e531578c54 Modify typedef_typedef testcase to work for all languages
Add CHANGES note

Closes #112.
2014-01-14 07:21:40 +00:00
Yann Diorcet
2e186244d6 Add test for checking prefix resolving in typedef 2014-01-14 07:21:40 +00:00
Vadim Zeitlin
cdf1ba9120 Don't accept strings too long to fit in char[N] with trailing NUL.
It was previously possible to assign "hello" to a variable backed by char[5]
storage in C, and the array contained the correct character data but without
the trailing NUL, which was unexpected in C.

This is not allowed any more, only "helo" can fit into a char[5] now and
anything else fails the type check, just as it already happened for the longer
strings before.

Closes #122
2013-12-23 21:13:25 +00:00
Vadim Zeitlin
88a0e228a9 Change the length of strings created from fixed-size buffers.
Use the usual C rule for NUL-terminated strings instead of discarding all the
trailing NUL characters.

This was unexpected (as buffers in C code are not necessarily always padded
with NULs to their full length) and also inconsistent among languages as this
was only done for those of them using typemaps/strings.swg but not for C# or
Java, for example, which terminated the string at the first NUL even before
this change.

Notice that this patch couldn't use strlen() or wcslen() with possibly not
NUL-terminated strings, so we had to add [our own equivalents of] strnlen()
and wcsnlen() and use them instead. This required adding yet another parameter
to string typemap macros, so update the example using them accordingly too.
2013-12-23 21:12:17 +00:00
Vadim Zeitlin
ed28725a15 Add std_auto_ptr.i defining typemaps for returning std::auto_ptr<>.
These typemaps are currently defined for C#, Java and Python only and the
tests are provided only for these languages.

Also add a brief description of the new header to the documentation.
2013-12-03 23:45:20 +01:00
Vadim Zeitlin
72afb74f47 Add support for case conversion characters in regex substitutions.
Allow using Perl-like \l, \L, \u, \U and \E escape sequences in the
substitution string used with %rename("%(regex:/pattern/subst/)s").
This is useful for e.g. title casing all string after removing some prefix.

Closes #82
2013-10-15 07:17:56 +01:00
William S Fulton
bcb7aee022 Merge branch 'master' into gsoc2009-matevz
Conflicts:
	Examples/Makefile.in
	Examples/guile/Makefile.in
	Lib/php/php.swg
	Makefile.in
	Source/CParse/parser.y
	configure.ac
2013-10-10 07:26:09 +01:00
William S Fulton
738cc36aab Rename all C++0x to C++11 and cpp0x to cpp11 2013-10-07 20:37:00 +01:00
William S Fulton
a91cd0bc5c Infinity is now by default an acceptable value for type 'float'.
This fix makes the handling of type 'float' and 'double' the same. The implementation requires the
C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available.
2013-09-12 07:28:12 +01:00
William S Fulton
b58dabced9 %implicitconv is improved for overloaded functions.
Like in C++, the methods with the actual types are considered before trying implicit conversions.
2013-08-28 20:30:46 +01:00
William S Fulton
1cc735df5e %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer.
Problem highlighted by Bo Peng on the swig-user mailing list. SF patch #230.
2013-08-28 20:28:15 +01:00
William S Fulton
1c44078751 Improve testing of %pythonprepend and %pythonappend 2013-07-02 20:00:17 +01:00
William S Fulton
ace8fcd972 SWIG_AsWCharPtrAndSize improper operation if cptr NULL
SF bug #1327

This doesn't have any noticeable effect with the usage of
SWIG_AsWCharPtrAndSize as shipped by SWIG, but could be a problem if a
user is using this function with cptr equal to zero and psize is non-zero
 - the length would be incorrectly set due to the call to PyUnicode_GetSize
failing.
2013-07-02 18:58:56 +01:00
Paweł Tomulik
c9295401da clean all .py files generated by python-test-suite
Closes #49
2013-06-04 22:23:53 +01:00