Commit graph

2,970 commits

Author SHA1 Message Date
William S Fulton
9defd8e033 Add support for differentiating target language statuses
Three status: Disabled, Experimental and Supported.

Any target language classified as 'Experimental' will issue new warning
524 SWIGWARN_LANG_EXPERIMENTAL.
Any target language classified as 'Disabled' will error out.

Languages will be classified in forthcoming commits.

Issue #1437
2019-02-04 18:46:16 +00:00
William S Fulton
b50e5fac8e Python docstring - add in missing Delete calls 2019-02-03 00:28:53 +00:00
William S Fulton
64a7678759 Remove some unnecessary casts in Python builtin code 2019-02-03 00:28:02 +00:00
William S Fulton
62c5ca89a6 Minor refactoring of generated Python code 2019-02-03 00:27:57 +00:00
William S Fulton
fddaf3f814 Minor refactoring of Python autodoc related code 2019-02-02 21:42:47 +00:00
William S Fulton
1e2190e6b8 Merge branch 'ahnolds-autodoc'
* ahnolds-autodoc:
  Apparently nicely lining things up violates pep8, so don't try
  Don't use bool in the generated files for C compatability
  Properly handle destructors as methods for autodoc and fix some stray newlines
  Fixing a bug where the cached doxygen docstring could be deleted while still in use, causing swig to segfault
  Fixing docstrings for variables and static functions for consistency
  Fixes so that fastproxy and autodoc work correctly with both low-level C API and high-level Python Shadow API
  Updating the changelog
  Also check documentation on the low-level API
  Fix a bug where anonymous arguments were misnumbered when used in constructors
  Fixing python docstring handling for -fastproxy

Conflicts:
	CHANGES.current
2019-02-02 21:39:48 +00:00
Olly Betts
ec72026285 Stop defaulting to Tcl
SWIG now requires a target language to be specified instead of
defaulting to wrapping for Tcl.  Specifying swig --help without
a target language now just shows the generic help.  The -nolang
option has been removed.
2019-02-01 12:57:00 +13:00
William S Fulton
528f33e9e5 Merge branch 'ZackerySpytz-OCaml-eliminate-wno-write-strings'
* ZackerySpytz-OCaml-eliminate-wno-write-strings:
  [OCaml] Remove support for OCaml versions < 3.12.0
  [OCaml] Fix toplevel creation for ocamlmktop versions >= 4.04.0
  [OCaml] Eliminate use of -Wno-write-strings
2019-01-31 07:29:09 +00:00
William S Fulton
526b2cf0ae Merge branch 'ZackerySpytz-OCaml-director-classes-throw'
* ZackerySpytz-OCaml-director-classes-throw:
  [OCaml] Fix handling of exception specifications for director classes
2019-01-31 07:21:50 +00:00
William S Fulton
c6d2c7703e Merge branch 'ZackerySpytz-OCaml-overloaded-duplicates'
* ZackerySpytz-OCaml-overloaded-duplicates:
  [OCaml] Don't generate duplicate declarations for overloaded functions
2019-01-31 07:18:22 +00:00
Alec Woods
120a6df838 Apparently nicely lining things up violates pep8, so don't try 2019-01-26 13:39:50 -05:00
Alec Woods
ed81f8ac73 Don't use bool in the generated files for C compatability 2019-01-26 09:30:26 -05:00
Alec Woods
98023054c6 Properly handle destructors as methods for autodoc and fix some stray newlines 2019-01-26 09:30:26 -05:00
Alec Woods
e150d58092 Fixing a bug where the cached doxygen docstring could be deleted while still in use, causing swig to segfault 2019-01-26 09:30:26 -05:00
Alec Woods
5106573b29 Fixing docstrings for variables and static functions for consistency 2019-01-26 09:30:26 -05:00
Alec Woods
86e08c8e34 Fixes so that fastproxy and autodoc work correctly with both low-level C API and high-level Python Shadow API 2019-01-26 09:30:26 -05:00
Alec Woods
97a624f360 Fix a bug where anonymous arguments were misnumbered when used in constructors 2019-01-26 09:30:26 -05:00
Alec Woods
591a70378e Fixing python docstring handling for -fastproxy 2019-01-26 09:30:26 -05:00
Zackery Spytz
35663b1622 [OCaml] Fix handling of exception specifications for director classes
The OCaml module was generating invalid code for director classes
which contain methods with exception specifications. The fix is based
on some of the code in python.cxx's classDirectorMethod().

This commit fixes compilation failures for a number of director unit
tests.

