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
In addition to the changes in the previous commit, also avoid syntax
errors in the generated Python docstrings by splitting them into several
parts if there are 3 quotes in a row in the input, as it's impossible to
have them inside triple-quoted strings, generally speaking (i.e. if
there are occurrences of both """ and ''' inside the string).
Single-line Doxygen comments ending with a double quote resulted in
syntactically-invalid Python docstrings in the output, so use triple
single quotes as delimiters in this case to avoid it.
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.
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
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
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.
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.
nested_in_template_wrap.cxx(247): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
python_pybuffer_wrap.cxx(2788): warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
Modules\python.cxx(2227) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
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.
One of side effects of 15b369028f was that
the default values were only included in Python doc strings if we could
be sure that they could be interpreted as valid Python expressions, but
this change was actually undesirable as it may be useful to see C++
expression for the default value in the doc string even when it isn't
valid in Python.
Undo this part of the change and extend autodoc unit test to check that
this stays fixed.
Closes#1271.
These remaining warnings are due to the design of Python's C API,
so suppress them by casting via void(*)(void) (which GCC documents
as the way to suppress this warning).
Closes#1259.
* vadz-better-param-names:
Enable keyword arguments for keyword_rename unit test
Update error messages test suite
Add more tests for Python parameter renaming
Improve handling parameters clashing with language keywords
- Static method wrappers were using the 'fastproxy' approach by default.
This is inconsistent with instance method wrappers. The fastproxy approach
is now turned off by default to be consistent with instance methods.
Static method wrappers can now also be controlled using the -fastproxy and
-olddefs options.
Example:
struct Klass {
static int statmethod(int a = 2);
};
generates:
class Klass(object):
...
@staticmethod
def statmethod(a=2):
return _example.Klass_statmethod(a)
instead of:
class Klass(object):
...
statmethod = staticmethod(_example.Klass_statmethod)
- Modernise wrappers for static methods to use decorator syntax - @staticmethod.
- Add missing runtime test for static class methods and using the actual
class method.
Previously, only Python tried to preserve the original parameter name
(by prepending or appending an underscore to it, but otherwise keeping
the original name) if it conflicted with one of the language keywords,
while all the other languages replaced the parameter name with a
meaningless "argN" in this case.
Now do this for all languages as this results in more readable generated
code and there doesn't seem to be any reason to restrict this to Python
only.
Global functions previously generated two definitions, eg:
def foo():
return _example.foo()
foo = _example.foo
The first definition is replaced by the second definition and so the second definition
is the one used when the method is actually called. Now just the first definition is
generated by default and if the -fastproxy command line option is used, just the second
definition is generated. The second definition is faster as it avoids the proxy Python
method as it calls the low-level C wrapper directly. Using both -fastproxy and -olddefs
command line options will restore the previously generated code as it will generate both
method definitions.
With this change, the wrappers for global C/C++ functions and C++ class methods now work
in the same way wrt to generating just a proxy method by default and control via
-fastproxy/-olddefs options.
Closes#639.