Commit graph

2,493 commits

Author SHA1 Message Date
Joseph C Wang
834a93f449 Revert "Merge pull request #494 from richardbeare/enumR2015B"
This reverts commit cb8973f313, reversing
changes made to ac3284f78c.
2015-08-11 09:57:57 +08:00
joequant
cb8973f313 Merge pull request #494 from richardbeare/enumR2015B
replacement for enumR2015 - tidied and rebased
2015-08-10 13:37:27 +08:00
Richard Beare
da1c6c60d3 This is a modification to support use of tricky enumerations in R. It
includes the addition of a _runme for an existing test - preproc_constants
that was previously not run. That tests includes a preprocessor based
setting of an enumeration which is ignored by the existing r enumeration
infrastructure. The new version correctly reports the enumeration value
as 4 - previous versions set it to 0. Traditional enumerations are unchanged.

The approach used to deal with these enumerations is similar to that of
other languages, and requires a call to a C function at runtime to return
the enumeration value. The previous approach figured out the values statically
and this is still used where possible. The need for a runtime call leads to
changes in when swig code is used in packages - see below.

One test that previously passed now fails - namely the R sourcing of
preproc_constants.R, as the enumeration code requires the shared library,
which isn't loaded by that script.

There is also a modification to the way the R _runme.R files are used.
The call to R CMD BATCH now includes a --args option that indicates
the source folder for the unittest.R file, and the first couple
of lines of the _runme.R files deal with correctly locating this.
Out of source tests now run correctly.

This work was motivated by problems generating the SimpleITK binding,
specifically with some of the more complex enumerations.

This approach does have some issues wrt to code in packages, but I can't
see an alternative. The problem with packages is that the R code setting
up the enumeration structures requires the shared library so that the C
functions returning enumeration values can be called. The enumeration
setup code thus needs to be moved to the package initialisation section.
For SimpleITK I do this using an R script, which I think is an acceptable
solution. The core part of the process is the following function. I dump
all the enumeration stuff into a .onload function. This is only necessary
if some of the enumerations are tricky.

splitSwigFile <- function(filename, onloadfile, mainfile)
{
p1 <- parse(file=filename)

getdefineEnum <- function(X)
{
return (is.call(X) & (X[[1]]=="defineEnumeration"))
}

dd <- sapply(p1, getdefineEnum)

enums <- p1[dd]
enums <- unlist(lapply(enums, deparse))

enums <- c(".onLoad <- function(libname, pkgname) {", enums, "}")

everythingelse <- p1[!dd]
everythingelse <- unlist(lapply(everythingelse, deparse))
writeLines(everythingelse, mainfile)
writeLines(enums, onloadfile)

}
2015-08-10 09:37:04 +10:00
xantares
92328a2016 pep257 & numpydoc conforming docstrings 2015-08-07 22:15:13 +01:00
William S Fulton
c6f8aadc64 Cosmetic corrections - Mac OS X 2015-08-02 20:14:20 +01:00
William S Fulton
e69cc0c0f5 Improve python code indentation warning / error messages 2015-07-30 08:26:17 +01:00
William S Fulton
a779f9bbc1 Function comment header formatting corrections 2015-07-30 08:26:17 +01:00
William S Fulton
fa282b3540 Improve Python docstring indentation handling
SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring
feature.
SWIG-3.0.6 gave a 'Line indented less than expected' error instead of
truncating the docstring text.
Now the indentation for the 'docstring' feature is smarter and is
adjusted so that no truncation occurs.

Closes #475
2015-07-30 08:26:08 +01:00
xantares
812f789db6 Avoid gcc uninitialized variable warnings in Python wrappers.
Just initialize the local array with zeroes.

Closes #453.
2015-07-25 19:10:06 +02:00
William S Fulton
457e0bfa81 Typemap attribute fixes
Fix for breakages in previous few commits:
- Perl test-suite - the "varout" typemap "type" attribute is now
  expanded in typemap.c instead of Perl.cxx.