Add director_exception_catches_runme.ml,
director_exception_nothrow_runme.ml, and director_ignore_runme.ml.
2019-01-26 05:58:38 -07:00
Zackery Spytz
f1a29ef6ec [OCaml] Don't generate duplicate declarations for overloaded functions
The OCaml module was generating duplicate declarations in the ml
and mli files for overloaded functions.  For every wrapper function
created for an overloaded function, it would generate a duplicate of
the dispatch function in the ml and mli files.

In addition, add the SWIG banner to generated ml and mli files.
2019-01-25 08:45:59 -07:00
Zackery Spytz
4ca7cd7b27 [OCaml] Eliminate use of -Wno-write-strings
Don't convert string literals to char * in the strings_test example.

In constantWrapper(), use SwigType_str() instead of SwigType_lstr()
in order to keep const qualifiers.
2019-01-24 05:32:35 -07:00
Zackery Spytz
4074f788b3 [OCaml] Fix %allowexception
OCaml's variableWrapper() wasn't calling emit_action_code() for
in/out typemaps, which meant that %allowexception was being ignored.

In addition, remove all comments in the typemaps in Lib/ocaml. In the
case of the allowexcept test, one of the typemap comments caused
compilation to fail because it became nested within another comment
in an %exception block.

Re-enable the allowexcept test.
Add allowexcept_runme.ml.
2019-01-22 07:51:45 -07:00
William S Fulton
d04b51881e Merge branch 'vadz-other-langs-autodoc-params'
* vadz-other-langs-autodoc-params:
  Harmonize parameters in autodoc in Ruby and Octave with Python
2019-01-22 07:50:32 +00:00
William S Fulton
8a1ad6adc6 Merge branch 'vadz-py-restore-autodoc-defval'
* vadz-py-restore-autodoc-defval:
  Always include default parameter values in Python autodoc strings
2019-01-22 07:21:31 +00:00
William S Fulton
d8478d671d Fix segfault using -python -noproxy and %pythonbegin 2019-01-21 07:50:48 +00:00
Vadim Zeitlin
cd526caed4 Harmonize parameters in autodoc in Ruby and Octave with Python
Backport changes to Python version of make_autodocParmList() to Ruby and
Octave modules, which use similar code.

In particular, this improves handling of parameters clashing with the
language keywords/reserved words for these languages as well.
2019-01-21 01:08:45 +01:00
Vadim Zeitlin
1e22e791ef Always include default parameter values in Python autodoc strings
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.
2019-01-21 00:57:02 +01:00
Olly Betts
3b03f920e7 Suppress warnings about PyCFunction casts
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.
2019-01-20 12:27:36 +13:00
William S Fulton
65cab79071 Merge branch 'ZackerySpytz-OCaml-dead-code-overloaded-funcs'
* ZackerySpytz-OCaml-dead-code-overloaded-funcs:
  [OCaml] Fix dead code generation in overloaded function wrappers
2019-01-19 23:03:07 +00:00
William S Fulton
6634016962 Merge branch 'ZackerySpytz-OCaml-error-msg-incorrect-overloaded-call'
* ZackerySpytz-OCaml-error-msg-incorrect-overloaded-call:
  [OCaml] Improve the error message for incorrect overloaded function calls
2019-01-19 22:59:12 +00:00
William S Fulton
2e9b270cbb Merge branch 'vadz-better-param-names'
* 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
2019-01-17 18:19:36 +00:00
Zackery Spytz
b3f903722b [OCaml] Improve the error message for incorrect overloaded function calls
List the possible prototypes in the error message. The code was taken
from python.cxx's dispatchFunction().
2019-01-16 23:08:12 -07:00
Zackery Spytz
fa1a0a378c [OCaml] Fix dead code generation in overloaded function wrappers
The OCaml module was generating dead code in the wrappers for
overloaded functions. Only the generated dispatch function needs to
allocate an array for the passed arguments.

In addition, add overload_extend, overload_rename and overload_subtype
runtime tests.
2019-01-16 20:00:40 -07:00
William S Fulton
32a8cd8f2f Merge branch 'ZackerySpytz-OCaml-constant-char-wrapping'
* ZackerySpytz-OCaml-constant-char-wrapping:
  [OCaml] Fix the wrapping of static const member chars
2019-01-16 21:46:57 +00:00
William S Fulton
e210982b7c Merge branch 'ZackerySpytz-OCaml-caml_-prefix'
* ZackerySpytz-OCaml-caml_-prefix:
  [OCaml] Add the caml_ prefix to some OCaml functions
