swig/Source/Modules
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
..
allegrocl.cxx Clearer warning message for badly constructed typecheck typemaps 2015-04-14 07:34:40 +01:00
allocate.cxx Don't generate constructor wrappers if a base class has a private constructor 2015-07-07 20:15:55 +01:00
browser.cxx Add lambda functions to the symbol tables and add ability to suppress lambda warnings. 2013-02-04 20:05:34 +00:00
cffi.cxx CFFI: handle array struct/union members. 2014-12-20 17:12:39 +03:00
chicken.cxx Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
clisp.cxx Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
contract.cxx Cosmetics/code beautification of nested class support 2013-11-29 07:29:58 +00:00
csharp.cxx Cosmetics - remove references to Java in C# module 2015-06-11 19:39:51 +01:00
d.cxx Create director_common.swg for language-indep code 2015-03-12 19:51:11 +13:00
directors.cxx Add support for thread_local when specified with other legitimate storage class specifiers - extern and static 2013-02-08 06:36:39 +00:00
emit.cxx Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
go.cxx Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
guile.cxx Guile - fix generated code for static const char member variables when defined and declared inline. 2015-02-11 23:34:23 +00:00
java.cxx Clearer variable name in Java director generated code 2015-07-17 22:34:08 +01:00
javascript.cxx Cosmetic corrections - Mac OS X 2015-08-02 20:14:20 +01:00
lang.cxx Don't generate constructor wrappers if a base class has a private constructor 2015-07-07 20:15:55 +01:00
lua.cxx Add c++11 strongly typed enum support for Lua 2014-11-28 07:47:45 +00:00
main.cxx Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
modula3.cxx Partial support for %constant and structs 2014-12-18 07:01:08 +00:00
module.cxx Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
mzscheme.cxx Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
nested.cxx Fix segmentation fault when top==NULL 2015-02-26 14:57:19 +13:00
ocaml.cxx Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
octave.cxx Fix C&P references to Python in comments 2015-03-27 12:40:42 +13:00
overload.cxx Clearer warning message for badly constructed typecheck typemaps 2015-04-14 07:34:40 +01:00
perl5.cxx Typemap attribute fixes 2015-07-24 00:32:46 +01:00
php.cxx Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +01:00
pike.cxx Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
python.cxx Improve python code indentation warning / error messages 2015-07-30 08:26:17 +01:00
r.cxx This is a modification to support use of tricky enumerations in R. It 2015-08-10 09:37:04 +10:00
README File move 2002-12-03 20:33:35 +00:00
ruby.cxx gcc-5.1 warning fixes 2015-04-26 01:18:26 +01:00
s-exp.cxx Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
scilab.cxx improve support of varargs 2015-06-23 16:24:35 +02:00
swigmain.cxx Merge remote-tracking branch 'origin/master' into gsoc2012-scilab 2015-01-26 10:50:20 +01:00
swigmod.h Merge branch 'alexey-pelykh-cpp11_strongly_typed_enums__direct_inject_in_java' 2014-11-21 07:34:12 +00:00
tcl8.cxx gcc-5.1 warning fixes 2015-04-26 01:18:26 +01:00
typepass.cxx obscure case workaround in std::set wrapper, where ignored type still need to be processed 2014-05-19 02:05:23 +04:00
uffi.cxx Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
utils.cxx Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
xml.cxx Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00

06/25/2002

This directory contains all of the SWIG language modules.  Many of these
modules contain code that dates back to SWIG1.0.  The module API has changed
a lot in the development releases so this is fairly messy.  We're working on
cleaning it up, but you'll have to bear with us until it's done.

-- Dave