- The swig_typemap_warn errors testcase showed that $1 was no longer
  being expanded correctly when used in output typemaps (lname not set).
2015-07-24 00:32:46 +01:00
William S Fulton
a00ab42f80 Merge branch 'm7thon-issue-445-python-class-docstrings'
* m7thon-issue-445-python-class-docstrings:
  Add changes note for Python tp_doc slot and docstring
  Set class docstring in tp_doc slot for python -builtin

Conflicts:
	CHANGES.current
2015-07-18 00:14:37 +01:00
Anbiru Shouta
977240b3f4 Clearer variable name in Java director generated code
Closes #463
2015-07-17 22:34:08 +01:00
Michael Thon
7ed63b11d7 Set class docstring in tp_doc slot for python -builtin 2015-07-09 02:05:33 +02:00
William S Fulton
3718b810c7 Don't generate constructor wrappers if a base class has a private constructor
g++-5 errors out with this now with errors such as:

default_constructor_wrap.cxx:665:27: error: use of deleted function ‘FFF::FFF()’
   result = (FFF *)new FFF();
                           ^
default_constructor_wrap.cxx:314:7: note: ‘FFF::FFF()’ is implicitly deleted because the default definition would be ill-formed:
 class FFF : public F {
       ^
default_constructor_wrap.cxx:301:4: error: ‘F::~F()’ is private
    ~F() { }
    ^
default_constructor_wrap.cxx:314:7: error: within this context
2015-07-07 20:15:55 +01:00
William S Fulton
edcdaaec16 Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
Nils Gladitz
925cec3a82 Add a space between literal and string macro
In C++11 a space between a literal and string macro is required.
2015-07-03 20:59:23 +01:00
Olly Betts
822b2355c0 Improve handling of whitespace in %pythoncode
Previously SWIG looked at the indentation of the first line and removed
that many characters from each subsequent line, regardless of what those
characters were.  This was made worse because SWIG's preprocessor removes
any whitespace before a '#'.  Fixes github issue #379, reported by Joe
Orton.
2015-06-29 22:12:38 +12:00
Simon Marchetto
b05f0057ca improve support of varargs 2015-06-23 16:24:35 +02:00
Ian Lance Taylor
11d8403c3c [Go] Fix member variables in base classes to handle CWRAP_NATURAL_VAR
correctly.  Add a test case for the problem.

Fixes #339.
2015-06-20 17:42:44 -07:00
William S Fulton
53b7659ebf Fix Python pep8 warning when using -fastinit (or -O)
Fixes: E231 missing whitespace after ','
2015-06-16 08:11:29 +01:00
William S Fulton
180e21269d Fix python -builtin -O and overloaded functions
More specifically fixes compile errors using -builtin -fastunpack -modernargs.
Recent regression (416277b). Closes #436.
2015-06-16 07:59:22 +01:00
William S Fulton
b94820adcf Fix r.cxx build break 2015-06-12 23:37:08 +01:00
William S Fulton
9b2bde403b R - Remove constantWrapper message wrapping constants
An implementation is still needed for constants.
2015-06-12 20:26:24 +01:00
William S Fulton
cc6970e21f Documentation improvements for -o and -oh options 2015-06-12 06:32:58 +01:00
William S Fulton
8bd6e596d1 Cosmetics - remove references to Java in C# module 2015-06-11 19:39:51 +01:00
William S Fulton
2b9b007027 C# -outfile cosmetic code fixes 2015-06-11 07:42:50 +01:00
Frederick Parotat
b83307e354 [C#] Single file mode (fixes)
Renamed argument '-csout' to '-outfile'.
Reformatting (Tab spacing; Pointer style).
Chagned html documentation.
2015-06-04 14:15:00 +02:00
Frederick Parotat
0b09978219 [C#] Single file mode (minor fix)
Removed debug output
2015-06-03 14:26:38 +02:00
Frederick Parotat
747e22f714 [C#] Single file mode
Added "-csout <path>" parameter. If supplied all generated C# code will
be written to the given file. Makes it easier to integrate SWIG into
automated script based build processes.
2015-06-03 14:19:13 +02:00
William S Fulton
b8e1a66a38 Add new feature "python:cdefaultargs"
Controls default argument code generation to obtain the default
arguments from the C++ layer instead of the Python layer.
2015-05-28 20:11:57 +01:00
William S Fulton
986a13f1a0 Fix Python typedef bool default arguments that are not booleans.
Includes code optimisation in PYTHON::convertValue().

Closes #327
2015-05-27 20:55:56 +01:00
William S Fulton
0a70498591 Refactor PYTHON::convertValue
Remove multiple return statements for upcoming commits.
2015-05-27 08:06:23 +01:00
Ian Lance Taylor
38c7d59f81 [Go] Adjust last change to always emit a destructor. 2015-05-18 11:28:24 -07:00
Ian Lance Taylor
5bca063536 [Go] Fix bug with ignored destructor--generated code did not compile. 2015-05-18 09:53:13 -07:00
William S Fulton
775afd3579 Refactor Java director swig_override array code
Remove code duplication: Use new Swig::BoolArray to replace multiple
instances of ZeroedBoolArray.

Refactors #403 and #413.
2015-05-10 11:40:42 +01:00
Olly Betts
9086eb351c Merge pull request #413 from LindleyF/master
Don't include an STL header in SWIG.
2015-05-08 11:57:13 +12:00
Lindley French
8f19d77fec Don't include an STL header in SWIG. 2015-05-07 11:29:47 -07:00
Olly Betts
c2972b8bf0 [Python] Deal with an integer as the default value of a bool
parameter in the C++ prototype.  Fixes github #327, reported by
Greg Allen.
2015-05-07 16:25:32 +12:00
Olly Betts
8fc7796643 Merge pull request #403 from LindleyF/master
Zero-initialize swig_override in the director constructor.
2015-05-07 13:26:04 +12:00
Lindley French
159b3c7958 Use a bitset which is automatically initialized to 0, instead of a bool array which is not. 2015-05-06 11:33:28 -07:00
William S Fulton
428b6176df Add support for friend templates, including operator overloading.
Closes #196.
2015-05-05 06:48:25 +01:00
Ian Lance Taylor
48263f4802 [Go] Make sure that arguments for which use memcpy when calling C are
still live after the call.  This ensures that they will not be
collected if the GC runs during the call.
2015-05-04 15:11:31 -07:00
Lindley French
5f0181bfdd Too hard to conditionally define the memset....instead just make sure the array is defined even if it's unused. 2015-05-01 12:40:07 -07:00
Lindley French
e8ca8fb2e6 Only output memset if the array exists. 2015-04-30 23:14:48 -07:00
Lindley French
8acca78953 Zero-initialize swig_override in the director constructor. 2015-04-30 21:16:30 -07:00
Vadim Zeitlin
6988b00aba Fix handling of default arguments after ignored ones in Python.
Don't skip checking subsequent arguments just because one of them has "in"
typemap with numinputs=0 attribute.

Add a unit test showing the problem which is relatively rare as it doesn't
happen for the class methods and is hidden unless autodoc feature is used for
the global functions.

Closes #377.
2015-04-27 23:17:14 +02:00
William S Fulton
d64c241e1c gcc-5.1 warning fixes 2015-04-26 01:18:26 +01:00
William S Fulton
416277b3a5 Python code generated with '-builtin -modernargs' segfaults for any method taking zero arguments.
Also fixes: "SystemError: error return without exception set" during error checking
when using just -builtin and the incorrect number of arguments is passed to a class
method expecting zero arguments.

Closes #256
Closes #382
2015-04-24 21:08:17 +01:00
William S Fulton
e4d02d20ad Warning fix for VC++ 2015-04-23 19:21:59 +01:00
Vadim Zeitlin
5569d91bd0 Fix handling of "default" typemap in Python.
Use "compact" arguments form for the function if "default" typemap is defined
for any of its arguments to allow omitting this argument when calling it from
Python.

Closes #377.
2015-04-23 15:11:05 +02:00