2019-01-16 21:44:20 +00:00
William S Fulton
cf1624ebc4 Python static method wrapper changes
- 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.
2019-01-16 08:21:00 +00:00
Vadim Zeitlin
3f5c17824c Improve handling parameters clashing with language keywords
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.
2019-01-16 04:16:59 +01:00
Zackery Spytz
c61c221057 [OCaml] Fix the wrapping of static const member chars
OCaml's constantWrapper() was adding unneeded quotes when wrapping
static const member chars.

Add runtime tests for char_constant, chartest, and
static_const_member.
2019-01-15 16:37:26 -07:00
Zackery Spytz
05589508a6 [OCaml] Add the caml_ prefix to some OCaml functions
In OCaml 3.08.0, many functions in the OCaml C API were renamed to
include a caml_ prefix. Their previous names were retained as macros
in caml/compatibility.h and were (apparently) deprecated.

Rename occurrences of alloc_string, alloc_tuple, callback, callback2,
callback3, copy_double, copy_int64, copy_string, failwith, and modify
in the OCaml module.

The OCaml module requires OCaml >= 3.08.3, so this change is safe
for all supported OCaml versions.
2019-01-14 20:45:13 -07:00
William S Fulton
b64d685d5f Merge branch 'ZackerySpytz-OCaml-fix-member-var-access'
* ZackerySpytz-OCaml-fix-member-var-access:
  OCaml's classHandler() requires name, not sym:name.
  [OCaml] Fix member var getters and setters
2019-01-11 18:42:19 +00:00
Zackery Spytz
4ca6fdc551 OCaml's classHandler() requires name, not sym:name.
In classHandler(), assign sym:name to the classname global so that it
can be used in membervariableHandler().

Add a small runme test for li_std_vector.
Use swigp4 when compiling the runme tests.
2019-01-08 20:10:07 -07:00
William S Fulton
c4481362b1
Merge pull request #1396 from ZackerySpytz/OCaml-unused-_v-var
[OCaml] Don't generate unused _v variables
2019-01-07 08:24:33 +00:00
Zackery Spytz
4a912668fc [OCaml] Fix member var getters and setters
Add `membervariableHandler()` to the `OCAML` class in ocaml.cxx (it is
partly based on the code in python.cxx and octave.cxx).

In Lib/ocaml/class.swg, wrapped classes/structs were not being added
to `class_master_list`. This is fixed by adding a call to
`register_class_byname`.

Add a unit test in the form of struct_value_runme.ml.
2019-01-06 09:40:25 -07:00
William S Fulton
96d33287b4 Fix Ruby docstring feature.
The docstring was not encapsulated within /* */ comments.

The implementation had code for autodoc strings being either single or
multi-line and then adding extra newlines. However, in practice only multi-line
autodoc string are ever generated, so this bit of code handling was removed.
The docstring feature does not attempt to add newlines depending on the
existence of newlines in the docstring.

Closes #538
2019-01-05 19:21:04 +00:00
Zackery Spytz
fe85dd22d8 [OCaml] Don't generate unused _v variables 2019-01-05 11:17:06 -07:00
William S Fulton
6a80ec314a Merge branch 'typecheck-null-nonpointers'
* typecheck-null-nonpointers:
  Fix overloading for non-pointers and NULL - MzScheme
  Overloading for non-pointers and NULL - Chicken
  Fix overloading for non-pointers and NULL - Scilab
  Fix overloading for non-pointers and NULL - R
  Fix overloading for non-pointers and NULL - Php
  Fix overloading for non-pointers and NULL - Octave
  Fix overloading for non-pointers and NULL - Lua
  Overloading for non-pointers and NULL - Javascript
  Fix overloading for non-pointers and NULL - Guile
  Fix overloading for non-pointers and NULL - Tcl
  Fix overloading for non-pointers and NULL - Perl
  Fix overloading for non-pointers and NULL - Ruby
  Add test for overloading and NULL
  Correct Python implicitconv code
  Fix typecheck typemaps for non-pointers and NULL
2019-01-03 08:13:19 +00:00
William S Fulton
07884f10ee Python - remove duplicate proxy method definitions for global function wrappers.
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.
2019-01-01 12:12:56 +00:00
William S Fulton
f181d20dd1 Fix overloading for non-pointers and NULL - R 2018-12-30 13:46:51 +00:00
William S Fulton
d314b53820 Python -newvwm command line option remains undocumented
Remove option from -help output text
It is hard to explain exactly what it does and is unclear as to how useful it is!
2018-12-18 19:51:38 +00:00
William S Fulton
5d6786598c Python command line options tidyup 2018-12-18 19:51:38 +00:00