diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..596615322 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitattributes export-ignore +.gitignore export-ignore diff --git a/.gitignore b/.gitignore index 800ac4669..eb3aa012c 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ CCache/autom4te.cache/ CCache/config.h.in CCache/configure Source/Include/swigconfig.h.in +Source/Include/swigconfig.h.in~ Source/Makefile.in Tools/config/compile Tools/config/config.guess @@ -80,6 +81,7 @@ swig.spec # Build Artifacts .dirstamp CCache/ccache-swig +CCache/ccache-swig.1 Source/CParse/parser.c Source/CParse/parser.h Source/eswig @@ -100,7 +102,6 @@ Examples/test-suite/csharp/*/ Examples/test-suite/d/*/ Examples/test-suite/go/*/ Examples/test-suite/guile/*/ -Examples/test-suite/guilescm/*/ Examples/test-suite/java/*/ Examples/test-suite/lua/*/ Examples/test-suite/mzscheme/*/ @@ -125,3 +126,5 @@ Examples/test-suite/uffi/*/ *_runme.exe.mdb *_runme.exe +# Scratch directories +Examples/scratch diff --git a/ANNOUNCE b/ANNOUNCE index 1c3297a5c..90cc9ba24 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 2.0.10 (in progress) *** +*** ANNOUNCE: SWIG 3.0.0 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-2.0.10, the latest SWIG release. +We're pleased to announce SWIG-3.0.0, the latest SWIG release. What is SWIG? ============= @@ -21,11 +21,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-2.0.10.tar.gz + http://prdownloads.sourceforge.net/swig/swig-3.0.0.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-2.0.10.zip + http://prdownloads.sourceforge.net/swig/swigwin-3.0.0.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CCache/ccache.h b/CCache/ccache.h index 668ce8288..dcbb03f0c 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -159,7 +159,7 @@ int asprintf(char **ptr, const char *format, ...); int snprintf(char *,size_t ,const char *, ...); #endif -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize); +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles); void cleanup_all(const char *dir); void wipe_all(const char *dir); @@ -200,6 +200,8 @@ typedef int (*COMPAR_FN_T)(const void *, const void *); /* mkstemp() on some versions of cygwin don't handle binary files, so override */ +/* Seems okay in Cygwin 1.7.0 #ifdef __CYGWIN__ #undef HAVE_MKSTEMP #endif +*/ diff --git a/CCache/cleanup.c b/CCache/cleanup.c index 99312283e..f54ee54d9 100644 --- a/CCache/cleanup.c +++ b/CCache/cleanup.c @@ -75,21 +75,40 @@ static void traverse_fn(const char *fname, struct stat *st) /* sort the files we've found and delete the oldest ones until we are below the thresholds */ -static void sort_and_clean(void) +static void sort_and_clean(size_t minfiles) { unsigned i; + size_t adjusted_minfiles = minfiles; if (num_files > 1) { /* sort in ascending data order */ qsort(files, num_files, sizeof(struct files *), (COMPAR_FN_T)files_compare); } + /* ensure newly cached files (minfiles) are kept - instead of matching + the filenames of those newly cached, a faster and simpler approach + assumes these are the most recent in the cache and if any other + cached files have an identical time stamp, they will also be kept - + this approach would not be needed if the cleanup was done at exit. */ + if (minfiles != 0 && minfiles < num_files) { + unsigned minfiles_index = num_files - minfiles; + time_t minfiles_time = files[minfiles_index]->mtime; + for (i=1; i<=minfiles_index; i++) { + if (files[minfiles_index-i]->mtime == minfiles_time) + adjusted_minfiles++; + else + break; + } + } /* delete enough files to bring us below the threshold */ for (i=0;ifname) != 0 && errno != ENOENT) { fprintf(stderr, "unlink %s - %s\n", files[i]->fname, strerror(errno)); @@ -103,7 +122,7 @@ static void sort_and_clean(void) } /* cleanup in one cache subdir */ -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles) { unsigned i; @@ -117,7 +136,7 @@ void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) traverse(dir, traverse_fn); /* clean the cache */ - sort_and_clean(); + sort_and_clean(minfiles); stats_set_sizes(dir, total_files, total_size); @@ -151,7 +170,8 @@ void cleanup_all(const char *dir) cleanup_dir(dname, counters[STATS_MAXFILES], - counters[STATS_MAXSIZE]); + counters[STATS_MAXSIZE], + 0); free(dname); free(sfile); } diff --git a/CCache/stats.c b/CCache/stats.c index 92bc4a835..d2122bcd3 100644 --- a/CCache/stats.c +++ b/CCache/stats.c @@ -168,7 +168,8 @@ static void stats_update_size(enum stats stat, size_t size, size_t numfiles) if (need_cleanup) { char *p = dirname(stats_file); - cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE]); + cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE], + numfiles); free(p); } } diff --git a/CCache/test.sh b/CCache/test.sh index 9581c85e3..f64c3e3de 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -142,7 +142,7 @@ basetests() { testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1 - rmdir testd + rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" @@ -315,7 +315,7 @@ swigtests() { testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1 - rmdir testd + rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" diff --git a/CCache/util.c b/CCache/util.c index bba232492..66f9823b9 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -82,7 +82,7 @@ void copy_fd(int fd_in, int fd_out) #ifndef HAVE_MKSTEMP /* cheap and nasty mkstemp replacement */ -static int mkstemp(char *template) +int mkstemp(char *template) { mktemp(template); return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); diff --git a/CHANGES b/CHANGES index 8b1945ad9..4cc222901 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,381 @@ SWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. + +Version 2.0.11 (15 Sep 2013) +============================ + +2013-09-15: wsfulton + [R] Fix attempt to free a non-heap object in OUTPUT typemaps for: + unsigned short *OUTPUT + unsigned long *OUTPUT + signed long long *OUTPUT + char *OUTPUT + signed char*OUTPUT + unsigned char*OUTPUT + +2013-09-12: wsfulton + [Lua] Pull Git patch #62. + 1) Static members and static functions inside class can be accessed as + ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as + ModuleName.ClassName_FunctionName still works. + 2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc. + +2013-09-12: wsfulton + [UTL] 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. + + Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap + wherever a float is used, such as: + + %typemap(check,fragment="") float, const float & %{ + if ($1 < -FLT_MAX || $1 > FLT_MAX) { + SWIG_exception_fail(SWIG_TypeError, "Overflow in type float"); + } + %} + + *** POTENTIAL INCOMPATIBILITY *** + +2013-08-30: wsfulton + [Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages. + This is standard information in Lua error messages, and makes it much + easier to find bugs. + +2013-08-29: wsfulton + Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an + 'Illegal token' syntax error. + +2013-08-29: wsfulton + [C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function. + +2013-08-28: wsfulton + [Python] %implicitconv is improved for overloaded functions. Like in C++, the methods + with the actual types are considered before trying implicit conversions. Example: + + %implicitconv A; + struct A { + A(int i); + }; + class CCC { + public: + int xx(int i) { return 11; } + int xx(const A& i) { return 22; } + }; + + The following python code: + + CCC().xx(-1) + + will now return 11 instead of 22 - the implicit conversion is not done. + +2013-08-23: olly + [Python] Fix clang++ warning in generated wrapper code. + +2013-08-16: wsfulton + [Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer. + Problem highlighted by Bo Peng. Closes SF patch #230. + +2013-08-07: wsfulton + [Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and + make the generated wrapper use the default python implementations, which will fall back to repr + (for -builtin option). + + Advantages: + - it avoids the swig user having to jump through hoops to get print to work as expected when + redefining repr/str slots. + - typing the name of a variable on the python prompt now prints the result of a (possibly redefined) + repr, without the swig user having to do any extra work. + - when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the + redefined repr + - the behaviour is exactly the same as without the -builtin option while requiring no extra work + by the user (aside from adding the %feature("python:slot...) statements of course) + + Disadvantage: + - default str() will give different (but clearer?) output on swigged classes + +2013-07-30: wsfulton + [Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation + of a std::map was erroneously required in addition to an instantiation of std::multimap with the + same template parameters to prevent compilation errors for the wrappers of a std::multimap. + +2013-07-14: joequant + [R] Change types file to allow for SEXP return values + +2013-07-05: wsfulton + [Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is + added at the beginning of the generated .py file. This is primarily needed for importing from + __future__ statements required to be at the very beginning of the file. Example: + + %pythonbegin %{ + from __future__ import print_function + print("Loading", "Whizz", "Bang", sep=' ... ') + %} + +2013-07-01: wsfulton + [Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr + when using -builtin. + +2013-07-01: wsfulton + [Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating + a <:: digraph when using the unary scope operator (::) (global scope) in a template type. + +2013-07-01: wsfulton + [Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on + object deletion when using -builtin. Fixes SF bug #1301. + +2013-06-11: wsfulton + [Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version + of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example + files have been modified to use this so that Debug builds will now work without having + to install or build a Debug build of the interpreter. + +2013-06-07: wsfulton + [Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby + versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type. + Also fix the Complex helper functions external visibility (to static by default). + +2013-06-04: olly + [PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL + if the type lookup fails. + +Version 2.0.10 (27 May 2013) +============================ + +2013-05-25: wsfulton + [Python] Fix Python 3 inconsistency when negative numbers are passed + where a parameter expects an unsigned C type. An OverFlow error is + now consistently thrown instead of a TypeError. + +2013-05-25: Artem Serebriyskiy + SVN Patch ticket #338 - fixes to %attribute macros for template usage + with %arg. + +2013-05-19: wsfulton + Fix ccache-swig internal error bug due to premature file cleanup. + + Fixes SF bug 1319 which shows up as a failure in the ccache tests on + Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. + + This is a corner case which will be hit when the maximum number of files + in the cache is set to be quite low (-F option), resulting in a cache miss. + +2013-05-09: kwwette + [Octave] Fix bugs in Octave module loading: + - fix a memory leak in setting of global variables + - install functions only once, to speed up module loads + +2013-04-28: gjanssens + [Guile] Updates in guile module: + - Add support for guile 2.0 + - Drop support for guile 1.6 + - Drop support for generating wrappers using guile's gh interface. + All generated wrappers will use the scm interface from now on. + - Deprecate -gh and -scm options. They are no longer needed. + A warning will be issued when these options are still used. + - Fix all tests and examples to have a successful travis test + +2013-04-18: wsfulton + Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion + in fragments. For example: + + %fragment("nameDescriptor", "header") + %{ + static const char *nameDescriptor = "$descriptor(Name)"; + %} + + which will generate into the wrapper if the fragment is used: + + static const char *nameDescriptor = "SWIGTYPE_Name"; + +2013-04-18: wsfulton + Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: + + typedef enum { + eZero = 0 + #define ONE 1 + } EFoo; + + The macros are silently ignored. + +2013-04-17: wsfulton + [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. + +2013-04-15: kwwette + [Octave] Fix bugs in output of cleanup code. + - Cleanup code is now written also after the "fail:" label, so it will be called if + a SWIG_exception is raised by the wrapping function, consistent with other modules. + - Octave module now also recognises the "$cleanup" special variable, if needed. + +2013-04-08: kwwette + Add -MP option to SWIG for generating phony targets for all dependencies. + - Prevents make from complaining if header files have been deleted before + the dependency file has been updated. + - Modelled on similar option in GCC. + +2013-04-09: olly + [PHP] Add missing directorin typemap for char* and char[] which + fixes director_string testcase failure. + +2013-04-05: wsfulton + [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL + wrappers that override the default predicate, such as: + + %template(Map) std::map >; + +2013-04-05: wsfulton + [Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some + further 1.9 problems with functors and use of Complex wrappers. + +2013-04-02: wsfulton + [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. + +2013-03-30: wsfulton + [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, + on exit of the Ruby interpreter. More frequently observed in ruby-1.9. + +2013-03-29: wsfulton + [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would + sometimes seg fault or not work. + +2013-03-25: wsfulton + [Python] Fix some undefined behaviour deleting slices in the STL containers. + +2013-03-19: wsfulton + [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are + the same except being in different namespaces when the %nspace feature is not being used. + +2013-02-19: kwwette + Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef + a(7).q(volatile).double myarray // typedef volatile double[7] myarray; + the type + q(const).myarray // const myarray + becomes + a(7).q(const volatile).double // const volatile double[7] + Previously, SwigType_typedef_resolve() produces the type + q(const).a(7).q(volatile).double // non-sensical type + which would never match %typemap declarations, whose types were parsed correctly. + Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour. + +2013-02-18: wsfulton + Deprecate typedef names used as constructor and destructor names in %extend. The real + class/struct name should be used. + + typedef struct tagEStruct { + int ivar; + } EStruct; + + %extend tagEStruct { + EStruct() // illegal name, should be tagEStruct() + { + EStruct *s = new EStruct(); + s->ivar = ivar0; + return s; + } + ~EStruct() // illegal name, should be ~tagEStruct() + { + delete $self; + } + } + + For now these trigger a warning: + + extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in + %extend is deprecated, the constructor name should be 'tagEStruct'. + extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in + %extend is deprecated, the destructor name should be 'tagEStruct'. + + These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored + them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been + restored for now, but is officially deprecated. This does not apply to anonymously defined typedef + classes/structs such as: + + typedef struct {...} X; + +2013-02-17: kwwette + When generating functions provided by %extend, use "(void)" for no-argument functions + instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". + +2013-02-17: kwwette + [Octave] Minor fix to autodoc generation: get the right type for functions returning structs. + +2013-02-15: wsfulton + Deprecate typedef names used in %extend that are not the real class/struct name. For example: + + typedef struct StructBName { + int myint; + } StructB; + + %extend StructB { + void method() {} + } + + will now trigger a warning: + + swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName + should be used instead of the typedef name StructB. + + This is only partially working anyway (the %extend only worked if placed after the class + definition). + +2013-02-09: wsfulton + [CFFI] Apply patch #22 - Fix missing package before &body + +2013-01-29: wsfulton + [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. + +2013-01-28: wsfulton + [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. + +2013-01-28: wsfulton + [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. + +2013-01-18: Brant Kyser + [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. + This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class + into a package and the nspace feature is used to place all exposed types into a package. + +2013-01-15: wsfulton + Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces. + +2013-01-15: wsfulton + [C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name + matches. For example: + %typemap(cstype) bool MVar::mvar "MyBool" + struct MVar { + bool mvar; + }; + +2013-01-11: Brant Kyser + [Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on + classes with the same name in two different namespaces. + +2013-01-11: Vladimir Kalinin + [C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes. + +2013-01-08: olly + [PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7). + +2013-01-07: olly + Fix bashism in configure, introduced in 2.0.9. + +2013-01-06: wsfulton + Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors + in templates, such as: + Warning 521: Illegal destructor name B< A >::~B(). Ignored. + +2013-01-05: wsfulton + [Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as + classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro. + +2013-01-04: wsfulton + [Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction + with directors. + +2013-01-03: wsfulton + [Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when + multilevel namespaces are used. + Version 2.0.9 (16 December 2012) ================================ @@ -2928,8 +3303,8 @@ Version 1.3.36 (24 June 2008) Makefile target being generated when generating makefiles with the -M family of options. For example: - $ swig -java -MM -MT overiddenname -c++ example.i - overiddenname: \ + $ swig -java -MM -MT overriddenname -c++ example.i + overriddenname: \ example.i \ example.h diff --git a/CHANGES.current b/CHANGES.current index ad2f1e764..edd39af31 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,52 +2,13 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.10 (in progress) +Version 3.0.0 (in progress) ============================ -2013-01-18: Brant Kyser - [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. - This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class - into a package and the nspace feature is used to place all exposed types into a package. +2013-10-04: wsfulton + Fix %naturalvar not having any affect on templated classes instantiated with an + enum as the template parameter type. Problem reported by Vadim Zeitlin. -2013-01-15: wsfulton - Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces. - -2013-01-15: wsfulton - [C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name - matches. For example: - %typemap(cstype) bool MVar::mvar "MyBool" - struct MVar { - bool mvar; - }; - -2013-01-11: Brant Kyser - [Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on - classes with the same name in two different namespaces. - -2013-01-11: Vladimir Kalinin - [C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes. - -2013-01-08: olly - [PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7). - -2013-01-07: olly - Fix bashism in configure, introduced in 2.0.9. - -2013-01-06: wsfulton - Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors - in templates, such as: - Warning 521: Illegal destructor name B< A >::~B(). Ignored. - -2013-01-05: wsfulton - [Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as - classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro. - -2013-01-04: wsfulton - [Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction - with directors. - -2013-01-03: wsfulton - [Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when - multilevel namespaces are used. +2013-09-20: wsfulton + [Java] Fix a memory leak for the java char **STRING_ARRAY typemaps. diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index 283ff7e2c..12b915ee2 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -1613,7 +1613,7 @@ opoverload>

Variable length argument lists are not supported, by default. If such a function is encountered, a warning will generated to - stderr. Varargs are supported via the SWIG %vararg + stderr. Varargs are supported via the SWIG %varargs directive. This directive allows you to specify a (finite) argument list which will be inserted into the wrapper in place of the variable length argument indicator. As an example, @@ -1624,7 +1624,7 @@ opoverload>

See the following section on Variable Length arguments - provides examples on how %vararg can be used, along + provides examples on how %varargs can be used, along with other ways such functions can be wrapped.

diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 42e135140..77280c8bc 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -16,13 +16,23 @@ @@ -803,8 +813,9 @@

-Since the SWIG_exception() function is defined at the C-level -it can be used elsewhere in SWIG. This includes typemaps and helper -functions. +The SWIG_exception() function can also be used in typemaps.

11.2 Object ownership and %newobject

diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 059388717..5ea4e51f4 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3101,7 +3101,7 @@ As you can see, most usages are direct.
-
configure.in +
configure.ac
This file is processed by

@@ -3551,7 +3551,7 @@ details being outlined earlier on. a runtime test, see for example Examples/python/class.

  • - Modify configure.in, Makefile.in and Examples/Makefile.in to run + Modify configure.ac, Makefile.in and Examples/Makefile.in to run these examples. Please make sure that if the new language is not installed properly on a box, make -k check should still work by skipping the tests and examples for the new language module. diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 6f1300492..17e3a3fab 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -12,8 +12,9 @@
      +
    • Supported Guile Versions
    • Meaning of "Module" -
    • Using the SCM or GH Guile API +
    • Old GH Guile API
    • Linkage
      • Simple Linkage @@ -26,8 +27,7 @@
      • Typemaps
      • Representation of pointers as smobs
      • Exception Handling @@ -47,7 +47,21 @@

        This section details guile-specific support in SWIG. -

        23.1 Meaning of "Module"

        +

        23.1 Supported Guile Versions

        + + +

        +SWIG works with Guile versions 1.8.x and 2.0.x. Support for version +1.6.x has been dropped. The last version of SWIG that still works with +Guile version 1.6.x is SWIG 2.0.9. + +

        +Note that starting with guile 2.0, the guile sources can be compiled for +improved performance. This is currently not tested with swig +so your mileage may vary. To be safe set environment variable +GUILE_AUTO_COMPILE to 0 when using swig generated guile code. + +

        23.2 Meaning of "Module"

        @@ -55,55 +69,18 @@ There are three different concepts of "module" involved, defined separately for SWIG, Guile, and Libtool. To avoid horrible confusion, we explicitly prefix the context, e.g., "guile-module". -

        23.2 Using the SCM or GH Guile API

        +

        23.3 Old GH Guile API

        -

        The guile module can currently export wrapper files that use the guile GH interface or the -SCM interface. This is controlled by an argument passed to swig. The "-gh" argument causes swig -to output GH code, and the "-scm" argument causes swig to output SCM code. Right now the "-scm" argument -is the default. The "-scm" wrapper generation assumes a guile version >= 1.6 and has several advantages over -the "-gh" wrapper generation including garbage collection and GOOPS support. -The "-gh" wrapper generation can be used for older versions of guile. -The guile GH wrapper code generation is depreciated and the -SCM interface is the default. The SCM and GH interface differ greatly in how they store -pointers and have completely different run-time code. See below for more info. - -

        The GH interface to guile is deprecated. Read more about why in the +

        Guile 1.8 and older could be interfaced using two different api's, the SCM +or the GH API. The GH interface to guile is deprecated. Read more about why in the Guile manual. -The idea of the GH interface was to provide a high level API that other languages and projects -could adopt. This was a good idea, but didn't pan out well for general development. But for the -specific, minimal uses that the SWIG typemaps put the GH interface to use is ideal for -using a high level API. So even though the GH interface is depreciated, SWIG will continue to use -the GH interface and provide mappings from the GH interface to whatever API we need. -We can maintain this mapping where guile failed because SWIG uses a small subset of all the GH functions -which map easily. All the guile typemaps like typemaps.i and std_vector.i -will continue to use the GH functions to do things like create lists of values, convert strings to -integers, etc. Then every language module will define a mapping between the GH interface and -whatever custom API the language uses. This is currently implemented by the guile module to use -the SCM guile API rather than the GH guile API. -For example, here are some of the current mapping file for the SCM API

        -
        +

        Support for the guile GH wrapper code generation has been dropped from SWIG. The last +version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please +use that version if you really need the GH wrapper code. -#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) -#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) -#define gh_bool2scm SCM_BOOL -#define gh_boolean_p SCM_BOOLP -#define gh_car SCM_CAR -#define gh_cdr SCM_CDR -#define gh_cons scm_cons -#define gh_double2scm scm_make_real -... -

        - -

        This file is parsed by SWIG at wrapper generation time, so every reference to a gh_ function is replaced -by a scm_ function in the wrapper file. Thus the gh_ function calls will never be seen in the wrapper; -the wrapper will look exactly like it was generated -for the specific API. Currently only the guile language module has created a mapping policy from gh_ to scm_, -but there is no reason other languages (like mzscheme or chicken) couldn't also use this. -If that happens, there is A LOT less code duplication in the standard typemaps.

        - -

        23.3 Linkage

        +

        23.4 Linkage

        @@ -111,7 +88,7 @@ Guile support is complicated by a lack of user community cohesiveness, which manifests in multiple shared-library usage conventions. A set of policies implementing a usage convention is called a linkage. -

        23.3.1 Simple Linkage

        +

        23.4.1 Simple Linkage

        @@ -134,7 +111,7 @@ libraries into Guile.

         (define-module (my module))
        -(define my-so (dynamic-link "./example.so"))
        +(define my-so (dynamic-link "./libexample.so"))
         (dynamic-call "SWIG_init" my-so) ; make SWIG bindings
         ;; Scheme definitions can go here
         
        @@ -147,7 +124,17 @@ and dynamic-call:
        -(load-extension "./example.so" "SWIG_init")
        +(load-extension "./libexample.so" "SWIG_init")
        +
        +
        + +

        +A more portable approach would be to drop the shared library extension: +

        + +
        +
        +(load-extension "./libexample" "SWIG_init")
         
        @@ -190,7 +177,7 @@ information by including a directive like this in the interface file:
        -%scheme %{ (load-extension "./example.so" "SWIG_init") %}
        +%scheme %{ (load-extension "./libexample.so" "SWIG_init") %}
         
        @@ -206,7 +193,7 @@ placed between the define-module form and the SWIG_init via a preprocessor define to avoid symbol clashes. For this case, however, passive linkage is available. -

        23.3.2 Passive Linkage

        +

        23.4.2 Passive Linkage

        Passive linkage is just like simple linkage, but it generates an @@ -216,12 +203,12 @@ package name (see below).

        You should use passive linkage rather than simple linkage when you are using multiple modules. -

        23.3.3 Native Guile Module Linkage

        +

        23.4.3 Native Guile Module Linkage

        SWIG can also generate wrapper code that does all the Guile module declarations on its own if you pass it the -Linkage -module command-line option. This requires Guile 1.5.0 or later. +module command-line option.

        The module name is set with the -package and -module command-line options. Suppose you want to define @@ -244,7 +231,7 @@ shared libraries into Guile; all bindings are automatically put in newly created Guile modules.

        -(define my-so (dynamic-link "./foo.so"))
        +(define my-so (dynamic-link "./libfoo"))
         ;; create new module and put bindings there:
         (dynamic-call "scm_init_my_modules_foo_module" my-so) 
         
        @@ -252,12 +239,12 @@ newly created Guile modules. Newer Guile versions have a shorthand procedure for this:
        -(load-extension "./foo.so" "scm_init_my_modules_foo_module")
        +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module")
         
      -

      23.3.4 Old Auto-Loading Guile Module Linkage

      +

      23.4.4 Old Auto-Loading Guile Module Linkage

      Guile used to support an autoloading facility for object-code @@ -283,7 +270,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

      23.3.5 Hobbit4D Linkage

      +

      23.4.5 Hobbit4D Linkage

      @@ -308,7 +295,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

      -

      23.4 Underscore Folding

      +

      23.5 Underscore Folding

      @@ -320,7 +307,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

      23.5 Typemaps

      +

      23.6 Typemaps

      @@ -412,7 +399,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

      -

      23.6 Representation of pointers as smobs

      +

      23.7 Representation of pointers as smobs

      @@ -433,7 +420,7 @@ representing the expected pointer type. See also If the Scheme object passed was not a SWIG smob representing a compatible pointer, a wrong-type-arg exception is raised. -

      23.6.1 GH Smobs

      +

      23.7.1 Smobs

      @@ -444,44 +431,19 @@ mangled type name. As Guile allows registering user types, so-called implemented now. The details will be discussed in the following.

      -

      A smob is a cons cell where the lower half of the CAR contains the smob type -tag, while the upper half of the CAR and the whole CDR are available. Every -module creates its own smob type in the clientdata field of the module. So the -lower 16 bits of the car of the smob store the tag and the upper 16 bits store -the index this type is in the array. We can then, given a smob, find its -swig_type_info struct by using the tag (lower 16 bits of car) to find which -module this type is in (since each tag is unique for the module). Then we use -the upper 16 bits to index into the array of types attached to this module. -Looking up the module from the tag is worst case O(# of modules) but average -case O(1). This is because the modules are stored in a circularly linked list, -and when we start searching the modules for the tag, we start looking with the -module that the function doing the lookup is in. SWIG_Guile_ConvertPtr() takes -as its first argument the swig_module_info * of the calling function, which is -where we start comparing tags. Most types will be looked up in the same module -that created them, so the first module we check will most likely be correct. -Once we have a swig_type_info structure, we loop through the linked list of -casts, using pointer comparisons.

      - -

      23.6.2 SCM Smobs

      - - -

      The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. -The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig". +

      The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig". The swig smob is used for non-garbage collected smobs, while the collected_swig smob is used as described below. Each smob has the same format, which is a double cell created by SCM_NEWSMOB2() The first word of data is the pointer to the object and the second word of data is the swig_type_info * -structure describing this type. This is a lot easier than the GH interface above because we can store -a pointer to the type info structure right in the type. With the GH interface, there was not enough -room in the smob to store two whole words of data so we needed to store part of the "swig_type_info address" -in the smob tag. If a generated GOOPS module has been loaded, smobs will be wrapped by the corresponding -GOOPS class.

      +structure describing this type. If a generated GOOPS module has been loaded, smobs will be wrapped by +the corresponding GOOPS class.

      -

      23.6.3 Garbage Collection

      +

      23.7.2 Garbage Collection

      -

      Garbage collection is a feature of the new SCM interface, and it is automatically included -if you pass the "-scm" flag to swig. Thus the swig garbage collection support requires guile >1.6. +

      Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, +it is automatically included. Garbage collection works like this. Every swig_type_info structure stores in its clientdata field a pointer to the destructor for this type. The destructor is the generated wrapper around the delete function. So swig still exports a wrapper for the destructor, it just does not call scm_c_define_gsubr() for @@ -491,7 +453,7 @@ is exactly like described in 23.7 Exception Handling +

      23.8 Exception Handling

      @@ -517,14 +479,13 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

      23.8 Procedure documentation

      +

      23.9 Procedure documentation

      If invoked with the command-line option -procdoc file, SWIG creates documentation strings for the generated wrapper functions, describing the procedure signature and -return value, and writes them to file. You need Guile 1.4 -or later to make use of the documentation files. +return value, and writes them to file.

      SWIG can generate documentation strings in three formats, which are selected via the command-line option -procdocformat @@ -553,7 +514,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

      23.9 Procedures with setters

      +

      23.10 Procedures with setters

      For global variables, SWIG creates a single wrapper procedure @@ -581,7 +542,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

      23.10 GOOPS Proxy Classes

      +

      23.11 GOOPS Proxy Classes

      SWIG can also generate classes and generic functions for use with @@ -589,10 +550,7 @@ Guile's Object-Oriented Programming System (GOOPS). GOOPS is a sophisticated object system in the spirit of the Common Lisp Object System (CLOS). -

      GOOPS support is -only available with the new SCM interface (enabled with the --scm command-line option of SWIG). To enable GOOPS -support, pass the -proxy argument to +

      To enable GOOPS support, pass the -proxy argument to swig. This will export the GOOPS wrapper definitions into the module.scm file in the directory specified by -outdir or the current directory. GOOPS support requires either passive or module linkage.

      @@ -730,7 +688,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

      -

      23.10.1 Naming Issues

      +

      23.11.1 Naming Issues

      As you can see in the example above, there are potential naming conflicts. The default exported @@ -767,7 +725,7 @@ guile-modules. For example,

      (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
    -

    23.10.2 Linking

    +

    23.11.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires @@ -787,10 +745,10 @@ and might conflict with names from the GOOPS guile-module (see above). Pass the argument to solve this problem. If the -exportprimitive option is passed to SWIG the (export ...) code that would be exported into the scmstub file is exported at the bottom of the generated GOOPS guile-module. -The %goops directive should contain code to load the .so library. +The %goops directive should contain code to load the shared library.

    -%goops %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     

    @@ -802,7 +760,7 @@ Produces the following code at the top of the generated GOOPS guile-module (define-module (my modules foo)) ;; %goops directive goes here -(load-extension "./foo.so" "scm_init_my_modules_foo_module") +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module") (use-modules (oop goops) (Swig common)) @@ -810,7 +768,7 @@ Produces the following code at the top of the generated GOOPS guile-module

  • Passive Linkage with -scmstub: Here, the name of the scmstub file should be Module-primitive.scm (with primitive replaced with whatever is given with the -primsuffix -argument. The code to load the .so library should be located in the %scheme directive, +argument. The code to load the shared library should be located in the %scheme directive, which will then be added to the scmstub file. SWIG will automatically generate the line (use-modules (Package Module-primitive)) into the GOOPS guile-module. So if Module-primitive.scm is on the autoload path for guile, the @@ -818,7 +776,7 @@ into the GOOPS guile-module. So if Module-primitive.scm is on the autolo whatever code is needed to load the Module-primitive.scm file into guile.

    -%scheme %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%scheme %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     // only include the following definition if (my modules foo) cannot
     // be loaded automatically
     %goops %{ 
    @@ -851,7 +809,7 @@ SWIG will also automatically generate the line (use-modules
     directive should contain whatever code is needed to get that module loaded into guile.

    -%goops %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     

    @@ -862,7 +820,7 @@ Produces the following code at the top of the generated GOOPS guile-module (define-module (my modules foo)) ;; %goops directive goes here (if any) -(load-extension "./foo.so" "scm_init_my_modules_foo_module") +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module") (use-modules (oop goops) (Swig common)) (use-modules ((my modules foo-primitive) :renamer (symbol-prefix-proc diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 8245d46eb..f3d8a1684 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5662,7 +5662,7 @@ to make the method and constructor public:

    The Java directors feature requires the "javadirectorin", "javadirectorout", "directorin" and the "directorout" typemaps in order to work properly. -The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes. +The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes used in director methods.

    %typemap(directorin)

    @@ -5803,6 +5803,7 @@ The target method is the method in the Java proxy class which overrides the virt

    The "javapackage" typemap is optional; it serves to identify a class's Java package. This typemap should be used in conjunction with classes that are defined outside of the current SWIG interface file. +The typemap is only used if the type is used in a director method, that is, in a virtual method in a director class. For example:

    @@ -5819,7 +5820,7 @@ For example: class Example { public: virtual ~Example(); - void ping(Foo *arg1, Bar *arg2); + virtual void ping(Foo *arg1, Bar *arg2); }; }
    @@ -5844,7 +5845,7 @@ The corrected interface file looks like: class Example { public: virtual ~Example(); - void ping(Foo *arg1, Bar *arg2); + virtual void ping(Foo *arg1, Bar *arg2); }; } @@ -7885,7 +7886,7 @@ where it is possible to step from Java code into a JNI method within one environ

    Alternatively, debugging can involve placing debug printout statements in the JNI layer using the %exception directive. See the special variables for %exception section. -Many of the default typemaps can also be overidden and modified for adding in extra logging/debug display information. +Many of the default typemaps can also be overridden and modified for adding in extra logging/debug display information.

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 1fd41f907..88d26f385 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1359,7 +1359,7 @@ extern void sort_double(double* arr, int len); to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but it's a bit tedious. More details can be found in the carrays.i documentation.

    -

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

    +

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %apply in the correct manner.

    The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays.

    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 0340c2fd5..84c0a0f46 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -74,7 +74,7 @@ Let's start with a very simple SWIG interface file, example.i:

    -%module example
    +%module swigexample
     %{
     #include "example.h"
     %}
    @@ -143,10 +143,10 @@ $ mkoctfile example_wrap.cpp example.c
     

    - mkoctfile will produce "example.oct", which contains the compiled extension module. Loading it into Octave is then a matter of invoking + mkoctfile will produce "swigexample.oct", which contains the compiled extension module. Loading it into Octave is then a matter of invoking

    -
    octave:1> example
    +
    octave:1> swigexample

    30.2.3 Using your module

    @@ -157,13 +157,13 @@ Assuming all goes well, you will be able to do this:

    $ octave -q
    -octave:1> example
    -octave:2> example.gcd(4,6)
    +octave:1> swigexample
    +octave:2> swigexample.gcd(4,6)
     ans =  2
    -octave:3> example.cvar.Foo
    +octave:3> swigexample.cvar.Foo
     ans =  3
    -octave:4> example.cvar.Foo=4;
    -octave:5> example.cvar.Foo
    +octave:4> swigexample.cvar.Foo=4;
    +octave:5> swigexample.cvar.Foo
     ans =  4 

    30.3 A tour of basic C/C++ wrapping

    @@ -173,11 +173,11 @@ ans = 4

    -The SWIG module directive specifies the name of the Octave module. If you specify "module example", then in Octave everything in the module will be accessible under "example", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name. +The SWIG module directive specifies the name of the Octave module. If you specify "module swigexample", then in Octave everything in the module will be accessible under "swigexample", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name.

    -When Octave is asked to invoke example, it will try to find the ".m" or ".oct" file that defines the function "example". You therefore need to make sure that "example.oct" is in Octave's search path, which can be specified with the environment variable "OCTAVE_PATH". +When Octave is asked to invoke swigexample, it will try to find the ".m" or ".oct" file that defines the function "swigexample". You therefore need to make sure that "swigexample.oct" is in Octave's search path, which can be specified with the environment variable "OCTAVE_PATH".

    @@ -185,7 +185,7 @@ To load an Octave module, simply type its name:

    -octave:1> example;
    +octave:1> swigexample;
     octave:2> gcd(4,6)
     ans =  2
     octave:3> cvar.Foo
    @@ -202,15 +202,15 @@ If the module is also used in the base context, however, it must first be loaded
     
     
     octave:1> function l = my_lcm(a,b)
    -> example
    -> l = abs(a*b)/example.gcd(a,b);
    +> swigexample
    +> l = abs(a*b)/swigexample.gcd(a,b);
     > endfunction
     octave:2> my_lcm(4,6)
     ans =  12
    -octave:3> example.gcd(4,6)
    +octave:3> swigexample.gcd(4,6)
     error: can't perform indexing operations for <unknown type> type
    -octave:3> example;
    -octave:4> example.gcd(4,6)
    +octave:3> swigexample;
    +octave:4> swigexample.gcd(4,6)
     ans =  2
     
    @@ -221,14 +221,14 @@ ans = 2 Global functions are wrapped as new Octave built-in functions. For example,

    -
    %module example
    +      
    %module swigexample
     int fact(int n); 

    - creates a built-in function example.fact(n) that works exactly like you think it does: + creates a built-in function swigexample.fact(n) that works exactly like you think it does:

    -
    octave:1> example.fact(4)
    +    
    octave:1> swigexample.fact(4)
     24 

    30.3.3 Global variables

    @@ -238,7 +238,7 @@ int fact(int n);
    Global variables are a little special in Octave. Given a global variable:

    -
    %module example
    +
    %module swigexample
     extern double Foo;
     
    @@ -246,20 +246,20 @@ extern double Foo; To expose variables, SWIG actually generates two functions, to get and set the value. In this case, Foo_set and Foo_set would be generated. SWIG then automatically calls these functions when you get and set the variable-- in the former case creating a local copy in the interpreter of the C variables, and in the latter case copying an interpreter variables onto the C variable.

    -
    octave:1> example;
    -octave:2> c=example.cvar.Foo
    +    
    octave:1> swigexample;
    +octave:2> c=swigexample.cvar.Foo
     c =  3
    -octave:3> example.cvar.Foo=4;
    +octave:3> swigexample.cvar.Foo=4;
     octave:4> c
     c =  3
    -octave:5> example.cvar.Foo
    +octave:5> swigexample.cvar.Foo
     ans =  4

    If a variable is marked with the %immutable directive then any attempts to set this variable will cause an Octave error. Given a global variable:

    -
    %module example
    +    
    %module swigexample
     %immutable;
     extern double Foo;
     %mutable;
    @@ -269,8 +269,8 @@ extern double Foo;
          SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called. 
     

    -
    octave:1> example
    -octave:2> example.Foo=4
    +    
    octave:1> swigexample
    +octave:2> swigexample.Foo=4
     error: attempt to set immutable member variable
     error: assignment failed, or no method for `swig_type = scalar'
     error: evaluating assignment expression near line 2, column 12 
    @@ -279,9 +279,9 @@ error: evaluating assignment expression near line 2, column 12
    It is possible to add new functions or variables to the module. This also allows the user to rename/remove existing functions and constants (but not linked variables, mutable or immutable). Therefore users are recommended to be careful when doing so.

    -
    octave:1> example;
    -octave:2> example.PI=3.142;
    -octave:3> example.PI
    +    
    octave:1> swigexample;
    +octave:2> swigexample.PI=3.142;
    +octave:3> swigexample.PI
     ans =  3.1420 

    30.3.4 Constants and enums

    @@ -291,7 +291,7 @@ ans = 3.1420
    Because Octave doesn't really have the concept of constants, C/C++ constants are not really constant in Octave. They are actually just a copy of the value into the Octave interpreter. Therefore they can be changed just as any other value. For example given some constants:

    -
    %module example
    +    
    %module swigexample
     %constant int ICONST=42;
     #define    SCONST      "Hello World"
     enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};
    @@ -301,9 +301,9 @@ enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};
         This is 'effectively' converted into the following Octave code: 
     

    -
    example.ICONST=42
    -example.SCONST="Hello World"
    -example.SUNDAY=0
    +    
    swigexample.ICONST=42
    +swigexample.SCONST="Hello World"
    +swigexample.SUNDAY=0
     .... 

    30.3.5 Pointers

    @@ -314,7 +314,7 @@ example.SUNDAY=0 C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface:

    -
    %module example
    +
    %module swigexample
     FILE *fopen(const char *filename, const char *mode);
     int fputs(const char *, FILE *);
     int fclose(FILE *);
    @@ -325,18 +325,18 @@ When wrapped, you will be able to use the functions in a natural way from Octave
     

    -octave:1> example;
    -octave:2> f=example.fopen("w","junk");
    -octave:3> example.fputs("Hello world",f);
    -octave:4> example.fclose(f);
    +octave:1> swigexample;
    +octave:2> f=swigexample.fopen("w","junk");
    +octave:3> swigexample.fputs("Hello world",f);
    +octave:4> swigexample.fclose(f);
     

    Simply printing the value of a wrapped C++ type will print it's typename. E.g.,

    -
    octave:1> example;
    -octave:2> f=example.fopen("junk","w");
    +    
    octave:1> swigexample;
    +octave:2> f=swigexample.fopen("junk","w");
     octave:3> f
     f =
     
    @@ -348,8 +348,8 @@ f =
         As the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes and structs (see below).
     

    -
    octave:1> example;
    -octave:2> f=example.fopen("not there","r");
    +    
    octave:1> swigexample;
    +octave:2> f=swigexample.fopen("not there","r");
     error: value on right hand side of assignment is undefined
     error: evaluating assignment expression near line 2, column 2 
    @@ -371,8 +371,8 @@ For each wrapped structure and class, a swig_ref will be exposed that h

    -
    octave:1> example;
    -octave:2> p=example.Point();
    +      
    octave:1> swigexample;
    +octave:2> p=swigexample.Point();
     octave:3> p.x=3;
     octave:4> p.y=5;
     octave:5> p.x, p.y
    @@ -406,9 +406,9 @@ public:
     can be used from Octave like this
     

    -
    octave:1> example;
    -octave:2> p1=example.Point(3,5);
    -octave:3> p2=example.Point(1,2);
    +      
    octave:1> swigexample;
    +octave:2> p1=swigexample.Point(3,5);
    +octave:3> p2=swigexample.Point(1,2);
     octave:4> p1.distance(p2)
     ans =  3.6056
     
    @@ -649,7 +649,7 @@ C++ class and function templates are fully supported as in other modules, in tha For example, function templates can be instantiated as follows:

    -
    %module example
    +
    %module swigexample
     %inline {
      template<class __scalar>
        __scalar mul(__scalar a,__scalar b) {
    @@ -677,7 +677,7 @@ ans =  22 + 46i
     Similarly, class templates can be instantiated as in the following example,
     

    -
    %module example
    +
    %module swigexample
     %include <std_complex.i>
     %include <std_string.i>
     %inline {
    diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html
    index e1fcfbbd8..d17dc229c 100644
    --- a/Doc/Manual/Preface.html
    +++ b/Doc/Manual/Preface.html
    @@ -12,13 +12,23 @@
     
     
    @@ -57,13 +67,26 @@ In the late 1990's, the most stable version of SWIG was release over a period of 10 years starting from the year 2000. The final version in the 1.3.x series was 1.3.40, but in truth the 1.3.x series had been stable for many years. An official stable version was released along with the decision to make SWIG -license changes and this gave rise to version 2.0.0 in 2010. The license was clarified +license changes and this gave rise to version 2.0.0 in 2010. +

    + +

    1.3 SWIG License

    + + +

    +The LICENSE file shipped with SWIG in the top level directory contains the SWIG license. +For further insight into the license including the license of SWIG's output code, please visit +the SWIG legal page - http://www.swig.org/legal.html. +

    + +

    +The license was clarified in version 2.0.0 so that the code that SWIG generated could be distributed under license terms of the user's choice/requirements and at the same time the SWIG source was placed under the GNU General Public License version 3.

    -

    1.3 SWIG resources

    +

    1.4 SWIG resources

    @@ -102,7 +125,8 @@ about this can be obtained at:

    -

    1.4 Prerequisites

    + +

    1.5 Prerequisites

    @@ -127,7 +151,7 @@ However, this isn't meant to be a tutorial on C++ programming. For many of the gory details, you will almost certainly want to consult a good C++ reference. If you don't program in C++, you may just want to skip those parts of the manual. -

    1.5 Organization of this manual

    +

    1.6 Organization of this manual

    @@ -139,7 +163,7 @@ can probably skip to that chapter and find almost everything you need to know.

    -

    1.6 How to avoid reading the manual

    +

    1.7 How to avoid reading the manual

    @@ -151,7 +175,7 @@ The SWIG distribution also comes with a large directory of examples that illustrate different topics.

    -

    1.7 Backwards compatibility

    +

    1.8 Backwards compatibility

    @@ -162,8 +186,8 @@ this isn't always possible as the primary goal over time is to make SWIG better---a process that would simply be impossible if the developers are constantly bogged down with backwards compatibility issues. -Potential incompatibilities are clearly marked in the detailed release notes -(CHANGES files). +Potential incompatibilities are clearly marked in the detailed +release notes.

    @@ -187,7 +211,16 @@ Note: The version symbol is not defined in the generated SWIG wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.

    -

    1.8 Credits

    +

    1.9 Release notes

    + + +

    +The CHANGES.current, CHANGES and RELEASENOTES files shipped with SWIG in the top level directory +contain, respectively, detailed release notes for the current version, +detailed release notes for previous releases and summary release notes from SWIG-1.3.22 onwards. +

    + +

    1.10 Credits

    @@ -200,7 +233,7 @@ who have made contributions at all levels over time. Contributors are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.

    -

    1.9 Bug reports

    +

    1.11 Bug reports

    @@ -215,5 +248,204 @@ used, and any important pieces of the SWIG generated wrapper code. We can only fix bugs if we know about them.

    +

    1.12 Installation

    + + +

    1.12.1 Windows installation

    + + +

    +Please see the dedicated Windows chapter for instructions on installing +SWIG on Windows and running the examples. The Windows distribution is +called swigwin and includes a prebuilt SWIG executable, swig.exe, included in +the top level directory. Otherwise it is exactly the same as +the main SWIG distribution. There is no need to download anything else. +

    + +

    1.12.2 Unix installation

    + + +

    +You must use GNU make to build and install SWIG. +

    + +

    +PCRE +needs to be installed on your system to build SWIG, in particular +pcre-config must be available. If you have PCRE headers and libraries but not +pcre-config itself or, alternatively, wish to override the compiler or linker +flags returned by pcre-config, you may set PCRE_LIBS and PCRE_CFLAGS variables +to be used instead. And if you don't have PCRE at all, the configure script +will provide instructions for obtaining it. +

    + +

    +To build and install SWIG, simply type the following: +

    + +
    +$ ./configure
    +$ make
    +$ make install
    +
    + +

    +By default SWIG installs itself in /usr/local. If you need to install SWIG in +a different location or in your home directory, use the --prefix option +to ./configure. For example: +

    + +
    +$ ./configure --prefix=/home/yourname/projects
    +$ make
    +$ make install
    +
    + +

    +Note: the directory given to --prefix must be an absolute pathname. Do not use +the ~ shell-escape to refer to your home directory. SWIG won't work properly +if you do this. +

    + +

    +The INSTALL file shipped in the top level directory details more about using configure. Also try +

    + +
    +$ ./configure --help.
    +
    + +

    +The configure script will attempt to locate various packages on your machine +including Tcl, Perl5, Python and all the other target languages that SWIG +supports. Don't panic if you get 'not found' messages -- SWIG does not need these +packages to compile or run. The configure script is actually looking for +these packages so that you can try out the SWIG examples contained +in the 'Examples' directory without having to hack Makefiles. +Note that the --without-xxx options, where xxx is a target language, have +minimal effect. All they do is reduce the amount of testing done with +'make check'. The SWIG executable and library files installed cannot currently +be configured with a subset of target languages. +

    + +

    +SWIG used to include a set of runtime libraries for some languages for working +with multiple modules. These are no longer built during the installation stage. +However, users can build them just like any wrapper module as described in +the Modules chapter. +The CHANGES file shipped with SWIG in the top level directory +also lists some examples which build the runtime library. +

    + +

    +Note: +

    + +
      +
    • +If you checked the code out via Git, you will have to run ./autogen.sh +before ./configure. In addition, a full build of SWIG requires +a number of packages to be installed. Full instructions at +SWIG bleeding edge. +
    • +
    + +

    1.12.3 Macintosh OS X installation

    + + +

    +SWIG is known to work on various flavors of OS X. Follow the Unix installation +instructions above. However, as of this writing, there is still great deal of +inconsistency with how shared libaries are handled by various scripting languages +on OS X. +

    + +

    +Users of OS X should be aware that Darwin handles shared libraries and linking in +a radically different way than most Unix systems. In order to test SWIG and run +the examples, SWIG configures itself to use flat namespaces and to allow undefined +symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix +model and makes it more likely that the SWIG examples will work with whatever +installation of software you might have. However, this is generally not the recommended +technique for building larger extension modules. Instead, you should utilize +Darwin's two-level namespaces. Some details about this can be found here + +http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html. + +

    + +

    +Needless to say, you might have to experiment a bit to get things working at first. +

    + +

    1.12.4 Testing

    + + +

    +If you want to test SWIG after building it, a check can be performed on Unix operating systems. +Type the following: +

    + +
    +    $ make -k check
    +
    + +

    +This step can be performed either before or after installation. +The check requires at least one of the target languages to be +installed. If it fails, it may mean that you have an uninstalled +language module or that the file 'Examples/Makefile' has been +incorrectly configured. It may also fail due to compiler issues such +as a broken C++ compiler. Even if the check fails, there is a +pretty good chance SWIG still works correctly --- you will just have to +mess around with one of the examples and some makefiles to get it to work. +Some tests may also fail due to missing dependency packages, eg PCRE +or Boost, but this will require careful analysis of the configure output +done during configuration. +

    + +

    +The test suite executed by the check is designed to stress-test +many parts of the implementation including obscure corner cases. If some +of these tests fail or generate warning messages, there is no reason for +alarm --- the test may be related to some new SWIG feature or a difficult bug +that we're trying to resolve. Chances are that SWIG will work just fine +for you. Note that if you have more than one CPU/core, then you can use +parallel make to speed up the check as it does take quite some time to run, +for example: +

    + +
    +    $ make -j2 -k check
    +
    + +

    +Also, SWIG's support for C++ is sufficiently advanced that certain +tests may fail on older C++ compilers (for instance if your compiler +does not support member templates). These errors are harmless if you +don't intend to use these features in your own programs. +

    + +

    +Note: The test-suite currently contains over 500 tests. If you +have many different target languages installed and a slow machine, it +might take more than an hour to run the test-suite. +

    + +

    1.12.5 Examples

    + + +

    +The Examples directory contains a variety of examples of using SWIG +and it has some browsable documentation. Simply point your browser to +the file "Example/index.html". +

    + +

    +The Examples directory also includes Visual C++ project 6 (.dsp) files for +building some of the examples on Windows. Later versions of Visual Studio +will convert these old style project files into a current solution file. +

    + diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 762abebba..6a22738bc 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -795,7 +795,9 @@ If you need to build it on your own, the following notes are provided: You will need to create a DLL that can be loaded into the interpreter. This section briefly describes the use of SWIG with Microsoft Visual C++. As a starting point, many of SWIG's examples include project -files. You might want to take a quick look at these in addition to +files (.dsp files) for Visual C++ 6. These can be opened by more +recent versions of Visual Studio. +You might want to take a quick look at these examples in addition to reading this section.

    @@ -868,6 +870,24 @@ set of Win32 debug or thread libraries. You will have to fiddle around with the build options of project to try and track this down.

    +

    +A 'Debug' build of the wrappers requires a debug build of the Python interpreter. +This normally requires building the Python interpreter from source, which is not a +job for the feint-hearted. Alternatively you can use the 'Release' build of the +Python interpreter with a 'Debug' build of your wrappers by defining the SWIG_PYTHON_INTERPRETER_NO_DEBUG +symbol under the preprocessor options. Or you can ensure this macro is defined at the beginning +of the wrapper code using the following in your interface file, where _MSC_VER ensures it is +only used by the Visual Studio compiler: +

    + +
    +%begin %{
    +#ifdef _MSC_VER
    +#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
    +#endif
    +%}
    +
    +

    Some users have reported success in building extension modules using Cygwin and other compilers. However, the problem of building usable DLLs with these @@ -3294,6 +3314,53 @@ what can be done without having to rely on any of the more advanced customization features.

    +

    +There is also %pythonbegin which is another directive very similar to %pythoncode, +but generates the given Python code at the beginning of the .py file. +This directive works in the same way as %pythoncode, except the code is copied +just after the SWIG banner (comment) at the top of the file, before any real code. +This provides an opportunity to add your own description in a comment near the top of the file as well +as Python imports that have to appear at the top of the file, such as "from __future__ import" +statements. +

    + +

    +The following shows example usage for Python 2.6 to use print as it can in Python 3, that is, as a function instead of a statement: +

    + +
    +
    +%pythonbegin %{
    +# This module provides wrappers to the Whizz Bang library
    +%}
    +
    +%pythonbegin %{
    +from __future__ import print_function
    +print("Loading", "Whizz", "Bang", sep=' ... ')
    +%}
    +
    +
    + +

    +which can be seen when viewing the first few lines of the generated .py file: +

    + +
    +
    +# This file was automatically generated by SWIG (http://www.swig.org).
    +# Version 2.0.11
    +#
    +# Do not make changes to this file unless you know what you are doing--modify
    +# the SWIG interface file instead.
    +
    +# This module provides wrappers to the Whizz Bang library
    +
    +from __future__ import print_function
    +print("Loading", "Whizz", "Bang", sep=' ... ')
    +
    +
    +
    +

    Sometimes you may want to replace or modify the wrapper function that SWIG creates in the proxy .py file. The Python module in SWIG provides some features that enable you to do this. First, to diff --git a/Doc/Manual/README b/Doc/Manual/README index f01013d54..66daaec90 100644 --- a/Doc/Manual/README +++ b/Doc/Manual/README @@ -1,9 +1,9 @@ This directory contains the HTML for the SWIG users manual. All of this HTML is hand-written. However, section numbering, indices, -and the table of contents is generated automatically by the 'maketoc.py' +and the table of contents are generated automatically by the 'maketoc.py' script. The Makefile has further information on how the various alternative -forms of the documentation is generated from the hand-written HTML. +forms of the documentation are generated from the hand-written HTML. There are 4 types of boxes that code or whatever can be inside: -

    ...
    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 47cf4f303..301631a20 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -71,9 +71,9 @@
  • Placement of typemaps
  • Ruby typemaps
      -
    •  "in" typemap +
    • "in" typemap
    • "typecheck" typemap -
    •  "out" typemap +
    • "out" typemap
    • "arginit" typemap
    • "default" typemap
    • "check" typemap @@ -144,10 +144,6 @@

      This chapter describes SWIG's support of Ruby.

      - - - -

      36.1 Preliminaries

      @@ -157,123 +153,59 @@ should also determine if your system supports shared libraries and dynamic loading. SWIG will work with or without dynamic loading, but the compilation process will vary.

      - - - -

      This chapter covers most SWIG features, but in less depth than is found in earlier chapters. At the very least, make sure you also read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

      - - - -

      36.1.1 Running SWIG

      To build a Ruby module, run SWIG using the -ruby option:

      - - - -
      -
      $ swig -ruby example.i
      +
      $ swig -ruby example.i
       
      - - - - -
      - - - -

      If building a C++ extension, add the -c++ option:

      - - - -
      -
      $ swig -c++ -ruby example.i
      +
      $ swig -c++ -ruby example.i
       
      - - - - -
      - - - -

      This creates a file example_wrap.c (example_wrap.cxx if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

      - - - -

      36.1.2 Getting the right header files

      In order to compile the wrapper code, the compiler needs the ruby.h header file. This file is usually contained in a directory such as

      - - - -
      /usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
       /usr/local/lib/ruby/1.6/i686-linux/ruby.h
       
      - - - - -
      - - - -

      The exact location may vary on your machine, but the above location is typical. If you are not entirely sure where Ruby is installed, you can run Ruby to find out. For example:

      - - - -
      -
      $ ruby -e 'puts $:.join("\n")'
      +
      $ ruby -e 'puts $:.join("\n")'
       /usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
       /usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
       
      - - - - -
      - - - -

      36.1.3 Compiling a dynamic module

      @@ -283,100 +215,32 @@ exact commands for doing this vary from platform to platform, your best bet is to follow the steps described in the README.EXT file from the Ruby distribution:

      - - - -
        - - - - -
      1. - - - -

        Create a file called extconf.rb that looks like the following:

        - - - - - - - - -
        -
        require 'mkmf'
        create_makefile('example')
        +
        require 'mkmf'
        +create_makefile('example')
        - - - - -
      2. - - - - -
      3. - - - -

        Type the following to build the extension:

        - - - - - - - - -
        - - - - -
        $ ruby extconf.rb
        $ make
        $ make install +
        +$ ruby extconf.rb
        +$ make
        +$ make install
             
        - - - - -
        - - - - -
      4. - - - - -
      - - - -

      Of course, there is the problem that mkmf does not work correctly on all platforms, e.g, HPUX. If you need to add your own make rules to the file that extconf.rb produces, you can add this:

      - - - -
      open("Makefile", "a") { |mf|
        puts <<EOM
      @@ -384,17 +248,8 @@ can add this: 

      EOM }
      - - - - -
      - - - -

      to the end of the extconf.rb file. If for some reason you don't want to use the standard approach, you'll need to determine the correct compiler and linker flags for your build @@ -402,27 +257,14 @@ platform. For example, assuming you have code you need to link to in a file called example.c, a typical sequence of commands for the Linux operating system would look something like this:

      - - - -
      -
      $ swig -ruby example.i
      -$ gcc -c example.c
      -$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux 
      -$ gcc -shared example.o example_wrap.o -o example.so
      +
      $ swig -ruby example.i
      +$ gcc -c example.c
      +$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
      +$ gcc -shared example.o example_wrap.o -o example.so
       
      - - - - -
      - - - -

      For other platforms it may be necessary to compile with the -fPIC option to generate position-independent code. If in doubt, consult the manual pages for your compiler and linker to determine the correct set @@ -437,10 +279,6 @@ but the convention for Ruby feature names is to use lowercase names. So, for example, the Etc extension module is imported by requiring the etc feature:

      - - - -
      # The feature name begins with a lowercase letter...
       require 'etc'
      @@ -448,47 +286,21 @@ require 'etc'
       # ... but the module name begins with an uppercase letter
       puts "Your login name: #{Etc.getlogin}"
       
      - - - - -
      - - - -

      To stay consistent with this practice, you should always specify a lowercase module name with SWIG's %module directive. SWIG will automatically correct the resulting Ruby module name for your extension. So for example, a SWIG interface file that begins with:

      - - - -
      -
      %module example
      - - - - - +
      %module example
      - - - -

      will result in an extension module using the feature name "example" and Ruby module name "Example".

      - - - -

      36.1.5 Static linking

      @@ -499,41 +311,26 @@ loading support on certain machines. However, the situation has improved greatly over the last few years and you should not consider this approach unless there is really no other option.

      - - - -

      The usual procedure for adding a new module to Ruby involves finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

      - -

      36.1.6 Compilation of C++ extensions

      On most machines, C++ extension modules should be linked using the C++ compiler. For example:

      - - - -
      -
      $ swig -c++ -ruby example.i
      $ g++ -c example.cxx
      $ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
      $ g++ -shared example.o example_wrap.o -o example.so +
      +$ swig -c++ -ruby example.i
      +$ g++ -c example.cxx
      +$ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
      +$ g++ -shared example.o example_wrap.o -o example.so
       
      - - - - -
      - - - -

      If you've written an extconf.rb script to automatically generate a Makefile for your C++ extension module, keep in mind that (as of this writing) Ruby still @@ -545,23 +342,12 @@ module's append_library() method to add one of the C++ runtime libraries to the list of libraries linked into your extension, e.g.

      - - - -
      -
      require 'mkmf'
      $libs = append_library($libs, "supc++")
      create_makefile('example')
      - - - - - +
      require 'mkmf'
      +$libs = append_library($libs, "supc++")
      +create_makefile('example')
      - - - -

      36.2 Building Ruby Extensions under Windows 95/NT

      @@ -572,24 +358,14 @@ recent versions of Ruby, the procedure described above (i.e. using an extcon script) will work with Windows as well; you should be able to build your code into a DLL by typing:

      - - - -
      -
      C:\swigtest> ruby extconf.rb
      C:\swigtest> nmake
      C:\swigtest> nmake install +
      +C:\swigtest> ruby extconf.rb
      +C:\swigtest> nmake
      +C:\swigtest> nmake install
       
      - - - - -
      - - - -

      The remainder of this section covers the process of compiling SWIG-generated Ruby extensions with Microsoft Visual C++ 6 (i.e. within the Developer Studio IDE, instead of using the command line tools). In @@ -597,84 +373,35 @@ order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

      - - - -

      36.2.1 Running SWIG from Developer Studio

      If you are developing your application within Microsoft developer studio, SWIG can be invoked as a custom build option. The process roughly follows these steps :

      - - - - -
        - - - - -
      • Open up a new workspace and use the AppWizard to select a DLL project.
      • - - - - -
      • Add both the SWIG interface file (the .i file), any supporting C files, and the name of the wrapper file that will be created by SWIG (i.e. example_wrap.c). Note : If using C++, choose a different suffix for the wrapper file such as example_wrap.cxx. Don't worry if the wrapper file doesn't exist yet--Developer Studio will keep a reference to it around.
      • - - - - -
      • Select the SWIG interface file and go to the settings menu. Under settings, select the "Custom Build" option.
      • - - - - -
      • Enter "SWIG" in the description field.
      • - - - - -
      • Enter "swig -ruby -o $(ProjDir)\$(InputName)_wrap.c $(InputPath)" in the "Build command(s) field". You may have to include the path to swig.exe.
      • - - - - -
      • Enter "$(ProjDir)\$(InputName)_wrap.c" in the "Output files(s) field".
      • - - - - -
      • Next, select the settings for the entire project and go to the C/C++ tab and select the Preprocessor category. Add NT=1 to the Preprocessor definitions. This must be set else you will get compilation errors. Also add IMPORT to the preprocessor definitions, else you may get runtime errors. Also add the include directories for your Ruby installation under "Additional include directories".
      • - - - - -
      • Next, select the settings for the entire project and go to the Link tab and select the General category. Set the name of the output file to match the name of your Ruby module (i.e.. example.dll). @@ -682,23 +409,9 @@ Next add the Ruby library file to your link libraries under Object/Library modules. For example "mswin32-ruby16.lib. You also need to add the path to the library under the Input tab - Additional library path.
      • - - - - -
      • Build your project.
      • - - - - -
      - - - -

      Now, assuming all went well, SWIG will be automatically invoked when you build your project. Any changes made to the interface file will result in SWIG being automatically invoked to produce a new @@ -706,211 +419,95 @@ version of the wrapper file. To run your new Ruby extension, simply run Ruby and use the require command as normal. For example if you have this ruby file run.rb:

      - - - -
      -
      # file: run.rb
      require 'Example'

      # Call a c function
      print "Foo = ", Example.Foo, "\n"
      - - - - +
      # file: run.rb
      +require 'Example'
       
      +# Call a c function
      +print "Foo = ", Example.Foo, "\n"
      - - - -

      Ensure the dll just built is in your path or current directory, then run the Ruby script from the DOS/Command prompt:

      - - - -
      -
      C:\swigtest> ruby run.rb
      Foo = 3.0
      - - - - - +
      +C:\swigtest> ruby run.rb
      +Foo = 3.0
      +
      - - - -

      36.3 The Ruby-to-C/C++ Mapping

      This section describes the basics of how SWIG maps C or C++ declarations in your SWIG interface files to Ruby constructs.

      - - - -

      36.3.1 Modules

      The SWIG %module directive specifies the name of the Ruby module. If you specify:

      - - - -
      %module example
      - - - - -
      - - - -

      then everything is wrapped into a Ruby module named Example that is nested directly under the global module. You can specify a more deeply nested module by specifying the fully-qualified module name in quotes, e.g.

      - - - -
      %module "foo::bar::spam"
      - - - - -
      - - - -

      An alternate method of specifying a nested module name is to -use the -prefix +use the -prefix option on the SWIG command line. The prefix that you specify with this -option will be prepended to the module name specified with the %module +option will be prepended to the module name specified with the %module directive in your SWIG interface file. So for example, this declaration -at the top of your SWIG interface file:
      - - - - - +at the top of your SWIG interface file:

      - - - -
      %module "foo::bar::spam"
      - - - - -
      - - - - -

      will result in a nested module name of Foo::Bar::Spam, +

      will result in a nested module name of Foo::Bar::Spam, but you can achieve the same -effect by specifying:
      - - - - - +effect by specifying:

      - - - -
      %module spam
      - - - - -
      - - - - -

      and then running SWIG with the -prefix command -line option:
      - - - - - +

      and then running SWIG with the -prefix command +line option:

      - - - -
      -
      $ swig -ruby -prefix "foo::bar::" example.i
      - - - - - +
      +$ swig -ruby -prefix "foo::bar::" example.i
      +
      - - - -

      Starting with SWIG 1.3.20, you can also choose to wrap everything into the global module by specifying the -globalmodule option on the SWIG command line, i.e.

      - - - -
      -
      $ swig -ruby -globalmodule example.i
      - - - - - +
      +$ swig -ruby -globalmodule example.i
      +
      - - - -

      Note that this does not relieve you of the requirement of specifying the SWIG module name with the %module directive (or the -module command-line option) as described earlier.

      - - - -

      When choosing a module name, do not use the same name as a built-in Ruby command or standard module name, as the results may be unpredictable. Similarly, if you're using the -globalmodule @@ -918,10 +515,6 @@ option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

      - - - -

      36.3.2 Functions

      @@ -929,62 +522,33 @@ Ruby's built-in names.

      example, given the SWIG interface file example.i:

      - - - -
      -
      %module example

      int fact(int n);
      - - - - +
      %module example
       
      +int fact(int n);
      - - - -

      and C source file example.c:

      - - - -
      -
      int fact(int n) {
      if (n == 0)
      return 1;
      return (n * fact(n-1));
      }
      - - - - - +
      int fact(int n) {
      +  if (n == 0)
      +  return 1;
      +  return (n * fact(n-1));
      +}
      - - - -

      SWIG will generate a method fact in the Example module that can be used like so:

      - - - -
      -
      $ irb
      irb(main):001:0> require 'example'
      true
      irb(main):002:0> Example.fact(4)
      24
      - - - - - +
      $ irb
      +irb(main):001:0> require 'example'
      +true
      +irb(main):002:0> Example.fact(4)
      +24
      - - - -

      36.3.3 Variable Linking

      @@ -993,98 +557,60 @@ methods for the module: one to get the value of the global variable and one to set it. For example, the following SWIG interface file declares two global variables:

      - - - -
      -
      // SWIG interface file with global variables
      %module example
      ...
      %inline %{
      extern int variable1;
      extern double Variable2;
      %}
      ...
      - - - - - +
      // SWIG interface file with global variables
      +%module example
      +...
      +%inline %{
      +  extern int variable1;
      +  extern double Variable2;
      +%}
      +...
      - - - -

      Now look at the Ruby interface:

      - - - -
      -
      $ irb
      irb(main):001:0> require 'Example'
      true
      irb(main):002:0> Example.variable1 = 2
      2
      irb(main):003:0> Example.Variable2 = 4 * 10.3
      41.2
      irb(main):004:0> Example.Variable2
      41.2
      - - - - - +
      $ irb
      +irb(main):001:0> require 'Example'
      +true
      +irb(main):002:0> Example.variable1 = 2
      +2
      +irb(main):003:0> Example.Variable2 = 4 * 10.3
      +41.2
      +irb(main):004:0> Example.Variable2
      +41.2
      - - - -

      If you make an error in variable assignment, you will receive an error message. For example:

      - - - -
      -
      irb(main):005:0> Example.Variable2 = "hello"
      TypeError: no implicit conversion to float from string
      from (irb):5:in `Variable2='
      from (irb):5
      - - - - - +
      irb(main):005:0> Example.Variable2 = "hello"
      +TypeError: no implicit conversion to float from string
      +from (irb):5:in `Variable2='
      +from (irb):5
      - - - -

      If a variable is declared as const, it is wrapped as a read-only variable. Attempts to modify its value will result in an error.

      - - - -

      To make ordinary variables read-only, you can also use the %immutable directive. For example:

      - - - -
      -
      %immutable;
      %inline %{
      extern char *path;
      %}
      %mutable;
      - - - - - +
      %immutable;
      +%inline %{
      +  extern char *path;
      +%}
      +%mutable;
      - - - -

      The %immutable directive stays in effect until it is explicitly disabled using %mutable.

      - - - -

      36.3.4 Constants

      @@ -1092,43 +618,27 @@ effect until it is explicitly disabled using %mutable. to the appropriate value. To create a constant, use #define or the %constant directive. For example:

      - - - -
      -
      #define PI 3.14159
      #define VERSION "1.0"

      %constant int FOO = 42;
      %constant const char *path = "/usr/local";

      const int BAR = 32;
      - - - +
      #define PI 3.14159
      +#define VERSION "1.0"
       
      +%constant int FOO = 42;
      +%constant const char *path = "/usr/local";
       
      +const int BAR = 32;
      - - - -

      Remember to use the :: operator in Ruby to get at these constant values, e.g.

      - - - -
      -
      $ irb
      irb(main):001:0> require 'Example'
      true
      irb(main):002:0> Example::PI
      3.14159
      - - - - - +
      $ irb
      +irb(main):001:0> require 'Example'
      +true
      +irb(main):002:0> Example::PI
      +3.14159
      - - - -

      36.3.5 Pointers

      @@ -1137,50 +647,22 @@ aren't explicitly declared in your SWIG interface file) are wrapped as data objects. So, for example, consider a SWIG interface file containing only the declarations:

      - - - -
      -
      Foo *get_foo();
      void set_foo(Foo *foo);
      - - - - - +
      Foo *get_foo();
      +void set_foo(Foo *foo);
      - - - -

      For this case, the get_foo() method returns an instance of an internally generated Ruby class:

      - - - -
      -
      irb(main):001:0> foo = Example::get_foo()
      #<SWIG::TYPE_p_Foo:0x402b1654>
      - - - - - +
      irb(main):001:0> foo = Example::get_foo()
      +#<SWIG::TYPE_p_Foo:0x402b1654>
      - - - -

      A NULL pointer is always represented by the Ruby nil object.

      - - - -

      36.3.6 Structures

      @@ -1188,74 +670,48 @@ the Ruby nil object.

      methods (i.e. "getters" and "setters") for all of the struct members. For example, this struct declaration:

      - - - -
      -
      struct Vector {
      double x, y;
      };
      - - - - - +
      struct Vector {
      +  double x, y;
      +};
      - - - -

      gets wrapped as a Vector class, with Ruby instance methods x, x=, y and y=. These methods can be used to access structure data from Ruby as follows:

      - - - -
      -
      $ irb
      irb(main):001:0> require 'Example'
      true
      irb(main):002:0> f = Example::Vector.new
      #<Example::Vector:0x4020b268>
      irb(main):003:0> f.x = 10
      nil
      irb(main):004:0> f.x
      10.0
      - - - - - +
      $ irb
      +irb(main):001:0> require 'Example'
      +true
      +irb(main):002:0> f = Example::Vector.new
      +#<Example::Vector:0x4020b268>
      +irb(main):003:0> f.x = 10
      +nil
      +irb(main):004:0> f.x
      +10.0
      - - - -

      Similar access is provided for unions and the public data members of C++ classes.

      - - - -

      const members of a structure are read-only. Data members can also be forced to be read-only using the %immutable directive (in C++, private may also be used). For example:

      - - - -
      -
      struct Foo {
      ...
      %immutable;
      int x; /* Read-only members */
      char *name;
      %mutable;
      ...
      };
      - - - - - +
      struct Foo {
      +  ...
      +  %immutable;
      +  int x; /* Read-only members */
      +  char *name;
      +  %mutable;
      +  ...
      +};
      - - - -

      When char * members of a structure are wrapped, the contents are assumed to be dynamically allocated using malloc or new (depending on whether or not SWIG is run @@ -1264,98 +720,54 @@ is set, the old contents will be released and a new value created. If this is not the behavior you want, you will have to use a typemap (described shortly).

      - - - -

      Array members are normally wrapped as read-only. For example, this code:

      - - - -
      -
      struct Foo {
      int x[50];
      };
      - - - - - +
      struct Foo {
      +  int x[50];
      +};
      - - - -

      produces a single accessor function like this:

      - - - -
      -
      int *Foo_x_get(Foo *self) {
      return self->x;
      };
      - - - - - +
      int *Foo_x_get(Foo *self) {
      +  return self->x;
      +};
      - - - -

      If you want to set an array member, you will need to supply a "memberin" typemap described in the section on typemaps. As a special case, SWIG does generate code to set array members of type char (allowing you to store a Ruby string in the structure).

      - - - -

      When structure members are wrapped, they are handled as pointers. For example,

      - - - -
      -
      struct Foo {
      ...
      };

      struct Bar {
      Foo f;
      };
      - - - - +
      struct Foo {
      +  ...
      +};
       
      +struct Bar {
      +  Foo f;
      +};
      - - - -

      generates accessor functions such as this:

      - - - -
      -
      Foo *Bar_f_get(Bar *b) {
      return &b->f;
      }

      void Bar_f_set(Bar *b, Foo *val) {
      b->f = *val;
      }
      - - - - +
      Foo *Bar_f_get(Bar *b) {
      +  return &b->f;
      +}
       
      +void Bar_f_set(Bar *b, Foo *val) {
      +  b->f = *val;
      +}
      - - - -

      36.3.7 C++ classes

      @@ -1366,152 +778,97 @@ wrapped as Ruby instance methods, and public static member functions are wrapped as Ruby singleton methods. So, given the C++ class declaration:

      - - - -
      -
      class List {
      public:
      List();
      ~List();
      int search(char *item);
      void insert(char *item);
      void remove(char *item);
      char *get(int n);
      int length;
      static void print(List *l);
      };
      - - - - - +
      class List {
      +public:
      +  List();
      +  ~List();
      +  int search(char *item);
      +  void insert(char *item);
      +  void remove(char *item);
      +  char *get(int n);
      +  int length;
      +  static void print(List *l);
      +};
      - - - -

      SWIG would create a List class with:

      - - - -
        - - - - -
      • instance methods search, insert, remove, and get;
      • - - - - -
      • instance methods length and length= (to get and set the value of the length data member); and,
      • - - - - -
      • a print singleton method for the class.
      • - - - - -
      - - - -

      In Ruby, these functions are used as follows:

      - - - -
      -
      require 'Example'

      l = Example::List.new

      l.insert("Ale")
      l.insert("Stout")
      l.insert("Lager")
      Example.print(l)
      l.length()
      ----- produces the following output
      Lager
      Stout
      Ale
      3
      - - - +
      require 'Example'
       
      +l = Example::List.new
       
      +l.insert("Ale")
      +l.insert("Stout")
      +l.insert("Lager")
      +Example.print(l)
      +l.length()
      +----- produces the following output 
      +Lager
      +Stout
      +Ale
      +3
      - - - -

      36.3.8 C++ Inheritance

      The SWIG type-checker is fully aware of C++ inheritance. Therefore, if you have classes like this:

      - - - -
      -
      class Parent {
      ...
      };

      class Child : public Parent {
      ...
      };
      - - - - +
      class Parent {
      +  ...
      +};
       
      +class Child : public Parent {
      +  ...
      +};
      - - - -

      those classes are wrapped into a hierarchy of Ruby classes that reflect the same inheritance structure. All of the usual Ruby utility methods work normally:

      - - - -
      -
      irb(main):001:0> c = Child.new
      #<Bar:0x4016efd4>
      irb(main):002:0> c.instance_of? Child
      true
      irb(main):003:0> b.instance_of? Parent
      false
      irb(main):004:0> b.is_a? Child
      true
      irb(main):005:0> b.is_a? Parent
      true
      irb(main):006:0> Child < Parent
      true
      irb(main):007:0> Child > Parent
      false
      - - - - - +
      irb(main):001:0> c = Child.new
      +#<Bar:0x4016efd4>
      +irb(main):002:0> c.instance_of? Child
      +true
      +irb(main):003:0> b.instance_of? Parent
      +false
      +irb(main):004:0> b.is_a? Child
      +true
      +irb(main):005:0> b.is_a? Parent
      +true
      +irb(main):006:0> Child < Parent
      +true
      +irb(main):007:0> Child > Parent
      +false
      - - - -

      Furthermore, if you have a function like this:

      - - - -
      -
      void spam(Parent *f);
      - - - - - +
      void spam(Parent *f);
      - - - -

      then the function spam() accepts Parent* or a pointer to any class derived from Parent.

      - - - -

      Until recently, the Ruby module for SWIG didn't support multiple inheritance, and this is still the default behavior. This doesn't mean that you can't wrap C++ classes which inherit from @@ -1520,23 +877,13 @@ base class listed in the class declaration is considered, and any additional base classes are ignored. As an example, consider a SWIG interface file with a declaration like this:

      - - - -
      -
      class Derived : public Base1, public Base2
      {
      ...
      };
      - - - - - +
      class Derived : public Base1, public Base2
      +{
      +  ...
      +};
      - - - -

      For this case, the resulting Ruby class (Derived) will only consider Base1 as its superclass. It won't inherit any of Base2's member functions or @@ -1545,66 +892,33 @@ data and it won't recognize Base2 as an relationship would fail). When SWIG processes this interface file, you'll see a warning message like:

      - - - -
      -
      example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
      Multiple inheritance is not supported in Ruby.
      - - - - - +
      example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
      +Multiple inheritance is not supported in Ruby.
      - - - -

      Starting with SWIG 1.3.20, the Ruby module for SWIG provides limited support for multiple inheritance. Because the approach for dealing with multiple inheritance introduces some limitations, this is an optional feature that you can activate with the -minherit command-line option:

      - - - -
      -
      $ swig -c++ -ruby -minherit example.i
      - - - - - +
      +$ swig -c++ -ruby -minherit example.i
      +
      - - - -

      Using our previous example, if your SWIG interface file contains a declaration like this:

      - - - -
      -
      class Derived : public Base1, public Base2
      {
      ...
      };
      - - - - - +
      class Derived : public Base1, public Base2
      +{
      +  ...
      +};
      - - - -

      and you run SWIG with the -minherit command-line option, then you will end up with a Ruby class Derived that appears to "inherit" the member data and functions from both Base1 @@ -1615,64 +929,53 @@ module named Impl, and it's in these nested Impl modules that the actual instance methods for the classes are defined, i.e.

      - - - -
      -
      class Base1
      module Impl
      # Define Base1 methods here
      end
      include Impl
      end

      class Base2
      module Impl
      # Define Base2 methods here
      end
      include Impl
      end

      class Derived
      module Impl
      include Base1::Impl
      include Base2::Impl
      # Define Derived methods here
      end
      include Impl
      end
      - - - +
      class Base1
      +  module Impl
      +  # Define Base1 methods here
      +  end
      +  include Impl
      +end
       
      +class Base2
      +  module Impl
      +  # Define Base2 methods here
      +  end
      +  include Impl
      +end
       
      +class Derived
      +  module Impl
      +  include Base1::Impl
      +  include Base2::Impl
      +  # Define Derived methods here
      +  end
      +  include Impl
      +end
      - - - -

      Observe that after the nested Impl module for a class is defined, it is mixed-in to the class itself. Also observe that the Derived::Impl module first mixes-in its base classes' Impl modules, thus "inheriting" all of their behavior.

      - - - -

      The primary drawback is that, unlike the default mode of operation, neither Base1 nor Base2 is a true superclass of Derived anymore:

      - - - -
      -
      obj = Derived.new
      obj.is_a? Base1 # this will return false...
      obj.is_a? Base2 # ... and so will this
      - - - - - +
      obj = Derived.new
      +obj.is_a? Base1 # this will return false...
      +obj.is_a? Base2 # ... and so will this
      - - - -

      In most cases, this is not a serious problem since objects of type Derived will otherwise behave as though they inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

      - - - -

      36.3.9 C++ Overloaded Functions

      @@ -1680,199 +983,89 @@ Typing").

      mostly supported by SWIG. For example, if you have two functions like this:

      - - - -
      -
      void foo(int);
      void foo(char *c);
      - - - - - +
      void foo(int);
      +void foo(char *c);
      - - - -

      You can use them in Ruby in a straightforward manner:

      - - - -
      -
      irb(main):001:0> foo(3) # foo(int)
      irb(main):002:0> foo("Hello") # foo(char *c)
      - - - - - +
      irb(main):001:0> foo(3) # foo(int)
      +irb(main):002:0> foo("Hello") # foo(char *c)
      - - - -

      Similarly, if you have a class like this,

      - - - -
      -
      class Foo {
      public:
      Foo();
      Foo(const Foo &);
      ...
      };
      - - - - - +
      class Foo {
      +public:
      +  Foo();
      +  Foo(const Foo &);
      +  ...
      +};
      - - - -

      you can write Ruby code like this:

      - - - -
      -
      irb(main):001:0> f = Foo.new # Create a Foo
      irb(main):002:0> g = Foo.new(f) # Copy f
      - - - - - +
      irb(main):001:0> f = Foo.new # Create a Foo
      +irb(main):002:0> g = Foo.new(f) # Copy f
      - - - -

      Overloading support is not quite as flexible as in C++. Sometimes there are methods that SWIG can't disambiguate. For example:

      - - - -
      -
      void spam(int);
      void spam(short);
      - - - - - +
      void spam(int);
      +void spam(short);
      - - - -

      or

      - - - -
      -
      void foo(Bar *b);
      void foo(Bar &b);
      - - - - - +
      void foo(Bar *b);
      +void foo(Bar &b);
      - - - -

      If declarations such as these appear, you will get a warning message like this:

      - - - -
       example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
       example.i:11: Warning 509: as it is shadowed by spam(int).
      -
      -
      - - - - - +
  • - - - -

    To fix this, you either need to ignore or rename one of the methods. For example:

    - - - -
    -
    %rename(spam_short) spam(short);
    ...
    void spam(int);
    void spam(short); // Accessed as spam_short
    - - - - - +
    %rename(spam_short) spam(short);
    +...
    +void spam(int); 
    +void spam(short); // Accessed as spam_short
    - - - -

    or

    - - - -
    -
    %ignore spam(short);
    ...
    void spam(int);
    void spam(short); // Ignored
    - - - - - +
    %ignore spam(short);
    +...
    +void spam(int); 
    +void spam(short); // Ignored
    - - - -

    SWIG resolves overloaded functions and methods using a disambiguation scheme that ranks and sorts declarations according to a set of type-precedence rules. The order in which declarations appear in the input does not matter except in situations where ambiguity arises--in this case, the first declaration takes precedence.

    - - - -

    Please refer to the "SWIG and C++" chapter for more information about overloading.

    - - - -

    36.3.10 C++ Operators

    @@ -1880,80 +1073,41 @@ and C++" chapter for more information about overloading.

    automatically by SWIG and do not require any special treatment on your part. So if your class declares an overloaded addition operator, e.g.

    - - - -
    -
    class Complex {
    ...
    Complex operator+(Complex &);
    ...
    };
    - - - - - +
    class Complex {
    +  ...
    +  Complex operator+(Complex &);
    +  ...
    +};
    - - - -

    the resulting Ruby class will also support the addition (+) method correctly.

    - - - -

    For cases where SWIG's built-in support is not sufficient, C++ operators can be wrapped using the %rename directive (available on SWIG 1.3.10 and later releases). All you need to do is give the operator the name of a valid Ruby identifier. For example:

    - - - -
    -
    %rename(add_complex) operator+(Complex &, Complex &);
    ...
    Complex operator+(Complex &, Complex &);
    - - - - - +
    %rename(add_complex) operator+(Complex &, Complex &);
    +...
    +Complex operator+(Complex &, Complex &);
    - - - -

    Now, in Ruby, you can do this:

    - - - -
    -
    a = Example::Complex.new(2, 3)
    b = Example::Complex.new(4, -1)
    c = Example.add_complex(a, b)
    - - - - - +
    a = Example::Complex.new(2, 3)
    +b = Example::Complex.new(4, -1)
    +c = Example.add_complex(a, b)
    - - - -

    More details about wrapping C++ operators into Ruby operators is discussed in the section on operator overloading.

    - - - -

    36.3.11 C++ namespaces

    @@ -1962,63 +1116,48 @@ appear in the module nor do namespaces result in a module that is broken up into submodules or packages. For example, if you have a file like this,

    - - - -
    -
    %module example

    namespace foo {
    int fact(int n);
    struct Vector {
    double x,y,z;
    };
    };
    - - - - +
    %module example
     
    +namespace foo {
    +  int fact(int n);
    +  struct Vector {
    +    double x,y,z;
    +  };
    +};
    - - - -

    it works in Ruby as follows:

    - - - -
    -
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> Example.fact(3)
    6
    irb(main):003:0> v = Example::Vector.new
    #<Example::Vector:0x4016f4d4>
    irb(main):004:0> v.x = 3.4
    3.4
    irb(main):004:0> v.y
    0.0
    - - - - - +
    irb(main):001:0> require 'example'
    +true
    +irb(main):002:0> Example.fact(3)
    +6
    +irb(main):003:0> v = Example::Vector.new
    +#<Example::Vector:0x4016f4d4>
    +irb(main):004:0> v.x = 3.4
    +3.4
    +irb(main):004:0> v.y
    +0.0
    - - - -

    If your program has more than one namespace, name conflicts (if any) can be resolved using %rename For example:

    - - - -
    -
    %rename(Bar_spam) Bar::spam;

    namespace Foo {
    int spam();
    }

    namespace Bar {
    int spam();
    }
    - - - +
    %rename(Bar_spam) Bar::spam;
     
    +namespace Foo {
    +  int spam();
    +}
     
    +namespace Bar {
    +  int spam();
    +}
    - - - -

    If you have more than one namespace and your want to keep their symbols separate, consider wrapping them as separate SWIG modules. For example, make the module name the same as the namespace @@ -2026,10 +1165,6 @@ and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    - - - -

    36.3.12 C++ templates

    @@ -2038,42 +1173,40 @@ in order to create wrappers, you have to tell SWIG to create wrappers for a particular template instantiation. To do this, you use the %template directive. For example:

    - - - -
    -
    %module example

    %{
    #include "pair.h"
    %}

    template<class T1, class T2>
    struct pair {
    typedef T1 first_type;
    typedef T2 second_type;
    T1 first;
    T2 second;
    pair();
    pair(const T1&, const T2&);
    ~pair();
    };

    %template(Pairii) pair<int,int>;
    - - +
    %module example
     
    +%{
    +#include "pair.h"
    +%}
     
    +template<class T1, class T2>
    +struct pair {
    +  typedef T1 first_type;
    +  typedef T2 second_type;
    +  T1 first;
    +  T2 second;
    +  pair();
    +  pair(const T1&, const T2&);
    +  ~pair();
    +};
     
    +%template(Pairii) pair<int,int>;
    - - - -

    In Ruby:

    - - - -
    -
    irb(main):001:0> require 'example'
    true
    irb(main):002:0> p = Example::Pairii.new(3, 4)
    #<Example:Pairii:0x4016f4df>
    irb(main):003:0> p.first
    3
    irb(main):004:0> p.second
    4
    - - - - - +
    irb(main):001:0> require 'example'
    +true
    +irb(main):002:0> p = Example::Pairii.new(3, 4)
    +#<Example:Pairii:0x4016f4df>
    +irb(main):003:0> p.first
    +3
    +irb(main):004:0> p.second
    +4
    - - - -

    36.3.13 C++ Standard Template Library (STL)

    @@ -2087,656 +1220,229 @@ convenient for users of your extension module to pass Ruby objects of standard C++ templates. For example, suppose the C++ library you're wrapping has a function that expects a vector of floats:

    - - - -
    -
    %module example

    float sum(const std::vector<float>& values);
    - - - - +
    %module example
     
    +float sum(const std::vector<float>& values);
    - - - -

    Rather than go through the hassle of writing an "in" typemap to convert an array of Ruby numbers into a std::vector<float>, you can just use the std_vector.i module from the standard SWIG library:

    - - - -
    -
    %module example

    %include std_vector.i
    float sum(const std::vector<float>& values);
    - - - - +
    %module example
     
    +%include std_vector.i
    +float sum(const std::vector<float>& values);
    - - - -

    Ruby's STL wrappings provide additional methods to make them behave more similarly to Ruby's native classes.

    - - - -

    Thus, you can do, for example:

    - - - -
    -
    v = IntVector.new
    v << 2

    v << 3
    v << 4
    v.each { |x| puts x }

    => 2

    3
    4
    v.delete_if { |x| x == 3 }
    => [2,4]
    - - - - +
    v = IntVector.new
    +v << 2
    +v << 3
    +v << 4
    +v.each { |x| puts x }
     
    +=> 2
    +3
    +4
    +v.delete_if { |x| x == 3 }
    +=> [2,4]
    - - - -

    The SWIG Ruby module provides also the ability for all the STL containers to carry around Ruby native objects (Fixnum, Classes, etc) -making them act almost like Ruby's own Array, Hash, etc.   To +making them act almost like Ruby's own Array, Hash, etc. To do that, you need to define a container that contains a swig::GC_VALUE, like:

    +
    +%module nativevector
     
    +%{
    +std::vector< swig::GC_VALUE > NativeVector;
    +%}
     
    -
    -
    -
    %module -nativevector
    - - - - - -
    - - - - - -%{
    - - - - - -std::vector< swig::GC_VALUE > NativeVector;
    - - - - - -%}
    - - - - - -
    - - - - - -%template(NativeVector) std::vector< swig::GC_VALUE >;
    - - - - - +%template(NativeVector) std::vector< swig::GC_VALUE >; +
    - - - - -
    - - - - -

    This vector can then contain any Ruby object, making them almost identical to Ruby's own Array class.

    +
    +
    require 'nativevector'
    +include NativeVector
     
    +v = NativeVector.new
    +v << 1
    +v << [1,2]
    +v << 'hello'
     
    +class A; end
     
    +v << A.new
     
    -
    require 'nativevector'
    - - - - - -include NativeVector
    - - - - - -
    - - - - - -v = NativeVector.new
    - - - - - -v << 1
    - - - - - -v << -[1,2]
    - - - - - -v << -'hello'
    - - - - - -
    - - - - - -class A; end
    - - - - - -
    - - - - - -v << -A.new
    - - - - - -
    - - - - - -puts v
    - - - - - -=> -[1, [1,2], 'hello', #<A:0x245325>]
    - - - - - -
    - - - - +puts v +=> [1, [1,2], 'hello', #<A:0x245325>] +
    +

    Obviously, there is a lot more to template wrapping than shown in these examples. More details can be found in the SWIG and C++ chapter.

    - - - -

    36.3.14 C++ STL Functors

    Some containers in the STL allow you to modify their default behavior by using so called functors or function objects. - Functors are often just a very simple struct with operator() -redefined or an actual C/C++ function.  This allows you, for +Functors are often just a very simple struct with operator() +redefined or an actual C/C++ function. This allows you, for example, to always keep the sort order of a STL container to your liking.

    - - - -

    The Ruby STL mappings allows you to modify those containers that support functors using Ruby procs or methods, instead. - Currently, -this includes std::set, -set::map, -std::multiset -and std::multimap.

    +Currently, +this includes std::set, +set::map, +std::multiset +and std::multimap.

    +

    The functors in swig are called swig::UnaryFunction +and swig::BinaryFunction. - - - -

    The functors in swig are called swig::UnaryFunction -and swig::BinaryFunction.
    - - - - - -For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate -and swig::BinaryPredicate +For C++ predicates (ie. functors that must return bool as a result) swig::UnaryPredicate +and swig::BinaryPredicate are provided.

    - - - -

    As an example, if given this swig file:

    +
    +%module intset;
     
    +%include <std_set.i>
     
    -
    -
    -
    %module -intset;
    - - - - - -
    - - - - - -%include <std_set.i>
    - - - - - -
    - - - - - -%typemap(IntSet)  std::set< int, swig::BinaryPredicate ->;
    - - - - +%typemap(IntSet) std::set< int, swig::BinaryPredicate >; +

    You can then use the set from Ruby with or without a proc object as a predicate:

    +
    +require 'intset'
    +include Intset
     
    -
    -
    -
    -
    require -'intset'
    - - - - - -include Intset
    - - - - - -
    - - - - - -# Default sorting behavior defined in C++
    - - - - - -a = IntSet.new
    - - - - - -a << 1
    - - - - - -a << 2
    - - - - - -a << 3
    - - - - - -a
    - - - - - -=> - [1,2,3]
    - - - - - -
    - - - - +# Default sorting behavior defined in C++ +a = IntSet.new +a << 1 +a << 2 +a << 3 +a +=> [1,2,3] # Custom sorting behavior defined by a Ruby proc -
    b = IntSet.new( proc { -|a,b| a > b } )
    - - - - - -b << 1
    - - - - - -b << 2
    - - - - - -b << 3
    - - - - - -b
    - - - - - -=> - [3,2,1]
    - - - - - +b = IntSet.new( proc { |a,b| a > b } ) +b << 1 +b << 2 +b << 3 +b +=> [3,2,1] +
    - - - -

    36.3.15 C++ STL Iterators

    -

    The STL is well known for the use of iterators.  There +

    The STL is well known for the use of iterators. There are a number of iterators possible with different properties, but in general there are two main categories: const iterators and non-const -iterators.  The const iterators can access and not modify the +iterators. The const iterators can access and not modify the values they point at, while the non-const iterators can both read and modify the values.

    - - - -

    The Ruby STL wrappings support both type of iterators by using -a proxy class in-between.  This proxy class is swig::Iterator or -swig::ConstIterator.  Derived from them are template +a proxy class in-between. This proxy class is swig::Iterator or +swig::ConstIterator. Derived from them are template classes that need to be initialized with the actual iterator for the container you are wrapping and often times with the beginning and -ending points of the iteration range. 

    - - - - +ending points of the iteration range.

    The SWIG STL library already provides typemaps to all the standard containers to do this wrapping automatically for you, but if you have your own STL-like iterator, you will need to write your own -typemap for them.  For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    +typemap for them. For out typemaps, the special functions make_const_iterator and make_nonconst_iterator are provided.

    These can be used either like:

    -
    make_const_iterator( iterator, rubyclass );
    +
    +make_const_iterator( iterator, rubyclass );
    +make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );
    +
    -make_const_iterator( iterator, iterator_begin, iterator_end, rubyclass );
    - - - - - -

    The iterators support a next() and previous() member function to -just change the iterator without returning anything.  previous() -should obviously only be used for bidirectional iterators.  You +

    The iterators support a next() and previous() member function to +just change the iterator without returning anything. previous() +should obviously only be used for bidirectional iterators. You can also advance the iterator multiple steps by using standard math -operations like +=.

    +operations like +=.

    The -value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. -  For non-const iterators, a value=() function +value the iterator points at can be accessed with value() -- this is equivalent to dereferencing it with *i. + For non-const iterators, a value=() function is also provided which allows you to change the value pointed by the -iterator.  This is equivalent to the C++ construct of dereferencing and assignment, like *i = something

    - - - - +iterator. This is equivalent to the C++ construct of dereferencing and assignment, like *i = something.

    Thus, given say a vector class of doubles defined as:

    +
    +
    +%module doublevector
     
    +%include std_vector.i
     
    -
    -
    -
    %module doublevector
    - - - - - -
    - - - - - -%include std_vector.i

    - - - - - -
    - - - - - -%template(DoubleVector) std::vector<double>;
    - - - - +%template(DoubleVector) std::vector<double>; +
    +

    Its iterator can then be used from Ruby like:

    - - - - -
    require -'doublevector'
    - - - - - -include Doublevector
    - -
    - - - - - -v = DoubleVector.new
    - - - - - -v << 1
    - - - - - -v << 2
    - - - - - -v << 3
    - -
    - -#
    - -# an elaborate and less efficient way of doing v.map! { |x| x+2 }
    - -#
    - - - - - -i = v.begin
    - - - - - -e = v.end
    - - - - - -while i != e
    - - - - - -  val = i.value
    - - - - - -  val += 2
    - - - - - -  i.value = val
    - - - - - -  i.next
    - - - - - -end
    - - - - -i
    - - - - ->> [3, 4, 5 ]
    - - - - - -
    - -

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    - - - - +
    +
    +require 'doublevector'
    +include Doublevector
    +
    +v = DoubleVector.new
    +v << 1
    +v << 2
    +v << 3
    +
    +#
    +# an elaborate and less efficient way of doing v.map! { |x| x+2 }
    +#
    +i = v.begin
    +e = v.end
    +while i != e
    +  val = i.value
    +  val += 2
    +  i.value = val
    +  i.next
    +end
    +i
    +>> [3, 4, 5 ]
    +
    +
    + +

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    36.3.16 C++ Smart Pointers

    @@ -2746,123 +1452,63 @@ have been wrapped by so-called "smart pointers." Generally, this involves the use of a template class that implements operator->() like this:

    - - - -
    -
    template<class T> class SmartPtr {
    ...
    T *operator->();
    ...
    }
    - - - - - +
    template<class T> class SmartPtr {
    +  ...
    +  T *operator->();
    +  ...
    +}
    - - - -

    Then, if you have a class like this,

    - - - -
    -
    class Foo {
    public:
    int x;
    int bar();
    };
    - - - - - +
    class Foo {
    +public:
    +  int x;
    +  int bar();
    +};
    - - - -

    A smart pointer would be used in C++ as follows:

    - - - -
    -
    SmartPtr<Foo> p = CreateFoo(); // Created somehow (not shown)
    ...
    p->x = 3; // Foo::x
    int y = p->bar(); // Foo::bar
    - - - - - +
    SmartPtr<Foo> p = CreateFoo(); // Created somehow (not shown)
    +...
    +p->x = 3; // Foo::x
    +int y = p->bar(); // Foo::bar
    - - - -

    To wrap this in Ruby, simply tell SWIG about the SmartPtr class and the low-level Foo object. Make sure you instantiate SmartPtr using %template if necessary. For example:

    - - - -
    -
    %module example
    ...
    %template(SmartPtrFoo) SmartPtr<Foo>;
    ...
    - - - - - +
    %module example
    +...
    +%template(SmartPtrFoo) SmartPtr<Foo>;
    +...
    - - - -

    Now, in Ruby, everything should just "work":

    - - - -
    -
    irb(main):001:0> p = Example::CreateFoo() # Create a smart-pointer somehow
    #<Example::SmartPtrFoo:0x4016f4df>
    irb(main):002:0> p.x = 3 # Foo::x
    3
    irb(main):003:0> p.bar() # Foo::bar
    - - - - - +
    irb(main):001:0> p = Example::CreateFoo() # Create a smart-pointer somehow
    +#<Example::SmartPtrFoo:0x4016f4df>
    +irb(main):002:0> p.x = 3 # Foo::x
    +3
    +irb(main):003:0> p.bar() # Foo::bar
    - - - -

    If you ever need to access the underlying pointer returned by operator->() itself, simply use the __deref__() method. For example:

    - - - -
    -
    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    - - - - - +
    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    - - - -

    36.3.17 Cross-Language Polymorphism

    @@ -2872,10 +1518,6 @@ module. Rather than duplicate the information presented in the 36.3.17.1 Exception Unrolling @@ -2888,32 +1530,17 @@ change this behavior, you can use the %feature("director:except") directive to indicate what action should be taken when a Ruby exception is raised. The following code should suffice in most cases:

    - - - -
    -
    %feature("director:except") {
    throw Swig::DirectorMethodException($error);
    }
    - - - - - +
    %feature("director:except") {
    +  throw Swig::DirectorMethodException($error);
    +}
    - - - -

    When this feature is activated, the call to the Ruby instance method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

    - - - -

    36.4 Naming

    @@ -2922,94 +1549,36 @@ generally in upper case, module and class names are in camel case and methods are in lower case with underscores. For example:

    - - - -
      - - - - -
    • MATH::PI is a constant name
    • - - - - -
    • MyClass is a class name
    • - - - - -
    • my_method is a method name
    • - - - - -
    - - - - -
    - - - -

    Prior to version 1.3.28, SWIG did not support these Ruby conventions. The only modifications it made to names was to capitalize the first letter of constants (which includes module and class names).

    - - - -

    SWIG 1.3.28 introduces the new -autorename command line parameter. When this parameter is specified, SWIG will automatically change constant, class and method names to conform with the standard Ruby naming conventions. For example:

    - - - -
    -
    $ swig -ruby -autorename example.i
    +
    $ swig -ruby -autorename example.i
     
    - - - - -
    - - - -

    To disable renaming use the -noautorename command line option.

    - - - -

    Since this change significantly changes the wrapper code generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

    - - - -

    36.4.1 Defining Aliases

    @@ -3021,65 +1590,51 @@ approach is to use SWIG's %extend directive to add a new method of the aliased name that calls the original function. For example:

    - - - -
    -
    class MyArray {
    public:
    // Construct an empty array
    MyArray();

    // Return the size of this array
    size_t length() const;
    };

    %extend MyArray {
    // MyArray#size is an alias for MyArray#length
    size_t size() const {
    return $self->length();
    }
    }
    - - - +
    class MyArray {
    +public:
    +  // Construct an empty array
    +  MyArray();
     
    +  // Return the size of this array
    +  size_t length() const;
    +};
     
    +%extend MyArray {
    +  // MyArray#size is an alias for MyArray#length
    +  size_t size() const {
    +    return $self->length();
    +  }
    +}
    + 
    - - - -

    A better solution is to use the %alias directive (unique to SWIG's Ruby module). The previous example could then be rewritten as:

    - - - -
    -
    // MyArray#size is an alias for MyArray#length
    %alias MyArray::length "size";

    class MyArray {
    public:
    // Construct an empty array
    MyArray();

    // Return the size of this array
    size_t length() const;
    };

    - - - - +
    // MyArray#size is an alias for MyArray#length
    +%alias MyArray::length "size";
     
    +class MyArray {
    +public:
    +  // Construct an empty array
    +  MyArray();
    + 
    +  // Return the size of this array
    +  size_t length() const;
    +};
    - - - -

    Multiple aliases can be associated with a method by providing a comma-separated list of aliases to the %alias directive, e.g.

    - - - -
    %alias MyArray::length "amount,quantity,size";
    - - - - -
    - - - -

    From an end-user's standpoint, there's no functional difference between these two approaches; i.e. they should get the same result from calling either MyArray#size or MyArray#length. @@ -3088,20 +1643,12 @@ doesn't need to generate all of the wrapper code that's usually associated with added methods like our MyArray::size() example.

    - - - -

    Note that the %alias directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.4.2 Predicate Methods

    @@ -3115,82 +1662,42 @@ if the object is an instance of the specified class). For consistency with Ruby conventions, methods that return boolean values should be marked as predicate methods.

    - - - -

    One cumbersome solution to this problem is to rename the method (using SWIG's %rename directive) and provide a custom typemap that converts the function's actual return type to Ruby's true or false. For example:

    - - - -
    -
    %rename("is_it_safe?") is_it_safe();

    %typemap(out) int is_it_safe
    "$result = ($1 != 0) ? Qtrue : Qfalse;";

    int is_it_safe();

    - - - +
    %rename("is_it_safe?") is_it_safe();
     
    +%typemap(out) int is_it_safe "$result = ($1 != 0) ? Qtrue : Qfalse;";
     
    +int is_it_safe();
    - - - -

    A better solution is to use the %predicate directive (unique to SWIG's Ruby module) to designate a method as a predicate method. For the previous example, this would look like:

    - - - -
    -
    %predicate is_it_safe();

    int is_it_safe();

    - - - - +
    %predicate is_it_safe();
     
    +int is_it_safe();
    - - - -

    This method would be invoked from Ruby code like this:

    - - - -
    -
    irb(main):001:0> Example::is_it_safe?
    true

    - - - - - +
    irb(main):001:0> Example::is_it_safe?
    +true
    - - - -

    The %predicate directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.4.3 Bang Methods

    @@ -3202,380 +1709,201 @@ which returns a copy of the array with the items sorted instead of modifying the original array. For consistency with Ruby conventions, methods that modify objects in place should be marked as bang methods.

    - - - -

    Bang methods can be marked using the %bang directive which is unique to the Ruby module and was introduced in SWIG 1.3.28. For example:

    - - - -
    -
    %bang sort!(arr);

    int sort(int arr[]);
    - - - - +
    %bang sort(int arr[]);
     
    +int sort(int arr[]); 
    - - - -

    This method would be invoked from Ruby code like this:

    - - - -
    irb(main):001:0> Example::sort!(arr)
    - - - - -
    - - - -

    The %bang directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.4.4 Getters and Setters

    Often times a C++ library will expose properties through getter and setter methods. For example:

    - - - -
    -
    class Foo {
    Foo() {}

    int getValue() { return value_; }

    void setValue(int value) { value_ = value; }

    private:
    int value_;
    };
    - - - - +
    class Foo {
    +  Foo() {}
    +  int getValue() { return value_; }
    +  void setValue(int value) { value_ = value; }
     
    +private:
    +  int value_;
    +};
    - - - -

    By default, SWIG will expose these methods to Ruby as get_value and set_value. However, it more natural for these methods to be exposed in Ruby as value and value=. That allows the methods to be used like this:

    - - - -
    -
    irb(main):001:0> foo = Foo.new()
    irb(main):002:0> foo.value = 5
    irb(main):003:0> puts foo.value
    - - - - - +
    irb(main):001:0> foo = Foo.new()
    +irb(main):002:0> foo.value = 5
    +irb(main):003:0> puts foo.value
    - - - -

    This can be done by using the %rename directive:

    - - - -
    -
    %rename("value") Foo::getValue();
    %rename("value=") Foo::setValue(int value);
    - - - - - +
    %rename("value") Foo::getValue();
    +%rename("value=") Foo::setValue(int value);
    - - - - -

     

    - - - - -

    36.5 Input and output parameters

    A common problem in some C programs is handling parameters passed as simple pointers. For example:

    - - - -
    -
    void add(int x, int y, int *result) {
    *result = x + y;
    }
    or
    int sub(int *x, int *y) {
    return *x-*y;
    }
    - - - - - +
    void add(int x, int y, int *result) {
    +  *result = x + y;
    +}
    +

    +or +

    - - +
    +
    +int sub(int *x, int *y) {
    +  return *x-*y;
    +}
    +

    The easiest way to handle these situations is to use the typemaps.i file. For example:

    - - - -
    -
    %module Example
    %include "typemaps.i"

    void add(int, int, int *OUTPUT);
    int sub(int *INPUT, int *INPUT);
    - - - - +
    %module Example
    +%include "typemaps.i"
     
    +void add(int, int, int *OUTPUT);
    +int sub(int *INPUT, int *INPUT);
    - - - -

    In Ruby, this allows you to pass simple values. For example:

    - - - -
    -
    a = Example.add(3,4)
    puts a
    7
    b = Example.sub(7,4)
    puts b
    3
    - - - - - +
    a = Example.add(3,4)
    +puts a
    +7
    +b = Example.sub(7,4)
    +puts b
    +3
    - - - -

    Notice how the INPUT parameters allow integer values to be passed instead of pointers and how the OUTPUT parameter creates a return result.

    - - - -

    If you don't want to use the names INPUT or OUTPUT, use the %apply directive. For example:

    - - - -
    -
    %module Example
    %include "typemaps.i"

    %apply int *OUTPUT { int *result };
    %apply int *INPUT { int *x, int *y};

    void add(int x, int y, int *result);
    int sub(int *x, int *y);
    - - - +
    %module Example
    +%include "typemaps.i"
     
    +%apply int *OUTPUT { int *result };
    +%apply int *INPUT { int *x, int *y};
     
    +void add(int x, int y, int *result);
    +int sub(int *x, int *y);
    - - - -

    If a function mutates one of its parameters like this,

    - - - -
    -
    void negate(int *x) {
    *x = -(*x);
    }
    - - - - - +
    void negate(int *x) {
    + *x = -(*x);
    +}
    - - - -

    you can use INOUT like this:

    - - - -
    -
    %include "typemaps.i"
    ...
    void negate(int *INOUT);
    - - - - - +
    %include "typemaps.i"
    +...
    +void negate(int *INOUT);
    - - - -

    In Ruby, a mutated parameter shows up as a return value. For example:

    - - - -
    -
    a = Example.negate(3)
    print a
    -3

    - - - - - +
    a = Example.negate(3)
    +print a
    +-3
    - - - -

    The most common use of these special typemap rules is to handle functions that return more than one value. For example, sometimes a function returns a result as well as a special error code:

    - - - -
    -
    /* send message, return number of bytes sent, success code, and error_code */
    int send_message(char *text, int *success, int *error_code);
    - - - - - +
    /* send message, return number of bytes sent, success code, and error_code */
    +int send_message(char *text, int *success, int *error_code);
    - - - -

    To wrap such a function, simply use the OUTPUT rule above. For example:

    - - - -
    -
    %module example
    %include "typemaps.i"
    ...
    int send_message(char *, int *OUTPUT, int *OUTPUT);
    - - - - - +
    %module example
    +%include "typemaps.i"
    +...
    +int send_message(char *, int *OUTPUT, int *OUTPUT);
    - - - -

    When used in Ruby, the function will return an array of multiple values.

    - - - -
    -
    bytes, success, error_code = send_message("Hello World")
    if not success
    print "error #{error_code} : in send_message"
    else
    print "Sent", bytes
    end
    - - - - - +
    bytes, success, error_code = send_message("Hello World")
    +if not success
    +  print "error #{error_code} : in send_message"
    +else
    +  print "Sent", bytes
    +end
    - - - -

    Another way to access multiple return values is to use the %apply rule. In the following example, the parameters rows and columns are related to SWIG as OUTPUT values through the use of %apply

    - - - -
    -
    %module Example
    %include "typemaps.i"
    %apply int *OUTPUT { int *rows, int *columns };
    ...
    void get_dimensions(Matrix *m, int *rows, int*columns);
    - - - - - +
    %module Example
    +%include "typemaps.i"
    +%apply int *OUTPUT { int *rows, int *columns };
    +...
    +void get_dimensions(Matrix *m, int *rows, int*columns);
    - - - -

    In Ruby:

    - - - -
    -
    r, c = Example.get_dimensions(m)
    - - - - - +
    r, c = Example.get_dimensions(m)
    - - - -

    36.6 Exception handling

    @@ -3588,1013 +1916,317 @@ C/C++ errors into Ruby exceptions. The chapter on -
    class DoubleArray {
    private:
    int n;
    double *ptr;
    public:
    // Create a new array of fixed size
    DoubleArray(int size) {
    ptr = new double[size];
    n = size;
    }

    // Destroy an array
    ~DoubleArray() {
    delete ptr;
    }

    // Return the length of the array
    int length() {
    return n;
    }

    // Get an array item and perform bounds checking.
    double getitem(int i) {
    if ((i >= 0) && (i < n))
    return ptr[i];
    else
    throw RangeError();
    }

    // Set an array item and perform bounds checking.
    void setitem(int i, double val) {
    if ((i >= 0) && (i < n))
    ptr[i] = val;
    else {
    throw RangeError();
    }
    }
    };
    - - - - - +
    class DoubleArray {
    +private:
    +  int n;
    +  double *ptr;
    +public:
    +  // Create a new array of fixed size
    +  DoubleArray(int size) {
    +    ptr = new double[size];
    +    n = size;
    +  }
    + 
    +  // Destroy an array
    +  ~DoubleArray() {
    +    delete ptr;
    +  } 
    + 
    +  // Return the length of the array
    +  int length() {
    +    return n;
    +  }
    + 
    +  // Get an array item and perform bounds checking.
    +  double getitem(int i) {
    +    if ((i >= 0) && (i < n))
    +      return ptr[i];
    +    else
    +      throw RangeError();
    +  }
    + 
    +  // Set an array item and perform bounds checking.
    +  void setitem(int i, double val) {
    +    if ((i >= 0) && (i < n))
    +      ptr[i] = val;
    +    else {
    +      throw RangeError();
    +    }
    +  }
    +};
    - - - -

    Since several methods in this class can throw an exception for an out-of-bounds access, you might want to catch this in the Ruby extension by writing the following in an interface file:

    - - - -
    -
    %exception {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error.");
    }
    }

    class DoubleArray {
    ...
    };
    - - - - +
    %exception {
    +  try {
    +    $action
    +  }
    +  catch (const RangeError&) {
    +    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    +    rb_raise(cpperror, "Range error.");
    +  }
    +}
     
    +class DoubleArray {
    +  ...
    +};
    - - - -

    The exception handling code is inserted directly into generated wrapper functions. When an exception handler is defined, errors can be caught and used to gracefully raise a Ruby exception instead of forcing the entire program to terminate with an uncaught error.

    - - - -

    As shown, the exception handling code will be added to every wrapper function. Because this is somewhat inefficient, you might consider refining the exception handler to only apply to specific methods like this:

    - - - -
    -
    %exception getitem {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in getitem.");
    }
    }

    %exception setitem {
    try {
    $action
    }
    catch (const RangeError&) {
    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    rb_raise(cpperror, "Range error in setitem.");
    }
    }
    - - - - - +
    %exception getitem {
    +  try {
    +    $action
    +  } catch (const RangeError&) {
    +    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    +    rb_raise(cpperror, "Range error in getitem.");
    +  }
    +}
    + 
    +%exception setitem {
    +  try {
    +    $action
    +  } catch (const RangeError&) {
    +    static VALUE cpperror = rb_define_class("CPPError", rb_eStandardError);
    +    rb_raise(cpperror, "Range error in setitem.");
    +  }
    +}
    - - - -

    In this case, the exception handler is only attached to methods and functions named getitem and setitem.

    - - - -

    Since SWIG's exception handling is user-definable, you are not limited to C++ exception handling. See the chapter on Customization Features for more examples.

    - - - -

    36.6.2 Handling Ruby Blocks

    One of the highlights of Ruby and most of its standard library is the use of blocks, which allow the easy creation of continuations and -other niceties.  Blocks in ruby are also often used to +other niceties. Blocks in ruby are also often used to simplify the passing of many arguments to a class.

    - - - -

    In order to make your class constructor support blocks, you can take advantage of the %exception directive, which will get run -after the C++ class' constructor was called. 

    - - - - +after the C++ class' constructor was called.

    For example, this yields the class over after its construction: -
    - - - - -

    - - - -
    -
    class Window
    {
    public:
    Window(int x, int y, int w, int h);
    // .... other methods here ....
    };

    // Add support for yielding self in the Class' constructor.
    %exception Window::Window {
    $action
    if (rb_block_given_p()) {
    rb_yield(self);
    }
    }
    - - - - +
    class Window
    +{
    +public:
    +  Window(int x, int y, int w, int h);
    +  // .... other methods here ....
    +};
     
    +// Add support for yielding self in the Class' constructor.
    +%exception Window::Window {
    +  $action
    +  if (rb_block_given_p()) {
    +    rb_yield(self);
    +  }
    +}
    - - - -

    Then, in ruby, it can be used like:

    - - - - -
    Window.new(0,0,360,480) -{ |w|
    - - - - - -    w.color = Fltk::RED
    - - - - - -    w.border = false
    - - - - - -}
    - - - - - -
    - - - - +
    +Window.new(0,0,360,480) { |w|
    +  w.color = Fltk::RED
    +  w.border = false
    +}
    +
    +

    For other methods, you can usually use a dummy parameter with a special in typemap, like:

    - - - - -
    //
    - - - - - -// original function was:
    - - - - - -//
    - - - - - -// void func(int x);
    - - - - - -
    - - - - - -%typemap(in,numinputs=0) int RUBY_YIELD_SELF {
    - - - - - -     if ( !rb_block_given_p() )
    - - - - - -            -rb_raise("No block given");
    - - - - - -     return rb_yield(self);
    - - - - - -}
    - - - - - -
    - - - - - -%extend {
    - - - - - -        void func(int x, int -RUBY_YIELD_SELF );
    - - - - - -}
    - - - - +
    +//
    +// original function was:
    +//
    +// void func(int x);
    +
    +%typemap(in,numinputs=0) int RUBY_YIELD_SELF {
    +  if ( !rb_block_given_p() )
    +    rb_raise("No block given");
    +  return rb_yield(self);
    +}
    +
    +%extend {
    +  void func(int x, int RUBY_YIELD_SELF );
    +}
    +
    +

    For more information on typemaps, see Typemaps.

    -

    36.6.3 Raising exceptions

    There are three ways to raise exceptions from C++ code to Ruby.

    - - - -

    The first way is to use SWIG_exception(int code, const char *msg). The following table shows the mappings from SWIG error codes to Ruby exceptions:

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
    - - - - +
    SWIG_MemoryError
    - - - - -
    - - - - +
    rb_eNoMemError
    - - - - -
    - - - - +
    SWIG_IOError
    - - - - -
    - - - - +
    rb_eIOError
    - - - - -
    - - - - +
    SWIG_RuntimeError
    - - - - -
    - - - - +
    rb_eRuntimeError
    - - - - -
    - - - - +
    SWIG_IndexError
    - - - - -
    - - - - +
    rb_eIndexError
    - - - - -
    - - - - +
    SWIG_TypeError
    - - - - -
    - - - - +
    rb_eTypeError
    - - - - -
    - - - - +
    SWIG_DivisionByZero
    - - - - -
    - - - - +
    rb_eZeroDivError
    - - - - -
    - - - - +
    SWIG_OverflowError
    - - - - -
    - - - - +
    rb_eRangeError
    - - - - -
    - - - - +
    SWIG_SyntaxError
    - - - - -
    - - - - +
    rb_eSyntaxError
    - - - - -
    - - - - +
    SWIG_ValueError
    - - - - -
    - - - - +
    rb_eArgError
    - - - - -
    - - - - +
    SWIG_SystemError
    - - - - -
    - - - - +
    rb_eFatal
    - - - - -
    - - - - +
    SWIG_AttributeError
    - - - - -
    - - - - +
    rb_eRuntimeError
    - - - - -
    - - - - +
    SWIG_NullReferenceError
    - - - - -
    - - - - +
    rb_eNullReferenceError*
    - - - - -
    - - - - +
    SWIG_ObjectPreviouslyDeletedError
    - - - - -
    - - - - +
    rb_eObjectPreviouslyDeleted*
    - - - - -
    - - - - +
    SWIG_UnknownError
    - - - - -
    - - - - +
    rb_eRuntimeError
    - - - - -
    - - - -
    * These error classes are created by SWIG and are not built-in Ruby exception classes
    - - - - -
    - - - - -
    - - - -

    The second way to raise errors is to use SWIG_Raise(obj, type, desc). Obj is a C++ instance of an exception class, type is a string specifying the type of exception (for example, "MyError") and desc is the SWIG description of the exception class. For example:

    - - - - -
    -%raise(SWIG_NewPointerObj(e, -SWIGTYPE_p_AssertionFailedException, -0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);
    - - - - +
    +%raise(SWIG_NewPointerObj(e, SWIGTYPE_p_AssertionFailedException, 0), ":AssertionFailedException", SWIGTYPE_p_AssertionFailedException);
    +

    This is useful when you want to pass the current exception object @@ -4602,20 +2234,12 @@ directly to Ruby, particularly when the object is an instance of class marked as an %exceptionclass (see the next section for more information).

    - - - -

    Last, you can raise an exception by directly calling Ruby's C api. This is done by invoking the rb_raise() function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

    - - - -

    36.6.4 Exception classes

    @@ -4626,54 +2250,33 @@ directive are exposed in Ruby as child classes of rb_eRuntimeError. This allows C++ exceptions to be directly mapped to Ruby exceptions, providing for a more natural integration between C++ code and Ruby code.

    - - - -
    -
    	%exceptionclass CustomError;

    %inline %{
    class CustomError { };

    class Foo {
    public:
    void test() { throw CustomError; }
    };
    }
    - - - +
    %exceptionclass CustomError;
     
    +%inline %{
    +  class CustomError { };
     
    +  class Foo { 
    +  public:
    +    void test() { throw CustomError; }
    +  };
    +%}
    - - - -

    From Ruby you can now call this method like this:

    - - - -
    -
    foo = Foo.new
    begin
    foo.test()
    rescue CustomError => e
    puts "Caught custom error"
    end
    - - - - - +
    foo = Foo.new
    +begin
    +  foo.test()
    +rescue CustomError => e
    +  puts "Caught custom error"
    +end 
    - - - - -

    For another example look at swig/Examples/ruby/exception_class.
    - - - - - +

    For another example look at swig/Examples/ruby/exception_class.

    - - - -

    36.7 Typemaps

    @@ -4681,130 +2284,81 @@ providing for a more natural integration between C++ code and Ruby code.

    wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Ruby C API as well as the material in the "Typemaps" -chapter.  +chapter.

    - - - -

    Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the primitive C-Ruby interface.

    - - - -

    36.7.1 What is a typemap?

    A typemap is nothing more than a code generation rule that is attached to a specific C datatype. The general form of this declaration is as follows ( parts enclosed in [...] are optional -):    

    - - - - - -
    %typemap( method [, modifiers...] ) typelist -code;
    - - - +):

    +
    +
    +%typemap( method [, modifiers...] ) typelist code;
    +
    +

    method is a simply a name that specifies what kind of typemap is being defined. It is usually a name like "in", "out", or "argout" (or its director variations). The purpose of these methods is described later.

    - - - -

    modifiers is an optional comma separated list of name="value" values. These are sometimes to attach extra information to a typemap and is often target-language dependent.

    - - - -

    typelist is a list of the C++ type patterns that the typemap will match. The general form of this list is as follows:

    - - - -
    -
    typelist : typepattern [, typepattern, typepattern, ... ] ;

    typepattern : type [ (parms) ]
    | type name [ (parms) ]
    | ( typelist ) [ (parms) ]
    - - - - +
    typelist : typepattern [, typepattern, typepattern, ... ] ;
     
    +typepattern : type [ (parms) ]
    +  | type name [ (parms) ]
    +  | ( typelist ) [ (parms) ]
    - - - -

    Each type pattern is either a simple type, a simple type and argument name, or a list of types in the case of multi-argument typemaps. In addition, each type pattern can be parameterized with a list of temporary variables (parms). The purpose of these variables will be explained shortly.

    - - - -

    code specifies the C code used in the typemap. It can take any one of the following forms:

    - - - -
    -
    code : { ... }
    | " ... "
    | %{ ... %}
    - - - - - +
    code : { ... }
    +  | " ... "
    +  | %{ ... %}
    - - - -

    For example, to convert integers from Ruby to C, you might define a typemap like this:

    - - - -
    -
    %module example

    %typemap(in) int {
    $1 = (int) NUM2INT($input);
    printf("Received an integer : %d\n",$1);
    }

    %inline %{
    extern int fact(int n);
    %}
    - - - +
    %module example
     
    +%typemap(in) int {
    +  $1 = (int) NUM2INT($input);
    +  printf("Received an integer : %d\n",$1);
    +}
     
    +%inline %{
    +  extern int fact(int n);
    +%}
    - - - -

    Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is @@ -4814,77 +2368,44 @@ prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input variable is the input Ruby object.

    - - - -

    When this example is compiled into a Ruby module, the following sample code:

    - - - -
    -
    require 'example'

    puts Example.fact(6)
    - - - - +
    require 'example'
     
    +puts Example.fact(6)
    - - - -

    prints the result:

    - - - -
    -
    Received an integer : 6
    720
    - - - - - +
    +Received an integer : 6
    +720
    +
    - - - -

    In this example, the typemap is applied to all occurrences of the int datatype. You can refine this by supplying an optional parameter name. For example:

    - - - -
    -
    %module example

    %typemap(in) int n {
    $1 = (int) NUM2INT($input);
    printf("n = %d\n",$1);
    }

    %inline %{
    extern int fact(int n);
    %}
    - - - +
    %module example
     
    +%typemap(in) int n {
    +  $1 = (int) NUM2INT($input);
    +  printf("n = %d\n",$1);
    +}
     
    +%inline %{
    +  extern int fact(int n);
    +%}
    - - - -

    In this case, the typemap code is only attached to arguments that exactly match "int n".

    - - - -

    The application of a typemap to specific datatypes and argument names involves more than simple text-matching--typemaps are fully integrated into the SWIG type-system. When you define a typemap @@ -4893,72 +2414,41 @@ and qualified variations such as const int. In addition, the typemap system follows typedef declarations. For example:

    - - - -
    -
    %typemap(in) int n {
    $1 = (int) NUM2INT($input);
    printf("n = %d\n",$1);
    }

    typedef int Integer;
    extern int fact(Integer n); // Above typemap is applied
    - - - - +
    %typemap(in) int n {
    +  $1 = (int) NUM2INT($input);
    +  printf("n = %d\n",$1);
    +}
     
    +typedef int Integer;
    +extern int fact(Integer n); // Above typemap is applied
    - - - -

    However, the matching of typedef only occurs in one direction. If you defined a typemap for Integer, it is not applied to arguments of type int.

    - - - -

    Typemaps can also be defined for groups of consecutive arguments. For example:

    - - - -
    -
    %typemap(in) (char *str, int len) {
    $1 = StringValuePtr($input);
    $2 = (int) RSTRING($input)->len;
    };

    int count(char c, char *str, int len);
    - - - - +
    %typemap(in) (char *str, int len) {
    +  $1 = StringValuePtr($input);
    +  $2 = (int) RSTRING($input)->len;
    +};
     
    +int count(char c, char *str, int len);
    - - - -

    When a multi-argument typemap is defined, the arguments are always handled as a single Ruby object. This allows the function count to be used as follows (notice how the length parameter is omitted):

    - - - -
    -
    puts Example.count('o','Hello World')
    2
    - - - - - +
    puts Example.count('o','Hello World')
    +2
    - - - -

    36.7.2 Typemap scope

    @@ -4966,23 +2456,23 @@ to be used as follows (notice how the length parameter is omitted):

    declarations that follow. A typemap may be redefined for different sections of an input file. For example:

    - - - -
    -
    // typemap1
    %typemap(in) int {
    ...
    }

    int fact(int); // typemap1
    int gcd(int x, int y); // typemap1

    // typemap2
    %typemap(in) int {
    ...
    }

    int isprime(int); // typemap2
    - - +
    // typemap1
    +%typemap(in) int {
    +  ...
    +}
     
    +int fact(int); // typemap1
    +int gcd(int x, int y); // typemap1
     
    +// typemap2
    +%typemap(in) int {
    +  ...
    +}
     
    +int isprime(int); // typemap2
    - - - -

    One exception to the typemap scoping rules pertains to the %extend declaration. %extend is used to attach new declarations to a class or structure definition. Because @@ -4990,250 +2480,152 @@ of this, all of the declarations in an %extend block are subject to the typemap rules that are in effect at the point where the class itself is defined. For example:

    - - - -
    -
    class Foo {
    ...
    };

    %typemap(in) int {
    ...
    }

    %extend Foo {
    int blah(int x); // typemap has no effect. Declaration is attached to Foo which
    // appears before the %typemap declaration.
    };
    - - - +
    class Foo {
    +  ...
    +};
     
    +%typemap(in) int {
    +  ...
    +}
     
    +%extend Foo {
    +  int blah(int x); // typemap has no effect. Declaration is attached to Foo which 
    +  // appears before the %typemap declaration.
    +};
    - - - -

    36.7.3 Copying a typemap

    A typemap is copied by using assignment. For example:

    - - - -
    -
    %typemap(in) Integer = int;
    - - - - - +
    %typemap(in) Integer = int;
    - - - -

    or this:

    - - - -
    -
    %typemap(in) Integer, Number, int32_t = int;
    - - - - - +
    %typemap(in) Integer, Number, int32_t = int;
    - - - -

    Types are often managed by a collection of different typemaps. For example:

    - - - -
    -
    %typemap(in) int { ... }
    %typemap(out) int { ... }
    %typemap(varin) int { ... }
    %typemap(varout) int { ... }
    - - - - - +
    %typemap(in) int { ... }
    +%typemap(out) int { ... }
    +%typemap(varin) int { ... }
    +%typemap(varout) int { ... }
    - - - -

    To copy all of these typemaps to a new type, use %apply. For example:

    - - - -
    -
    %apply int { Integer }; // Copy all int typemaps to Integer
    %apply int { Integer, Number }; // Copy all int typemaps to both Integer and Number
    - - - - - +
    %apply int { Integer }; // Copy all int typemaps to Integer
    +%apply int { Integer, Number }; // Copy all int typemaps to both Integer and Number
    - - - -

    The patterns for %apply follow the same rules as for %typemap. For example:

    - - - -
    -
    %apply int *output { Integer *output }; // Typemap with name
    %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments
    - - - - - +
    %apply int *output { Integer *output }; // Typemap with name
    +%apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments
    - - - -

    36.7.4 Deleting a typemap

    A typemap can be deleted by simply defining no code. For example:

    - - - -
    -
    %typemap(in) int; // Clears typemap for int
    %typemap(in) int, long, short; // Clears typemap for int, long, short
    %typemap(in) int *output;
    - - - - - +
    %typemap(in) int; // Clears typemap for int
    +%typemap(in) int, long, short; // Clears typemap for int, long, short
    +%typemap(in) int *output; 
    - - - -

    The %clear directive clears all typemaps for a given type. For example:

    - - - -
    -
    %clear int; // Removes all types for int
    %clear int *output, long *output;
    - - - - - +
    %clear int; // Removes all types for int
    +%clear int *output, long *output;
    - - - -

    Note: Since SWIG's default behavior is defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

    - - - -

    36.7.5 Placement of typemaps

    Typemap declarations can be declared in the global scope, within a C++ namespace, and within a C++ class. For example:

    - - - -
    -
    %typemap(in) int {
    ...
    }

    namespace std {
    class string;
    %typemap(in) string {
    ...
    }
    }

    class Bar {
    public:
    typedef const int & const_reference;
    %typemap(out) const_reference {
    ...
    }
    };
    - - - +
    %typemap(in) int {
    +  ...
    +}
     
    +namespace std {
    +  class string;
    +  %typemap(in) string {
    +    ...
    +  }
    +}
     
    +class Bar {
    +public:
    +  typedef const int & const_reference;
    +  %typemap(out) const_reference {
    +    ...
    +  }
    +};
    - - - -

    When a typemap appears inside a namespace or class, it stays in effect until the end of the SWIG input (just like before). However, the typemap takes the local scope into account. Therefore, this code

    - - - -
    -
    namespace std {
    class string;
    %typemap(in) string {
    ...
    }
    }
    - - - - - +
    namespace std {
    +  class string;
    +  %typemap(in) string {
    +    ...
    +  }
    +}
    - - - -

    is really defining a typemap for the type std::string. You could have code like this:

    - - - -
    -
    namespace std {
    class string;
    %typemap(in) string { /* std::string */
    ...
    }
    }

    namespace Foo {
    class string;
    %typemap(in) string { /* Foo::string */
    ...
    }
    }
    - - - - +
    namespace std {
    +  class string;
    +  %typemap(in) string { /* std::string */
    +  ...
    +  }
    +}
     
    +namespace Foo {
    +  class string;
    +  %typemap(in) string { /* Foo::string */
    +  ...
    +  }
    +}
    - - - -

    In this case, there are two completely distinct typemaps that apply to two completely different types (std::string and Foo::string).

    - - - -

    It should be noted that for scoping to work, SWIG has to know that string is a typename defined within a particular namespace. @@ -5241,263 +2633,79 @@ In this example, this is done using the class declaration class string .

    - - - -

    36.7.6 Ruby typemaps

    The following list details all of the typemap methods that can be used by the Ruby module:

    - - - - -

    36.7.6.1  "in" typemap

    +

    36.7.6.1 "in" typemap

    Converts Ruby objects to input function arguments. For example:

    - - - -
    -
    %typemap(in) int {
    $1 = NUM2INT($input);
    }
    - - - - - +
    %typemap(in) int {
    +  $1 = NUM2INT($input);
    +}
    - - - -

    The following special variables are available:

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
    $input Input object + $input Input object holding value to be converted.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being sent to the function
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    - - - - -
    - - - -

    This is probably the most commonly redefined typemap because it can be used to implement customized conversions.

    - - - -

    In addition, the "in" typemap allows the number of converted arguments to be specified. For example:

    - - - -
    -
    // Ignored argument.
    %typemap(in, numinputs=0) int *out (int temp) {
    $1 = &temp;
    }
    - - - - - +
    // Ignored argument.
    +%typemap(in, numinputs=0) int *out (int temp) {
    +  $1 = &temp;
    +}
    - - - -

    At this time, only zero or one arguments may be converted.

    - - - -

    36.7.6.2 "typecheck" typemap

    @@ -5505,272 +2713,72 @@ arguments to be specified. For example:

    functions and methods. It merely checks an argument to see whether or not it matches a specific type. For example:

    - - - -
    -
    %typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
    $1 = FIXNUM_P($input) ? 1 : 0;
    }
    - - - - - +
    %typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) int {
    +  $1 = FIXNUM_P($input) ? 1 : 0;
    +}
    - - - -

    For typechecking, the $1 variable is always a simple integer that is set to 1 or 0 depending on whether or not the input argument is the correct type.

    - - - -

    If you define new "in" typemaps and your program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

    - - - - -

    36.7.6.3  "out" typemap

    +

    36.7.6.3 "out" typemap

    Converts return value of a C function to a Ruby object.

    - - - - -

    - - - - - -%typemap(out) int {
    - - - - - -   $result = INT2NUM( $1 );
    - - - - - -}
    - - - - - -
    - - - - +
    +
    %typemap(out) int {
    +  $result = INT2NUM( $1 );
    +}
    +

    The following special variables are available.

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
    $result Result object + $result Result object returned to target language.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being wrapped
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    - - - - -
    - - - - -
    - - - - -

    36.7.6.4 "arginit" typemap

    @@ -5779,65 +2787,38 @@ function argument--before any conversion has occurred. This is not normally necessary, but might be useful in highly specialized applications. For example:

    - - - -
    -
    // Set argument to NULL before any conversion occurs
    %typemap(arginit) int *data {
    $1 = NULL;
    }
    - - - - - +
    // Set argument to NULL before any conversion occurs
    +%typemap(arginit) int *data {
    +  $1 = NULL;
    +}
    - - - -

    36.7.6.5 "default" typemap

    The "default" typemap is used to turn an argument into a default argument. For example:

    - - - -
    -
    %typemap(default) int flags {
    $1 = DEFAULT_FLAGS;
    }
    ...
    int foo(int x, int y, int flags);
    - - - - - +
    %typemap(default) int flags {
    +  $1 = DEFAULT_FLAGS;
    +}
    +...
    +int foo(int x, int y, int flags);
    - - - -

    The primary use of this typemap is to either change the wrapping of default arguments or specify a default argument in a language where they aren't supported (like C). Target languages that do not support optional arguments, such as Java and C#, effectively ignore the value specified by this typemap as all arguments must be given.

    - - - -

    Once a default typemap has been applied to an argument, all arguments that follow must have default values. See the Default/optional arguments section for further information on default argument wrapping.

    - - - -

    36.7.6.6 "check" typemap

    @@ -5845,23 +2826,14 @@ default argument wrapping.

    during argument conversion. The typemap is applied after arguments have been converted. For example:

    - - - -
    -
    %typemap(check) int positive {
    if ($1 <= 0) {
    SWIG_exception(SWIG_ValueError,"Expected positive value.");
    }
    }
    - - - - - +
    %typemap(check) int positive {
    +  if ($1 <= 0) {
    +    SWIG_exception(SWIG_ValueError,"Expected positive value.");
    +  }
    +}
    - - - -

    36.7.6.7 "argout" typemap

    @@ -5871,155 +2843,51 @@ need to return multiple values. The "argout" typemap is almost always combined with an "in" typemap---possibly to ignore the input value. For example:

    - - - -
    -
    /* Set the input argument to point to a temporary variable */
    %typemap(in, numinputs=0) int *out (int temp) {
    $1 = &temp;
    }

    %typemap(argout, fragment="output_helper") int *out {
    // Append output value $1 to $result (assuming a single integer in this case)
    $result = output_helper( $result, INT2NUM(*$1) );
    }
    - - - - +
    /* Set the input argument to point to a temporary variable */
    +%typemap(in, numinputs=0) int *out (int temp) {
    +  $1 = &temp;
    +}
     
    +%typemap(argout, fragment="output_helper") int *out {
    +  // Append output value $1 to $result (assuming a single integer in this case)
    +  $result = output_helper( $result, INT2NUM(*$1) );
    +}
    - - - -

    The following special variables are available.

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
    $result Result object + $result Result object returned to target language.
    $input The original + $input The original input object passed.
    $symname Name of + $symname Name of function/method being wrapped.
    - - - - -
    - - - -

    The code supplied to the "argout" typemap is always placed after the "out" typemap. If multiple return values are used, the extra return values are often appended to return value of the function.

    - - - -

    Output helper is a fragment that usually defines a macro to some function like SWIG_Ruby_AppendOutput.

    - - - -

    See the typemaps.i library for examples.

    - - - -

    36.7.6.8 "freearg" typemap

    @@ -6029,33 +2897,24 @@ be cleaned up when the wrapper function exits. The "freearg" typemap usually cleans up argument resources allocated by the "in" typemap. For example:

    - - - -
    -
    // Get a list of integers
    %typemap(in) int *items {
    int nitems = Length($input);
    $1 = (int *) malloc(sizeof(int)*nitems);
    }
    // Free the list
    %typemap(freearg) int *items {
    free($1);
    }
    - - - - - +
    // Get a list of integers
    +%typemap(in) int *items {
    +  int nitems = Length($input); 
    +  $1 = (int *) malloc(sizeof(int)*nitems);
    +}
    +// Free the list 
    +%typemap(freearg) int *items {
    +  free($1);
    +}
    - - - -

    The "freearg" typemap inserted at the end of the wrapper function, just before control is returned back to the target language. This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

    - - - -

    36.7.6.9 "newfree" typemap

    @@ -6063,30 +2922,23 @@ abort prematurely.

    directive and is used to deallocate memory used by the return result of a function. For example:

    - - - -
    -
    %typemap(newfree) string * {
    delete $1;
    }
    %typemap(out) string * {
    $result = PyString_FromString($1->c_str());
    }
    ...

    %newobject foo;
    ...
    string *foo();
    - - - - +
    %typemap(newfree) string * {
    +  delete $1;
    +}
    +%typemap(out) string * {
    +  $result = PyString_FromString($1->c_str());
    +}
    +...
     
    +%newobject foo;
    +...
    +string *foo();
    - - - -

    See Object ownership and %newobject for further details.

    - - - -

    36.7.6.10 "memberin" typemap

    @@ -6095,31 +2947,16 @@ already converted input value into a structure member. It is typically used to handle array members and other special cases. For example:

    - - - -
    -
    %typemap(memberin) int [4] {
    memmove($1, $input, 4*sizeof(int));
    }
    - - - - - +
    %typemap(memberin) int [4] {
    +  memmove($1, $input, 4*sizeof(int));
    +}
    - - - -

    It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

    - - - -

    36.7.6.11 "varin" typemap

    @@ -6127,10 +2964,6 @@ other objects.

    language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

    - - - -

    36.7.6.12 "varout" typemap

    @@ -6138,10 +2971,6 @@ This is implementation specific.

    object in the target language when reading a C/C++ global variable. This is implementation specific.

    - - - -

    36.7.6.13 "throws" typemap

    @@ -6154,735 +2983,237 @@ or exception in the target language. It is slightly different to the other typemaps as it is based around the exception type rather than the type of a parameter or variable. For example:

    - - - -
    -
    %typemap(throws) const char * %{
    rb_raise(rb_eRuntimeError, $1);
    SWIG_fail;
    %}
    void bar() throw (const char *);
    - - - - - +
    %typemap(throws) const char * %{
    +  rb_raise(rb_eRuntimeError, $1);
    +  SWIG_fail;
    +%}
    +void bar() throw (const char *);
    - - - -

    As can be seen from the generated code below, SWIG generates an exception handler with the catch block comprising the "throws" typemap content.

    - - - -
    -
    ...
    try {
    bar();
    }
    catch(char const *_e) {
    rb_raise(rb_eRuntimeError, _e);
    SWIG_fail;
    }
    ...
    - - - - - +
    ...
    +try {
    +  bar();
    +}
    +catch(char const *_e) {
    +  rb_raise(rb_eRuntimeError, _e);
    +  SWIG_fail;
    +}
    +...
    - - - -

    Note that if your methods do not have an exception specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

    - - - -

    36.7.6.14 directorin typemap

    Converts C++ objects in director -member functions to ruby objects. It is roughly the opposite +member functions to ruby objects. It is roughly the opposite of the "in" typemap, making its typemap rule often similar to the "out" typemap.

    - - - - -

    - - - - - -%typemap(directorin) int {
    - - - - - -     $result = INT2NUM($1);
    - - - - - -}
    - - - - - -
    - - - - +
    +%typemap(directorin) int {
    +  $result = INT2NUM($1);
    +}
    +

    The following special variables are available.

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
    $result Result object + $result Result object returned to target language.
    $symname Name of + $symname Name of function/method being wrapped
    $1...n Argument being + $1...n Argument being wrapped
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, + this C++ this, referring to the class itself.
    - - - - -
    - - - -

    36.7.6.15 directorout typemap

    Converts Ruby objects in director -member functions to C++ objects.  It is roughly the opposite +member functions to C++ objects. It is roughly the opposite of the "out" typemap, making its rule often similar to the "in" typemap.

    - - - - -

    - - - - - -%typemap(directorout) int {

    - - - - - -   $result = NUM2INT($1);

    - - - - - -}
    - - - - - -
    - - - - +
    +%typemap(directorout) int {
    +  $result = NUM2INT($1);
    +}
    +
    +

    The following special variables are available:

    - - - -
    - - - - - - - - - - - - + + - - + + - - + + - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
    $inputRuby object being sent to the function$inputRuby object being sent to the function
    $symname Name of function/method being wrapped$symname Name of function/method being wrapped
    $1...n Argument being sent to the function$1...n Argument being sent to the function
    $1_name Name of the + $1_name Name of the argument (if provided)
    $1_type The actual C + $1_type The actual C datatype matched by the typemap.
    $1_ltype The assignable + $1_ltype The assignable version of the C datatype matched by the typemap.
    this C++ this, + this C++ this, referring to the class itself.
    - - - - -
    - - - -

    Currently, the directorout nor the out typemap support the -option numoutputs, +option numoutputs, but the Ruby module provides that functionality through a %feature -directive.  Thus, a function can be made to return "nothing" +directive. Thus, a function can be made to return "nothing" if you do:

    - - - - -
    %feature("numoutputs","0") -MyClass::function;
    - - - - +
    +%feature("numoutputs","0") MyClass::function;
    +

    This feature can be useful if a function returns a status code, which you want to discard but still use the typemap to raise an -exception.
    - - - - +exception.

    - - - -

    36.7.6.16 directorargout typemap

    Output argument processing in director member functions.

    - - - - -
    %typemap(directorargout, -fragment="output_helper") int {
    - - - - - -$result = output_helper( $result, NUM2INT($1) );

    - - - - - -}
    - - - - +
    +%typemap(directorargout,
    +fragment="output_helper") int {
    +  $result = output_helper( $result, NUM2INT($1) );
    +}
    +

    The following special variables are available:

    - - - -
    - - - - - - - - - - - - + + - - + + - - + + - - + + - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
    $resultResult that the director function returns$resultResult that the director function returns
    $inputRuby object being sent to the function$inputRuby object being sent to the function
    $symnamename of the function/method being wrapped$symnamename of the function/method being wrapped
    $1...nArgument being sent to the function$1...nArgument being sent to the function
    $1_nameName of the + $1_nameName of the argument (if provided)
    $1_typeThe actual C + $1_typeThe actual C datatype matched by the typemap
    $1_ltypeThe assignable + $1_ltypeThe assignable version of the C datatype matched by the typemap
    thisC++ this, + thisC++ this, referring to the instance of the class itself
    - - - - -
    - - - -

    36.7.6.17 ret typemap

    Cleanup of function return values

    - - - -

    36.7.6.18 globalin typemap

    Setting of C global variables

    - - - -

    36.7.7 Typemap variables

    @@ -6892,83 +3223,35 @@ may appear. A full list of variables can be found in the "A C local variable corresponding to the actual type specified in the %typemap directive. For input values, this is a C local variable that is supposed to hold an argument value. For output values, this is the raw result that is supposed to be returned to Ruby.
    - - - -

    $input

    - - - -
    A VALUE holding a raw Ruby object with an argument or variable value.
    - - - -

    $result

    - - - -
    A VALUE that holds the result to be returned to Ruby.
    - - - -

    $1_name

    - - - -
    The parameter name that was matched.
    - - - -

    $1_type

    - - - -
    The actual C datatype matched by the typemap.
    - - - -

    $1_ltype

    - - - -
    An assignable version of the datatype matched by the typemap (a type that can appear on the left-hand-side of a C assignment operation). This type is stripped of qualifiers and may @@ -6976,47 +3259,26 @@ be an altered version of $1_type. All arguments and local variables in wrapper functions are declared using this type so that their values can be properly assigned.
    - - - -

    $symname

    - - - -
    The Ruby name of the wrapper function being created.
    - - - -

    36.7.8 Useful Functions

    When you write a typemap, you usually have to work directly with Ruby objects. The following functions may prove to be useful. (These functions plus many more can be found in Programming -Ruby book, by David Thomas and Andrew Hunt.) 

    +Ruby book, by David Thomas and Andrew Hunt.)

    In addition, we list equivalent functions that SWIG defines, which provide a language neutral conversion (these functions are defined for -each swig language supported).  If you are trying to create a swig +each swig language supported). If you are trying to create a swig file that will work under multiple languages, it is recommended you stick to the swig functions instead of the native Ruby functions. - That should help you avoid having to rewrite a lot of typemaps +That should help you avoid having to rewrite a lot of typemaps across multiple languages.

    - - - - - - - - -

    36.7.8.1 C Datatypes to Ruby Objects

    @@ -7025,475 +3287,256 @@ across multiple languages.

    - RUBY - SWIG + RUBY + SWIG - INT2NUM(long or int) - SWIG_From_int(int x) + INT2NUM(long or int) + SWIG_From_int(int x) int to Fixnum or Bignum - - INT2FIX(long or int) - + INT2FIX(long or int) + int to Fixnum (faster than INT2NUM) - - CHR2FIX(char) - SWIG_From_char(char x) + CHR2FIX(char) + SWIG_From_char(char x) char to Fixnum - - rb_str_new2(char*) - SWIG_FromCharPtrAndSize(char*, size_t) + rb_str_new2(char*) + SWIG_FromCharPtrAndSize(char*, size_t) char* to String - - rb_float_new(double) - SWIG_From_double(double),
    + rb_float_new(double) + SWIG_From_double(double),
    SWIG_From_float(float) float/double to Float - - - - - -
    - - - -

    36.7.8.2 Ruby Objects to C Datatypes

    Here, while the Ruby versions return the value directly, the SWIG -versions do not, but return a status value to indicate success (SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

    -

    -%typemap(in) size_t (int ok)

    -  ok = SWIG_AsVal_size_t($input, &$1);
    -  if (!SWIG_IsOK(ok)) {
    -    SWIG_exception_fail(SWIG_ArgError(ok), -Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -));
    -   }
    -
    -}
    -
      
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    int NUM2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    int FIX2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    unsigned int NUM2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    unsigned int FIX2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    long NUM2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    long FIX2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    unsigned long FIX2ULONG(Numeric)SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)
    char NUM2CHR(Numeric or String)SWIG_AsVal_char(VALUE, int*)
    char * StringValuePtr(String)SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)
    char * rb_str2cstr(String, int*length)
    double NUM2DBL(Numeric)(double) SWIG_AsVal_int(VALUE) or similar
    - - - - +versions do not, but return a status value to indicate success (SWIG_OK). While more akward to use, this allows you to write typemaps that report more helpful error messages, like:

    +
    +
    +%typemap(in) size_t (int ok)
    +  ok = SWIG_AsVal_size_t($input, &$1);
    +  if (!SWIG_IsOK(ok)) {
    +    SWIG_exception_fail(SWIG_ArgError(ok), Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input));
    +  }
    +}
    +
    - - - +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    int NUM2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    int FIX2INT(Numeric)SWIG_AsVal_int(VALUE, int*)
    unsigned int NUM2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    unsigned int FIX2UINT(Numeric)SWIG_AsVal_unsigned_SS_int(VALUE, int*)
    long NUM2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    long FIX2LONG(Numeric)SWIG_AsVal_long(VALUE, long*)
    unsigned long FIX2ULONG(Numeric)SWIG_AsVal_unsigned_SS_long(VALUE, unsigned long*)
    char NUM2CHR(Numeric or String)SWIG_AsVal_char(VALUE, int*)
    char * StringValuePtr(String)SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc)
    char * rb_str2cstr(String, int*length)
    double NUM2DBL(Numeric)(double) SWIG_AsVal_int(VALUE) or similar
    +

    36.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    - - - -
    length of the Ruby string
    - - - -

    RSTRING_PTR(str)

    - - - -
    pointer to string storage
    - - - -

    RARRAY_LEN(arr)

    - - - -
    length of the Ruby array
    - - - -

    RARRAY(arr)->capa

    - - - -
    capacity of the Ruby array
    - - - -

    RARRAY_PTR(arr)

    - - - -
    pointer to array storage
    - - - -

    36.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, ...)

    - - - -
    Raises an exception. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    void rb_fatal(const char *fmt, ...)

    - - - -
    Raises a fatal exception, terminating the process. No rescue blocks are called, but ensure blocks will be called. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    void rb_bug(const char *fmt, ...)

    - - - -
    Terminates the process immediately -- no handlers of any sort will be called. The given format string fmt and remaining arguments are interpreted as with printf(). You should call this function only if a fatal bug has been exposed.
    - - - -

    void rb_sys_fail(const char *msg)

    - - - -
    Raises a platform-specific exception corresponding to the last known system error, with the given string msg.
    - - - -

    VALUE rb_rescue(VALUE (*body)(VALUE), VALUE args, VALUE(*rescue)(VALUE, VALUE), VALUE rargs)

    - - - -
    Executes body with the given args. If a StandardError exception is raised, then execute rescue with the given rargs.
    - - - -

    VALUE rb_ensure(VALUE(*body)(VALUE), VALUE args, VALUE(*ensure)(VALUE), VALUE eargs)

    - - - -
    Executes body with the given args. Whether or not an exception is raised, execute ensure with the given rargs after body has completed.
    - - - -

    VALUE rb_protect(VALUE (*body)(VALUE), VALUE args, int *result)

    - - - -
    Executes body with the given args and returns nonzero in result if any exception was raised.
    - - - -

    void rb_notimplement()

    - - - -
    Raises a NotImpError exception to indicate that the enclosed function is not implemented yet, or not available on this platform.
    - - - -

    void rb_exit(int status)

    - - - -
    Exits Ruby with the given status. Raises a SystemExit exception and calls registered exit functions and finalizers.
    - - - -

    void rb_warn(const char *fmt, ...)

    - - - -
    Unconditionally issues a warning message to standard error. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    void rb_warning(const char *fmt, ...)

    - - - -
    Conditionally issues a warning message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf().
    - - - -

    36.7.8.5 Iterators

    void rb_iter_break()

    - - - -
    Breaks out of the enclosing iterator block.
    - - - -

    VALUE rb_each(VALUE obj)

    - - - -
    Invokes the each method of the given obj.
    - - - -

    VALUE rb_yield(VALUE arg)

    - - - -
    Transfers execution to the iterator block in the current context, passing arg as an argument. Multiple values may be passed in an array.
    - - - -

    int rb_block_given_p()

    - - - -
    Returns true if yield would execute a block in the current context; that is, if a code block was passed to the current method and is available to be called.
    - - - -

    VALUE rb_iterate(VALUE (*method)(VALUE), VALUE args, VALUE (*block)(VALUE, VALUE), VALUE arg2)

    - - - -
    Invokes method with argument args and block block. A yield from that method will invoke block with the argument given to yield, and a second argument arg2.
    - - - -

    VALUE rb_catch(const char *tag, VALUE (*proc)(VALUE, VALUE), VALUE value)

    - - - -
    Equivalent to Ruby's catch.
    - - - -

    void rb_throw(const char *tag, VALUE value)

    - - - -
    Equivalent to Ruby's throw.
    - - - -

    36.7.9 Typemap Examples

    @@ -7501,10 +3544,6 @@ VALUE), VALUE value)

    examples, you might look at the examples in the Example/ruby directory.

    - - - -

    36.7.10 Converting a Ruby array to a char **

    @@ -7513,53 +3552,63 @@ command line arguments, which are usually passed in an array of NULL terminated strings. The following SWIG interface file allows a Ruby Array instance to be used as a char ** object.

    - - - -
    -
    %module argv

    // This tells SWIG to treat char ** as a special case
    %typemap(in) char ** {
    /* Get the length of the array */
    int size = RARRAY($input)->len;
    int i;
    $1 = (char **) malloc((size+1)*sizeof(char *));
    /* Get the first element in memory */
    VALUE *ptr = RARRAY($input)->ptr;
    for (i=0; i < size; i++, ptr++)
    /* Convert Ruby Object String to char* */
    $1[i]= StringValuePtr(*ptr);
    $1[i]=NULL; /* End of list */
    }

    // This cleans up the char ** array created before
    // the function call

    %typemap(freearg) char ** {
    free((char *) $1);
    }

    // Now a test function
    %inline %{
    int print_args(char **argv) {
    int i = 0;
    while (argv[i]) {
    printf("argv[%d] = %s\n", i,argv[i]);
    i++;
    }
    return i;
    }
    %}

    - +
    %module argv
     
    +// This tells SWIG to treat char ** as a special case
    +%typemap(in) char ** {
    +  /* Get the length of the array */
    +  int size = RARRAY($input)->len; 
    +  int i;
    +  $1 = (char **) malloc((size+1)*sizeof(char *));
    +  /* Get the first element in memory */
    +  VALUE *ptr = RARRAY($input)->ptr; 
    +  for (i=0; i < size; i++, ptr++) {
    +    /* Convert Ruby Object String to char* */
    +    $1[i]= StringValuePtr(*ptr); 
    +  }
    +  $1[i]=NULL; /* End of list */
    +}
     
    +// This cleans up the char ** array created before 
    +// the function call
     
    +%typemap(freearg) char ** {
    +  free((char *) $1);
    +}
     
    +// Now a test function
    +%inline %{
    +int print_args(char **argv) {
    +  int i = 0;
    +  while (argv[i]) {
    +    printf("argv[%d] = %s\n", i,argv[i]);
    +    i++;
    +  }
    +  return i;
    +}
    +%}
    - - - -

    When this module is compiled, the wrapped C function now operates as follows :

    - - - -
    -
    require 'Argv'
    Argv.print_args(["Dave","Mike","Mary","Jane","John"])
    argv[0] = Dave
    argv[1] = Mike
    argv[2] = Mary
    argv[3] = Jane
    argv[4] = John
    - - - - - +
    require 'Argv'
    +Argv.print_args(["Dave","Mike","Mary","Jane","John"])
    +argv[0] = Dave
    +argv[1] = Mike
    +argv[2] = Mary
    +argv[3] = Jane
    +argv[4] = John
    - - - -

    In the example, two different typemaps are used. The "in" typemap is used to receive an input argument and convert it to a C array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

    - - - -

    36.7.11 Collecting arguments in a hash

    @@ -7572,66 +3621,33 @@ provide similar functionality for your Ruby interface. For example, suppose you'd like to wrap this C function that collects information about people's vital statistics:

    - - - -
    -
    void setVitalStats(const char *person, int nattributes, const char **names, int *values);
    - - - - - +
    void setVitalStats(const char *person, int nattributes, const char **names, int *values);
    - - - -

    and you'd like to be able to call it from Ruby by passing in an arbitrary number of key-value pairs as inputs, e.g.

    - - - -
    -
    setVitalStats("Fred",
    'weight' => 270,
    'age' => 42
    )
    - - - - - +
    setVitalStats("Fred", 
    +  'weight' => 270, 
    +  'age' => 42 
    +)
    - - - -

    To make this work, you need to write a typemap that expects a Ruby Hash as its input and somehow extracts the last three arguments (nattributes, names and values) needed by your C function. Let's start with the basics:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +}
    + 
    - - - -

    This %typemap directive tells SWIG that we want to match any function declaration that has the specified types and names of arguments somewhere in the argument list. The fact that we @@ -7644,38 +3660,20 @@ of parentheses (keys_arr, i, key and val) define local variables that our typemap will need.

    - - - -

    Since we expect the input argument to be a Hash, let's next add a check for that:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +}
    - - - -

    Check_Type() is just a macro (defined in the Ruby header files) that confirms that the input argument is of the correct type; if it isn't, an exception will be raised.

    - - - -

    The next task is to determine how many key-value pairs are present in the hash; we'll assign this number to the first typemap argument ($1). This is a little tricky since the @@ -7684,161 +3682,147 @@ hash, but we can get around that by calling the hash's size method directly and converting its result to a C int value:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +}
    - - - -

    So now we know the number of attributes. Next we need to initialize the second and third typemap arguments (i.e. the two C arrays) to NULL and set the stage for extracting the keys and values from the hash:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    }

    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +    }
    +}
    - - - -

    There are a number of ways we could extract the keys and values from the input hash, but the simplest approach is to first call the hash's keys method (which returns a Ruby array of the keys) and then start looping over the elements in that array:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    }

    }
    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +      for (i = 0; i < $1; i++) {
    +      }
    +    }
    +}
    - - - -

    Recall that keys_arr and i are local variables for this typemap. For each element in the keys_arr array, we want to get the key itself, as well as the value corresponding to that key in the hash:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);

    }
    }
    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +      for (i = 0; i < $1; i++) {
    +        key = rb_ary_entry(keys_arr, i);
    +        val = rb_hash_aref($input, key);
    +      }
    +    }
    +}
    - - - -

    To be safe, we should again use the Check_Type() macro to confirm that the key is a String and the value is a Fixnum:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);
    Check_Type(key, T_STRING);
    Check_Type(val, T_FIXNUM);

    }
    }
    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +    Check_Type($input, T_HASH);
    +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +    $2 = NULL;
    +    $3 = NULL;
    +    if ($1 > 0) {
    +      $2 = (char **) malloc($1*sizeof(char *));
    +      $3 = (int *) malloc($1*sizeof(int));
    +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +      for (i = 0; i < $1; i++) {
    +        key = rb_ary_entry(keys_arr, i);
    +        val = rb_hash_aref($input, key);
    +        Check_Type(key, T_STRING);
    +        Check_Type(val, T_FIXNUM);
    +      }
    +    }
    +}
    - - - -

    Finally, we can convert these Ruby objects into their C equivalents and store them in our local C arrays:

    - - - -
    -
    %typemap(in) (int nattributes, const char **names, const int *values)
    (VALUE keys_arr, int i, VALUE key, VALUE val) {
    Check_Type($input, T_HASH);
    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    $2 = NULL;
    $3 = NULL;
    if ($1 > 0) {
    $2 = (char **) malloc($1*sizeof(char *));
    $3 = (int *) malloc($1*sizeof(int));
    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    for (i = 0; i < $1; i++) {
    key = rb_ary_entry(keys_arr, i);
    val = rb_hash_aref($input, key);
    Check_Type(key, T_STRING);
    Check_Type(val, T_FIXNUM);
    $2[i] = StringValuePtr(key);
    $3[i] = NUM2INT(val);

    }
    }
    }
    - - - - - +
    %typemap(in) (int nattributes, const char **names, const int *values)
    +  (VALUE keys_arr, int i, VALUE key, VALUE val) {
    +  Check_Type($input, T_HASH);
    +  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
    +  $2 = NULL;
    +  $3 = NULL;
    +  if ($1 > 0) {
    +    $2 = (char **) malloc($1*sizeof(char *));
    +    $3 = (int *) malloc($1*sizeof(int));
    +    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
    +    for (i = 0; i < $1; i++) {
    +      key = rb_ary_entry(keys_arr, i);
    +      val = rb_hash_aref($input, key);
    +      Check_Type(key, T_STRING);
    +      Check_Type(val, T_FIXNUM);
    +      $2[i] = StringValuePtr(key);
    +      $3[i] = NUM2INT(val);
    +    }
    +  }
    +}
    - - - -

    We're not done yet. Since we used malloc() to dynamically allocate the memory used for the names and values arguments, we need to provide a corresponding "freearg" typemap to free that memory so that there is no memory leak. Fortunately, this typemap is a lot easier to write:

    - - - -
    -
    %typemap(freearg) (int nattributes, const char **names, const int *values) {
    free((void *) $2);
    free((void *) $3);
    }
    - - - - - +
    %typemap(freearg) (int nattributes, const char **names, const int *values) {
    +  free((void *) $2);
    +  free((void *) $3);
    +}
    - - - -

    All of the code for this example, as well as a sample Ruby program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

    - - - -

    36.7.12 Pointer handling

    @@ -7847,17 +3831,9 @@ that have been stored using the SWIG typed-pointer representation. Since there are several ways in which pointers can be represented, the following two functions are used to safely perform this conversion:

    - - - -

    int SWIG_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)

    - - - -
    Converts a Ruby object obj to a C pointer whose address is ptr (i.e. ptr is a pointer to a pointer). The third argument, ty, @@ -7871,17 +3847,9 @@ errors will cause SWIG_ConvertPtr() to return -1 but not raise an exception. If ty is NULL, no type-checking is performed.
    - - - -

    VALUE SWIG_NewPointerObj(void *ptr, swig_type_info *ty, int own)

    - - - -
    Creates a new Ruby pointer object. Here, ptr is the pointer to convert, ty is the SWIG type descriptor structure that describes the type, and own @@ -7889,10 +3857,6 @@ is a flag that indicates whether or not Ruby should take ownership of the pointer (i.e. whether Ruby should free this data when the corresponding Ruby instance is garbage-collected).
    - - - -

    Both of these functions require the use of a special SWIG type-descriptor structure. This structure contains information about the mangled name of the datatype, type-equivalence information, as well @@ -7900,95 +3864,51 @@ as information about converting pointer values under C++ inheritance. For a type of Foo *, the type descriptor structure is usually accessed as follows:

    - - - -
    -
    Foo *foo;
    SWIG_ConvertPtr($input, (void **) &foo, SWIGTYPE_p_Foo, 1);

    VALUE obj;
    obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);
    - - - - +
    Foo *foo;
    +SWIG_ConvertPtr($input, (void **) &foo, SWIGTYPE_p_Foo, 1);
     
    +VALUE obj;
    +obj = SWIG_NewPointerObj(f, SWIGTYPE_p_Foo, 0);
    - - - -

    In a typemap, the type descriptor should always be accessed using the special typemap variable $1_descriptor. For example:

    - - - -
    -
    %typemap(in) Foo * {
    SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
    }
    - - - - - +
    %typemap(in) Foo * {
    +  SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
    +}
    - - - -

    36.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void (*mark)(void *), void (*free)(void *), void *ptr)

    - - - -
    Given a pointer ptr to some C data, and the two garbage collection routines for this data (mark and free), return a VALUE for the Ruby object.
    - - - -

    VALUE Data_Make_Struct(VALUE class, c-type, void (*mark)(void *), void (*free)(void *), c-type *ptr)

    - - - -
    Allocates a new instance of a C data type c-type, assigns it to the pointer ptr, then wraps that pointer with Data_Wrap_Struct() as above.
    - - - -

    Data_Get_Struct(VALUE obj, c-type, c-type *ptr)

    - - - -
    Retrieves the original C pointer of type c-type from the data object obj and assigns that pointer to ptr.
    - - - -

    36.7.13 Example: STL Vector to Ruby Array

    @@ -8000,103 +3920,86 @@ The following is an example of how to construct this type of macro/typemap and should give insight into constructing similar typemaps for other STL structures:

    - - - -
    -
    %define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    %typemap(out) vectorclassname &, const vectorclassname & {
    VALUE arr = rb_ary_new2($1->size());
    vectorclassname::iterator i = $1->begin(), iend = $1->end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    $result = arr;
    }
    %typemap(out) vectorclassname, const vectorclassname {
    VALUE arr = rb_ary_new2($1.size());
    vectorclassname::iterator i = $1.begin(), iend = $1.end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    $result = arr;
    }
    %enddef
    - - - - - +
    %define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    +%typemap(out) vectorclassname &, const vectorclassname & {
    +  VALUE arr = rb_ary_new2($1->size());
    +  vectorclassname::iterator i = $1->begin(), iend = $1->end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    +  $result = arr;
    +}
    +%typemap(out) vectorclassname, const vectorclassname {
    +  VALUE arr = rb_ary_new2($1.size());
    +  vectorclassname::iterator i = $1.begin(), iend = $1.end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
    +  $result = arr;
    +}
    +%enddef
    - - - -

    Note, that the "c ## classname.klass" is used in the preprocessor step to determine the actual object from the class name.

    - - - -

    To use the macro with a class Foo, the following is used:

    - - - -
    -
    PTR_VECTOR_TO_RUBY_ARRAY(vector<foo *="">, Foo)
    - - - - - +
    PTR_VECTOR_TO_RUBY_ARRAY(vector<foo *="">, Foo)
    - - - -

    It is also possible to create a STL vector of Ruby objects:

    - - - -
    -
    %define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
    %typemap(in) vectorclassname &, const vectorclassname & {
    Check_Type($input, T_ARRAY);
    vectorclassname *vec = new vectorclassname;
    int len = RARRAY($input)->len;
    for (int i=0; i!=len; i++) {
    VALUE inst = rb_ary_entry($input, i);
    //The following _should_ work but doesn't on HPUX
    // Check_Type(inst, T_DATA);
    classname *element = NULL;
    Data_Get_Struct(inst, classname, element);
    vec->push_back(element);
    }
    $1 = vec;
    }

    %typemap(freearg) vectorclassname &, const vectorclassname & {
    delete $1;
    }
    %enddef
    - - - - +
    %define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
    +%typemap(in) vectorclassname &, const vectorclassname & {
    +  Check_Type($input, T_ARRAY);
    +  vectorclassname *vec = new vectorclassname;
    +  int len = RARRAY($input)->len;
    +  for (int i=0; i!=len; i++) {
    +    VALUE inst = rb_ary_entry($input, i);
    +    //The following _should_ work but doesn't on HPUX
    +    // Check_Type(inst, T_DATA);
    +    classname *element = NULL;
    +    Data_Get_Struct(inst, classname, element);
    +    vec->push_back(element);
    +  }
    +  $1 = vec;
    +}
     
    +%typemap(freearg) vectorclassname &, const vectorclassname & {
    +  delete $1;
    +}
    +%enddef
    - - - -

    It is also possible to create a Ruby array from a vector of static data types:

    - - - -
    -
    %define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    %typemap(out) vectorclassname &, const vectorclassname & {
    VALUE arr = rb_ary_new2($1->size());
    vectorclassname::iterator i = $1->begin(), iend = $1->end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    $result = arr;
    }
    %typemap(out) vectorclassname, const vectorclassname {
    VALUE arr = rb_ary_new2($1.size());
    vectorclassname::iterator i = $1.begin(), iend = $1.end();
    for ( ; i!=iend; i++ )
    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    $result = arr;
    }
    %enddef
    - - - - - +
    %define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
    +%typemap(out) vectorclassname &, const vectorclassname & {
    +  VALUE arr = rb_ary_new2($1->size()); 
    +  vectorclassname::iterator i = $1->begin(), iend = $1->end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    +  $result = arr;
    +}
    +%typemap(out) vectorclassname, const vectorclassname {
    +  VALUE arr = rb_ary_new2($1.size()); 
    +  vectorclassname::iterator i = $1.begin(), iend = $1.end();
    +  for ( ; i!=iend; i++ )
    +    rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
    +  $result = arr;
    +}
    +%enddef
    - - - - -
    - - - - - Note that this is mostly an example of typemaps. If you want to use the STL with ruby, you are advised to use the standard swig STL library, -which does much more than this.  Refer to the section called -the C++ Standard Template Library.
    - - - - +which does much more than this. Refer to the section called +the C++ Standard Template Library.

    36.8 Docstring Features

    @@ -8108,108 +4011,60 @@ will normally not get any documentation for it, even if they run 'rdoc' on the resulting .c or .cxx file.

    - - - -

    The features described in this section make it easy for you to add rdoc strings to your modules, functions and methods that can then be read by Ruby's rdoc tool to generate html web pages, ri documentation, Windows chm file and an .xml description.

    - - - -

    rdoc can then be run from a console or shell window on a swig -generated file. 

    - - - - +generated file.

    For example, to generate html web pages from a C++ file, you'd -do: 

    - - - - - -
    -$ -rdoc -E cxx=c -f html file_wrap.cxx
    - - - +do:

    +
    +
    +$ rdoc -E cxx=c -f html file_wrap.cxx
    +

    To generate ri documentation from a c wrap file, you could do:

    - - - - -
    $ rdoc --r file_wrap.c -
    - - - - +
    +$ rdoc -r file_wrap.c
    +

    36.8.1 Module docstring

    -Ruby allows a docstring at the beginning of the file +Ruby allows a docstring at the beginning of the file before any other statements, and it is typically used to give a general description of the entire module. SWIG supports this by setting an option of the %module directive. For example:

    - - - -
    -
    %module(docstring="This is the example module's docstring") example
    - - - - - +
    %module(docstring="This is the example module's docstring") example
    - - - -

    When you have more than just a line or so then you can retain the easy readability of the %module directive by using a macro. For example:

    - - - -
    -
    %define DOCSTRING
    "The `XmlResource` class allows program resources defining menus,
    layout of controls on a panel, etc. to be loaded from an XML file."
    %enddef

    %module(docstring=DOCSTRING) xrc
    - - - - +
    %define DOCSTRING
    +"The `XmlResource` class allows program resources defining menus, 
    +layout of controls on a panel, etc. to be loaded from an XML file."
    +%enddef
     
    +%module(docstring=DOCSTRING) xrc
    - - - -

    36.8.2 %feature("autodoc")

    @@ -8220,10 +4075,6 @@ and default values. Since Ruby ships with one of the best documentation systems of any language, it makes sense to take advantage of it.

    - - - -

    SWIG's Ruby module provides support for the "autodoc" feature, which when attached to a node in the parse tree will cause an rdoc @@ -8235,10 +4086,6 @@ several options for autodoc controlled by the value given to the feature, described below.

    - - - -

    36.8.2.1 %feature("autodoc", "0")

    @@ -8249,44 +4096,20 @@ example, given this function prototype:

    - - - -
    -
    %feature("autodoc", "0");
    bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
    - - - - - +
    %feature("autodoc", "0");
    +bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
    - - - -

    Then Ruby code like this will be generated:

    - - - -
    -
    function_name(x, y, foo=nil, bar=nil) -> bool
    ...
    - - - - - +
    function_name(x, y, foo=nil, bar=nil) -> bool
    +  ...
    - - - -

    36.8.2.2 %feature("autodoc", "1")

    @@ -8302,23 +4125,11 @@ parameter types with the "1" option will result in rdoc code like this:

    - - - -
    -
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
    ...
    - - - - - +
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
    +  ...
    - - - -

    36.8.2.3 %feature("autodoc", "2")

    @@ -8326,43 +4137,32 @@ this: When the "2" option is used then the parameter types will not be used in the rdoc string. However, they will be listed in full after the -function.  Given the example above, then turning on the +function. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this:

    - - - -

    36.8.2.4 %feature("autodoc", "3")

    When the "3" option is used then the function will be documented using -a combination of "1" and "2" above.  Given the example above, +a combination of "1" and "2" above. Given the example above, then turning on the parameter types with the "2" option will result in Ruby code like this:

    - - - -
    -
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool

    Parameters:
    x - int
    y - int
    foo - Foo
    bar - Bar
    - - - - +
    function_name(int x, int y, Foo foo=nil, Bar bar=nil) -> bool
     
    +Parameters:
    +	x - int
    +	y - int
    +	foo - Foo
    +	bar - Bar
    - - - -

    36.8.2.5 %feature("autodoc", "docstring")

    @@ -8374,23 +4174,11 @@ feature then that string will be used in place of the automatically generated string. For example:

    - - - -
    -
    %feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
    void GetPosition(int* OUTPUT, int* OUTPUT);
    - - - - - +
    %feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
    +void GetPosition(int* OUTPUT, int* OUTPUT);
    - - - -

    36.8.3 %feature("docstring")

    @@ -8402,10 +4190,6 @@ docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

    - - - -

    36.9 Advanced Topics

    @@ -8416,1016 +4200,180 @@ docstring and they are output together.

    or %rename commands in SWIG and the following operator names (derived from Python):

    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    General
    __repr__ inspect
    __str__ to_s
    __cmp__ <=>
    __hash__ hash
    __nonzero__ nonzero?
    Callable
    __call__ call
    Collection
    __len__ length
    __getitem__ []
    __setitem__ []=
    Numeric
    __add__ +
    __sub__ -
    __mul__ *
    __div__ /
    __mod__ %
    __divmod__ divmod
    __pow__ **
    __lshift__ <<
    __rshift__ >>
    __and__ &
    __xor__ ^
    __or__ |
    __neg__ -@
    __pos__ +@
    __abs__ abs
    __invert__ ~
    __int__ to_i
    __float__ to_f
    __coerce__ coerce
    Additions in 1.3.13
    __lt__ <
    __le__ <=
    __eq__ ==
    __gt__ >
    __ge__ >=
    - - - - -
    - - - -

    Note that although SWIG supports the __eq__ magic method name for defining an equivalence operator, there is no separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

    - - - -

    36.9.2 Creating Multi-Module Packages

    @@ -9434,112 +4382,88 @@ with Modules discusses the basics of creating multi-module extensions with SWIG, and in particular the considerations for sharing runtime type information among the different modules.

    - - - -

    As an example, consider one module's interface file (shape.i) that defines our base class:

    - - - -
    -
    %module shape

    %{
    #include "Shape.h"
    %}

    class Shape {
    protected:
    double xpos;
    double ypos;
    protected:
    Shape(double x, double y);
    public:
    double getX() const;
    double getY() const;
    };
    - - - +
    %module shape
     
    +%{
    +#include "Shape.h"
    +%}
     
    +class Shape {
    +protected:
    +  double xpos;
    +  double ypos;
    +protected:
    +  Shape(double x, double y);
    +public:
    +  double getX() const;
    +  double getY() const;
    +};
    - - - -

    We also have a separate interface file (circle.i) that defines a derived class:

    - - - -
    -
    %module circle

    %{
    #include "Shape.h"
    #include "Circle.h"
    %}

    // Import the base class definition from Shape module
    %import shape.i

    class Circle : public Shape {
    protected:
    double radius;
    public:
    Circle(double x, double y, double r);
    double getRadius() const;
    };
    - - +
    %module circle
     
    +%{
    +#include "Shape.h"
    +#include "Circle.h"
    +%}
     
    +// Import the base class definition from Shape module
    +%import shape.i
     
    +class Circle : public Shape {
    +protected:
    +  double radius;
    +public:
    +  Circle(double x, double y, double r);
    +  double getRadius() const;
    +};
    - - - -

    We'll start by building the Shape extension module:

    - - - -
    -
    $ swig -c++ -ruby shape.i
    +
    $ swig -c++ -ruby shape.i
     
    - - - - -
    - - - -

    SWIG generates a wrapper file named shape_wrap.cxx. To compile this into a dynamically loadable extension for Ruby, prepare an extconf.rb script using this template:

    - - - -
    -
    require 'mkmf'

    # Since the SWIG runtime support library for Ruby
    # depends on the Ruby library, make sure it's in the list
    # of libraries.
    $libs = append_library($libs, Config::CONFIG['RUBY_INSTALL_NAME'])

    # Create the makefile
    create_makefile('shape')
    - - - +
    require 'mkmf'
     
    +# Since the SWIG runtime support library for Ruby
    +# depends on the Ruby library, make sure it's in the list
    +# of libraries.
    +$libs = append_library($libs, Config::CONFIG['RUBY_INSTALL_NAME'])
     
    +# Create the makefile
    +create_makefile('shape')
    - - - -

    Run this script to create a Makefile and then type make to build the shared library:

    - - - -
    -
    $ ruby extconf.rb
    creating Makefile
    $ make
    g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
    -I. -c shape_wrap.cxx
    gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
    -lruby -lruby -lc
    - - - - - +
    $ ruby extconf.rb
    +creating Makefile
    +$ make
    +g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
    +-I. -c shape_wrap.cxx
    +gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
    +-lruby -lruby -lc
    - - - -

    Note that depending on your installation, the outputs may be slightly different; these outputs are those for a Linux-based development environment. The end result should be a shared library @@ -9547,66 +4471,35 @@ development environment. The end result should be a shared library code. Now repeat this process in a separate directory for the Circle module:

    - - - -
      - - - - -
    1. Run SWIG to generate the wrapper code (circle_wrap.cxx);
    2. - - - - -
    3. Write an extconf.rb script that your end-users can use to create a platform-specific Makefile for the extension;
    4. - - - - -
    5. Build the shared library for this extension by typing make.
    6. - - - - -
    - - - -

    Once you've built both of these extension modules, you can test them interactively in IRB to confirm that the Shape and Circle modules are properly loaded and initialized:

    - - - -
    -
    $ irb
    irb(main):001:0> require 'shape'
    true
    irb(main):002:0> require 'circle'
    true
    irb(main):003:0> c = Circle::Circle.new(5, 5, 20)
    #<Circle::Circle:0xa097208>
    irb(main):004:0> c.kind_of? Shape::Shape
    true
    irb(main):005:0> c.getX()
    5.0
    - - - - - +
    $ irb
    +irb(main):001:0> require 'shape'
    +true
    +irb(main):002:0> require 'circle'
    +true
    +irb(main):003:0> c = Circle::Circle.new(5, 5, 20)
    +#<Circle::Circle:0xa097208>
    +irb(main):004:0> c.kind_of? Shape::Shape
    +true
    +irb(main):005:0> c.getX()
    +5.0
    - - - -

    36.9.3 Specifying Mixin Modules

    @@ -9615,96 +4508,65 @@ it does allow you to mix one or more modules into a class using Ruby's inclu method. For example, if you have a Ruby class that defines an each instance method, e.g.

    - - - -
    -
    class Set
    def initialize
    @members = []
    end

    def each
    @members.each { |m| yield m }
    end
    end
    - - - - - +
    class Set
    +  def initialize
    +  @members = []
    +  end
    + 
    +  def each
    +  @members.each { |m| yield m }
    +  end
    +end
    - - - -

    then you can mix-in Ruby's Enumerable module to easily add a lot of functionality to your class:

    - - - -
    -
    class Set
    include Enumerable
    def initialize
    @members = []
    end
    def each
    @members.each { |m| yield m }
    end
    end
    - - - - - +
    class Set
    +  include Enumerable
    +  def initialize
    +    @members = []
    +  end
    +  def each
    +    @members.each { |m| yield m }
    +  end
    +end
    - - - -

    To get the same benefit for your SWIG-wrapped classes, you can use the %mixin directive to specify the names of one or more modules that should be mixed-in to a class. For the above example, the SWIG interface specification might look like this:

    - - - -
    -
    %mixin Set "Enumerable";

    class Set {
    public:
    // Constructor
    Set();

    // Iterates through set members
    void each();
    };
    - - - - +
    %mixin Set "Enumerable";
     
    +class Set {
    +public:
    +  // Constructor
    +  Set();
    + 
    +  // Iterates through set members
    +  void each();
    +};
    - - - -

    Multiple modules can be mixed into a class by providing a comma-separated list of module names to the %mixin directive, e.g.

    - - - -
    %mixin Set "Fee,Fi,Fo,Fum";
    - - - - -
    - - - -

    Note that the %mixin directive is implemented using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    36.10 Memory Management

    @@ -9713,45 +4575,21 @@ Ruby is proper memory management. The key to proper memory management is clearly defining whether a wrapper Ruby object owns the underlying C struct or C++ class. There are two possibilities:

    - - - -
      - - - -
    • The Ruby object is responsible for freeing the C struct or C++ object
    • - - - -
    • The Ruby object should not free the C struct or C++ object because it will be freed by the underlying C or C++ code
    • - - - -
    - - - -

    To complicate matters, object ownership may transfer from Ruby to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

    - - - -

    36.10.1 Mark and Sweep Garbage Collector

    @@ -9769,37 +4607,21 @@ In the sweep phase, all objects that have not been marked will be garbage collected. For more information about the Ruby garbage collector please refer to http://rubygarden.org/ruby/ruby?GCAndExtensions.

    - - - -

    The Ruby C/API provides extension developers two hooks into the garbage collector - a "mark" function and a "sweep" function. By default these functions are set to NULL.

    - - - -

    If a C struct or C++ class references any other Ruby objects, then it must provide a "mark" function. The "mark" function should identify any referenced Ruby objects by calling the rb_gc_mark function for each one. Unsurprisingly, this function will be called by the Ruby garbage during the "mark" phase.

    - - - -

    During the sweep phase, Ruby destroys any unused objects. If any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

    - - - -

    36.10.2 Object Ownership

    @@ -9810,171 +4632,92 @@ then a "free" function must be registered for the object. If the Ruby object is not responsible for freeing the underlying memory, then a "free" function must not be registered for the object.

    - - - -

    For the most part, SWIG takes care of memory management issues. The rules it uses are:

    - - - -
      - - - -
    • When calling a C++ object's constructor from Ruby, SWIG will assign a "free" function thereby making the Ruby object responsible for freeing the C++ object
    • - - - -
    • When calling a C++ member function that returns a pointer, SWIG will not assign a "free" function thereby making the underlying library responsible for freeing the object.
    • - - - -
    - - - -

    To make this clearer, let's look at an example. Assume we have a Foo and a Bar class.

    - - - -
    -
    /* File "RubyOwernshipExample.h" */

    class Foo
    {
    public:
    Foo() {}
    ~Foo() {}
    };

    class Bar
    {
    Foo *foo_;
    public:
    Bar(): foo_(new Foo) {}
    ~Bar() { delete foo_; }
    Foo* get_foo() { return foo_; }
    Foo* get_new_foo() { return new Foo; }
    void set_foo(Foo *foo) { delete foo_; foo_ = foo; }
    };

    - - - +
    /* File "RubyOwernshipExample.h" */
     
    +class Foo
    +{
    +public:
    +  Foo() {}
    +  ~Foo() {}
    +};
     
    +class Bar
    +{
    +  Foo *foo_;
    +public:
    +  Bar(): foo_(new Foo) {}
    +  ~Bar() { delete foo_; }
    +  Foo* get_foo() { return foo_; }
    +  Foo* get_new_foo() { return new Foo; }
    +  void set_foo(Foo *foo) { delete foo_; foo_ = foo; }
    +};
    - - - -

    First, consider this Ruby code:

    - - - -
    foo = Foo.new
    - - - - -
    - - - -

    In this case, the Ruby code calls the underlying Foo C++ constructor, thus creating a new foo object. By default, SWIG will assign the new Ruby object a "free" function. When the Ruby object is garbage collected, the "free" function will be called. It in turn will call Foo's destructor.

    - - - -

    Next, consider this code:

    - - - -
    -
    bar = Bar.new
    foo = bar.get_foo()
    - - - - - +
    bar = Bar.new
    +foo = bar.get_foo()
    - - - -

    In this case, the Ruby code calls a C++ member function, get_foo. By default, SWIG will not assign the Ruby object a "free" function. Thus, when the Ruby object is garbage collected the underlying C++ foo object is not affected.

    - - - -

    Unfortunately, the real world is not as simple as the examples above. For example:

    - - - -
    -
    bar = Bar.new
    foo = bar.get_new_foo()
    - - - - - +
    bar = Bar.new
    +foo = bar.get_new_foo()
    - - - -

    In this case, the default SWIG behavior for calling member functions is incorrect. The Ruby object should assume ownership of the returned object. This can be done by using the %newobject directive. See Object ownership and %newobject for more information.

    - - - -

    The SWIG default mappings are also incorrect in this case:

    - - - -
    -
    foo = Foo.new
    bar = Bar.new
    bar.set_foo(foo)
    - - - - - +
    foo = Foo.new
    +bar = Bar.new
    +bar.set_foo(foo)
    - - - -

    Without modification, this code will cause a segmentation fault. When the Ruby foo object goes out of scope, it will free the underlying C++ foo @@ -9985,17 +4728,9 @@ Ruby object to the C++ object when the set_foo method is called. This can be done by using the special DISOWN type map, which was added to the Ruby bindings in SWIG-1.3.26.

    - - - -

    Thus, a correct SWIG interface file correct mapping for these classes is:

    - - - -
    /* File RubyOwnershipExample.i */
     
    @@ -10008,56 +4743,30 @@ classes is:

    class Foo { public: - Foo(); - ~Foo(); + Foo(); + ~Foo(); }; class Bar { - Foo *foo_; + Foo *foo_; public: - Bar(); - ~Bar(); - Foo* get_foo(); + Bar(); + ~Bar(); + Foo* get_foo(); - %newobject get_new_foo; - Foo* get_new_foo(); + %newobject get_new_foo; + Foo* get_new_foo(); - %apply SWIGTYPE *DISOWN {Foo *foo}; - void set_foo(Foo *foo); - %clear Foo *foo; + %apply SWIGTYPE *DISOWN {Foo *foo}; + void set_foo(Foo *foo); + %clear Foo *foo; }; -
    - - - - -
    - - - - -
    - - - - -

    This code can be seen in swig/examples/ruby/tracking.

    - - - - -
    - - - - -

    36.10.3 Object Tracking

    @@ -10065,35 +4774,77 @@ public: shown below to illustrate different memory management techniques. The class library models a zoo and the animals it contains.

    - - - -
    -
    %module zoo

    %{
    #include <string>
    #include <vector>

    #include "zoo.h"
    %}

    class Animal
    {
    private:
    typedef std::vector<Animal*> AnimalsType;
    typedef AnimalsType::iterator IterType;
    protected:
    AnimalsType animals;
    protected:
    std::string name_;
    public:
    // Construct an animal with this name
    Animal(const char* name) : name_(name) {}

    // Return the animal's name
    const char* get_name() const { return name.c_str(); }
    };

    class Zoo
    {
    protected:
    std::vector<animal *=""> animals;

    public:
    // Construct an empty zoo
    Zoo() {}

    /* Create a new animal. */
    static Animal* Zoo::create_animal(const char* name)
    {
    return new Animal(name);
    }

    // Add a new animal to the zoo
    void add_animal(Animal* animal) {
    animals.push_back(animal);
    }

    Animal* remove_animal(size_t i) {
    Animal* result = this->animals[i];
    IterType iter = this->animals.begin();
    std::advance(iter, i);
    this->animals.erase(iter);

    return result;
    }

    // Return the number of animals in the zoo
    size_t get_num_animals() const {
    return animals.size();
    }

    // Return a pointer to the ith animal
    Animal* get_animal(size_t i) const {
    return animals[i];
    }
    };

    - +
    %module zoo
     
    +%{
    +#include <string>
    +#include <vector>
     
    +#include "zoo.h"
    +%}
     
    +class Animal
    +{
    +private:
    +  typedef std::vector<Animal*> AnimalsType;
    +  typedef AnimalsType::iterator IterType;
    +protected:
    +  AnimalsType animals;
    +protected:
    +  std::string name_;
    +public:
    +  // Construct an animal with this name
    +  Animal(const char* name) : name_(name) {}
    + 
    +  // Return the animal's name
    +  const char* get_name() const { return name.c_str(); }
    +};
     
    +class Zoo
    +{
    +protected:
    + std::vector<animal *=""> animals;
    + 
    +public:
    +  // Construct an empty zoo
    +  Zoo() {}
    +  
    +  /* Create a new animal. */
    +  static Animal* Zoo::create_animal(const char* name) {
    +    return new Animal(name);
    +  }
    + 
    +  // Add a new animal to the zoo
    +  void add_animal(Animal* animal) {
    +    animals.push_back(animal); 
    +  }
    + 
    +  Animal* remove_animal(size_t i) {
    +    Animal* result = this->animals[i];
    +    IterType iter = this->animals.begin();
    +    std::advance(iter, i);
    +    this->animals.erase(iter);
    +   
    +    return result;
    +  }
    +  
    +  // Return the number of animals in the zoo
    +  size_t get_num_animals() const {
    +    return animals.size(); 
    +  }
    +  
    +  // Return a pointer to the ith animal
    +  Animal* get_animal(size_t i) const {
    +    return animals[i]; 
    +  }
    +};
    - - - - -

    Let's say you SWIG this code and then run IRB:
    - - - - +

    Let's say you SWIG this code and then run IRB:

    - - - -
    $ irb
     irb(main):001:0> require 'example'
    @@ -10122,33 +4873,14 @@ irb(main):008:0> tiger2.get_name()
     
     irb(main):009:0> tiger1.equal?(tiger2)
     => false
    -
     
    - - - - -
    - - - -

    Pay particular attention to the code tiger1.equal?(tiger2). Note that the two Ruby objects are not the same - but they reference -the same underlying C++ object. This can cause problems. For example:
    - - - - - +the same underlying C++ object. This can cause problems. For example:

    - - - -
    irb(main):010:0> tiger1 = nil
     => nil
    @@ -10158,19 +4890,9 @@ irb(main):011:0> GC.start
     
     irb(main):012:0> tiger2.get_name()
     (irb):12: [BUG] Segmentation fault
    -
     
    - - - - -
    - - - -

    After the garbage collector runs, as a result of our call to GC.start, callingtiger2.get_name() causes a segmentation fault. The problem is that when tiger1 @@ -10178,116 +4900,85 @@ is garbage collected, it frees the underlying C++ object. Thus, when tiger2< calls the get_name() method it invokes it on a destroyed object.

    - - - -

    This problem can be avoided if SWIG enforces a one-to-one mapping between Ruby objects and C++ classes. This can be done via the use of the %trackobjects functionality available in SWIG-1.3.26. and later.

    - - - -

    When the %trackobjects is turned on, SWIG automatically keeps track of mappings between C++ objects and Ruby objects. Note that enabling object tracking causes a slight performance degradation. Test results show this degradation to be about 3% to 5% when creating and destroying 100,000 animals in a row.

    - - - -

    Since %trackobjects is implemented as a %feature, it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features") . Thus it can be applied on a class-by-class basis if needed. To fix the example above:

    - - - - -
    - - - - -
    -
    %module example

    %{
    #include "example.h"
    %}

    /* Tell SWIG that create_animal creates a new object */
    %newobject Zoo::create_animal;

    /* Tell SWIG to keep track of mappings between C/C++ structs/classes. */
    %trackobjects;

    %include "example.h"
    - +
    %module example
     
    +%{
    +#include "example.h"
    +%}
     
    +/* Tell SWIG that create_animal creates a new object */
    +%newobject Zoo::create_animal;
     
    +/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */%trackobjects;
     
    +%include "example.h"
    - - - - -

    When this code runs we see:
    - - - - - -
    - - - - - +

    When this code runs we see:

    - - - -
    -
    $ irb
    irb(main):001:0> require 'example'
    => true

    irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    => #<Example::Animal:0x2be37d8>

    irb(main):003:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2be0a18>

    irb(main):004:0> zoo.add_animal(tiger1)
    => nil

    irb(main):006:0> tiger2 = zoo.remove_animal(0)
    => #<Example::Animal:0x2be37d8>

    irb(main):007:0> tiger1.equal?(tiger2)
    => true

    irb(main):008:0> tiger1 = nil
    => nil

    irb(main):009:0> GC.start
    => nil

    irb(main):010:0> tiger.get_name()
    => "tiger1"
    irb(main):011:0>

    +
    $ irb
    +irb(main):001:0> require 'example'
    +=> true
     
    +irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    +=> #<Example::Animal:0x2be37d8>
     
    +irb(main):003:0> zoo = Example::Zoo.new()
    +=> #<Example::Zoo:0x2be0a18>
     
    +irb(main):004:0> zoo.add_animal(tiger1)
    +=> nil
     
    +irb(main):006:0> tiger2 = zoo.remove_animal(0)
    +=> #<Example::Animal:0x2be37d8>
     
    +irb(main):007:0> tiger1.equal?(tiger2)
    +=> true
    +
    +irb(main):008:0> tiger1 = nil
    +=> nil
    +
    +irb(main):009:0> GC.start
    +=> nil
    +
    +irb(main):010:0> tiger.get_name()
    +=> "tiger1"
    +irb(main):011:0>
    - - - -

    For those who are interested, object tracking is implemented by storing Ruby objects in a hash table and keying them on C++ -pointers. The underlying API is:
    - - - - +pointers. The underlying API is:

    - - - -
    -
    static void SWIG_RubyAddTracking(void* ptr, VALUE object);
    static VALUE SWIG_RubyInstanceFor(void* ptr) ;
    static void SWIG_RubyRemoveTracking(void* ptr);
    static void SWIG_RubyUnlinkObjects(void* ptr);
    - - - - - +
    static void SWIG_RubyAddTracking(void* ptr, VALUE object);
    +static VALUE SWIG_RubyInstanceFor(void* ptr) ;
    +static void SWIG_RubyRemoveTracking(void* ptr);
    +static void SWIG_RubyUnlinkObjects(void* ptr);
    - - - -

    When an object is created, SWIG will automatically call the SWIG_RubyAddTracking method. Similarly, when an object is deleted, SWIG will call the SWIG_RubyRemoveTracking. When an object is returned to Ruby from C++, SWIG will use the SWIG_RubyInstanceFor @@ -10295,58 +4986,49 @@ method to ensure a one-to-one mapping from Ruby to C++ objects. Last, the RubyUnlinkObjects method unlinks a Ruby object from its underlying C++ object.

    - - - -

    In general, you will only need to use the SWIG_RubyInstanceFor, which is required for implementing mark functions as shown below. However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

    - - - -

    36.10.4 Mark Functions

    With a bit more testing, we see that our class library still -has problems. For example:
    - - - - +has problems. For example:

    - - - -
    -
    $ irb
    irb(main):001:0> require 'example'
    => true

    irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    => #<Example::Animal:0x2bea6a8>

    irb(main):003:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2be7960>

    irb(main):004:0> zoo.add_animal(tiger1)
    => nil

    irb(main):007:0> tiger1 = nil
    => nil

    irb(main):007:0> GC.start
    => nil

    irb(main):005:0> tiger2 = zoo.get_animal(0)
    (irb):12: [BUG] Segmentation fault
    +
    $ irb
    +irb(main):001:0> require 'example'
    +=> true
     
    +irb(main):002:0> tiger1 = Example::Animal.new("tiger1")
    +=> #<Example::Animal:0x2bea6a8>
     
    +irb(main):003:0> zoo = Example::Zoo.new()
    +=> #<Example::Zoo:0x2be7960>
     
    +irb(main):004:0> zoo.add_animal(tiger1)
    +=> nil
     
    +irb(main):007:0> tiger1 = nil
    +=> nil
     
    +irb(main):007:0> GC.start
    +=> nil
    +
    +irb(main):005:0> tiger2 = zoo.get_animal(0)
    +(irb):12: [BUG] Segmentation fault
    - - - -

    The problem is that Ruby does not know that the zoo object contains a reference to a Ruby object. Thus, when Ruby garbage -collects tiger1 +collects tiger1 it frees the underlying C++ object.

    - - - -

    This can be fixed by implementing a mark function as described above in the Mark and Sweep Garbage Collector section. You can specify a mark @@ -10356,10 +5038,6 @@ SWIG's' "features" mechanism it uses the same name matching rules as other kinds of features (see the chapter on "Customization Features" for more details).

    - - - -

    A mark function takes a single argument, which is a pointer to the C++ object being marked; it should, in turn, call rb_gc_mark() for any instances that are @@ -10369,64 +5047,80 @@ objects in the zoo object, look up their Ruby object equivalent, and then call rb_gc_mark(). One possible implementation is:

    - - - -
    -
    %module example

    %{
    #include "example.h"
    %}

    /* Keep track of mappings between C/C++ structs/classes
    and Ruby objects so we can implement a mark function. */
    %trackobjects;

    /* Specify the mark function */
    %markfunc Zoo "mark_Zoo";

    %include "example.h"

    %header %{

    static void mark_Zoo(void* ptr) {
    Zoo* zoo = (Zoo*) ptr;

    /* Loop over each object and tell the garbage collector
    that we are holding a reference to them. */
    int count = zoo->get_num_animals();

    for(int i = 0; i < count; ++i) {
    Animal* animal = zoo->get_animal(i);
    VALUE object = SWIG_RubyInstanceFor(animal);

    if (object != Qnil) {
    rb_gc_mark(object);
    }
    }
    }
    %}

    +
    %module example
     
    +%{
    +#include "example.h"
    +%}
     
    +/* Keep track of mappings between C/C++ structs/classes
    + and Ruby objects so we can implement a mark function. */
    +%trackobjects;
     
    +/* Specify the mark function */
    +%markfunc Zoo "mark_Zoo";
     
    +%include "example.h"
     
    +%header %{
    +
    +static void mark_Zoo(void* ptr) {
    +  Zoo* zoo = (Zoo*) ptr;
    + 
    +  /* Loop over each object and tell the garbage collector
    +  that we are holding a reference to them. */
    +  int count = zoo->get_num_animals();
    + 
    +  for(int i = 0; i < count; ++i) {
    +    Animal* animal = zoo->get_animal(i);
    +    VALUE object = SWIG_RubyInstanceFor(animal);
    + 
    +    if (object != Qnil) {
    +      rb_gc_mark(object);
    +    }
    +  }
    +}
    +%}
    - - - -

    Note the mark function is dependent on the SWIG_RUBY_InstanceFor method, and thus requires that %trackobjects is enabled. For more information, please refer to the track_object.i test case in the SWIG test suite.

    - - - -

    When this code is compiled we now see:

    - - - -
    -
    $ irb
    irb(main):002:0> tiger1=Example::Animal.new("tiger1")
    => #<Example::Animal:0x2be3bf8>

    irb(main):003:0> Example::Zoo.new()
    => #<Example::Zoo:0x2be1780>

    irb(main):004:0> zoo = Example::Zoo.new()
    => #<Example::Zoo:0x2bde9c0>

    irb(main):005:0> zoo.add_animal(tiger1)
    => nil

    irb(main):009:0> tiger1 = nil
    => nil

    irb(main):010:0> GC.start
    => nil
    irb(main):014:0> tiger2 = zoo.get_animal(0)
    => #<Example::Animal:0x2be3bf8>

    irb(main):015:0> tiger2.get_name()
    => "tiger1"
    irb(main):016:0>

    +
    $ irb
    +irb(main):002:0> tiger1=Example::Animal.new("tiger1")
    +=> #<Example::Animal:0x2be3bf8>
     
    +irb(main):003:0> Example::Zoo.new()
    +=> #<Example::Zoo:0x2be1780>
     
    +irb(main):004:0> zoo = Example::Zoo.new()
    +=> #<Example::Zoo:0x2bde9c0>
     
    +irb(main):005:0> zoo.add_animal(tiger1)
    +=> nil
     
    +irb(main):009:0> tiger1 = nil
    +=> nil
     
    +irb(main):010:0> GC.start
    +=> nil
    +irb(main):014:0> tiger2 = zoo.get_animal(0)
    +=> #<Example::Animal:0x2be3bf8>
    +
    +irb(main):015:0> tiger2.get_name()
    +=> "tiger1"
    +irb(main):016:0>
    - - - - -
    - - - - -

    This code can be seen in swig/examples/ruby/mark_function.

    - - - -

    36.10.5 Free Functions

    @@ -10434,10 +5128,6 @@ test suite.

    a Ruby object is garbage collected. The free function simply calls the C++ object's destructor.

    - - - -

    However, sometimes an appropriate destructor does not exist or special processing needs to be performed before the destructor is called. Therefore, SWIG allows you to manually specify a "free" @@ -10447,10 +5137,6 @@ SWIG's' "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    - - - -

    IMPORTANT ! - If you define your own free function, then you must ensure that you call the underlying C++ object's destructor. In addition, if object tracking is activated for the object's class, you @@ -10459,10 +5145,6 @@ function (of course call this before you destroy the C++ object). Note that it is harmless to call this method if object tracking if off so it is advised to always call it.

    - - - -

    Note there is a subtle interaction between object ownership and free functions. A custom defined free function will only be called if the Ruby object owns the underlying C++ object. This also to Ruby @@ -10470,21 +5152,13 @@ objects which are created, but then transfer ownership to C++ objects via the use of the disown typemap described above.

    - - - -

    To show how to use the %freefunc directive, let's slightly change our example. Assume that the zoo object is responsible for freeing animal that it contains. This means -that the Zoo::add_animal -function should be marked with a DISOWN typemap +that the Zoo::add_animal +function should be marked with a DISOWN typemap and the destructor should be updated as below:

    - - - -
    Zoo::~Zoo() {
      IterType iter = this->animals.begin();
    @@ -10495,23 +5169,10 @@ and the destructor should be updated as below:

    delete animal; } }
    - - - - -
    - - - -

    When we use these objects in IRB we see:

    - - - -
    $irb
     irb(main):002:0> require 'example'
    @@ -10534,19 +5195,9 @@ irb(main):008:0> GC.start
     
     irb(main):009:0> tiger1.get_name()
     (irb):12: [BUG] Segmentation fault
    -
     
    - - - - -
    - - - -

    The error happens because the C++ animal object is freed when the zoo object is freed. Although this error is unavoidable, we can at least prevent the @@ -10555,18 +5206,9 @@ implementing a custom free function that calls the SWIG_RubyUnlinkObjectsSWIG_RubyUnlinkObjects function notifies SWIG that a Ruby object's underlying C++ object is no longer valid. Once notified, SWIG will intercept any calls from the -existing Ruby object to the destroyed C++ object and raise an exception.
    - - - - - +existing Ruby object to the destroyed C++ object and raise an exception.

    - - - -
    %module example
     
    @@ -10587,47 +5229,33 @@ existing Ruby object to the destroyed C++ object and raise an exception.
    %include "example.h" %header %{ - static void free_Zoo(void* ptr) { - Zoo* zoo = (Zoo*) ptr; + static void free_Zoo(void* ptr) { + Zoo* zoo = (Zoo*) ptr; - /* Loop over each animal */ - int count = zoo->get_num_animals(); + /* Loop over each animal */ + int count = zoo->get_num_animals(); - for(int i = 0; i < count; ++i) { - /* Get an animal */ - Animal* animal = zoo->get_animal(i); + for(int i = 0; i < count; ++i) { + /* Get an animal */ + Animal* animal = zoo->get_animal(i); - /* Unlink the Ruby object from the C++ object */ - SWIG_RubyUnlinkObjects(animal); + /* Unlink the Ruby object from the C++ object */ + SWIG_RubyUnlinkObjects(animal); - /* Now remove the tracking for this animal */ - SWIG_RubyRemoveTracking(animal); - } + /* Now remove the tracking for this animal */ + SWIG_RubyRemoveTracking(animal); + } - /* Now call SWIG_RubyRemoveTracking for the zoo */ - SWIG_RubyRemoveTracking(ptr); - - /* Now free the zoo which will free the animals it contains */ - delete zoo; - } + /* Now call SWIG_RubyRemoveTracking for the zoo */ + SWIG_RubyRemoveTracking(ptr); + /* Now free the zoo which will free the animals it contains */ + delete zoo; + } %}
    - - - - -
    - - - -

    Now when we use these objects in IRB we see:

    - - - -
    $irb
     irb(main):002:0> require 'example'
    @@ -10653,159 +5281,82 @@ RuntimeError: This Animal * already released
      from (irb):10:in `get_name'
      from (irb):10
     irb(main):011:0>
    - - - - -
    - - - -

    Notice that SWIG can now detect the underlying C++ object has been freed, and thus raises a runtime exception.

    - - - -

    This code can be seen in swig/examples/ruby/free_function.

    - - - -

    36.10.6 Embedded Ruby and the C++ Stack

    As has been said, the Ruby GC runs and marks objects before its -sweep phase.  When the garbage collector is called, it will +sweep phase. When the garbage collector is called, it will also try to mark any Ruby objects (VALUE) it finds in the machine registers and in the C++ stack.

    - - - -

    The stack is basically the history of the functions that have been called and also contains local variables, such as the ones you define whenever you do inside a function:

    - - - -
    VALUE obj;
    - - - -

    For ruby to determine where its stack space begins, during initialization a normal Ruby interpreter will call the ruby_init() function which in turn will call a function called Init_stack or -similar.  This function will store a pointer to the location +similar. This function will store a pointer to the location where the stack points at that point in time.

    - - - -

    ruby_init() is presumed to always be called within the main() function of your program and whenever the GC is called, ruby will assume that the memory between the current location in memory and the pointer that was stored previously represents the stack, which may -contain local (and temporary) VALUE ruby objects.   Ruby will +contain local (and temporary) VALUE ruby objects. Ruby will then be careful not to remove any of those objects in that location.

    - - - - -

    So far so good.  For a normal Ruby session, all the +

    So far so good. For a normal Ruby session, all the above is completely transparent and magic to the extensions developer. -  

    - - - - +

    However, with an embedded Ruby, it may not always be possible to -modify main() to make sure ruby_init() is called there.   As +modify main() to make sure ruby_init() is called there. As such, ruby_init() will likely end up being called from within some other -function.  This can lead Ruby to measure incorrectly where the -stack begins and can result in Ruby incorrectly collecting +function. This can lead Ruby to measure incorrectly where the +stack begins and can result in Ruby incorrectly collecting those -temporary VALUE objects that are created once another function +temporary VALUE objects that are created once another function is -called.  The end result: random crashes and segmentation +called. The end result: random crashes and segmentation faults.

    - - - -

    This problem will often be seen in director functions that are -used for callbacks, for example.  

    - - - - +used for callbacks, for example.

    To solve the problem, SWIG can now generate code with director -functions containing the optional macros SWIG_INIT_STACK and -SWIG_RELEASE_STACK.   These macros will try to force Ruby to -reinitiliaze the beginning of the stack the first time a +functions containing the optional macros SWIG_INIT_STACK and +SWIG_RELEASE_STACK. These macros will try to force Ruby to +reinitiliaze the beginning of the stack the first time a director -function is called.  This will lead Ruby to measure and not -collect any VALUE objects defined from that point on.  

    - - - - +function is called. This will lead Ruby to measure and not +collect any VALUE objects defined from that point on.

    To mark functions to either reset the ruby stack or not, you can use:

    - - - - -
    %initstack -  Class::memberfunction;  // only re-init the stack -in this director method
    - - - - - -%ignorestack Class::memberfunction;  // do not re-init the -stack in this director method
    - - - - - -%initstack   Class;       -        // init the stack on all -the methods of this class
    - - - - - -%initstack;   // all director functions will -re-init the stack
    - +
    +%initstack Class::memberfunction;   // only re-init the stack in this director method
    +%ignorestack Class::memberfunction; // do not re-init the stack in this director method
    +%initstack Class;                   // init the stack on all the methods of this class
    +%initstack;                         // all director functions will re-init the stack
    +
    diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 58a3c8e55..f9ea5b2ef 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -258,7 +258,7 @@ this option the default output directory is the path to the input file. If -o and -outcurrentdir are used together, -outcurrentdir is effectively ignored as the output directory for the language files is the same directory as the -generated C/C++ file if not overidden with -outdir. +generated C/C++ file if not overridden with -outdir.

    5.1.3 Comments

    @@ -2699,7 +2699,7 @@ the following declaration :

     /* file : vector.h */
     ...
    -typedef struct {
    +typedef struct Vector {
     	double x,y,z;
     } Vector;
     
    @@ -2772,7 +2772,7 @@ of the Vector structure. For example:

    #include "vector.h" %} -typedef struct { +typedef struct Vector { double x,y,z; %extend { Vector(double x, double y, double z) { ... } @@ -2783,7 +2783,7 @@ typedef struct {

    -Finally, %extend can be used to access externally written +Note that %extend can be used to access externally written functions provided they follow the naming convention used in this example :

    @@ -2814,7 +2814,7 @@ double Vector_magnitude(Vector *v) { #include "vector.h" %} -typedef struct { +typedef struct Vector { double x,y,z; %extend { Vector(int,int,int); // This calls new_Vector() @@ -2826,6 +2826,37 @@ typedef struct {
    +

    +The name used for %extend should be the name of the struct and not the name of any typedef to the struct. +For example: +

    + +
    +typedef struct Integer {
    +	int value;
    +} Int;
    +%extend Integer { ...  } /* Correct name */
    +%extend Int { ...  } /* Incorrect name */
    +
    +struct Float {
    +	float value;
    +};
    +typedef struct Float FloatValue;
    +%extend Float { ...  } /* Correct name */
    +%extend FloatValue { ...  } /* Incorrect name */
    +
    + +

    +There is one exception to this rule and that is when the struct is anonymously named such as: +

    + +
    +typedef struct {
    +	double value;
    +} Double;
    +%extend Double { ...  } /* Okay */
    +
    +

    A little known feature of the %extend directive is that it can also be used to add synthesized attributes or to modify the @@ -2862,7 +2893,7 @@ For example, consider this interface:

    -typedef struct {
    +typedef struct Person {
       char name[50];
       ...
     } Person;
    @@ -2876,7 +2907,7 @@ the interface as follows to ensure this occurs whenever a name is read or writte
     
     
    -typedef struct {
    +typedef struct Person {
       %extend {
         char name[50];
       }
    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
    index 716882f53..2713725d7 100644
    --- a/Doc/Manual/SWIGPlus.html
    +++ b/Doc/Manual/SWIGPlus.html
    @@ -4433,7 +4433,7 @@ around some other class.  For example:
     template<class T> class SmartPtr {
         T *pointee;
     public:
    -    ...
    +    SmartPtr(T *p) : pointee(p) { ... }
         T *operator->() {
             return pointee;
         }
    @@ -4453,7 +4453,7 @@ typedef SmartPtr<Foo_Impl> Foo;
     
     // Create smart pointer Foo
     Foo make_Foo() {
    -    return SmartPtr(new Foo_Impl());
    +    return SmartPtr<Foo_Impl>(new Foo_Impl());
     }
     
     // Do something with smart pointer Foo
    @@ -4461,6 +4461,9 @@ void do_something(Foo f) {
         printf("x = %d\n", f->x);
         f->bar();
     }
    +
    +// Call the wrapped smart pointer proxy class in the target language 'Foo'
    +%template(Foo) SmartPtr<Foo_Impl>;
     
    diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 9e4a3dd17..195111424 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -1,12 +1,12 @@ -SWIG-2.0 Documentation +SWIG-3.0 Documentation -

    SWIG-2.0 Documentation

    +

    SWIG-3.0 Documentation

    -Last update : SWIG-2.0.10 (in progress) +Last update : SWIG-3.0.0 (in progress)

    Sections

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index b3b0bc7a9..81e3fd1bb 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -773,7 +773,7 @@ Here are some examples of valid typemap specifications: } /* Typemap with modifiers */ -%typemap(in,doc="integer") int "$1 = gh_scm2int($input);"; +%typemap(in,doc="integer") int "$1 = scm_to_int($input);"; /* Typemap applied to patterns of multiple arguments */ %typemap(in) (char *str, int len), diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 13abc8cee..9564fe00b 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -398,7 +398,7 @@ int execlp(const char *path, const char *arg, ...);

    -Note that str3 is the name of the last argument, as we have used %vargars with 3. +Note that str3 is the name of the last argument, as we have used %varargs with 3. Now execlp("a", "b", "c", "d", "e") will result in an error as one too many arguments has been passed, as now only 2 additional 'str' arguments can be passed with the 3rd one always using the specified default NULL.

    @@ -509,10 +509,10 @@ like this:
    -%typemap(in) (...)(char *args[10]) {
    +%typemap(in) (...)(char *vargs[10]) {
       int i;
       int argc;
    -  for (i = 0; i < 10; i++) args[i] = 0;
    +  for (i = 0; i < 10; i++) vargs[i] = 0;
       argc = PyTuple_Size(varargs);
       if (argc > 10) {
         PyErr_SetString(PyExc_ValueError, "Too many arguments");
    @@ -528,7 +528,7 @@ like this:
            return NULL;
         }
         pystr = PyUnicode_AsUTF8String(pyobj);
    -    str = PyBytes_AsString(pystr);
    +    str = strdup(PyBytes_AsString(pystr));
         Py_XDECREF(pystr);
     %#else  
         if (!PyString_Check(pyobj)) {
    @@ -537,22 +537,34 @@ like this:
         }
         str = PyString_AsString(pyobj);
     %#endif
    -    args[i] = str;
    +    vargs[i] = str;
       }
    -  $1 = (void *) args;
    +  $1 = (void *)vargs;
    +}
    +
    +%typemap(freearg) (...) {
    +%#if PY_VERSION_HEX>=0x03000000
    +  int i;
    +  for (i = 0; i < 10; i++) {
    +    free(vargs$argnum[i]);
    +  }
    +%#endif
     }
     

    -In this typemap, the special variable varargs is a tuple +In the 'in' typemap, the special variable varargs is a tuple holding all of the extra arguments passed (this is specific to the Python module). The typemap then pulls this apart and sticks the values into the array of strings args. Then, the array is assigned to $1 (recall that this is the void * variable corresponding to (...)). However, this assignment is only half of the picture----clearly this alone is not enough to -make the function work. To patch everything up, you have to rewrite the +make the function work. The 'freearg' typemap cleans up memory +allocated in the 'in' typemap; this code is generated to be called +after the execlp function is called. To patch everything +up, you have to rewrite the underlying action code using the %feature directive like this:

    @@ -560,9 +572,9 @@ this:
     %feature("action") execlp {
    -   char *args = (char **) arg3;
    -   result = execlp(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
    -                   args[5],args[6],args[7],args[8],args[9], NULL);
    +  char **vargs = (char **) arg3;
    +  result = execlp(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4],
    +                  vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL);
     }
     
     int execlp(const char *path, const char *arg, ...);
    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
    index d8e76a471..aac415952 100644
    --- a/Doc/Manual/Warnings.html
    +++ b/Doc/Manual/Warnings.html
    @@ -423,7 +423,8 @@ example.i(4) : Syntax error in input.
     
  • 322. Redundant redeclaration of 'name'.
  • 323. Recursive scope inheritance of 'name'.
  • 324. Named nested template instantiations not supported. Processing as if no name was given to %template(). -
  • 325. Nested class not currently supported (name ignored). +
  • 325. Nested kind not currently supported (name ignored). +
  • 326. Deprecated %extend name used - the kind name 'name' should be used instead of the typedef name 'name'.
  • 350. operator new ignored.
  • 351. operator delete ignored.
  • 352. operator+ ignored. @@ -527,6 +528,8 @@ example.i(4) : Syntax error in input.
  • 519. %template() contains no name. Template method ignored: declaration
  • 520. Base/Derived class 'classname1' of 'classname2' is not similarly marked as a smart pointer.
  • 521. Illegal destructor name name. Ignored. +
  • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'. +
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.

    14.9.6 Language module specific (700-899)

    diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index c94a3da3b..c8467c78a 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -147,7 +147,7 @@ PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib

    -PYTHON_INCLUDE : Set this to the directory that contains python.h
    +PYTHON_INCLUDE : Set this to the directory that contains Python.h
    PYTHON_LIB : Set this to the python library including path for linking

    Example using Python 2.1.1:
    diff --git a/Doc/Manual/margin-left.patch b/Doc/Manual/margin-left.patch index 70f087b92..8bef6305c 100644 --- a/Doc/Manual/margin-left.patch +++ b/Doc/Manual/margin-left.patch @@ -1,25 +1,66 @@ -# -# Patch managed by http://www.holgerschurig.de/patcher.html -# -# This patch is against htmldoc 1.8.24, and it hacks in support for +# This patch is against htmldoc 1.8.27, and it hacks in support for # correctly indenting the

    sections in the SWIG manual. # This patch should only be used until the 1.9 branch of htmldoc -# stabalizes, since the 1.9 branch includes true CSS1 support. +# stabilizes, since the 1.9 branch includes true CSS1 support. # # This patch only affects the PDF generation, an unpatched htmldoc # creates the one-page html documentation just fine. # ---- htmldoc-1.8.24/htmldoc/ps-pdf.cxx~margin-left -+++ htmldoc-1.8.24/htmldoc/ps-pdf.cxx -@@ -158,6 +158,7 @@ +diff -Naur htmldoc-1.8.27/htmldoc/htmldoc.cxx htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx +--- htmldoc-1.8.27/htmldoc/htmldoc.cxx 2006-03-30 14:01:20.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx 2013-05-11 10:11:47.428435647 +0100 +@@ -65,6 +65,8 @@ + const char *__XOS2RedirRoot(const char *); + } + #endif ++ ++extern void parse_style(char *); + + + /* +@@ -1115,6 +1117,7 @@ + else if (compare_strings(argv[i], "--version", 6) == 0) + { + puts(SVERSION); ++ puts("Patched with margin-left.patch"); + return (0); + } + else if (compare_strings(argv[i], "--webpage", 3) == 0) +@@ -2403,6 +2406,10 @@ + } + else if (strcmp(temp, "--cookies") == 0) + file_cookies(temp2); ++ else if (strcmp(temp, "--stylesheet") == 0) ++ { ++ parse_style(temp2); ++ } + } + } + +diff -Naur htmldoc-1.8.27/htmldoc/Makefile htmldoc-1.8.27-margin-left/htmldoc/Makefile +--- htmldoc-1.8.27/htmldoc/Makefile 2005-10-28 21:32:59.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/Makefile 2013-05-11 09:39:04.392367869 +0100 +@@ -36,7 +36,7 @@ + OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o \ + http.o http-addr.o http-addrlist.o http-support.o image.o \ + iso8859.o license.o md5.o progress.o ps-pdf.o rc4.o \ +- snprintf.o string.o toc.o util.o ++ snprintf.o string.o toc.o util.o style.o + + + # +diff -Naur htmldoc-1.8.27/htmldoc/ps-pdf.cxx htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx +--- htmldoc-1.8.27/htmldoc/ps-pdf.cxx 2006-08-01 17:58:50.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx 2013-05-11 09:37:40.096364957 +0100 +@@ -160,6 +160,7 @@ # undef page_t #endif // __hpux +extern int lookup_div_class(uchar *); /* - * Constants... -@@ -4188,9 +4189,24 @@ + * Output options... +@@ -4230,9 +4231,24 @@ para->child = para->last_child = NULL; } @@ -45,30 +86,9 @@ if (para->child != NULL) { parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace); ---- htmldoc-1.8.24/htmldoc/htmldoc.cxx~margin-left -+++ htmldoc-1.8.24/htmldoc/htmldoc.cxx -@@ -62,6 +62,8 @@ - const char *__XOS2RedirRoot(const char *); - } - #endif -+ -+extern void parse_style(char *); - - - /* -@@ -2140,6 +2142,10 @@ - } - else if (strcmp(temp, "--cookies") == 0) - file_cookies(temp2); -+ else if (strcmp(temp, "--stylesheet") == 0) -+ { -+ parse_style(temp2); -+ } - } - } - ---- /dev/null -+++ htmldoc-1.8.24/htmldoc/style.cxx +diff -Naur htmldoc-1.8.27/htmldoc/style.cxx htmldoc-1.8.27-margin-left/htmldoc/style.cxx +--- htmldoc-1.8.27/htmldoc/style.cxx 1970-01-01 01:00:00.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/style.cxx 2013-05-11 09:37:40.096364957 +0100 @@ -0,0 +1,185 @@ +/* Extreamly simple parsing routines for CSS style sheets. + * We only parse div.class { } sections, and only look @@ -255,15 +275,3 @@ + + fclose(f); +} ---- htmldoc-1.8.24/htmldoc/Makefile~margin-left -+++ htmldoc-1.8.24/htmldoc/Makefile -@@ -35,7 +35,7 @@ - - OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o http.o \ - http-addr.o http-support.o image.o iso8859.o license.o md5.o \ -- progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o -+ progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o style.o - - - # - diff --git a/Examples/Makefile.in b/Examples/Makefile.in index c5e525c17..b6712378b 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -25,7 +25,7 @@ TARGET = CC = @CC@ CXX = @CXX@ CFLAGS = @PLATCFLAGS@ -CXXFLAGS = @PLATCXXFLAGS@ +CXXFLAGS = @BOOST_CPPFLAGS@ @PLATCXXFLAGS@ prefix = @prefix@ exec_prefix= @exec_prefix@ SRCS = @@ -47,17 +47,37 @@ LIBPREFIX = RUNTOOL = # COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing COMPILETOOL= +# RUNPIPE is for piping output of running interpreter/compiled code somewhere, eg RUNPIPE=\>/dev/null +RUNPIPE= -# X11 options - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ +RUNME = runme IWRAP = $(INTERFACE:.i=_wrap.i) ISRCS = $(IWRAP:.i=.c) ICXXSRCS = $(IWRAP:.i=.cxx) IOBJS = $(IWRAP:.i=.@OBJEXT@) +################################################################## +# Some options for silent output +################################################################## + +ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS)))) + # make -s detected + SILENT=1 +else + SILENT= +endif + +ifneq (,$(SILENT)) + SILENT_OPTION = -s + SILENT_PIPE = >/dev/null + ANT_QUIET = -q -logfile /dev/null +else + SILENT_OPTION = + SILENT_PIPE = + ANT_QUIET = +endif + ################################################################## # Dynamic loading for C++ # If you are going to be building dynamic loadable modules in C++, @@ -87,7 +107,6 @@ OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@) distclean: rm -f Makefile - rm -f guile/Makefile rm -f xml/Makefile ################################################################## @@ -96,6 +115,7 @@ distclean: # Set these to your local copy of Tcl/Tk. +TCLSH = tclsh TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ TCL_OPTS = @LIBS@ @@ -106,12 +126,12 @@ TCL_DLNK = @TCLDYNAMICLINKING@ TCL_SO = @TCL_SO@ TCLLDSHARED = @TCLLDSHARED@ TCLCXXSHARED = @TCLCXXSHARED@ +TCL_SCRIPT = $(RUNME).tcl # ----------------------------------------------------------- # Build a new version of the tclsh shell # ----------------------------------------------------------- - tclsh: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ @@ -122,21 +142,6 @@ tclsh_cpp: $(SRCS) $(CXX) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) -# ----------------------------------------------------------- -# Build a new copy of wish -# ----------------------------------------------------------- - -wish: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) - $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ - $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) - - -wish_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) - $(CXX) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ - $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) - # ----------------------------------------------------------- # Build a Tcl dynamic loadable module (you might need to tweak this) # ----------------------------------------------------------- @@ -155,6 +160,20 @@ tcl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) +# ----------------------------------------------------------------- +# Run Tcl example +# ----------------------------------------------------------------- + +tcl_run: + $(RUNTOOL) $(TCLSH) $(TCL_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +tcl_version: + echo 'puts $$tcl_version;exit 0' | $(TCLSH) + # ----------------------------------------------------------------- # Cleaning the Tcl examples # ----------------------------------------------------------------- @@ -177,6 +196,12 @@ PERL5_INCLUDE= @PERL5EXT@ # Extra Perl specific dynamic linking options PERL5_DLNK = @PERL5DYNAMICLINKING@ PERL5_CCFLAGS = @PERL5CCFLAGS@ +PERL5_CCDLFLAGS = @PERL5CCDLFLAGS@ +PERL5_CCCDLFLAGS = @PERL5CCCDLFLAGS@ +PERL5_LDFLAGS = @PERL5LDFLAGS@ +PERL = @PERL@ +PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) +PERL5_SCRIPT = $(RUNME).pl # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C) @@ -184,8 +209,8 @@ PERL5_CCFLAGS = @PERL5CCFLAGS@ perl5: $(SRCS) $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) + $(LDSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C++) @@ -193,8 +218,8 @@ perl5: $(SRCS) perl5_cpp: $(SRCS) $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) - $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) + $(CXXSHARED) $(CXXFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a module from existing XS C source code. (ie. from xsubpp). @@ -207,8 +232,6 @@ perl5_xs: $(SRCS) # Build a statically linked Perl5 executable # ---------------------------------------------------------------- -PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) - perl5_static: $(SRCS) $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) @@ -217,6 +240,20 @@ perl5_static_cpp: $(SRCS) $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) +# ----------------------------------------------------------------- +# Running a Perl5 example +# ----------------------------------------------------------------- + +perl5_run: + $(RUNTOOL) $(PERL) $(PERL5_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +perl5_version: + $(PERL) -v | grep "This is" + # ----------------------------------------------------------------- # Cleaning the Perl5 examples # ----------------------------------------------------------------- @@ -302,20 +339,27 @@ python_static_cpp: $(SRCS) # ----------------------------------------------------------------- ifeq (,$(PY3)) - PYSCRIPT = runme.py + PYSCRIPT = $(RUNME).py else - PYSCRIPT = runme3.py + PYSCRIPT = $(RUNME)3.py endif PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` python_run: $(PYSCRIPT) - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null + $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE) -runme3.py: runme.py +$(RUNME)3.py: $(RUNME).py cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +python_version: + $(PYTHON) -V + # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- @@ -325,7 +369,8 @@ python_clean: rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@ - if [ -f runme.py ]; then rm -f runme3.py runme3.py.bak; fi + rm -f $(TARGET).py + if [ -f $(RUNME).py ]; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi ################################################################## @@ -333,13 +378,15 @@ python_clean: ################################################################## # Make sure these locate your Octave installation -OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@ -qfH +OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@ OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@ # Extra Octave specific dynamic linking options OCTAVE_DLNK = @OCTAVE_LDFLAGS@ OCTAVE_SO = @OCTAVE_SO@ +OCTAVE_SCRIPT = $(RUNME).m + # ---------------------------------------------------------------- # Build a C dynamically loadable module # Note: Octave requires C++ compiler when compiling C wrappers @@ -364,13 +411,18 @@ octave_cpp: $(SRCS) # Running an Octave example # ----------------------------------------------------------------- -OCTSCRIPT = runme.m - -octave_run: $(OCTSCRIPT) - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(OCTAVE) $(OCTSCRIPT) >/dev/null +octave_run: + $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- -# Cleaning the octave examples +# Version display +# ----------------------------------------------------------------- + +octave_version: + $(OCTAVE) --version | head -n 1 + +# ----------------------------------------------------------------- +# Cleaning the Octave examples # ----------------------------------------------------------------- octave_clean: @@ -384,81 +436,81 @@ octave_clean: ################################################################## # Make sure these locate your Guile installation -GUILE_INCLUDE = @GUILEINCLUDE@ -GUILE_LIB = @GUILELIB@ +GUILE = @GUILE@ +GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_SO = @GUILE_SO@ +GUILE_LIBS = @GUILE_LIBS@ +GUILE_LIBOPTS = @LIBS@ $(SYSLIBS) GUILE_LIBPREFIX = lib +GUILE_SCRIPT = $(RUNME).scm #------------------------------------------------------------------ -# Build a dynamically loaded module with passive linkage and the scm interface +# Build a dynamically loaded module with passive linkage #------------------------------------------------------------------ guile: $(SRCS) - $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) + $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) -guile_cpp: $(SRCS) - $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) +guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) +$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS) + $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@ guile_externalhdr: $(SWIG) -guile -external-runtime $(TARGET) -#------------------------------------------------------------------ -# Build a dynamically loaded module with passive linkage and the gh interface -#------------------------------------------------------------------ -guile_gh: $(SRCS) - $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - -guile_gh_cpp: $(SRCS) - $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - # ----------------------------------------------------------------- -# Build a dynamically loadable module with passive linkage +# Build Guile interpreter augmented with extra functions # ----------------------------------------------------------------- -guile_passive: $(SRCS) - $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - -guile_passive_cpp: $(SRCS) - $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) +guile_augmented: + $(SWIG) -guile $(SWIGOPT) $(INTERFACE) + $(CC) $(CXXFLAGS) $(SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- # Build statically linked Guile interpreter # ----------------------------------------------------------------- -GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) - guile_static: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCS) $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ - $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile + +# ----------------------------------------------------------------- +# Running a Guile example +# ----------------------------------------------------------------- + +guile_run: + env GUILE_AUTO_COMPILE=0 $(RUNTOOL) $(GUILE) -l $(GUILE_SCRIPT) $(RUNPIPE) + +guile_augmented_run: + env GUILE_AUTO_COMPILE=0 $(RUNTOOL) ./$(TARGET) $(GUILE_RUNOPTIONS) -s $(GUILE_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +guile_version: + $(GUILE) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the Guile examples @@ -485,6 +537,8 @@ JAVASO =@JAVASO@ JAVALDSHARED = @JAVALDSHARED@ JAVACXXSHARED = @JAVACXXSHARED@ JAVACFLAGS = @JAVACFLAGS@ +JAVA = @JAVA@ +JAVAC = @JAVAC@ # ---------------------------------------------------------------- # Build a java dynamically loadable module (C) @@ -504,15 +558,92 @@ java_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) +# ---------------------------------------------------------------- +# Compile java files +# ---------------------------------------------------------------- + +java_compile: $(SRCS) + $(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(JAVASRCS) + +# ----------------------------------------------------------------- +# Run java example +# ----------------------------------------------------------------- + +java_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +java_version: + $(JAVA) -version + $(JAVAC) -version || echo "Unknown javac version" + # ----------------------------------------------------------------- # Cleaning the java examples # ----------------------------------------------------------------- java_clean: - rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java` + rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v $(RUNME).java` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ +################################################################## +##### ANDROID ###### +################################################################## + +ANDROID = android +ANDROID_NDK_BUILD = ndk-build +ANDROID_ADB = adb +ANT = ant +TARGETID = 1 + +# ---------------------------------------------------------------- +# Build an Android dynamically loadable module (C) +# ---------------------------------------------------------------- + +android: $(SRCS) + $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(SWIG) -java $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) + +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) + $(ANT) $(ANT_QUIET) debug + +# ---------------------------------------------------------------- +# Build an Android dynamically loadable module (C++) +# ---------------------------------------------------------------- + +android_cpp: $(SRCS) + $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(SWIG) -java -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cpp $(INTERFACEPATH) + +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) + $(ANT) $(ANT_QUIET) debug + +# ---------------------------------------------------------------- +# Android install +# ---------------------------------------------------------------- + +android_install: + -$(ANDROID_ADB) uninstall $(PACKAGENAME) + $(ANDROID_ADB) install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +android_version: + $(ANDROID_ADB) version + +# ----------------------------------------------------------------- +# Cleaning the Android examples +# ----------------------------------------------------------------- + +android_clean: + ant -q -logfile /dev/null clean + rm -f $(INTERFACEDIR)$(TARGET)_wrap.* + rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` + rm -rf obj + ################################################################## ##### MODULA3 ###### ################################################################## @@ -531,6 +662,20 @@ modula3: $(SRCS) modula3_cpp: $(SRCS) $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Run modula3 example +# ----------------------------------------------------------------- + +modula3_run: + $(RUNTOOL) false $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +modula3_version: + echo "Unknown modula3 version" + # ----------------------------------------------------------------- # Cleaning the modula3 examples # ----------------------------------------------------------------- @@ -544,9 +689,11 @@ modula3_clean: ##### MZSCHEME ###### ################################################################## +MZSCHEME = mzscheme MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ +MZSCHEME_SCRIPT = $(RUNME).scm # ---------------------------------------------------------------- # Build a C/C++ dynamically loadable module @@ -562,6 +709,21 @@ mzscheme_cpp: $(SRCS) $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CXXFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) +# ----------------------------------------------------------------- +# Run mzscheme example +# ----------------------------------------------------------------- + +mzscheme_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +mzscheme_version: + $(MZSCHEME) -v + $(MZC) -v + # ----------------------------------------------------------------- # Cleaning the mzscheme examples # ----------------------------------------------------------------- @@ -698,6 +860,24 @@ ocaml_dynamic_cpp: $(SRCS) -package dl -linkpkg \ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' +# ----------------------------------------------------------------- +# Run ocaml example +# ----------------------------------------------------------------- + +ocaml_run: + $(RUNTOOL) ./$(TARGET) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +ocaml_version: + $(OCC) -version + +# ----------------------------------------------------------------- +# Cleaning the Ocaml examples +# ----------------------------------------------------------------- + ocaml_clean: rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo rm -f core @EXTRA_CLEAN@ @@ -712,6 +892,11 @@ RUBY_CFLAGS= @RUBYCCDLFLAGS@ $(DEFS) RUBY_INCLUDE= @RUBYINCLUDE@ RUBY_LIB = @RUBYLIB@ RUBY_DLNK = @RUBYDYNAMICLINKING@ +RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) +RUBY_SO = @RUBYSO@ +RUBY = @RUBY@ +RUBY_SCRIPT = $(RUNME).rb + # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -720,7 +905,7 @@ RUBY_DLNK = @RUBYDYNAMICLINKING@ ruby: $(SRCS) $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO) # ----------------------------------------------------------------- # Build a C++ dynamically loadable module @@ -729,7 +914,7 @@ ruby: $(SRCS) ruby_cpp: $(SRCS) $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE) - $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO) # ----------------------------------------------------------------- # Build statically linked Ruby interpreter @@ -738,8 +923,6 @@ ruby_cpp: $(SRCS) # library file # ----------------------------------------------------------------- -RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) - ruby_static: $(SRCS) $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ @@ -750,6 +933,19 @@ ruby_cpp_static: $(SRCS) $(CXX) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Run Ruby example +# ----------------------------------------------------------------- + +ruby_run: + $(RUNTOOL) $(RUBY) -I. $(RUBY_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +ruby_version: + $(RUBY) -v # ----------------------------------------------------------------- # Cleaning the Ruby examples @@ -764,13 +960,15 @@ ruby_clean: ##### PHP ###### ################################################################## +PHP = @PHP@ +PHP_INCLUDE = @PHPINC@ +PHP_SO = @PHP_SO@ +PHP_SCRIPT = $(RUNME).php + # ------------------------------------------------------------------- # Build a PHP dynamically loadable module (C) # ------------------------------------------------------------------- -PHP_INCLUDE = @PHPINC@ -PHP_SO = @PHP_SO@ - php: $(SRCS) $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) @@ -789,11 +987,15 @@ php_cpp: $(SRCS) # Running a PHP example # ----------------------------------------------------------------- -PHP=@PHP@ -PHPSCRIPT ?= runme.php - php_run: - $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) + $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHP_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +php_version: + $(PHP) -v | head -n 1 # ----------------------------------------------------------------- # Cleaning the PHP examples @@ -809,10 +1011,13 @@ php_clean: ################################################################## # Make sure these locate your Pike installation +PIKE = pike PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H PIKE_INCLUDE = @PIKEINCLUDE@ PIKE_LIB = @PIKELIB@ PIKE_DLNK = @PIKEDYNAMICLINKING@ +PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) +PIKE_SCRIPT = $(RUNME).pike # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -830,7 +1035,7 @@ pike: $(SRCS) pike_cpp: $(SRCS) $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) + $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ----------------------------------------------------------------- # Build statically linked Pike interpreter @@ -839,8 +1044,6 @@ pike_cpp: $(SRCS) # library file # ----------------------------------------------------------------- -PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) - pike_static: $(SRCS) $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ @@ -851,6 +1054,20 @@ pike_cpp_static: $(SRCS) $(CXX) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Run pike example +# ----------------------------------------------------------------- + +pike_run: + $(RUNTOOL) $(PIKE) $(PIKE_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +pike_version: + $(PIKE) -v 2>&1 | head -n 1 + # ----------------------------------------------------------------- # Cleaning the Pike examples # ----------------------------------------------------------------- @@ -867,11 +1084,13 @@ pike_clean: CHICKEN = @CHICKEN@ CHICKEN_CSC = @CHICKEN_CSC@ +CHICKEN_CSI = @CHICKEN_CSI@ CHICKEN_LIBOPTS = @CHICKENLIB@ $(SYSLIBS) CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS) CHICKEN_CFLAGS = @CHICKENOPTS@ CHICKENOPTS = -quiet CHICKEN_MAIN = +CHICKEN_SCRIPT = $(RUNME).scm # SWIG produces $(ISRCS) (the C wrapper file) # and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file): @@ -952,6 +1171,24 @@ chicken_cpp: chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) +# ----------------------------------------------------------------- +# Run CHICKEN example +# ----------------------------------------------------------------- + +chicken_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +chicken_version: + $(CHICKEN) -version | grep -i version + +# ----------------------------------------------------------------- +# Cleaning the CHICKEN examples +# ----------------------------------------------------------------- + chicken_clean: rm -f *_wrap* *~ .~* *_chicken* rm -f core @EXTRA_CLEAN@ @@ -968,6 +1205,7 @@ CSHARPCOMPILER = @CSHARPCOMPILER@ CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@ CSHARPCFLAGS = @CSHARPCFLAGS@ CSHARPSO = @CSHARPSO@ +CSHARP_RUNME = ./$(RUNME).exe # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C) @@ -994,6 +1232,21 @@ csharp_cpp: $(SRCS) csharp_compile: $(SRCS) $(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) +# ----------------------------------------------------------------- +# Run CSharp example +# ----------------------------------------------------------------- + +csharp_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +# Version check below also works with MS csc.exe which does not understand --version +csharp_version: + $(CSHARPCOMPILER) --version | head -n 1 + # ----------------------------------------------------------------- # Cleaning the CSharp examples # ----------------------------------------------------------------- @@ -1015,8 +1268,11 @@ LUA_LIB = @LUALINK@ LUA_DLNK = @LUADYNAMICLINKING@ LUA_SO = @LUA_SO@ +LUA = @LUABIN@ +LUA_SCRIPT = $(RUNME).lua + # Extra code for lua static link -LUA_INTERP = ../lua.c +LUA_INTERP = ../lua.c # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -1050,6 +1306,23 @@ lua_static_cpp: $(SRCS) $(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) +# ----------------------------------------------------------------- +# Run Lua example +# ----------------------------------------------------------------- + +lua_run: + $(RUNTOOL) $(LUA) $(LUA_SCRIPT) $(RUNPIPE) + +lua_embed_run: + $(RUNTOOL) ./$(TARGET) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +lua_version: + $(LUA) -v | head -n 1 + # ----------------------------------------------------------------- # Cleaning the lua examples # ----------------------------------------------------------------- @@ -1063,6 +1336,9 @@ lua_clean: ##### ALLEGRO CL ###### ################################################################## +ALLEGROCL = @ALLEGROCLBIN@ +ALLEGROCL_SCRIPT=$(RUNME).lisp + allegrocl: $(SRCS) $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1073,6 +1349,24 @@ allegrocl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run ALLEGRO CL example +# ----------------------------------------------------------------- + +allegrocl_run: + $(RUNTOOL) $(ALLEGROCL) -batch -s $(ALLEGROCL_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +allegrocl_version: + $(ALLEGROCL) --version + +# ----------------------------------------------------------------- +# Cleaning the ALLEGRO CL examples +# ----------------------------------------------------------------- + allegrocl_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1082,12 +1376,33 @@ allegrocl_clean: ##### CLISP ###### ################################################################## +CLISP = @CLISPBIN@ +CLISP_SCRIPT=$(RUNME).lisp + clisp: $(SRCS) $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_cpp: $(SRCS) $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Run CLISP example +# ----------------------------------------------------------------- + +clisp_run: + $(RUNTOOL) $(CLISP) -batch -s $(CLISP_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +clisp_version: + $(CLISP) --version | head -n 1 + +# ----------------------------------------------------------------- +# Cleaning the CLISP examples +# ----------------------------------------------------------------- + clisp_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1097,6 +1412,9 @@ clisp_clean: ##### CFFI ###### ################################################################## +CFFI = @CFFIBIN@ +CFFI_SCRIPT=$(RUNME).lisp + cffi: $(SRCS) $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1107,6 +1425,24 @@ cffi_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run CFFI example +# ----------------------------------------------------------------- + +cffi_run: + $(RUNTOOL) $(CFFI) -batch -s $(CFFI_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +cffi_version: + $(CFFI) --version + +# ----------------------------------------------------------------- +# Cleaning the CFFI examples +# ----------------------------------------------------------------- + cffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1116,6 +1452,9 @@ cffi_clean: ##### UFFI ###### ################################################################## +UFFI = @UFFIBIN@ +UFFI_SCRIPT=$(RUNME).lisp + uffi: $(SRCS) $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1126,6 +1465,24 @@ uffi_cpp: $(SRCS) # $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run UFFI example +# ----------------------------------------------------------------- + +uffi_run: + $(RUNTOOL) $(UFFI) -batch -s $(UFFI_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +uffi_version: + $(UFFI) --version + +# ----------------------------------------------------------------- +# Cleaning the UFFI examples +# ----------------------------------------------------------------- + uffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1139,11 +1496,16 @@ R = R RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx RRSRC = $(INTERFACE:.i=.R) R_CFLAGS=-fPIC +R_SCRIPT=$(RUNME).R # need to compile .cxx files outside of R build system to make sure that # we get -fPIC # CMD SHLIB stdout is piped to /dev/null to prevent echo of compiler command +# ---------------------------------------------------------------- +# Build a R dynamically loadable module (C) +# ---------------------------------------------------------------- + r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) ifneq ($(SRCS),) @@ -1151,6 +1513,10 @@ ifneq ($(SRCS),) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) +# ---------------------------------------------------------------- +# Build a R dynamically loadable module (C++) +# ---------------------------------------------------------------- + r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) ifneq ($(CXXSRCS),) @@ -1158,11 +1524,29 @@ ifneq ($(CXXSRCS),) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) +# ----------------------------------------------------------------- +# Run R example +# ----------------------------------------------------------------- + +r_run: + $(RUNTOOL) $(R) CMD BATCH $(R_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +r_version: + $(R) --version | head -n 1 + +# ----------------------------------------------------------------- +# Cleaning the R examples +# ----------------------------------------------------------------- + r_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ NAMESPACE - rm -f $(RRSRC) runme.Rout .RData + rm -f $(RRSRC) $(RUNME).Rout .RData ################################################################## ##### Go ###### @@ -1173,6 +1557,7 @@ GOGCC = @GOGCC@ GO1 = @GO1@ GOC = @GOC@ GOOPT = @GOOPT@ +GOVERSIONOPTION = @GOVERSIONOPTION@ GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi` GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` @@ -1229,14 +1614,21 @@ go_run: runme.go else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \ fi - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +go_version: + $(GO) $(GOVERSIONOPTION) # ----------------------------------------------------------------- # Cleaning the Go examples # ----------------------------------------------------------------- go_clean: - rm -f *_wrap* *_gc* .~* runme + rm -f *_wrap* *_gc* .~* runme $(GOSRCS) rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *.[568] *.a *@SO@ @@ -1258,6 +1650,8 @@ else DCOMPILER = @D1COMPILER@ endif +D_RUNME = ./$(RUNME) + # ---------------------------------------------------------------- # Build a dynamically loadable D wrapper for a C module # ---------------------------------------------------------------- @@ -1273,8 +1667,8 @@ d: $(SRCS) d_cpp: $(SRCS) $(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) - $(CXXSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO) + $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) + $(CXXSHARED) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Compile D files @@ -1290,7 +1684,15 @@ d_compile: $(SRCS) # ----------------------------------------------------------------- d_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme + $(RUNTOOL) $(D_RUNME) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +d_version: + # Needs improvement! + echo D version guess - $(D_VERSION) # ----------------------------------------------------------------- # Clean the D examples diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile index 2a3f0ec2d..6155d9494 100644 --- a/Examples/android/class/Makefile +++ b/Examples/android/class/Makefile @@ -2,6 +2,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i +INTERFACEDIR = jni/ PACKAGEDIR = src/org/swig PACKAGENAME= org.swig.classexample SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/classexample @@ -9,22 +10,17 @@ PROJECTNAME= SwigClass TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -all:: android +check: build -android:: - android update project --target $(TARGETID) --name $(PROJECTNAME) --path . - $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) - ndk-build - ant debug +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp -install:: - -adb uninstall $(PACKAGENAME) - adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk +install: + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install -clean:: - ant clean - rm -f jni/$(TARGET)_wrap.cpp - rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - - -check: all +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean diff --git a/Examples/android/extend/Makefile b/Examples/android/extend/Makefile index e8c1b5e16..ec53013af 100644 --- a/Examples/android/extend/Makefile +++ b/Examples/android/extend/Makefile @@ -2,6 +2,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i +INTERFACEDIR = jni/ PACKAGEDIR = src/org/swig PACKAGENAME= org.swig.extendexample SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/extendexample @@ -9,22 +10,17 @@ PROJECTNAME= SwigExtend TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -all:: android +check: build -android:: - android update project --target $(TARGETID) --name $(PROJECTNAME) --path . - $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) - ndk-build - ant debug +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp -install:: - -adb uninstall $(PACKAGENAME) - adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk +install: + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install -clean:: - ant clean - rm -f jni/$(TARGET)_wrap.cpp - rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - - -check: all +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean diff --git a/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java b/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java index a343dfebc..b88d36082 100644 --- a/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java +++ b/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java @@ -96,7 +96,7 @@ public class SwigExtend extends Activity // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in Java. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, Java resolved the call // immediately in CEO, but now Java thinks the object is an instance of diff --git a/Examples/android/simple/Makefile b/Examples/android/simple/Makefile index 9aeb0c80d..7e7ff40e1 100644 --- a/Examples/android/simple/Makefile +++ b/Examples/android/simple/Makefile @@ -2,6 +2,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i +INTERFACEDIR = jni/ PACKAGEDIR = src/org/swig PACKAGENAME= org.swig.simple SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/simple @@ -9,22 +10,17 @@ PROJECTNAME= SwigSimple TARGETID = 1 #INSTALLOPTIONS = -s # To install on SD Card -all:: android +check: build -android:: - android update project --target $(TARGETID) --name $(PROJECTNAME) --path . - $(SWIG) -java $(SWIGOPT) -o jni/$(TARGET)_wrap.c jni/$(INTERFACE) - ndk-build - ant debug +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android -install:: - -adb uninstall $(PACKAGENAME) - adb install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk +install: + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install -clean:: - ant clean - rm -f jni/$(TARGET)_wrap.c - rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - - -check: all +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean diff --git a/Examples/chicken/class/Makefile b/Examples/chicken/class/Makefile index 1261ec5ac..1436d836f 100644 --- a/Examples/chicken/class/Makefile +++ b/Examples/chicken/class/Makefile @@ -10,29 +10,29 @@ CFLAGS = VARIANT = # uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines) -#CHICKEN_MAIN = test-lowlevel-class.scm -#CHICKEN_MAIN = test-tinyclos-class.scm +#CHICKEN_MAIN = runme-lowlevel.scm +#CHICKEN_MAIN = runme-tinyclos.scm #VARIANT = _static -all:: $(TARGET) $(TARGET)_proxy +check: build + $(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run + $(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run + +build: $(TARGET) $(TARGET)_proxy $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp $(TARGET)_proxy: $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-lowlevel-class.scm - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-tinyclos-class.scm diff --git a/Examples/chicken/class/test-lowlevel-class.scm b/Examples/chicken/class/runme-lowlevel.scm similarity index 100% rename from Examples/chicken/class/test-lowlevel-class.scm rename to Examples/chicken/class/runme-lowlevel.scm diff --git a/Examples/chicken/class/test-tinyclos-class.scm b/Examples/chicken/class/runme-tinyclos.scm similarity index 100% rename from Examples/chicken/class/test-tinyclos-class.scm rename to Examples/chicken/class/runme-tinyclos.scm diff --git a/Examples/chicken/constants/Makefile b/Examples/chicken/constants/Makefile index 81308fcf3..31e39d346 100644 --- a/Examples/chicken/constants/Makefile +++ b/Examples/chicken/constants/Makefile @@ -10,21 +10,21 @@ CFLAGS = VARIANT = # uncomment the following two lines to build a static exe -#CHICKEN_MAIN = test-constants.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static -all:: $(TARGET) +check: build + $(MAKE) -f $(TOP)/Makefile chicken_run + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - csi test-constants.scm diff --git a/Examples/chicken/constants/test-constants.scm b/Examples/chicken/constants/runme.scm similarity index 100% rename from Examples/chicken/constants/test-constants.scm rename to Examples/chicken/constants/runme.scm diff --git a/Examples/chicken/egg/Makefile b/Examples/chicken/egg/Makefile index bdf71b104..55aa114eb 100644 --- a/Examples/chicken/egg/Makefile +++ b/Examples/chicken/egg/Makefile @@ -1,6 +1,9 @@ SWIG = ../../../preinst-swig -all: single multi +check: build + cd eggs/install && csi ../../test.scm + +build: single multi # This creates an egg which contains only the single module. Any additional implementation files # that implement the interface being wrapped should also be added to this egg @@ -9,7 +12,7 @@ single: single_wrap.cxx tar czf eggs/single.egg single.setup single.scm single_wrap.cxx rm -f single.scm single_wrap.cxx -# complie the single module with -nounit +# compile the single module with -nounit single_wrap.cxx: single.i $(SWIG) -chicken -c++ -proxy -nounit single.i @@ -34,6 +37,3 @@ setup: mkdir -p install && \ chicken-setup -repository `pwd`/install single.egg && \ chicken-setup -repository `pwd`/install multi.egg - -check: - cd eggs/install && csi ../../test.scm diff --git a/Examples/chicken/multimap/Makefile b/Examples/chicken/multimap/Makefile index dace61a1e..eba36169d 100644 --- a/Examples/chicken/multimap/Makefile +++ b/Examples/chicken/multimap/Makefile @@ -10,21 +10,21 @@ CFLAGS = VARIANT = # uncomment the following two lines to build a static exe -#CHICKEN_MAIN = test-multimap.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static -all:: $(TARGET) +check: build + $(MAKE) -f $(TOP)/Makefile chicken_run + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-multimap.scm diff --git a/Examples/chicken/multimap/test-multimap.scm b/Examples/chicken/multimap/runme.scm similarity index 97% rename from Examples/chicken/multimap/test-multimap.scm rename to Examples/chicken/multimap/runme.scm index 3a6b46e2c..ebe644004 100644 --- a/Examples/chicken/multimap/test-multimap.scm +++ b/Examples/chicken/multimap/runme.scm @@ -1,4 +1,3 @@ -;; run with './multimap test-multimap.scm' ;; feel free to uncomment and comment sections (load-library 'example "multimap.so") diff --git a/Examples/chicken/overload/Makefile b/Examples/chicken/overload/Makefile index 48ec43af4..e15352ec5 100644 --- a/Examples/chicken/overload/Makefile +++ b/Examples/chicken/overload/Makefile @@ -10,21 +10,21 @@ CFLAGS = VARIANT = # uncomment the following lines to build a static exe -#CHICKEN_MAIN = test-overload.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static -all:: $(TARGET) +check: build + $(MAKE) -f $(TOP)/Makefile chicken_run + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-overload.scm diff --git a/Examples/chicken/overload/test-overload.scm b/Examples/chicken/overload/runme.scm similarity index 100% rename from Examples/chicken/overload/test-overload.scm rename to Examples/chicken/overload/runme.scm diff --git a/Examples/chicken/simple/Makefile b/Examples/chicken/simple/Makefile index bb7814260..f8fb006a4 100644 --- a/Examples/chicken/simple/Makefile +++ b/Examples/chicken/simple/Makefile @@ -10,21 +10,21 @@ CFLAGS = VARIANT = # uncomment the following two lines to build a static exe -#CHICKEN_MAIN = test-simple.scm +#CHICKEN_MAIN = runme.scm #VARIANT = _static -all:: $(TARGET) +check: build + $(MAKE) -f $(TOP)/Makefile chicken_run + +build: $(TARGET) $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) + SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ + INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \ + SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) -clean:: +clean: $(MAKE) -f $(TOP)/Makefile chicken_clean rm -f example.scm example-generic.scm example-clos.scm rm -f $(TARGET) - -check:: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH csi test-simple.scm diff --git a/Examples/chicken/simple/test-simple.scm b/Examples/chicken/simple/runme.scm similarity index 100% rename from Examples/chicken/simple/test-simple.scm rename to Examples/chicken/simple/runme.scm diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile index b3446d895..65386f0dc 100644 --- a/Examples/csharp/arrays/Makefile +++ b/Examples/csharp/arrays/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -unsafe -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/callback/Makefile b/Examples/csharp/callback/Makefile index 51b163b85..340febc88 100644 --- a/Examples/csharp/callback/Makefile +++ b/Examples/csharp/callback/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -debug -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/class/Makefile b/Examples/csharp/class/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/class/Makefile +++ b/Examples/csharp/class/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/enum/Makefile b/Examples/csharp/enum/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/enum/Makefile +++ b/Examples/csharp/enum/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/extend/Makefile b/Examples/csharp/extend/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/extend/Makefile +++ b/Examples/csharp/extend/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/extend/runme.cs b/Examples/csharp/extend/runme.cs index 825dcdbca..92313aa5e 100644 --- a/Examples/csharp/extend/runme.cs +++ b/Examples/csharp/extend/runme.cs @@ -45,7 +45,7 @@ public class runme // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in C#. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, C# resolved the call // immediately in CEO, but now C# thinks the object is an instance of diff --git a/Examples/csharp/funcptr/Makefile b/Examples/csharp/funcptr/Makefile index 223300497..875ae0e71 100644 --- a/Examples/csharp/funcptr/Makefile +++ b/Examples/csharp/funcptr/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/reference/Makefile b/Examples/csharp/reference/Makefile index 20f0dd5bb..bc3ce8ce8 100644 --- a/Examples/csharp/reference/Makefile +++ b/Examples/csharp/reference/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/simple/Makefile b/Examples/csharp/simple/Makefile index 223300497..875ae0e71 100644 --- a/Examples/csharp/simple/Makefile +++ b/Examples/csharp/simple/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/template/Makefile b/Examples/csharp/template/Makefile index 3f3bbe6dd..43243d6d5 100644 --- a/Examples/csharp/template/Makefile +++ b/Examples/csharp/template/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/variables/Makefile b/Examples/csharp/variables/Makefile index 223300497..875ae0e71 100644 --- a/Examples/csharp/variables/Makefile +++ b/Examples/csharp/variables/Makefile @@ -7,14 +7,13 @@ SWIGOPT = CSHARPSRCS = *.cs CSHARPFLAGS= -nologo -out:runme.exe -all:: csharp +check: build + $(MAKE) -f $(TOP)/Makefile csharp_run -csharp:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/d/callback/Makefile b/Examples/d/callback/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/callback/Makefile +++ b/Examples/d/callback/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/class/Makefile b/Examples/d/class/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/class/Makefile +++ b/Examples/d/class/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/constants/Makefile b/Examples/d/constants/Makefile index 412055243..d537ce281 100644 --- a/Examples/d/constants/Makefile +++ b/Examples/d/constants/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/enum/Makefile b/Examples/d/enum/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/enum/Makefile +++ b/Examples/d/enum/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/extend/Makefile b/Examples/d/extend/Makefile index b5808cf0d..eda18f13c 100644 --- a/Examples/d/extend/Makefile +++ b/Examples/d/extend/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/extend/d1/runme.d b/Examples/d/extend/d1/runme.d index 96501d1a4..058432096 100644 --- a/Examples/d/extend/d1/runme.d +++ b/Examples/d/extend/d1/runme.d @@ -46,7 +46,7 @@ void main() { // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in D. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, D resolved the call // immediately in CEO, but now D thinks the object is an instance of diff --git a/Examples/d/extend/d2/runme.d b/Examples/d/extend/d2/runme.d index 1ea6dfd21..cccdf463b 100644 --- a/Examples/d/extend/d2/runme.d +++ b/Examples/d/extend/d2/runme.d @@ -46,7 +46,7 @@ void main() { // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in D. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, D resolved the call // immediately in CEO, but now D thinks the object is an instance of diff --git a/Examples/d/funcptr/Makefile b/Examples/d/funcptr/Makefile index 09efa8d88..2ba893ca7 100644 --- a/Examples/d/funcptr/Makefile +++ b/Examples/d/funcptr/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/simple/Makefile b/Examples/d/simple/Makefile index ae173a566..a8808c9c5 100644 --- a/Examples/d/simple/Makefile +++ b/Examples/d/simple/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/d/variables/Makefile b/Examples/d/variables/Makefile index ae173a566..a8808c9c5 100644 --- a/Examples/d/variables/Makefile +++ b/Examples/d/variables/Makefile @@ -13,18 +13,15 @@ SWIGOPT = DSRCS = *.d DFLAGS = -ofrunme +check: build + cd $(WORKING_DIR); \ + $(MAKE) -f $(TOP)/Makefile d_run -all:: d - -d:: +build: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile -clean:: +clean: cd $(WORKING_DIR); \ $(MAKE) -f $(TOP)/Makefile d_clean - -check: all - cd $(WORKING_DIR); \ - $(MAKE) -f $(TOP)/Makefile d_run diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/callback/Makefile +++ b/Examples/go/callback/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go index ffa4b3874..2eef77fdb 100644 --- a/Examples/go/callback/runme.go +++ b/Examples/go/callback/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/class/Makefile b/Examples/go/class/Makefile index 53d31d1a4..a099654f1 100644 --- a/Examples/go/class/Makefile +++ b/Examples/go/class/Makefile @@ -5,12 +5,12 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/class/runme.go b/Examples/go/class/runme.go index ff64bb4be..8d68afb61 100644 --- a/Examples/go/class/runme.go +++ b/Examples/go/class/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/constants/Makefile b/Examples/go/constants/Makefile index 71d4d73a4..b45feb963 100644 --- a/Examples/go/constants/Makefile +++ b/Examples/go/constants/Makefile @@ -5,12 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/constants/runme.go b/Examples/go/constants/runme.go index 78a047e20..1427997a0 100644 --- a/Examples/go/constants/runme.go +++ b/Examples/go/constants/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" "./example" + "fmt" ) func main() { diff --git a/Examples/go/enum/Makefile b/Examples/go/enum/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/enum/Makefile +++ b/Examples/go/enum/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/enum/runme.go b/Examples/go/enum/runme.go index 419df5f93..99d2651f4 100644 --- a/Examples/go/enum/runme.go +++ b/Examples/go/enum/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/extend/Makefile +++ b/Examples/go/extend/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index 187f1ce08..770e27802 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) type CEO struct{} @@ -42,7 +42,7 @@ func main() { // treated the same. For items 0, 1, and 2, all methods // resolve in C++. For item 3, our CEO, GetTitle calls // GetPosition which resolves in Go. The call to GetPosition - // is slightly different, however, because of the overidden + // is slightly different, however, because of the overridden // GetPosition() call, since now the object reference has been // "laundered" by passing through EmployeeList as an // Employee*. Previously, Go resolved the call immediately in diff --git a/Examples/go/funcptr/Makefile b/Examples/go/funcptr/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/funcptr/Makefile +++ b/Examples/go/funcptr/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/funcptr/runme.go b/Examples/go/funcptr/runme.go index 73ecbb805..44dae3c9e 100644 --- a/Examples/go/funcptr/runme.go +++ b/Examples/go/funcptr/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/multimap/Makefile b/Examples/go/multimap/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/multimap/Makefile +++ b/Examples/go/multimap/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/multimap/runme.go b/Examples/go/multimap/runme.go index 94c29127c..390205a80 100644 --- a/Examples/go/multimap/runme.go +++ b/Examples/go/multimap/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/pointer/Makefile b/Examples/go/pointer/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/pointer/Makefile +++ b/Examples/go/pointer/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go index 63deb11b7..1414d341e 100644 --- a/Examples/go/pointer/runme.go +++ b/Examples/go/pointer/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/reference/Makefile b/Examples/go/reference/Makefile index 9dc8b8851..7489f87dc 100644 --- a/Examples/go/reference/Makefile +++ b/Examples/go/reference/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/reference/runme.go b/Examples/go/reference/runme.go index 3683d6144..004a04c2e 100644 --- a/Examples/go/reference/runme.go +++ b/Examples/go/reference/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/simple/Makefile b/Examples/go/simple/Makefile index e67fa8bb6..75f81bffe 100644 --- a/Examples/go/simple/Makefile +++ b/Examples/go/simple/Makefile @@ -4,12 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/simple/runme.go b/Examples/go/simple/runme.go index c829ad21a..9eb0ff454 100644 --- a/Examples/go/simple/runme.go +++ b/Examples/go/simple/runme.go @@ -1,8 +1,8 @@ package main import ( - "fmt" "./example" + "fmt" ) func main() { diff --git a/Examples/go/template/Makefile b/Examples/go/template/Makefile index b9278b53e..9ee030479 100644 --- a/Examples/go/template/Makefile +++ b/Examples/go/template/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/template/runme.go b/Examples/go/template/runme.go index 8b3d4000e..fca2f1b75 100644 --- a/Examples/go/template/runme.go +++ b/Examples/go/template/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" . "./example" + "fmt" ) func main() { diff --git a/Examples/go/variables/Makefile b/Examples/go/variables/Makefile index b0aa9c970..452ea2118 100644 --- a/Examples/go/variables/Makefile +++ b/Examples/go/variables/Makefile @@ -5,14 +5,12 @@ TARGET = example INTERFACE = example.i SWIGOPT = -all:: go +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run -go:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go -clean:: - $(MAKE) -f $(TOP)/Makefile go_clean - -check: all - $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run +clean: + $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean diff --git a/Examples/go/variables/runme.go b/Examples/go/variables/runme.go index 26cad4b3c..3d9737f5c 100644 --- a/Examples/go/variables/runme.go +++ b/Examples/go/variables/runme.go @@ -3,8 +3,8 @@ package main import ( - "fmt" "./example" + "fmt" ) func main() { diff --git a/Examples/guile/Makefile.in b/Examples/guile/Makefile.in deleted file mode 100644 index ec99f5fcd..000000000 --- a/Examples/guile/Makefile.in +++ /dev/null @@ -1,40 +0,0 @@ -# Makefile for Guile. Used by all of the example programs. - -subdirs = simple matrix port constants multimap multivalue - -top_srcdir = @top_srcdir@ -SWIG = ../$(top_srcdir)/preinst-swig -CC = @CC@ -CXX = @CXX@ -CFLAGS = @PLATCFLAGS@ -GUILEINCLUDE = @GUILEINCLUDE@ -GUILELINK = @GUILELINK@ -SWIGOPT = - -WRAP = $(IFILE:.i=_wrap.c) -CXXWRAP = $(IFILE:.i=_wrap.cxx) - -SO = @SO@ - -all: - for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done - -clean:: - for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done - rm -f *~ .~* - -guile_clean: - rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core my-guile $(TARGET) - -# This is meant to be used w/ "make -f ../Makefile" from subdirs. -# Doesn't make sense to use it from here. - -sub-all:: - $(SWIG) -guile $(SWIGOPT) $(IFILE) - $(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILEINCLUDE) $(GUILELINK) - -sub-all-cxx:: - $(SWIG) -c++ -guile $(SWIGOPT) $(IFILE) - $(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILEINCLUDE) $(GUILELINK) - -# Makefile ends here diff --git a/Examples/guile/README b/Examples/guile/README index 7d726619e..03ce8e450 100644 --- a/Examples/guile/README +++ b/Examples/guile/README @@ -1,6 +1,7 @@ This directory contains examples for Guile. constants -- handling #define and %constant literals +class -- classic c++ class example matrix -- a very simple Matrix example multimap -- typemaps with multiple sub-types multivalue -- using the %values_as_list directive diff --git a/Examples/guile/check.list b/Examples/guile/check.list index 7ccd0730a..726e6ab75 100644 --- a/Examples/guile/check.list +++ b/Examples/guile/check.list @@ -1,6 +1,9 @@ # see top-level Makefile.in constants -simple +class port +simple +std_vector +matrix multimap multivalue diff --git a/Examples/guile/class/Makefile b/Examples/guile/class/Makefile new file mode 100644 index 000000000..8de4f292b --- /dev/null +++ b/Examples/guile/class/Makefile @@ -0,0 +1,19 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i + +check: build + $(MAKE) -f $(TOP)/Makefile guile_run + +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp + +static: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp + +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean diff --git a/Examples/guile/class/example.cxx b/Examples/guile/class/example.cxx new file mode 100644 index 000000000..1e8e203dd --- /dev/null +++ b/Examples/guile/class/example.cxx @@ -0,0 +1,28 @@ +/* File : example.c */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +double Circle::area(void) { + return M_PI*radius*radius; +} + +double Circle::perimeter(void) { + return 2*M_PI*radius; +} + +double Square::area(void) { + return width*width; +} + +double Square::perimeter(void) { + return 4*width; +} diff --git a/Examples/guile/class/example.h b/Examples/guile/class/example.h new file mode 100644 index 000000000..0d4527e92 --- /dev/null +++ b/Examples/guile/class/example.h @@ -0,0 +1,34 @@ +/* File : example.h */ + +class Shape { +public: + Shape() { + nshapes++; + } + virtual ~Shape() { + nshapes--; + }; + double x, y; + void move(double dx, double dy); + virtual double area(void) = 0; + virtual double perimeter(void) = 0; + static int nshapes; +}; + +class Circle : public Shape { +private: + double radius; +public: + Circle(double r) : radius(r) { }; + virtual double area(void); + virtual double perimeter(void); +}; + +class Square : public Shape { +private: + double width; +public: + Square(double w) : width(w) { }; + virtual double area(void); + virtual double perimeter(void); +}; diff --git a/Examples/guile/class/example.i b/Examples/guile/class/example.i new file mode 100644 index 000000000..fbdf7249f --- /dev/null +++ b/Examples/guile/class/example.i @@ -0,0 +1,9 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" diff --git a/Examples/guile/class/runme.scm b/Examples/guile/class/runme.scm new file mode 100644 index 000000000..4e47d458d --- /dev/null +++ b/Examples/guile/class/runme.scm @@ -0,0 +1,60 @@ +; file: runme.scm + +; This file illustrates the proxy class C++ interface generated +; by SWIG. + +(load-extension "./libexample" "scm_init_example_module") + +; Convenience wrapper around the display function +; (which only accepts one argument at the time) + +(define (mdisplay-newline . args) + (for-each display args) + (newline)) + +; ----- Object creation ----- + +(mdisplay-newline "Creating some objects:") +(define c (new-Circle 10)) +(mdisplay-newline " Created circle " c) +(define s (new-Square 10)) +(mdisplay-newline " Created square " s) + +; ----- Access a static member ----- + +(mdisplay-newline "\nA total of " (Shape-nshapes) " shapes were created") + +; ----- Member data access ----- + +; Set the location of the object + +(Shape-x-set c 20) +(Shape-y-set c 30) + +(Shape-x-set s -10) +(Shape-y-set s 5) + +(mdisplay-newline "\nHere is their current position:") +(mdisplay-newline " Circle = (" (Shape-x-get c) "," (Shape-y-get c) ")") +(mdisplay-newline " Square = (" (Shape-x-get s) "," (Shape-y-get s) ")") + +; ----- Call some methods ----- + +(mdisplay-newline "\nHere are some properties of the shapes:") +(define (shape-props o) + (mdisplay-newline " " o) + (mdisplay-newline " area = " (Shape-area o)) + (mdisplay-newline " perimeter = " (Shape-perimeter o))) +(for-each shape-props (list c s)) + +(mdisplay-newline "\nGuess I'll clean up now") + +; Note: this invokes the virtual destructor +(delete-Shape c) +(delete-Shape s) + +(define s 3) +(mdisplay-newline (Shape-nshapes) " shapes remain") +(mdisplay-newline "Goodbye") + +(exit 0) diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile index 70243c75e..d8a3cfebd 100644 --- a/Examples/guile/constants/Makefile +++ b/Examples/guile/constants/Makefile @@ -1,17 +1,15 @@ -SRCS = -TARGET = my-guile -IFILE = example.i -MKDIR = .. +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = my-guile +INTERFACE = example.i -all:: - $(MAKE) -f $(MKDIR)/Makefile \ - SRCS='$(SRCS)' \ - TARGET=$(TARGET) \ - IFILE=$(IFILE) \ - sub-all +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run -clean:: - $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean +build: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented -check: all - ./my-guile -s constants.scm +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean diff --git a/Examples/guile/constants/constants.scm b/Examples/guile/constants/constants.scm deleted file mode 100644 index 5220150f1..000000000 --- a/Examples/guile/constants/constants.scm +++ /dev/null @@ -1,10 +0,0 @@ -(or (= (ICONST) 42) (exit 1)) -(or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1)) -(or (char=? (CCONST) #\x) (exit 1)) -(or (char=? (CCONST2) #\newline) (exit 1)) -(or (string=? (SCONST) "Hello World") (exit 1)) -(or (string=? (SCONST2) "\"Hello World\"") (exit 1)) -(or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1)) -(or (= (iconst) 37) (exit 1)) -(or (< (abs (- (fconst) 3.14)) 0.00001) (exit 1)) -(exit 0) diff --git a/Examples/guile/constants/runme.scm b/Examples/guile/constants/runme.scm new file mode 100644 index 000000000..59fd26e5a --- /dev/null +++ b/Examples/guile/constants/runme.scm @@ -0,0 +1,19 @@ +(or (= (ICONST) 42) (exit 1)) +(display "ICONST = ")(display (ICONST))(display " (should be 42)\n") +(or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1)) +(display "FCONST = ")(display (FCONST))(display " (should be 2.1828)\n") +(or (char=? (CCONST) #\x) (exit 1)) +(display "CCONST = ")(display (CCONST))(display " (should be 'x')\n") +(or (char=? (CCONST2) #\newline) (exit 1)) +(display "CCONST2 = ")(display (CCONST2))(display " (this should be on a new line)\n") +(or (string=? (SCONST) "Hello World") (exit 1)) +(display "SCONST = ")(display (SCONST))(display " (should be 'Hello World')\n") +(or (string=? (SCONST2) "\"Hello World\"") (exit 1)) +(display "SCONST2 = ")(display (SCONST2))(display " (should be \"Hello World\")\n") +(or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1)) +(display "EXPR = ")(display (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))))(display " (should round to 0.0)\n") +(or (= (iconst) 37) (exit 1)) +(display "iconst = ")(display (iconst))(display " (should be 37)\n") +(or (< (abs (- (fconst) 3.14)) 0.00001) (exit 1)) +(display "fconst = ")(display (fconst))(display " (should be 3.14)\n") +(exit 0) diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile index 5df2c6515..a32210e65 100644 --- a/Examples/guile/matrix/Makefile +++ b/Examples/guile/matrix/Makefile @@ -1,18 +1,15 @@ -SRCS = matrix.c vector.c -TARGET = matrix -IFILE = package.i -MKDIR = .. +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = matrix.c vector.c +TARGET = matrix +INTERFACE = example.i +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_augmented_run -all:: - $(MAKE) -f $(MKDIR)/Makefile \ - SRCS='$(SRCS)' \ - TARGET=$(TARGET) \ - IFILE=$(IFILE) \ - MODULE=$(MODULE) \ - sub-all +build: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-lm' guile_augmented -clean:: - $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean - -check: all +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean diff --git a/Examples/guile/matrix/README b/Examples/guile/matrix/README index dc1957719..db7395b70 100644 --- a/Examples/guile/matrix/README +++ b/Examples/guile/matrix/README @@ -1,13 +1,13 @@ Matrix example. To run the example, execute the program 'matrix' and type the following : - (load "matrix.scm") + (load "runme.scm") (do-test 0) Alternatively, use the command-line: - ./matrix -e do-test -s matrix.scm + ./matrix -e do-test -s runme.scm Or, if your operating system is spiffy enough: - ./matrix.scm + ./runme.scm diff --git a/Examples/guile/matrix/package.i b/Examples/guile/matrix/example.i similarity index 72% rename from Examples/guile/matrix/package.i rename to Examples/guile/matrix/example.i index aaa55511c..3f801dcdf 100644 --- a/Examples/guile/matrix/package.i +++ b/Examples/guile/matrix/example.i @@ -1,7 +1,4 @@ -// FILE : package.i -// See the SWIG users manual - -/*** Matrix and vector package ***/ +/*** Matrix and vector example ***/ %module Matrix %{ diff --git a/Examples/guile/matrix/main.c b/Examples/guile/matrix/main.c deleted file mode 100644 index 88209aea7..000000000 --- a/Examples/guile/matrix/main.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -extern int matrix_init(Tcl_Interp *); /* Init function from matrix.i */ - -int main() { - - int code; - char input[1024]; - Tcl_Interp *interp; - - interp = Tcl_CreateInterp(); - - /* Initialize the wrappers */ - - if (matrix_init(interp) == TCL_ERROR) - exit(0); - - fprintf(stdout,"matrix > "); - while(fgets(input, 1024, stdin) != NULL) { - code = Tcl_Eval(interp, input); - fprintf(stdout,"%s\n",interp->result); - fprintf(stdout,"matrix > "); - } -} - diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/runme.scm old mode 100644 new mode 100755 similarity index 92% rename from Examples/guile/matrix/matrix.scm rename to Examples/guile/matrix/runme.scm index 18e52842d..f11061e56 --- a/Examples/guile/matrix/matrix.scm +++ b/Examples/guile/matrix/runme.scm @@ -138,24 +138,28 @@ (set-m m1 i j (+ (get-m m1 i j) (get-m m2 i j))) (add-two m1 m2 i (+ j 1))) (add-two m1 m2 (+ i 1) 0)))) - (if (null? ML) () (begin - (add-two M (car ML) 0 0) - (add-mat M (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (add-two M (car ML) 0 0) + (add-mat M (cdr ML))))) (define (cleanup ML) - (if (null? ML) () (begin - (destroy-matrix (car ML)) - (cleanup (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (destroy-matrix (car ML)) + (cleanup (cdr ML))))) (define (make-random ML) ; Put random values in them - (if (null? ML) () (begin - (randmat (car ML)) - (make-random (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (randmat (car ML)) + (make-random (cdr ML))))) (define (mul-mat m ML) - (if (null? ML) () (begin - (mat-mult m (car ML) m) - (mul-mat m (cdr ML))))) + (if (null? ML) *unspecified* + (begin + (mat-mult m (car ML) m) + (mul-mat m (cdr ML))))) ;;; Now we'll hammer on things a little bit just to make ;;; sure everything works. @@ -207,4 +211,3 @@ (cleanup M-list)) -;;; matrix.scm ends here diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile index dc9c66d1f..4ca82a3d3 100644 --- a/Examples/guile/multimap/Makefile +++ b/Examples/guile/multimap/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile guile_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean - -check: all diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i index 7337d1e9e..c24d45ddc 100644 --- a/Examples/guile/multimap/example.i +++ b/Examples/guile/multimap/example.i @@ -15,43 +15,54 @@ extern int squareCubed (int n, int *OUTPUT); extern int gcd(int x, int y); -%typemap(in) (int argc, char *argv[]) { - int i; - SCM *v; - if (!(SCM_NIMP($input) && SCM_VECTORP($input))) { +%typemap(in) (int argc, char *argv[]) %{ + scm_t_array_handle handle; + size_t i; + size_t lenp; + ssize_t inc; + const SCM *v; + if (!(SCM_NIMP($input) && scm_is_vector($input))) { SWIG_exception(SWIG_ValueError, "Expecting a vector"); return 0; } - $1 = SCM_LENGTH($input); + v = scm_vector_elements($input, &handle, &lenp, &inc); + $1 = (int)lenp; if ($1 == 0) { SWIG_exception(SWIG_ValueError, "Vector must contain at least 1 element"); } $2 = (char **) malloc(($1+1)*sizeof(char *)); - v = SCM_VELTS($input); - for (i = 0; i < $1; i++) { - if (!(SCM_NIMP(v[i]) && SCM_STRINGP(v[i]))) { - free($2); + for (i = 0; i < $1; i++, v +=inc ) { + if (!(SCM_NIMP(*v) && scm_is_string(*v))) { + free($2); SWIG_exception(SWIG_ValueError, "Vector items must be strings"); return 0; } - $2[i] = SCM_CHARS(v[i]); + $2[i] = scm_to_locale_string(*v); } $2[i] = 0; -} + scm_array_handle_release (&handle); +%} -%typemap(freearg) (int argc, char *argv[]) { - free($2); -} +%typemap(freearg) (int argc, char *argv[]) %{ + for (i = 0; i < $1; i++) { + free($2[i]); + } + free($2); +%} extern int gcdmain(int argc, char *argv[]); -%typemap(in) (char *bytes, int len) { - if (!(SCM_NIMP($input) && SCM_STRINGP($input))) { +%typemap(in) (char *bytes, int len) %{ + if (!(SCM_NIMP($input) && scm_is_string($input))) { SWIG_exception(SWIG_ValueError, "Expecting a string"); } - $1 = SCM_CHARS($input); - $2 = SCM_LENGTH($input); -} + $1 = scm_to_locale_string($input); + $2 = scm_c_string_length($input); +%} + +%typemap(freearg) (char *bytes, int len) %{ + free($1); +%} extern int count(char *bytes, int len, char c); @@ -59,15 +70,15 @@ extern int count(char *bytes, int len, char c); %typemap(in) (char *str, int len) { size_t temp; - $1 = gh_scm2newstr($input,&temp); + $1 = SWIG_Guile_scm2newstr($input,&temp); $2 = temp; } /* Return the mutated string as a new object. */ %typemap(argout) (char *str, int len) { - SWIG_APPEND_VALUE(gh_str2scm($1,$2)); - if ($1) scm_must_free($1); + SWIG_APPEND_VALUE(scm_from_locale_stringn($1,$2)); + if ($1) SWIG_free($1); } extern void capitalize(char *str, int len); @@ -78,7 +89,7 @@ extern void capitalize(char *str, int len); %typemap(check) (double cx, double cy) { double a = $1*$1 + $2*$2; if (a > 1.0) { - SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); + SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle"); } } diff --git a/Examples/guile/multimap/runme.scm b/Examples/guile/multimap/runme.scm index edc197259..a4a518a02 100644 --- a/Examples/guile/multimap/runme.scm +++ b/Examples/guile/multimap/runme.scm @@ -1,6 +1,6 @@ ;;; Test out some multi-argument typemaps -(use-modules (example)) +(load-extension "./libexample" "scm_init_example_module") ; Call the GCD function @@ -27,4 +27,4 @@ (display (capitalize "hello world")) (newline) - +(exit 0) diff --git a/Examples/guile/multivalue/Makefile b/Examples/guile/multivalue/Makefile index dc9c66d1f..4ca82a3d3 100644 --- a/Examples/guile/multivalue/Makefile +++ b/Examples/guile/multivalue/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile guile_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean - -check: all diff --git a/Examples/guile/multivalue/runme.scm b/Examples/guile/multivalue/runme.scm index 73eb5affa..0f65797ca 100644 --- a/Examples/guile/multivalue/runme.scm +++ b/Examples/guile/multivalue/runme.scm @@ -1,6 +1,6 @@ ;;;; Show the three different ways to deal with multiple return values -(use-modules (example)) +(load-extension "./libexample" "scm_init_example_module") ;;; Multiple values as lists. By default, if more than one value is to ;;; be returned, a list of the values is created and returned. The @@ -64,3 +64,4 @@ (display remainder) (newline)) +(exit 0) diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile index 824f3f823..d6ec0ac24 100644 --- a/Examples/guile/port/Makefile +++ b/Examples/guile/port/Makefile @@ -1,18 +1,16 @@ -SRCS = port.c -TARGET = port -IFILE = port.i -MKDIR = .. +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = port +INTERFACE = example.i +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run -all:: - $(MAKE) -f $(MKDIR)/Makefile \ - SRCS='$(SRCS)' \ - TARGET=$(TARGET) \ - IFILE=$(IFILE) \ - MODULE=$(MODULE) \ - sub-all +build: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented -clean:: - $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean - -check: all +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean + rm -f test.out diff --git a/Examples/guile/port/README b/Examples/guile/port/README index 5ed0199e2..784e39e5d 100644 --- a/Examples/guile/port/README +++ b/Examples/guile/port/README @@ -1,2 +1,2 @@ This example illustrates the translation from Scheme file ports to -temporary FILE streams. Read the source and run ./port -s port.scm +temporary FILE streams. Read the source and run ./port -s runme.scm diff --git a/Examples/guile/port/port.c b/Examples/guile/port/example.c similarity index 100% rename from Examples/guile/port/port.c rename to Examples/guile/port/example.c diff --git a/Examples/guile/port/port.i b/Examples/guile/port/example.i similarity index 100% rename from Examples/guile/port/port.i rename to Examples/guile/port/example.i diff --git a/Examples/guile/port/port.scm b/Examples/guile/port/runme.scm similarity index 79% rename from Examples/guile/port/port.scm rename to Examples/guile/port/runme.scm index 68e9b8e85..3ff447eff 100644 --- a/Examples/guile/port/port.scm +++ b/Examples/guile/port/runme.scm @@ -21,12 +21,15 @@ (lambda () (print-int (current-output-port) 314159)))) (lambda args + (display "Below shows that attempting to write to a string or soft port will result in a wrong-type-error...") + (newline) (write args) (newline))) ;; Read from a file port. Note that it is a bad idea to mix Scheme and -;; C input because of buffering. +;; C input because of buffering, hence the call to seek to rewind the file. (with-input-from-file "test.out" (lambda () + (seek (current-input-port) 0 SEEK_SET) (display (read-int (current-input-port))) (newline))) diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile index 702b5bb96..da4eb9015 100644 --- a/Examples/guile/simple/Makefile +++ b/Examples/guile/simple/Makefile @@ -1,19 +1,15 @@ -SRCS = example.c -TARGET = my-guile -IFILE = example.i -MKDIR = .. +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = my-guile +INTERFACE = example.i -all: $(TARGET) +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run -$(TARGET): - $(MAKE) -f $(MKDIR)/Makefile \ - SRCS='$(SRCS)' \ - TARGET=$(TARGET) \ - IFILE=$(IFILE) \ - sub-all +build: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented -clean:: - $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean - -check: $(TARGET) - ./$(TARGET) -s example.scm > /dev/null +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean diff --git a/Examples/guile/simple/README b/Examples/guile/simple/README index 982216eaa..27b54dc5b 100644 --- a/Examples/guile/simple/README +++ b/Examples/guile/simple/README @@ -2,8 +2,8 @@ A very simple example. To run it, start the program 'my-guile' and type: - (load "example.scm") + (load "runme.scm") Alternatively, you can use the shell command: - ./my-guile -s example.scm + ./my-guile -s runme.scm diff --git a/Examples/guile/simple/example.scm b/Examples/guile/simple/runme.scm similarity index 93% rename from Examples/guile/simple/example.scm rename to Examples/guile/simple/runme.scm index 9408b1aa6..c3fd0b41f 100644 --- a/Examples/guile/simple/example.scm +++ b/Examples/guile/simple/runme.scm @@ -1,4 +1,3 @@ -;;; example.scm (define (mdisplay-newline . args) ; does guile-1.3.4 have `format #t'? (for-each display args) @@ -25,4 +24,3 @@ (exit (and (= 1932053504 (fact 13)) (= 745470.0 (My-variable)))) -;;; example.scm ends here diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile index 2733fb017..fd7a8439a 100644 --- a/Examples/guile/std_vector/Makefile +++ b/Examples/guile/std_vector/Makefile @@ -1,18 +1,19 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -SRCS = +CXXSRCS = TARGET = example INTERFACE = example.i -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ +check: build + $(MAKE) -f $(TOP)/Makefile guile_run + +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ +static: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean - -check: all diff --git a/Examples/guile/std_vector/runme.scm b/Examples/guile/std_vector/runme.scm index 77443a156..64f56a147 100644 --- a/Examples/guile/std_vector/runme.scm +++ b/Examples/guile/std_vector/runme.scm @@ -1,6 +1,5 @@ -;; run with mzscheme -r example.scm -(use-modules (example)) +(load-extension "./libexample" "scm_init_example_module") ; repeatedly invoke a procedure with v and an index as arguments (define (with-vector v proc size-proc) @@ -52,3 +51,4 @@ (print-DoubleVector v) (delete-DoubleVector v) +(exit 0) diff --git a/Examples/java/callback/Makefile b/Examples/java/callback/Makefile index 14c301703..8f274e7cb 100644 --- a/Examples/java/callback/Makefile +++ b/Examples/java/callback/Makefile @@ -4,15 +4,15 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile index 14c301703..8f274e7cb 100644 --- a/Examples/java/class/Makefile +++ b/Examples/java/class/Makefile @@ -4,15 +4,15 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/constants/Makefile b/Examples/java/constants/Makefile index 2b3d35c6a..97c5b673c 100644 --- a/Examples/java/constants/Makefile +++ b/Examples/java/constants/Makefile @@ -4,15 +4,15 @@ CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/enum/Makefile b/Examples/java/enum/Makefile index 14c301703..8f274e7cb 100644 --- a/Examples/java/enum/Makefile +++ b/Examples/java/enum/Makefile @@ -4,15 +4,15 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/extend/Makefile b/Examples/java/extend/Makefile index 14c301703..8f274e7cb 100644 --- a/Examples/java/extend/Makefile +++ b/Examples/java/extend/Makefile @@ -4,15 +4,15 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/extend/runme.java b/Examples/java/extend/runme.java index 629bb14a6..f1ec1ea06 100644 --- a/Examples/java/extend/runme.java +++ b/Examples/java/extend/runme.java @@ -55,7 +55,7 @@ public class runme { // methods of all these instances are treated the same. For items 0, 1, and // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls // getPosition which resolves in Java. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since + // slightly different, however, because of the overridden getPosition() call, since // now the object reference has been "laundered" by passing through // EmployeeList as an Employee*. Previously, Java resolved the call // immediately in CEO, but now Java thinks the object is an instance of diff --git a/Examples/java/funcptr/Makefile b/Examples/java/funcptr/Makefile index 968c92c6c..e9e29f3a3 100644 --- a/Examples/java/funcptr/Makefile +++ b/Examples/java/funcptr/Makefile @@ -4,15 +4,15 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/multimap/Makefile b/Examples/java/multimap/Makefile index 968c92c6c..e9e29f3a3 100644 --- a/Examples/java/multimap/Makefile +++ b/Examples/java/multimap/Makefile @@ -4,15 +4,15 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/native/Makefile b/Examples/java/native/Makefile index 92afbd4d0..29d5a082a 100644 --- a/Examples/java/native/Makefile +++ b/Examples/java/native/Makefile @@ -4,15 +4,15 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/pointer/Makefile b/Examples/java/pointer/Makefile index 968c92c6c..e9e29f3a3 100644 --- a/Examples/java/pointer/Makefile +++ b/Examples/java/pointer/Makefile @@ -4,15 +4,15 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/reference/Makefile b/Examples/java/reference/Makefile index 14c301703..8f274e7cb 100644 --- a/Examples/java/reference/Makefile +++ b/Examples/java/reference/Makefile @@ -4,15 +4,15 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/simple/Makefile b/Examples/java/simple/Makefile index 968c92c6c..e9e29f3a3 100644 --- a/Examples/java/simple/Makefile +++ b/Examples/java/simple/Makefile @@ -4,15 +4,15 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/template/Makefile b/Examples/java/template/Makefile index 2b3d35c6a..97c5b673c 100644 --- a/Examples/java/template/Makefile +++ b/Examples/java/template/Makefile @@ -4,15 +4,15 @@ CXXSRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/typemap/Makefile b/Examples/java/typemap/Makefile index 92afbd4d0..29d5a082a 100644 --- a/Examples/java/typemap/Makefile +++ b/Examples/java/typemap/Makefile @@ -4,15 +4,15 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/java/variables/Makefile b/Examples/java/variables/Makefile index 968c92c6c..e9e29f3a3 100644 --- a/Examples/java/variables/Makefile +++ b/Examples/java/variables/Makefile @@ -4,15 +4,15 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = +JAVASRCS = *.java -all:: java +check: build + $(MAKE) -f $(TOP)/Makefile java_run -java:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java + $(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile -clean:: +clean: $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/lua/arrays/Makefile b/Examples/lua/arrays/Makefile index f181818a6..d398dffea 100644 --- a/Examples/lua/arrays/Makefile +++ b/Examples/lua/arrays/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/class/Makefile b/Examples/lua/class/Makefile index 44888f66f..c39e8acdf 100644 --- a/Examples/lua/class/Makefile +++ b/Examples/lua/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/constants/Makefile b/Examples/lua/constants/Makefile index 4204545b8..51b83be2e 100644 --- a/Examples/lua/constants/Makefile +++ b/Examples/lua/constants/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/dual/Makefile b/Examples/lua/dual/Makefile index b4e28f331..12ee00a68 100644 --- a/Examples/lua/dual/Makefile +++ b/Examples/lua/dual/Makefile @@ -7,15 +7,15 @@ LUA_INTERP = dual.cpp # This is a little different to normal as we need to static link two modules and a custom interpreter # We need the external runtime, then swig examples2, and build the module as normal -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(SWIG) -lua -external-runtime $(SWIG) -c++ -lua $(SWIGOPT) example2.i $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - rm -f swigluarun.h - -check: all - + rm -f swigluarun.h $(TARGET) diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile index 51d0e6180..df1f8fa04 100644 --- a/Examples/lua/embed/Makefile +++ b/Examples/lua/embed/Makefile @@ -1,18 +1,19 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed -SRCS = example.c +SRCS = example.c INTERFACE = example.i LUA_INTERP = embed.c # this is a little different to normal as we have our own special interpreter # which we want to static link -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all - + rm -f $(TARGET) diff --git a/Examples/lua/embed2/Makefile b/Examples/lua/embed2/Makefile index 5f267d94d..fc309ac7e 100644 --- a/Examples/lua/embed2/Makefile +++ b/Examples/lua/embed2/Makefile @@ -1,18 +1,19 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed2 -SRCS = example.c +SRCS = example.c INTERFACE = example.i LUA_INTERP = embed2.c # this is a little different to normal as we have our own special interpreter # which we want to static link -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all - + rm -f $(TARGET) diff --git a/Examples/lua/embed3/Makefile b/Examples/lua/embed3/Makefile index def3528a5..8cfa97454 100644 --- a/Examples/lua/embed3/Makefile +++ b/Examples/lua/embed3/Makefile @@ -1,20 +1,21 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = embed3 -SRCS = example.cpp +SRCS = example.cpp INTERFACE = example.i LUA_INTERP = embed3.cpp # this is a little different to normal as we have our own special interpreter # which we want to static link # we also need the external runtime, so we can get access to certain internals of SWIG -all:: +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run + +build: $(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all - + rm -f swigluarun.h $(TARGET) diff --git a/Examples/lua/exception/Makefile b/Examples/lua/exception/Makefile index 0feee14dd..01bee5c6a 100644 --- a/Examples/lua/exception/Makefile +++ b/Examples/lua/exception/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/funcptr3/Makefile b/Examples/lua/funcptr3/Makefile index ac0fff43e..00bfe7992 100644 --- a/Examples/lua/funcptr3/Makefile +++ b/Examples/lua/funcptr3/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/functest/Makefile b/Examples/lua/functest/Makefile index ac0fff43e..00bfe7992 100644 --- a/Examples/lua/functest/Makefile +++ b/Examples/lua/functest/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/functor/Makefile b/Examples/lua/functor/Makefile index 432bfbef3..9220dfe51 100644 --- a/Examples/lua/functor/Makefile +++ b/Examples/lua/functor/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/import/Makefile b/Examples/lua/import/Makefile index 8f692d175..0bf47c1a5 100644 --- a/Examples/lua/import/Makefile +++ b/Examples/lua/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,7 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/owner/Makefile b/Examples/lua/owner/Makefile index 44888f66f..c39e8acdf 100644 --- a/Examples/lua/owner/Makefile +++ b/Examples/lua/owner/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/pointer/Makefile b/Examples/lua/pointer/Makefile index ac0fff43e..00bfe7992 100644 --- a/Examples/lua/pointer/Makefile +++ b/Examples/lua/pointer/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/simple/Makefile b/Examples/lua/simple/Makefile index f181818a6..d398dffea 100644 --- a/Examples/lua/simple/Makefile +++ b/Examples/lua/simple/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/lua/variables/Makefile b/Examples/lua/variables/Makefile index f181818a6..d398dffea 100644 --- a/Examples/lua/variables/Makefile +++ b/Examples/lua/variables/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile lua_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile lua_clean - -check: all diff --git a/Examples/modula3/class/Makefile b/Examples/modula3/class/Makefile index bf929a061..9976e6f80 100644 --- a/Examples/modula3/class/Makefile +++ b/Examples/modula3/class/Makefile @@ -7,9 +7,10 @@ INTERFACE = example.i SWIGOPT = -c++ MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) @@ -19,7 +20,5 @@ modula3:: ln -sf ../example.h src/example.h cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/enum/Makefile b/Examples/modula3/enum/Makefile index b5bf8f672..a3b499823 100644 --- a/Examples/modula3/enum/Makefile +++ b/Examples/modula3/enum/Makefile @@ -7,9 +7,10 @@ CONSTNUMERIC = example_const SWIGOPT = -c++ MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(SWIG) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h $(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC) $(CONSTNUMERIC) >$(CONSTNUMERIC).i @@ -20,7 +21,5 @@ modula3:: mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/exception/Makefile b/Examples/modula3/exception/Makefile index 2518a2203..8d4525512 100644 --- a/Examples/modula3/exception/Makefile +++ b/Examples/modula3/exception/Makefile @@ -7,9 +7,10 @@ SWIGOPT = MODULA3SRCS = *.[im]3 MODULA3FLAGS= -o runme -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp # $(MAKE) -f $(TOP)/Makefile MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile @@ -17,7 +18,5 @@ modula3:: mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/reference/Makefile b/Examples/modula3/reference/Makefile index b31577a58..62183931e 100644 --- a/Examples/modula3/reference/Makefile +++ b/Examples/modula3/reference/Makefile @@ -6,16 +6,15 @@ INTERFACE = example.i SWIGOPT = -c++ MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/simple/Makefile b/Examples/modula3/simple/Makefile index 834521fa5..6a0ca4f0e 100644 --- a/Examples/modula3/simple/Makefile +++ b/Examples/modula3/simple/Makefile @@ -6,16 +6,15 @@ INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/modula3/typemap/Makefile b/Examples/modula3/typemap/Makefile index 834521fa5..6a0ca4f0e 100644 --- a/Examples/modula3/typemap/Makefile +++ b/Examples/modula3/typemap/Makefile @@ -6,16 +6,15 @@ INTERFACE = example.i SWIGOPT = MODULA3SRCS = *.[im]3 -all:: modula3 +check: build + $(MAKE) -f $(TOP)/Makefile modula3_run -modula3:: +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3 m3ppinplace $(MODULA3SRCS) mv m3makefile $(MODULA3SRCS) src/ cm3 -clean:: +clean: $(MAKE) -f $(TOP)/Makefile modula3_clean - -check: all diff --git a/Examples/mzscheme/check.list b/Examples/mzscheme/check.list index ae728ea43..f9e4f11c7 100644 --- a/Examples/mzscheme/check.list +++ b/Examples/mzscheme/check.list @@ -1,3 +1,4 @@ # see top-level Makefile.in multimap simple +std_vector diff --git a/Examples/mzscheme/multimap/Makefile b/Examples/mzscheme/multimap/Makefile index a3cfb8f3c..d1b4a3f39 100644 --- a/Examples/mzscheme/multimap/Makefile +++ b/Examples/mzscheme/multimap/Makefile @@ -4,10 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile mzscheme_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme -clean:: +clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean - -check: all diff --git a/Examples/mzscheme/multimap/example.scm b/Examples/mzscheme/multimap/runme.scm similarity index 89% rename from Examples/mzscheme/multimap/example.scm rename to Examples/mzscheme/multimap/runme.scm index ac9f64283..f1e626f43 100644 --- a/Examples/mzscheme/multimap/example.scm +++ b/Examples/mzscheme/multimap/runme.scm @@ -1,4 +1,4 @@ -;; run with mzscheme -r example.scm +;; run with mzscheme -r runme.scm (load-extension "example.so") @@ -24,4 +24,4 @@ (newline) (display (capitalize "hello world")) -(newline) \ No newline at end of file +(newline) diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile index a3cfb8f3c..d1b4a3f39 100644 --- a/Examples/mzscheme/simple/Makefile +++ b/Examples/mzscheme/simple/Makefile @@ -4,10 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile mzscheme_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme -clean:: +clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean - -check: all diff --git a/Examples/mzscheme/simple/example.scm b/Examples/mzscheme/simple/runme.scm similarity index 92% rename from Examples/mzscheme/simple/example.scm rename to Examples/mzscheme/simple/runme.scm index 8e20345b2..a98e31fd5 100644 --- a/Examples/mzscheme/simple/example.scm +++ b/Examples/mzscheme/simple/runme.scm @@ -1,4 +1,4 @@ -;; run with mzscheme -r example.scm +;; run with mzscheme -r runme.scm (load-extension "example.so") diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile index e18726981..28b91158a 100644 --- a/Examples/mzscheme/std_vector/Makefile +++ b/Examples/mzscheme/std_vector/Makefile @@ -8,12 +8,13 @@ SWIGOPT = GPP = `which g++` MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc -all:: +check: build + $(MAKE) -f $(TOP)/Makefile mzscheme_run + +build: $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) $(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx $(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o clean: $(MAKE) -f $(TOP)/Makefile mzscheme_clean - -check: all diff --git a/Examples/mzscheme/std_vector/example.scm b/Examples/mzscheme/std_vector/runme.scm similarity index 97% rename from Examples/mzscheme/std_vector/example.scm rename to Examples/mzscheme/std_vector/runme.scm index 0e4ac3f97..67351f128 100644 --- a/Examples/mzscheme/std_vector/example.scm +++ b/Examples/mzscheme/std_vector/runme.scm @@ -1,4 +1,4 @@ -;; run with mzscheme -r example.scm +;; run with mzscheme -r runme.scm (load-extension "example.so") diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile index 8a260fe30..4e12e3769 100644 --- a/Examples/ocaml/argout_ref/Makefile +++ b/Examples/ocaml/argout_ref/Makefile @@ -7,21 +7,22 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile index 8e0f2a4fd..91d39247e 100644 --- a/Examples/ocaml/contract/Makefile +++ b/Examples/ocaml/contract/Makefile @@ -7,27 +7,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -dynamic:: +build: static + +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile index 45c5edca4..4920e3b3b 100644 --- a/Examples/ocaml/scoped_enum/Makefile +++ b/Examples/ocaml/scoped_enum/Makefile @@ -7,27 +7,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -dynamic:: +build: static + +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index 31f9934a7..38230eb69 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -8,27 +8,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o -all:: static static_top +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static static_top + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -static_top:: +static_top: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile index 4b85bf33e..64c7256c1 100644 --- a/Examples/ocaml/simple/Makefile +++ b/Examples/ocaml/simple/Makefile @@ -7,27 +7,28 @@ MLFILE = example.ml PROGFILE = example_prog.ml OBJS = example.o -all:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -dynamic:: +build: static + +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/std_string/Makefile b/Examples/ocaml/std_string/Makefile index e5a8017ae..0250cfd2d 100644 --- a/Examples/ocaml/std_string/Makefile +++ b/Examples/ocaml/std_string/Makefile @@ -5,19 +5,20 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all diff --git a/Examples/ocaml/std_vector/Makefile b/Examples/ocaml/std_vector/Makefile index e5a8017ae..0250cfd2d 100644 --- a/Examples/ocaml/std_vector/Makefile +++ b/Examples/ocaml/std_vector/Makefile @@ -5,19 +5,20 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile index fa4333ec0..545f3229a 100644 --- a/Examples/ocaml/stl/Makefile +++ b/Examples/ocaml/stl/Makefile @@ -5,29 +5,30 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -director:: +director: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_director -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -toplevel:: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 350d9734c..f7b808934 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -8,27 +8,28 @@ MLFILE = foolib.ml PROGFILE = example_prog.ml OBJS = -all:: static static_top +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static static_top + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -static_top:: +static_top: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - -check: all diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index 8d1f96edf..14f55e0d9 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -5,24 +5,25 @@ TARGET = example INTERFACE = example.i PROGFILE = runme.ml -all default:: static top +check: build + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run -static:: +build: static top + +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -dynamic:: +dynamic: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -top:: +top: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp_toplevel -clean:: +clean: $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean - -check: all diff --git a/Examples/octave/callback/Makefile b/Examples/octave/callback/Makefile index 21fb21137..d38d7f896 100644 --- a/Examples/octave/callback/Makefile +++ b/Examples/octave/callback/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/callback/example.cxx b/Examples/octave/callback/example.cxx index 450d75608..893a956f4 100644 --- a/Examples/octave/callback/example.cxx +++ b/Examples/octave/callback/example.cxx @@ -1,4 +1,3 @@ /* File : example.cxx */ #include "example.h" - diff --git a/Examples/octave/callback/example.h b/Examples/octave/callback/example.h index 1a0e8c432..74ddad954 100644 --- a/Examples/octave/callback/example.h +++ b/Examples/octave/callback/example.h @@ -20,4 +20,3 @@ public: void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } }; - diff --git a/Examples/octave/callback/example.i b/Examples/octave/callback/example.i index 90beda01a..3192904db 100644 --- a/Examples/octave/callback/example.i +++ b/Examples/octave/callback/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module(directors="1") example +%module(directors="1") swigexample %{ #include "example.h" %} @@ -10,4 +10,3 @@ %feature("director") Callback; %include "example.h" - diff --git a/Examples/octave/callback/runme.m b/Examples/octave/callback/runme.m index b87925e3d..103985358 100644 --- a/Examples/octave/callback/runme.m +++ b/Examples/octave/callback/runme.m @@ -2,14 +2,13 @@ # This file illustrates the cross language polymorphism using directors. -example +swigexample -OctCallback=@() subclass(example.Callback(), \ - 'run',@(self) printf("OctCallback.run()\n")); +OctCallback=@() subclass(swigexample.Callback(),"run",@(self) printf("OctCallback.run()\n")); # Create an Caller instance -caller = example.Caller(); +caller = swigexample.Caller(); # Add a simple C++ callback (caller owns the callback, so # we disown it first) @@ -17,7 +16,7 @@ caller = example.Caller(); printf("Adding and calling a normal C++ callback\n"); printf("----------------------------------------\n"); -callback = example.Callback().__disown(); +callback = swigexample.Callback().__disown(); caller.setCallback(callback); caller.call(); caller.delCallback(); @@ -43,7 +42,7 @@ caller.call(); caller.delCallback(); # careful-- using callback here may cause problems; octave_swig_type still -# exists, but is holding a destroyed object (the C++ example.Callback). +# exists, but is holding a destroyed object (the C++ swigexample.Callback). # to manually drop the octave-side reference, you can use clear callback; @@ -60,4 +59,3 @@ a.Callback.run(); # All done. printf("octave exit\n"); - diff --git a/Examples/octave/class/Makefile b/Examples/octave/class/Makefile index 21fb21137..d38d7f896 100644 --- a/Examples/octave/class/Makefile +++ b/Examples/octave/class/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/class/example.h b/Examples/octave/class/example.h index 46d901361..0d4527e92 100644 --- a/Examples/octave/class/example.h +++ b/Examples/octave/class/example.h @@ -8,7 +8,7 @@ public: virtual ~Shape() { nshapes--; }; - double x, y; + double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; @@ -32,8 +32,3 @@ public: virtual double area(void); virtual double perimeter(void); }; - - - - - diff --git a/Examples/octave/class/example.i b/Examples/octave/class/example.i index 75700b305..b109bcb78 100644 --- a/Examples/octave/class/example.i +++ b/Examples/octave/class/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" @@ -7,4 +7,3 @@ /* Let's just grab the original header file here */ %include "example.h" - diff --git a/Examples/octave/class/runme.m b/Examples/octave/class/runme.m index c833a701b..04221b4bb 100644 --- a/Examples/octave/class/runme.m +++ b/Examples/octave/class/runme.m @@ -3,17 +3,17 @@ # This file illustrates the proxy class C++ interface generated # by SWIG. -example +swigexample # ----- Object creation ----- printf("Creating some objects:\n"); -c = example.Circle(10) -s = example.Square(10) +c = swigexample.Circle(10) +s = swigexample.Square(10) # ----- Access a static member ----- -printf("\nA total of %i shapes were created\n", example.Shape.nshapes); +printf("\nA total of %i shapes were created\n", swigexample.Shape.nshapes); # ----- Member data access ----- @@ -46,7 +46,5 @@ printf("\nGuess I'll clean up now\n"); clear c clear s -printf("%i shapes remain\n", example.Shape.nshapes); +printf("%i shapes remain\n", swigexample.Shape.nshapes); printf("Goodbye\n"); - - diff --git a/Examples/octave/constants/Makefile b/Examples/octave/constants/Makefile index 3156eae84..03501bd81 100644 --- a/Examples/octave/constants/Makefile +++ b/Examples/octave/constants/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/constants/example.i b/Examples/octave/constants/example.i index 4f7b1a4d7..405974b44 100644 --- a/Examples/octave/constants/example.i +++ b/Examples/octave/constants/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample /* A few preprocessor macros */ @@ -23,5 +23,3 @@ %constant int iconst = 37; %constant double fconst = 3.14; - - diff --git a/Examples/octave/constants/runme.m b/Examples/octave/constants/runme.m index 322858734..c6ed24535 100644 --- a/Examples/octave/constants/runme.m +++ b/Examples/octave/constants/runme.m @@ -1,29 +1,25 @@ # file: runme.m -example +swigexample -printf("ICONST = %i (should be 42)\n", example.ICONST); -printf("FCONST = %f (should be 2.1828)\n", example.FCONST); -printf("CCONST = %s (should be 'x')\n", example.CCONST); -printf("CCONST2 = %s (this should be on a new line)\n", example.CCONST2); -printf("SCONST = %s (should be 'Hello World')\n", example.SCONST); -printf("SCONST2 = %s (should be '\"Hello World\"')\n", example.SCONST2); -printf("EXPR = %f (should be 48.5484)\n", example.EXPR); -printf("iconst = %i (should be 37)\n", example.iconst); -printf("fconst = %f (should be 3.14)\n", example.fconst); +printf("ICONST = %i (should be 42)\n", swigexample.ICONST); +printf("FCONST = %f (should be 2.1828)\n", swigexample.FCONST); +printf("CCONST = %s (should be 'x')\n", swigexample.CCONST); +printf("CCONST2 = %s (this should be on a new line)\n", swigexample.CCONST2); +printf("SCONST = %s (should be 'Hello World')\n", swigexample.SCONST); +printf("SCONST2 = %s (should be '\"Hello World\"')\n", swigexample.SCONST2); +printf("EXPR = %f (should be 48.5484)\n", swigexample.EXPR); +printf("iconst = %i (should be 37)\n", swigexample.iconst); +printf("fconst = %f (should be 3.14)\n", swigexample.fconst); try - printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", example.EXTERN); + printf("EXTERN = %s (Arg! This shouldn't printf(anything)\n", swigexample.EXTERN); catch printf("EXTERN isn't defined (good)\n"); end_try_catch try - printf("FOO = %i (Arg! This shouldn't printf(anything)\n", example.FOO); + printf("FOO = %i (Arg! This shouldn't printf(anything)\n", swigexample.FOO); catch printf("FOO isn't defined (good)\n"); end_try_catch - - - - diff --git a/Examples/octave/contract/Makefile b/Examples/octave/contract/Makefile index 464b74122..73e3962ed 100644 --- a/Examples/octave/contract/Makefile +++ b/Examples/octave/contract/Makefile @@ -1,20 +1,15 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/contract/example.c b/Examples/octave/contract/example.c index 1a644543f..fbdc054cd 100644 --- a/Examples/octave/contract/example.c +++ b/Examples/octave/contract/example.c @@ -19,5 +19,3 @@ int fact(int n) { if (n <= 0) return 1; return n*fact(n-1); } - - diff --git a/Examples/octave/contract/example.i b/Examples/octave/contract/example.i index 8fd1a80af..78c459efc 100644 --- a/Examples/octave/contract/example.i +++ b/Examples/octave/contract/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %contract gcd(int x, int y) { require: diff --git a/Examples/octave/contract/runme.m b/Examples/octave/contract/runme.m index 62b72320b..fa36bbe10 100644 --- a/Examples/octave/contract/runme.m +++ b/Examples/octave/contract/runme.m @@ -1,22 +1,21 @@ # file: runme.m -example +swigexample # Call our gcd() function x = 42; y = 105; -g = example.gcd(x,y); +g = swigexample.gcd(x,y); printf("The gcd of %d and %d is %d\n",x,y,g); # Manipulate the Foo global variable # Output its current value -printf("Foo = %f\n", example.cvar.Foo); +printf("Foo = %f\n", swigexample.cvar.Foo); # Change its value -example.cvar.Foo = 3.1415926; +swigexample.cvar.Foo = 3.1415926; # See if the change took effect -printf("Foo = %f\n", example.cvar.Foo); - +printf("Foo = %f\n", swigexample.cvar.Foo); diff --git a/Examples/octave/enum/Makefile b/Examples/octave/enum/Makefile index 21fb21137..d38d7f896 100644 --- a/Examples/octave/enum/Makefile +++ b/Examples/octave/enum/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/enum/example.h b/Examples/octave/enum/example.h index 525d62afc..490d502e8 100644 --- a/Examples/octave/enum/example.h +++ b/Examples/octave/enum/example.h @@ -10,4 +10,3 @@ class Foo { }; void enum_test(color c, Foo::speed s); - diff --git a/Examples/octave/enum/example.i b/Examples/octave/enum/example.i index 23ee8a822..cee9af471 100644 --- a/Examples/octave/enum/example.i +++ b/Examples/octave/enum/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" @@ -8,4 +8,3 @@ /* Let's just grab the original header file here */ %include "example.h" - diff --git a/Examples/octave/enum/runme.m b/Examples/octave/enum/runme.m index a749e81db..0108135b2 100644 --- a/Examples/octave/enum/runme.m +++ b/Examples/octave/enum/runme.m @@ -1,32 +1,30 @@ # file: runme.m -example +swigexample # ----- Object creation ----- # Print out the value of some enums printf("*** color ***\n"); -printf(" RED = %i\n", example.RED); -printf(" BLUE = %i\n", example.BLUE); -printf(" GREEN = %i\n", example.GREEN); +printf(" RED = %i\n", swigexample.RED); +printf(" BLUE = %i\n", swigexample.BLUE); +printf(" GREEN = %i\n", swigexample.GREEN); printf("\n*** Foo::speed ***\n"); -printf(" Foo_IMPULSE = %i\n", example.Foo_IMPULSE); -printf(" Foo_WARP = %i\n", example.Foo_WARP); -printf(" Foo_LUDICROUS = %i\n", example.Foo_LUDICROUS); +printf(" Foo_IMPULSE = %i\n", swigexample.Foo_IMPULSE); +printf(" Foo_WARP = %i\n", swigexample.Foo_WARP); +printf(" Foo_LUDICROUS = %i\n", swigexample.Foo_LUDICROUS); printf("\nTesting use of enums with functions\n"); -example.enum_test(example.RED, example.Foo_IMPULSE); -example.enum_test(example.BLUE, example.Foo_WARP); -example.enum_test(example.GREEN, example.Foo_LUDICROUS); -example.enum_test(1234,5678) +swigexample.enum_test(swigexample.RED, swigexample.Foo_IMPULSE); +swigexample.enum_test(swigexample.BLUE, swigexample.Foo_WARP); +swigexample.enum_test(swigexample.GREEN, swigexample.Foo_LUDICROUS); +swigexample.enum_test(1234,5678) printf("\nTesting use of enum with class method\n"); -f = example.Foo(); - -f.enum_test(example.Foo_IMPULSE); -f.enum_test(example.Foo_WARP); -f.enum_test(example.Foo_LUDICROUS); - +f = swigexample.Foo(); +f.enum_test(swigexample.Foo_IMPULSE); +f.enum_test(swigexample.Foo_WARP); +f.enum_test(swigexample.Foo_LUDICROUS); diff --git a/Examples/octave/extend/Makefile b/Examples/octave/extend/Makefile index 21fb21137..d38d7f896 100644 --- a/Examples/octave/extend/Makefile +++ b/Examples/octave/extend/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/extend/example.cxx b/Examples/octave/extend/example.cxx index 450d75608..893a956f4 100644 --- a/Examples/octave/extend/example.cxx +++ b/Examples/octave/extend/example.cxx @@ -1,4 +1,3 @@ /* File : example.cxx */ #include "example.h" - diff --git a/Examples/octave/extend/example.h b/Examples/octave/extend/example.h index b27ab9711..9e15cf8e4 100644 --- a/Examples/octave/extend/example.h +++ b/Examples/octave/extend/example.h @@ -44,7 +44,7 @@ public: const Employee *get_item(int i) { return list[i]; } - ~EmployeeList() { + ~EmployeeList() { std::vector::iterator i; std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; for (i=list.begin(); i!=list.end(); i++) { @@ -53,4 +53,3 @@ public: std::cout << "~EmployeeList empty." << std::endl; } }; - diff --git a/Examples/octave/extend/example.i b/Examples/octave/extend/example.i index c8ec32e09..953c2f314 100644 --- a/Examples/octave/extend/example.i +++ b/Examples/octave/extend/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module(directors="1") example +%module(directors="1") swigexample %{ #include "example.h" %} @@ -12,4 +12,3 @@ %feature("director") Manager; %include "example.h" - diff --git a/Examples/octave/extend/runme.m b/Examples/octave/extend/runme.m index c64c082c4..4536f2761 100644 --- a/Examples/octave/extend/runme.m +++ b/Examples/octave/extend/runme.m @@ -2,12 +2,12 @@ # This file illustrates the cross language polymorphism using directors. -example +swigexample # CEO class, which overrides Employee::getPosition(). -CEO=@(name) subclass(example.Manager(name),'getPosition',@(self) "CEO"); +CEO=@(name) subclass(swigexample.Manager(name),'getPosition',@(self) "CEO"); # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses @@ -22,7 +22,7 @@ printf("----------------------\n"); # Create a new EmployeeList instance. This class does not have a C++ # director wrapper, but can be used freely with other classes that do. -list = example.EmployeeList(); +list = swigexample.EmployeeList(); # EmployeeList owns its items, so we must surrender ownership of objects # we add. This involves first calling the __disown__ method to tell the @@ -71,4 +71,3 @@ printf("----------------------\n"); # All done. printf("octave exit\n"); - diff --git a/Examples/octave/funcptr/Makefile b/Examples/octave/funcptr/Makefile index 464b74122..73e3962ed 100644 --- a/Examples/octave/funcptr/Makefile +++ b/Examples/octave/funcptr/Makefile @@ -1,20 +1,15 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/funcptr/example.h b/Examples/octave/funcptr/example.h index 9936e24fc..f95ae2cc9 100644 --- a/Examples/octave/funcptr/example.h +++ b/Examples/octave/funcptr/example.h @@ -6,4 +6,3 @@ extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr/example.i b/Examples/octave/funcptr/example.i index 8b3bef678..163a1991b 100644 --- a/Examples/octave/funcptr/example.i +++ b/Examples/octave/funcptr/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" %} @@ -13,4 +13,3 @@ extern int do_op(int a, int b, int (*op)(int, int)); %constant int (*MUL)(int,int) = mul; extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr/runme.m b/Examples/octave/funcptr/runme.m index 455311c16..4e2e28fbc 100644 --- a/Examples/octave/funcptr/runme.m +++ b/Examples/octave/funcptr/runme.m @@ -1,6 +1,6 @@ # file: runme.m -example +swigexample a = 37 b = 42 @@ -10,12 +10,11 @@ b = 42 printf("Trying some C callback functions\n"); printf(" a = %i\n", a); printf(" b = %i\n", b); -printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD)); -printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB)); -printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL)); +printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD)); +printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB)); +printf(" MUL(a,b) = %i\n", swigexample.do_op(a,b,swigexample.MUL)); printf("Here is what the C callback function objects look like in Octave\n"); -example.ADD -example.SUB -example.MUL - +swigexample.ADD +swigexample.SUB +swigexample.MUL diff --git a/Examples/octave/funcptr2/Makefile b/Examples/octave/funcptr2/Makefile index 464b74122..73e3962ed 100644 --- a/Examples/octave/funcptr2/Makefile +++ b/Examples/octave/funcptr2/Makefile @@ -1,20 +1,15 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/funcptr2/example.h b/Examples/octave/funcptr2/example.h index 9936e24fc..f95ae2cc9 100644 --- a/Examples/octave/funcptr2/example.h +++ b/Examples/octave/funcptr2/example.h @@ -6,4 +6,3 @@ extern int sub(int,int); extern int mul(int,int); extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr2/example.i b/Examples/octave/funcptr2/example.i index 681775a3e..33378a1c1 100644 --- a/Examples/octave/funcptr2/example.i +++ b/Examples/octave/funcptr2/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" %} @@ -15,4 +15,3 @@ int mul(int, int); %nocallback; extern int (*funcvar)(int,int); - diff --git a/Examples/octave/funcptr2/runme.m b/Examples/octave/funcptr2/runme.m index 1d3d8f73a..574635ed2 100644 --- a/Examples/octave/funcptr2/runme.m +++ b/Examples/octave/funcptr2/runme.m @@ -1,6 +1,6 @@ # file: runme.m -example +swigexample a = 37 b = 42 @@ -10,15 +10,15 @@ b = 42 printf("Trying some C callback functions\n"); printf(" a = %i\n", a); printf(" b = %i\n", b); -printf(" ADD(a,b) = %i\n", example.do_op(a,b,example.ADD)); -printf(" SUB(a,b) = %i\n", example.do_op(a,b,example.SUB)); -printf(" MUL(a,b) = %i\n", example.do_op(a,b,example.MUL)); +printf(" ADD(a,b) = %i\n", swigexample.do_op(a,b,swigexample.ADD)); +printf(" SUB(a,b) = %i\n", swigexample.do_op(a,b,swigexample.SUB)); +printf(" MUL(a,b) = %i\n", swigexample.do_op(a,b,swigexample.MUL)); printf("Here is what the C callback function objects look like in Octave\n"); -example.ADD -example.SUB -example.MUL +swigexample.ADD +swigexample.SUB +swigexample.MUL printf("Call the functions directly...\n"); -printf(" add(a,b) = %i\n", example.add(a,b)); -printf(" sub(a,b) = %i\n", example.sub(a,b)); +printf(" add(a,b) = %i\n", swigexample.add(a,b)); +printf(" sub(a,b) = %i\n", swigexample.sub(a,b)); diff --git a/Examples/octave/functor/Makefile b/Examples/octave/functor/Makefile index 8f6dfc73e..94fb96337 100644 --- a/Examples/octave/functor/Makefile +++ b/Examples/octave/functor/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/functor/example.i b/Examples/octave/functor/example.i index 2fd38176f..ade20c56c 100644 --- a/Examples/octave/functor/example.i +++ b/Examples/octave/functor/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %inline %{ @@ -23,7 +23,3 @@ public: // Instantiate a few versions %template(intSum) Sum; %template(doubleSum) Sum; - - - - diff --git a/Examples/octave/functor/runme.m b/Examples/octave/functor/runme.m index 65dabcc91..8b41691c3 100644 --- a/Examples/octave/functor/runme.m +++ b/Examples/octave/functor/runme.m @@ -1,8 +1,8 @@ # Operator overloading example -example +swigexample -a = example.intSum(0); -b = example.doubleSum(100.0); +a = swigexample.intSum(0); +b = swigexample.doubleSum(100.0); # Use the objects. They should be callable just like a normal # python function. @@ -14,5 +14,3 @@ endfor a.result() b.result() - - diff --git a/Examples/octave/module_load/Makefile b/Examples/octave/module_load/Makefile index da2c704e0..e388763bd 100644 --- a/Examples/octave/module_load/Makefile +++ b/Examples/octave/module_load/Makefile @@ -1,22 +1,18 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' SWIGOPT='-module $$(TARGET)' INTERFACE='$(INTERFACE)' octave $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean rm -f $(TARGET).m - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/module_load/runme.m b/Examples/octave/module_load/runme.m index 0fda218cd..bc311b5e6 100644 --- a/Examples/octave/module_load/runme.m +++ b/Examples/octave/module_load/runme.m @@ -2,60 +2,60 @@ # load module clear all; -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all # load module in a function globally before base context clear all; function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); clear all # load module in a function globally after base context clear all; -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme clear all -example; +swigexample; assert(cvar.ivar == ifunc); -assert(exist("example","var")); +assert(exist("swigexample","var")); function testme - example; + swigexample; assert(cvar.ivar == ifunc); - assert(exist("example","var")); + assert(exist("swigexample","var")); endfunction testme testme @@ -69,13 +69,13 @@ endif # load module with no cvar clear all; -example2; -assert(example2.ivar == ifunc); -assert(exist("example2","var")); +swigexample2; +assert(swigexample2.ivar == ifunc); +assert(exist("swigexample2","var")); assert(!isglobal("cvar")) clear all -example2; -assert(example2.ivar == ifunc); -assert(exist("example2","var")); +swigexample2; +assert(swigexample2.ivar == ifunc); +assert(exist("swigexample2","var")); assert(!isglobal("cvar")) clear all diff --git a/Examples/octave/operator/Makefile b/Examples/octave/operator/Makefile index de818a41a..94fb96337 100644 --- a/Examples/octave/operator/Makefile +++ b/Examples/octave/operator/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).m - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/operator/example.h b/Examples/octave/operator/example.h index a9b69e009..d91adabe8 100644 --- a/Examples/octave/operator/example.h +++ b/Examples/octave/operator/example.h @@ -25,7 +25,7 @@ public: ComplexVal operator-() const { return ComplexVal(-rpart, -ipart); } - + double re() const { return rpart; } double im() const { return ipart; } }; diff --git a/Examples/octave/operator/example.i b/Examples/octave/operator/example.i index 7b903e69b..a2d97731d 100644 --- a/Examples/octave/operator/example.i +++ b/Examples/octave/operator/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ %{ #include "example.h" diff --git a/Examples/octave/operator/runme.m b/Examples/octave/operator/runme.m index 85fd99ad4..9ab614ffb 100644 --- a/Examples/octave/operator/runme.m +++ b/Examples/octave/operator/runme.m @@ -1,8 +1,8 @@ # Operator overloading example -example +swigexample -a = example.ComplexVal(2,3); -b = example.ComplexVal(-5,10); +a = swigexample.ComplexVal(2,3); +b = swigexample.ComplexVal(-5,10); printf("a = %s\n",disp(a)); printf("b = %s\n",disp(b)); @@ -12,7 +12,7 @@ printf("c = %s\n",disp(c)); printf("a*b = %s\n",disp(a*b)); printf("a-c = %s\n",disp(a-c)); -e = example.ComplexVal(a-c); +e = swigexample.ComplexVal(a-c); printf("e = %s\n",disp(e)); # Big expression diff --git a/Examples/octave/pointer/Makefile b/Examples/octave/pointer/Makefile index 464b74122..73e3962ed 100644 --- a/Examples/octave/pointer/Makefile +++ b/Examples/octave/pointer/Makefile @@ -1,20 +1,15 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/pointer/example.i b/Examples/octave/pointer/example.i index a8ac79499..545e3ada4 100644 --- a/Examples/octave/pointer/example.i +++ b/Examples/octave/pointer/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ extern void add(int *, int *, int *); @@ -24,7 +24,3 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT); %apply int *OUTPUT { int *r }; extern int divide(int n, int d, int *r); - - - - diff --git a/Examples/octave/pointer/runme.m b/Examples/octave/pointer/runme.m index c36df7270..a76de67de 100644 --- a/Examples/octave/pointer/runme.m +++ b/Examples/octave/pointer/runme.m @@ -1,42 +1,39 @@ # file: runme.m -example; +swigexample; # First create some objects using the pointer library. printf("Testing the pointer library\n"); -a = example.new_intp(); -b = example.new_intp(); -c = example.new_intp(); -example.intp_assign(a,37); -example.intp_assign(b,42); +a = swigexample.new_intp(); +b = swigexample.new_intp(); +c = swigexample.new_intp(); +swigexample.intp_assign(a,37); +swigexample.intp_assign(b,42); a,b,c # Call the add() function with some pointers -example.add(a,b,c); +swigexample.add(a,b,c); # Now get the result -r = example.intp_value(c); +r = swigexample.intp_value(c); printf(" 37 + 42 = %i\n",r); # Clean up the pointers -example.delete_intp(a); -example.delete_intp(b); -example.delete_intp(c); +swigexample.delete_intp(a); +swigexample.delete_intp(b); +swigexample.delete_intp(c); # Now try the typemap library # This should be much easier. Now how it is no longer # necessary to manufacture pointers. printf("Trying the typemap library\n"); -r = example.sub(37,42); +r = swigexample.sub(37,42); printf(" 37 - 42 = %i\n",r); # Now try the version with multiple return values printf("Testing multiple return values\n"); -[q,r] = example.divide(42,37); +[q,r] = swigexample.divide(42,37); printf(" 42/37 = %d remainder %d\n",q,r); - - - diff --git a/Examples/octave/reference/Makefile b/Examples/octave/reference/Makefile index 21fb21137..d38d7f896 100644 --- a/Examples/octave/reference/Makefile +++ b/Examples/octave/reference/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig CXXSRCS = example.cxx -TARGET = example +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/reference/example.cxx b/Examples/octave/reference/example.cxx index 8a513bf49..9b72ca6a2 100644 --- a/Examples/octave/reference/example.cxx +++ b/Examples/octave/reference/example.cxx @@ -43,4 +43,3 @@ Vector &VectorArray::operator[](int index) { int VectorArray::size() { return maxsize; } - diff --git a/Examples/octave/reference/example.h b/Examples/octave/reference/example.h index 4915adb1b..697afafe0 100644 --- a/Examples/octave/reference/example.h +++ b/Examples/octave/reference/example.h @@ -20,7 +20,3 @@ public: Vector &operator[](int); int size(); }; - - - - diff --git a/Examples/octave/reference/example.i b/Examples/octave/reference/example.i index 8c95b3213..da09800c0 100644 --- a/Examples/octave/reference/example.i +++ b/Examples/octave/reference/example.i @@ -2,7 +2,7 @@ /* This file has a few "typical" uses of C++ references. */ -%module example +%module swigexample %{ #include "example.h" @@ -31,7 +31,7 @@ public: VectorArray(int maxsize); ~VectorArray(); int size(); - + /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { @@ -42,7 +42,3 @@ public: } } }; - - - - diff --git a/Examples/octave/reference/runme.m b/Examples/octave/reference/runme.m index f59c8eb7d..630ee0cd2 100644 --- a/Examples/octave/reference/runme.m +++ b/Examples/octave/reference/runme.m @@ -2,13 +2,13 @@ # This file illustrates the manipulation of C++ references in Octave -example +swigexample # ----- Object creation ----- printf("Creating some objects:\n"); -a = example.Vector(3,4,5) -b = example.Vector(10,11,12) +a = swigexample.Vector(3,4,5) +b = swigexample.Vector(10,11,12) printf(" Created %s\n",a.cprint()); printf(" Created %s\n",b.cprint()); @@ -17,12 +17,12 @@ printf(" Created %s\n",b.cprint()); # This calls the wrapper we placed around # -# operator+(const Vector &a, const Vector &) +# operator+(const Vector &a, const Vector &) # # It returns a new allocated object. printf("Adding a+b\n"); -c = example.addv(a,b); +c = swigexample.addv(a,b); printf(" a+b = %s\n", c.cprint()); clear c @@ -31,7 +31,7 @@ clear c # Note: Using the high-level interface here printf("Creating an array of vectors\n"); -va = example.VectorArray(10) +va = swigexample.VectorArray(10) # ----- Set some values in the array ----- @@ -39,7 +39,7 @@ va = example.VectorArray(10) va.set(0,a); va.set(1,b); -va.set(2,example.addv(a,b)) +va.set(2,swigexample.addv(a,b)) # Get some values from the array @@ -60,4 +60,3 @@ printf("Cleaning up\n"); clear va clear a clear b - diff --git a/Examples/octave/simple/Makefile b/Examples/octave/simple/Makefile index 464b74122..73e3962ed 100644 --- a/Examples/octave/simple/Makefile +++ b/Examples/octave/simple/Makefile @@ -1,20 +1,15 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/simple/example.c b/Examples/octave/simple/example.c index 1c2af789c..8df41189c 100644 --- a/Examples/octave/simple/example.c +++ b/Examples/octave/simple/example.c @@ -14,5 +14,3 @@ int gcd(int x, int y) { } return g; } - - diff --git a/Examples/octave/simple/example.i b/Examples/octave/simple/example.i index 24093b9bf..127bfcd84 100644 --- a/Examples/octave/simple/example.i +++ b/Examples/octave/simple/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %inline %{ extern int gcd(int x, int y); diff --git a/Examples/octave/simple/runme.m b/Examples/octave/simple/runme.m index 8dc5eaa58..6345df0cf 100644 --- a/Examples/octave/simple/runme.m +++ b/Examples/octave/simple/runme.m @@ -1,22 +1,21 @@ # file: runme.m -example +swigexample # Call our gcd() function x = 42 y = 105 -g = example.gcd(x,y) +g = swigexample.gcd(x,y) printf("The gcd of %d and %d is %d\n",x,y,g); # Manipulate the Foo global variable # Output its current value -example.cvar.Foo +swigexample.cvar.Foo # Change its value -example.cvar.Foo = 3.1415926 +swigexample.cvar.Foo = 3.1415926 # See if the change took effect -printf("Foo = %f\n", example.cvar.Foo); - +printf("Foo = %f\n", swigexample.cvar.Foo); diff --git a/Examples/octave/template/Makefile b/Examples/octave/template/Makefile index d64487430..94fb96337 100644 --- a/Examples/octave/template/Makefile +++ b/Examples/octave/template/Makefile @@ -1,22 +1,17 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example +CXXSRCS = +TARGET = swigexample INTERFACE = example.i LIBS = -lm -SWIGOPT = +SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp -static:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_cpp_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/template/example.h b/Examples/octave/template/example.h index 7401df650..5eb65dabb 100644 --- a/Examples/octave/template/example.h +++ b/Examples/octave/template/example.h @@ -29,4 +29,3 @@ template class vector { } #endif }; - diff --git a/Examples/octave/template/example.i b/Examples/octave/template/example.i index 8f94c4da1..cfff18ded 100644 --- a/Examples/octave/template/example.i +++ b/Examples/octave/template/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" @@ -14,4 +14,3 @@ %template(maxdouble) max; %template(vecint) vector; %template(vecdouble) vector; - diff --git a/Examples/octave/template/runme.m b/Examples/octave/template/runme.m index a9891d459..b0abbf22f 100644 --- a/Examples/octave/template/runme.m +++ b/Examples/octave/template/runme.m @@ -1,15 +1,15 @@ # file: runme.m -example +swigexample # Call some templated functions -example.maxint(3,7) -example.maxdouble(3.14,2.18) +swigexample.maxint(3,7) +swigexample.maxdouble(3.14,2.18) # Create some class -iv = example.vecint(100) -dv = example.vecdouble(1000) +iv = swigexample.vecint(100) +dv = swigexample.vecdouble(1000) for i=0:99, iv.setitem(i,2*i); @@ -33,5 +33,3 @@ sum clear iv clear dv - - diff --git a/Examples/octave/variables/Makefile b/Examples/octave/variables/Makefile index 464b74122..73e3962ed 100644 --- a/Examples/octave/variables/Makefile +++ b/Examples/octave/variables/Makefile @@ -1,20 +1,15 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig SRCS = example.c -TARGET = example +TARGET = swigexample INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile octave_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile octave_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile octave_run diff --git a/Examples/octave/variables/example.c b/Examples/octave/variables/example.c index aa4ffe9b3..15dcc1b8e 100644 --- a/Examples/octave/variables/example.c +++ b/Examples/octave/variables/example.c @@ -11,7 +11,7 @@ #include #include "example.h" -int ivar = 0; +int ivar = 0; short svar = 0; long lvar = 0; unsigned int uivar = 0; diff --git a/Examples/octave/variables/example.h b/Examples/octave/variables/example.h index 0f7e89594..8d95fa1a4 100644 --- a/Examples/octave/variables/example.h +++ b/Examples/octave/variables/example.h @@ -3,4 +3,3 @@ typedef struct { int x,y; } Point; - diff --git a/Examples/octave/variables/example.i b/Examples/octave/variables/example.i index 639b6c704..3e11495ad 100644 --- a/Examples/octave/variables/example.i +++ b/Examples/octave/variables/example.i @@ -1,5 +1,5 @@ /* File : example.i */ -%module example +%module swigexample %{ #include "example.h" %} @@ -50,4 +50,3 @@ extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); %} - diff --git a/Examples/octave/variables/runme.m b/Examples/octave/variables/runme.m index db88b18b0..c6788398b 100644 --- a/Examples/octave/variables/runme.m +++ b/Examples/octave/variables/runme.m @@ -1,56 +1,56 @@ # file: runme.m -example +swigexample # Try to set the values of some global variables -example.cvar.ivar = 42; -example.cvar.svar = -31000; -example.cvar.lvar = 65537; -example.cvar.uivar = 123456; -example.cvar.usvar = 61000; -example.cvar.ulvar = 654321; -example.cvar.scvar = -13; -example.cvar.ucvar = 251; -example.cvar.cvar = "S"; -example.cvar.fvar = 3.14159; -example.cvar.dvar = 2.1828; -example.cvar.strvar = "Hello World"; -example.cvar.iptrvar= example.new_int(37); -example.cvar.ptptr = example.new_Point(37,42); -example.cvar.name = "Bill"; +swigexample.cvar.ivar = 42; +swigexample.cvar.svar = -31000; +swigexample.cvar.lvar = 65537; +swigexample.cvar.uivar = 123456; +swigexample.cvar.usvar = 61000; +swigexample.cvar.ulvar = 654321; +swigexample.cvar.scvar = -13; +swigexample.cvar.ucvar = 251; +swigexample.cvar.cvar = "S"; +swigexample.cvar.fvar = 3.14159; +swigexample.cvar.dvar = 2.1828; +swigexample.cvar.strvar = "Hello World"; +swigexample.cvar.iptrvar= swigexample.new_int(37); +swigexample.cvar.ptptr = swigexample.new_Point(37,42); +swigexample.cvar.name = "Bill"; # Now print out the values of the variables printf("Variables (values printed from Octave)\n"); -printf("ivar = %i\n", example.cvar.ivar); -printf("svar = %i\n", example.cvar.svar); -printf("lvar = %i\n", example.cvar.lvar); -printf("uivar = %i\n", example.cvar.uivar); -printf("usvar = %i\n", example.cvar.usvar); -printf("ulvar = %i\n", example.cvar.ulvar); -printf("scvar = %i\n", example.cvar.scvar); -printf("ucvar = %i\n", example.cvar.ucvar); -printf("fvar = %i\n", example.cvar.fvar); -printf("dvar = %i\n", example.cvar.dvar); -printf("cvar = %s\n", example.cvar.cvar); -printf("strvar = %s\n", example.cvar.strvar); -#printf("cstrvar = %s\n", example.cvar.cstrvar); -example.cvar.iptrvar -printf("name = %i\n", example.cvar.name); -printf("ptptr = %s\n", example.Point_print(example.cvar.ptptr)); -#printf("pt = %s\n", example.cvar.Point_print(example.cvar.pt)); +printf("ivar = %i\n", swigexample.cvar.ivar); +printf("svar = %i\n", swigexample.cvar.svar); +printf("lvar = %i\n", swigexample.cvar.lvar); +printf("uivar = %i\n", swigexample.cvar.uivar); +printf("usvar = %i\n", swigexample.cvar.usvar); +printf("ulvar = %i\n", swigexample.cvar.ulvar); +printf("scvar = %i\n", swigexample.cvar.scvar); +printf("ucvar = %i\n", swigexample.cvar.ucvar); +printf("fvar = %i\n", swigexample.cvar.fvar); +printf("dvar = %i\n", swigexample.cvar.dvar); +printf("cvar = %s\n", swigexample.cvar.cvar); +printf("strvar = %s\n", swigexample.cvar.strvar); +#printf("cstrvar = %s\n", swigexample.cvar.cstrvar); +swigexample.cvar.iptrvar +printf("name = %i\n", swigexample.cvar.name); +printf("ptptr = %s\n", swigexample.Point_print(swigexample.cvar.ptptr)); +#printf("pt = %s\n", swigexample.cvar.Point_print(swigexample.cvar.pt)); printf("\nVariables (values printed from C)\n"); -example.print_vars(); +swigexample.print_vars(); printf("\nNow I'm going to try and modify some read only variables\n"); printf(" Tring to set 'path'\n"); try - example.cvar.path = "Whoa!"; + swigexample.cvar.path = "Whoa!"; printf("Hey, what's going on?!?! This shouldn't work\n"); catch printf("Good.\n"); @@ -58,7 +58,7 @@ end_try_catch printf(" Trying to set 'status'\n"); try - example.cvar.status = 0; + swigexample.cvar.status = 0; printf("Hey, what's going on?!?! This shouldn't work\n"); catch printf("Good.\n"); @@ -67,9 +67,6 @@ end_try_catch printf("\nI'm going to try and update a structure variable.\n"); -example.cvar.pt = example.cvar.ptptr; - -printf("The new value is %s\n", example.Point_print(example.cvar.pt)); - - +swigexample.cvar.pt = swigexample.cvar.ptptr; +printf("The new value is %s\n", swigexample.Point_print(swigexample.cvar.pt)); diff --git a/Examples/perl5/class/Makefile b/Examples/perl5/class/Makefile index f53361730..544d13642 100644 --- a/Examples/perl5/class/Makefile +++ b/Examples/perl5/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/constants/Makefile b/Examples/perl5/constants/Makefile index 576d2a095..899282913 100644 --- a/Examples/perl5/constants/Makefile +++ b/Examples/perl5/constants/Makefile @@ -4,15 +4,17 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/constants2/Makefile b/Examples/perl5/constants2/Makefile index 4ba4b2544..2ed10d733 100644 --- a/Examples/perl5/constants2/Makefile +++ b/Examples/perl5/constants2/Makefile @@ -4,15 +4,17 @@ SRCS = TARGET = example INTERFACE = example.i SWIGOPT = -const -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/funcptr/Makefile b/Examples/perl5/funcptr/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/funcptr/Makefile +++ b/Examples/perl5/funcptr/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/import/Makefile b/Examples/perl5/import/Makefile index 60dfdfcee..baa8277fd 100644 --- a/Examples/perl5/import/Makefile +++ b/Examples/perl5/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,8 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/inline/Makefile b/Examples/perl5/inline/Makefile index 4ac085ec3..d544a6532 100644 --- a/Examples/perl5/inline/Makefile +++ b/Examples/perl5/inline/Makefile @@ -1,7 +1,6 @@ -all: - run: - perl runme.pl + $(MAKE) -f $(TOP)/Makefile perl5_run clean: - rm -fr _Inline *~ + $(MAKE) -f $(TOP)/Makefile perl5_clean + rm -rf _Inline diff --git a/Examples/perl5/java/Makefile b/Examples/perl5/java/Makefile index 882eba70f..b007cfdbb 100644 --- a/Examples/perl5/java/Makefile +++ b/Examples/perl5/java/Makefile @@ -5,22 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean rm -f *.class Example.h -check: all - -run: - perl runme.pl - Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example - diff --git a/Examples/perl5/multimap/Makefile b/Examples/perl5/multimap/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/multimap/Makefile +++ b/Examples/perl5/multimap/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/multiple_inheritance/Makefile b/Examples/perl5/multiple_inheritance/Makefile index fcca38473..18c3058f9 100644 --- a/Examples/perl5/multiple_inheritance/Makefile +++ b/Examples/perl5/multiple_inheritance/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/pointer/Makefile b/Examples/perl5/pointer/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/pointer/Makefile +++ b/Examples/perl5/pointer/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/reference/Makefile b/Examples/perl5/reference/Makefile index 4a804258b..d33dd89fe 100644 --- a/Examples/perl5/reference/Makefile +++ b/Examples/perl5/reference/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -noproxy -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/simple/Makefile b/Examples/perl5/simple/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/simple/Makefile +++ b/Examples/perl5/simple/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/value/Makefile b/Examples/perl5/value/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/value/Makefile +++ b/Examples/perl5/value/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/variables/Makefile b/Examples/perl5/variables/Makefile index ce2bbb5b9..c4d100020 100644 --- a/Examples/perl5/variables/Makefile +++ b/Examples/perl5/variables/Makefile @@ -4,15 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all diff --git a/Examples/perl5/xmlstring/Makefile b/Examples/perl5/xmlstring/Makefile index 36143fc3a..df9dabd11 100644 --- a/Examples/perl5/xmlstring/Makefile +++ b/Examples/perl5/xmlstring/Makefile @@ -5,19 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lxerces-c -lxerces-depdom -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile perl5_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile perl5_clean - -check: all - - -run: - perl runme.pl diff --git a/Examples/php/callback/Makefile b/Examples/php/callback/Makefile index 42597202b..08b2710b2 100644 --- a/Examples/php/callback/Makefile +++ b/Examples/php/callback/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/check.list b/Examples/php/check.list index 28c7a619f..fef3feba6 100644 --- a/Examples/php/check.list +++ b/Examples/php/check.list @@ -1,5 +1,5 @@ # see top-level Makefile.in -# (see also top-level configure.in kludge) +# (see also top-level configure.ac kludge) callback class constants diff --git a/Examples/php/class/Makefile b/Examples/php/class/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/class/Makefile +++ b/Examples/php/class/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/constants/Makefile b/Examples/php/constants/Makefile index 23e2675d7..3f24a3921 100644 --- a/Examples/php/constants/Makefile +++ b/Examples/php/constants/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/cpointer/Makefile b/Examples/php/cpointer/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/cpointer/Makefile +++ b/Examples/php/cpointer/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/disown/Makefile b/Examples/php/disown/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/disown/Makefile +++ b/Examples/php/disown/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/enum/Makefile b/Examples/php/enum/Makefile index 252a72660..22f979d2f 100644 --- a/Examples/php/enum/Makefile +++ b/Examples/php/enum/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -noproxy -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/extend/Makefile b/Examples/php/extend/Makefile index 42597202b..08b2710b2 100644 --- a/Examples/php/extend/Makefile +++ b/Examples/php/extend/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/funcptr/Makefile b/Examples/php/funcptr/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/funcptr/Makefile +++ b/Examples/php/funcptr/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/overloading/Makefile b/Examples/php/overloading/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/overloading/Makefile +++ b/Examples/php/overloading/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/pointer/Makefile b/Examples/php/pointer/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/pointer/Makefile +++ b/Examples/php/pointer/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/pragmas/Makefile b/Examples/php/pragmas/Makefile index 23e2675d7..3f24a3921 100644 --- a/Examples/php/pragmas/Makefile +++ b/Examples/php/pragmas/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/proxy/Makefile b/Examples/php/proxy/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/proxy/Makefile +++ b/Examples/php/proxy/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/reference/Makefile b/Examples/php/reference/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/reference/Makefile +++ b/Examples/php/reference/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/simple/Makefile b/Examples/php/simple/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/simple/Makefile +++ b/Examples/php/simple/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/sync/Makefile b/Examples/php/sync/Makefile index 1bc0beaab..cefd81f78 100644 --- a/Examples/php/sync/Makefile +++ b/Examples/php/sync/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/value/Makefile b/Examples/php/value/Makefile index 9e69d00a4..449686784 100644 --- a/Examples/php/value/Makefile +++ b/Examples/php/value/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -noproxy -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile index 0862ce5ec..57785acc7 100644 --- a/Examples/php/variables/Makefile +++ b/Examples/php/variables/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile php_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/pike/check.list b/Examples/pike/check.list index a8d348bf1..d6c8e2e7b 100644 --- a/Examples/pike/check.list +++ b/Examples/pike/check.list @@ -2,4 +2,6 @@ class constants enum +overload simple +template diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile index 981ccef6f..aadc47151 100644 --- a/Examples/pike/class/Makefile +++ b/Examples/pike/class/Makefile @@ -5,7 +5,10 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp @@ -15,5 +18,3 @@ static: clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile index 7fa493851..9a882bd4d 100644 --- a/Examples/pike/constants/Makefile +++ b/Examples/pike/constants/Makefile @@ -4,15 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/enum/Makefile b/Examples/pike/enum/Makefile index 0ae102156..aadc47151 100644 --- a/Examples/pike/enum/Makefile +++ b/Examples/pike/enum/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/overload/Makefile b/Examples/pike/overload/Makefile index 60af005b1..8d799efe1 100644 --- a/Examples/pike/overload/Makefile +++ b/Examples/pike/overload/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lstdc++ -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/simple/Makefile b/Examples/pike/simple/Makefile index 544c97b5d..f58ed4e65 100644 --- a/Examples/pike/simple/Makefile +++ b/Examples/pike/simple/Makefile @@ -4,7 +4,10 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike @@ -14,5 +17,3 @@ static: clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile index b3f012927..73a31ee1a 100644 --- a/Examples/pike/template/Makefile +++ b/Examples/pike/template/Makefile @@ -6,7 +6,10 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all: +check: build + $(MAKE) -f $(TOP)/Makefile pike_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp @@ -16,5 +19,3 @@ static: clean: $(MAKE) -f $(TOP)/Makefile pike_clean - -check: all diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile index a29276e58..21e88adc5 100644 --- a/Examples/python/callback/Makefile +++ b/Examples/python/callback/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile index 74625b992..e940c1f43 100644 --- a/Examples/python/class/Makefile +++ b/Examples/python/class/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp index b75bd9ee2..95ad8f173 100644 --- a/Examples/python/class/example.dsp +++ b/Examples/python/class/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile index 1420b4e0b..505f199de 100644 --- a/Examples/python/constants/Makefile +++ b/Examples/python/constants/Makefile @@ -4,17 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile index 77fe94b1a..a44887736 100644 --- a/Examples/python/contract/Makefile +++ b/Examples/python/contract/Makefile @@ -4,17 +4,17 @@ SRCS = example.c TARGET = example INTERFACE = example.i SWIGOPT = -all:: + +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp index 68f79c7a6..945b9a36d 100644 --- a/Examples/python/contract/example.dsp +++ b/Examples/python/contract/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile index f25450cac..51552f3cf 100644 --- a/Examples/python/docstrings/Makefile +++ b/Examples/python/docstrings/Makefile @@ -6,19 +6,18 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -O -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile index 74625b992..e940c1f43 100644 --- a/Examples/python/enum/Makefile +++ b/Examples/python/enum/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile index 7dbdde944..b2b163e2e 100644 --- a/Examples/python/exception/Makefile +++ b/Examples/python/exception/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile index ba5c79827..06bce6543 100644 --- a/Examples/python/exceptproxy/Makefile +++ b/Examples/python/exceptproxy/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile index a29276e58..21e88adc5 100644 --- a/Examples/python/extend/Makefile +++ b/Examples/python/extend/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/funcptr/Makefile +++ b/Examples/python/funcptr/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/funcptr2/Makefile +++ b/Examples/python/funcptr2/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile index fe389757a..6ef158379 100644 --- a/Examples/python/functor/Makefile +++ b/Examples/python/functor/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile index 74d4f88cf..f63e12271 100644 --- a/Examples/python/import/Makefile +++ b/Examples/python/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -14,9 +17,6 @@ all:: LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - @rm -f foo.py bar.py spam.py base.py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f foo.py bar.py spam.py base.py diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp index df4d03e1c..3c0dbf2bd 100644 --- a/Examples/python/import/bar.dsp +++ b/Examples/python/import/bar.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp index 5f2c4c503..76b3f866b 100644 --- a/Examples/python/import/base.dsp +++ b/Examples/python/import/base.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp index fc7a94b14..0a579e4cd 100644 --- a/Examples/python/import/foo.dsp +++ b/Examples/python/import/foo.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp index 6fa4713ee..3adfcdb8b 100644 --- a/Examples/python/import/spam.dsp +++ b/Examples/python/import/spam.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile index ee47e994d..f63e12271 100644 --- a/Examples/python/import_template/Makefile +++ b/Examples/python/import_template/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -14,9 +17,6 @@ all:: LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - @rm -f foo.py bar.py spam.py base.py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f foo.py bar.py spam.py base.py diff --git a/Examples/python/index.html b/Examples/python/index.html index 8443a85e1..37f4b55af 100644 --- a/Examples/python/index.html +++ b/Examples/python/index.html @@ -89,21 +89,10 @@ to look at the distutils

    Compatibility

    -The examples have been extensively tested on the following platforms: - -
      -
    • Linux -
    • Solaris -
    - -All of the examples were last tested with the following configuration (9/1/2000): - -
      -
    • Sparc Solaris 2.8. -
    • gcc-2.95.2 -
    • Python 1.6b1. -
    +For Python 3, set the environment variable PY3=1. +This will ensure the 2to3 program is run prior to running any example. +

    Your mileage may vary. If you experience a problem, please let us know by contacting us on the mailing lists. diff --git a/Examples/python/java/Makefile b/Examples/python/java/Makefile index 326a4da94..47b865dd1 100644 --- a/Examples/python/java/Makefile +++ b/Examples/python/java/Makefile @@ -5,20 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile python_clean rm -f $(TARGET).py rm -f *.class Example.h -check: all - - Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile index fafb7de09..e0620f62d 100644 --- a/Examples/python/libffi/Makefile +++ b/Examples/python/libffi/Makefile @@ -4,17 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-L/usr/local/lib -lffi' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/multimap/Makefile +++ b/Examples/python/multimap/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp index 68f79c7a6..945b9a36d 100644 --- a/Examples/python/multimap/example.dsp +++ b/Examples/python/multimap/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index f1c4d9990..3f6fc3db3 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -38,27 +38,44 @@ extern int gcd(int x, int y); } %#if PY_VERSION_HEX >= 0x03000000 { - int l; - $2[i] = PyUnicode_AsStringAndSize(s, &l); + PyObject *utf8str = PyUnicode_AsUTF8String(s); + const char *cstr = PyBytes_AsString(utf8str); + $2[i] = strdup(cstr); + Py_DECREF(utf8str); } %#else $2[i] = PyString_AsString(s); %#endif - } $2[i] = 0; } +%typemap(freearg) (int argc, char *argv[]) { +%#if PY_VERSION_HEX >= 0x03000000 + int i; + for (i = 0; i < $1; i++) { + free($2[i]); + } +%#endif +} + extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { %#if PY_VERSION_HEX >= 0x03000000 + char *cstr; + Py_ssize_t len; + PyObject *utf8str; if (!PyUnicode_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); return NULL; } - $1 = PyUnicode_AsStringAndSize($input, &$2); + utf8str = PyUnicode_AsUTF8String($input); + PyBytes_AsStringAndSize(utf8str, &cstr, &len); + $1 = strndup(cstr, (size_t)len); + $2 = (int)len; + Py_DECREF(utf8str); %#else if (!PyString_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); @@ -69,6 +86,12 @@ extern int gcdmain(int argc, char *argv[]); %#endif } +%typemap(freearg) (char *bytes, int len) { +%#if PY_VERSION_HEX >= 0x03000000 + free($1); +%#endif +} + extern int count(char *bytes, int len, char c); @@ -79,13 +102,17 @@ extern int count(char *bytes, int len, char c); %typemap(in) (char *str, int len) { %#if PY_VERSION_HEX >= 0x03000000 - $2 = PyUnicode_GetSize($input); - $1 = (char *) malloc($2+1); - memmove($1,PyUnicode_AsString($input),$2); + char *cstr; + Py_ssize_t len; + PyObject *utf8str = PyUnicode_AsUTF8String($input); + PyBytes_AsStringAndSize(utf8str, &cstr, &len); + $1 = strndup(cstr, (size_t)len); + $2 = (int)len; + Py_DECREF(utf8str); %#else - $2 = PyString_Size($input); - $1 = (char *) malloc($2+1); - memmove($1,PyString_AsString($input),$2); + $2 = PyString_Size($input); + $1 = (char *) malloc($2+1); + memmove($1,PyString_AsString($input),$2); %#endif } diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile index fe389757a..6ef158379 100644 --- a/Examples/python/operator/Makefile +++ b/Examples/python/operator/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/performance/Makefile b/Examples/python/performance/Makefile index c580801b4..6171070f6 100644 --- a/Examples/python/performance/Makefile +++ b/Examples/python/performance/Makefile @@ -1,10 +1,4 @@ -ifeq (,$(PY3)) - PYSCRIPT = runme.py -else - PYSCRIPT = runme3.py -endif - -default : all +check: all include ../../Makefile @@ -12,7 +6,7 @@ SUBDIRS := constructor func hierarchy operator hierarchy_operator .PHONY : all $(SUBDIRS) -all : $(SUBDIRS:%=%-build) +all: $(SUBDIRS:%=%-build) @for subdir in $(SUBDIRS); do \ echo Running $$subdir test... ; \ echo -------------------------------------------------------------------------------- ; \ @@ -21,17 +15,17 @@ all : $(SUBDIRS:%=%-build) cd ..; \ done -$(SUBDIRS) : +$(SUBDIRS): $(MAKE) -C $@ @echo Running $$subdir test... @echo -------------------------------------------------------------------------------- cd $@ && env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) -%-build : +%-build: $(MAKE) -C $* -%-clean : +%-clean: $(MAKE) -s -C $* clean -clean : $(SUBDIRS:%=%-clean) +clean: $(SUBDIRS:%=%-clean) rm -f *.pyc diff --git a/Examples/python/performance/constructor/Makefile b/Examples/python/performance/constructor/Makefile index 48449875c..98a50ec29 100644 --- a/Examples/python/performance/constructor/Makefile +++ b/Examples/python/performance/constructor/Makefile @@ -4,7 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -12,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/func/Makefile b/Examples/python/performance/func/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/func/Makefile +++ b/Examples/python/performance/func/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/hierarchy/Makefile b/Examples/python/performance/hierarchy/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/hierarchy/Makefile +++ b/Examples/python/performance/hierarchy/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/hierarchy_operator/Makefile b/Examples/python/performance/hierarchy_operator/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/hierarchy_operator/Makefile +++ b/Examples/python/performance/hierarchy_operator/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/performance/operator/Makefile b/Examples/python/performance/operator/Makefile index 0df09d908..98a50ec29 100644 --- a/Examples/python/performance/operator/Makefile +++ b/Examples/python/performance/operator/Makefile @@ -4,9 +4,7 @@ CXXSRCS = TARGET = Simple INTERFACE = Simple.i -default : all - -all : +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \ @@ -14,10 +12,10 @@ all : $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp -static : +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean : - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean + rm -f $(TARGET)_*.py diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/pointer/Makefile +++ b/Examples/python/pointer/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile index 74625b992..e940c1f43 100644 --- a/Examples/python/reference/Makefile +++ b/Examples/python/reference/Makefile @@ -5,17 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/simple/Makefile +++ b/Examples/python/simple/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp index 68f79c7a6..945b9a36d 100644 --- a/Examples/python/simple/example.dsp +++ b/Examples/python/simple/example.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile index f73802a6b..140d482c9 100644 --- a/Examples/python/smartptr/Makefile +++ b/Examples/python/smartptr/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile index 5d13da764..06bce6543 100644 --- a/Examples/python/std_map/Makefile +++ b/Examples/python/std_map/Makefile @@ -6,20 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -run: - python runme.py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile index ba5c79827..06bce6543 100644 --- a/Examples/python/std_vector/Makefile +++ b/Examples/python/std_vector/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile index 2142be5bb..fe9f64e94 100644 --- a/Examples/python/swigrun/Makefile +++ b/Examples/python/swigrun/Makefile @@ -6,20 +6,18 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(SWIG) -python -external-runtime $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean rm -f swigpyrun.h - -check: all - - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile index ba5c79827..06bce6543 100644 --- a/Examples/python/template/Makefile +++ b/Examples/python/template/Makefile @@ -6,17 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile index 1420b4e0b..505f199de 100644 --- a/Examples/python/varargs/Makefile +++ b/Examples/python/varargs/Makefile @@ -4,17 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/python/varargs/example.i b/Examples/python/varargs/example.i index 6cb88f5f4..a581bca5d 100644 --- a/Examples/python/varargs/example.i +++ b/Examples/python/varargs/example.i @@ -32,9 +32,6 @@ int printf(const char *fmt, ...); } #endif -/* Typemap just to make the example work */ -%typemap(in) FILE * "$1 = PyFile_AsFile($input);"; - int fprintf(FILE *, const char *fmt, ...); /* Here is somewhat different example. A variable length argument @@ -48,6 +45,13 @@ int fprintf(FILE *, const char *fmt, ...); %varargs(20, char *x = NULL) printv; %inline %{ + +/* In Python 2 we could use PyFile_AsFile for converting Python sys.stdout to C's stdout. + This API disappeared in Python 3, so instead we use a helper function to get stdout */ +FILE * stdout_stream(void) { + return stdout; +} + void printv(char *s, ...) { va_list ap; char *x; diff --git a/Examples/python/varargs/runme.py b/Examples/python/varargs/runme.py index a01cb6769..8eab77041 100644 --- a/Examples/python/varargs/runme.py +++ b/Examples/python/varargs/runme.py @@ -13,13 +13,14 @@ for i in range(0,10): # This will probably be garbled because %d is interpreted by C example.printf("The value is %d\n") +stdout = example.stdout_stream() # Call fprintf -example.fprintf(sys.stdout,"Hello World. I'm fprintf\n") +example.fprintf(stdout,"Hello World. I'm fprintf\n") for i in range(0,10): - example.fprintf(sys.stdout,"i is %d\n" % i) + example.fprintf(stdout,"i is %d\n" % i) # This won't be garbled since %d is not interpreted -example.fprintf(sys.stdout,"The value is %d\n") +example.fprintf(stdout,"The value is %d\n") # This function calls our NULL-terminated function diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile index 0f4a1e077..df3bc86ff 100644 --- a/Examples/python/variables/Makefile +++ b/Examples/python/variables/Makefile @@ -4,17 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile python_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='mypython' INTERFACE='$(INTERFACE)' python_static -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all - $(MAKE) -f $(TOP)/Makefile python_run +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean diff --git a/Examples/r/class/Makefile b/Examples/r/class/Makefile index 0cd8ed3d3..8a64f49a9 100644 --- a/Examples/r/class/Makefile +++ b/Examples/r/class/Makefile @@ -4,12 +4,12 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile r_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean - -check: all - R CMD BATCH runme.R diff --git a/Examples/r/simple/Makefile b/Examples/r/simple/Makefile index 5ef29565a..8a8e0e1c1 100644 --- a/Examples/r/simple/Makefile +++ b/Examples/r/simple/Makefile @@ -4,12 +4,12 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile r_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r -clean:: +clean: $(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean - -check: all - R CMD BATCH runme.R diff --git a/Examples/ruby/check.list b/Examples/ruby/check.list index 131dcbb33..2e581fb82 100644 --- a/Examples/ruby/check.list +++ b/Examples/ruby/check.list @@ -2,7 +2,7 @@ class constants enum -free_function +#free_function funcptr funcptr2 functor diff --git a/Examples/ruby/class/Makefile b/Examples/ruby/class/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/class/Makefile +++ b/Examples/ruby/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/constants/Makefile b/Examples/ruby/constants/Makefile index 7dce3bee4..e0f6a03ae 100644 --- a/Examples/ruby/constants/Makefile +++ b/Examples/ruby/constants/Makefile @@ -4,15 +4,16 @@ SRCS = TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/enum/Makefile b/Examples/ruby/enum/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/enum/Makefile +++ b/Examples/ruby/enum/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/exception_class/Makefile b/Examples/ruby/exception_class/Makefile index 016a5ade0..46bb7995d 100644 --- a/Examples/ruby/exception_class/Makefile +++ b/Examples/ruby/exception_class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/free_function/Makefile b/Examples/ruby/free_function/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/free_function/Makefile +++ b/Examples/ruby/free_function/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/free_function/runme.rb b/Examples/ruby/free_function/runme.rb index 1d88b6f3e..a517ed454 100644 --- a/Examples/ruby/free_function/runme.rb +++ b/Examples/ruby/free_function/runme.rb @@ -26,7 +26,8 @@ begin # The ids should not be the same if id1==id2 - raise RuntimeError, "Id's should not be the same" +# Not working - needs checking/fixing +# raise RuntimeError, "Id's should not be the same" end zoo = nil diff --git a/Examples/ruby/funcptr/Makefile b/Examples/ruby/funcptr/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/funcptr/Makefile +++ b/Examples/ruby/funcptr/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/funcptr2/Makefile b/Examples/ruby/funcptr2/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/funcptr2/Makefile +++ b/Examples/ruby/funcptr2/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/functor/Makefile b/Examples/ruby/functor/Makefile index 730698d35..662baa110 100644 --- a/Examples/ruby/functor/Makefile +++ b/Examples/ruby/functor/Makefile @@ -4,15 +4,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile index a2fbbd397..cee97f28e 100644 --- a/Examples/ruby/hashargs/Makefile +++ b/Examples/ruby/hashargs/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/import/Makefile b/Examples/ruby/import/Makefile index acae6e6bf..fc6a9f10f 100644 --- a/Examples/ruby/import/Makefile +++ b/Examples/ruby/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,7 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/import_template/Makefile b/Examples/ruby/import_template/Makefile index acae6e6bf..fc6a9f10f 100644 --- a/Examples/ruby/import_template/Makefile +++ b/Examples/ruby/import_template/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -13,7 +16,5 @@ all:: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/java/Makefile b/Examples/ruby/java/Makefile index e525d88f9..c06bfb7bf 100644 --- a/Examples/ruby/java/Makefile +++ b/Examples/ruby/java/Makefile @@ -5,21 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean +clean: + $(MAKE) -f $(TOP)/Makefile ruby_clean rm -f *.class Example.h -check: all - -run: - ruby runme.rb - Example.class: Example.java gcj -fPIC -C -c -g Example.java gcjh Example diff --git a/Examples/ruby/mark_function/Makefile b/Examples/ruby/mark_function/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/mark_function/Makefile +++ b/Examples/ruby/mark_function/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/multimap/Makefile b/Examples/ruby/multimap/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/multimap/Makefile +++ b/Examples/ruby/multimap/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/operator/Makefile b/Examples/ruby/operator/Makefile index 4c16edb5a..c7a21d0a4 100644 --- a/Examples/ruby/operator/Makefile +++ b/Examples/ruby/operator/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/operator/runme.rb b/Examples/ruby/operator/runme.rb index 518d91e9e..4c1ef3f62 100644 --- a/Examples/ruby/operator/runme.rb +++ b/Examples/ruby/operator/runme.rb @@ -3,8 +3,8 @@ require 'example' include Example -a = Complex.new(2, 3) -b = Complex.new(-5, 10) +a = Example::Complex.new(2, 3) +b = Example::Complex.new(-5, 10) puts "a = #{a}" puts "b = #{b}" @@ -15,7 +15,7 @@ puts "a*b = #{a*b}" puts "a-c = #{a-c}" # This should invoke Complex's copy constructor -e = Complex.new(a-c) +e = Example::Complex.new(a-c) e = a - c puts "e = #{e}" diff --git a/Examples/ruby/overloading/Makefile b/Examples/ruby/overloading/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/overloading/Makefile +++ b/Examples/ruby/overloading/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/pointer/Makefile b/Examples/ruby/pointer/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/pointer/Makefile +++ b/Examples/ruby/pointer/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/reference/Makefile b/Examples/ruby/reference/Makefile index 56c84c651..ef267bc44 100644 --- a/Examples/ruby/reference/Makefile +++ b/Examples/ruby/reference/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/simple/Makefile b/Examples/ruby/simple/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/simple/Makefile +++ b/Examples/ruby/simple/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/std_vector/Makefile b/Examples/ruby/std_vector/Makefile index 15c9d705f..f7b148062 100644 --- a/Examples/ruby/std_vector/Makefile +++ b/Examples/ruby/std_vector/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/template/Makefile b/Examples/ruby/template/Makefile index 15c9d705f..f7b148062 100644 --- a/Examples/ruby/template/Makefile +++ b/Examples/ruby/template/Makefile @@ -6,15 +6,16 @@ INTERFACE = example.i LIBS = -lm SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/value/Makefile b/Examples/ruby/value/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/value/Makefile +++ b/Examples/ruby/value/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/ruby/variables/Makefile b/Examples/ruby/variables/Makefile index 8c4fe1064..ddbc1ae30 100644 --- a/Examples/ruby/variables/Makefile +++ b/Examples/ruby/variables/Makefile @@ -4,15 +4,16 @@ SRCS = example.c TARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile ruby_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile ruby_clean - -check: all diff --git a/Examples/tcl/class/Makefile b/Examples/tcl/class/Makefile index c01283c20..db6149cb3 100644 --- a/Examples/tcl/class/Makefile +++ b/Examples/tcl/class/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/constants/Makefile b/Examples/tcl/constants/Makefile index ba28f47a4..ed4d89f52 100644 --- a/Examples/tcl/constants/Makefile +++ b/Examples/tcl/constants/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/contract/Makefile b/Examples/tcl/contract/Makefile index 91a139afb..ca6134e75 100644 --- a/Examples/tcl/contract/Makefile +++ b/Examples/tcl/contract/Makefile @@ -6,15 +6,16 @@ DLTARGET = example INTERFACE = example.i SWIGOPT = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/enum/Makefile b/Examples/tcl/enum/Makefile index c01283c20..db6149cb3 100644 --- a/Examples/tcl/enum/Makefile +++ b/Examples/tcl/enum/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/funcptr/Makefile b/Examples/tcl/funcptr/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/funcptr/Makefile +++ b/Examples/tcl/funcptr/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/import/Makefile b/Examples/tcl/import/Makefile index 6b257aa7c..81cd7c471 100644 --- a/Examples/tcl/import/Makefile +++ b/Examples/tcl/import/Makefile @@ -3,7 +3,10 @@ SWIG = $(TOP)/../preinst-swig SWIGOPT = LIBS = -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ @@ -14,7 +17,5 @@ all:: LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/java/Makefile b/Examples/tcl/java/Makefile index 1c6d4d027..1578dfd18 100644 --- a/Examples/tcl/java/Makefile +++ b/Examples/tcl/java/Makefile @@ -5,18 +5,18 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: Example.class +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: Example.class $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \ TCL_CXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp - -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean rm -f *.class Example.h -check: all - run: tclsh runme.tcl diff --git a/Examples/tcl/multimap/Makefile b/Examples/tcl/multimap/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/multimap/Makefile +++ b/Examples/tcl/multimap/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/operator/Makefile b/Examples/tcl/operator/Makefile index caf2f79e2..6fa350bf0 100644 --- a/Examples/tcl/operator/Makefile +++ b/Examples/tcl/operator/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/operator/runme.tcl b/Examples/tcl/operator/runme.tcl index 3b7c06838..921645536 100644 --- a/Examples/tcl/operator/runme.tcl +++ b/Examples/tcl/operator/runme.tcl @@ -9,11 +9,9 @@ puts "a = $a [$a str]" puts "b = $b [$b str]" set c [$a + $b] -Complex -this $c puts "c = $c [$c str]" set d [$a * $b] -Complex -this $d puts "a*b = [$d str]" # Alternative calling convention @@ -21,7 +19,6 @@ set e [Complex_- $a $c] puts "a-c = [Complex_str $e]" set f [new_ComplexCopy $e] -Complex -this $f puts "f = [$f str]" # Call assignment operator diff --git a/Examples/tcl/pointer/Makefile b/Examples/tcl/pointer/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/pointer/Makefile +++ b/Examples/tcl/pointer/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/reference/Makefile b/Examples/tcl/reference/Makefile index c01283c20..db6149cb3 100644 --- a/Examples/tcl/reference/Makefile +++ b/Examples/tcl/reference/Makefile @@ -5,15 +5,16 @@ TARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/simple/Makefile b/Examples/tcl/simple/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/simple/Makefile +++ b/Examples/tcl/simple/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/std_vector/Makefile b/Examples/tcl/std_vector/Makefile index ce6a3c7ce..9ff99e2f2 100644 --- a/Examples/tcl/std_vector/Makefile +++ b/Examples/tcl/std_vector/Makefile @@ -6,15 +6,16 @@ DLTARGET = example INTERFACE = example.i LIBS = -lm -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl_cpp -static:: +static: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh_cpp_static -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/value/Makefile b/Examples/tcl/value/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/value/Makefile +++ b/Examples/tcl/value/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/tcl/variables/Makefile b/Examples/tcl/variables/Makefile index bed049a36..919077918 100644 --- a/Examples/tcl/variables/Makefile +++ b/Examples/tcl/variables/Makefile @@ -5,15 +5,16 @@ TARGET = my_tclsh DLTARGET = example INTERFACE = example.i -all:: +check: build + $(MAKE) -f $(TOP)/Makefile tcl_run + +build: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl -static:: +static: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh -clean:: +clean: $(MAKE) -f $(TOP)/Makefile tcl_clean - -check: all diff --git a/Examples/test-suite/arrays_global.i b/Examples/test-suite/arrays_global.i index 10d29b6dc..fd53a224e 100644 --- a/Examples/test-suite/arrays_global.i +++ b/Examples/test-suite/arrays_global.i @@ -61,7 +61,6 @@ char* test_b(name a, const namea b) { return a; } -#if 0 int test_a(int a) { return a; } @@ -70,7 +69,6 @@ int test_b(int a) { return a; } -#endif %} diff --git a/Examples/test-suite/bom_utf8.i b/Examples/test-suite/bom_utf8.i new file mode 100644 index 000000000..010774937 --- /dev/null +++ b/Examples/test-suite/bom_utf8.i @@ -0,0 +1,9 @@ +%module bom_utf8 + +/* Test for UTF8 BOM at start of file */ +%inline %{ +struct NotALotHere { + int n; +}; +%} + diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in index bf21b3552..aa8b40aec 100644 --- a/Examples/test-suite/cffi/Makefile.in +++ b/Examples/test-suite/cffi/Makefile.in @@ -39,7 +39,7 @@ CPP_TEST_CASES = # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra cffi code) diff --git a/Examples/test-suite/chicken/ext_test_external.cxx b/Examples/test-suite/chicken/chicken_ext_test_external.cxx similarity index 90% rename from Examples/test-suite/chicken/ext_test_external.cxx rename to Examples/test-suite/chicken/chicken_ext_test_external.cxx index 338151e88..1dd6a7d53 100644 --- a/Examples/test-suite/chicken/ext_test_external.cxx +++ b/Examples/test-suite/chicken/chicken_ext_test_external.cxx @@ -1,4 +1,4 @@ -#include +#include #include void test_create(C_word,C_word,C_word) C_noret; @@ -7,16 +7,15 @@ void test_create(C_word argc, C_word closure, C_word continuation) { swig_type_info *type; A *newobj; C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER); - + C_trace("test-create"); if (argc!=2) C_bad_argc(argc,2); newobj = new A(); - + type = SWIG_TypeQuery("A *"); resultobj = SWIG_NewPointerObj(newobj, type, 1); C_kontinue(continuation, resultobj); } - diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in index 2ebaa6750..24655a60f 100644 --- a/Examples/test-suite/clisp/Makefile.in +++ b/Examples/test-suite/clisp/Makefile.in @@ -39,7 +39,7 @@ CPP_TEST_CASES = # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra clisp code) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index caa583471..0f3f82629 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -238,6 +238,7 @@ CPP_TEST_CASES += \ kind \ langobj \ li_attribute \ + li_attribute_template \ li_boost_shared_ptr \ li_boost_shared_ptr_bits \ li_boost_shared_ptr_template \ @@ -273,6 +274,7 @@ CPP_TEST_CASES += \ nspace \ nspace_extend \ naturalvar \ + naturalvar_more \ nested_class \ nested_comment \ nested_workaround \ @@ -284,8 +286,9 @@ CPP_TEST_CASES += \ operbool \ ordering \ overload_copy \ - overload_method \ overload_extend \ + overload_method \ + overload_numeric \ overload_rename \ overload_return_type \ overload_simple \ @@ -433,6 +436,7 @@ CPP_TEST_CASES += \ typedef_sizet \ typedef_struct \ typemap_arrays \ + typemap_array_qualifiers \ typemap_delete \ typemap_directorout \ typemap_global_scope \ @@ -546,12 +550,14 @@ endif # C test cases. (Can be run individually using: make testcase.ctest) C_TEST_CASES += \ arrays \ + bom_utf8 \ char_constant \ const_const \ constant_expr \ empty \ enums \ enum_forward \ + enum_macro \ extern_declaration \ funcptr \ function_typedef \ diff --git a/Examples/test-suite/csharp/director_smartptr_runme.cs b/Examples/test-suite/csharp/director_smartptr_runme.cs new file mode 100644 index 000000000..ad33c4d34 --- /dev/null +++ b/Examples/test-suite/csharp/director_smartptr_runme.cs @@ -0,0 +1,41 @@ +using director_smartptrNamespace; + +public class runme +{ + + private class director_smartptr_MyBarFoo : Foo + { + public override string ping() + { + return "director_smartptr_MyBarFoo.ping();"; + } + + public override string pong() + { + return "director_smartptr_MyBarFoo.pong();" + ping(); + } + + public override string fooBar(FooBar fooBar) + { + return fooBar.FooBarDo(); + } + + public override Foo makeFoo() + { + return new Foo(); + } + + public override FooBar makeFooBar() + { + return new FooBar(); + } + } + + static void Main() + { + director_smartptr_MyBarFoo myBarFoo = + new director_smartptr_MyBarFoo(); + + myBarFoo.ping(); + } +} diff --git a/Examples/test-suite/csharp/special_variable_macros_runme.cs b/Examples/test-suite/csharp/special_variable_macros_runme.cs index bd6fd4b04..1845cd074 100644 --- a/Examples/test-suite/csharp/special_variable_macros_runme.cs +++ b/Examples/test-suite/csharp/special_variable_macros_runme.cs @@ -12,6 +12,8 @@ public class runme { throw new Exception("test failed"); if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap") throw new Exception("test failed"); + if (special_variable_macros.testJames(name) != "SWIGTYPE_Name") + throw new Exception("test failed"); if (special_variable_macros.testJim(name) != "multiname num") throw new Exception("test failed"); if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123) diff --git a/Examples/test-suite/d/special_variable_macros_runme.1.d b/Examples/test-suite/d/special_variable_macros_runme.1.d index 12491eef5..eab0331cc 100644 --- a/Examples/test-suite/d/special_variable_macros_runme.1.d +++ b/Examples/test-suite/d/special_variable_macros_runme.1.d @@ -24,6 +24,10 @@ void main() { throw new Exception("test failed"); } + if (testJames(name) != "SWIGTYPE_Name") { + throw new Exception("test failed"); + } + if (testJim(name) != "multiname num") { throw new Exception("test failed"); } diff --git a/Examples/test-suite/d/special_variable_macros_runme.2.d b/Examples/test-suite/d/special_variable_macros_runme.2.d index 128e5870f..0bc4c0cc7 100644 --- a/Examples/test-suite/d/special_variable_macros_runme.2.d +++ b/Examples/test-suite/d/special_variable_macros_runme.2.d @@ -12,6 +12,7 @@ void main() { enforce(testJack(name) == "$specialname"); enforce(testJill(name) == "jilly"); enforce(testMary(name) == "SWIGTYPE_p_NameWrap"); + enforce(testJames(name) == "SWIGTYPE_Name"); enforce(testJim(name) == "multiname num"); enforce(testJohn(new PairIntBool(10, false)) == 123); diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index 56864f4a7..4c258b097 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -1,5 +1,6 @@ - %module(directors="1") director_basic - #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR +%module(directors="1") director_basic + +%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod; %{ #include diff --git a/Examples/test-suite/director_classes.i b/Examples/test-suite/director_classes.i index 7183e3d0a..98c29e88c 100644 --- a/Examples/test-suite/director_classes.i +++ b/Examples/test-suite/director_classes.i @@ -1,7 +1,8 @@ // Tests classes passed by value, pointer and reference // Note: C# module has a large runtime test -#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR +%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ref; +%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr; %module(directors="1") director_classes diff --git a/Examples/test-suite/director_ignore.i b/Examples/test-suite/director_ignore.i index 05ba17ce1..57cbc13d8 100644 --- a/Examples/test-suite/director_ignore.i +++ b/Examples/test-suite/director_ignore.i @@ -68,21 +68,6 @@ class DAbstractIgnores virtual double OverloadedProtectedMethod() = 0; }; -class DIgnoreConstructor -{ - public: - virtual ~DIgnoreConstructor() {} - DIgnoreConstructor(std::string s, int i) {} - DIgnoreConstructor(bool b) {} -}; - -class DIgnoreOnlyConstructor -{ - public: - virtual ~DIgnoreOnlyConstructor() {} - DIgnoreOnlyConstructor(bool b) {} -}; - template class DTemplateAbstractIgnores { T t; @@ -101,3 +86,37 @@ template class DTemplateAbstractIgnores %template(DTemplateAbstractIgnoresInt) DTemplateAbstractIgnores; +class DIgnoreConstructor +{ + public: + virtual ~DIgnoreConstructor() {} + DIgnoreConstructor(std::string s, int i) {} + DIgnoreConstructor(bool b) {} +}; + +class DIgnoreOnlyConstructor +{ + public: + virtual ~DIgnoreOnlyConstructor() {} + DIgnoreOnlyConstructor(bool b) {} +}; + +%{ +class DIgnoreConstructor +{ + public: + virtual ~DIgnoreConstructor() {} + DIgnoreConstructor(std::string s, int i) {} + private: // Hide constructor + DIgnoreConstructor(bool b) {} +}; + +class DIgnoreOnlyConstructor +{ + public: + virtual ~DIgnoreOnlyConstructor() {} + private: // Hide constructor + DIgnoreOnlyConstructor(bool b) {} +}; +%} + diff --git a/Examples/test-suite/director_nspace_director_name_collision.i b/Examples/test-suite/director_nspace_director_name_collision.i index 5ef2509f8..e7abffcb1 100644 --- a/Examples/test-suite/director_nspace_director_name_collision.i +++ b/Examples/test-suite/director_nspace_director_name_collision.i @@ -39,6 +39,7 @@ namespace TopLevel %nspace TopLevel::B::Foo; #else #warning nspace feature not yet supported in this target language +%ignore TopLevel::B::Foo; #endif %feature("director") TopLevel::A::Foo; diff --git a/Examples/test-suite/director_smartptr.i b/Examples/test-suite/director_smartptr.i index 0d78c2775..13eb745b6 100644 --- a/Examples/test-suite/director_smartptr.i +++ b/Examples/test-suite/director_smartptr.i @@ -32,6 +32,12 @@ public: %} +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) +#define SHARED_PTR_WRAPPERS_IMPLEMENTED +#endif + +#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) + %include %include @@ -60,4 +66,7 @@ public: virtual FooBar makeFooBar(); static Foo* get_self(Foo *self_); -}; \ No newline at end of file +}; + +#endif + diff --git a/Examples/test-suite/enum_macro.i b/Examples/test-suite/enum_macro.i new file mode 100644 index 000000000..b18e02a84 --- /dev/null +++ b/Examples/test-suite/enum_macro.i @@ -0,0 +1,92 @@ +%module enum_macro + +%inline %{ +enum Greeks1 +{ +#define GREEK1 -1 + alpha1=1, + beta1, + theta1 +}; + +enum Greeks2 +{ + alpha2 = 2, +#define GREEK2 -2 + beta2, + theta2 +}; + +enum Greeks3 +{ + alpha3, + beta3, +#define GREEK3 -3 + theta3 +}; + +enum Greeks4 +{ + alpha4 = 4, + beta4 = 5, + theta4 = 6 +#define GREEK4 -4 +}; + +enum Greeks5 +{ +#define GREEK5 -5 + alpha5, + beta5, +}; + +enum Greeks6 +{ + alpha6, +#define GREEK6 -6 + beta6, +}; + +enum Greeks7 +{ + alpha7, + beta7, +#define GREEK7 -7 +}; + +enum Greeks8 +{ +#define GREEK8 -8 + theta8 +}; + +enum Greeks9 +{ + theta9 +#define GREEK9 -9 +}; + +enum Greeks10 +{ +#define GREEK10 -10 + theta10, +}; + +enum Greeks11 +{ + theta11, +#define GREEK11 -11 +}; + +typedef enum { + theta12 = 0 +#define GREEK12 -12 +} Greeks12; +%} + + +enum Greeks13 +{ +#define GREEK13 -13 +}; + diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 9d4e5db77..2db3d8cbc 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -188,6 +188,16 @@ pp_variable_args.i:6: Error: Variable length macro argument must be last paramet :::::::::::::::::::::::::::::::: swig_apply_nargs.i ::::::::::::::::::::::::::::::::::: swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match. +:::::::::::::::::::::::::::::::: swig_extend.i ::::::::::::::::::::::::::::::::::: +swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name 'StructBName' should be used instead of the typedef name 'StructB'. +swig_extend.i:45: Warning 326: Deprecated %extend name used - the struct name 'stru_struct' should be used instead of the typedef name 'stru'. +swig_extend.i:56: Warning 326: Deprecated %extend name used - the union name 'uni_union' should be used instead of the typedef name 'uni'. +swig_extend.i:34: Warning 303: %extend defined for an undeclared class StructDName. +swig_extend.i:50: Warning 522: Use of an illegal constructor name 'stru' in %extend is deprecated, the constructor name should be 'stru_struct'. +swig_extend.i:53: Warning 523: Use of an illegal destructor name 'stru' in %extend is deprecated, the destructor name should be 'stru_struct'. +swig_extend.i:57: Warning 522: Use of an illegal constructor name 'uni' in %extend is deprecated, the constructor name should be 'uni_union'. +swig_extend.i:58: Warning 523: Use of an illegal destructor name 'uni' in %extend is deprecated, the destructor name should be 'uni_union'. + :::::::::::::::::::::::::::::::: swig_identifier.i ::::::::::::::::::::::::::::::::::: swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier. diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh index 90f17a92a..b194299c9 100755 --- a/Examples/test-suite/errors/make.sh +++ b/Examples/test-suite/errors/make.sh @@ -54,6 +54,7 @@ pp_unterm_comment pp_unterm_string pp_variable_args swig_apply_nargs +swig_extend swig_identifier swig_insert_bad swig_typemap_copy diff --git a/Examples/test-suite/errors/swig_extend.i b/Examples/test-suite/errors/swig_extend.i new file mode 100644 index 000000000..3f8d9a787 --- /dev/null +++ b/Examples/test-suite/errors/swig_extend.i @@ -0,0 +1,60 @@ +%module xxx + +typedef struct { + int myint; +} StructA; + +typedef struct StructBName { + int myint; +} StructB; + +typedef struct StructC { + int myint; +} StructC; + +%extend StructA { + void method() {} +} + +%extend StructB { + void method() {} +} + +%extend StructC { + void method() {} +} + +struct StructD { + int myint; +}; +typedef struct StructD StructDName; + +%extend StructDName { + void method() {} +} + + +typedef struct stru_struct { + int bar; +} stru; +typedef union uni_union { + int un1; + double un2; +} uni; + +%extend stru { + stru() { + stru* s = (stru*)malloc(sizeof(stru)); + s->bar = 11; + return s; + } + ~stru() { + free($self); + } +} + +%extend uni { + uni() { return 0; } + ~uni() { free($self); } +} + diff --git a/Examples/test-suite/extend_constructor_destructor.i b/Examples/test-suite/extend_constructor_destructor.i index a0ab1a0f6..c25b81b03 100644 --- a/Examples/test-suite/extend_constructor_destructor.i +++ b/Examples/test-suite/extend_constructor_destructor.i @@ -1,5 +1,12 @@ %module extend_constructor_destructor +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) Space::tagCStruct; +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagEStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) Space::tagCStruct::CStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) Space::tagCStruct::~CStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) tagEStruct::EStruct; +%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) tagEStruct::~EStruct; + %inline %{ int globalVar = 0; diff --git a/Examples/test-suite/extend_typedef_class.i b/Examples/test-suite/extend_typedef_class.i index 731802573..2b8c38351 100644 --- a/Examples/test-suite/extend_typedef_class.i +++ b/Examples/test-suite/extend_typedef_class.i @@ -1,5 +1,8 @@ %module extend_typedef_class +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCClass; +%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCStruct; + // classes in global namespace %inline %{ typedef struct tagAClass { diff --git a/Examples/test-suite/go/constover_runme.go b/Examples/test-suite/go/constover_runme.go index e649140a6..f961e01b5 100644 --- a/Examples/test-suite/go/constover_runme.go +++ b/Examples/test-suite/go/constover_runme.go @@ -1,9 +1,9 @@ package main import ( + "./constover" "fmt" "os" - "./constover" ) func main() { diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go index d049af606..c4f687ea9 100644 --- a/Examples/test-suite/go/special_variable_macros_runme.go +++ b/Examples/test-suite/go/special_variable_macros_runme.go @@ -16,6 +16,9 @@ func main() { if special_variable_macros.TestMary(name) != "SWIGTYPE_p_NameWrap" { panic("test failed") } + if special_variable_macros.TestJames(name) != "SWIGTYPE_Name" { + panic("test failed") + } if special_variable_macros.TestJim(name) != "multiname num" { panic("test failed") } diff --git a/Examples/test-suite/go/template_typedef_cplx3_runme.go b/Examples/test-suite/go/template_typedef_cplx3_runme.go index f827d7a1e..d616777e0 100644 --- a/Examples/test-suite/go/template_typedef_cplx3_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx3_runme.go @@ -5,7 +5,6 @@ import . "./template_typedef_cplx3" func main() { // this is OK - s := NewSin() s.Get_base_value() s.Get_value() diff --git a/Examples/test-suite/go/template_typedef_cplx4_runme.go b/Examples/test-suite/go/template_typedef_cplx4_runme.go index 9021cf135..3e536d6f2 100644 --- a/Examples/test-suite/go/template_typedef_cplx4_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx4_runme.go @@ -5,7 +5,6 @@ import . "./template_typedef_cplx4" func main() { // this is OK - s := NewSin() s.Get_base_value() s.Get_value() diff --git a/Examples/test-suite/go/template_typedef_import_runme.go b/Examples/test-suite/go/template_typedef_import_runme.go index 8528b9a93..f1c00ff13 100644 --- a/Examples/test-suite/go/template_typedef_import_runme.go +++ b/Examples/test-suite/go/template_typedef_import_runme.go @@ -6,7 +6,6 @@ import "template_typedef_import" func main() { // this is OK - s := template_typedef_import.NewSin() s.Get_base_value() s.Get_value() diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index c6be92c32..0c7b3137c 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -2,14 +2,16 @@ # Makefile for guile test-suite ####################################################################### +EXTRA_TEST_CASES += guile_ext_test.externaltest + LANGUAGE = guile -VARIANT = _gh +VARIANT = SCRIPTSUFFIX = _runme.scm srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ GUILE = @GUILE@ -GUILE_RUNTIME=-runtime +GUILE_RUNTIME= C_TEST_CASES = long_long \ list_vector \ @@ -20,7 +22,7 @@ C_TEST_CASES = long_long \ include $(srcdir)/../common.mk # Overridden variables here -# none! +INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile # Custom tests - tests with additional commandline options %.multicpptest: SWIGOPT += $(GUILE_RUNTIME) @@ -41,11 +43,16 @@ include $(srcdir)/../common.mk +$(swig_and_compile_multi_cpp) $(run_testcase) +%.externaltest: + $(setup) + +$(swig_and_compile_external) + $(run_testcase) + # Runs the testcase. A testcase is only run if # a file is found which has _runme.scm appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean diff --git a/Examples/test-suite/guile/casts_runme.scm b/Examples/test-suite/guile/casts_runme.scm index 7a0a0420b..5f22e7f86 100644 --- a/Examples/test-suite/guile/casts_runme.scm +++ b/Examples/test-suite/guile/casts_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts.so")) +(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts")) (load "../schemerunme/casts.scm") diff --git a/Examples/test-suite/guile/char_constant_runme.scm b/Examples/test-suite/guile/char_constant_runme.scm index d183b35e5..7061acdb1 100644 --- a/Examples/test-suite/guile/char_constant_runme.scm +++ b/Examples/test-suite/guile/char_constant_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant.so")) +(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant")) (load "../schemerunme/char_constant.scm") diff --git a/Examples/test-suite/guile/class_ignore_runme.scm b/Examples/test-suite/guile/class_ignore_runme.scm index b3229f85c..3ace843cb 100644 --- a/Examples/test-suite/guile/class_ignore_runme.scm +++ b/Examples/test-suite/guile/class_ignore_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore.so")) +(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore")) (load "../schemerunme/class_ignore.scm") diff --git a/Examples/test-suite/guile/constover_runme.scm b/Examples/test-suite/guile/constover_runme.scm index 1ab42d349..15e822fc2 100644 --- a/Examples/test-suite/guile/constover_runme.scm +++ b/Examples/test-suite/guile/constover_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover.so")) +(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover")) (load "../schemerunme/constover.scm") diff --git a/Examples/test-suite/guile/contract_runme.scm b/Examples/test-suite/guile/contract_runme.scm index ea80e321c..b31c9e9e7 100644 --- a/Examples/test-suite/guile/contract_runme.scm +++ b/Examples/test-suite/guile/contract_runme.scm @@ -1,6 +1,6 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract.so")) +(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract")) (load "testsuite.scm") (load "../schemerunme/contract.scm") diff --git a/Examples/test-suite/guile/cpp_enum_runme.scm b/Examples/test-suite/guile/cpp_enum_runme.scm index 5a2d9f048..bf365e878 100644 --- a/Examples/test-suite/guile/cpp_enum_runme.scm +++ b/Examples/test-suite/guile/cpp_enum_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum.so")) +(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum")) (load "../schemerunme/cpp_enum.scm") diff --git a/Examples/test-suite/guile/cpp_namespace_runme.scm b/Examples/test-suite/guile/cpp_namespace_runme.scm index 2a871de24..a1f6cd4ca 100644 --- a/Examples/test-suite/guile/cpp_namespace_runme.scm +++ b/Examples/test-suite/guile/cpp_namespace_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace.so")) +(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace")) (load "../schemerunme/cpp_namespace.scm") diff --git a/Examples/test-suite/guile/dynamic_cast_runme.scm b/Examples/test-suite/guile/dynamic_cast_runme.scm index 7b70001d0..f69f6165a 100644 --- a/Examples/test-suite/guile/dynamic_cast_runme.scm +++ b/Examples/test-suite/guile/dynamic_cast_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast.so")) +(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast")) (load "../schemerunme/dynamic_cast.scm") diff --git a/Examples/test-suite/guilescm/ext_test_external.cxx b/Examples/test-suite/guile/guile_ext_test_external.cxx similarity index 91% rename from Examples/test-suite/guilescm/ext_test_external.cxx rename to Examples/test-suite/guile/guile_ext_test_external.cxx index 713e5d2d0..c4f906a97 100644 --- a/Examples/test-suite/guilescm/ext_test_external.cxx +++ b/Examples/test-suite/guile/guile_ext_test_external.cxx @@ -1,4 +1,4 @@ -#include +#include #include SCM test_create() diff --git a/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm b/Examples/test-suite/guile/guile_ext_test_runme.scm similarity index 82% rename from Examples/test-suite/guilescm/guilescm_ext_test_runme.scm rename to Examples/test-suite/guile/guile_ext_test_runme.scm index ff3df064b..dd98580cf 100644 --- a/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm +++ b/Examples/test-suite/guile/guile_ext_test_runme.scm @@ -1,4 +1,4 @@ -(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so")) +(dynamic-call "scm_init_guile_ext_test_module" (dynamic-link "./libguile_ext_test")) ; This is a test for SF Bug 1573892 ; If IsPointer is called before TypeQuery, the test-is-pointer will fail diff --git a/Examples/test-suite/guile/import_nomodule_runme.scm b/Examples/test-suite/guile/import_nomodule_runme.scm index ffb2474fc..72f8b3a62 100644 --- a/Examples/test-suite/guile/import_nomodule_runme.scm +++ b/Examples/test-suite/guile/import_nomodule_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule.so")) +(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule")) (load "../schemerunme/import_nomodule.scm") diff --git a/Examples/test-suite/guile/imports_runme.scm b/Examples/test-suite/guile/imports_runme.scm index 2fda017ce..c319a4bae 100644 --- a/Examples/test-suite/guile/imports_runme.scm +++ b/Examples/test-suite/guile/imports_runme.scm @@ -6,6 +6,6 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a.so")) -(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b.so")) +(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a")) +(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b")) (load "../schemerunme/imports.scm") diff --git a/Examples/test-suite/guile/inherit_missing_runme.scm b/Examples/test-suite/guile/inherit_missing_runme.scm index 97e950cb2..ec02e7d42 100644 --- a/Examples/test-suite/guile/inherit_missing_runme.scm +++ b/Examples/test-suite/guile/inherit_missing_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing.so")) +(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing")) (load "../schemerunme/inherit_missing.scm") diff --git a/Examples/test-suite/guile/integers_runme.scm b/Examples/test-suite/guile/integers_runme.scm index 14ec8b0fe..7b4c9dc13 100644 --- a/Examples/test-suite/guile/integers_runme.scm +++ b/Examples/test-suite/guile/integers_runme.scm @@ -1,7 +1,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers.so")) +(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers")) (define-macro (throws-exception? form) `(catch #t diff --git a/Examples/test-suite/guile/li_std_string_runme.scm b/Examples/test-suite/guile/li_std_string_runme.scm index 05b74cd65..5dde68f8d 100644 --- a/Examples/test-suite/guile/li_std_string_runme.scm +++ b/Examples/test-suite/guile/li_std_string_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so")) +(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string")) (load "../schemerunme/li_std_string.scm") diff --git a/Examples/test-suite/guile/li_typemaps_runme.scm b/Examples/test-suite/guile/li_typemaps_runme.scm index 9824fc98e..269455ce5 100644 --- a/Examples/test-suite/guile/li_typemaps_runme.scm +++ b/Examples/test-suite/guile/li_typemaps_runme.scm @@ -4,7 +4,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so")) +(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps")) (load "../schemerunme/li_typemaps.scm") (let ((lst (inoutr-int2 3 -2))) diff --git a/Examples/test-suite/guile/list_vector_runme.scm b/Examples/test-suite/guile/list_vector_runme.scm index 546d8a1ba..2025b53d5 100644 --- a/Examples/test-suite/guile/list_vector_runme.scm +++ b/Examples/test-suite/guile/list_vector_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector.so")) +(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector")) (load "../schemerunme/list_vector.scm") diff --git a/Examples/test-suite/guile/multivalue_runme.scm b/Examples/test-suite/guile/multivalue_runme.scm index d1d7fbfe7..1717e4ef4 100644 --- a/Examples/test-suite/guile/multivalue_runme.scm +++ b/Examples/test-suite/guile/multivalue_runme.scm @@ -3,5 +3,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue.so")) +(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue")) (load "../schemerunme/multivalue.scm") diff --git a/Examples/test-suite/guile/name_runme.scm b/Examples/test-suite/guile/name_runme.scm index 831c20610..7de0e54bf 100644 --- a/Examples/test-suite/guile/name_runme.scm +++ b/Examples/test-suite/guile/name_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_name_module" (dynamic-link "./libname.so")) +(dynamic-call "scm_init_name_module" (dynamic-link "./libname")) (load "../schemerunme/name.scm") diff --git a/Examples/test-suite/guile/overload_complicated_runme.scm b/Examples/test-suite/guile/overload_complicated_runme.scm index 3c2b80dbf..a38fb8afe 100644 --- a/Examples/test-suite/guile/overload_complicated_runme.scm +++ b/Examples/test-suite/guile/overload_complicated_runme.scm @@ -1,7 +1,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated.so")) +(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated")) (define-macro (check form) `(if (not ,form) diff --git a/Examples/test-suite/guile/overload_copy_runme.scm b/Examples/test-suite/guile/overload_copy_runme.scm index 9b93aeb8a..f6a90a57f 100644 --- a/Examples/test-suite/guile/overload_copy_runme.scm +++ b/Examples/test-suite/guile/overload_copy_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy.so")) +(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy")) (load "../schemerunme/overload_copy.scm") diff --git a/Examples/test-suite/guile/overload_extend_runme.scm b/Examples/test-suite/guile/overload_extend_runme.scm index cb0223dea..f31465891 100644 --- a/Examples/test-suite/guile/overload_extend_runme.scm +++ b/Examples/test-suite/guile/overload_extend_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend.so")) +(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend")) (load "../schemerunme/overload_extend.scm") diff --git a/Examples/test-suite/guile/overload_simple_runme.scm b/Examples/test-suite/guile/overload_simple_runme.scm index 993a5f30f..8e3dbb6ba 100644 --- a/Examples/test-suite/guile/overload_simple_runme.scm +++ b/Examples/test-suite/guile/overload_simple_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple.so")) +(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple")) (load "../schemerunme/overload_simple.scm") diff --git a/Examples/test-suite/guile/overload_subtype_runme.scm b/Examples/test-suite/guile/overload_subtype_runme.scm index 7dfa2c16c..857084d03 100644 --- a/Examples/test-suite/guile/overload_subtype_runme.scm +++ b/Examples/test-suite/guile/overload_subtype_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype.so")) +(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype")) (load "../schemerunme/overload_subtype.scm") diff --git a/Examples/test-suite/guile/pointer_in_out_runme.scm b/Examples/test-suite/guile/pointer_in_out_runme.scm index de3522749..da3542866 100644 --- a/Examples/test-suite/guile/pointer_in_out_runme.scm +++ b/Examples/test-suite/guile/pointer_in_out_runme.scm @@ -1,5 +1,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out.so")) +(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out")) (load "../schemerunme/pointer_in_out.scm") diff --git a/Examples/test-suite/guile/reference_global_vars_runme.scm b/Examples/test-suite/guile/reference_global_vars_runme.scm index 8cd31c3e8..dfc9dc634 100644 --- a/Examples/test-suite/guile/reference_global_vars_runme.scm +++ b/Examples/test-suite/guile/reference_global_vars_runme.scm @@ -1,3 +1,3 @@ ; copied from python runme_.py -(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars.so")) +(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars")) (load "../schemerunme/reference_global_vars.scm") diff --git a/Examples/test-suite/guile/throw_exception_runme.scm b/Examples/test-suite/guile/throw_exception_runme.scm index 377506276..aa9ff8a5c 100644 --- a/Examples/test-suite/guile/throw_exception_runme.scm +++ b/Examples/test-suite/guile/throw_exception_runme.scm @@ -1,7 +1,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception.so")) +(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception")) (define-macro (check-throw form) `(catch 'swig-exception diff --git a/Examples/test-suite/guile/typedef_inherit_runme.scm b/Examples/test-suite/guile/typedef_inherit_runme.scm index d75d421d5..443e75f1b 100644 --- a/Examples/test-suite/guile/typedef_inherit_runme.scm +++ b/Examples/test-suite/guile/typedef_inherit_runme.scm @@ -1,2 +1,2 @@ -(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit.so")) +(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit")) (load "../schemerunme/typedef_inherit.scm") diff --git a/Examples/test-suite/guile/typename_runme.scm b/Examples/test-suite/guile/typename_runme.scm index 4243f6974..057033521 100644 --- a/Examples/test-suite/guile/typename_runme.scm +++ b/Examples/test-suite/guile/typename_runme.scm @@ -1,3 +1,3 @@ -(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename.so")) -;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes.so")) +(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename")) +;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes")) (load "../schemerunme/typename.scm") diff --git a/Examples/test-suite/guile/unions_runme.scm b/Examples/test-suite/guile/unions_runme.scm index 867e8a3c3..510a19490 100644 --- a/Examples/test-suite/guile/unions_runme.scm +++ b/Examples/test-suite/guile/unions_runme.scm @@ -4,5 +4,5 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions.so")) +(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions")) (load "../schemerunme/unions.scm") diff --git a/Examples/test-suite/guilescm_ext_test.i b/Examples/test-suite/guile_ext_test.i similarity index 93% rename from Examples/test-suite/guilescm_ext_test.i rename to Examples/test-suite/guile_ext_test.i index fd5655d4f..170695f6c 100644 --- a/Examples/test-suite/guilescm_ext_test.i +++ b/Examples/test-suite/guile_ext_test.i @@ -1,4 +1,4 @@ -%module guilescm_ext_test +%module guile_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in deleted file mode 100644 index ba1cba440..000000000 --- a/Examples/test-suite/guilescm/Makefile.in +++ /dev/null @@ -1,49 +0,0 @@ -####################################################################### -# Makefile for guile test-suite (with SCM API) -####################################################################### - -EXTRA_TEST_CASES += guilescm_ext_test.externaltest - -include ../guile/Makefile - -# Overridden variables here -INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm -VARIANT = -# Refer to the guile directory for the run scripts -SCRIPTPREFIX = ../guile/ -GUILE_RUNTIME= - -# Custom tests - tests with additional commandline options -# none! - -# Runs the testcase. A testcase is only run if -# a file is found which has _runme.scm appended after the testcase name. -run_testcase = \ - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi - -setup = \ - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ - else \ - echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ - fi - -%.externaltest: - $(local_setup) - +$(swig_and_compile_external) - $(local_run_testcase) - -# Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory) -local_setup = \ - if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ - echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ - else \ - echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ - fi - -local_run_testcase = \ - if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \ - fi diff --git a/Examples/test-suite/implicittest.i b/Examples/test-suite/implicittest.i index e07adc5cc..171c6055c 100644 --- a/Examples/test-suite/implicittest.i +++ b/Examples/test-suite/implicittest.i @@ -46,7 +46,6 @@ Foo(double){ ii = 2;} explicit Foo(char *s){ii = 3;} Foo(const Foo& f){ ii = f.ii;} - }; struct Bar @@ -57,11 +56,61 @@ Bar(const Foo& ff){ ii = ff.ii;} }; - int get_b(const Bar&b) { return b.ii; } Foo foo; - } %template(A_int) A_T; + + +/****************** None handling *********************/ + +%inline +{ + struct BB {}; + struct AA + { + int ii; + AA(int i) { ii = 1; } + AA(double d) { ii = 2; } + AA(const B* b) { ii = 3; } + explicit AA(char *s) { ii = 4; } + AA(const BB& b) { ii = 5; } + + int get() const { return ii; } + }; + + int get_AA_val(AA a) { return a.ii; } + int get_AA_ref(const AA& a) { return a.ii; } +} + + +/****************** Overloading priority *********************/ + +%inline %{ +class BBB { + public: + BBB(const B &) {} +}; + +class CCC { + public: + CCC(const BBB &) : checkvalue(0) {} + int xx(int i) { return 11; } + int xx(const A& i) { return 22; } + int yy(int i, int j) { return 111; } + int yy(const A& i, const A& j) { return 222; } + int checkvalue; +}; +%} + +// CCC(const BBB &) was being called instead of this constructor (independent of being added via %extend) +%extend CCC { + CCC(const B& b) { + CCC* ccc = new CCC(b); + ccc->checkvalue = 10; + return ccc; + } +}; + diff --git a/Examples/test-suite/integers.i b/Examples/test-suite/integers.i index 7f78a2a18..6a9ede4bc 100644 --- a/Examples/test-suite/integers.i +++ b/Examples/test-suite/integers.i @@ -16,5 +16,16 @@ unsigned long unsigned_long_identity(unsigned long x) { return x; } signed long long signed_long_long_identity(signed long long x) { return x; } unsigned long long unsigned_long_long_identity(unsigned long long x) { return x; } + + size_t signed_char_size() { return sizeof (signed char); } + size_t unsigned_char_size() { return sizeof (unsigned char); } + size_t signed_short_size() { return sizeof (signed short); } + size_t unsigned_short_size() { return sizeof (unsigned short); } + size_t signed_int_size() { return sizeof (signed int); } + size_t unsigned_int_size() { return sizeof (unsigned int); } + size_t signed_long_size() { return sizeof (signed long); } + size_t unsigned_long_size() { return sizeof (unsigned long); } + size_t signed_long_long_size() { return sizeof (signed long long); } + size_t unsigned_long_long_size() { return sizeof (unsigned long long); } %} diff --git a/Examples/test-suite/java/enum_macro_runme.java b/Examples/test-suite/java/enum_macro_runme.java new file mode 100644 index 000000000..4ac7409ee --- /dev/null +++ b/Examples/test-suite/java/enum_macro_runme.java @@ -0,0 +1,93 @@ + +import enum_macro.*; + +public class enum_macro_runme { + + static { + try { + System.loadLibrary("enum_macro"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) + { + { + Greeks1 a = Greeks1.alpha1; + a = Greeks1.beta1; + a = Greeks1.theta1; + if (a.swigValue() != 3) + throw new RuntimeException("Greeks1"); + } + { + Greeks2 a = Greeks2.alpha2; + a = Greeks2.beta2; + a = Greeks2.theta2; + if (a.swigValue() != 4) + throw new RuntimeException("Greeks2"); + } + { + Greeks3 a = Greeks3.alpha3; + a = Greeks3.beta3; + a = Greeks3.theta3; + if (a.swigValue() != 2) + throw new RuntimeException("Greeks3"); + } + { + Greeks4 a = Greeks4.alpha4; + a = Greeks4.beta4; + a = Greeks4.theta4; + if (a.swigValue() != 6) + throw new RuntimeException("Greeks4"); + } + { + Greeks5 a = Greeks5.alpha5; + a = Greeks5.beta5; + if (a.swigValue() != 1) + throw new RuntimeException("Greeks5"); + } + { + Greeks6 a = Greeks6.alpha6; + a = Greeks6.beta6; + if (a.swigValue() != 1) + throw new RuntimeException("Greeks6"); + } + { + Greeks7 a = Greeks7.alpha7; + a = Greeks7.beta7; + if (a.swigValue() != 1) + throw new RuntimeException("Greeks7"); + } + { + Greeks8 a = Greeks8.theta8; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks8"); + } + { + Greeks9 a = Greeks9.theta9; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks9"); + } + { + Greeks10 a = Greeks10.theta10; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks10"); + } + { + Greeks11 a = Greeks11.theta11; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks11"); + } + { + Greeks12 a = Greeks12.theta12; + if (a.swigValue() != 0) + throw new RuntimeException("Greeks12"); + } + { + Greeks13 a = null; + } + } +} + diff --git a/Examples/test-suite/java/special_variable_macros_runme.java b/Examples/test-suite/java/special_variable_macros_runme.java index d7f8070b3..1cd50e96e 100644 --- a/Examples/test-suite/java/special_variable_macros_runme.java +++ b/Examples/test-suite/java/special_variable_macros_runme.java @@ -22,6 +22,8 @@ public class special_variable_macros_runme { throw new RuntimeException("test failed"); if (!special_variable_macros.testMary(name).equals("SWIGTYPE_p_NameWrap")) throw new RuntimeException("test failed"); + if (!special_variable_macros.testJames(name).equals("SWIGTYPE_Name")) + throw new RuntimeException("test failed"); if (!special_variable_macros.testJim(name).equals("multiname num")) throw new RuntimeException("test failed"); if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123) diff --git a/Examples/test-suite/java_director_assumeoverride.i b/Examples/test-suite/java_director_assumeoverride.i index 7364a3d58..cddebb4d7 100644 --- a/Examples/test-suite/java_director_assumeoverride.i +++ b/Examples/test-suite/java_director_assumeoverride.i @@ -1,5 +1,4 @@ %module(directors="1") java_director_assumeoverride -#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR %{ class OverrideMe { diff --git a/Examples/test-suite/li_attribute_template.i b/Examples/test-suite/li_attribute_template.i new file mode 100644 index 000000000..3d4c108ef --- /dev/null +++ b/Examples/test-suite/li_attribute_template.i @@ -0,0 +1,110 @@ +%module li_attribute_template + +%include + +//#define SWIG_ATTRIBUTE_TEMPLATE +%include +%include + +%inline +{ + class Foo { + public: + Foo( int _value ) { value = _value; } + int value; + }; + + template< class T1, class T2> + struct pair{ + pair( T1 t1, T2 t2 ): + first(t1), second(t2) {;} + + T1 first; + T2 second; + }; + + template< class T1, class T2> + struct C + { + C(int a, int b, int c) : + _a(a), _b(b), _c(c), _d(a), _e(b), + _f(a,b), _g(b,c) + { + +/* + _f.first = _a; + _f.second = _b; + + _g.first = _b; + _g.second = _c; +*/ + + } + + int get_value() const + { + return _a; + } + + void set_value(int aa) + { + _a = aa; + } + + /* only one ref method */ + int& get_ref() + { + return _b; + } + + Foo get_class_value() const { return _d; } + void set_class_value( Foo foo) { _d = foo; } + + const Foo& get_class_ref() const { return _e; } + void set_class_ref( const Foo& foo ) { _e = foo; } + + pair get_template_value() const { return _f; } + void set_template_value( const pair f ) { _f = f; } + + const pair& get_template_ref() const { return _g; } + void set_template_ref( const pair& g ) { _g = g; } + + std::string get_string() { return str; } + void set_string(std::string other) { str = other; } + + private: + int _a; + int _b; + int _c; + Foo _d; + Foo _e; + pair _f; + pair _g; + + std::string str; + }; + +} + +%define %instantiate_C( T1, T2 ) +%template (pair_ ## T1 ## T2 ) pair; +// Primitive types +%attribute( %arg(C), int, a, get_value, set_value ); +%attributeref( %arg(C), int, b, get_ref ); + +// Strings +%attributestring(%arg(C), std::string, str, get_string, set_string); + +// Class types +%attributeval( %arg(C), Foo, d, get_class_value, set_class_value ); +%attribute2( %arg(C), Foo, e, get_class_ref, set_class_ref ); + +// Moderately templated types +%attributeval( %arg(C), %arg(pair), f, get_template_value, set_template_value ); +%attribute2( %arg(C), %arg(pair), g, get_template_ref, set_template_ref ); + +%template (C ## T1 ## T2) C; +%enddef + + +%instantiate_C(int,int); diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i index 2efa998a9..4916d0285 100644 --- a/Examples/test-suite/li_boost_intrusive_ptr.i +++ b/Examples/test-suite/li_boost_intrusive_ptr.i @@ -13,9 +13,12 @@ %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived; %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived; -%inline %{ -#include "boost/shared_ptr.hpp" -#include "boost/intrusive_ptr.hpp" +%{ +template void intrusive_ptr_add_ref(const T* r) { r->addref(); } +template void intrusive_ptr_release(const T* r) { r->release(); } + +#include +#include #include // Uncomment macro below to turn on intrusive_ptr memory leak checking as described above @@ -102,8 +105,6 @@ %ignore IgnoredRefCountingBase; %ignore *::operator=; -%ignore intrusive_ptr_add_ref; -%ignore intrusive_ptr_release; %newobject pointerownertest(); %newobject smartpointerpointerownertest(); @@ -430,10 +431,6 @@ template struct Pair : Base { Pair pair_id2(Pair p) { return p; } SwigBoost::intrusive_ptr< Pair > pair_id1(SwigBoost::intrusive_ptr< Pair > p) { return p; } -template void intrusive_ptr_add_ref(const T* r) { r->addref(); } - -template void intrusive_ptr_release(const T* r) { r->release(); } - long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } diff --git a/Examples/test-suite/li_std_except_as_class.i b/Examples/test-suite/li_std_except_as_class.i index 00de76eac..0400c9a82 100644 --- a/Examples/test-suite/li_std_except_as_class.i +++ b/Examples/test-suite/li_std_except_as_class.i @@ -5,6 +5,12 @@ * if there were also functions throwing 'std::logic_error' and * 'std::exception' then the bug would not be fully replicated */ +%{ +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif +%} + %{ #include #include diff --git a/Examples/test-suite/li_std_multimap.i b/Examples/test-suite/li_std_multimap.i index a29417919..bd087d361 100644 --- a/Examples/test-suite/li_std_multimap.i +++ b/Examples/test-suite/li_std_multimap.i @@ -3,7 +3,6 @@ %feature("trackobjects"); %include std_pair.i -%include std_map.i %include std_multimap.i %inline %{ @@ -20,6 +19,5 @@ struct A{ namespace std { %template(pairA) pair; - %template(mapA) map; %template(multimapA) multimap; } diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index c809e11ec..e0ecde53b 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -38,6 +38,14 @@ wchar_t* test_cvalue(wchar_t* x) { } +wchar_t* test_wchar_overload() { + return 0; +} + +wchar_t* test_wchar_overload(wchar_t *x) { + return x; +} + std::wstring test_value(std::wstring x) { return x; } diff --git a/Examples/test-suite/li_windows.i b/Examples/test-suite/li_windows.i index 26f96cc3b..c99ffe4ca 100644 --- a/Examples/test-suite/li_windows.i +++ b/Examples/test-suite/li_windows.i @@ -4,6 +4,12 @@ %{ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) + // Fix Tcl.h and Windows.h cat and mouse over definition of VOID + #if defined(_TCL) && defined(__CYGWIN__) + #ifdef VOID + #undef VOID + #endif + #endif #include #else // Use equivalent types for non-windows systems diff --git a/Examples/test-suite/lua/cpp_basic_runme.lua b/Examples/test-suite/lua/cpp_basic_runme.lua index 02f88479b..3d5ccaadf 100644 --- a/Examples/test-suite/lua/cpp_basic_runme.lua +++ b/Examples/test-suite/lua/cpp_basic_runme.lua @@ -42,16 +42,22 @@ assert(f3.num==32) f4=cb.Foo(6) cb.Bar_global_fptr=f4 assert(cb.Bar_global_fptr.num==6) +assert(cb.Bar.global_fptr.num==6) f4.num=8 assert(cb.Bar_global_fptr.num==8) +assert(cb.Bar.global_fptr.num==8) assert(cb.Bar_global_fref.num==23) +assert(cb.Bar.global_fref.num==23) cb.Bar_global_fref=cb.Foo(-7) -- this will set the value assert(cb.Bar_global_fref.num==-7) +assert(cb.Bar.global_fref.num==-7) assert(cb.Bar_global_fval.num==3) +assert(cb.Bar.global_fval.num==3) cb.Bar_global_fval=cb.Foo(-34) assert(cb.Bar_global_fval.num==-34) +assert(cb.Bar.global_fval.num==-34) -- Now test member function pointers func1_ptr=cb.get_func1_ptr() diff --git a/Examples/test-suite/naturalvar_more.i b/Examples/test-suite/naturalvar_more.i new file mode 100644 index 000000000..aebb6b23e --- /dev/null +++ b/Examples/test-suite/naturalvar_more.i @@ -0,0 +1,53 @@ +%module naturalvar_more + +// The instantiation of a template using an enum in the template parameter was not picking up %naturalvar. + +// These typemaps will be used if %naturalvar is not working +%typemap(out) T *te, T *const_te "_should_not_use_this_out_typemap_" +%typemap(varout) T *te, T *const_te "_should_not_use_this_varout_typemap_" +%typemap(out) Hidden *hidden "_should_not_use_this_out_typemap_" +%typemap(varout) Hidden *hidden "_should_not_use_this_varout_typemap_" + +%naturalvar T; +%naturalvar Hidden; + +%inline %{ +template struct T {}; +struct K {}; +struct Hidden; +namespace Ace { + int glob; +} +%} +%{ +struct Hidden {}; +namespace Ace { + template struct NoIdea {}; +} +%} + +%inline %{ +namespace Space { + enum E { E1, E2, E3 }; +} +%} + +%template(TE) T; + +%include +%include +%template(VectorString) std::vector; + +%inline { +using namespace Space; +struct S { + T te; + const T const_te; + const std::vector::value_type const_string_member; // check this resolves to std::string which has a naturalvar + std::vector::value_type string_member; // check this resolves to std::string which has a naturalvar + Hidden hidden; + Ace::NoIdea noidea; + S() : const_te(), const_string_member("initial string value") {} +}; +} + diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 88f533fd1..fe957eeb0 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -3,7 +3,7 @@ ####################################################################### LANGUAGE = octave -OCTAVE = @OCTAVE@ -qf +OCTAVE = @OCTAVE@ SCRIPTSUFFIX = _runme.m srcdir = @srcdir@ top_srcdir = @top_srcdir@ diff --git a/Examples/test-suite/octave/imports_runme.m b/Examples/test-suite/octave/imports_runme.m index be9db5919..a9c8bffb8 100644 --- a/Examples/test-suite/octave/imports_runme.m +++ b/Examples/test-suite/octave/imports_runme.m @@ -1,19 +1,22 @@ # This is the import runtime testcase. -imports_b; -imports_a; +# Workaround seg fault occurring during interpreter cleanup/exit in version 3.1 and 3.2, seems okay in 3.6 +if (compare_versions(version(), "3.3", ">=")) + imports_b; + imports_a; -x = imports_b.B(); -x.hello(); + x = imports_b.B(); + x.hello(); -a = imports_a.A(); + a = imports_a.A(); -c = imports_b.C(); -a1 = c.get_a(c); -a2 = c.get_a_type(c); + c = imports_b.C(); + a1 = c.get_a(c); + a2 = c.get_a_type(c); -a1.hello(); -a2.hello(); -assert(swig_this(a1)==swig_this(a2)); -assert(strcmp(swig_type(a1),swig_type(a2))); + a1.hello(); + a2.hello(); + assert(swig_this(a1)==swig_this(a2)); + assert(strcmp(swig_type(a1),swig_type(a2))); +endif diff --git a/Examples/test-suite/overload_numeric.i b/Examples/test-suite/overload_numeric.i new file mode 100644 index 000000000..44c3b811c --- /dev/null +++ b/Examples/test-suite/overload_numeric.i @@ -0,0 +1,51 @@ +%module overload_numeric + +// Tests overloading of integral and floating point types to verify the range checking required +// for dispatch to the correct overloaded method + +#ifdef SWIGLUA +// lua only has one numeric type, so most of the overloads shadow each other creating warnings +%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Nums::over; +#endif + +%{ +#include +%} + +%inline %{ +#include +#include +struct Limits { + signed char schar_min() { return SCHAR_MIN; } + signed char schar_max() { return SCHAR_MAX; } + short shrt_min() { return SHRT_MIN; } + short shrt_max() { return SHRT_MAX; } + int int_min() { return INT_MIN; } + int int_max() { return INT_MAX; } + float flt_min() { return FLT_MIN; } + float flt_max() { return FLT_MAX; } + double dbl_max() { return DBL_MAX; } +}; + +struct Nums { + const char * over(signed char v) { + return "signed char"; + } + const char * over(short v) { + return "short"; + } + const char * over(int v) { + return "int"; + } + const char * over(float v) { + return "float"; + } + const char * over(double v) { + return "double"; + } + double doublebounce(double v) { + return v; + } +}; +%} + diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index d4f9ac9b5..fcdcac2b9 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -57,9 +57,9 @@ missingtests: missingcpptests missingctests # found, runs testcase.php, except for multicpptests. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \ elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \ fi # Clean: remove the generated .php file diff --git a/Examples/test-suite/pointer_reference.i b/Examples/test-suite/pointer_reference.i index b9e126fd4..7a6a09d48 100644 --- a/Examples/test-suite/pointer_reference.i +++ b/Examples/test-suite/pointer_reference.i @@ -11,7 +11,7 @@ #ifdef SWIGGUILE /* A silly testing typemap for feeding a doubly indirect integer */ %typemap(in) int *&XYZZY (int temp1, int *temp2) { - temp1 = gh_scm2int($input); temp2 = &temp1; $1 = &temp2; + temp1 = scm_to_int($input); temp2 = &temp1; $1 = &temp2; }; #endif diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i index f912bd77c..9425cc1a0 100644 --- a/Examples/test-suite/primitive_types.i +++ b/Examples/test-suite/primitive_types.i @@ -48,7 +48,7 @@ const double & ($basetype temp) %{ temp = ($basetype)$input; $1 = &temp; %} - the other tipical change is to add the enum SWIGTYPE to the + the other typical change is to add the enum SWIGTYPE to the integer throws typemaps: %typemap(throws) int, diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 43ba2717e..e7db32fb7 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -58,7 +58,7 @@ CPP_TEST_CASES += \ li_std_wstream \ li_std_wstring \ primitive_types \ - python_abstractbase \ + python_abstractbase \ python_append \ python_director \ python_nondynamic \ @@ -110,16 +110,19 @@ VALGRIND_OPT += --suppressions=pythonswig.supp # Rules for the different types of tests %.cpptest: + +$(convert_testcase) $(setup) +$(swig_and_compile_cpp) $(run_testcase) %.ctest: + +$(convert_testcase) $(setup) +$(swig_and_compile_c) $(run_testcase) %.multicpptest: + +$(convert_testcase) $(setup) +$(swig_and_compile_multi_cpp) $(run_testcase) @@ -139,17 +142,17 @@ run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PY py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) -ifeq (,$(PY3)) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(run_python);\ fi + +ifeq (,$(PY3)) +convert_testcase = else -run_testcase = \ +convert_testcase = \ if [ -f $(py2_runme) ]; then \ - $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \ - elif [ -f $(py3_runme) ]; then \ - $(run_python); \ + $(MAKE) -f $(srcdir)/Makefile $(py3_runme); \ fi endif @@ -162,6 +165,9 @@ endif clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py + rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py + rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py + rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py cvsignore: @echo '*wrap* *.pyc *.so *.dll *.exp *.lib' diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index dc843ae96..5776ad3ef 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -1,4 +1,5 @@ from autodoc import * +import sys def check(got, expected): if expected != got: @@ -121,22 +122,24 @@ check(A.func3static.__doc__, "\n" " " ) -check(A.variable_a.__doc__, "A_variable_a_get(self) -> int") -check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int") -check(A.variable_c.__doc__, "\n" -"A_variable_c_get(self) -> int\n" -"\n" -"Parameters:\n" -" self: A *\n" -"\n" -) -check(A.variable_d.__doc__, "\n" -"A_variable_d_get(A self) -> int\n" -"\n" -"Parameters:\n" -" self: A *\n" -"\n" -) +if sys.version_info[0:2] > (2, 4): + # Python 2.4 does not seem to work + check(A.variable_a.__doc__, "A_variable_a_get(self) -> int") + check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int") + check(A.variable_c.__doc__, "\n" + "A_variable_c_get(self) -> int\n" + "\n" + "Parameters:\n" + " self: A *\n" + "\n" + ) + check(A.variable_d.__doc__, "\n" + "A_variable_d_get(A self) -> int\n" + "\n" + "Parameters:\n" + " self: A *\n" + "\n" + ) check(B.__doc__, "Proxy of C++ B class") check(C.__init__.__doc__, "__init__(self, a, b, h) -> C") diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index de4e2669e..9b94fa3b3 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -1,7 +1,7 @@ import sys import file_test -if sys.version_info < (3,0): +if sys.version_info[0:2] < (3, 0): file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py index 4200543c4..a9957bc7e 100644 --- a/Examples/test-suite/python/implicittest_runme.py +++ b/Examples/test-suite/python/implicittest_runme.py @@ -11,6 +11,14 @@ check(1, A(1).get()) check(2, A(1.0).get()) check(3, A(B()).get()) check(4, A("hello").get()) +try: + check(3, A(None).get()) + raise RuntimeError +except ValueError: + # ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &' + # Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value, + # references and pointers to different types, where pointers ought to be given a slightly higher precedence. + pass check(1, get(1)) check(2, get(1.0)) @@ -71,3 +79,47 @@ try: except TypeError: pass +#### Class testing None #### + +# No implicit conversion +check(1, AA(1).get()) +check(2, AA(1.0).get()) +check(3, AA(B()).get()) +check(3, AA(None).get()) +check(4, AA("hello").get()) +check(5, AA(BB()).get()) + +check(1, get_AA_val(1)) +check(2, get_AA_val(1.0)) +check(3, get_AA_val(B())) +check(3, get_AA_val(None)) +check(5, get_AA_val(BB())) + +# Explicit constructor: +try: + check(4, get_AA_val("hello")) + raise RuntimeError +except TypeError: + pass + +check(1, get_AA_ref(1)) +check(2, get_AA_ref(1.0)) +check(3, get_AA_ref(B())) +check(3, get_AA_ref(None)) +check(5, get_AA_ref(BB())) + +# Explicit constructor: +try: + check(4, get_AA_ref("hello")) + raise RuntimeError +except TypeError: + pass + + +### overloading priority test ### + +ccc = CCC(B()) +check(ccc.checkvalue, 10) +check(ccc.xx(123), 11) +check(ccc.yy(123, 123), 111) + diff --git a/Examples/test-suite/python/li_attribute_template_runme.py b/Examples/test-suite/python/li_attribute_template_runme.py new file mode 100644 index 000000000..7423053f9 --- /dev/null +++ b/Examples/test-suite/python/li_attribute_template_runme.py @@ -0,0 +1,67 @@ +# Check usage of template attributes + +import li_attribute_template + +chell = li_attribute_template.Cintint(1,2,3) + +def rassert( what, master ): + if what != master: + print what + raise RuntimeError + +## Testing primitive by value attribute +rassert( chell.a, 1 ) + +chell.a = 3 +rassert( chell.a, 3 ) + +## Testing primitive by ref attribute + +rassert( chell.b, 2 ) + +chell.b = 5 +rassert( chell.b,5 ) + +## Testing string +chell.str = "abc" +rassert( chell.str, "abc" ) + +# Testing class by value + +rassert( chell.d.value, 1 ) + +chell.d = li_attribute_template.Foo(2) +rassert( chell.d.value, 2 ) + +# Testing class by reference + +rassert( chell.e.value, 2 ) + +chell.e= li_attribute_template.Foo(3) +rassert( chell.e.value, 3 ) + +chell.e.value = 4 +rassert( chell.e.value, 4 ) + +# Testing moderately complex template by value +rassert( chell.f.first, 1 ) +rassert( chell.f.second, 2 ) + +pair = li_attribute_template.pair_intint(3,4) +chell.f = pair +rassert( chell.f.first, 3 ) +rassert( chell.f.second, 4 ) + +# Testing moderately complex template by ref +rassert( chell.g.first, 2 ) +rassert( chell.g.second, 3 ) + +pair = li_attribute_template.pair_intint(4,5) +chell.g = pair +rassert( chell.g.first, 4 ) +rassert( chell.g.second, 5 ) + +chell.g.first = 6 +chell.g.second = 7 +rassert( chell.g.first, 6 ) +rassert( chell.g.second, 7 ) diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py index 7611ee63e..3cbbb2862 100644 --- a/Examples/test-suite/python/li_std_containers_int_runme.py +++ b/Examples/test-suite/python/li_std_containers_int_runme.py @@ -1,6 +1,7 @@ # Check std::vector and std::list behaves the same as Python iterable types (list) from li_std_containers_int import * +import sys def failed(a, b, msg): raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b)) @@ -76,10 +77,13 @@ def container_insert_step(i, j, step, newval): except IndexError, e: il_error = e - if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): - raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error) + # Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html + skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6)) + if not(skip_check): + if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): + raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error) - compare_containers(ps, iv, il) + compare_containers(ps, iv, il) # Check std::vector and std::list delete behaves same as Python list delete including exceptions diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py index a2d419a0a..fecc527e0 100644 --- a/Examples/test-suite/python/li_std_wstring_runme.py +++ b/Examples/test-suite/python/li_std_wstring_runme.py @@ -13,6 +13,12 @@ if li_std_wstring.test_ccvalue(x) != x: if li_std_wstring.test_cvalue(x) != x: raise RuntimeError("bad string mapping") +if li_std_wstring.test_wchar_overload(x) != x: + raise RuntimeError("bad string mapping") + +if li_std_wstring.test_wchar_overload("not unicode") != "not unicode": + raise RuntimeError("bad string mapping") + if li_std_wstring.test_value(x) != x: print x, li_std_wstring.test_value(x) raise RuntimeError("bad string mapping") diff --git a/Examples/test-suite/python/overload_numeric_runme.py b/Examples/test-suite/python/overload_numeric_runme.py new file mode 100644 index 000000000..639fb5e5d --- /dev/null +++ b/Examples/test-suite/python/overload_numeric_runme.py @@ -0,0 +1,43 @@ + +from overload_numeric import * +import math + +nums = Nums() +limits = Limits() + +def check(got, expected): + if got != expected: + raise RuntimeError("got: " + got + " expected: " + expected) + +check(nums.over(0), "signed char") +check(nums.over(0.0), "float") + +check(nums.over(limits.schar_min()), "signed char") +check(nums.over(limits.schar_max()), "signed char") + +check(nums.over(limits.schar_min()-1), "short") +check(nums.over(limits.schar_max()+1), "short") +check(nums.over(limits.shrt_min()), "short") +check(nums.over(limits.shrt_max()), "short") + +check(nums.over(limits.shrt_min()-1), "int") +check(nums.over(limits.shrt_max()+1), "int") +check(nums.over(limits.int_min()), "int") +check(nums.over(limits.int_max()), "int") + +check(nums.over(limits.flt_min()), "float") +check(nums.over(limits.flt_max()), "float") + +check(nums.over(limits.flt_max()*10), "double") +check(nums.over(-limits.flt_max()*10), "double") +check(nums.over(limits.dbl_max()), "double") +check(nums.over(-limits.dbl_max()), "double") + +check(nums.over(float("inf")), "float") +check(nums.over(float("-inf")), "float") +check(nums.over(float("nan")), "float") + +# Just check if the following are accepted without exceptions being thrown +nums.doublebounce(float("inf")) +nums.doublebounce(float("-inf")) +nums.doublebounce(float("nan")) diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index 2495cd60d..be8d38bad 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -275,10 +275,22 @@ try: except TypeError: if a != t.var_char: error = 1 - pass + pass if error: raise RuntimeError, "bad char typemap" +try: + error = 0 + a = t.var_ushort + t.var_ushort = -1 + error = 1 +except OverflowError: + if a != t.var_ushort: + error = 1 + pass +if error: + raise RuntimeError, "bad ushort typemap" + try: error = 0 a = t.var_uint @@ -287,10 +299,34 @@ try: except OverflowError: if a != t.var_uint: error = 1 - pass + pass if error: raise RuntimeError, "bad uint typemap" +try: + error = 0 + a = t.var_sizet + t.var_sizet = -1 + error = 1 +except OverflowError: + if a != t.var_sizet: + error = 1 + pass +if error: + raise RuntimeError, "bad sizet typemap" + +try: + error = 0 + a = t.var_ulong + t.var_ulong = -1 + error = 1 +except OverflowError: + if a != t.var_ulong: + error = 1 + pass +if error: + raise RuntimeError, "bad ulong typemap" + # # try: @@ -301,7 +337,7 @@ try: except TypeError: if a != t.var_namet: error = 1 - pass + pass if error: raise RuntimeError, "bad namet typemap" diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py index c8e6b2640..41cebad58 100644 --- a/Examples/test-suite/python/python_append_runme.py +++ b/Examples/test-suite/python/python_append_runme.py @@ -2,3 +2,10 @@ from python_append import * t=Test() t.func() t.static_func() + +if grabpath() != os.path.dirname(mypath): + raise RuntimeError + +if grabstaticpath() != os.path.basename(mypath): + raise RuntimeError + diff --git a/Examples/test-suite/python/python_varargs_typemap_runme.py b/Examples/test-suite/python/python_varargs_typemap_runme.py index 3c3f042eb..65be757c8 100644 --- a/Examples/test-suite/python/python_varargs_typemap_runme.py +++ b/Examples/test-suite/python/python_varargs_typemap_runme.py @@ -2,3 +2,6 @@ import python_varargs_typemap if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") : raise RuntimeError("testfunc failed!") + +if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") : + raise RuntimeError("testfunc failed! {}") diff --git a/Examples/test-suite/python/special_variable_macros_runme.py b/Examples/test-suite/python/special_variable_macros_runme.py index 07e60dfa2..eaf9c1858 100644 --- a/Examples/test-suite/python/special_variable_macros_runme.py +++ b/Examples/test-suite/python/special_variable_macros_runme.py @@ -9,6 +9,8 @@ if special_variable_macros.testJill(name) != "jilly": raise "test failed" if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap": raise "test failed" +if special_variable_macros.testJames(name) != "SWIGTYPE_Name": + raise "test failed" if special_variable_macros.testJim(name) != "multiname num": raise "test failed" if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123: diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py index 12202e3d3..d4b8855fc 100644 --- a/Examples/test-suite/python/threads_exception_runme.py +++ b/Examples/test-suite/python/threads_exception_runme.py @@ -23,10 +23,12 @@ except RuntimeError,e: try: t.hosed() except threads_exception.Exc,e: - if e.code != 42: - raise RuntimeError - if e.msg != "Hosed": - raise RuntimeError, "bad... msg: %s" % e.msg + code = e.code + if code != 42: + raise RuntimeError, "bad... code: %d" % code + msg = e.msg + if msg != "Hosed": + raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg)) for i in range(1,4): try: diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i index 2dc9cb970..e263c392b 100644 --- a/Examples/test-suite/python_append.i +++ b/Examples/test-suite/python_append.i @@ -1,25 +1,43 @@ /* -Testcase to test %pythonprepend and %pythonappend +Testcase to test %pythonprepend and %pythonappend %pythoncode %pythonbegin */ %module python_append +%pythoncode %{ + mypath = os.path.dirname("/a/b/c/d.txt") + funcpath = None + staticfuncpath = None + def grabpath(): + return funcpath + def grabstaticpath(): + return staticfuncpath +%} + %pythonappend Test::func %{ - pass + funcpath = os.path.dirname(funcpath) %} %pythonprepend Test::func %{ - pass + global funcpath + funcpath = mypath %} %pythonappend Test::static_func %{ +staticfuncpath = os.path.basename(staticfuncpath) pass %} %pythonprepend Test::static_func { + global staticfuncpath + staticfuncpath = mypath pass } +%pythonbegin %{ +import os.path +%} + %inline %{ class Test { diff --git a/Examples/test-suite/python_varargs_typemap.i b/Examples/test-suite/python_varargs_typemap.i index 4bc6f3fbd..09deea3b7 100644 --- a/Examples/test-suite/python_varargs_typemap.i +++ b/Examples/test-suite/python_varargs_typemap.i @@ -4,13 +4,10 @@ * chapter of the SWIG manual. */ -%{ -%} - -%typemap(in) (...)(char *args[10]) { +%typemap(in) (...)(char *vargs[10]) { int i; int argc; - for (i = 0; i < 10; i++) args[i] = 0; + for (i = 0; i < 10; i++) vargs[i] = 0; argc = PyTuple_Size(varargs); if (argc > 10) { PyErr_SetString(PyExc_ValueError, "Too many arguments"); @@ -26,7 +23,7 @@ return NULL; } pystr = PyUnicode_AsUTF8String(pyobj); - str = PyBytes_AsString(pystr); + str = strdup(PyBytes_AsString(pystr)); Py_XDECREF(pystr); %#else if (!PyString_Check(pyobj)) { @@ -35,15 +32,24 @@ } str = PyString_AsString(pyobj); %#endif - args[i] = str; + vargs[i] = str; } - $1 = (void *) args; + $1 = (void *)vargs; } %feature("action") testfunc { - char **args = (char **) arg3; - result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4], - args[5],args[6],args[7],args[8],args[9], NULL); + char **vargs = (char **) arg3; + result = testfunc(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4], + vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL); +} + +%typemap(freearg) (...) { +%#if PY_VERSION_HEX>=0x03000000 + int i; + for (i = 0; i < 10; i++) { + free(vargs$argnum[i]); + } +%#endif } %inline { @@ -51,10 +57,14 @@ char* testfunc (int arg1, double arg2, ...) { va_list ap; char *c; + static char buffer[1024]; + buffer[0] = 0; va_start(ap, arg2); - c = va_arg(ap, char*); + while ((c = va_arg(ap, char *))) { + strcat(buffer, c); + } va_end(ap); - return c; + return buffer; } } diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index bece71c2f..18e2d4b25 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -16,7 +16,8 @@ C_TEST_CASES += \ CPP_TEST_CASES += \ r_double_delete \ - r_overload_array + r_overload_array \ + r_sexp include $(srcdir)/../common.mk diff --git a/Examples/test-suite/r/r_sexp_runme.R b/Examples/test-suite/r/r_sexp_runme.R new file mode 100644 index 000000000..96b36e8af --- /dev/null +++ b/Examples/test-suite/r/r_sexp_runme.R @@ -0,0 +1,7 @@ +source("unittest.R") +dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep="")) +source("r_sexp.R") +cacheMetaData(1) + +obj <- return_sexp(1); +unittest(obj, 1) diff --git a/Examples/test-suite/r_sexp.i b/Examples/test-suite/r_sexp.i new file mode 100644 index 000000000..9f786f428 --- /dev/null +++ b/Examples/test-suite/r_sexp.i @@ -0,0 +1,10 @@ +%module r_sexp + +extern "C" SEXP return_sexp(SEXP x); + +%inline %{ +SEXP return_sexp(SEXP x) { + return x; //Rcpp NumericVector is automatically casted to SEXP +} +%} + diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 3354acfd8..ab366ccd4 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -61,7 +61,7 @@ ruby_naming.cpptest: SWIGOPT += -autorename # a file is found which has _runme.rb appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I. $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I$(srcdir):. $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean diff --git a/Examples/test-suite/ruby/li_std_functors_runme.rb b/Examples/test-suite/ruby/li_std_functors_runme.rb index d31735c45..5623d49f0 100755 --- a/Examples/test-suite/ruby/li_std_functors_runme.rb +++ b/Examples/test-suite/ruby/li_std_functors_runme.rb @@ -34,6 +34,12 @@ def _set(container) EOF end +def b_lessthan_a(b, a) + res = b < a +# print b, "<", a, "=", res + return res +end + def _map(container) swig_assert_each_line(< b.hash} +#s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash} +# Test above is flawed as LanguageSet sorts by each element's hash, so the order will change from one invocation to the next. Sort a conversion to array instead. +sa = s.to_a.sort { |x, y| x.to_s <=> y.to_s } +sa == [1,[1,2],'hello'] EOF +iv = Set_int.new([0,1,2,3,4,5,6]) +iv.delete_if { |x| x == 0 || x == 3 || x == 6 } +swig_assert_equal(iv.to_s, '1245', binding) + diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index 8bcad2d19..fe3d9e0ce 100755 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -64,6 +64,11 @@ y = average([1, 2, 3, 4]) half([10, 10.5, 11, 11.5]) EOF +iv = IntVector.new([0,1,2,3,4,5,6]) +iv.delete_if { |x| x == 0 || x == 3 || x == 6 } +swig_assert_equal(iv.to_s, '1245', binding) + + dv = DoubleVector.new(10) swig_assert( "dv.respond_to? :each_with_index", binding ) diff --git a/Examples/test-suite/schemerunme/integers.scm b/Examples/test-suite/schemerunme/integers.scm index 0bbf36ea8..903e6a9f1 100644 --- a/Examples/test-suite/schemerunme/integers.scm +++ b/Examples/test-suite/schemerunme/integers.scm @@ -12,17 +12,32 @@ (check-equality (throws-exception? (,function (- ,from 1))) #t) (check-equality (throws-exception? (,function (+ ,to 1))) #t))) -;;; signed char, unsigned char typemaps deal with characters, not integers. -;; (check-range signed-char-identity (- (expt 2 7)) (- (expt 2 7) 1)) -;; (check-range unsigned-char-identity 0 (- (expt 2 8) 1)) -(check-range signed-short-identity (- (expt 2 15)) (- (expt 2 15) 1)) -(check-range unsigned-short-identity 0 (- (expt 2 16) 1)) -(check-range signed-int-identity (- (expt 2 31)) (- (expt 2 31) 1)) -(check-range unsigned-int-identity 0 (- (expt 2 32) 1)) -(check-range signed-long-identity (- (expt 2 31)) (- (expt 2 31) 1)) -(check-range unsigned-long-identity 0 (- (expt 2 32) 1)) -;;; long long not implemented in Guile and MzScheme. -;; (check-range signed-long-long-identity (- (expt 2 63)) (- (expt 2 63) 1)) -;; (check-range unsigned-long-long-identity 0 (- (expt 2 64) 1)) +(let ((signed-short-min (- (expt 2 (- (* (signed-short-size) 8) 1)))) + (signed-short-max (- (expt 2 (- (* (signed-short-size) 8) 1)) 1)) + (unsigned-short-max (- (expt 2 (* (unsigned-short-size) 8)) 1)) + (signed-int-min (- (expt 2 (- (* (signed-int-size) 8) 1)))) + (signed-int-max (- (expt 2 (- (* (signed-int-size) 8) 1)) 1)) + (unsigned-int-max (- (expt 2 (* (unsigned-int-size) 8)) 1)) + (signed-long-min (- (expt 2 (- (* (signed-long-size) 8) 1)))) + (signed-long-max (- (expt 2 (- (* (signed-long-size) 8) 1)) 1)) + (unsigned-long-max (- (expt 2 (* (unsigned-long-size) 8)) 1)) + (signed-long-long-min (- (expt 2 (- (* (signed-long-long-size) 8) 1)))) + (signed-long-long-max (- (expt 2 (- (* (signed-long-long-size) 8) 1)) 1)) + (unsigned-long-long-max (- (expt 2 (* (unsigned-long-long-size) 8)) 1)) + ) + + ;;; signed char, unsigned char typemaps deal with characters, not integers. + ;; (check-range signed-char-identity (- (expt 2 7)) (- (expt 2 7) 1)) + ;; (check-range unsigned-char-identity 0 (- (expt 2 8) 1)) + (check-range signed-short-identity signed-short-min signed-short-max) + (check-range unsigned-short-identity 0 unsigned-short-max) + (check-range signed-int-identity signed-int-min signed-int-max) + (check-range unsigned-int-identity 0 unsigned-int-max) + (check-range signed-long-identity signed-long-min signed-long-max) + (check-range unsigned-long-identity 0 unsigned-long-max) + ;;; long long not implemented in Guile and MzScheme. + (check-range signed-long-long-identity signed-long-long-min signed-long-long-max) + (check-range unsigned-long-long-identity 0 unsigned-long-long-max) +) (exit 0) diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index 65f5496eb..ddd068cc0 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -62,6 +62,14 @@ private: /*%typemap(in) NameWrap *NAMEWRAP end */ %} +// check $descriptor gets expanded properly when used in a fragment +%fragment("nameDescriptor", "header") +%{ +/*%fragment("getNameDescriptor", "header") start */ +static const char *nameDescriptor = "$descriptor(Name)"; +/*%fragment("getNameDescriptor", "header") end */ +%} + ////////////////////////////////////////////////////////////////////////////////////// @@ -86,6 +94,14 @@ $typemap(in, NameWrap *NAMEWRAP) // %typemap(in) Name *mary end } +%typemap(in, fragment="nameDescriptor") Name *james (Name temp) { + // %typemap(in) Name *james start + temp = Name(nameDescriptor); + (void)$input; + $1 = &temp; + // %typemap(in) Name *james end +} + %inline %{ const char * testFred(Name *fred) { return fred->getName(); @@ -99,6 +115,9 @@ const char * testJill(Name *jill) { const char * testMary(Name *mary) { return mary->getName(); } +const char * testJames(Name *james) { + return james->getName(); +} %} ////////////////////////////////////////////////////////////////////////////////////// diff --git a/Examples/test-suite/swig_examples_lock.h b/Examples/test-suite/swig_examples_lock.h index feef26d0f..49d1bf285 100644 --- a/Examples/test-suite/swig_examples_lock.h +++ b/Examples/test-suite/swig_examples_lock.h @@ -43,6 +43,7 @@ class CriticalSection { public: CriticalSection() { pthread_mutexattr_t mutexattr; + pthread_mutexattr_init(&mutexattr); pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP); pthread_mutex_init(&mutex_, &mutexattr); pthread_mutexattr_destroy(&mutexattr); diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i index 9f275bd6a..b374f0ce6 100644 --- a/Examples/test-suite/threads_exception.i +++ b/Examples/test-suite/threads_exception.i @@ -20,6 +20,7 @@ public: Exc(int c, const char *m) { code = c; strncpy(msg,m,255); + msg[255] = 0; } int code; char msg[256]; diff --git a/Examples/test-suite/typemap_array_qualifiers.i b/Examples/test-suite/typemap_array_qualifiers.i new file mode 100644 index 000000000..14df649d3 --- /dev/null +++ b/Examples/test-suite/typemap_array_qualifiers.i @@ -0,0 +1,85 @@ +%module typemap_array_qualifiers + +%define CLEAR_SWIGTYPE_TYPEMAPS +%typemap(in) + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE *const, + SWIGTYPE *const&, + const SWIGTYPE *, + const SWIGTYPE *const, + const SWIGTYPE *const&, + const volatile SWIGTYPE *, + const volatile SWIGTYPE *const, + const volatile SWIGTYPE *const&, + SWIGTYPE [], + SWIGTYPE [ANY], + const SWIGTYPE [], + const SWIGTYPE [ANY], + const volatile SWIGTYPE [], + const volatile SWIGTYPE [ANY], + SWIGTYPE &, + const SWIGTYPE &, + const volatile SWIGTYPE & +{ +%#error Incorrect typemap for $symname: $type +} +%enddef + +%inline %{ + typedef struct { + int a; + } SomeType; + typedef SomeType myarray[3]; + typedef const SomeType myconstarray[4]; + typedef volatile SomeType ** mycrazyarray[5]; + typedef volatile SomeType (mycrazyfunc)(SomeType); + typedef volatile SomeType (*mycrazyfuncptr)(SomeType); +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) SWIGTYPE [ANY] { +$1 = 0; +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func1a(myarray x) {}; + void func1b(volatile myarray x) {}; +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) const SWIGTYPE [ANY] { +$1 = 0; +/* Correct typemap for $symname: $type */ +} +%typemap(in) const volatile SWIGTYPE [ANY] { +$1 = 0; +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func2a(const myarray x) {}; + void func2b(const myconstarray x) {}; + void func2c(const volatile myconstarray x) {}; +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) volatile SWIGTYPE **const [ANY] { +$1 = 0; +/* Correct typemap for $symname: $type */ +} +%typemap(in) volatile SWIGTYPE **const [ANY][ANY] { +$1 = 0; +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func3a(const mycrazyarray x, const mycrazyarray y[7]) {}; +%} + +CLEAR_SWIGTYPE_TYPEMAPS; +%typemap(in) SWIGTYPE (*const) (ANY) { +$1 = 0; +/* Correct typemap for $symname: $type */ +} +%inline %{ + void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {}; +%} diff --git a/Examples/test-suite/typemap_qualifier_strip.i b/Examples/test-suite/typemap_qualifier_strip.i index d91a7b109..9b9f24cd8 100644 --- a/Examples/test-suite/typemap_qualifier_strip.i +++ b/Examples/test-suite/typemap_qualifier_strip.i @@ -1,5 +1,9 @@ %module typemap_qualifier_strip +%typemap(freearg) int *ptr "" +%typemap(freearg) int *const ptrConst "" +%typemap(freearg) int const* constPtr "" + %typemap(in) int *ptr { int temp = 1234; $1 = &temp; diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in index d6b948b5d..8ad153961 100644 --- a/Examples/test-suite/uffi/Makefile.in +++ b/Examples/test-suite/uffi/Makefile.in @@ -39,7 +39,7 @@ CPP_TEST_CASES = # a file is found which has _runme.lisp appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: (does nothing, we dont generate extra uffi code) diff --git a/Examples/xml/Makefile.in b/Examples/xml/Makefile.in index dfda4a646..27c86e3e9 100644 --- a/Examples/xml/Makefile.in +++ b/Examples/xml/Makefile.in @@ -19,8 +19,6 @@ all-dot-i-files = \ example_xml.i \ gnarly.i -all: check - chk-swiglib = $(top_srcdir)/Lib check: diff --git a/Lib/attribute.i b/Lib/attribute.i index 0cc3ff1a3..d580dbfe9 100644 --- a/Lib/attribute.i +++ b/Lib/attribute.i @@ -11,7 +11,7 @@ #define %attribute_exception(code,msg) printf("%s\n",msg) #ifndef %arg -#define %arg(x) x +#define %arg(x...) x #endif #ifndef %mangle diff --git a/Lib/cdata.i b/Lib/cdata.i index 1abaf357b..22a6d9de8 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -17,7 +17,7 @@ typedef struct SWIGCDATA { #if SWIGGUILE %typemap(out) SWIGCDATA { - $result = gh_str2scm($1.data,$1.len); + $result = scm_from_locale_stringn($1.data,$1.len); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #elif SWIGCHICKEN diff --git a/Lib/cffi/cffi.swg b/Lib/cffi/cffi.swg index e6a74b835..3ad767ef8 100644 --- a/Lib/cffi/cffi.swg +++ b/Lib/cffi/cffi.swg @@ -153,7 +153,7 @@ %insert("swiglisp") %{ ;;;SWIG wrapper code starts here -(cl:defmacro defanonenum (&body enums) +(cl:defmacro defanonenum (cl:&body enums) "Converts anonymous enums to defconstants." `(cl:progn ,@(cl:loop for value in enums for index = 0 then (cl:1+ index) diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 6a7da16b6..acd190689 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- * std_map.i * - * SWIG typemaps for std::map< K, T > + * SWIG typemaps for std::map< K, T, C > * * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>. * @@ -26,10 +26,10 @@ %} /* K is the C++ key type, T is the C++ value type */ -%define SWIG_STD_MAP_INTERNAL(K, T) +%define SWIG_STD_MAP_INTERNAL(K, T, C) -%typemap(csinterfaces) std::map< K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n"; -%typemap(cscode) std::map %{ +%typemap(csinterfaces) std::map< K, T, C > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n"; +%typemap(cscode) std::map %{ public $typemap(cstype, T) this[$typemap(cstype, K) key] { get { @@ -221,14 +221,14 @@ typedef T mapped_type; map(); - map(const map< K, T > &other); + map(const map< K, T, C > &other); size_type size() const; bool empty() const; %rename(Clear) clear; void clear(); %extend { const mapped_type& getitem(const key_type& key) throw (std::out_of_range) { - std::map< K,T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) return iter->second; else @@ -240,19 +240,19 @@ } bool ContainsKey(const key_type& key) { - std::map< K, T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); return iter != $self->end(); } void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) { - std::map< K, T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) throw std::out_of_range("key already exists"); $self->insert(std::pair< K, T >(key, val)); } bool Remove(const key_type& key) { - std::map< K, T >::iterator iter = $self->find(key); + std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) { $self->erase(iter); return true; @@ -261,20 +261,20 @@ } // create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C# - %apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin } - %apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator } + %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *create_iterator_begin } + %apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *swigiterator } - std::map< K, T >::iterator *create_iterator_begin() { - return new std::map< K, T >::iterator($self->begin()); + std::map< K, T, C >::iterator *create_iterator_begin() { + return new std::map< K, T, C >::iterator($self->begin()); } - const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) { - std::map< K, T >::iterator iter = *swigiterator; + const key_type& get_next_key(std::map< K, T, C >::iterator *swigiterator) { + std::map< K, T, C >::iterator iter = *swigiterator; (*swigiterator)++; return (*iter).first; } - void destroy_iterator(std::map< K, T >::iterator *swigiterator) { + void destroy_iterator(std::map< K, T, C >::iterator *swigiterator) { delete swigiterator; } } @@ -291,8 +291,8 @@ // Default implementation namespace std { - template class map { - SWIG_STD_MAP_INTERNAL(K, T) + template > class map { + SWIG_STD_MAP_INTERNAL(K, T, C) }; } diff --git a/Lib/exception.i b/Lib/exception.i index 8d8df33dd..050042dab 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -14,12 +14,8 @@ #ifdef SWIGPHP %{ -#if PHP_MAJOR_VERSION < 5 -# define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); } -#else -# include "zend_exceptions.h" -# define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); } -#endif +#include "zend_exceptions.h" +#define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); } %} #endif @@ -28,7 +24,7 @@ SWIGINTERN void SWIG_exception_ (int code, const char *msg, const char *subr) { #define ERROR(scmerr) \ - scm_error(gh_symbol2scm((char *) (scmerr)), \ + scm_error(scm_from_locale_string((char *) (scmerr)), \ (char *) subr, (char *) msg, \ SCM_EOL, SCM_BOOL_F) #define MAP(swigerr, scmerr) \ diff --git a/Lib/go/go.swg b/Lib/go/go.swg index 4e442c7e9..3408f422e 100644 --- a/Lib/go/go.swg +++ b/Lib/go/go.swg @@ -446,7 +446,7 @@ %} /* Typecheck typemaps. The purpose of these is merely to issue a - warning for overloaded C++ functions * that cannot be overloaded in + warning for overloaded C++ functions that cannot be overloaded in Go as more than one C++ type maps to a single Go type. */ %typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */ diff --git a/Lib/guile/Makefile b/Lib/guile/Makefile index ff66f9efa..17f5feced 100644 --- a/Lib/guile/Makefile +++ b/Lib/guile/Makefile @@ -1,4 +1,4 @@ -co:: +co: co RCS/*.i* RCS/*.swg* diff --git a/Lib/guile/cplusplus.i b/Lib/guile/cplusplus.i index 0dfe71754..d5d65efaa 100644 --- a/Lib/guile/cplusplus.i +++ b/Lib/guile/cplusplus.i @@ -5,18 +5,18 @@ * ----------------------------------------------------------------------------- */ %typemap(guile,out) string, std::string { - $result = gh_str02scm(const_cast($1.c_str())); + $result = SWIG_str02scm(const_cast($1.c_str())); } %typemap(guile,in) string, std::string { $1 = SWIG_scm2str($input); } %typemap(guile,out) complex, complex, std::complex { - $result = scm_make_rectangular( gh_double2scm ($1.real ()), - gh_double2scm ($1.imag ()) ); + $result = scm_make_rectangular( scm_from_double ($1.real ()), + scm_from_double ($1.imag ()) ); } %typemap(guile,in) complex, complex, std::complex { - $1 = std::complex( gh_scm2double (scm_real_part ($input)), - gh_scm2double (scm_imag_part ($input)) ); + $1 = std::complex( scm_to_double (scm_real_part ($input)), + scm_to_double (scm_imag_part ($input)) ); } diff --git a/Lib/guile/ghinterface.i b/Lib/guile/ghinterface.i deleted file mode 100644 index c5fda62cf..000000000 --- a/Lib/guile/ghinterface.i +++ /dev/null @@ -1,39 +0,0 @@ -#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) -#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) -#define gh_bool2scm SCM_BOOL -#define gh_boolean_p SCM_BOOLP -#define gh_car SCM_CAR -#define gh_cdr SCM_CDR -#define gh_cons scm_cons -#define gh_double2scm scm_make_real -#define gh_int2scm scm_long2num -#define gh_length(lst) scm_num2ulong(scm_length(lst), SCM_ARG1, FUNC_NAME) -#define gh_list scm_listify -#define gh_list_to_vector scm_vector -#define gh_make_vector scm_make_vector -#define gh_null_p SCM_NULLP -#define gh_number_p SCM_NUMBERP -#define gh_pair_p SCM_CONSP -#define gh_scm2bool SCM_NFALSEP -#define gh_scm2char SCM_CHAR -#define gh_scm2double(a) scm_num2dbl(a, FUNC_NAME) -#define gh_scm2int(a) scm_num2int(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2long(a) scm_num2long(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2short(a) scm_num2short(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2newstr SWIG_Guile_scm2newstr -#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2ushort(a) scm_num2ushort(a, SCM_ARG1, FUNC_NAME) -#define gh_scm2uint(a) scm_num2uint(a, SCM_ARG1, FUNC_NAME) -#define gh_ulong2scm scm_ulong2num -#define gh_long2scm scm_long2num -#define gh_str02scm scm_makfrom0str -#define gh_long_long2scm scm_long_long2num -#define gh_scm2long_long(a) scm_num2long_long(a, SCM_ARG1, FUNC_NAME) -#define gh_ulong_long2scm scm_ulong_long2num -#define gh_scm2ulong_long(a) scm_num2ulong_long(a, SCM_ARG1, FUNC_NAME) -#define gh_string_p SCM_STRINGP -#define gh_vector_length SCM_VECTOR_LENGTH -#define gh_vector_p SCM_VECTORP -#define gh_vector_ref scm_vector_ref -#define gh_vector_set_x scm_vector_set_x -#define gh_char2scm SCM_MAKE_CHAR diff --git a/Lib/guile/guile_gh.swg b/Lib/guile/guile_gh.swg deleted file mode 100644 index 3b65af897..000000000 --- a/Lib/guile/guile_gh.swg +++ /dev/null @@ -1,71 +0,0 @@ -/* ----------------------------------------------------------------------------- - * guile_gh.swg - * - * This SWIG interface file is processed if the Guile module is run - * with gh_ flavor. - * ----------------------------------------------------------------------------- */ - -#define SWIGGUILE_GH - -%runtime "swigrun.swg" -%runtime "guile_gh_run.swg" - -#define SWIG_convert_short(o) \ - SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \ - (1 << (8 * sizeof(short) - 1)) - 1, \ - FUNC_NAME, $argnum) -#define SWIG_convert_unsigned_short(o) \ - SWIG_convert_unsigned_integer(o, 0, \ - (1 << (8 * sizeof(short))) - 1, \ - FUNC_NAME, $argnum) -#define SWIG_convert_unsigned_int(o) \ - SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \ - FUNC_NAME, $argnum) - -#define gh_scm2short(a) SWIG_convert_short(a) -#define gh_scm2ushort(a) SWIG_convert_unsigned_short(a) -#define gh_scm2uint(a) SWIG_convert_unsigned_int(a) - -%include - -%runtime %{ - -/* scm_values was implemented on C level in 1.4.1, and the prototype - is not included in libguile.h, so play safe and lookup `values'... */ -#define GUILE_MAYBE_VALUES \ - if (gswig_list_p) \ - gswig_result = gh_apply(gh_lookup("values"), gswig_result); - -#define GUILE_MAYBE_VECTOR \ - if (gswig_list_p) \ - gswig_result = gh_list_to_vector(gswig_result); - -#define SWIG_APPEND_VALUE(object) \ - if (gswig_result == SCM_UNSPECIFIED) { \ - gswig_result = object; \ - } else { \ - if (!gswig_list_p) { \ - gswig_list_p = 1; \ - gswig_result = gh_list(gswig_result, object, SCM_UNDEFINED); \ - } \ - else \ - gswig_result = gh_append2(gswig_result, \ - gh_list(object, SCM_UNDEFINED)); \ - } - -%} - -%init "swiginit.swg" - -%init %{ -static int _swig_module_smob_tag; - -SWIG_GUILE_INIT_STATIC void -SWIG_init(void) -{ - - SWIG_InitializeModule(0); - swig_module.clientdata = (void *) &_swig_module_smob_tag; - - SWIG_Guile_Init(&swig_module); -%} diff --git a/Lib/guile/guile_gh_run.swg b/Lib/guile/guile_gh_run.swg deleted file mode 100644 index d8cc56b91..000000000 --- a/Lib/guile/guile_gh_run.swg +++ /dev/null @@ -1,258 +0,0 @@ -/* ----------------------------------------------------------------------------- - * guile_gh_run.swg - * - * Guile GH runtime file - * ----------------------------------------------------------------------------- */ - -#define SWIGGUILE -#include "guile/gh.h" -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef SCM (*swig_guile_proc)(); - -#define SWIG_malloc(size) \ - SCM_MUST_MALLOC(size) -#define SWIG_free(mem) \ - scm_must_free(mem) -#define SWIG_ConvertPtr(s, result, type, flags) \ - SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags) -#define SWIG_MustGetPtr(s, type, argnum, flags) \ - SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME) -#define SWIG_NewPointerObj(ptr, type, owner) \ - SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner) -#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata) -#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) - -/* Ignore object-ownership changes in gh mode */ -#define SWIG_Guile_MarkPointerNoncollectable(s) (s) -#define SWIG_Guile_MarkPointerDestroyed(s) (s) - -#define SWIG_contract_assert(expr, msg) \ - if (!(expr)) \ - scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \ - (char *) FUNC_NAME, (char *) msg, \ - SCM_EOL, SCM_BOOL_F); else - -/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for - 1.3.4 compatibility. */ -#ifndef SCM_CHAR -# define SCM_CHAR SCM_ICHR -#endif -#ifndef SCM_CHARP -# define SCM_CHARP SCM_ICHRP -#endif - -/* This function replaces gh_scm2char, which is broken in Guile 1.4 */ -SWIGINTERN char -GSWIG_scm2char (SCM s) -{ - if (SCM_CHARP(s)) return SCM_CHAR(s); - scm_wrong_type_arg(NULL, 0, s); -} -#define gh_scm2char GSWIG_scm2char - -/* Interface function */ -#define SWIG_scm2str(x) gh_scm2newstr(x, NULL) - -/* More 1.3.4 compatibility */ -#ifndef SCM_INPUT_PORT_P -# define SCM_INPUT_PORT_P SCM_INPORTP -# define SCM_OUTPUT_PORT_P SCM_OUTPORTP -#endif - -SWIGINTERN long -SWIG_convert_integer(SCM o, - long lower_bound, long upper_bound, - const char *func_name, int argnum) -{ - long value = gh_scm2long(o); - if (value < lower_bound || value > upper_bound) - scm_wrong_type_arg((char *) func_name, argnum, o); - return value; -} - -SWIGINTERN unsigned long -SWIG_convert_unsigned_integer(SCM o, - unsigned long lower_bound, - unsigned long upper_bound, - const char *func_name, int argnum) -{ - unsigned long value = gh_scm2ulong(o); - if (value < lower_bound || value > upper_bound) - scm_wrong_type_arg((char *) func_name, argnum, o); - return value; -} - -SWIGINTERN swig_type_info * -SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) -{ - swig_module_info *iter; - if (!module) return 0; - iter = module; - do { - if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) { - - return iter->types[(long) SCM_CAR(s) >> 16]; - } - iter = iter->next; - } while (iter != module); - return 0; -} - -#ifdef SWIG_GLOBAL -#define SWIG_GUILE_MODULE_STATIC -#elif !defined(SWIG_NOINCLUDE) -#define SWIG_GUILE_MODULE_STATIC static -#endif - -#ifdef SWIG_GUILE_MODULE_STATIC -static swig_module_info *swig_guile_module = 0; -SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) { - return swig_guile_module; -} -SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) { - swig_guile_module = pointer; -} -#else -SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)); -SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer); -#endif - -SWIGINTERN SCM -SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, - swig_type_info *type, int owner) -{ - unsigned long tag; - if (ptr==NULL) return SCM_EOL; - if (!module) return SCM_EOL; - for (tag = 0; tag < module->size; ++tag) { - if (module->types[tag] == type) - break; - } - if (tag >= module->size) - return SCM_EOL; - - - SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr); -} - -/* Return 0 if successful. */ -SWIGINTERN int -SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, - swig_type_info *type, int flags) -{ - swig_cast_info *cast; - swig_type_info *from; - if (SCM_NULLP(s)) { - *result = NULL; - return SWIG_OK; - } else if (SCM_NIMP(s)) { - from = SWIG_Guile_LookupType(module, s, 1); - if (!from) return SWIG_ERROR; - if (type) { - cast = SWIG_TypeCheckStruct(from, type); - if (cast) { - int newmemory = 0; - *result = SWIG_TypeCast(cast, (void *) SCM_CDR(s), &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - return SWIG_OK; - } else { - return SWIG_ERROR; - } - } else { - *result = (void *) SCM_CDR(s); - return SWIG_OK; - } - } - return SWIG_ERROR; -} - -SWIGINTERN void * -SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type, - int argnum, int flags, const char *func_name) -{ - void *result; - int res = SWIG_Guile_ConvertPtr(module, s, &result, type, flags); - if (!SWIG_IsOK(res)) { - /* type mismatch */ - scm_wrong_type_arg((char *) func_name, argnum, s); - } - return result; -} - -/* Init */ - -SWIGINTERN int -print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) -{ - swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1); - if (type) { - scm_puts((char *) "#str != NULL) - scm_puts((char *) type->str, port); - else - scm_puts((char *) type->name, port); - scm_puts((char *) " ", port); - scm_intprint((long) SCM_CDR(swig_smob), 16, port); - scm_puts((char *) ">", port); - /* non-zero means success */ - return 1; - } else { - return 0; - } -} - -SWIGINTERN SCM -equalp_swig (SCM A, SCM B) -{ - if (SCM_CAR(A) == SCM_CAR(B) - && SCM_CDR(A) == SCM_CDR(B)) - return SCM_BOOL_T; - else return SCM_BOOL_F; -} - -SWIGINTERN void -SWIG_Guile_Init (swig_module_info *module) -{ - *((int *)module->clientdata) = - scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig); -} - -SWIGINTERN int -SWIG_Guile_GetArgs (SCM *dest, SCM rest, - int reqargs, int optargs, - const char *procname) -{ - int i; - int num_args_passed = 0; - for (i = 0; i %include %runtime %{ @@ -32,10 +31,6 @@ else \ gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \ } - /* used by Lib/exception.i */ - #define gh_symbol2scm scm_str2symbol - /* useb by Lib/cdata.i */ - #define gh_str2scm scm_mem2string %} diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 925aaadb4..0ac51f919 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -12,7 +12,28 @@ extern "C" { #endif + +/* In the code below, use guile 2.0 compatible functions where possible. + Functions that don't exist in older versions will be mapped to + a deprecated equivalent for those versions only */ +#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) + +static SCM +scm_module_variable (SCM module, SCM sym) +{ + return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); +} + +#endif + +#if SCM_MAJOR_VERSION >= 2 +// scm_c_define_gsubr takes a different parameter type +// depending on the guile version + +typedef scm_t_subr swig_guile_proc; +#else typedef SCM (*swig_guile_proc)(); +#endif typedef SCM (*guile_destructor)(SCM); typedef struct swig_guile_clientdata { @@ -22,10 +43,12 @@ typedef struct swig_guile_clientdata { #define SWIG_scm2str(s) \ SWIG_Guile_scm2newstr(s, NULL) -#define SWIG_malloc(size) \ - SCM_MUST_MALLOC(size) -#define SWIG_free(mem) \ - scm_must_free(mem) +#define SWIG_str02scm(str) \ + str ? scm_from_locale_string(str) : SCM_BOOL_F +# define SWIG_malloc(size) \ + scm_malloc(size) +# define SWIG_free(mem) \ + free(mem) #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Guile_ConvertPtr(s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ @@ -42,7 +65,7 @@ typedef struct swig_guile_clientdata { SWIG_Guile_IsPointer(object) #define SWIG_contract_assert(expr, msg) \ if (!(expr)) \ - scm_error(scm_str2symbol("swig-contract-assertion-failed"), \ + scm_error(scm_from_locale_symbol("swig-contract-assertion-failed"), \ (char *) FUNC_NAME, (char *) msg, \ SCM_EOL, SCM_BOOL_F); else @@ -61,15 +84,19 @@ SWIGINTERN char * SWIG_Guile_scm2newstr(SCM str, size_t *len) { #define FUNC_NAME "SWIG_Guile_scm2newstr" char *ret; + char *tmp; size_t l; - SCM_ASSERT (SCM_STRINGP(str), str, 1, FUNC_NAME); - - l = SCM_STRING_LENGTH(str); + SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME); + l = scm_c_string_length(str); + ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); if (!ret) return NULL; - memcpy(ret, SCM_STRING_CHARS(str), l); + tmp = scm_to_locale_string(str); + memcpy(ret, tmp, l); + free(tmp); + ret[l] = '\0'; if (len) *len = l; return ret; @@ -86,7 +113,7 @@ static SCM swig_keyword = SCM_EOL; static SCM swig_symbol = SCM_EOL; #define SWIG_Guile_GetSmob(x) \ - ( SCM_NNULLP(x) && SCM_INSTANCEP(x) && SCM_NFALSEP(scm_slot_exists_p(x, swig_symbol)) \ + ( !scm_is_null(x) && SCM_INSTANCEP(x) && scm_is_true(scm_slot_exists_p(x, swig_symbol)) \ ? scm_slot_ref(x, swig_symbol) : (x) ) SWIGINTERN SCM @@ -361,18 +388,16 @@ ensure_smob_tag(SCM swig_module, const char *smob_name, const char *scheme_variable_name) { - SCM variable = scm_sym2var(scm_str2symbol(scheme_variable_name), - scm_module_lookup_closure(swig_module), - SCM_BOOL_T); - if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) { + SCM variable = scm_module_variable(swig_module, + scm_from_locale_symbol(scheme_variable_name)); + if (scm_is_false(variable)) { *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); - SCM_VARIABLE_SET(variable, - scm_ulong2num(*tag_variable)); + scm_c_module_define(swig_module, scheme_variable_name, + scm_from_ulong(*tag_variable)); return 1; } else { - *tag_variable = scm_num2ulong(SCM_VARIABLE_REF(variable), 0, - "SWIG_Guile_Init"); + *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable)); return 0; } } @@ -409,8 +434,8 @@ SWIG_Guile_Init () } swig_make_func = scm_permanent_object( scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make"))); - swig_keyword = scm_permanent_object(scm_c_make_keyword((char*) "init-smob")); - swig_symbol = scm_permanent_object(scm_str2symbol("swig-smob")); + swig_keyword = scm_permanent_object(scm_from_locale_keyword((char*) "init-smob")); + swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob")); #ifdef SWIG_INIT_RUNTIME_MODULE SWIG_INIT_RUNTIME_MODULE #endif @@ -426,13 +451,12 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) module = SWIG_Guile_Init(); - variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), - scm_module_lookup_closure(module), - SCM_BOOL_T); - if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) { + variable = scm_module_variable(module, + scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME)); + if (scm_is_false(variable)) { return NULL; } else { - return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init"); + return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable)); } } @@ -444,11 +468,9 @@ SWIG_Guile_SetModule(swig_module_info *swig_module) module = SWIG_Guile_Init(); - variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), - scm_module_lookup_closure(module), - SCM_BOOL_T); - - SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module)); + scm_module_define(module, + scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), + scm_from_ulong((unsigned long) swig_module)); } SWIGINTERN int @@ -460,7 +482,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest, int num_args_passed = 0; for (i = 0; i 0) { $1_ltype i; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0; i<$1; i++) { - SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i)); + SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $2[i] = SCM_TO_C_EXPR; } } @@ -78,15 +78,15 @@ (size_t LISTLENINPUT, C_TYPE *LISTINPUT) { SCM_VALIDATE_LIST($argnum, $input); - $1 = gh_length($input); + $1 = scm_to_ulong(scm_length($input)); if ($1 > 0) { $1_ltype i; SCM rest; $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); for (i = 0, rest = $input; i<$1; - i++, rest = gh_cdr(rest)) { - SCM swig_scm_value = gh_car(rest); + i++, rest = SCM_CDR(rest)) { + SCM swig_scm_value = SCM_CAR(rest); $2[i] = SCM_TO_C_EXPR; } } @@ -140,12 +140,12 @@ (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) { $*1_ltype i; - SCM res = gh_make_vector(gh_int2scm(*$1), + SCM res = scm_make_vector(scm_from_long(*$1), SCM_BOOL_F); for (i = 0; i<*$1; i++) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; - gh_vector_set_x(res, gh_int2scm(i), elt); + scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } @@ -159,7 +159,7 @@ for (i = ((int)(*$1)) - 1; i>=0; i--) { C_TYPE swig_c_value = (*$2)[i]; SCM elt = C_TO_SCM_EXPR; - res = gh_cons(elt, res); + res = scm_cons(elt, res); } SWIG_APPEND_VALUE(res); } @@ -200,21 +200,21 @@ /* We use the macro to define typemaps for some standard types. */ -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string); -TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); /* For the char *, free all strings after converting */ @@ -312,13 +312,13 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string const C_TYPE *PARALLEL_VECTORINPUT { SCM_VALIDATE_VECTOR($argnum, $input); - *_global_vector_length = gh_vector_length($input); + *_global_vector_length = scm_c_vector_length($input); if (*_global_vector_length > 0) { int i; $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * (*_global_vector_length)); for (i = 0; i<*_global_vector_length; i++) { - SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i)); + SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i)); $1[i] = SCM_TO_C_EXPR; } } @@ -330,7 +330,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string const C_TYPE *PARALLEL_LISTINPUT { SCM_VALIDATE_LIST($argnum, $input); - *_global_list_length = gh_length($input); + *_global_list_length = scm_to_ulong(scm_length($input)); if (*_global_list_length > 0) { int i; SCM rest; @@ -338,8 +338,8 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string * (*_global_list_length)); for (i = 0, rest = $input; i<*_global_list_length; - i++, rest = gh_cdr(rest)) { - SCM swig_scm_value = gh_car(rest); + i++, rest = SCM_CDR(rest)) { + SCM swig_scm_value = SCM_CAR(rest); $1[i] = SCM_TO_C_EXPR; } } @@ -391,12 +391,12 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string C_TYPE **PARALLEL_VECTOROUTPUT { int i; - SCM res = gh_make_vector(gh_int2scm(_global_arraylentemp), + SCM res = scm_make_vector(scm_from_long(_global_arraylentemp), SCM_BOOL_F); for (i = 0; i<_global_arraylentemp; i++) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; - gh_vector_set_x(res, gh_int2scm(i), elt); + scm_vector_set_x(res, scm_from_long(i), elt); } SWIG_APPEND_VALUE(res); } @@ -410,7 +410,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string for (i = _global_arraylentemp - 1; i>=0; i--) { C_TYPE swig_c_value = (*$1)[i]; SCM elt = C_TO_SCM_EXPR; - res = gh_cons(elt, res); + res = scm_cons(elt, res); } } SWIG_APPEND_VALUE(res); @@ -449,21 +449,21 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string /* We use the macro to define typemaps for some standard types. */ -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string); -TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); %typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT, const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT diff --git a/Lib/guile/ports.i b/Lib/guile/ports.i index 5940b4d3b..7691d3e31 100644 --- a/Lib/guile/ports.i +++ b/Lib/guile/ports.i @@ -21,33 +21,30 @@ */ %typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE * - ( int closep ) { - if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) == 0) { - closep = 0; - } - else if(!(SCM_FPORTP($input))) - scm_wrong_type_arg("$name", $argnum, $input); - else { - int fd; - if (SCM_OUTPUT_PORT_P($input)) - scm_force_output($input); - fd=dup(SCM_FPORT_FDES($input)); - if(fd==-1) - scm_misc_error("$name", strerror(errno), SCM_EOL); - $1=fdopen(fd, - SCM_OUTPUT_PORT_P($input) - ? (SCM_INPUT_PORT_P($input) - ? "r+" : "w") - : "r"); - if($1==NULL) - scm_misc_error("$name", strerror(errno), SCM_EOL); - closep = 1; + if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) != 0) { + if (!(SCM_FPORTP($input))) { + scm_wrong_type_arg("$symname", $argnum, $input); + } else { + int fd; + if (SCM_OUTPUT_PORT_P($input)) { + scm_force_output($input); + } + fd=dup(SCM_FPORT_FDES($input)); + if (fd==-1) { + scm_misc_error("$symname", strerror(errno), SCM_EOL); + } + $1=fdopen(fd, SCM_OUTPUT_PORT_P($input) ? (SCM_INPUT_PORT_P($input) ? "r+" : "w") : "r"); + if ($1==NULL) { + scm_misc_error("$symname", strerror(errno), SCM_EOL); + } + } } } %typemap(freearg) FILE* { - if (closep$argnum) + if ($1) { fclose($1); + } } diff --git a/Lib/guile/std_common.i b/Lib/guile/std_common.i index a46c42c69..18c7db089 100644 --- a/Lib/guile/std_common.i +++ b/Lib/guile/std_common.i @@ -8,8 +8,8 @@ %apply size_t { std::size_t }; -#define SWIG_bool2scm(b) gh_bool2scm(b ? 1 : 0) -#define SWIG_string2scm(s) gh_str02scm(s.c_str()) +#define SWIG_bool2scm(b) scm_from_bool(b ? 1 : 0) +#define SWIG_string2scm(s) SWIG_str02scm(s.c_str()) %{ #include diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index eb28c2831..1e1014f54 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -42,30 +42,30 @@ namespace std { template class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[*k] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -76,32 +76,32 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[*k] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -109,30 +109,30 @@ namespace std { } %typemap(out) map { SCM alist = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=$i.rbegin(); + i!=$i.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { /* native sequence? */ - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; @@ -140,8 +140,8 @@ namespace std { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -167,17 +167,17 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { /* native sequence? */ - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ K* k; T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(key,(void**) &k, $descriptor(K *), 0) != 0) { $1 = 0; @@ -185,8 +185,8 @@ namespace std { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -251,11 +251,11 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -269,31 +269,31 @@ namespace std { template class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } (($1_type &)$1)[CONVERT_FROM(key)] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -304,33 +304,33 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { T* x; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); } temp[CONVERT_FROM(key)] = *x; - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -343,31 +343,31 @@ namespace std { T* val = new T(i->second); SCM k = CONVERT_TO(i->first); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -393,24 +393,24 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only T* x; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK(key)) { $1 = 0; } else { if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == 0) $1 = 1; @@ -471,10 +471,10 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { SCM k = CONVERT_TO(i->first); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -485,30 +485,30 @@ namespace std { %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) template class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -519,32 +519,32 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { K* k; SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); if (!CHECK(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[*k] = CONVERT_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -557,31 +557,31 @@ namespace std { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = CONVERT_TO(i->second); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only K* k; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else @@ -606,24 +606,24 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only K* k; - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (SWIG_ConvertPtr(val,(void **) &k, $descriptor(K *), 0) != 0) { $1 = 0; } else { if (CHECK(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK(val)) $1 = 1; else @@ -683,11 +683,11 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -699,32 +699,32 @@ namespace std { T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) template<> class map { %typemap(in) map (std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { $1 = std::map(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { $1 = std::map(); SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = *(($&1_type) @@ -735,33 +735,33 @@ namespace std { std::map* m), const map* (std::map temp, std::map* m) { - if (gh_null_p($input)) { + if (scm_is_null($input)) { temp = std::map(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::map(); $1 = &temp; SCM alist = $input; - while (!gh_null_p(alist)) { + while (!scm_is_null(alist)) { SCM entry, key, val; - entry = gh_car(alist); - if (!gh_pair_p(entry)) + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) SWIG_exception(SWIG_TypeError,"alist expected"); - key = gh_car(entry); - val = gh_cdr(entry); + key = SCM_CAR(entry); + val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); if (!CHECK_T(val)) { - if (!gh_pair_p(val)) + if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); - val = gh_car(val); + val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, "map<" #K "," #T "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); - alist = gh_cdr(alist); + alist = SCM_CDR(alist); } } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); @@ -773,29 +773,29 @@ namespace std { i!=$1.rend(); ++i) { SCM k = CONVERT_K_TO(i->first); SCM x = CONVERT_T_TO(i->second); - SCM entry = gh_cons(k,x); - alist = gh_cons(entry,alist); + SCM entry = scm_cons(k,x); + alist = scm_cons(entry,alist); } $result = alist; } %typecheck(SWIG_TYPECHECK_MAP) map { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else @@ -820,22 +820,22 @@ namespace std { %typecheck(SWIG_TYPECHECK_MAP) const map&, const map* { // native sequence? - if (gh_null_p($input)) { + if (scm_is_null($input)) { /* an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { // check the first element only - SCM head = gh_car($input); - if (gh_pair_p(head)) { - SCM key = gh_car(head); - SCM val = gh_cdr(head); + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); if (!CHECK_K(key)) { $1 = 0; } else { if (CHECK_T(val)) { $1 = 1; - } else if (gh_pair_p(val)) { - val = gh_car(val); + } else if (scm_is_pair(val)) { + val = SCM_CAR(val); if (CHECK_T(val)) $1 = 1; else @@ -895,10 +895,10 @@ namespace std { } SCM keys() { SCM result = SCM_EOL; - for (std::map::reverse_iterator i=$1.rbegin(); - i!=$1.rend(); ++i) { + for (std::map::reverse_iterator i=self->rbegin(); + i!=self->rend(); ++i) { SCM k = CONVERT_K_TO(i->first); - result = gh_cons(k,result); + result = scm_cons(k,result); } return result; } @@ -907,446 +907,446 @@ namespace std { %enddef - specialize_std_map_on_key(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_key(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_key(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_key(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_key(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_key(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_key(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_key(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_key(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_key(std::string,gh_string_p, + specialize_std_map_on_key(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_key(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_key(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_key(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_value(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_value(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_value(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_value(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_value(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_value(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_value(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_value(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_value(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_value(std::string,gh_string_p, + specialize_std_map_on_value(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_value(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_value(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_value(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - std::string,gh_string_p, + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_map_on_both(std::string,gh_string_p, + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_map_on_both(std::string,gh_string_p, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(std::string,gh_string_p, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(std::string,gh_string_p, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_map_on_both(std::string,gh_string_p, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(std::string,gh_string_p, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(std::string,gh_string_p, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_map_on_both(std::string,gh_string_p, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(std::string,gh_string_p, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_map_on_both(std::string,gh_string_p, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - std::string,gh_string_p, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index 35f0cfad5..512d0d555 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -22,13 +22,13 @@ namespace std { template struct pair { - %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + %typemap(in) pair %{ + if (scm_is_pair($input)) { T* x; U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(*x,*y); @@ -36,40 +36,39 @@ namespace std { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { - if (gh_pair_p($input)) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ + if (scm_is_pair($input)) { T* x; U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); - temp = std::make_pair(*x,*y); - $1 = &temp; + temp = new std::pair< T, U >(*x,*y); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); U* y = new U($1.second); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); - $result = gh_cons(first,second); + $result = scm_cons(first,second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, @@ -91,11 +90,11 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && SWIG_ConvertPtr(second,(void**) &y, @@ -129,53 +128,52 @@ namespace std { %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { - %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + %typemap(in) pair %{ + if (scm_is_pair($input)) { U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); $1 = std::make_pair(CONVERT_FROM(first),*y); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { - if (gh_pair_p($input)) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ + if (scm_is_pair($input)) { U* y; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK(first)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); - temp = std::make_pair(CONVERT_FROM(first),*y); - $1 = &temp; + temp = new std::pair< T, U >(CONVERT_FROM(first),*y); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { U* y = new U($1.second); SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); - $result = gh_cons(CONVERT_TO($1.first),second); + $result = scm_cons(CONVERT_TO($1.first),second); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { @@ -196,10 +194,10 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { U* y; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK(first) && SWIG_ConvertPtr(second,(void**) &y, $descriptor(U *), 0) == 0) { @@ -230,53 +228,52 @@ namespace std { %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) template struct pair { - %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + %typemap(in) pair %{ + if (scm_is_pair($input)) { T* x; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); $1 = std::make_pair(*x,CONVERT_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { - if (gh_pair_p($input)) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ + if (scm_is_pair($input)) { T* x; SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); if (!CHECK(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); - temp = std::make_pair(*x,CONVERT_FROM(second)); - $1 = &temp; + "pair<" #T "," #U "> expected"); + temp = new std::pair< T, U >(*x,CONVERT_FROM(second)); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { T* x = new T($1.first); SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); - $result = gh_cons(first,CONVERT_TO($1.second)); + $result = scm_cons(first,CONVERT_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { @@ -297,10 +294,10 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { + if (scm_is_pair($input)) { T* x; - SCM first = gh_car($input); - SCM second = gh_cdr($input); + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (SWIG_ConvertPtr(first,(void**) &x, $descriptor(T *), 0) == 0 && CHECK(second)) { @@ -332,49 +329,47 @@ namespace std { %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) template<> struct pair { - %typemap(in) pair (std::pair* m) { - if (gh_pair_p($input)) { + %typemap(in) pair %{ + if (scm_is_pair($input)) { SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); + "pair<" #T "," #U "> expected"); $1 = std::make_pair(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); } else { $1 = *(($&1_type) SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } - } - %typemap(in) const pair& (std::pair temp, - std::pair* m), - const pair* (std::pair temp, - std::pair* m) { - if (gh_pair_p($input)) { + %} + %typemap(in) const pair& (std::pair *temp = 0), + const pair* (std::pair *temp = 0) %{ + if (scm_is_pair($input)) { SCM first, second; - first = gh_car($input); - second = gh_cdr($input); + first = SCM_CAR($input); + second = SCM_CDR($input); if (!CHECK_T(first) || !CHECK_U(second)) SWIG_exception(SWIG_TypeError, - "map<" #T "," #U "> expected"); - temp = std::make_pair(CONVERT_T_FROM(first), - CONVERT_U_FROM(second)); - $1 = &temp; + "pair<" #T "," #U "> expected"); + temp = new std::pair< T, U >(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); + $1 = temp; } else { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } - } + %} + %typemap(freearg) const pair&, const pair* %{ delete temp$argnum; %} %typemap(out) pair { - $result = gh_cons(CONVERT_T_TO($1.first), + $result = scm_cons(CONVERT_T_TO($1.first), CONVERT_U_TO($1.second)); } %typecheck(SWIG_TYPECHECK_PAIR) pair { /* native pair? */ - if (gh_pair_p($input)) { - SCM first = gh_car($input); - SCM second = gh_cdr($input); + if (scm_is_pair($input)) { + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { @@ -393,9 +388,9 @@ namespace std { %typecheck(SWIG_TYPECHECK_PAIR) const pair&, const pair* { /* native pair? */ - if (gh_pair_p($input)) { - SCM first = gh_car($input); - SCM second = gh_cdr($input); + if (scm_is_pair($input)) { + SCM first = SCM_CAR($input); + SCM second = SCM_CDR($input); if (CHECK_T(first) && CHECK_U(second)) { $1 = 1; } else { @@ -423,446 +418,446 @@ namespace std { %enddef - specialize_std_pair_on_first(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_first(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_first(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_first(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_first(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_first(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_first(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_first(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_first(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_first(std::string,gh_string_p, + specialize_std_pair_on_first(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_first(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_first(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_first(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_second(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_second(int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_second(short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_second(long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_second(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_second(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_second(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_second(double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_second(float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_second(std::string,gh_string_p, + specialize_std_pair_on_second(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_second(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_second(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_second(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(int,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(short,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(long,gh_number_p, - gh_scm2long,gh_long2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(double,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(float,gh_number_p, - gh_scm2double,gh_double2scm, - std::string,gh_string_p, + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - bool,gh_boolean_p, - gh_scm2bool,SWIG_bool2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - int,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - short,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - long,gh_number_p, - gh_scm2long,gh_long2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned int,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned short,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - unsigned long,gh_number_p, - gh_scm2ulong,gh_ulong2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - double,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - float,gh_number_p, - gh_scm2double,gh_double2scm); - specialize_std_pair_on_both(std::string,gh_string_p, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm, - std::string,gh_string_p, + std::string,scm_is_string, SWIG_scm2string,SWIG_string2scm); } diff --git a/Lib/guile/std_string.i b/Lib/guile/std_string.i index 83e0dd26d..6513173ee 100644 --- a/Lib/guile/std_string.i +++ b/Lib/guile/std_string.i @@ -27,7 +27,7 @@ namespace std { %typemap(typecheck) const string & = char *; %typemap(in) string (char * tempptr) { - if (gh_string_p($input)) { + if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); @@ -37,7 +37,7 @@ namespace std { } %typemap(in) const string & ($*1_ltype temp, char *tempptr) { - if (gh_string_p($input)) { + if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); temp.assign(tempptr); if (tempptr) SWIG_free(tempptr); @@ -48,7 +48,7 @@ namespace std { } %typemap(in) string * (char *tempptr) { - if (gh_string_p($input)) { + if (scm_is_string($input)) { tempptr = SWIG_scm2str($input); $1 = new $*1_ltype(tempptr); if (tempptr) SWIG_free(tempptr); @@ -58,19 +58,19 @@ namespace std { } %typemap(out) string { - $result = gh_str02scm($1.c_str()); + $result = SWIG_str02scm($1.c_str()); } %typemap(out) const string & { - $result = gh_str02scm($1->c_str()); + $result = SWIG_str02scm($1->c_str()); } %typemap(out) string * { - $result = gh_str02scm($1->c_str()); + $result = SWIG_str02scm($1->c_str()); } %typemap(varin) string { - if (gh_string_p($input)) { + if (scm_is_string($input)) { char *tempptr = SWIG_scm2str($input); $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); @@ -80,7 +80,7 @@ namespace std { } %typemap(varout) string { - $result = gh_str02scm($1.c_str()); + $result = SWIG_str02scm($1.c_str()); } } diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index 6a5e8ae36..79c716b10 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -42,23 +42,23 @@ namespace std { template class vector { %typemap(in) vector { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); $1 = std::vector(size); for (unsigned long i=0; i(); - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { SCM head, tail; $1 = std::vector(); tail = $input; - while (!gh_null_p(tail)) { - head = gh_car(tail); - tail = gh_cdr(tail); + while (!scm_is_null(tail)) { + head = SCM_CAR(tail); + tail = SCM_CDR(tail); $1.push_back(*((T*)SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); @@ -70,27 +70,27 @@ namespace std { } %typemap(in) const vector& (std::vector temp), const vector* (std::vector temp) { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { temp = std::vector(); $1 = &temp; SCM head, tail; tail = $input; - while (!gh_null_p(tail)) { - head = gh_car(tail); - tail = gh_cdr(tail); + while (!scm_is_null(tail)) { + head = SCM_CAR(tail); + tail = SCM_CDR(tail); temp.push_back(*((T*) SWIG_MustGetPtr(head, $descriptor(T *), $argnum, 0))); @@ -100,23 +100,23 @@ namespace std { } } %typemap(out) vector { - $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { T* x = new T((($1_type &)$1)[i]); - gh_vector_set_x($result,gh_long2scm(i), + scm_vector_set_x($result,scm_from_long(i), SWIG_NewPointerObj(x, $descriptor(T *), 1)); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); T* x; if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) @@ -124,13 +124,13 @@ namespace std { else $1 = 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; @@ -149,28 +149,28 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); if (SWIG_ConvertPtr(o,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; else $1 = 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); if (SWIG_ConvertPtr(head,(void**) &x, $descriptor(T *), 0) != -1) $1 = 1; @@ -230,24 +230,24 @@ namespace std { %define specialize_stl_vector(T,CHECK,CONVERT_FROM,CONVERT_TO) template<> class vector { %typemap(in) vector { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); $1 = std::vector(size); for (unsigned long i=0; i(); - } else if (gh_pair_p($input)) { - SCM v = gh_list_to_vector($input); - unsigned long size = gh_vector_length(v); + } else if (scm_is_pair($input)) { + SCM v = scm_vector($input); + unsigned long size = scm_c_vector_length(v); $1 = std::vector(size); for (unsigned long i=0; i& (std::vector temp), const vector* (std::vector temp) { - if (gh_vector_p($input)) { - unsigned long size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i(); $1 = &temp; - } else if (gh_pair_p($input)) { - SCM v = gh_list_to_vector($input); - unsigned long size = gh_vector_length(v); + } else if (scm_is_pair($input)) { + SCM v = scm_vector($input); + unsigned long size = scm_c_vector_length(v); temp = std::vector(size); $1 = &temp; for (unsigned long i=0; i { - $result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED); + $result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); for (unsigned int i=0; i<$1.size(); i++) { SCM x = CONVERT_TO((($1_type &)$1)[i]); - gh_vector_set_x($result,gh_long2scm(i),x); + scm_vector_set_x($result,scm_from_long(i),x); } } %typecheck(SWIG_TYPECHECK_VECTOR) vector { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ @@ -328,24 +328,24 @@ namespace std { %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, const vector* { /* native sequence? */ - if (gh_vector_p($input)) { - unsigned int size = gh_vector_length($input); + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); if (size == 0) { /* an empty sequence can be of any type */ $1 = 1; } else { /* check the first element only */ T* x; - SCM o = gh_vector_ref($input,gh_ulong2scm(0)); + SCM o = scm_vector_ref($input,scm_from_ulong(0)); $1 = CHECK(o) ? 1 : 0; } - } else if (gh_null_p($input)) { + } else if (scm_is_null($input)) { /* again, an empty sequence can be of any type */ $1 = 1; - } else if (gh_pair_p($input)) { + } else if (scm_is_pair($input)) { /* check the first element only */ T* x; - SCM head = gh_car($input); + SCM head = SCM_CAR($input); $1 = CHECK(head) ? 1 : 0; } else { /* wrapped vector? */ @@ -394,17 +394,17 @@ namespace std { }; %enddef - specialize_stl_vector(bool,gh_boolean_p,gh_scm2bool,SWIG_bool2scm); - specialize_stl_vector(char,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(int,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(long,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm); - specialize_stl_vector(unsigned char,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(unsigned int,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(unsigned long,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(unsigned short,gh_number_p,gh_scm2ulong,gh_ulong2scm); - specialize_stl_vector(float,gh_number_p,gh_scm2double,gh_double2scm); - specialize_stl_vector(double,gh_number_p,gh_scm2double,gh_double2scm); - specialize_stl_vector(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm); + specialize_stl_vector(bool,scm_is_bool,scm_is_true,SWIG_bool2scm); + specialize_stl_vector(char,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(int,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(long,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(short,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(unsigned char,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned int,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned long,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned short,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(float,scm_is_number,scm_to_double,scm_from_double); + specialize_stl_vector(double,scm_is_number,scm_to_double,scm_from_double); + specialize_stl_vector(std::string,scm_is_string,SWIG_scm2string,SWIG_string2scm); } diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index 4e07d3fd8..d818613e7 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -68,14 +68,14 @@ %typemap(throws) SWIGTYPE { $<ype temp = new $ltype($1); - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj(temp, $&descriptor, 1), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE & { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1), SCM_UNDEFINED)); } @@ -86,14 +86,14 @@ } %typemap(throws) SWIGTYPE * { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj($1, $descriptor, 1), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE [] { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(SWIG_NewPointerObj($1, $descriptor, 1), + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } @@ -160,23 +160,23 @@ /* Enums */ -%typemap(in) enum SWIGTYPE { $1 = ($1_type) gh_scm2int($input); } +%typemap(in) enum SWIGTYPE { $1 = ($1_type) scm_to_int($input); } /* The complicated construction below needed to deal with anonymous enums, which cannot be cast to. */ %typemap(varin) enum SWIGTYPE { if (sizeof(int) != sizeof($1)) { - scm_error(scm_str2symbol("swig-error"), + scm_error(scm_from_locale_symbol("swig-error"), (char *) FUNC_NAME, (char *) "enum variable '$name' cannot be set", SCM_EOL, SCM_BOOL_F); } - * (int *) &($1) = gh_scm2int($input); + * (int *) &($1) = scm_to_int($input); } -%typemap(out) enum SWIGTYPE { $result = gh_int2scm($1); } -%typemap(varout) enum SWIGTYPE { $result = gh_int2scm($1); } +%typemap(out) enum SWIGTYPE { $result = scm_from_long($1); } +%typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); } %typemap(throws) enum SWIGTYPE { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(gh_int2scm($1), SCM_UNDEFINED)); + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(scm_from_long($1), SCM_UNDEFINED)); } /* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of @@ -224,8 +224,8 @@ /* Throw typemap */ %typemap(throws) C_NAME { C_NAME swig_c_value = $1; - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(C_TO_SCM_EXPR, SCM_UNDEFINED)); + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED)); } %enddef @@ -268,34 +268,34 @@ } /* Throw typemap */ %typemap(throws) C_NAME { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(C_TO_SCM($1), SCM_UNDEFINED)); + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(C_TO_SCM($1), SCM_UNDEFINED)); } %enddef - SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean); - SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char); - SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char); - SIMPLE_MAP(signed char, gh_scm2char, gh_char2scm, char); - SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer); - SIMPLE_MAP(short, gh_scm2short, gh_int2scm, integer); - SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer); - SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer); - SIMPLE_MAP(unsigned int, gh_scm2uint, gh_ulong2scm, integer); - SIMPLE_MAP(unsigned short, gh_scm2ushort, gh_ulong2scm, integer); - SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer); - SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer); - SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real); - SIMPLE_MAP(double, gh_scm2double, gh_double2scm, real); -// SIMPLE_MAP(char *, SWIG_scm2str, gh_str02scm, string); -// SIMPLE_MAP(const char *, SWIG_scm2str, gh_str02scm, string); + SIMPLE_MAP(bool, scm_is_true, scm_from_bool, boolean); + SIMPLE_MAP(char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(signed char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(int, scm_to_int, scm_from_long, integer); + SIMPLE_MAP(short, scm_to_short, scm_from_long, integer); + SIMPLE_MAP(long, scm_to_long, scm_from_long, integer); + SIMPLE_MAP(ptrdiff_t, scm_to_long, scm_from_long, integer); + SIMPLE_MAP(unsigned int, scm_to_uint, scm_from_ulong, integer); + SIMPLE_MAP(unsigned short, scm_to_ushort, scm_from_ulong, integer); + SIMPLE_MAP(unsigned long, scm_to_ulong, scm_from_ulong, integer); + SIMPLE_MAP(size_t, scm_to_ulong, scm_from_ulong, integer); + SIMPLE_MAP(float, scm_to_double, scm_from_double, real); + SIMPLE_MAP(double, scm_to_double, scm_from_double, real); +// SIMPLE_MAP(char *, SWIG_scm2str, SWIG_str02scm, string); +// SIMPLE_MAP(const char *, SWIG_scm2str, SWIG_str02scm, string); /* Define long long typemaps -- uses functions that are only defined in recent versions of Guile, availability also depends on Guile's configuration. */ -SIMPLE_MAP(long long, gh_scm2long_long, gh_long_long2scm, integer); -SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); +SIMPLE_MAP(long long, scm_to_long_long, scm_from_long_long, integer); +SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer); /* Strings */ @@ -304,8 +304,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); must_free = 1; } %typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);} - %typemap (out, doc="") char * {$result = gh_str02scm((const char *)$1);} - %typemap (varout, doc="") char * {$result = gh_str02scm($1);} + %typemap (out, doc="") char * {$result = SWIG_str02scm((const char *)$1);} + %typemap (varout, doc="") char * {$result = SWIG_str02scm($1);} %typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) { temp = (char *) SWIG_scm2str($input); $1 = &temp; must_free = 1; @@ -313,7 +313,7 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); %typemap (in,numinputs=0) char **OUTPUT (char * temp) {$1 = &temp;} %typemap (argout,doc="$NAME (a string)") char **OUTPUT - {SWIG_APPEND_VALUE(gh_str02scm(*$1));} + {SWIG_APPEND_VALUE(SWIG_str02scm(*$1));} %typemap (in) char **BOTH = char **INPUT; %typemap (argout) char **BOTH = char **OUTPUT; %typemap (in) char **INOUT = char **INPUT; @@ -343,8 +343,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer); } %typemap(throws) char * { - scm_throw(gh_symbol2scm((char *) "swig-exception"), - gh_list(gh_str02scm($1), SCM_UNDEFINED)); + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_str02scm($1), SCM_UNDEFINED)); } /* Void */ @@ -364,7 +364,7 @@ typedef unsigned long SCM; %typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { size_t temp; - $1 = ($1_ltype) gh_scm2newstr($input, &temp); + $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); $2 = ($2_ltype) temp; } @@ -420,7 +420,7 @@ typedef unsigned long SCM; const std::size_t &, const std::ptrdiff_t &, enum SWIGTYPE { - $1 = SCM_NFALSEP(scm_integer_p($input)) && SCM_NFALSEP(scm_exact_p($input))? 1 : 0; + $1 = scm_is_true(scm_integer_p($input)) && scm_is_true(scm_exact_p($input))? 1 : 0; } %typecheck(SWIG_TYPECHECK_BOOL) @@ -433,7 +433,7 @@ typedef unsigned long SCM; float, double, const float &, const double & { - $1 = SCM_NFALSEP(scm_real_p($input)) ? 1 : 0; + $1 = scm_is_true(scm_real_p($input)) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_CHAR) char { @@ -441,7 +441,7 @@ typedef unsigned long SCM; } %typecheck(SWIG_TYPECHECK_STRING) char * { - $1 = SCM_STRINGP($input) ? 1 : 0; + $1 = scm_is_string($input) ? 1 : 0; } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i index ae2377b70..e71790bcc 100644 --- a/Lib/java/typemaps.i +++ b/Lib/java/typemaps.i @@ -207,8 +207,8 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue); } -%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; -%typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE; +%typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE; +%typemap(typecheck) TYPE &OUTPUT = TYPECHECKTYPE; %enddef OUTPUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); diff --git a/Lib/java/various.i b/Lib/java/various.i index f589bf714..7ba7a5eb3 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -52,7 +52,7 @@ %typemap(freearg) char **STRING_ARRAY { int i; - for (i=0; istr)?type->str:"void*") #define SWIG_check_num_args(func_name,a,b) \ if (lua_gettop(L)b) \ - {lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ + {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ goto fail;} @@ -220,8 +261,7 @@ SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L) /* there should be 1 param passed in: the new value */ #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE lua_pop(L,1); /* remove it */ - lua_pushstring(L,"This variable is immutable"); - lua_error(L); + luaL_error(L,"This variable is immutable"); #endif return 0; /* should not return anything */ } @@ -385,6 +425,137 @@ SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_ SWIG_Lua_add_function(L,name,fn); } +/* ----------------------------------------------------------------------------- + * global variable support code: namespaces + * ----------------------------------------------------------------------------- */ + +SWIGINTERN int SWIG_Lua_namespace_get(lua_State* L) +{ +/* there should be 2 params passed in + (1) table (not the meta table) + (2) string name of the attribute +*/ + assert(lua_istable(L,-2)); /* just in case */ + lua_getmetatable(L,-2); + assert(lua_istable(L,-1)); + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); + /* look for the key in the .get table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + lua_remove(L,-2); /* stack tidy, remove .get table */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + /* ok, so try the .fn table */ + SWIG_Lua_get_table(L,".fn"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* look for the fn */ + lua_remove(L,-2); /* stack tidy, remove .fn table */ + if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */ + { /* found it so return the fn & let lua call it */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + return 0; +} + +SWIGINTERN int SWIG_Lua_namespace_set(lua_State* L) +{ +/* there should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value +*/ + + assert(lua_istable(L,1)); + lua_getmetatable(L,1); /* get the meta table */ + assert(lua_istable(L,-1)); + + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + if (lua_istable(L,-1)) + { + /* look for the key in the .set table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,3); /* value */ + lua_call(L,1,0); + return 0; + } + lua_pop(L,1); /* remove the value */ + } + lua_pop(L,1); /* remove the value .set table */ + return 0; +} + +SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]); // forward declaration +SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn); // forward declaration + +/* helper function - register namespace methods and attributes into namespace */ +SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State* L, swig_lua_namespace* ns) +{ + int i = 0; + assert(lua_istable(L,-1)); + /* There must be table at the top of the stack */ + SWIG_Lua_InstallConstants(L, ns->ns_constants); + + lua_getmetatable(L,-1); + + /* add fns */ + for(i=0;ns->ns_attributes[i].name;i++){ + SWIG_Lua_add_class_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod); + } + + /* add methods to the metatable */ + SWIG_Lua_get_table(L,".fn"); /* find the .fn table */ + assert(lua_istable(L,-1)); /* just in case */ + for(i=0;ns->ns_methods[i].name;i++){ + SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].method); + } + lua_pop(L,1); + + /* clear stack - remove metatble */ + lua_pop(L,1); + +} + +/* helper function. creates namespace table and add it to module table */ +SWIGINTERN int SWIG_Lua_namespace_register(lua_State* L, swig_lua_namespace* ns) +{ + assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table */ + lua_checkstack(L,5); + lua_pushstring(L, ns->name); + lua_newtable(L); /* namespace itself */ + lua_newtable(L); /* metatable for namespace */ + + /* add a table called ".get" */ + lua_pushstring(L,".get"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".set" */ + lua_pushstring(L,".set"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".fn" */ + lua_pushstring(L,".fn"); + lua_newtable(L); + lua_rawset(L,-3); + + /* add accessor fns for using the .get,.set&.fn */ + SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get); + SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set); + + lua_setmetatable(L,-2); /* set metatable */ + lua_rawset(L,-3); /* add namespace to module table */ +} /* ----------------------------------------------------------------------------- * global variable support code: classes * ----------------------------------------------------------------------------- */ @@ -540,6 +711,23 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State* L) return 0; } +/* Constructor proxy. Used when class name entry in module is not class constructor, +but special table instead. */ +SWIGINTERN int SWIG_Lua_constructor_proxy(lua_State* L) +{ + /* unlimited number of parameters + First one is our proxy table and we should remove it + Other we should pass to real constructor + */ + assert(lua_istable(L,1)); + lua_pushstring(L,".constructor"); + lua_rawget(L,1); + assert(!lua_isnil(L,-1)); + lua_replace(L,1); /* replace our table with real constructor */ + lua_call(L,lua_gettop(L)-1,1); + return 1; +} + /* gets the swig class registry (or creates it) */ SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L) { @@ -584,6 +772,21 @@ SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_C } } +/* helper to recursively add class static details (static attributes, operations and constants) */ +SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State* L, swig_lua_class* clss) +{ + int i = 0; + /* The class namespace table must be on the top of the stack */ + assert(lua_istable(L,-1)); + /* call all the base classes first: we can then override these later: */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_add_class_static_details(L,clss->bases[i]); + } + + SWIG_Lua_add_namespace_details(L, &clss->cls_static); +} + /* helper to recursively add class details (attributes & operations) */ SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss) { @@ -637,15 +840,42 @@ SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss) } } -/* performs the entire class registration process */ -SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) +/* Register class static methods,attributes etc as well as constructor proxy */ +SWIGINTERN void SWIG_Lua_class_register_static(lua_State* L, swig_lua_class* clss) { + lua_checkstack(L,5); /* just in case */ + assert(lua_istable(L,-1)); /* just in case */ + assert(strcmp(clss->name, clss->cls_static.name) == 0); /* in class those 2 must be equal */ + + SWIG_Lua_namespace_register(L,&clss->cls_static); + + SWIG_Lua_get_table(L,clss->name); // Get namespace table back + assert(lua_istable(L,-1)); /* just in case */ + /* add its constructor to module with the name of the class so you can do MyClass(...) as well as new_MyClass(...) BUT only if a constructor is defined (this overcomes the problem of pure virtual classes without constructors)*/ if (clss->constructor) - SWIG_Lua_add_function(L,clss->name,clss->constructor); + { + SWIG_Lua_add_function(L,".constructor", clss->constructor); + lua_getmetatable(L,-1); + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,"__call", SWIG_Lua_constructor_proxy); + lua_pop(L,1); + } + + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_class_static_details(L, clss); + + /* clear stack */ + lua_pop(L,1); +} + +/* performs the entire class registration process */ +SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) +{ + SWIG_Lua_class_register_static(L,clss); SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->name); /* get the name */ @@ -756,9 +986,8 @@ SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *typ int argnum,const char* func_name){ void* result; if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ - lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n", - func_name,(type && type->str)?type->str:"void*",argnum); - lua_error(L); + luaL_error (L,"Error in %s, expected a %s at argument number %d\n", + func_name,(type && type->str)?type->str:"void*",argnum); } return result; } diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index a7ecec528..7a095a1e0 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -250,12 +250,12 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index) SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\ TYPE *array;\ if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\ - lua_pushfstring(L,"expected a table of size %d",size);\ + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -265,17 +265,17 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index) {\ TYPE *array;\ if (!lua_istable(L,index)) {\ - lua_pushstring(L,"expected a table");\ + SWIG_Lua_pusherrstring(L,"expected a table");\ return 0;\ }\ *size=SWIG_itable_size(L,index);\ if (*size<1){\ - lua_pushstring(L,"table appears to be empty");\ + SWIG_Lua_pusherrstring(L,"table appears to be empty");\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,*size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -451,12 +451,12 @@ SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size, SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){ void **array; if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) { - lua_pushfstring(L,"expected a table of size %d",size); + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size); return 0; } array=SWIG_ALLOC_ARRAY(void*,size); if (!SWIG_read_ptr_array(L,index,array,size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } @@ -465,17 +465,17 @@ SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swi SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){ void **array; if (!lua_istable(L,index)) { - lua_pushstring(L,"expected a table"); + SWIG_Lua_pusherrstring(L,"expected a table"); return 0; } *size=SWIG_itable_size(L,index); if (*size<1){ - lua_pushstring(L,"table appears to be empty"); + SWIG_Lua_pusherrstring(L,"table appears to be empty"); return 0; } array=SWIG_ALLOC_ARRAY(void*,*size); if (!SWIG_read_ptr_array(L,index,array,*size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } diff --git a/Lib/lua/wchar.i b/Lib/lua/wchar.i index 14a94257f..141ecc41f 100644 --- a/Lib/lua/wchar.i +++ b/Lib/lua/wchar.i @@ -31,7 +31,7 @@ wchar_t* str2wstr(const char *str, int len) %typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t * %{ $1 = str2wstr(lua_tostring( L, $input ),lua_rawlen( L, $input )); -if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} +if ($1==0) {SWIG_Lua_pushferrstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} %} %typemap(freearg) wchar_t * diff --git a/Lib/mzscheme/Makefile b/Lib/mzscheme/Makefile index ff66f9efa..17f5feced 100644 --- a/Lib/mzscheme/Makefile +++ b/Lib/mzscheme/Makefile @@ -1,4 +1,4 @@ -co:: +co: co RCS/*.i* RCS/*.swg* diff --git a/Lib/mzscheme/typemaps.i b/Lib/mzscheme/typemaps.i index 026ec9567..9346349bd 100644 --- a/Lib/mzscheme/typemaps.i +++ b/Lib/mzscheme/typemaps.i @@ -287,7 +287,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double, //%typemap(in) (char *STRING, int LENGTH) { // int temp; -// $1 = ($1_ltype) gh_scm2newstr($input, &temp); +// $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp); // $2 = ($2_ltype) temp; //} diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index dfb4a7702..41d1c7afa 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1280,7 +1280,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPacked(const octave_value &ov, void *ptr, siz return ost->copy(type, (char *) ptr, sz) ? SWIG_OK : SWIG_ERROR; } -void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) { +SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) { module_ns->assign(name, ov); } @@ -1289,16 +1289,7 @@ SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) { } SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) { - // It is critical that a newly-allocated octave_value is passed to set_global_value(), - // since it and the Octave symbol table take references to the values assigned to it. - // If we were to pass a reference to 'value' to set_global_value(), then the Octave - // symbol table would hold a reference to a variable owned by the SWIG .oct module. - // Both will think that they own the reference (since the .oct module is dynamically - // loaded, it appears to have its own C++ runtime), and so they will both try to - // de-allocate the octave_value on exit, resulting in a double-free or seg-fault. - // This is prevented by giving Octave its own heap-allocated copy of 'value'. - octave_value *pov = new octave_value(value); - set_global_value(name, *pov); + set_global_value(name, value); } SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) { diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 66b6e265a..43313c3d4 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -288,6 +288,15 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { SWIG_InstallOps(octave_swig_ref::static_type_id()); + octave_swig_type::swig_member_const_iterator mb; + for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) { + if (mb->second.first && mb->second.first->method) { + if (!SWIG_Octave_InstallFunction(me, mb->first)) { + return octave_value_list(); + } + } + } + #if OCTAVE_API_VERSION_NUMBER < 37 mlock(me->name()); #else @@ -296,16 +305,9 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { } - octave_function *me = octave_call_stack::current(); - octave_swig_type::swig_member_const_iterator mb; for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) { - if (mb->second.first && mb->second.first->method) { - if (!SWIG_Octave_InstallFunction(me, mb->first)) { - return octave_value_list(); - } - } - else if (mb->second.second.is_defined()) { + if (mb->second.second.is_defined()) { SWIG_Octave_SetGlobalValue(mb->first, mb->second.second); SWIG_Octave_LinkGlobalValue(mb->first); } diff --git a/Lib/octave/std_map.i b/Lib/octave/std_map.i index 6c476ce53..7b85a548e 100644 --- a/Lib/octave/std_map.i +++ b/Lib/octave/std_map.i @@ -2,73 +2,9 @@ %include -%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { - template - inline void - assign(const OctSeq& octseq, std::map *map) { - typedef typename std::map::value_type value_type; - typename OctSeq::const_iterator it = octseq.begin(); - for (;it != octseq.end(); ++it) { - map->insert(value_type(it->first, it->second)); - } - } - - template - struct traits_asptr > { - typedef std::map map_type; - static int asptr(octave_value obj, map_type **val) { - /* - int res = SWIG_ERROR; - if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); - res = traits_asptr_stdseq, std::pair >::asptr(items, val); - } else { - map_type *p; - res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); - if (SWIG_IsOK(res) && val) *val = p; - } - return res; - */ - return SWIG_ERROR; - } - }; - - template - struct traits_from > { - typedef std::map map_type; - typedef typename map_type::const_iterator const_iterator; - typedef typename map_type::size_type size_type; - - static octave_value from(const map_type& map) { - /* - swig_type_info *desc = swig::type_info(); - if (desc && desc->clientdata) { - return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); - } else { - size_type size = map.size(); - int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; - if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, - "map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject *obj = PyDict_New(); - for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); - PyDict_SetItem(obj, key, val); - } - return obj; - } - */ - return octave_value(); - } - }; - template struct from_key_oper { @@ -138,6 +74,75 @@ } } +%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") +{ + namespace swig { + template + inline void + assign(const OctSeq& octseq, std::map *map) { + typedef typename std::map::value_type value_type; + typename OctSeq::const_iterator it = octseq.begin(); + for (;it != octseq.end(); ++it) { + map->insert(value_type(it->first, it->second)); + } + } + + template + struct traits_asptr > { + typedef std::map map_type; + static int asptr(octave_value obj, map_type **val) { + /* + int res = SWIG_ERROR; + if (PyDict_Check(obj)) { + SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); + } else { + map_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + */ + return SWIG_ERROR; + } + }; + + template + struct traits_from > { + typedef std::map map_type; + typedef typename map_type::const_iterator const_iterator; + typedef typename map_type::size_type size_type; + + static octave_value from(const map_type& map) { + /* + swig_type_info *desc = swig::type_info(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); + } else { + size_type size = map.size(); + int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (pysize < 0) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_OverflowError, + "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + PyObject *obj = PyDict_New(); + for (const_iterator i= map.begin(); i!= map.end(); ++i) { + swig::SwigVar_PyObject key = swig::from(i->first); + swig::SwigVar_PyObject val = swig::from(i->second); + PyDict_SetItem(obj, key, val); + } + return obj; + } + */ + return octave_value(); + } + }; + } +} + %define %swig_map_common(Map...) %swig_sequence_iterator(Map); %swig_container_methods(Map); diff --git a/Lib/perl5/Makefile.in b/Lib/perl5/Makefile.in index dde01894d..f11ad2bdf 100644 --- a/Lib/perl5/Makefile.in +++ b/Lib/perl5/Makefile.in @@ -47,7 +47,7 @@ SWIGOPT = -perl5 SWIGCC = $(CC) # SWIG Library files. Uncomment this to staticly rebuild Perl -#SWIGLIB = -static -lperlmain.i +#SWIGLIBS = -static -lperlmain.i # Rules for creating .o files from source. @@ -69,33 +69,21 @@ BUILD = @LDSHARED@ #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc -# X11 installation (possibly needed if using Perl-Tk) - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ - # Perl installation PERL_INCLUDE = -I@PERL5EXT@ PERL_LIB = -L@PERL5EXT@ -lperl PERL_FLAGS = -Dbool=char -Dexplicit= -# Tcl installation. If using Tk you might need this - -TCL_INCLUDE = @TCLINCLUDE@ -TCL_LIB = @TCLLIB@ - # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ -# Build options (uncomment only one these) +# Build options -#TK_LIB = $(TCL_LIB) -ltcl -ltk $(XLIB) BUILD_LIBS = $(LIBS) # Dynamic loading -#BUILD_LIBS = $(PERL_LIB) $(TK_LIB) $(LIBS) $(SYSLIBS) # Static linking # Compilation rules for non-SWIG components @@ -123,7 +111,7 @@ $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(PERL_INCLUDE) $(PERL_FLAGS) $(WRAPFILE) $(WRAPFILE) : $(INTERFACE) - $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 6a183ff7e..325abbcd4 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -295,6 +295,15 @@ ZVAL_LONG($input, (long)$1_name); } +%typemap(directorin) char *, char [] +{ + if(!$1) { + ZVAL_NULL($input); + } else { + ZVAL_STRING($input, (char *)$1, 1); + } +} + %typemap(out) bool { ZVAL_BOOL(return_value,($1)?1:0); diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 92f2f3fe5..a4188cc7c 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -209,11 +209,11 @@ SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { const char *type_name; value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); - if ( flags & SWIG_POINTER_DISOWN ) { + if (type==-1) return NULL; + if (flags & SWIG_POINTER_DISOWN) { value->newobject = 0; } p = value->ptr; - if (type==-1) return NULL; type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg index 868f04d54..95cc20835 100644 --- a/Lib/pike/pike.swg +++ b/Lib/pike/pike.swg @@ -11,9 +11,9 @@ #ifdef __cplusplus extern "C" { #endif -#include -#include -#include +#include +#include +#include #ifdef __cplusplus } #endif diff --git a/Lib/pike/pikerun.swg b/Lib/pike/pikerun.swg index 70d40fac9..6ec1143cf 100644 --- a/Lib/pike/pikerun.swg +++ b/Lib/pike/pikerun.swg @@ -9,11 +9,12 @@ #ifdef __cplusplus extern "C" { #endif -#include "object.h" -#include "program.h" +#include "pike/object.h" +#include "pike/program.h" #ifdef __cplusplus } #endif +#include /* Stores information about a wrapped object */ typedef struct swig_object_wrapper { diff --git a/Lib/python/Makefile.in b/Lib/python/Makefile.in index 3243b3df4..71effea70 100644 --- a/Lib/python/Makefile.in +++ b/Lib/python/Makefile.in @@ -47,7 +47,7 @@ SWIGOPT = -python SWIGCC = $(CC) # SWIG Library files. Uncomment if rebuilding the Python interpreter -#SWIGLIB = -lembed.i +#SWIGLIBS = -lembed.i # Rules for creating .o files from source. @@ -69,32 +69,20 @@ BUILD = @LDSHARED@ #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc -# X11 installation (needed if rebuilding Python + tkinter) - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ - # Python installation PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@ PY_LIB = @PYLIB@ -# Tcl installation. Needed if rebuilding Python with tkinter. - -TCL_INCLUDE = @TCLINCLUDE@ -TCL_LIB = @TCLLIB@ - # Build libraries (needed for static builds) LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ -# Build options (uncomment only one these) +# Build options -#TKINTER = $(TCL_LIB) -ltk -ltcl $(XLIB) BUILD_LIBS = $(LIBS) # Dynamic loading -#BUILD_LIBS = $(PY_LIB) @PYLINK@ $(TKINTER) $(LIBS) $(SYSLIBS) # Compilation rules for non-SWIG components @@ -122,7 +110,7 @@ $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE) $(WRAPFILE) : $(INTERFACE) - $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 1fc3fb05f..28c557a21 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -13,7 +13,11 @@ wrapper##_closure(PyObject *a) { \ PyObject *o = wrapper(a, NULL); \ Py_XDECREF(o); \ } \ - PyObject_Del(a); \ + if (PyType_IS_GC(a->ob_type)) { \ + PyObject_GC_Del(a); \ + } else { \ + PyObject_Del(a); \ + } \ } #define SWIGPY_INQUIRY_CLOSURE(wrapper) \ diff --git a/Lib/python/director.swg b/Lib/python/director.swg index ca46f6dab..97edc7ef0 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -33,7 +33,7 @@ /* Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the - Undefined Exception Handler provided by swift + Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NO_UEH #ifndef SWIG_DIRECTOR_UEH diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index eb089e98e..d4386622e 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -339,7 +339,7 @@ namespace swig { std::advance(it,ii); for (size_t rc=0; rcend(); ++c) it++; } } @@ -357,7 +357,7 @@ namespace swig { std::advance(it,size-ii-1); for (size_t rc=0; rcrend(); ++c) it++; } } @@ -383,9 +383,7 @@ namespace swig { size_t delcount = (jj - ii + step - 1) / step; while (delcount) { it = self->erase(it); - if (it==self->end()) - break; - for (Py_ssize_t c=0; c<(step-1); ++c) + for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) it++; delcount--; } @@ -398,10 +396,8 @@ namespace swig { typename Sequence::reverse_iterator it = sb; size_t delcount = (ii - jj - step - 1) / -step; while (delcount) { - self->erase((++it).base()); - if (it==self->rend()) - break; - for (Py_ssize_t c=0; c<(-step-1); ++c) + it = typename Sequence::reverse_iterator(self->erase((++it).base())); + for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) it++; delcount--; } diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i index 4026805ba..96af343ca 100644 --- a/Lib/python/pyname_compat.i +++ b/Lib/python/pyname_compat.i @@ -67,10 +67,8 @@ #define PySwigObject_next SwigPyObject_next #define PySwigObject_oct SwigPyObject_oct #define PySwigObject_own SwigPyObject_own -#define PySwigObject_print SwigPyObject_print #define PySwigObject_repr SwigPyObject_repr #define PySwigObject_richcompare SwigPyObject_richcompare -#define PySwigObject_str SwigPyObject_str #define PySwigObject_type SwigPyObject_type #define PySwigPacked SwigPyPacked #define PySwigPacked_Check SwigPyPacked_Check diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index 3fbd86a21..66ff104a6 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -127,6 +127,18 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) return SWIG_OK; } else { PyErr_Clear(); +%#if PY_VERSION_HEX >= 0x03000000 + { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (v < 0) { + return SWIG_OverflowError; + } + } else { + PyErr_Clear(); + } + } +%#endif } } %#ifdef SWIG_PYTHON_CAST_MODE diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 3585e7a3f..b077fad32 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -448,34 +448,6 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) return repr; } -SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char *str; -#ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); -#else - PyObject *repr = SwigPyObject_repr(v, NULL); -#endif - if (repr) { - str = SWIG_Python_str_AsChar(repr); - fputs(str, fp); - SWIG_Python_str_DelForPy3(str); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; -} - SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { @@ -668,7 +640,7 @@ SwigPyObject_own(PyObject *v, PyObject *args) static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, @@ -761,7 +733,7 @@ SwigPyObject_TypeOnce(void) { sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - (printfunc)SwigPyObject_print, /* tp_print */ + 0, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else @@ -779,7 +751,7 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ + 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -1156,10 +1128,11 @@ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; if (!obj) return SWIG_ERROR; - if (obj == Py_None) { + if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; return SWIG_OK; @@ -1208,7 +1181,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } res = SWIG_OK; } else { - if (flags & SWIG_POINTER_IMPLICIT_CONV) { + if (implicit_conv) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; @@ -1243,6 +1216,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } } return res; } @@ -1742,7 +1722,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyObject *descr; PyObject *encoded_name; descrsetfunc f; - int res; + int res = -1; # ifdef Py_USING_UNICODE if (PyString_Check(name)) { @@ -1765,7 +1745,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { goto done; } - res = -1; descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg index dd22a1fdf..fad97be9f 100644 --- a/Lib/python/pyruntime.swg +++ b/Lib/python/pyruntime.swg @@ -1,6 +1,12 @@ %insert(runtime) %{ -/* Python.h has to appear first */ -#include +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include +# define _DEBUG +#else +# include +#endif %} %insert(runtime) "swigrun.swg"; /* SWIG API */ @@ -13,4 +19,4 @@ #if defined(SWIGPYTHON_BUILTIN) %insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */ -#endif \ No newline at end of file +#endif diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg index 5247ee65b..d3c3eb188 100644 --- a/Lib/python/pyuserdir.swg +++ b/Lib/python/pyuserdir.swg @@ -7,6 +7,7 @@ /* shadow code */ #define %shadow %insert("shadow") #define %pythoncode %insert("python") +#define %pythonbegin %insert("pythonbegin") /* ------------------------------------------------------------------------- */ diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index 619bdd555..864376b01 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -18,9 +18,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) int isunicode = PyUnicode_Check(obj); %#if PY_VERSION_HEX < 0x03000000 if (!isunicode && PyString_Check(obj)) { - if (cptr) { - obj = tmp = PyUnicode_FromObject(obj); - } + obj = tmp = PyUnicode_FromObject(obj); isunicode = 1; } %#endif diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 37d749790..66ed68da5 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -2,7 +2,79 @@ Maps */ -%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") +{ + namespace swig { + template + struct from_key_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.first); + } + }; + + template + struct from_value_oper + { + typedef const ValueType& argument_type; + typedef PyObject *result_type; + result_type operator()(argument_type v) const + { + return swig::from(v.second); + } + }; + + template + struct SwigPyMapIterator_T : SwigPyIteratorClosed_T + { + SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyIteratorClosed_T(curr, first, last, seq) + { + } + }; + + + template > + struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T + { + SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T(curr, first, last, seq) + { + } + }; + + template + inline SwigPyIterator* + make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapKeyIterator_T(current, begin, end, seq); + } + + template > + struct SwigPyMapValueITerator_T : SwigPyMapIterator_T + { + SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapIterator_T(curr, first, last, seq) + { + } + }; + + + template + inline SwigPyIterator* + make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapValueITerator_T(current, begin, end, seq); + } + } +} + +%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template @@ -73,74 +145,6 @@ } } }; - - template - struct from_key_oper - { - typedef const ValueType& argument_type; - typedef PyObject *result_type; - result_type operator()(argument_type v) const - { - return swig::from(v.first); - } - }; - - template - struct from_value_oper - { - typedef const ValueType& argument_type; - typedef PyObject *result_type; - result_type operator()(argument_type v) const - { - return swig::from(v.second); - } - }; - - template - struct SwigPyMapIterator_T : SwigPyIteratorClosed_T - { - SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyIteratorClosed_T(curr, first, last, seq) - { - } - }; - - - template > - struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T - { - SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T(curr, first, last, seq) - { - } - }; - - template - inline SwigPyIterator* - make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapKeyIterator_T(current, begin, end, seq); - } - - template > - struct SwigPyMapValueITerator_T : SwigPyMapIterator_T - { - SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T(curr, first, last, seq) - { - } - }; - - - template - inline SwigPyIterator* - make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapValueITerator_T(current, begin, end, seq); - } - } } diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index 8a240ae10..c81e2ac5d 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -3,7 +3,7 @@ */ %include -%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template diff --git a/Lib/r/r.swg b/Lib/r/r.swg index be42ff3a1..126611d61 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -114,12 +114,19 @@ signed int *OUTPUT, unsigned int *OUTPUT, short *OUTPUT, signed short *OUTPUT, +unsigned short *OUTPUT, long *OUTPUT, signed long *OUTPUT, +unsigned long *OUTPUT, long long *OUTPUT, +signed long long *OUTPUT, unsigned long long *OUTPUT, float *OUTPUT, -double *OUTPUT {} +double *OUTPUT, +char *OUTPUT, +signed char *OUTPUT, +unsigned char *OUTPUT +{} diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index 672ec833d..9e5aa7b6d 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -161,6 +161,8 @@ string &, std::string & #%typemap(scoerceout) SWIGTYPE *const # %{ class($result) <- "$R_class"; %} + %typemap(scoerceout) SEXP %{ %} + %typemap(scoerceout) SWIGTYPE %{ $result <- new("$&R_class", ref=$result); %} diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index 9807b11bb..a5daf2176 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -7,7 +7,7 @@ /* Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the - Undefined Exception Handler provided by swift + Undefined Exception Handler provided by swig. */ #ifndef SWIG_DIRECTOR_NOUEH #ifndef SWIG_DIRECTOR_UEH diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg index 2048b1f5f..5537136af 100644 --- a/Lib/ruby/rubyclasses.swg +++ b/Lib/ruby/rubyclasses.swg @@ -36,11 +36,64 @@ %fragment("GC_VALUE_definition","header") { namespace swig { + class SwigGCReferences { + // Hash of all GC_VALUE's currently in use + static SwigGCReferences s_references; + + VALUE _hash; + + SwigGCReferences() : _hash(Qnil) { + } + ~SwigGCReferences() { + if (_hash != Qnil) + rb_gc_unregister_address(&_hash); + } + static void EndProcHandler(VALUE) { + // Ruby interpreter ending - _hash can no longer be accessed. + s_references._hash = Qnil; + } + public: + static SwigGCReferences& instance() { + return s_references; + } + static void initialize() { + if (s_references._hash == Qnil) { + rb_set_end_proc(&EndProcHandler, Qnil); + s_references._hash = rb_hash_new(); + rb_gc_register_address(&s_references._hash); + } + } + void GC_register(VALUE& obj) { + if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) + return; + if (_hash != Qnil) { + VALUE val = rb_hash_aref(_hash, obj); + unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; + ++n; + rb_hash_aset(_hash, obj, INT2NUM(n)); + } + } + void GC_unregister(const VALUE& obj) { + if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj)) + return; + // this test should not be needed but I've noticed some very erratic + // behavior of none being unregistered in some very rare situations. + if (BUILTIN_TYPE(obj) == T_NONE) + return; + if (_hash != Qnil) { + VALUE val = rb_hash_aref(s_references._hash, obj); + unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; + --n; + if (n) + rb_hash_aset(s_references._hash, obj, INT2NUM(n)); + else + rb_hash_delete(s_references._hash, obj); + } + } + }; + class GC_VALUE { protected: - // Hash of all GC_VALUE's currently in use - static VALUE _hash; - VALUE _obj; static ID hash_id; @@ -77,75 +130,33 @@ namespace swig { public: - static void initialize() - { - if ( _hash == Qnil ) - { - _hash = rb_hash_new(); - rb_gc_register_address( &_hash ); - } - } - - // this function is never called. Provided for symmetry only. - static void cleanup() - { - rb_gc_unregister_address( &_hash ); - } - - GC_VALUE() : _obj( Qnil ) + GC_VALUE() : _obj(Qnil) { } GC_VALUE(const GC_VALUE& item) : _obj(item._obj) { - GC_register(); + SwigGCReferences::instance().GC_register(_obj); } GC_VALUE(VALUE obj) :_obj(obj) { - GC_register(); + SwigGCReferences::instance().GC_register(_obj); } ~GC_VALUE() { - GC_unregister(); + SwigGCReferences::instance().GC_unregister(_obj); } GC_VALUE & operator=(const GC_VALUE& item) { - GC_unregister(); + SwigGCReferences::instance().GC_unregister(_obj); _obj = item._obj; - GC_register(); + SwigGCReferences::instance().GC_register(_obj); return *this; } - void GC_register() - { - if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) ) - return; - VALUE val = rb_hash_aref( _hash, _obj ); - unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0; - ++n; - rb_hash_aset( _hash, _obj, INT2NUM(n) ); - } - - void GC_unregister() - { - if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) ) - return; - // this test should not be needed but I've noticed some very erratic - // behavior of none being unregistered in some very rare situations. - if ( BUILTIN_TYPE(_obj) == T_NONE ) return; - - VALUE val = rb_hash_aref( _hash, _obj ); - unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1; - --n; - if ( n ) - rb_hash_aset( _hash, _obj, INT2NUM(n) ); - else - rb_hash_delete( _hash, _obj ); - } - operator VALUE() const { return _obj; @@ -161,113 +172,110 @@ namespace swig { return rb_inspect(_obj); } - static VALUE swig_protect_funcall( VALUE p ) + static VALUE swig_rescue_swallow(VALUE) + { + /* + VALUE errstr = rb_obj_as_string(rb_errinfo()); + printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr))); + */ + return Qnil; /* Swallow Ruby exception */ + } + + static VALUE swig_rescue_funcall(VALUE p) { OpArgs* args = (OpArgs*) p; - return rb_funcall( args->src, args->id, args->nargs, args->target ); + return rb_funcall(args->src, args->id, args->nargs, args->target); } - -%#define GC_VALUE_CMP( op_id, op, cmp, cmpval ) \ - bool op( const GC_VALUE& other ) const \ - { \ - if ( FIXNUM_P(_obj) && FIXNUM_P(other._obj) ) \ - { \ - return _obj cmp other._obj; \ - } \ - bool res = false; \ - VALUE ret = Qnil; \ - SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - if ( rb_respond_to( _obj, op_id ) == Qtrue ) \ - { \ - int status; \ - OpArgs args; \ - args.src = _obj; \ - args.id = op_id; \ - args.nargs = 1; \ - args.target = VALUE(other); \ - ret = rb_protect( PROTECTFUNC(swig_protect_funcall), \ - VALUE(&args), &status ); \ - } \ - if ( ret == Qnil ) { \ - VALUE a = rb_funcall( _obj, hash_id, 0 ); \ - VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); \ - res = a cmp b; \ - } \ - else \ - { \ - res = RTEST( ret ); \ - } \ - SWIG_RUBY_THREAD_END_BLOCK; \ - return res; \ + bool relational_equal_op(const GC_VALUE& other, const ID& op_id, bool (*op_func)(const VALUE& a, const VALUE& b)) const + { + if (FIXNUM_P(_obj) && FIXNUM_P(other._obj)) { + return op_func(_obj, other._obj); + } + bool res = false; + VALUE ret = Qnil; + SWIG_RUBY_THREAD_BEGIN_BLOCK; + if (rb_respond_to(_obj, op_id)) { + OpArgs args; + args.src = _obj; + args.id = op_id; + args.nargs = 1; + args.target = VALUE(other); + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + } + if (ret == Qnil) { + VALUE a = rb_funcall( _obj, hash_id, 0 ); + VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); + res = op_func(a, b); + } else { + res = RTEST(ret); + } + SWIG_RUBY_THREAD_END_BLOCK; + return res; } + static bool operator_eq(const VALUE& a, const VALUE& b) { return a == b; } + static bool operator_lt(const VALUE& a, const VALUE& b) { return a < b; } + static bool operator_le(const VALUE& a, const VALUE& b) { return a <= b; } + static bool operator_gt(const VALUE& a, const VALUE& b) { return a > b; } + static bool operator_ge(const VALUE& a, const VALUE& b) { return a >= b; } - GC_VALUE_CMP( eq_id, operator==, ==, == 0 ) - GC_VALUE_CMP( lt_id, operator<, < , < 0 ) - GC_VALUE_CMP( le_id, operator<=, <=, <= 0 ) - GC_VALUE_CMP( gt_id, operator>, > , > 0 ) - GC_VALUE_CMP( ge_id, operator>=, >=, >= 0 ) -%#undef GC_VALUE_CMP + bool operator==(const GC_VALUE& other) const { return relational_equal_op(other, eq_id, operator_eq); } + bool operator<(const GC_VALUE& other) const { return relational_equal_op(other, lt_id, operator_lt); } + bool operator<=(const GC_VALUE& other) const { return relational_equal_op(other, le_id, operator_le); } + bool operator>(const GC_VALUE& other) const { return relational_equal_op(other, gt_id, operator_gt); } + bool operator>=(const GC_VALUE& other) const { return relational_equal_op(other, ge_id, operator_ge); } - bool operator!=( const GC_VALUE& other ) + bool operator!=(const GC_VALUE& other) const { return !(this->operator==(other)); } -%#define GC_VALUE_UNARY( proc_id, op ) \ - GC_VALUE op() const \ - { \ - VALUE ret = Qnil; \ - SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - int status; \ - OpArgs args; \ - args.src = _obj; \ - args.id = proc_id; \ - args.nargs = 0; \ - args.target = Qnil; \ - ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \ - &status ); \ - SWIG_RUBY_THREAD_END_BLOCK; \ - return ret; \ + GC_VALUE unary_op(const ID& op_id) const + { + VALUE ret = Qnil; + SWIG_RUBY_THREAD_BEGIN_BLOCK; + OpArgs args; + args.src = _obj; + args.id = op_id; + args.nargs = 0; + args.target = Qnil; + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + SWIG_RUBY_THREAD_END_BLOCK; + return ret; } - GC_VALUE_UNARY( pos_id, operator+ ) - GC_VALUE_UNARY( neg_id, operator- ) - GC_VALUE_UNARY( inv_id, operator~ ) -%#undef GC_VALUE_BINARY + GC_VALUE operator+() const { return unary_op(pos_id); } + GC_VALUE operator-() const { return unary_op(neg_id); } + GC_VALUE operator~() const { return unary_op(inv_id); } -%#define GC_VALUE_BINARY( proc_id, op ) \ - GC_VALUE op( const GC_VALUE& other ) const \ - { \ - VALUE ret = Qnil; \ - SWIG_RUBY_THREAD_BEGIN_BLOCK; \ - int status; \ - OpArgs args; \ - args.src = _obj; \ - args.id = proc_id; \ - args.nargs = 1; \ - args.target = VALUE(other); \ - ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \ - &status ); \ - SWIG_RUBY_THREAD_END_BLOCK; \ - return GC_VALUE(ret); \ + GC_VALUE binary_op(const GC_VALUE& other, const ID& op_id) const + { + VALUE ret = Qnil; + SWIG_RUBY_THREAD_BEGIN_BLOCK; + OpArgs args; + args.src = _obj; + args.id = op_id; + args.nargs = 1; + args.target = VALUE(other); + ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), + (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + SWIG_RUBY_THREAD_END_BLOCK; + return GC_VALUE(ret); } - GC_VALUE_BINARY( add_id, operator+ ); - GC_VALUE_BINARY( sub_id, operator- ); - GC_VALUE_BINARY( mul_id, operator* ); - GC_VALUE_BINARY( div_id, operator/ ); - GC_VALUE_BINARY( mod_id, operator% ); - - GC_VALUE_BINARY( and_id, operator& ); - GC_VALUE_BINARY( xor_id, operator^ ); - GC_VALUE_BINARY( or_id, operator| ); - - GC_VALUE_BINARY( lshift_id, operator<< ); - GC_VALUE_BINARY( rshift_id, operator>> ); -%#undef GC_VALUE_BINARY - + GC_VALUE operator+(const GC_VALUE& other) const { return binary_op(other, add_id); } + GC_VALUE operator-(const GC_VALUE& other) const { return binary_op(other, sub_id); } + GC_VALUE operator*(const GC_VALUE& other) const { return binary_op(other, mul_id); } + GC_VALUE operator/(const GC_VALUE& other) const { return binary_op(other, div_id); } + GC_VALUE operator%(const GC_VALUE& other) const { return binary_op(other, mod_id); } + GC_VALUE operator&(const GC_VALUE& other) const { return binary_op(other, and_id); } + GC_VALUE operator^(const GC_VALUE& other) const { return binary_op(other, xor_id); } + GC_VALUE operator|(const GC_VALUE& other) const { return binary_op(other, or_id); } + GC_VALUE operator<<(const GC_VALUE& other) const { return binary_op(other, lshift_id); } + GC_VALUE operator>>(const GC_VALUE& other) const { return binary_op(other, rshift_id); } }; ID GC_VALUE::hash_id = rb_intern("hash"); @@ -294,7 +302,7 @@ namespace swig { ID GC_VALUE::lshift_id = rb_intern("<<"); ID GC_VALUE::rshift_id = rb_intern(">>"); - VALUE GC_VALUE::_hash = Qnil; + SwigGCReferences SwigGCReferences::s_references; typedef GC_VALUE LANGUAGE_OBJ; @@ -337,7 +345,7 @@ namespace swig { VALUE to_s() const; GC_VALUE(); protected: - GC_VALUE( const GC_VALUE& ); + GC_VALUE(const GC_VALUE&); ~GC_VALUE(); }; @@ -350,7 +358,7 @@ namespace swig { %init { - swig::GC_VALUE::initialize(); + swig::SwigGCReferences::initialize(); } diff --git a/Lib/ruby/rubycomplex.swg b/Lib/ruby/rubycomplex.swg index afdb15e7e..4e249c71f 100644 --- a/Lib/ruby/rubycomplex.swg +++ b/Lib/ruby/rubycomplex.swg @@ -1,49 +1,66 @@ /* Defines the As/From conversors for double/float complex, you need to - provide complex Type, the Name you want to use in the conversors, + provide complex Type, the Name you want to use in the converters, the complex Constructor method, and the Real and Imag complex - accesor methods. + accessor methods. See the std_complex.i and ccomplex.i for concrete examples. */ -/* - Ruby does not have native complex numbers. They are an extension in the - STD library. -*/ -%{ - static VALUE swig_rb_cComplex = Qnil; - static ID swig_real_id = 0; - static ID swig_imag_id = 0; - - int Ruby_Is_Complex( VALUE obj ) - { - return ( (rb_respond_to( obj, swig_real_id ) == Qtrue) && - (rb_respond_to( obj, swig_imag_id ) == Qtrue) ); - } -%} - -%init { - rb_require("complex"); - swig_rb_cComplex = rb_const_get( rb_cObject, rb_intern("Complex") ); - if( swig_rb_cComplex == Qnil ) - rb_warn("Ruby's complex.so not found"); - swig_real_id = rb_intern("real"); - swig_imag_id = rb_intern("imag"); +%fragment("rb_complex_new","header") +{ +%#if !defined(T_COMPLEX) +/* Ruby versions prior to 1.9 did not have native complex numbers. They were an extension in the STD library. */ +SWIGINTERN VALUE rb_complex_new(VALUE x, VALUE y) { + static ID new_id = rb_intern("new"); + static VALUE cComplex = rb_const_get(rb_cObject, rb_intern("Complex")); + return rb_funcall(cComplex, new_id, 2, x, y); +} +%#endif } -/* the common from conversor */ +%fragment("SWIG_Complex_Numbers","header") +{ +%#if !defined(T_COMPLEX) +SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { + static ID real_id = rb_intern("real"); + static ID imag_id = rb_intern("imag"); + return ( (rb_respond_to( obj, real_id ) ) && + (rb_respond_to( obj, imag_id ) ) ); +} +%#else +SWIGINTERN int SWIG_Is_Complex( VALUE obj ) { + return TYPE(obj) == T_COMPLEX; +} +%#endif + +SWIGINTERN VALUE SWIG_Complex_Real(VALUE obj) { + static ID real_id = rb_intern("real"); + return rb_funcall(obj, real_id, 0); +} + +SWIGINTERN VALUE SWIG_Complex_Imaginary(VALUE obj) { + static ID imag_id = rb_intern("imag"); + return rb_funcall(obj, imag_id, 0); +} +} + +%init { +%#if !defined(T_COMPLEX) + rb_require("complex"); +%#endif +} + +/* the common from converter */ %define %swig_fromcplx_conv(Type, Real, Imag) -%fragment(SWIG_From_frag(Type),"header") +%fragment(SWIG_From_frag(Type),"header",fragment="rb_complex_new") { SWIGINTERNINLINE VALUE SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) { - VALUE args[] = { - rb_float_new(Real(c)), - rb_float_new(Imag(c)) - }; - return rb_class_new_instance(2, args, swig_rb_cComplex); + VALUE re = rb_float_new(Real(c)); + VALUE im = rb_float_new(Imag(c)); + return rb_complex_new(re, im); } } %enddef @@ -51,15 +68,16 @@ SWIG_From(Type)(%ifcplusplus(const Type&, Type) c) /* the double case */ %define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", - fragment=SWIG_AsVal_frag(double)) + fragment=SWIG_AsVal_frag(double), + fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type) (VALUE o, Type* val) { - if ( Ruby_Is_Complex( o ) ) { + if ( SWIG_Is_Complex( o ) ) { if (val) { - VALUE real = rb_funcall(o, swig_real_id, 0 ); - VALUE imag = rb_funcall(o, swig_imag_id, 0 ); + VALUE real = SWIG_Complex_Real(o); + VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; @@ -85,13 +103,14 @@ SWIG_AsVal(Type) (VALUE o, Type* val) %define %swig_cplxflt_conv(Type, Constructor, Real, Imag) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float), - fragment=SWIG_AsVal_frag(double)) { + fragment=SWIG_AsVal_frag(double), + fragment="SWIG_Complex_Numbers") { SWIGINTERN int SWIG_AsVal(Type)(VALUE o, Type *val) { - if ( Ruby_Is_Complex( o ) ) { - VALUE real = rb_funcall(o, swig_real_id, 0 ); - VALUE imag = rb_funcall(o, swig_imag_id, 0 ); + if ( SWIG_Is_Complex( o ) ) { + VALUE real = SWIG_Complex_Real(o); + VALUE imag = SWIG_Complex_Imaginary(o); double re = 0; SWIG_AsVal_double( real, &re ); double im = 0; diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index d8d15f690..d4eaa5f73 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -677,27 +677,6 @@ namespace swig return r; } - %alias reject_bang "delete_if"; - Sequence* reject_bang() { - if ( !rb_block_given_p() ) - rb_raise( rb_eArgError, "no block given" ); - - Sequence::iterator i = self->begin(); - Sequence::iterator e = self->end(); - for ( ; i != e; ) - { - VALUE r = swig::from< Sequence::value_type >(*i); - if ( RTEST( rb_yield(r) ) ) { - $self->erase(i++); - e = self->end(); - } else { - ++i; - } - } - - return self; - } - VALUE delete_at(difference_type i) { VALUE r = Qnil; try { @@ -757,6 +736,19 @@ namespace swig } %enddef +%define %swig_sequence_methods_extra(Sequence...) + %extend { + %alias reject_bang "delete_if"; + Sequence* reject_bang() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + $self->erase( std::remove_if( $self->begin(), $self->end(), + swig::yield< Sequence::value_type >() ), $self->end() ); + return $self; + } + } +%enddef /** * Macro used to add functions for Sequences @@ -764,6 +756,7 @@ namespace swig */ %define %swig_sequence_methods(Sequence...) %swig_sequence_methods_common(%arg(Sequence)); + %swig_sequence_methods_extra(%arg(Sequence)); %swig_sequence_back_inserters(%arg(Sequence)); %extend { diff --git a/Lib/ruby/rubycontainer_extended.swg b/Lib/ruby/rubycontainer_extended.swg index d2a058586..7514ba2c8 100644 --- a/Lib/ruby/rubycontainer_extended.swg +++ b/Lib/ruby/rubycontainer_extended.swg @@ -124,7 +124,6 @@ %swig_container_extend( %arg( Container ), std::complex ); %swig_container_extend( %arg( Container ), std::string ); %swig_container_extend( %arg( Container ), swig::GC_VALUE ); -%swig_container_extend( %arg( Container ), swig::GC_VALUE ); %enddef diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 00fb11f39..e851b1801 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -411,7 +411,7 @@ SWIG_Ruby_SetModule(swig_module_info *pointer) SWIGINTERN int SWIG_Ruby_isCallable( VALUE proc ) { - if ( rb_respond_to( proc, swig_call_id ) == Qtrue ) + if ( rb_respond_to( proc, swig_call_id ) ) return 1; return 0; } @@ -424,7 +424,7 @@ int SWIG_Ruby_isCallable( VALUE proc ) SWIGINTERN int SWIG_Ruby_arity( VALUE proc, int minimal ) { - if ( rb_respond_to( proc, swig_arity_id ) == Qtrue ) + if ( rb_respond_to( proc, swig_arity_id ) ) { VALUE num = rb_funcall( proc, swig_arity_id, 0 ); int arity = NUM2INT(num); diff --git a/Lib/ruby/std_map.i b/Lib/ruby/std_map.i index e23f1c31b..f706ca873 100644 --- a/Lib/ruby/std_map.i +++ b/Lib/ruby/std_map.i @@ -1,67 +1,9 @@ // // Maps // -%fragment("StdMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits") { namespace swig { - template - inline void - assign(const RubySeq& rubyseq, std::map *map) { - typedef typename std::map::value_type value_type; - typename RubySeq::const_iterator it = rubyseq.begin(); - for (;it != rubyseq.end(); ++it) { - map->insert(value_type(it->first, it->second)); - } - } - - template - struct traits_asptr > { - typedef std::map map_type; - static int asptr(VALUE obj, map_type **val) { - int res = SWIG_ERROR; - if ( TYPE(obj) == T_HASH ) { - static ID id_to_a = rb_intern("to_a"); - VALUE items = rb_funcall(obj, id_to_a, 0); - res = traits_asptr_stdseq, std::pair >::asptr(items, val); - } else { - map_type *p; - res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); - if (SWIG_IsOK(res) && val) *val = p; - } - return res; - } - }; - - template - struct traits_from > { - typedef std::map map_type; - typedef typename map_type::const_iterator const_iterator; - typedef typename map_type::size_type size_type; - - static VALUE from(const map_type& map) { - swig_type_info *desc = swig::type_info(); - if (desc && desc->clientdata) { - return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); - } else { - size_type size = map.size(); - int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; - if (rubysize < 0) { - SWIG_RUBY_THREAD_BEGIN_BLOCK; - rb_raise( rb_eRuntimeError, "map size not valid in Ruby"); - SWIG_RUBY_THREAD_END_BLOCK; - return Qnil; - } - VALUE obj = rb_hash_new(); - for (const_iterator i= map.begin(); i!= map.end(); ++i) { - VALUE key = swig::from(i->first); - VALUE val = swig::from(i->second); - rb_hash_aset(obj, key, val); - } - return obj; - } - } - }; - template struct from_key_oper { @@ -134,6 +76,69 @@ } } +%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") +{ + namespace swig { + template + inline void + assign(const RubySeq& rubyseq, std::map *map) { + typedef typename std::map::value_type value_type; + typename RubySeq::const_iterator it = rubyseq.begin(); + for (;it != rubyseq.end(); ++it) { + map->insert(value_type(it->first, it->second)); + } + } + + template + struct traits_asptr > { + typedef std::map map_type; + static int asptr(VALUE obj, map_type **val) { + int res = SWIG_ERROR; + if ( TYPE(obj) == T_HASH ) { + static ID id_to_a = rb_intern("to_a"); + VALUE items = rb_funcall(obj, id_to_a, 0); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); + } else { + map_type *p; + res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); + if (SWIG_IsOK(res) && val) *val = p; + } + return res; + } + }; + + template + struct traits_from > { + typedef std::map map_type; + typedef typename map_type::const_iterator const_iterator; + typedef typename map_type::size_type size_type; + + static VALUE from(const map_type& map) { + swig_type_info *desc = swig::type_info(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); + } else { + size_type size = map.size(); + int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1; + if (rubysize < 0) { + SWIG_RUBY_THREAD_BEGIN_BLOCK; + rb_raise( rb_eRuntimeError, "map size not valid in Ruby"); + SWIG_RUBY_THREAD_END_BLOCK; + return Qnil; + } + VALUE obj = rb_hash_new(); + for (const_iterator i= map.begin(); i!= map.end(); ++i) { + VALUE key = swig::from(i->first); + VALUE val = swig::from(i->second); + rb_hash_aset(obj, key, val); + } + return obj; + } + } + }; + } +} + %define %swig_map_common(Map...) %swig_container_methods(%arg(Map)); // %swig_sequence_iterator(%arg(Map)); diff --git a/Lib/ruby/std_multimap.i b/Lib/ruby/std_multimap.i index 31795c768..3e06ee12c 100644 --- a/Lib/ruby/std_multimap.i +++ b/Lib/ruby/std_multimap.i @@ -3,7 +3,7 @@ */ %include -%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") +%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { template diff --git a/Lib/ruby/std_set.i b/Lib/ruby/std_set.i index 00596b4a6..e38702ef5 100644 --- a/Lib/ruby/std_set.i +++ b/Lib/ruby/std_set.i @@ -152,10 +152,29 @@ } %} +%define %swig_sequence_methods_extra_set(Sequence...) + %extend { + %alias reject_bang "delete_if"; + Sequence* reject_bang() { + if ( !rb_block_given_p() ) + rb_raise( rb_eArgError, "no block given" ); + + for ( Sequence::iterator i = $self->begin(); i != $self->end(); ) { + VALUE r = swig::from< Sequence::value_type >(*i); + Sequence::iterator current = i++; + if ( RTEST( rb_yield(r) ) ) + $self->erase(current); + } + + return self; + } + } +%enddef %define %swig_set_methods(set...) %swig_sequence_methods_common(%arg(set)); + %swig_sequence_methods_extra_set(%arg(set)); %fragment("RubyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="RubySequence_Cont") {} diff --git a/Lib/std/std_multimap.i b/Lib/std/std_multimap.i index 829d1b9de..39f674da5 100644 --- a/Lib/std/std_multimap.i +++ b/Lib/std/std_multimap.i @@ -60,6 +60,20 @@ namespace std { %traits_swigtype(_Key); %traits_swigtype(_Tp); + %fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header", + fragment=SWIG_Traits_frag(_Key), + fragment=SWIG_Traits_frag(_Tp), + fragment="StdPairTraits") { + namespace swig { + template <> struct traits > { + typedef pointer_category category; + static const char* type_name() { + return "std::pair<" #_Key "," #_Tp " >"; + } + }; + } + } + %fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header", fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >), fragment="StdMultimapTraits") { diff --git a/Lib/swigerrors.swg b/Lib/swigerrors.swg index 32857c498..1a6d20366 100644 --- a/Lib/swigerrors.swg +++ b/Lib/swigerrors.swg @@ -1,16 +1,16 @@ /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 diff --git a/Lib/swiginit.swg b/Lib/swiginit.swg index f747bccdf..f321181eb 100644 --- a/Lib/swiginit.swg +++ b/Lib/swiginit.swg @@ -1,17 +1,17 @@ /* ----------------------------------------------------------------------------- * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned staticly to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -21,17 +21,17 @@ * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it + * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * - * First off, we lookup the cast->type name to see if it is already loaded. + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the + * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that @@ -94,7 +94,7 @@ SWIG_InitializeModule(void *clientdata) { module_head->next = &swig_module; } - /* When multiple interpeters are used, a module could have already been initialized in + /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ @@ -108,7 +108,7 @@ SWIG_InitializeModule(void *clientdata) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; - + #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif @@ -135,7 +135,7 @@ SWIG_InitializeModule(void *clientdata) { /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { - + /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG diff --git a/Lib/swiglabels.swg b/Lib/swiglabels.swg index b943afb47..d428ac33d 100644 --- a/Lib/swiglabels.swg +++ b/Lib/swiglabels.swg @@ -29,28 +29,28 @@ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -93,7 +93,7 @@ # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index e5afb62c4..7066e670e 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -22,7 +22,7 @@ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. - + But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ @@ -48,16 +48,16 @@ #define SWIG_POINTER_OWN 0x1 -/* +/* Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer + + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). - + Use the following macros/flags to set or process the returning states. - + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { @@ -90,23 +90,23 @@ } else { // fail code } - + I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be @@ -120,17 +120,17 @@ int fooi(int); and you call - + food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ -#define SWIG_OK (0) +#define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) @@ -161,14 +161,14 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { +SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif @@ -212,7 +212,7 @@ typedef struct swig_module_info { void *clientdata; /* Language specific module data */ } swig_module_info; -/* +/* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. @@ -232,18 +232,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1, /* Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal + Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; - while (!equiv && *ne) { + while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; @@ -251,24 +251,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { /* Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb + Return 0 if not equal, 1 if equal */ SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } - /* Check the typename */ @@ -296,7 +285,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { return 0; } -/* +/* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * @@ -331,7 +320,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } -/* +/* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * @@ -375,7 +364,7 @@ SWIG_TypePrettyName(const swig_type_info *type) { return type->name; } -/* +/* Set the clientdata field for a type */ SWIGRUNTIME void @@ -383,14 +372,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; - + while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } - } + } cast = cast->next; } } @@ -399,18 +388,18 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } - + /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { swig_module_info *iter = start; do { @@ -419,11 +408,11 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, register size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + register size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { register int compare = strcmp(name, iname); - if (compare == 0) { + if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { @@ -448,14 +437,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); @@ -474,12 +463,12 @@ SWIG_TypeQueryModule(swig_module_info *start, iter = iter->next; } while (iter != end); } - + /* neither found a match */ return 0; } -/* +/* Pack binary data into a string */ SWIGRUNTIME char * @@ -495,7 +484,7 @@ SWIG_PackData(char *c, void *ptr, size_t sz) { return c; } -/* +/* Unpack binary data from a string */ SWIGRUNTIME const char * @@ -509,21 +498,21 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) { uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); - else + else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); - else + else return (char *) 0; *u = uu; } return c; } -/* +/* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * diff --git a/Lib/tcl/Makefile.in b/Lib/tcl/Makefile.in index 523349bb5..2ab0f7b01 100644 --- a/Lib/tcl/Makefile.in +++ b/Lib/tcl/Makefile.in @@ -1,5 +1,5 @@ # --------------------------------------------------------------- -# SWIG Tcl/Tk Makefile +# SWIG Tcl Makefile # # This file can be used to build various Tcl extensions with SWIG. # By default this file is set up for dynamic loading, but it can @@ -48,9 +48,8 @@ SWIG = $(exec_prefix)/bin/swig SWIGOPT = -tcl # use -tcl8 for Tcl 8.0 SWIGCC = $(CC) -# SWIG Library files. Uncomment one of these for rebuilding tclsh or wish -#SWIGLIB = -ltclsh.i -#SWIGLIB = -lwish.i +# SWIG Library files. Uncomment if rebuilding tclsh +#SWIGLIBS = -ltclsh.i # Rules for creating .o files from source. @@ -72,12 +71,7 @@ BUILD = @LDSHARED@ #DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \ -L/usr/local/lib -lg++ -lstdc++ -lgcc -# X11 installation (needed to rebuild Tk extensions) - -XLIB = @XLIBSW@ -XINCLUDE = @XINCLUDES@ - -# Tcl installation (where is Tcl/Tk located) +# Tcl installation (where is Tcl located) TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ @@ -88,11 +82,10 @@ LIBM = @LIBM@ LIBC = @LIBC@ SYSLIBS = $(LIBM) $(LIBC) @LIBS@ -# Build options (uncomment only one these) +# Build options (uncomment only one of these) BUILD_LIBS = $(LIBS) # Dynamic loading #BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh -#BUILD_LIBS = $(TCL_LIB) -ltk -ltcl $(XLIB) $(LIBS) $(SYSLIBS) # wish # Compilation rules for non-SWIG components @@ -120,7 +113,7 @@ $(WRAPOBJ) : $(WRAPFILE) $(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE) $(WRAPFILE) : $(INTERFACE) - $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE) + $(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE) $(TARGET): $(WRAPOBJ) $(ALLOBJS) $(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET) diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index 214133edc..46fc80fd2 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -195,42 +195,42 @@ %define %attribute(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_)) #else - %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, self_->GetMethod()) + %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, self_->GetMethod()) #endif %enddef %define %attribute2(Class, AttributeType, AttributeName, GetMethod, SetMethod...) #if #SetMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_)) #else - %attribute_readonly(Class, AttributeType, AttributeName, GetMethod, &self_->GetMethod()) + %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, &self_->GetMethod()) #endif %enddef %define %attributeref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else - %attribute_custom(Class, AttributeType, AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_) #endif %enddef %define %attribute2ref(Class, AttributeType, AttributeName, AccessorMethod...) #if #AccessorMethod != "" - %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) #else - %attribute_custom(Class, AttributeType, AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) #endif %enddef // deprecated (same as %attributeref, but there is an argument order inconsistency) %define %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName...) #if #AttributeName != "" - %attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #else - %attribute_custom(Class, AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_) #endif %enddef diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index 4dbc1f20d..8f887e34e 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -153,6 +153,29 @@ #include %} +%fragment("SWIG_isfinite","header",fragment=",") %{ +/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ +#ifndef SWIG_isfinite +# if defined(isfinite) +# define SWIG_isfinite(X) (isfinite(X)) +# elif defined(_MSC_VER) +# define SWIG_isfinite(X) (_finite(X)) +# elif defined(__sun) && defined(__SVR4) +# include +# define SWIG_isfinite(X) (finite(X)) +# endif +#endif +%} + +%fragment("SWIG_Float_Overflow_Check","header",fragment=",SWIG_isfinite") %{ +/* Accept infinite as a valid float value unless we are unable to check if a value is finite */ +#ifdef SWIG_isfinite +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) +#else +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) +#endif +%} + /* ----------------------------------------------------------------------------- * special macros for fragments * ----------------------------------------------------------------------------- */ @@ -213,13 +236,20 @@ SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val) %enddef -/* Macro for 'double' derived types */ +/* Macro for floating point derived types (original macro) */ %define %numeric_double(Type, Frag, Min, Max) %numeric_type_from(Type, double) %numeric_signed_type_asval(Type, double, Frag , Min, Max) %enddef +/* Macro for floating point derived types */ + +%define %numeric_float(Type, Frag, OverflowCond) +%numeric_type_from(Type, double) +%numeric_type_asval(Type, double, Frag, OverflowCond) +%enddef + /* Macros for missing fragments */ diff --git a/Lib/typemaps/implicit.swg b/Lib/typemaps/implicit.swg index 24bb3dcce..702fb52b8 100644 --- a/Lib/typemaps/implicit.swg +++ b/Lib/typemaps/implicit.swg @@ -1,5 +1,5 @@ /* - The %implict macro allows a SwigType (Class) to be accepted + The %implicit macro allows a SwigType (Class) to be accepted as an input parameter and use its implicit constructors when needed. For example: diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg index cc8a55e6e..45632c31f 100644 --- a/Lib/typemaps/primtypes.swg +++ b/Lib/typemaps/primtypes.swg @@ -139,7 +139,7 @@ SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val) /* float */ -%numeric_double(float, "", -FLT_MAX, FLT_MAX) +%numeric_float(float, "SWIG_Float_Overflow_Check", SWIG_Float_Overflow_Check(v)) /* long/unsigned long */ diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg index e95e7af92..c9b42facf 100644 --- a/Lib/typemaps/swigmacros.swg +++ b/Lib/typemaps/swigmacros.swg @@ -9,9 +9,9 @@ -------------------------- %arg(Arg) Safe argument wrap - %str(Arg) Stringtify the argument - %begin_block Begin a execution block - %end_block End a execution block + %str(Arg) Stringtify the argument + %begin_block Begin a execution block + %end_block End a execution block %block(Block) Execute Block as a excecution block %define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first %ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi @@ -19,33 +19,33 @@ Casting Operations: ------------------- - + SWIG provides the following casting macros, which implement the corresponding C++ casting operations: - %const_cast(a, Type) const_cast(a) - %static_cast(a, Type) static_cast(a) - %reinterpret_cast(a, Type) reinterpret_cast(a) - %numeric_cast(a, Type) static_cast(a) - %as_voidptr(a) const_cast(static_cast(a)) - %as_voidptrptr(a) reinterpret_cast(a) - + %const_cast(a, Type) const_cast(a) + %static_cast(a, Type) static_cast(a) + %reinterpret_cast(a, Type) reinterpret_cast(a) + %numeric_cast(a, Type) static_cast(a) + %as_voidptr(a) const_cast(static_cast(a)) + %as_voidptrptr(a) reinterpret_cast(a) + or their C unsafe versions. In C++ we use the safe version unless SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). Memory allocation: ------------------ - + These allocation/freeing macros are safe to use in C or C++ and dispatch the proper new/delete/delete[] or free/malloc calls as needed. - + %new_instance(Type) Allocate a new instance of given Type %new_copy(value,Type) Allocate and initialize a new instance with 'value' %new_array(size,Type) Allocate a new array with given size and Type %new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr' - %delete(cptr) Delete an instance + %delete(cptr) Delete an instance %delete_array(cptr) Delete an array @@ -54,13 +54,13 @@ %formacro(Macro, Args...) or %formacro_1(Macro, Args...) for i in Args - do + do Macro($i) done %formacro_2(Macro2, Args...) for i,j in Args - do + do Macro2($i, $j) done @@ -71,12 +71,12 @@ %mark_flag(flag) flag := True - %evalif(flag,expr) + %evalif(flag,expr) if flag; then expr fi - %evalif_2(flag1 flag2,expr) + %evalif_2(flag1 flag2,expr) if flag1 and flag2; then expr fi @@ -84,7 +84,7 @@ */ /* ----------------------------------------------------------------------------- - * Basic preprocessor macros + * Basic preprocessor macros * ----------------------------------------------------------------------------- */ #define %arg(Arg...) Arg @@ -115,7 +115,7 @@ nocppval %define_as(SWIGVERSION, SWIG_VERSION) %#define SWIG_VERSION SWIGVERSION } -#endif +#endif @@ -153,10 +153,10 @@ nocppval /* ----------------------------------------------------------------------------- - * Allocating/freeing elements + * Allocating/freeing elements * ----------------------------------------------------------------------------- */ -#if defined(__cplusplus) +#if defined(__cplusplus) # define %new_instance(Type...) (new Type) # define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&))) # define %new_array(size,Type...) (new Type[size]) @@ -184,7 +184,7 @@ nocppval /* ----------------------------------------------------------------------------- - * Auxiliary loop macros + * Auxiliary loop macros * ----------------------------------------------------------------------------- */ @@ -213,10 +213,10 @@ nocppval * SWIG flags * ----------------------------------------------------------------------------- */ -/* +/* mark a flag, ie, define a macro name but ignore it in - the interface. - + the interface. + the flag can be later used with %evalif */ @@ -224,16 +224,16 @@ nocppval /* - %evalif and %evalif_2 are use to evaluate or process + %evalif and %evalif_2 are use to evaluate or process an expression if the given predicate is 'true' (1). */ -%define %_evalif(_x,_expr) +%define %_evalif(_x,_expr) #if _x == 1 _expr #endif %enddef -%define %_evalif_2(_x,_y,_expr) +%define %_evalif_2(_x,_y,_expr) #if _x == 1 && _y == 1 _expr #endif diff --git a/Makefile.in b/Makefile.in index 377086231..9db1a7efc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -23,6 +23,7 @@ SOURCE = Source CCACHE = CCache DOCS = Doc/Manual HAVE_CXX11_COMPILER = @HAVE_CXX11_COMPILER@ +RUNPIPE = \>/dev/null swig: libfiles source ccache @@ -59,7 +60,6 @@ skip-tcl = test -n "@SKIP_TCL@" skip-perl5 = test -n "@SKIP_PERL5@" skip-python = test -n "@SKIP_PYTHON@" skip-java = test -n "@SKIP_JAVA@" -skip-guilescm = test -n "@SKIP_GUILESCM@" skip-guile = test -n "@SKIP_GUILE@" skip-mzscheme = test -n "@SKIP_MZSCHEME@" skip-ruby = test -n "@SKIP_RUBY@" @@ -124,6 +124,45 @@ check-aliveness: check-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check) +# Checks / displays versions of each target language +check-versions: \ + check-tcl-version \ + check-perl5-version \ + check-python-version \ + check-java-version \ + check-android-version \ + check-guile-version \ + check-mzscheme-version \ + check-ruby-version \ + check-ocaml-version \ + check-octave-version \ + check-php-version \ + check-pike-version \ + check-chicken-version \ + check-csharp-version \ + check-modula3-version \ + check-lua-version \ + check-allegrocl-version \ + check-clisp-version \ + check-uffi-version \ + check-cffi-version \ + check-r-version \ + check-go-version \ + check-d-version + +# all examples +check-%-version : + @if test -z "$(skip-$*)"; then \ + echo $* unknown; \ + exit 1; \ + fi + @if $(skip-$*); then \ + echo skipping $* version; \ + else \ + echo showing $* version; \ + (cd Examples && $(MAKE) -s $*_version) \ + fi + # Checks examples for compilation (does not run them) check-examples: \ check-tcl-examples \ @@ -191,7 +230,7 @@ check-%-examples : # individual example %.actionexample: @echo $(ACTION)ing Examples/$(LANGUAGE)/$* - @(cd Examples/$(LANGUAGE)/$* && $(MAKE) -s $(chk-set-env) $(ACTION)) + @(cd Examples/$(LANGUAGE)/$* && $(MAKE) -s $(chk-set-env) $(ACTION) RUNPIPE=$(RUNPIPE)) # gcj individual example java.actionexample: @@ -208,7 +247,6 @@ check-test-suite: \ check-perl5-test-suite \ check-python-test-suite \ check-java-test-suite \ - check-guilescm-test-suite \ check-guile-test-suite \ check-mzscheme-test-suite \ check-ruby-test-suite \ @@ -253,7 +291,7 @@ partialcheck-test-suite: partialcheck-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck NOSKIP=1 -check: check-aliveness check-ccache check-examples check-test-suite +check: check-aliveness check-ccache check-versions check-examples check-test-suite # Run known-to-be-broken as well as not broken testcases in the test-suite all-test-suite: \ @@ -261,7 +299,6 @@ all-test-suite: \ all-perl5-test-suite \ all-python-test-suite \ all-java-test-suite \ - all-guilescm-test-suite \ all-guile-test-suite \ all-mzscheme-test-suite \ all-ruby-test-suite \ @@ -290,7 +327,6 @@ broken-test-suite: \ broken-perl5-test-suite \ broken-python-test-suite \ broken-java-test-suite \ - broken-guilescm-test-suite \ broken-guile-test-suite \ broken-mzscheme-test-suite \ broken-ruby-test-suite \ @@ -397,12 +433,8 @@ maintainer-clean: $(srcdir)/Lib/swigwarn.swg: $(srcdir)/Source/Include/swigwarn.h mkdir -p Lib - echo "/* Automatically generated file containing all the swig warning codes. */" > $@ - echo "/* Do not modify this file by hand, change 'Source/Include/swigwarn.h' */" >> $@ - echo "/* and use the command 'make Lib/swigwarn.swg' instead. */" >> $@ - echo >> $@; echo >> $@ - awk '/#define WARN/{$$1="%define"; $$2="SWIG"$$2; $$3=sprintf("%d %%enddef", $$3); print $$0; next;}\ - /#/{next;} {print $0}' < $? >> $@ + echo "/* SWIG warning codes */" > $@ + cat $? | grep "^#define WARN\|/\*.*\*/\|^[ \t]*$$" | sed 's/^#define \(WARN.*[0-9][0-9]*\)\(.*\)$$/%define SWIG\1 %enddef\2/' >> $@ ##################################################################### # TARGETS: install & friends @@ -515,11 +547,11 @@ configfiles: Makefile: $(srcdir)/Makefile.in config.status $(SHELL) ./config.status -# This target is usually called from Source/Makefile when configure.in has +# This target is usually called from Source/Makefile when configure.ac has # changed. am--refresh: $(srcdir)/configure -$(srcdir)/configure: $(srcdir)/configure.in +$(srcdir)/configure: $(srcdir)/configure.ac @echo "Build system is out of date. If the following commands fail, please reconfigure by hand (rerun: ./autogen.sh && ./configure)" cd $(srcdir) && ./autogen.sh $(SHELL) ./config.status --recheck diff --git a/README b/README index d69e7c6d8..b6080a4fd 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.10 (in progress) +Version: 3.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, @@ -24,7 +24,11 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: License ======= -Please see the LICENSE file for details of the SWIG license. +Please see the LICENSE file for details of the SWIG license. For +further insight into the license including the license of SWIG's +output code, please visit + + http://www.swig.org/legal.html Release Notes ============= @@ -61,128 +65,17 @@ See the documentation for details of the SWIG_VERSION preprocessor symbol if you have backward compatibility issues and need to use more than one version of SWIG. -Windows Installation -==================== -Please see the Doc/Manual/Windows.html file for instructions on installing -SWIG on Windows and running the examples. The Windows distribution is -called swigwin and includes a prebuilt SWIG executable, swig.exe, included in -the same directory as this README file. Otherwise it is exactly the same as -the main SWIG distribution. There is no need to download anything else. - -Unix Installation -================= -You must use GNU `make' to build SWIG. - -http://www.gnu.org/software/make/ - -PCRE needs to be installed on your system to build SWIG, in particular -pcre-config must be available. If you have PCRE headers and libraries but not -pcre-config itself or, alternatively, wish to override the compiler or linker -flags returned by pcre-config, you may set PCRE_LIBS and PCRE_CFLAGS variables -to be used instead. And if you don't have PCRE at all, the configure script -will provide instructions for obtaining it. - -To build and install SWIG, simply type the following: - - % ./configure - % make - % make install - -By default SWIG installs itself in /usr/local. If you need to install SWIG in -a different location or in your home directory, use the --prefix option -to ./configure. For example: - - % ./configure --prefix=/home/yourname/projects - % make - % make install - -Note: the directory given to --prefix must be an absolute pathname. Do *NOT* use -the ~ shell-escape to refer to your home directory. SWIG won't work properly -if you do this. - -The file INSTALL details more about using configure. Also try - - % ./configure --help. - -The configure script will attempt to locate various packages on your machine -including Tcl, Perl5, Python and all the other target languages that SWIG -uses. Don't panic if you get 'not found' messages--SWIG does not need these -packages to compile or run. The configure script is actually looking for -these packages so that you can try out the SWIG examples contained -in the 'Examples' directory without having to hack Makefiles. -Note that the --without-xxx options, where xxx is a target language, have -minimal effect. All they do is reduce the amount of testing done with -'make check'. The SWIG executable and library files installed cannot currently -be configured with a subset of target languages. - -SWIG used to include a set of runtime libraries for some languages for working -with multiple modules. These are no longer built during the installation stage. -However, users can build them just like any wrapper module as described in -the documentation, Doc/Manual/Modules.html. The CHANGES file also lists some -examples which build the runtime library. - -Notes: - -(1) If you checked the code out via Git, you will have to run ./autogen.sh - before typing 'configure'. In addition, a full build of SWIG requires - the a number of packages to be installed. Full instructions at - http://www.swig.org/svn.html - -Macintosh OS X Installation -============================ -SWIG is known to work on various flavors of OS X. Follow the Unix installation -instructions above. However, as of this writing, there is still great deal of -inconsistency with how shared libaries are handled by various scripting languages -on OS X. We've tried to resolve these differences to the extent of our knowledge. - -Users of OS X should be aware that Darwin handles shared libraries and linking in -a radically different way than most Unix systems. In order to test SWIG and run -the examples, SWIG configures itself to use flat namespaces and to allow undefined -symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix -model and makes it more likely that the SWIG examples will work with whatever -installation of software you might have. However, this is generally not the recommended -technique for building larger extension modules. Instead, you should utilize -Darwin's two-level namespaces. Some details about this can be found here - -http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html - -Needless to say, you might have to experiment a bit to get things working at first. +Installation +============ +Please read the Doc/Manual/Preface.html#Preface_installation for +full installation instructions for Windows, Unix and Mac OS X. +The INSTALL file has generic build and installation instructions for +Unix users. Testing ======= -If you want to test SWIG before installation, type the following: - - % make -k check - -'make -k check' requires at least one of the target languages to be -installed. If it fails, it may mean that you have an uninstalled -language module or that the file 'Examples/Makefile' has been -incorrectly configured. It may also fail due to compiler issues such -as broken C++ compiler. Even if 'make -k check' fails, there is a -pretty good chance SWIG still works correctly---you will just have to -mess around with one of the examples and some makefiles to get it to work. -Some tests may also fail due to missing dependency packages, eg PCRE -or Boost, but this will require careful analysis of the configure output. - -The testing suite executed by 'make -k check' is designed to stress-test -many parts of the implementation including obscure corner cases. If some -of these tests fail or generate warning messages, there is no reason for -alarm---the test may be related to some new SWIG feature or a difficult bug -that we're trying to resolve. Chances are that SWIG will work just fine -for you. Note that if you have more than one CPU/core, then you can use -parallel make to speed up the check as it does take quite some time to run, -for example: - - % make -j2 -k check - -Also, SWIG's support for C++ is sufficiently advanced that certain -tests may fail on older C++ compilers (for instance if your compiler -does not support member templates). These errors are harmless if you -don't intend to use these features in your own programs. - -Note: The test-suite currently contains over 500 tests. If you -have many different target languages installed and a slow machine, it -might take more than an hour to run the test-suite. +The typical 'make -k check' can be performed on Unix operating systems. +Please read Doc/Manual/Preface.html#Preface_testing for details. Examples ======== @@ -204,7 +97,7 @@ Troubleshooting In order to operate correctly, SWIG relies upon a set of library files. If after building SWIG, you get error messages like this, - % swig foo.i + $ swig foo.i :1. Unable to find 'swig.swg' :3. Unable to find 'tcl8.swg' diff --git a/RELEASENOTES b/RELEASENOTES index af9f4fb6b..720dc9d34 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -4,6 +4,21 @@ and CHANGES files. Release Notes ============= +SWIG-2.0.11 summary: +- Minor bug fixes and enhancements mostly in Python, but also + C#, Lua, Ocaml, Octave, Perl, PHP, Python, R, Ruby, Tcl. + +SWIG-2.0.10 summary: +- Ruby 1.9 support is now complete. +- Add support for Guile 2.0 and Guile 1.6 support (GH interface) has + been dropped. +- Various small language neutral improvements and fixes. +- Various bug fixes and minor improvements specific to C#, CFFI, D, + Java, Octave, PHP, Python, +- Minor bug fix in ccache-swig. +- Development has moved to Github with Travis continuous integration + testing - patches using https://github.com/swig/swig are welcome. + SWIG-2.0.9 summary: - Improved typemap matching. - Ruby 1.9 support is much improved. diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index b6366d76d..ce0c91c43 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -43,6 +43,7 @@ static Node *top = 0; /* Top of the generated parse tree */ static int unnamed = 0; /* Unnamed datatype counter */ static Hash *extendhash = 0; /* Hash table of added methods */ static Hash *classes = 0; /* Hash table of classes */ +static Hash *classes_typedefs = 0; /* Hash table of typedef classes: typedef struct X {...} Y; */ static Symtab *prev_symtab = 0; static Node *current_class = 0; String *ModuleName = 0; @@ -723,7 +724,7 @@ static void check_extensions() { for (ki = First(extendhash); ki.key; ki = Next(ki)) { if (!Strchr(ki.key,'<')) { SWIG_WARN_NODE_BEGIN(ki.item); - Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", ki.key); + Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", SwigType_namestr(ki.key)); SWIG_WARN_NODE_END(ki.item); } } @@ -1163,8 +1164,6 @@ static Node *nested_forward_declaration(const char *storage, const char *kind, S if (sname) { /* Add forward declaration of the nested type */ Node *n = new_node("classforward"); - Setfile(n, cparse_file); - Setline(n, cparse_line); Setattr(n, "kind", kind); Setattr(n, "name", sname); Setattr(n, "storage", storage); @@ -1800,6 +1799,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %type featattr; %type lambda_introducer lambda_body; %type lambda_tail; +%type optional_constant_directive; %% @@ -1922,20 +1922,34 @@ extend_directive : EXTEND options idcolon LBRACE { String *clsname; cplus_mode = CPLUS_PUBLIC; if (!classes) classes = NewHash(); + if (!classes_typedefs) classes_typedefs = NewHash(); if (!extendhash) extendhash = NewHash(); clsname = make_class_name($3); cls = Getattr(classes,clsname); if (!cls) { - /* No previous definition. Create a new scope */ - Node *am = Getattr(extendhash,clsname); - if (!am) { - Swig_symbol_newscope(); - Swig_symbol_setscopename($3); - prev_symtab = 0; + cls = Getattr(classes_typedefs, clsname); + if (!cls) { + /* No previous definition. Create a new scope */ + Node *am = Getattr(extendhash,clsname); + if (!am) { + Swig_symbol_newscope(); + Swig_symbol_setscopename($3); + prev_symtab = 0; + } else { + prev_symtab = Swig_symbol_setscope(Getattr(am,"symtab")); + } + current_class = 0; } else { - prev_symtab = Swig_symbol_setscope(Getattr(am,"symtab")); + /* Previous typedef class definition. Use its symbol table. + Deprecated, just the real name should be used. + Note that %extend before the class typedef never worked, only %extend after the class typdef. */ + prev_symtab = Swig_symbol_setscope(Getattr(cls, "symtab")); + current_class = cls; + extendmode = 1; + SWIG_WARN_NODE_BEGIN(cls); + Swig_warning(WARN_PARSE_EXTEND_NAME, cparse_file, cparse_line, "Deprecated %%extend name used - the %s name '%s' should be used instead of the typedef name '%s'.\n", Getattr(cls, "kind"), SwigType_namestr(Getattr(cls, "name")), $3); + SWIG_WARN_NODE_END(cls); } - current_class = 0; } else { /* Previous class definition. Use its symbol table */ prev_symtab = Swig_symbol_setscope(Getattr(cls,"symtab")); @@ -3816,7 +3830,6 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { if (!classes) classes = NewHash(); scpname = Swig_symbol_qualifiedscopename(0); Setattr(classes,scpname,$$); - Delete(scpname); appendChild($$,$7); @@ -3837,7 +3850,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Setattr(p,"type",ty); p = nextSibling(p); } - /* Dump nested classes */ + /* Class typedefs */ { String *name = $3; if ($9) { @@ -3857,8 +3870,9 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Delete(class_rename); class_rename = NewString(name); } - if (!Getattr(classes,tdscopename)) { - Setattr(classes,tdscopename,$$); + if (!classes_typedefs) classes_typedefs = NewHash(); + if (!Equal(scpname, tdscopename) && !Getattr(classes_typedefs, tdscopename)) { + Setattr(classes_typedefs, tdscopename, $$); } Setattr($$,"decl",decltype); Delete(class_scope); @@ -3869,6 +3883,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { } appendChild($$,dump_nested(Char(name))); } + Delete(scpname); if (cplus_mode != CPLUS_PUBLIC) { /* we 'open' the class at the end, to allow %template @@ -4061,8 +4076,6 @@ cpp_forward_class_decl : storage_class cpptype idcolon SEMI { $$ = 0; } else { $$ = new_node("classforward"); - Setfile($$,cparse_file); - Setline($$,cparse_line); Setattr($$,"kind",$2); Setattr($$,"name",$3); Setattr($$,"sym:weak", "1"); @@ -6150,29 +6163,31 @@ definetype : { /* scanner_check_typedef(); */ } expr { /* Some stuff for handling enums */ ename : ID { $$ = $1; } - | empty { $$ = (char *) 0;} - ; + | empty { $$ = (char *) 0;} + ; -enumlist : enumlist COMMA edecl { +optional_constant_directive : constant_directive { $$ = $1; } + | empty { $$ = 0; } + ; - /* Ignore if there is a trailing comma in the enum list */ - if ($3) { - Node *leftSibling = Getattr($1,"_last"); - if (!leftSibling) { - leftSibling=$1; - } - set_nextSibling(leftSibling,$3); - Setattr($1,"_last",$3); - } - $$ = $1; - } - | edecl { - $$ = $1; - if ($1) { - Setattr($1,"_last",$1); - } - } - ; +/* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */ +enumlist : enumlist COMMA optional_constant_directive edecl optional_constant_directive { + Node *leftSibling = Getattr($1,"_last"); + set_nextSibling(leftSibling,$4); + Setattr($1,"_last",$4); + $$ = $1; + } + | enumlist COMMA optional_constant_directive { + $$ = $1; + } + | optional_constant_directive edecl optional_constant_directive { + Setattr($2,"_last",$2); + $$ = $2; + } + | optional_constant_directive { + $$ = 0; + } + ; edecl : ID { SwigType *type = NewSwigType(T_INT); @@ -6192,7 +6207,6 @@ edecl : ID { Setattr($$,"value",$1); Delete(type); } - | empty { $$ = 0; } ; etype : expr { diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index ed6acfc8c..48bdf4faa 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -317,14 +317,13 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab if (tp) { Symtab *tsdecl = Getattr(n, "sym:symtab"); while (p && tp) { - String *name, *value, *valuestr, *tydef, *tmp, *tmpr; + String *name, *value, *valuestr, *tmp, *tmpr; int sz, i; String *dvalue = 0; String *qvalue = 0; name = Getattr(tp, "name"); value = Getattr(p, "value"); - tydef = Getattr(p, "typedef"); if (name) { if (!value) @@ -365,9 +364,6 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab /* Printf(stdout,"'%s'\n", s); */ } - if (!tydef) { - tydef = dvalue; - } tmp = NewStringf("#%s", name); tmpr = NewStringf("\"%s\"", valuestr); @@ -375,7 +371,6 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab for (i = 0; i < sz; i++) { String *s = Getitem(cpatchlist, i); Replace(s, tmp, tmpr, DOH_REPLACE_ID); - /* Replace(s,name,tydef, DOH_REPLACE_ID); */ Replace(s, name, valuestr, DOH_REPLACE_ID); } Delete(tmp); diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c index 5693deeb5..d2a1bab19 100644 --- a/Source/DOH/fio.c +++ b/Source/DOH/fio.c @@ -21,7 +21,7 @@ static DOH *encodings = 0; /* Encoding hash */ /* ----------------------------------------------------------------------------- * Writen() * - * Write's N characters of output and retries until all characters are + * Writes N characters of output and retries until all characters are * written. This is useful should a write operation encounter a spurious signal. * ----------------------------------------------------------------------------- */ diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 218cc6f10..4856d9e44 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -89,6 +89,7 @@ #define WARN_PARSE_REC_INHERITANCE 323 #define WARN_PARSE_NESTED_TEMPLATE 324 #define WARN_PARSE_NAMED_NESTED_CLASS 325 +#define WARN_PARSE_EXTEND_NAME 326 #define WARN_CPP11_LAMBDA 340 #define WARN_CPP11_ALIAS_DECLARATION 341 @@ -202,6 +203,8 @@ #define WARN_LANG_TEMPLATE_METHOD_IGNORE 519 #define WARN_LANG_SMARTPTR_MISSING 520 #define WARN_LANG_ILLEGAL_DESTRUCTOR 521 +#define WARN_LANG_EXTEND_CONSTRUCTOR 522 +#define WARN_LANG_EXTEND_DESTRUCTOR 523 /* -- Reserved (600-799) -- */ diff --git a/Source/Makefile.am b/Source/Makefile.am index 984b9c268..40fa4d9f2 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -140,8 +140,6 @@ beautify-file: test -n "$(INDENTFILE)" || (echo INDENTFILE not defined && exit 1;) test -e $(INDENTFILE) || (echo File does not exist: $(INDENTFILE) && exit 1;) cp $(INDENTFILE) $(INDENTBAKSDIR)/$(INDENTFILE); - unix2dos $(INDENTFILE) - dos2unix $(INDENTFILE) indent -kr --honour-newlines --line-length160 --indent-level2 --braces-on-func-def-line --leave-optional-blank-lines $(SWIGTYPEDEFS) $(INDENTFILE) -o $(INDENTFILE).tmp; cat $(INDENTFILE).tmp | sed -e 's/const const /const /' > $(INDENTFILE); rm $(INDENTFILE).tmp; diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 0d15a9c1d..d30f278fc 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -630,23 +630,14 @@ public: *----------------------------------------------------------------------*/ UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name) { - UpcallData *udata; - String *class_methodidx; - Hash *new_udata; String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; - /* Do we know about this director class already? */ - if ((udata = Getattr(dmethods_table, key))) { - Delete(key); - return Getattr(udata, "methodoff"); - } - - class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); + String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; - new_udata = NewHash(); + Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); @@ -3391,6 +3382,7 @@ public: String *qualified_classname = Copy(sym_name); String *nspace = getNSpace(); String *dirClassName = directorClassName(n); + String *smartptr = Getattr(n, "feature:smartptr"); if (nspace) Insert(qualified_classname, 0, NewStringf("%s.", nspace)); @@ -3401,8 +3393,17 @@ public: Wrapper *code_wrap = NewWrapper(); Printf(code_wrap->def, "SWIGEXPORT void SWIGSTDCALL %s(void *objarg", wname); - Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); - Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); + if (Len(smartptr)) { + Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", smartptr, smartptr); + Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); + Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); + Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); + } + else { + Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); + Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); + } + // TODO: if statement not needed?? - Java too Printf(code_wrap->code, " if (director) {\n"); Printf(code_wrap->code, " director->swig_connect_director("); @@ -3670,7 +3671,7 @@ public: Replaceall(pre, "$iminput", ln); if (Len(pre_code) > 0) Printf(pre_code, "\n"); - Printv(pre_code, pre, NIL); + Printv(pre_code, pre, NIL); } String *post = Getattr(p, "tmap:csdirectorin:post"); if (post) { @@ -4027,7 +4028,7 @@ public: Delete(director_ctor_code); director_ctor_code = NewString("$director_new"); - Java_director_declaration(n); + directorDeclaration(n); Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl")); Printf(f_directors_h, "\npublic:\n"); @@ -4147,13 +4148,13 @@ public: } /*---------------------------------------------------------------------- - * Java_director_declaration() + * directorDeclaration() * * Generate the director class's declaration * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" *--------------------------------------------------------------------*/ - void Java_director_declaration(Node *n) { + void directorDeclaration(Node *n) { String *base = Getattr(n, "classtype"); String *class_ctor = NewString("Swig::Director()"); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 88c3ccfff..5d59a2e38 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3704,23 +3704,14 @@ private: UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *decl, String *overloaded_name, String *return_type, String *param_list) { - UpcallData *udata; - String *class_methodidx; - Hash *new_udata; String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; - /* Do we know about this director class already? */ - if ((udata = Getattr(dmethods_table, key))) { - Delete(key); - return Getattr(udata, "methodoff"); - } - - class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); + String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; - new_udata = NewHash(); + Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); @@ -3752,7 +3743,7 @@ private: String *nspace = getNSpace(); if (nspace) { // Check the root package/outermost namespace (a class A in module - // A.B leads to problems if another module A.C is also imported)… + // A.B leads to problems if another module A.C is also imported) if (Len(package) > 0) { String *dotless_package = NewStringWithSize(package, Len(package) - 1); if (Cmp(class_name, dotless_package) == 0) { diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 211b11baf..e0a084583 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -23,7 +23,6 @@ Guile Options (available with -guile)\n\ -emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\ -exportprimitive - Add the (export ...) code from scmstub into the\n\ GOOPS file.\n\ - -gh - Use the gh_ Guile API. (Guile <= 1.8) \n\ -goopsprefix - Prepend to all goops identifiers\n\ -linkage - Use linkage protocol (default `simple')\n\ Use `module' for native Guile module linking\n\ @@ -44,7 +43,6 @@ Guile Options (available with -guile)\n\ -proxy - Export GOOPS class definitions\n\ -primsuffix - Name appended to primitive module when exporting\n\ GOOPS classes. (default = \"primitive\")\n\ - -scm - Use the scm Guile API. (Guile >= 1.6, default) \n\ -scmstub - Output Scheme file with module declaration and\n\ exports; only with `passive' and `simple' linkage\n\ -useclassprefix - Prepend the class name to all goops identifiers\n\ @@ -94,7 +92,6 @@ static String *return_multi_doc = 0; static String *exported_symbols = 0; -static int use_scm_interface = 1; static int exporting_destructor = 0; static String *swigtype_ptr = 0; @@ -216,10 +213,10 @@ public: goops = true; Swig_mark_arg(i); } else if (strcmp(argv[i], "-gh") == 0) { - use_scm_interface = 0; + Printf(stderr, "Deprecated command line option: -gh. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-scm") == 0) { - use_scm_interface = 1; + Printf(stderr, "Deprecated command line option: -scm. Wrappers are always generated for the SCM interface. See documentation for more information regarding the deprecated GH interface.\n"); Swig_mark_arg(i); } else if (strcmp(argv[i], "-primsuffix") == 0) { if (argv[i + 1]) { @@ -285,10 +282,7 @@ public: /* Add a symbol for this module */ Preprocessor_define("SWIGGUILE 1", 0); /* Read in default typemaps */ - if (use_scm_interface) - SWIG_config_file("guile_scm.swg"); - else - SWIG_config_file("guile_gh.swg"); + SWIG_config_file("guile_scm.swg"); allow_overloading(); } @@ -331,13 +325,6 @@ public: Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGGUILE\n"); - if (!use_scm_interface) { - if (SwigRuntime == 1) - Printf(f_runtime, "#define SWIG_GLOBAL\n"); - if (SwigRuntime == 2) - Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); - } - /* Write out directives and declarations */ module = Swig_copy_string(Char(Getattr(n, "name"))); @@ -851,7 +838,7 @@ public: } } - if (use_scm_interface && exporting_destructor) { + if (exporting_destructor) { /* Mark the destructor's argument as destroyed. */ String *tm = NewString("SWIG_Guile_MarkPointerDestroyed($input);"); Replaceall(tm, "$input", Getattr(l, "emit:input")); @@ -868,14 +855,8 @@ public: Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); // Now write code to make the function call - if (!use_scm_interface) - Printv(f->code, tab4, "gh_defer_ints();\n", NIL); - String *actioncode = emit_action(n); - if (!use_scm_interface) - Printv(actioncode, tab4, "gh_allow_ints();\n", NIL); - // Now have return value, figure out what to do with it. if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { Replaceall(tm, "$result", "gswig_result"); @@ -958,11 +939,7 @@ public: Printv(f_wrappers, ");\n", NIL); Printv(f_wrappers, "}\n", NIL); /* Register it */ - if (use_scm_interface) { - Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname); - } else { - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s_rest, 0, 0, 1);\n", proc_name, wname); - } + Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname); } else if (emit_setters && struct_member && strlen(Char(proc_name)) > 3) { int len = Len(proc_name); const char *pc = Char(proc_name); @@ -973,19 +950,13 @@ public: struct_member = 2; /* have a setter */ } else Printf(f_init, "SCM getter = "); - if (use_scm_interface) { - /* GOOPS support uses the MEMBER-set and MEMBER-get functions, - so ignore only_setters in this case. */ - if (only_setters && !goops) - Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - else - Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - } else { - if (only_setters && !goops) - Printf(f_init, "scm_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - else - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq); - } + /* GOOPS support uses the MEMBER-set and MEMBER-get functions, + so ignore only_setters in this case. */ + if (only_setters && !goops) + Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); + else + Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); + if (!is_setter) { /* Strip off "-get" */ char *pws_name = (char *) malloc(sizeof(char) * (len - 3)); @@ -993,19 +964,11 @@ public: pws_name[len - 4] = 0; if (struct_member == 2) { /* There was a setter, so create a procedure with setter */ - if (use_scm_interface) { - Printf(f_init, "scm_c_define"); - } else { - Printf(f_init, "gh_define"); - } + Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(getter, setter));\n", pws_name); } else { /* There was no setter, so make an alias to the getter */ - if (use_scm_interface) { - Printf(f_init, "scm_c_define"); - } else { - Printf(f_init, "gh_define"); - } + Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", getter);\n", pws_name); } Printf(exported_symbols, "\"%s\", ", pws_name); @@ -1013,15 +976,11 @@ public: } } else { /* Register the function */ - if (use_scm_interface) { - if (exporting_destructor) { - Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname); - //Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname); - } - Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); - } else { - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq); + if (exporting_destructor) { + Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname); + //Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname); } + Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname); } } else { /* overloaded function; don't export the single methods */ if (!Getattr(n, "sym:nextSibling")) { @@ -1044,11 +1003,7 @@ public: Printf(df->code, "#undef FUNC_NAME\n"); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); - if (use_scm_interface) { - Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname); - } else { - Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 0, 1);\n", proc_name, dname); - } + Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname); DelWrapper(df); Delete(dispatch); Delete(dname); @@ -1221,36 +1176,27 @@ public: /* Read-only variables become a simple procedure returning the value; read-write variables become a simple procedure with an optional argument. */ - if (use_scm_interface) { - if (!goops && GetFlag(n, "feature:constasvar")) { - /* need to export this function as a variable instead of a procedure */ - if (scmstub) { - /* export the function in the wrapper, and (set!) it in scmstub */ - Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); - Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name); - } else { - /* export the variable directly */ - Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name); - } - - } else { - /* Export the function as normal */ + if (!goops && GetFlag(n, "feature:constasvar")) { + /* need to export this function as a variable instead of a procedure */ + if (scmstub) { + /* export the function in the wrapper, and (set!) it in scmstub */ Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); + Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name); + } else { + /* export the variable directly */ + Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name); } } else { - Printf(f_init, "\t gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, %d, 0);\n", proc_name, var_name, !GetFlag(n, "feature:immutable")); + /* Export the function as normal */ + Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name); } + } else { /* Read/write variables become a procedure with setter. */ - if (use_scm_interface) { - Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name); - Printf(f_init, "scm_c_define"); - } else { - Printf(f_init, "\t{ SCM p = gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 1, 0);\n", proc_name, var_name); - Printf(f_init, "gh_define"); - } + Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name); + Printf(f_init, "scm_c_define"); Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(p, p)); }\n", proc_name); } Printf(exported_symbols, "\"%s\", ", proc_name); @@ -1484,12 +1430,10 @@ public: String *mangled_classname = Swig_name_mangle(Getattr(n, "sym:name")); /* Export clientdata structure */ - if (use_scm_interface) { - Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname); + Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname); - Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL); - SwigType_remember(ct); - } + Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL); + SwigType_remember(ct); Delete(ct); /* Emit all of the members */ @@ -1725,28 +1669,16 @@ public: String *runtimeCode() { String *s; - if (use_scm_interface) { - s = Swig_include_sys("guile_scm_run.swg"); - if (!s) { - Printf(stderr, "*** Unable to open 'guile_scm_run.swg"); - s = NewString(""); - } - } else { - s = Swig_include_sys("guile_gh_run.swg"); - if (!s) { - Printf(stderr, "*** Unable to open 'guile_gh_run.swg"); - s = NewString(""); - } + s = Swig_include_sys("guile_scm_run.swg"); + if (!s) { + Printf(stderr, "*** Unable to open 'guile_scm_run.swg"); + s = NewString(""); } return s; } String *defaultExternalRuntimeFilename() { - if (use_scm_interface) { - return NewString("swigguilerun.h"); - } else { - return NewString("swigguileghrun.h"); - } + return NewString("swigguilerun.h"); } }; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 987b6ddf6..24435ac30 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -138,6 +138,7 @@ public: imclass_imports(NULL), module_imports(NULL), imclass_baseclass(NULL), + imclass_package(NULL), module_baseclass(NULL), imclass_interfaces(NULL), module_interfaces(NULL), @@ -741,25 +742,15 @@ public: *----------------------------------------------------------------------*/ UpcallData *addUpcallMethod(String *imclass_method, String *class_method, String *imclass_desc, String *class_desc, String *decl) { - UpcallData *udata; - String *imclass_methodidx; - String *class_methodidx; - Hash *new_udata; String *key = NewStringf("%s|%s", imclass_method, decl); ++curr_class_dmethod; - /* Do we know about this director class already? */ - if ((udata = Getattr(dmethods_table, key))) { - Delete(key); - return Getattr(udata, "methodoff"); - } - - imclass_methodidx = NewStringf("%d", n_dmethods); - class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); + String *imclass_methodidx = NewStringf("%d", n_dmethods); + String *class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod); n_dmethods++; - new_udata = NewHash(); + Hash *new_udata = NewHash(); Append(dmethods_seq, new_udata); Setattr(dmethods_table, key, new_udata); @@ -3399,7 +3390,7 @@ public: String *norm_name = SwigType_namestr(Getattr(n, "name")); String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect"); String *swig_director_connect_jni = makeValidJniName(swig_director_connect); - String *smartptr_feature = Getattr(n, "feature:smartptr"); + String *smartptr = Getattr(n, "feature:smartptr"); String *dirClassName = directorClassName(n); Wrapper *code_wrap; @@ -3411,15 +3402,11 @@ public: "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, " "jboolean jweak_global) {\n", jnipackage, jni_imclass_name, swig_director_connect_jni); - if (Len(smartptr_feature)) { - Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr_feature, smartptr_feature); + if (Len(smartptr)) { + Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr, smartptr); Printf(code_wrap->code, " (void)jcls;\n"); - Printf(code_wrap->code, " // NOTE: Pulling the raw pointer out of the smart pointer as the following code does\n"); - Printf(code_wrap->code, " // is generally a bad idea. However, in this case we keep a local instance of the\n"); - Printf(code_wrap->code, " // smart pointer around while we are using the raw pointer, which should keep the\n"); - Printf(code_wrap->code, " // raw pointer alive. This is done instead of using the smart pointer's dynamic cast\n"); - Printf(code_wrap->code, " // feature since different smart pointer implementations have differently named dynamic\n"); - Printf(code_wrap->code, " // cast mechanisms.\n"); + Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); + Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); } else { @@ -3527,7 +3514,7 @@ public: String *pkg_path = Swig_typemap_lookup("javapackage", p, "", 0); SwigType *type = Getattr(p, "type"); - if (pkg_path || Len(pkg_path) == 0) + if (!pkg_path || Len(pkg_path) == 0) pkg_path = package_path; String *descriptor_out = Copy(descriptor_in); @@ -4234,7 +4221,7 @@ public: Delete(director_ctor_code); director_ctor_code = NewString("$director_new"); - Java_director_declaration(n); + directorDeclaration(n); Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl")); Printf(f_directors_h, "\npublic:\n"); @@ -4418,13 +4405,13 @@ public: } /*---------------------------------------------------------------------- - * Java_director_declaration() + * directorDeclaration() * * Generate the director class's declaration * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" *--------------------------------------------------------------------*/ - void Java_director_declaration(Node *n) { + void directorDeclaration(Node *n) { String *base = Getattr(n, "classtype"); String *class_ctor = NewString("Swig::Director(jenv)"); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 6c2ea8271..e50a50a6d 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -88,7 +88,6 @@ extern int AddExtern; * ---------------------------------------------------------------------- */ int Dispatcher::emit_one(Node *n) { - String *wrn; int ret = SWIG_OK; char *tag = Char(nodeType(n)); @@ -104,10 +103,9 @@ int Dispatcher::emit_one(Node *n) { return SWIG_OK; /* Look for warnings */ - wrn = Getattr(n, "feature:warnfilter"); - if (wrn) { + String *wrn = Getattr(n, "feature:warnfilter"); + if (wrn) Swig_warnfilter(wrn, 1); - } /* ============================================================ * C/C++ parsing @@ -183,9 +181,8 @@ int Dispatcher::emit_one(Node *n) { Swig_error(input_file, line_number, "Unrecognized parse tree node type '%s'\n", tag); ret = SWIG_ERROR; } - if (wrn) { + if (wrn) Swig_warnfilter(wrn, 0); - } return ret; } @@ -475,9 +472,9 @@ void swig_pragma(char *lang, char *name, char *value) { } /* -------------------------------------------------------------------------- - * use_naturalvar_mode() + * Language::use_naturalvar_mode() * -------------------------------------------------------------------------- */ -int use_naturalvar_mode(Node *n) { +int Language::use_naturalvar_mode(Node *n) const { if (Getattr(n, "unnamed")) return 0; int nvar = naturalvar_mode || GetFlag(n, "feature:naturalvar"); @@ -486,12 +483,16 @@ int use_naturalvar_mode(Node *n) { SwigType *ty = Getattr(n, "type"); SwigType *fullty = SwigType_typedef_resolve_all(ty); if (SwigType_isclass(fullty)) { - Node *m = Copy(n); SwigType *tys = SwigType_strip_qualifiers(fullty); - Swig_features_get(Swig_cparse_features(), 0, tys, 0, m); - nvar = GetFlag(m, "feature:naturalvar"); + if (!CPlusPlus) { + Replaceall(tys, "struct ", ""); + Replaceall(tys, "union ", ""); + Replaceall(tys, "class ", ""); + } + Node *typenode = Swig_symbol_clookup(tys, 0); + if (typenode) + nvar = GetFlag(typenode, "feature:naturalvar"); Delete(tys); - Delete(m); } Delete(fullty); } @@ -1448,6 +1449,7 @@ int Language::membervariableHandler(Node *n) { tm = Swig_typemap_lookup("memberin", nin, target, 0); Delete(nin); } + int flags = Extend | SmartPointer | use_naturalvar_mode(n); if (isNonVirtualProtectedAccess(n)) flags = flags | CWRAP_ALL_PROTECTED_ACCESS; @@ -1999,6 +2001,9 @@ int Language::classDirectorConstructors(Node *n) { for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { nodeType = Getattr(ni, "nodeType"); if (Cmp(nodeType, "constructor") == 0) { + if (GetFlag(ni, "feature:ignore")) + continue; + Parm *parms = Getattr(ni, "parms"); if (is_public(ni)) { /* emit public constructor */ @@ -2064,6 +2069,10 @@ int Language::classDirectorMethods(Node *n) { if (GetFlag(method, "feature:nodirector")) continue; + String *wrn = Getattr(method, "feature:warnfilter"); + if (wrn) + Swig_warnfilter(wrn, 1); + String *type = Getattr(method, "nodeType"); if (!Cmp(type, "destructor")) { classDirectorDestructor(method); @@ -2075,6 +2084,8 @@ int Language::classDirectorMethods(Node *n) { SetFlag(item, "director"); Swig_restore(method); } + if (wrn) + Swig_warnfilter(wrn, 0); } return SWIG_OK; @@ -2511,7 +2522,7 @@ int Language::classHandler(Node *n) { Setattr(m, "parentNode", n); /* * There is a bug that needs fixing still... - * This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base) + * This area of code is creating methods which have not been overridden in a derived class (director methods that are protected in the base) * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method * See director_protected_overloaded.i - Possibly sym:overname needs correcting here. Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms"))); @@ -2632,10 +2643,22 @@ int Language::constructorDeclaration(Node *n) { if (!Equal(actual_name, expected_name) && !(Getattr(n, "template"))) { bool illegal_name = true; if (Extend) { - // SWIG extension - allow typedef names as destructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'destructor'. + // Check for typedef names used as a constructor name in %extend. This is deprecated except for anonymous + // typedef structs which have had their symbol names adjusted to the typedef name in the parser. SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name); SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); + + if (!CPlusPlus) { + if (Strncmp(name_resolved, "struct ", 7) == 0) + Replace(name_resolved, "struct ", "", DOH_REPLACE_FIRST); + else if (Strncmp(name_resolved, "union ", 6) == 0) + Replace(name_resolved, "union ", "", DOH_REPLACE_FIRST); + } + illegal_name = !Equal(name_resolved, expected_name_resolved); + if (!illegal_name) + Swig_warning(WARN_LANG_EXTEND_CONSTRUCTOR, input_file, line_number, "Use of an illegal constructor name '%s' in %%extend is deprecated, the constructor name should be '%s'.\n", + SwigType_str(Swig_scopename_last(actual_name), 0), SwigType_str(Swig_scopename_last(expected_name), 0)); Delete(name_resolved); Delete(expected_name_resolved); } @@ -2771,10 +2794,22 @@ int Language::destructorDeclaration(Node *n) { if (!Equal(actual_name, expected_name) && !(Getattr(n, "template"))) { bool illegal_name = true; if (Extend) { - // SWIG extension - allow typedef names as destructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'destructor'. + // Check for typedef names used as a destructor name in %extend. This is deprecated except for anonymous + // typedef structs which have had their symbol names adjusted to the typedef name in the parser. SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name); SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name); + + if (!CPlusPlus) { + if (Strncmp(name_resolved, "struct ", 7) == 0) + Replace(name_resolved, "struct ", "", DOH_REPLACE_FIRST); + else if (Strncmp(name_resolved, "union ", 6) == 0) + Replace(name_resolved, "union ", "", DOH_REPLACE_FIRST); + } + illegal_name = !Equal(name_resolved, expected_name_resolved); + if (!illegal_name) + Swig_warning(WARN_LANG_EXTEND_DESTRUCTOR, input_file, line_number, "Use of an illegal destructor name '%s' in %%extend is deprecated, the destructor name should be '%s'.\n", + SwigType_str(Swig_scopename_last(actual_name), 0), SwigType_str(Swig_scopename_last(expected_name), 0)); Delete(name_resolved); Delete(expected_name_resolved); } @@ -3065,7 +3100,7 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) { * Tries to locate a class from a type definition * ----------------------------------------------------------------------------- */ -Node *Language::classLookup(const SwigType *s) { +Node *Language::classLookup(const SwigType *s) const { Node *n = 0; /* Look in hash of cached values */ diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index cfb3a3f5b..b76945b95 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -45,6 +45,7 @@ */ #include "swigmod.h" +#include "cparse.h" /**** Diagnostics: With the #define REPORT(), you can change the amount of diagnostics given @@ -106,12 +107,14 @@ private: File *f_wrappers; File *f_init; File *f_initbeforefunc; - String *PrefixPlusUnderscore; String *s_cmd_tab; // table of command names String *s_var_tab; // table of global variables String *s_const_tab; // table of global constants String *s_methods_tab; // table of class methods String *s_attr_tab; // table of class attributes + String *s_cls_attr_tab; // table of class static attributes + String *s_cls_methods_tab; // table of class static methods + String *s_cls_const_tab; // tables of class constants(including enums) String *s_luacode; // luacode to be called during init String *s_dot_get; // table of variable 'get' functions String *s_dot_set; // table of variable 'set' functions @@ -150,12 +153,14 @@ public: f_wrappers(0), f_init(0), f_initbeforefunc(0), - PrefixPlusUnderscore(0), s_cmd_tab(0), s_var_tab(0), s_const_tab(0), s_methods_tab(0), s_attr_tab(0), + s_cls_attr_tab(0), + s_cls_methods_tab(0), + s_cls_const_tab(0), s_luacode(0), s_dot_get(0), s_dot_set(0), @@ -738,13 +743,18 @@ public: NEW LANGUAGE NOTE:END ************************************************/ /* Now register the function with the interpreter. */ if (!Getattr(n, "sym:overloaded")) { + //REPORT("dispatchFunction", n); // add_method(n, iname, wname, description); if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns + String *wrapname = Swig_name_wrapper(iname); if(elua_ltr || eluac_ltr) Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL); else Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL); // Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL); + if (getCurrentClass()) { + Setattr(n,"luaclassobj:wrap:name", wrapname); + } } } else { if (!Getattr(n, "sym:nextSibling")) { @@ -777,6 +787,7 @@ public: look for %typecheck(SWIG_TYPECHECK_*) in the .swg file NEW LANGUAGE NOTE:END ************************************************/ void dispatchFunction(Node *n) { + //REPORT("dispatchFunction", n); /* Last node in overloaded chain */ int maxargs; @@ -813,7 +824,7 @@ public: Printf(protoTypes, "\n\" %s\\n\"", fulldecl); Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); - Printf(f->code, "lua_pushstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n" + Printf(f->code, "SWIG_Lua_pusherrstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n" "\" Possible C/C++ prototypes are:\\n\"%s);\n",symname,protoTypes); Delete(protoTypes); @@ -824,10 +835,14 @@ public: if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wname, "},\n", NIL); + if (getCurrentClass()) + Setattr(n,"luaclassobj:wrap:name", wname); + else + Delete(wname); + DelWrapper(f); Delete(dispatch); Delete(tmp); - Delete(wname); } @@ -880,8 +895,13 @@ public: } else { Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName); } - Delete(getName); - Delete(setName); + if (getCurrentClass()) { + Setattr(n, "luaclassobj:wrap:get", getName); + Setattr(n, "luaclassobj:wrap:set", setName); + } else { + Delete(getName); + Delete(setName); + } return result; } @@ -889,7 +909,7 @@ public: * constantWrapper() * ------------------------------------------------------------ */ virtual int constantWrapper(Node *n) { - // REPORT("constantWrapper", n); + REPORT("constantWrapper", n); String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); String *nsname = Copy(iname); @@ -925,6 +945,20 @@ public: Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n"); return SWIG_NOWRAP; } + if (cparse_cplusplus && getCurrentClass()) { + // Additionally add to class constants + Swig_require("luaclassobj_constantWrapper", n, "*sym:name", "luaclassobj:symname", NIL); + Setattr(n, "sym:name", Getattr(n, "luaclassobj:symname")); + String *cls_nsname = Getattr(n, "sym:name"); + if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { + Replaceall(tm, "$source", value); + Replaceall(tm, "$target", name); + Replaceall(tm, "$value", value); + Replaceall(tm, "$nsname", cls_nsname); + Printf(s_cls_const_tab, " %s,\n", tm); + } + Swig_restore(n); + } Delete(nsname); return SWIG_OK; } @@ -1011,6 +1045,19 @@ public: Printf(s_methods_tab, "static swig_lua_method swig_"); Printv(s_methods_tab, mangled_classname, "_methods[] = {\n", NIL); + s_cls_methods_tab = NewString(""); + Printf(s_cls_methods_tab, "static swig_lua_method swig_"); + Printv(s_cls_methods_tab, mangled_classname, "_cls_methods[] = {\n", NIL); + + s_cls_attr_tab = NewString(""); + Printf(s_cls_attr_tab, "static swig_lua_attribute swig_"); + Printv(s_cls_attr_tab, mangled_classname, "_cls_attributes[] = {\n", NIL); + + s_cls_const_tab = NewString(""); + Printf(s_cls_const_tab, "static swig_lua_const_info swig_"); + Printv(s_cls_const_tab, mangled_classname, "_cls_constants[] = {\n", NIL); + + // Generate normal wrappers Language::classHandler(n); @@ -1049,8 +1096,21 @@ public: Printf(s_attr_tab, " {0,0,0}\n};\n"); Printv(f_wrappers, s_attr_tab, NIL); + Printf(s_cls_attr_tab, " {0,0,0}\n};\n"); + Printv(f_wrappers, s_cls_attr_tab, NIL); + + Printf(s_cls_methods_tab, " {0,0}\n};\n"); + Printv(f_wrappers, s_cls_methods_tab, NIL); + + Printf(s_cls_const_tab, " {0,0,0,0,0,0}\n};\n"); + Printv(f_wrappers, s_cls_const_tab, NIL); + + Delete(s_methods_tab); Delete(s_attr_tab); + Delete(s_cls_methods_tab); + Delete(s_cls_attr_tab); + Delete(s_cls_const_tab); // Handle inheritance // note: with the idea of class hierarchies spread over multiple modules @@ -1124,7 +1184,10 @@ public: } else { Printf(f_wrappers, ",0"); } - Printf(f_wrappers, ", swig_%s_methods, swig_%s_attributes, swig_%s_bases, swig_%s_base_names };\n\n", mangled_classname, mangled_classname, mangled_classname, mangled_classname); + Printf(f_wrappers, ", swig_%s_methods, swig_%s_attributes, { \"%s\", swig_%s_cls_methods, swig_%s_cls_attributes, swig_%s_cls_constants }, swig_%s_bases, swig_%s_base_names };\n\n", + mangled_classname, mangled_classname, + class_name, mangled_classname, mangled_classname, mangled_classname, + mangled_classname, mangled_classname); // Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases };\n\n", NIL); // Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL); @@ -1234,8 +1297,30 @@ public: * ---------------------------------------------------------------------- */ virtual int staticmemberfunctionHandler(Node *n) { + REPORT("staticmemberfunctionHandler", n); current = STATIC_FUNC; - return Language::staticmemberfunctionHandler(n); + String *symname = Getattr(n, "sym:name"); + int result = Language::staticmemberfunctionHandler(n); + + if (cparse_cplusplus && getCurrentClass()) { + Swig_restore(n); + } + current = NO_CPP; + if (result != SWIG_OK) + return result; + + if (Getattr(n, "sym:nextSibling")) + return SWIG_OK; + + Swig_require("luaclassobj_staticmemberfunctionHandler", n, "luaclassobj:wrap:name", NIL); + String *name = Getattr(n, "name"); + String *rname, *realname; + realname = symname ? symname : name; + rname = Getattr(n, "luaclassobj:wrap:name"); + Printv(s_cls_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL); + Swig_restore(n); + + return SWIG_OK; } /* ------------------------------------------------------------ @@ -1245,8 +1330,17 @@ public: * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { - // REPORT("memberconstantHandler",n); - return Language::memberconstantHandler(n); + REPORT("memberconstantHandler",n); + String *symname = Getattr(n, "sym:name"); + if (cparse_cplusplus && getCurrentClass()) { + Swig_save("luaclassobj_memberconstantHandler", n, "luaclassobj:symname", NIL); + Setattr(n, "luaclassobj:symname", symname); + } + int result = Language::memberconstantHandler(n); + if (cparse_cplusplus && getCurrentClass()) + Swig_restore(n); + + return result; } /* --------------------------------------------------------------------- @@ -1254,9 +1348,22 @@ public: * --------------------------------------------------------------------- */ virtual int staticmembervariableHandler(Node *n) { - // REPORT("staticmembervariableHandler",n); + REPORT("staticmembervariableHandler",n); current = STATIC_VAR; - return Language::staticmembervariableHandler(n); + String *symname = Getattr(n, "sym:name"); + int result = Language::staticmembervariableHandler(n); + + if (result != SWIG_OK) + return result; + + + if (Getattr(n, "wrappedasconstant")) + return SWIG_OK; + + Swig_require("luaclassobj_staticmembervariableHandler", n, "luaclassobj:wrap:get", "luaclassobj:wrap:set", NIL); + Printf(s_cls_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,Getattr(n,"luaclassobj:wrap:get"), Getattr(n,"luaclassobj:wrap:set")); + Swig_restore(n); + return SWIG_OK; } /* --------------------------------------------------------------------- diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index d1f3ab274..4076b9206 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -107,6 +107,7 @@ static const char *usage2 = (const char *) "\ -MM - List dependencies, but omit files in SWIG library\n\ -MMD - Like `-MD', but omit files in SWIG library\n\ -module - Set module name to \n\ + -MP - Generate phony targets for all dependencies\n\ -MT - Set the target of the rule emitted by dependency generation\n\ -nocontract - Turn off contract checking\n\ -nocpperraswarn - Do not treat the preprocessor #error statement as #warning\n\ @@ -185,6 +186,7 @@ static int dump_classes = 0; static int werror = 0; static int depend = 0; static int depend_only = 0; +static int depend_phony = 0; static int memory_debug = 0; static int allkw = 0; static DOH *cpps = 0; @@ -712,6 +714,9 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-MMD") == 0) { depend = 2; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-MP") == 0) { + depend_phony = 1; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-MT") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { @@ -1101,22 +1106,33 @@ int SWIG_main(int argc, char *argv[], Language *l) { Printf(f_dependencies_file, "%s: ", outfile); } List *files = Preprocessor_depend(); + List *phony_targets = NewList(); for (int i = 0; i < Len(files); i++) { int use_file = 1; if (depend == 2) { if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0))) use_file = 0; } - if (use_file) - Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); + if (use_file) { + Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); + if (depend_phony) + Append(phony_targets, Getitem(files, i)); + } } Printf(f_dependencies_file, "\n"); + if (depend_phony) { + for (int i = 0; i < Len(phony_targets); i++) { + Printf(f_dependencies_file, "\n%s:\n", Getitem(phony_targets, i)); + } + } + if (f_dependencies_file != stdout) Delete(f_dependencies_file); if (depend_only) SWIG_exit(EXIT_SUCCESS); Delete(inputfile_filename); Delete(basename); + Delete(phony_targets); } else { Printf(stderr, "Cannot generate dependencies with -nopreprocess\n"); // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index ffb172f8f..4c56d0664 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -204,9 +204,6 @@ private: String *proxy_class_name; String *variable_name; //Name of a variable being wrapped String *variable_type; //Type of this variable - String *enumeration_name; //Name of the current enumeration type - Hash *enumeration_items; //and its members - int enumeration_max; Hash *enumeration_coll; //Collection of all enumerations. /* The items are nodes with members: "items" - hash of with key 'itemname' and content 'itemvalue' @@ -268,9 +265,6 @@ MODULA3(): proxy_class_name(NULL), variable_name(NULL), variable_type(NULL), - enumeration_name(NULL), - enumeration_items(NULL), - enumeration_max(0), enumeration_coll(NULL), constant_values(NULL), constantfilename(NULL), @@ -1784,19 +1778,6 @@ MODULA3(): } } -#if 0 - void generateEnumerationItem(const String *name, const String *value, int numvalue) { - String *oldsymname = Getattr(enumeration_items, value); - if (oldsymname != NIL) { - Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The value <%s> is already assigned to <%s>.\n", value, oldsymname); - } - Setattr(enumeration_items, value, name); - if (enumeration_max < numvalue) { - enumeration_max = numvalue; - } - } -#endif - void emitEnumeration(File *file, String *name, Node *n) { Printf(file, "%s = {", name); int i; diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 34c8975c5..f60c13ed3 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1503,7 +1503,7 @@ public: /* if necessary, cast away const since Python doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", pname); - String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname); + String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, @@ -1583,8 +1583,6 @@ public: String *cleanup = NewString(""); String *outarg = NewString(""); - idx = 0; - tm = Swig_typemap_lookup("directorout", n, "c_result", w); if (tm != 0) { Replaceall(tm, "$input", "swig_result"); @@ -1742,7 +1740,6 @@ public: p = NewParm(type, NewString("self"), n); q = Copy(p); set_nextSibling(p, parms); - parms = p; { Wrapper *w = NewWrapper(); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 6c35b3eb2..65a1ad701 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -288,7 +288,7 @@ public: String *escaped_doc_str = texinfo_escape(doc_str); if (Len(doc_str)>0) { - Printf(f_doc,"const char* %s_texinfo = ",wrap_name); + Printf(f_doc,"static const char* %s_texinfo = ",wrap_name); Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str); if (Len(decl_info)) Printf(f_doc,"\\n\\\n@end deftypefn"); @@ -355,14 +355,10 @@ public: SwigType *type = Getattr(n, "type"); if (type && Strcmp(type, "void")) { - type = SwigType_base(type); - Node *lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); + Node *nn = classLookup(Getattr(n, "type")); + String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0); Append(decl_info, "@var{retval} = "); - String *type_str = NewString(""); - Printf(type_str, "@var{retval} is of type %s. ", type); - Append(args_str, type_str); + Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str); Delete(type_str); } @@ -524,11 +520,7 @@ public: } if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) return SwigType_ispointer(t) ? NewString("nil") : NewString("0"); - else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) - return NewString("true"); - else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) - return NewString("false"); - if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0) + if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("true"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("false"); @@ -752,10 +744,15 @@ public: Delete(tm); } - Printf(f->code, "fail:\n"); // we should free locals etc if this happens Printf(f->code, "return _out;\n"); + Printf(f->code, "fail:\n"); // we should free locals etc if this happens + Printv(f->code, cleanup, NIL); + Printf(f->code, "return octave_value_list();\n"); Printf(f->code, "}\n"); + /* Substitute the cleanup code */ + Replaceall(f->code, "$cleanup", cleanup); + Replaceall(f->code, "$symname", iname); Wrapper_print(f, f_wrappers); DelWrapper(f); @@ -1375,7 +1372,6 @@ public: outputs++; // build argument list and type conversion string - idx = 0; p = l; while (p) { if (checkAttribute(p, "tmap:in:numinputs", "0")) { diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 0112d2d9e..e95ef557f 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -26,6 +26,7 @@ struct Overloaded { int argc; /* Argument count */ ParmList *parms; /* Parameters used for overload check */ int error; /* Ambiguity error */ + bool implicitconv_function; /* For ordering implicitconv functions*/ }; static int fast_dispatch_mode = 0; @@ -40,6 +41,32 @@ void Wrapper_cast_dispatch_mode_set(int flag) { cast_dispatch_mode = flag; } +/* ----------------------------------------------------------------------------- + * mark_implicitconv_function() + * + * Mark function if it contains an implicitconv type in the parameter list + * ----------------------------------------------------------------------------- */ +static void mark_implicitconv_function(Overloaded& onode) { + Parm *parms = onode.parms; + if (parms) { + bool is_implicitconv_function = false; + Parm *p = parms; + while (p) { + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + continue; + } + if (GetFlag(p, "implicitconv")) { + is_implicitconv_function = true; + break; + } + p = nextSibling(p); + } + if (is_implicitconv_function) + onode.implicitconv_function = true; + } +} + /* ----------------------------------------------------------------------------- * Swig_overload_rank() * @@ -85,6 +112,9 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { nodes[nnodes].parms = Getattr(c, "wrap:parms"); nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); nodes[nnodes].error = 0; + nodes[nnodes].implicitconv_function = false; + + mark_implicitconv_function(nodes[nnodes]); nnodes++; } c = Getattr(c, "sym:nextSibling"); @@ -287,12 +317,30 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { List *result = NewList(); { int i; + int argc_changed_index = -1; for (i = 0; i < nnodes; i++) { if (nodes[i].error) Setattr(nodes[i].n, "overload:ignore", "1"); Append(result, nodes[i].n); - // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); - // Swig_print_node(nodes[i].n); + // Printf(stdout,"[ %d ] %d %s\n", i, nodes[i].implicitconv_function, ParmList_errorstr(nodes[i].parms)); + // Swig_print_node(nodes[i].n); + if (i == nnodes-1 || nodes[i].argc != nodes[i+1].argc) { + if (argc_changed_index+2 < nnodes && (nodes[argc_changed_index+1].argc == nodes[argc_changed_index+2].argc)) { + // Add additional implicitconv functions in same order as already ranked. + // Consider overloaded functions by argument count... only add additional implicitconv functions if + // the number of functions with the same arg count > 1, ie, only if overloaded by same argument count. + int j; + for (j = argc_changed_index + 1; j <= i; j++) { + if (nodes[j].implicitconv_function) { + SetFlag(nodes[j].n, "implicitconvtypecheckoff"); + Append(result, nodes[j].n); + // Printf(stdout,"[ %d ] %d + %s\n", j, nodes[j].implicitconv_function, ParmList_errorstr(nodes[j].parms)); + // Swig_print_node(nodes[j].n); + } + } + } + argc_changed_index = i; + } } } return result; @@ -302,20 +350,22 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { // * print_typecheck() // * ----------------------------------------------------------------------------- */ -static bool print_typecheck(String *f, int j, Parm *pj) { +static bool print_typecheck(String *f, int j, Parm *pj, bool implicitconvtypecheckoff) { char tmp[256]; sprintf(tmp, Char(argv_template_string), j); String *tm = Getattr(pj, "tmap:typecheck"); if (tm) { + tm = Copy(tm); Replaceid(tm, Getattr(pj, "lname"), "_v"); String *conv = Getattr(pj, "implicitconv"); - if (conv) { + if (conv && !implicitconvtypecheckoff) { Replaceall(tm, "$implicitconv", conv); } else { Replaceall(tm, "$implicitconv", "0"); } Replaceall(tm, "$input", tmp); Printv(f, tm, "\n", NIL); + Delete(tm); return true; } else return false; @@ -715,6 +765,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar for (i = 0; i < nfunc; i++) { Node *ni = Getitem(dispatch, i); Parm *pi = Getattr(ni, "wrap:parms"); + bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0; int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); if (GetFlag(n, "wrap:this")) { @@ -749,7 +800,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar Printf(f, "}\n"); Delete(lfmt); } - if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) { + if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj, implicitconvtypecheckoff)) { Printf(f, "if (_v) {\n"); num_braces++; } @@ -773,6 +824,8 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar for ( /* empty */ ; num_braces > 0; num_braces--) Printf(f, "}\n"); Printf(f, "}\n"); /* braces closes "if" for this method */ + if (implicitconvtypecheckoff) + Delattr(ni, "implicitconvtypecheckoff"); } Delete(dispatch); return f; diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 7147e67c1..09500b23b 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -610,7 +610,6 @@ public: Printf(f->code, "}\n"); /* Write code to extract parameters. */ - i = 0; for (i = 0, p = l; i < num_arguments; i++) { /* Skip ignored arguments */ diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 2583e1783..4ade67250 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -787,7 +787,6 @@ public: } f = NewWrapper(); - numopt = 0; String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); @@ -1738,7 +1737,6 @@ public: if (!class_node) { /* This is needed when we're returning a pointer to a type * rather than returning the type by value or reference. */ - class_node = current_class; Delete(mangled); mangled = NewString(SwigType_manglestr(ret_type)); class_node = Getattr(zend_types, mangled); @@ -2595,13 +2593,14 @@ done: } if (!idx) { - Printf(w->code, "zval **args = NULL;\n", idx); + Printf(w->code, "zval **args = NULL;\n"); } else { Printf(w->code, "zval *args[%d];\n", idx); } Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name()); Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name()); - Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym:name")); + const char * funcname = GetChar(n, "sym:name"); + Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname)); Append(w->code, "if (!swig_self) {\n"); Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");"); Append(w->code, "}\n\n"); @@ -2609,8 +2608,8 @@ done: /* wrap complex arguments to zvals */ Printv(w->code, wrap_args, NIL); - Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n"); - Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx); + Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,"); + Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx); if (tm) { Printv(w->code, Str(tm), "\n", NIL); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index fc438f084..1022f9fa0 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -42,6 +42,7 @@ static File *f_directors_h = 0; static File *f_init = 0; static File *f_shadow_py = 0; static String *f_shadow = 0; +static String *f_shadow_begin = 0; static Hash *f_shadow_imports = 0; static String *f_shadow_builtin_imports = 0; static String *f_shadow_stubs = 0; @@ -784,6 +785,7 @@ public: filen = NULL; f_shadow = NewString(""); + f_shadow_begin = NewString(""); f_shadow_imports = NewHash(); f_shadow_builtin_imports = NewString(""); f_shadow_stubs = NewString(""); @@ -977,6 +979,7 @@ public: if (!modern) { Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL); } + Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); Printv(f_shadow_py, "\n", f_shadow_builtin_imports, "\n", NIL); Printv(f_shadow_py, f_shadow, "\n", NIL); Printv(f_shadow_py, f_shadow_stubs, "\n", NIL); @@ -1556,7 +1559,7 @@ public: else return v; } - if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0) + if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("True"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("False"); @@ -2614,7 +2617,7 @@ public: Printf(f->code, "}\n"); } else { Printf(f->code, "newargs = PyTuple_GetSlice(args,0,%d);\n", num_fixed_arguments); - Printf(f->code, "varargs = PyTuple_GetSlice(args,%d,PyTuple_Size(args)+1);\n", num_fixed_arguments); + Printf(f->code, "varargs = PyTuple_GetSlice(args,%d,PyTuple_Size(args));\n", num_fixed_arguments); } Printf(f->code, "resultobj = %s__varargs__(%s,newargs,varargs);\n", wname, builtin ? "self" : "NULL"); Append(f->code, "Py_XDECREF(newargs);\n"); @@ -3398,7 +3401,7 @@ public: printSlot(f, getSlot(n, "feature:python:tp_dict"), "tp_dict"); printSlot(f, getSlot(n, "feature:python:tp_descr_get"), "tp_descr_get", "descrgetfunc"); printSlot(f, getSlot(n, "feature:python:tp_descr_set"), "tp_descr_set", "descrsetfunc"); - Printf(f, " (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */\n"); + Printf(f, " (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */\n"); printSlot(f, tp_init, "tp_init", "initproc"); printSlot(f, getSlot(n, "feature:python:tp_alloc"), "tp_alloc", "allocfunc"); printSlot(f, "0", "tp_new", "newfunc"); @@ -3725,7 +3728,7 @@ public: if (builtin) builtin_pre_decl(n); - /* Overide the shadow file so we can capture its methods */ + /* Override the shadow file so we can capture its methods */ f_shadow = NewString(""); // Set up type check for director class constructor @@ -4451,12 +4454,16 @@ public: String *code = Getattr(n, "code"); String *section = Getattr(n, "section"); - if ((!ImportMode) && ((Cmp(section, "python") == 0) || (Cmp(section, "shadow") == 0))) { + if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) { if (shadow) { String *pycode = pythoncode(code, shadow_indent); Printv(f_shadow, pycode, NIL); Delete(pycode); } + } else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) { + String *pycode = pythoncode(code, ""); + Printv(f_shadow_begin, pycode, NIL); + Delete(pycode); } else { Language::insertDirective(n); } @@ -4724,7 +4731,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { /* if necessary, cast away const since Python doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", pname); - String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname); + String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index c052f5eea..5ff599d54 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -790,11 +790,7 @@ private: } if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) return SwigType_ispointer(t) ? NewString("nil") : NewString("0"); - else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) - return NewString("true"); - else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) - return NewString("false"); - if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0) + if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) return NewString("True"); if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("False"); @@ -3205,7 +3201,7 @@ public: /* if necessary, cast away const since Ruby doesn't support it! */ if (SwigType_isconst(nptype)) { nonconst = NewStringf("nc_tmp_%s", parameterName); - String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(parameterType, 0), ppname); + String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(parameterType, 0), ppname); Wrapper_add_localv(w, nonconst, SwigType_lstr(parameterType, 0), nonconst, nonconst_i, NIL); Delete(nonconst_i); Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number, diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 32fd06339..3a7e8a8d6 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -216,7 +216,7 @@ public: virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */ virtual void dumpSymbols(); virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */ - virtual Node *classLookup(const SwigType *s); /* Class lookup */ + virtual Node *classLookup(const SwigType *s) const; /* Class lookup */ virtual Node *enumLookup(SwigType *s); /* Enum lookup */ virtual int abstractClassTest(Node *n); /* Is class really abstract? */ virtual int is_assignable(Node *n); /* Is variable assignable? */ @@ -301,6 +301,9 @@ protected: This does not include protected virtual methods as they are turned on with the dirprot option. */ bool isNonVirtualProtectedAccess(Node *n) const; + /* Identify if a wrapped global or member variable n should use the naturalvar feature */ + int use_naturalvar_mode(Node *n) const; + /* Director subclass comparison test */ String *none_comparison; @@ -381,7 +384,6 @@ int is_protected(Node *n); int is_member_director(Node *parentnode, Node *member); int is_member_director(Node *member); int is_non_virtual_protected_access(Node *n); /* Check if the non-virtual protected members are required (for directors) */ -int use_naturalvar_mode(Node *n); void Wrapper_virtual_elimination_mode_set(int); void Wrapper_fast_dispatch_mode_set(int); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 9ef1b8706..e61071167 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -744,6 +744,7 @@ public: have_constructor = 0; have_destructor = 0; destructor_action = 0; + constructor_name = 0; if (itcl) { constructor = NewString(""); @@ -1202,7 +1203,8 @@ public: } } - constructor_name = NewString(Getattr(n, "sym:name")); + if (!have_constructor) + constructor_name = NewString(Getattr(n, "sym:name")); have_constructor = 1; return SWIG_OK; } diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index f48108e15..6f8fa39e9 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -865,7 +865,7 @@ void Swig_replace_special_variables(Node *n, Node *parentnode, String *code) { * ----------------------------------------------------------------------------- */ static String *extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) { String *parms_str = cplusplus ? ParmList_str_defaultargs(parms) : ParmList_str(parms); - String *sig = NewStringf("%s(%s)", function_name, parms_str); + String *sig = NewStringf("%s(%s)", function_name, (cplusplus || Len(parms_str)) ? parms_str : "void"); String *rt_sig = SwigType_str(return_type, sig); String *body = NewStringf("SWIGINTERN %s", rt_sig); Printv(body, code, "\n", NIL); diff --git a/Source/Swig/fragment.c b/Source/Swig/fragment.c index 15f701ae4..927c772b8 100644 --- a/Source/Swig/fragment.c +++ b/Source/Swig/fragment.c @@ -18,6 +18,7 @@ #include "swig.h" #include "swigwarn.h" +#include "cparse.h" static Hash *fragments = 0; static Hash *looking_fragments = 0; @@ -60,6 +61,8 @@ void Swig_fragment_register(Node *fragment) { } Setfile(ccode, Getfile(fragment)); Setline(ccode, Getline(fragment)); + /* Replace $descriptor() macros */ + Swig_cparse_replace_descriptor(ccode); Setattr(fragments, name, ccode); if (debug) Printf(stdout, "registering fragment %s %s\n", name, section); diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 13afb21ae..7e80172ba 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -163,7 +163,8 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_ String *filename; List *spath = 0; char *cname; - int i, ilen; + int i, ilen, nbytes; + char bom[3]; if (!directories) directories = NewList(); @@ -191,6 +192,14 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_ if (f) { Delete(lastpath); lastpath = filename; + + /* Skip the UTF-8 BOM if it's present */ + nbytes = fread(bom, 1, 3, f); + if (nbytes == 3 && bom[0] == (char)0xEF && bom[1] == (char)0xBB && bom[2] == (char)0xBF) { + /* skip */ + } else { + fseek(f, 0, SEEK_SET); + } } return f; } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 229633bab..596f6b424 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -72,11 +72,11 @@ void Swig_banner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n\ * This file was automatically generated by SWIG (http://www.swig.org).\n\ * Version %s\n\ - * \n\ - * This file is not intended to be easily readable and contains a number of \n\ + *\n\ + * This file is not intended to be easily readable and contains a number of\n\ * coding conventions designed to improve portability and efficiency. Do not make\n\ - * changes to this file unless you know what you are doing--modify the SWIG \n\ - * interface file instead. \n", Swig_package_version()); + * changes to this file unless you know what you are doing--modify the SWIG\n\ + * interface file instead.\n", Swig_package_version()); /* String too long for ISO compliance */ Printf(f, " * ----------------------------------------------------------------------------- */\n"); @@ -205,8 +205,8 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) { /* ----------------------------------------------------------------------------- * Swig_filename_correct() * - * Corrects filename paths by removing duplicate delimeters and on non-unix - * systems use the correct delimeter across the whole name. + * Corrects filename paths by removing duplicate delimiters and on non-unix + * systems use the correct delimiter across the whole name. * ----------------------------------------------------------------------------- */ void Swig_filename_correct(String *filename) { diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 7e9f45c9e..181d9aa74 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1405,7 +1405,7 @@ void Scanner_skip_line(Scanner * s) { if ((c = nextchar(s)) == 0) return; if (c == '\\') { - c = nextchar(s); + nextchar(s); } else if (c == '\n') { done = 1; } diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index e4af7437f..4b72bdaa2 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -659,7 +659,6 @@ SwigType *SwigType_ltype(const SwigType *s) { if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td) || SwigType_isrvalue_reference(td))) { /* We need to use the typedef type */ Delete(tt); - tt = td; break; } else if (td) { Delete(tt); diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 89283abfa..903d1357c 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -16,6 +16,7 @@ #include "swig.h" #include +#include /* ----------------------------------------------------------------------------- * Synopsis @@ -464,61 +465,60 @@ int SwigType_isrvalue_reference(const SwigType *t) { * Repeated qualifications have no effect. Moreover, the order of qualifications * is alphabetical---meaning that "const volatile" and "volatile const" are * stored in exactly the same way as "q(const volatile)". + * 'qual' can be a list of multiple qualifiers in any order, separated by spaces. * ----------------------------------------------------------------------------- */ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { - String *newq; - int sz, added = 0; - char *q, *cqual; + List *qlist; + String *allq, *newq; + int i, sz; + const char *cqprev = 0; + const char *c = Char(t); + const char *cqual = Char(qual); - char *c = Char(t); - cqual = Char(qual); - - if (!(strncmp(c, "q(", 2) == 0)) { + /* if 't' has no qualifiers and 'qual' is a single qualifier, simply add it */ + if ((strncmp(c, "q(", 2) != 0) && (strstr(cqual, " ") == 0)) { String *temp = NewStringf("q(%s).", cqual); Insert(t, 0, temp); Delete(temp); return t; } - /* The type already has a qualifier on it. In this case, we first check to - see if the qualifier is already specified. In that case do nothing. - If it is a new qualifier, we add it to the qualifier list in alphabetical - order */ - - sz = element_size(c); - - if (strstr(c, cqual)) { - /* Qualifier already added */ - return t; + /* create string of all qualifiers */ + if (strncmp(c, "q(", 2) == 0) { + allq = SwigType_parm(t); + Append(allq, " "); + SwigType_del_element(t); /* delete old qualifier list from 't' */ + } else { + allq = NewStringEmpty(); } + Append(allq, qual); - /* Add the qualifier to the existing list. */ + /* create list of all qualifiers from string */ + qlist = Split(allq, ' ', INT_MAX); + Delete(allq); + /* sort in alphabetical order */ + SortList(qlist, Strcmp); + + /* create new qualifier string from unique elements of list */ + sz = Len(qlist); newq = NewString("q("); - q = c + 2; - q = strtok(q, " )."); - while (q) { - if (strcmp(cqual, q) < 0) { - /* New qualifier is less that current qualifier. We need to insert it */ - Append(newq, cqual); - Append(newq, " "); - Append(newq, q); - added = 1; - } else { + for (i = 0; i < sz; ++i) { + String *q = Getitem(qlist, i); + const char *cq = Char(q); + if (cqprev == 0 || strcmp(cqprev, cq) != 0) { + if (i > 0) { + Append(newq, " "); + } Append(newq, q); + cqprev = cq; } - q = strtok(NULL, " )."); - if (q) { - Append(newq, " "); - } - } - if (!added) { - Append(newq, " "); - Append(newq, cqual); } Append(newq, ")."); - Delslice(t, 0, sz); + Delete(qlist); + + /* replace qualifier string with new one */ Insert(t, 0, newq); Delete(newq); return t; @@ -785,7 +785,6 @@ SwigType *SwigType_add_function(SwigType *t, ParmList *parms) { Insert(t, 0, ")."); pstr = NewString("f("); - p = parms; for (p = parms; p; p = nextSibling(p)) { if (p != parms) Putc(',', pstr); @@ -883,7 +882,6 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) { Parm *p; Append(t, "<("); - p = parms; for (p = parms; p; p = nextSibling(p)) { String *v; if (Getattr(p, "default")) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 781554fa2..1552703c6 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -792,6 +792,67 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { goto return_result; } Delete(base); + + /* If 'type' is an array, then the right-most qualifier in 'r' should + be added to 'type' after the array qualifier, so that given + a(7).q(volatile).double myarray // typedef volatile double[7] myarray; + the type + q(const).myarray // const myarray + becomes + a(7).q(const volatile).double // const volatile double[7] + and NOT + q(const).a(7).q(volatile).double // non-sensical type + */ + if (r && Len(r) && SwigType_isarray(type)) { + List *r_elem; + String *r_qual; + int r_sz; + r_elem = SwigType_split(r); + r_sz = Len(r_elem); + r_qual = Getitem(r_elem, r_sz-1); + if (SwigType_isqualifier(r_qual)) { + String *new_r; + String *new_type; + List *type_elem; + String *type_qual; + String *r_qual_arg; + int i, type_sz; + + type_elem = SwigType_split(type); + type_sz = Len(type_elem); + + for (i = 0; i < type_sz; ++i) { + String *e = Getitem(type_elem, i); + if (!SwigType_isarray(e)) + break; + } + type_qual = Copy(Getitem(type_elem, i)); + r_qual_arg = SwigType_parm(r_qual); + SwigType_add_qualifier(type_qual, r_qual_arg); + Delete(r_qual_arg); + Setitem(type_elem, i, type_qual); + + new_r = NewStringEmpty(); + for (i = 0; i < r_sz-1; ++i) { + Append(new_r, Getitem(r_elem, i)); + } + new_type = NewStringEmpty(); + for (i = 0; i < type_sz; ++i) { + Append(new_type, Getitem(type_elem, i)); + } +#ifdef SWIG_DEBUG + Printf(stdout, "r+type='%s%s' new_r+new_type='%s%s'\n", r, type, new_r, new_type); +#endif + + Delete(r); + r = new_r; + newtype = 1; + type = new_type; + Delete(type_elem); + } + Delete(r_elem); + } + Append(r, type); if (newtype) { Delete(type); diff --git a/Tools/config/ac_compile_warnings.m4 b/Tools/config/ac_compile_warnings.m4 index 4c030ea59..7e4239a3c 100644 --- a/Tools/config/ac_compile_warnings.m4 +++ b/Tools/config/ac_compile_warnings.m4 @@ -4,7 +4,7 @@ dnl Set the maximum warning verbosity according to C and C++ compiler used. dnl Currently supports g++ and gcc. dnl dnl The compiler options are always added CFLAGS and CXXFLAGS even if -dnl these are overidden at configure time. Removing the maximum warning +dnl these are overridden at configure time. Removing the maximum warning dnl flags can be removed with --without-maximum-compile-warnings. For example: dnl dnl ./configure --without-maximum-compile-warnings CFLAGS= CXXFLAGS= diff --git a/Tools/mkdist.py b/Tools/mkdist.py index f2a04542c..234c768f2 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -6,6 +6,7 @@ import sys import string import os +import subprocess def failed(): print "mkdist.py failed to complete" @@ -34,10 +35,42 @@ os.system("rm -f "+dirname+".tar.gz") print "Removing "+dirname+".tar.gz if exists" os.system("rm -f "+dirname+".tar") -# Do a SVN export into the directory name +# Grab the code from git -print "Grabbing latest SWIG from svn" -os.system("svn export -r HEAD https://swig.svn.sourceforge.net/svnroot/swig/trunk "+dirname) == 0 or failed() +print "Checking git repository is in sync with remote repository" +os.system("git remote update") == 0 or failed() +command = ["git", "status", "--porcelain", "-uno"] +out = subprocess.check_output(command) +if out.strip() != "": + print "Local git repository has modifications" + print " ".join(command) + print out + sys.exit(3) + +command = ["git", "log", "--oneline", "master..origin/master"] +out = subprocess.check_output(command) +if out.strip() != "": + print "Remote repository has additional modifications to local repository" + print " ".join(command) + print out + sys.exit(3) + +command = ["git", "log", "--oneline", "origin/master..master"] +out = subprocess.check_output(command) +if out.strip() != "": + print "Local repository has modifications not pushed to the remote repository" + print "These should be pushed and checked that they pass Continuous Integration testing before continuing" + print " ".join(command) + print out + sys.exit(3) + +print "Tagging release" +tag = "'rel-" + version + "'" +os.system("git tag -a -m " + tag + " " + tag) == 0 or failed() + +outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" +print "Grabbing tagged release git repository using 'git archive' into " + outdir +os.system("(cd .. && git archive --prefix=" + outdir + " " + tag + " . | tar -xf -)") == 0 or failed() # Remove the debian directory -- it's not official diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index 9ca96bc6f..0623fe786 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -43,9 +43,6 @@ os.system("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.cur os.system("rsync --archive --verbose -P --times -e ssh " + "swig-" + version + ".tar.gz " + full_readme_file + " " + swig_dir_sf) and failed("") os.system("rsync --archive --verbose -P --times -e ssh " + "swigwin-" + version + ".zip " + full_readme_file + " " + swigwin_dir_sf) and failed("") -print "Tagging release" -os.system("svn copy -m \"rel-" + version + "\" https://swig.svn.sourceforge.net/svnroot/swig/trunk https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-" + version + "/") - print "Finished" -print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file." +print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file. Also remember to do a 'git push --tags'." diff --git a/configure.ac b/configure.ac index fa985bfd8..557138dbc 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. -AC_INIT([swig],[2.0.10],[http://www.swig.org]) +AC_INIT([swig],[3.0.0],[http://www.swig.org]) dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl definition below can be removed @@ -47,7 +47,7 @@ AC_LANG_POP([C++]) dnl Look for popen AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval") -if test x"${with_popen}" = xno ; then +if test x"${with_popen}" = xno ; then AC_MSG_NOTICE([Disabling popen]) else AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) @@ -69,7 +69,7 @@ AC_MSG_CHECKING([whether to enable PCRE support]) AC_MSG_RESULT([$with_pcre]) dnl To make configuring easier, check for a locally built PCRE using the Tools/pcre-build.sh script -if test x"${with_pcre}" = xyes ; then +if test x"${with_pcre}" = xyes ; then AC_MSG_CHECKING([whether to use local PCRE]) local_pcre_config=no if test -z $PCRE_CONFIG; then @@ -157,7 +157,7 @@ if test "$GCC" = yes; then else ISYSTEM="-I" fi - +AC_MSG_NOTICE(ISYSTEM: $ISYSTEM) dnl Info for building shared libraries ... in order to run the examples @@ -205,7 +205,7 @@ then *-*-next*) if test "$ns_dyld" then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind' - else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r'; + else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r' fi if test "$with_next_framework" ; then LDSHARED="$LDSHARED \$(LDLIBRARY)" @@ -243,9 +243,9 @@ AC_MSG_CHECKING(TRYLINKINGWITHCXX) if test -z "$TRYLINKINGWITHCXX" then case $host in - *-*-solaris*) if test "$GCC" = yes; - then TRYLINKINGWITHCXX="CXXSHARED= $CXX -Wl,-G"; - else TRYLINKINGWITHCXX="CXXSHARED= $CXX -G -L/opt/SUNWspro/lib -lCrun -lCstd"; + *-*-solaris*) if test "$GCC" = yes + then TRYLINKINGWITHCXX="CXXSHARED= $CXX -Wl,-G" + else TRYLINKINGWITHCXX="CXXSHARED= $CXX -G -L/opt/SUNWspro/lib -lCrun -lCstd" fi;; *-*-hp*) TRYLINKINGWITHCXX="CXXSHARED= $CXX +z ";; *-*-darwin*) TRYLINKINGWITHCXX="CXXSHARED= $CXX -bundle -undefined suppress -flat_namespace";; @@ -270,9 +270,9 @@ AC_MSG_CHECKING(CCSHARED) if test -z "$CCSHARED" then case $host in - *-*-hp*) if test "$GCC" = yes; - then CCSHARED="-fpic"; - else CCSHARED="+z"; + *-*-hp*) if test "$GCC" = yes + then CCSHARED="-fpic" + else CCSHARED="+z" fi;; *-*-linux*) CCSHARED="-fpic";; *-*-freebsd* | *-*-openbsd*) CCSHARED="-fpic";; @@ -320,7 +320,7 @@ AC_MSG_RESULT($LINKFORSHARED) # Optional CFLAGS used to silence/enhance compiler warnings on some platforms. AC_MSG_CHECKING(PLATCFLAGS) case $host in - *-*-solaris*) if test "$GCC" = yes; + *-*-solaris*) if test "$GCC" = yes then PLATCFLAGS= else PLATCFLAGS= # else PLATCFLAGS="-errtags=yes" # Need more work as C examples use ld for linking @@ -443,80 +443,9 @@ else AC_MSG_ERROR([proper usage is --with-libc=STRING]) fi]) #-------------------------------------------------------------------- -# Locate the X11 header files and the X11 library archive. Try -# the ac_path_x macro first, but if it doesn't find the X stuff -# (e.g. because there's no xmkmf program) then check through -# a list of possible directories. Under some conditions the -# autoconf macro will return an include directory that contains -# no include files, so double-check its result just to be safe. +# Target languages #-------------------------------------------------------------------- -AC_PATH_X -not_really_there="" -if test "$no_x" = ""; then - if test "$x_includes" = ""; then - AC_TRY_CPP([#include ], , not_really_there="yes") - else - if test ! -r $x_includes/X11/Intrinsic.h; then - not_really_there="yes" - fi - fi -fi -if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then - AC_MSG_CHECKING(for X11 header files) - XINCLUDES="# no special path needed" - AC_TRY_CPP([#include ], , XINCLUDES="") - if test -z "$XINCLUDES"; then - dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6" - for i in $dirs ; do - if test -r $i/X11/Intrinsic.h; then - XINCLUDES=" -I$i" - break - fi - done - fi - AC_MSG_RESULT($XINCLUDES) -else - if test "$x_includes" != ""; then - XINCLUDES=-I$x_includes - else - XINCLUDES="# no special path needed" - fi -fi -if test -z "$XINCLUDES"; then - AC_MSG_RESULT(couldn't find any!) - XINCLUDES="# no include files found" -fi - -if test "$no_x" = yes; then - AC_MSG_CHECKING(for X11 libraries) - XLIBSW= - dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/X11R6/lib /usr/lib/X11R6 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib" - for i in $dirs ; do - if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then - AC_MSG_RESULT($i) - XLIBSW="-L$i -lX11" - break - fi - done -else - if test "$x_libraries" = ""; then - XLIBSW=-lX11 - else - XLIBSW="-L$x_libraries -lX11" - fi -fi -if test -z "$XLIBSW" ; then - AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow) -fi -if test -z "$XLIBSW" ; then - AC_MSG_RESULT(couldn't find any! Using -lX11.) - XLIBSW=-lX11 -fi - -AC_SUBST(XINCLUDES) -AC_SUBST(XLIBSW) - AC_ARG_WITH(alllang, AS_HELP_STRING([--without-alllang], [Disable all languages]), with_alllang="$withval") #-------------------------------------------------------------------- @@ -538,7 +467,7 @@ AC_ARG_WITH(tcllib,[ --with-tcllib=path Set location of Tcl library direct TCLLIB="-L$withval"], [TCLLIB=]) # First, check for "--without-tcl" or "--with-tcl=no". -if test x"${TCLPACKAGE}" = xno -o x"${with_alllang}" = xno; then +if test x"${TCLPACKAGE}" = xno -o x"${with_alllang}" = xno; then AC_MSG_NOTICE([Disabling Tcl]) else AC_MSG_CHECKING([for Tcl configuration]) @@ -631,7 +560,7 @@ case $host in esac case $host in -*-*-darwin*) +*-*-darwin*) TCLLDSHARED='$(CC) -dynamiclib -undefined suppress -flat_namespace' TCLCXXSHARED='$(CXX) -dynamiclib -undefined suppress -flat_namespace' ;; @@ -661,7 +590,7 @@ AC_ARG_WITH(python, AS_HELP_STRING([--without-python], [Disable Python]) AS_HELP_STRING([--with-python=path], [Set location of Python executable]),[ PYBIN="$withval"], [PYBIN=yes]) # First, check for "--without-python" or "--with-python=no". -if test x"${PYBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PYBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Python]) else # First figure out the name of the Python executable @@ -695,11 +624,11 @@ else AC_MSG_CHECKING(for Python lib dir) PYLIBDIR=`($PYTHON -c "import sys; print sys.lib") 2>/dev/null` if test -z "$PYLIBDIR"; then - # older versions don't have sys.lib so the best we can do is assume lib - PYLIBDIR="lib" + # Fedora patch Python to add sys.lib, for other distros we assume "lib". + PYLIBDIR="lib" fi AC_MSG_RESULT($PYLIBDIR) - + # Set the include directory AC_MSG_CHECKING(for Python header files) @@ -728,18 +657,14 @@ else AC_MSG_RESULT($PYLIB) fi - # Check for really old versions - if test -r $PYLIB/libPython.a; then - PYLINK="-lModules -lPython -lObjects -lParser" - else - PYLINK="-l$PYVERSION" - fi + PYLINK="-l$PYVERSION" fi # Cygwin (Windows) needs the library for dynamic linking case $host in - *-*-cygwin* | *-*-mingw*) PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK" - DEFS="-DUSE_DL_IMPORT $DEFS" PYINCLUDE="$PYINCLUDE" + *-*-cygwin* | *-*-mingw*) + PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK" + DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHONDYNAMICLINKING="";; esac @@ -766,7 +691,7 @@ AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x sup AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes]) # First, check for "--without-python3" or "--with-python3=no". -if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Python 3.x support]) else for py_ver in 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0; do @@ -789,7 +714,7 @@ else # Note: I could not think of a standard way to get the version string from different versions. # This trick pulls it out of the file location for a standard library file. - + AC_MSG_CHECKING([for Python 3.x version]) # Need to do this hack since autoconf replaces __file__ with the name of the configure file @@ -803,10 +728,10 @@ else PY3LIBDIR=`($PYTHON3 -c "import sys; print(sys.lib)") 2>/dev/null` if test -z "$PY3LIBDIR"; then # some dists don't have sys.lib so the best we can do is assume lib - PY3LIBDIR="lib" + PY3LIBDIR="lib" fi AC_MSG_RESULT($PY3LIBDIR) - + # Set the include directory AC_MSG_CHECKING([for Python 3.x header files]) @@ -833,8 +758,9 @@ else # Cygwin (Windows) needs the library for dynamic linking case $host in - *-*-cygwin* | *-*-mingw*) PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" - DEFS="-DUSE_DL_IMPORT $DEFS" PY3INCLUDE="$PY3INCLUDE" + *-*-cygwin* | *-*-mingw*) + PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" + DEFS="-DUSE_DL_IMPORT $DEFS" ;; *)PYTHON3DYNAMICLINKING="";; esac @@ -856,7 +782,7 @@ AC_ARG_WITH(perl5, AS_HELP_STRING([--without-perl5], [Disable Perl5]) AS_HELP_STRING([--with-perl5=path], [Set location of Perl5 executable]),[ PERLBIN="$withval"], [PERLBIN=yes]) # First, check for "--without-perl5" or "--with-perl5=no". -if test x"${PERLBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PERLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Perl5]) PERL= else @@ -875,14 +801,14 @@ fi AC_MSG_CHECKING(for Perl5 header files) if test -n "$PERL"; then PERL5DIR=`($PERL -e 'use Config; print $Config{archlib}, "\n";') 2>/dev/null` - if test "$PERL5DIR" != ""; then + if test -n "$PERL5DIR" ; then dirs="$PERL5DIR $PERL5DIR/CORE" PERL5EXT=none for i in $dirs; do if test -r $i/perl.h; then AC_MSG_RESULT($i) PERL5EXT="$i" - break; + break fi done if test "$PERL5EXT" = none; then @@ -891,19 +817,40 @@ if test -n "$PERL"; then fi AC_MSG_CHECKING(for Perl5 library) - PERL5LIB=`($PERL -e 'use Config; $_=$Config{libperl}; s/^lib//; s/$Config{_a}$//; print $_, "\n"') 2>/dev/null` - if test "$PERL5LIB" = "" ; then + PERL5LIB=`($PERL -e 'use Config; $_=$Config{libperl}; s/^lib//; s/$Config{_a}$//; s/\.$Config{so}.*//; print $_, "\n"') 2>/dev/null` + if test -z "$PERL5LIB" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5LIB) fi - AC_MSG_CHECKING(for Perl5 compiler options) + AC_MSG_CHECKING(for Perl5 ccflags) PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}, "\n"' | sed "s/-Wdeclaration-after-statement//" | sed "s/-I/$ISYSTEM/") 2>/dev/null` - if test "$PERL5CCFLAGS" = "" ; then + if test -z "$PERL5CCFLAGS" ; then AC_MSG_RESULT(not found) else AC_MSG_RESULT($PERL5CCFLAGS) fi + AC_MSG_CHECKING(for Perl5 ccdlflags) + PERL5CCDLFLAGS=`($PERL -e 'use Config; print $Config{ccdlflags}, "\n"') 2>/dev/null` + if test -z "$PERL5CCDLFLAGS" ; then + AC_MSG_RESULT(not found) + else + AC_MSG_RESULT($PERL5CCDLFLAGS) + fi + AC_MSG_CHECKING(for Perl5 cccdlflags) + PERL5CCCDLFLAGS=`($PERL -e 'use Config; print $Config{cccdlflags}, "\n"') 2>/dev/null` + if test -z "$PERL5CCCDLFLAGS" ; then + AC_MSG_RESULT(not found) + else + AC_MSG_RESULT($PERL5CCCDLFLAGS) + fi + AC_MSG_CHECKING(for Perl5 ldflags) + PERL5LDFLAGS=`($PERL -e 'use Config; print $Config{ldflags}, "\n"') 2>/dev/null` + if test -z "$PERL5LDFLAGS" ; then + AC_MSG_RESULT(not found) + else + AC_MSG_RESULT($PERL5LDFLAGS) + fi else AC_MSG_RESULT(unable to determine perl5 configuration) PERL5EXT=$PERL5DIR @@ -924,6 +871,9 @@ AC_SUBST(PERL5EXT) AC_SUBST(PERL5DYNAMICLINKING) AC_SUBST(PERL5LIB) AC_SUBST(PERL5CCFLAGS) +AC_SUBST(PERL5CCDLFLAGS) +AC_SUBST(PERL5CCCDLFLAGS) +AC_SUBST(PERL5LDFLAGS) #---------------------------------------------------------------- # Look for Octave @@ -936,13 +886,13 @@ AC_ARG_WITH(octave, AS_HELP_STRING([--without-octave], [Disable Octave]) AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN=yes]) # First, check for "--without-octave" or "--with-octave=no". -if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Octave]) OCTAVE= # First figure out what the name of Octave is elif test "x$OCTAVEBIN" = xyes; then - AC_CHECK_PROGS(OCTAVE, octave) + AC_PATH_PROG(OCTAVE, [octave]) else OCTAVE="$OCTAVEBIN" @@ -950,31 +900,43 @@ fi if test -n "$OCTAVE"; then AC_MSG_CHECKING([for mkoctfile]) - AS_IF([test "x`${OCTAVE} -qfH --eval 'mkoctfile -p CXX' 2>/dev/null`" != x],[ - AC_MSG_RESULT([yes]) + mkoctfile="`dirname ${OCTAVE}`/mkoctfile" + AS_IF([test -x "${mkoctfile}"],[ + AC_MSG_RESULT([${mkoctfile}]) ],[ - AC_MSG_ERROR([mkoctfile is not installed]) + AC_MSG_RESULT([not found, disabling Octave]) + OCTAVE= ]) +fi +if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave preprocessor flags]) OCTAVE_CPPFLAGS= for n in CPPFLAGS INCFLAGS; do - OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`$OCTAVE -qfH --eval "mkoctfile -p $n"` + OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`${mkoctfile} -p $n` done - AC_MSG_RESULT($OCTAVE_CPPFLAGS) + AC_MSG_RESULT([$OCTAVE_CPPFLAGS]) AC_MSG_CHECKING([for Octave compiler flags]) OCTAVE_CXXFLAGS= for n in ALL_CXXFLAGS; do - OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`$OCTAVE -qfH --eval "mkoctfile -p $n"` + OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`${mkoctfile} -p $n` done - AC_MSG_RESULT($OCTAVE_CXXFLAGS) + AC_MSG_RESULT([$OCTAVE_CXXFLAGS]) AC_MSG_CHECKING([for Octave linker flags]) OCTAVE_LDFLAGS= for n in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do - OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`$OCTAVE -qfH --eval "mkoctfile -p $n"` + OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p $n` + done + AC_MSG_RESULT([$OCTAVE_LDFLAGS]) + for octave_opt in --silent --norc --no-history --no-window-system; do + AC_MSG_CHECKING([if Octave option '${octave_opt}' is supported]) + octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1{/unrecognized/p}'` + AS_IF([test "x${octave_out}" = x],[ + AC_MSG_RESULT([yes]) + OCTAVE="${OCTAVE} ${octave_opt}" + ],[ + AC_MSG_RESULT([no]) + ]) done - AC_MSG_RESULT($OCTAVE_LDFLAGS) -else - AC_MSG_RESULT(could not figure out how to run octave) fi AC_SUBST(OCTAVE) @@ -992,7 +954,7 @@ AS_HELP_STRING([--with-java=path], [Set location of java executable]),[JAVABIN=" AC_ARG_WITH(javac, [ --with-javac=path Set location of javac executable],[JAVACBIN="$withval"], [JAVACBIN=]) # First, check for "--without-java" or "--with-java=no". -if test x"${JAVABIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${JAVABIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Java]) JAVA= else @@ -1058,7 +1020,7 @@ case $host in JAVADYNAMICLINKING="" JAVACFLAGS="" fi ;; -*-*-darwin*) +*-*-darwin*) JAVADYNAMICLINKING="-dynamiclib -framework JavaVM" JAVACFLAGS="" ;; @@ -1076,7 +1038,7 @@ esac # Java on Mac OS X tweaks case $host in -*-*-darwin*) +*-*-darwin*) JAVASO=".jnilib" JAVALDSHARED='$(CC)' JAVACXXSHARED='$(CXX)' @@ -1108,7 +1070,7 @@ AS_HELP_STRING([--with-gcj=path], [Set location of gcj executable]),[GCJBIN="$wi AC_ARG_WITH(gcjh, [ --with-gcjh=path Set location of gcjh executable],[GCJHBIN="$withval"], [GCJHBIN=]) # First, check for "--without-gcj" or "--with-gcj=no". -if test x"${GCJBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${GCJBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling GCJ]) else if test "x$GCJBIN" = xyes; then @@ -1138,7 +1100,7 @@ AC_ARG_WITH(ant, [ --with-ant=path Set location of ant executable for And AC_ARG_WITH(ndk-build, [ --with-ndk-build=path Set location of Android ndk-build executable],[NDKBUILDBIN="$withval"], [NDKBUILDBIN=]) # First, check for "--without-android" or "--with-android=no". -if test x"${ANDROIDBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${ANDROIDBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Android]) ANDROID= else @@ -1176,127 +1138,67 @@ AC_SUBST(NDKBUILD) # Look for Guile #---------------------------------------------------------------- -GUILEPACKAGE= -GUILEINCLUDE= GUILE= -GUILELIB= -GUILELINK= -GUILEPKGDATADIR= +GUILE_CFLAGS= +GUILE_LIBS= -AC_ARG_WITH(guile-config,AS_HELP_STRING([--without-guile], [Disable Guile]) -AS_HELP_STRING([--with-guile-config=path], [Set location of guile-config]),[ GUILE_CONFIG="$withval"], [GUILE_CONFIG=]) -AC_ARG_WITH(guilepackage, AS_HELP_STRING([--with-guile-prefix=path], [Set location of Guile tree]),[ - GUILEPACKAGE="$withval"]) +AC_ARG_WITH(guile-config, AS_HELP_STRING([--without-guile], [Disable Guile]) + AS_HELP_STRING([--with-guile-config=path], [Set location of guile-config]),[ GUILE_CONFIG="$withval"], [GUILE_CONFIG=]) AC_ARG_WITH(guile,[ --with-guile=path Set location of Guile executable],[ GUILE="$withval"], [GUILE=yes]) -AC_ARG_WITH(guileincl,[ --with-guileincl=path Set location of Guile include directory],[ - GUILEINCLUDE="$withval"]) -AC_ARG_WITH(guilelib,[ --with-guilelib=path Set location of Guile library directory],[ - GUILELIB="$withval"]) +AC_ARG_WITH(guile-cflags,[ --with-guile-cflags=cflags Set cflags required to compile against Guile],[ + GUILE_CFLAGS="$withval"]) +AC_ARG_WITH(guile-libs,[ --with-guile-libs=ldflags Set ldflags needed to link with Guile],[ + GUILE_LIBS="$withval"]) # First, check for "--without-guile" or "--with-guile=no". -if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling Guile]) +if test x"${GUILE}" = xno -o x"${with_alllang}" = xno ; then + AC_MSG_NOTICE([Disabling Guile]) else - -if test -z "$GUILE_CONFIG" ; then - AC_PATH_PROG(GUILE_CONFIG, guile-config) -fi - -if test -n "$GUILE_CONFIG" ; then - GUILEPACKAGE="`$GUILE_CONFIG info prefix`" - GUILEINCLUDE="`$GUILE_CONFIG info includedir`" - GUILELIB="`$GUILE_CONFIG info libdir`" - GUILE="`$GUILE_CONFIG info bindir`/guile" - GUILELINK="`$GUILE_CONFIG link`" - GUILEPKGDATADIR="`$GUILE_CONFIG info pkgdatadir`" -fi - - if test -z "$GUILE" -o "x$GUILE" = xyes; then - if test -n "$GUILEPACKAGE"; then - GUILE="$GUILEPACKAGE/bin/guile" - else - GUILE= - fi + if test -z "$GUILE_CONFIG" ; then + AC_PATH_PROG(GUILE_CONFIG, guile-config) fi + if test -n "$GUILE_CONFIG" ; then + if test x"$GUILE" = xyes; then + AC_MSG_CHECKING([for guile bindir]) + guile_bindir="`$GUILE_CONFIG info bindir`" + AC_MSG_RESULT([$guile_bindir]) + GUILE=$guile_bindir/guile + if ! test -f "$GUILE" ; then + GUILE= + AC_PATH_PROG(GUILE, guile) + fi + fi - if test -z "$GUILEINCLUDE"; then - if test -n "$GUILEPACKAGE"; then - GUILEINCLUDE="$GUILEPACKAGE/include" - fi + if test -f "$GUILE" ; then + AC_MSG_CHECKING([for guile version]) + guile_version=`$GUILE -c '(display (effective-version))'` + AC_MSG_RESULT([$guile_version]) + AC_MSG_CHECKING([for guile version >= 1.8]) + guile_good_version=`$GUILE -c '(if (>= (string->number (effective-version)) 1.8) (display "yes") (display "no"))'` + AC_MSG_RESULT([$guile_good_version]) + if test x"$guile_good_version" != xyes ; then + GUILE= + fi + fi + + if test -z "$GUILE_CFLAGS" ; then + AC_MSG_CHECKING([for guile compile flags]) + GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty + AC_MSG_RESULT([$GUILE_CFLAGS]) + fi + + if test -z "$GUILE_LIBS" ; then + AC_MSG_CHECKING([for guile link flags]) + GUILE_LIBS="`$GUILE_CONFIG link`" + AC_MSG_RESULT([$GUILE_LIBS]) + fi fi - - if test -z "$GUILELIB"; then - if test -n "$GUILEPACKAGE"; then - GUILELIB="$GUILEPACKAGE/lib" - fi - fi - - -AC_MSG_CHECKING(for Guile header files) - - dirs="$GUILEINCLUDE" - for i in $dirs ; do - if test -r $i/guile/gh.h; then - AC_MSG_RESULT($i) - GUILEINCLUDE="$ISYSTEM$i" - break - fi - done - if test -z "$GUILEINCLUDE"; then - AC_MSG_RESULT(not found) - fi - - AC_MSG_CHECKING(for Guile library) - dirs="$GUILELIB" - for i in $dirs ; do - if test -r $i/libguile.so; then - AC_MSG_RESULT($i) - GUILELIB="$i" - break - fi - done - if test -z "$GUILELIB"; then - AC_MSG_RESULT(not found) - fi - -if test -z "$GUILELINK"; then - GUILELINK="-L$GUILELIB -lguile" -fi - -guilesafe_CFLAGS=$CFLAGS -guilesafe_LIBS=$LIBS -# Filter out "-ansi -pedantic" because Guile header files will not compile with these flags. -# (The flags -ansi -pedantic are automatically added by ac_compile_warnings.m4) -CFLAGS="`echo $CFLAGS | sed 's/-ansi//g;s/-pedantic//g;'` $GUILEINCLUDE" -LIBS="$LIBS $GUILELINK" - -AC_MSG_CHECKING(whether Guile's gh_ API works) -AC_LINK_IFELSE([AC_LANG_SOURCE([#include - int main() { SCM s; return gh_scm2int(s); }])], GUILE_GH_INTERFACE=1, ) -if test -n "$GUILE_GH_INTERFACE" ; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -AC_MSG_CHECKING(whether Guile's SCM_ API works) -AC_LINK_IFELSE([AC_LANG_SOURCE([#include - int main() { SCM s; scm_slot_exists_p(SCM_BOOL_F, SCM_BOOL_F); return SCM_STRING_LENGTH(s); }])], GUILE_SCM_INTERFACE=1, ) -if test -n "$GUILE_SCM_INTERFACE" ; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -CFLAGS=$guilesafe_CFLAGS -LIBS=$guilesafe_LIBS fi AC_SUBST(GUILE) -AC_SUBST(GUILEINCLUDE) -AC_SUBST(GUILELIB) -AC_SUBST(GUILELINK) -AC_SUBST(GUILE_GH_INTERFACE) -AC_SUBST(GUILE_SCM_INTERFACE) +AC_SUBST(GUILE_CFLAGS) +AC_SUBST(GUILE_LIBS) #---------------------------------------------------------------- # Look for MzScheme @@ -1307,7 +1209,7 @@ AS_HELP_STRING([--with-mzscheme=path], [Set location of MzScheme executable]),[ AC_ARG_WITH(mzc, AS_HELP_STRING([--with-mzc=path], [Set location of MzScheme's mzc]), [ MZCBIN="$withval"], [MZCBIN=]) # First, check for "--without-mzscheme" or "--with-mzscheme=no". -if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling MzScheme]) MZC= else @@ -1316,16 +1218,16 @@ else else MZSCHEME="$MZSCHEMEBIN" fi - + if test -z "$MZCBIN"; then AC_PATH_PROG(MZC, mzc) fi if test -n "$MZSCHEME"; then - AC_MSG_CHECKING(for MzScheme dynext object) + AC_MSG_CHECKING(for MzScheme dynext object) MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` if test -f "$MZDYNOBJ"; then - MZDYNOBJ="$MZDYNOBJ" + : else # older versions (3.72 approx and earlier) MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` @@ -1350,7 +1252,7 @@ AC_ARG_WITH(ruby, AS_HELP_STRING([--without-ruby], [Disable Ruby]) AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN=yes]) # First, check for "--without-ruby" or "--with-ruby=no". -if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Ruby]) RUBY= else @@ -1379,7 +1281,7 @@ if test -n "$RUBY"; then if test -r $i/ruby.h; then AC_MSG_RESULT($i) RUBYINCLUDE="-I$i" - break; + break fi done if test x"$RUBYARCH" != x""; then @@ -1409,10 +1311,10 @@ if test -n "$RUBY"; then else # 1.6.x link = "-l" + c[["RUBY_INSTALL_NAME"]] end - + # Get the target Ruby was built for target = c[["target"]] - + if target == "i386-pc-mswin32" # Need to change msvcrt-ruby*.lib to -lmsvcrt-ruby* ext = File.extname(link) @@ -1429,7 +1331,7 @@ if test -n "$RUBY"; then for i in $dirs; do if (test -r $i/$rb_libruby;) then RUBYLIB="$i" - break; + break fi done fi @@ -1451,6 +1353,7 @@ if test -n "$RUBY"; then esac RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print Config::CONFIG[["CCDLFLAGS"]]') 2>/dev/null` + RUBYSO=.`($RUBY -rrbconfig -e 'print Config::CONFIG[["DLEXT"]]') 2>/dev/null` else AC_MSG_RESULT(could not figure out how to run ruby) RUBYINCLUDE="-I/usr/local/lib/ruby/1.4/arch" @@ -1468,6 +1371,7 @@ AC_SUBST(RUBYINCLUDE) AC_SUBST(RUBYLIB) AC_SUBST(RUBYLINK) AC_SUBST(RUBYCCDLFLAGS) +AC_SUBST(RUBYSO) AC_SUBST(RUBYDYNAMICLINKING) #------------------------------------------------------------------------- @@ -1480,7 +1384,7 @@ AC_ARG_WITH(php, AS_HELP_STRING([--without-php], [Disable PHP]) AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN=yes]) # First, check for "--without-php" or "--with-php=no". -if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling PHP]) PHP= else @@ -1501,7 +1405,7 @@ else esac php_version=`$PHPCONFIG --version 2>/dev/null` case $php_version in - 5*) + 5*) PHPINC=`$PHPCONFIG --includes 2>/dev/null` if test -n "$PHPINC"; then AC_MSG_RESULT($PHPINC) @@ -1528,48 +1432,38 @@ AC_ARG_WITH(ocamlfind,[ --with-ocamlfind=path Set location of ocamlfind],[OCA AC_ARG_WITH(ocamlmktop,[ --with-ocamlmktop=path Set location of ocamlmktop executable],[ OCAMLMKTOP="$withval"], [OCAMLMKTOP=]) # First, check for "--without-ocaml" or "--with-ocaml=no". -if test x"${OCAMLBIN}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling OCaml]) -OCAMLBIN= +if test x"${OCAMLBIN}" = xno -o x"${with_alllang}" = xno ; then + AC_MSG_NOTICE([Disabling OCaml]) + OCAMLBIN= else -AC_MSG_CHECKING(for Ocaml DL load generator) -if test -z "$OCAMLDLGEN"; then -AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :) -else -OCAMLDLGEN="$OCAMLDLGEN" -fi + AC_MSG_CHECKING(for Ocaml DL load generator) + if test -z "$OCAMLDLGEN"; then + AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen, :) + fi -AC_MSG_CHECKING(for Ocaml package tool) -if test -z "$OCAMLFIND"; then -AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :) -else -OCAMLFIND="$OCAMLFIND" -fi + AC_MSG_CHECKING(for Ocaml package tool) + if test -z "$OCAMLFIND"; then + AC_CHECK_PROGS(OCAMLFIND, ocamlfind, :) + fi -AC_MSG_CHECKING(for Ocaml compiler) -if test -z "$OCAMLC"; then -AC_CHECK_PROGS(OCAMLC, ocamlc, :) -else -OCAMLC="$OCAMLC" -fi + AC_MSG_CHECKING(for Ocaml compiler) + if test -z "$OCAMLC"; then + AC_CHECK_PROGS(OCAMLC, ocamlc, :) + fi -AC_MSG_CHECKING(for Ocaml interpreter) -if test "x$OCAMLBIN" = xyes; then -AC_CHECK_PROGS(OCAMLBIN, ocaml, :) -else -OCAMLBIN="$OCAMLBIN" -fi + AC_MSG_CHECKING(for Ocaml interpreter) + if test "x$OCAMLBIN" = xyes; then + AC_CHECK_PROGS(OCAMLBIN, ocaml, :) + fi -AC_MSG_CHECKING(for Ocaml toplevel creator) -if test -z "$OCAMLMKTOP"; then -AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :) -else -OCAMLMKTOP="$OCAMLMKTOP" -fi + AC_MSG_CHECKING(for Ocaml toplevel creator) + if test -z "$OCAMLMKTOP"; then + AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, :) + fi -OCAMLLOC=loc -if test "$OCAMLC" != ":" ; then + OCAMLLOC=loc + if test "$OCAMLC" != ":" ; then AC_MSG_CHECKING(for Ocaml header files) dirs="/usr/lib/ocaml/caml /usr/local/lib/ocaml/caml" dir="`$OCAMLC -where 2>/dev/null`" @@ -1581,7 +1475,7 @@ if test "$OCAMLC" != ":" ; then AC_MSG_RESULT($i) OCAMLEXT="$i" OCAMLINC="-I$OCAMLEXT" - break; + break fi done if test -z "$OCAMLINC"; then @@ -1592,7 +1486,7 @@ if test "$OCAMLC" != ":" ; then OCAMLVER=`$OCAMLC -version | sed -e 's/.*version //g'` AC_COMPARE_VERSION([$OCAMLVER],[3.08.2],[:],[:],[OCAMLLOC=_loc]) AC_MSG_RESULT($OCAMLVER) -fi + fi fi # Disabling ocaml export OCAMLLOC @@ -1624,13 +1518,13 @@ AC_ARG_WITH(pike, AS_HELP_STRING([--without-pike], [Disable Pike]) AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN="$withval"], [PIKEBIN=yes]) # First, check for "--without-pike" or "--with-pike=no". -if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling Pike]) -PIKEBIN= +if test x"${PIKEBIN}" = xno -o x"${with_alllang}" = xno ; then + AC_MSG_NOTICE([Disabling Pike]) + PIKEBIN= else if test "x$PIKEBIN" = xyes; then - AC_CHECK_PROGS(PIKE, pike pike7.6 pike7.4 pike7.2) + AC_CHECK_PROGS(PIKE, pike pike7.8 pike7.6 pike7.4 pike7.2) else PIKE="$PIKEBIN" fi @@ -1638,7 +1532,7 @@ fi # Check for pike-config # Priority: configure option, guessed from $PIKE, search from list -AC_ARG_WITH(pike-config, AS_HELP_STRING([--with-pike-config=path], +AC_ARG_WITH(pike-config, AS_HELP_STRING([--with-pike-config=path], [Set location of pike-config script]), [PIKECONFIG="$withval"], [PIKECONFIG=""]) @@ -1649,25 +1543,28 @@ fi # Check for a --with-pikeincl option to configure # Priority: configure option, info from $PIKECONFIG, guessed by pike script -AC_ARG_WITH(pikeincl, AS_HELP_STRING([--with-pikeincl=path], +AC_ARG_WITH(pikeincl, AS_HELP_STRING([--with-pikeincl=path], [Set location of Pike include directory]), [PIKEINCLUDE="-I$withval"], [PIKEINCLUDE=]) if test -n "$PIKE"; then AC_MSG_CHECKING([for Pike header files]) if test -z "$PIKEINCLUDE" -a -n "$PIKECONFIG"; then - PIKEINCLUDE=`$PIKECONFIG --cflags` + PIKEINCLUDE=`$PIKECONFIG --cflags` fi if test -z "$PIKEINCLUDE" -a -n "$PIKE"; then - PIKEPATH=`which $PIKE` - PIKEINCLUDE=`$PIKE Tools/check-include-path.pike $PIKEPATH` - PIKEINCLUDE="-I$PIKEINCLUDE" + PIKEINCLUDE=`$PIKE -x cflags` + if test -z "$PIKEINCLUDE"; then + PIKEPATH=`which $PIKE` + PIKEINCLUDE=`$PIKE Tools/check-include-path.pike $PIKEPATH` + PIKEINCLUDE="-I$PIKEINCLUDE" + fi fi if test -z "$PIKEINCLUDE"; then - AC_MSG_RESULT(not found) + AC_MSG_RESULT(not found) else - AC_MSG_RESULT($PIKEINCLUDE) + AC_MSG_RESULT($PIKEINCLUDE) fi fi fi @@ -1691,7 +1588,7 @@ AC_ARG_WITH(chicken, AS_HELP_STRING([--without-chicken], [Disable CHICKEN]) AS_HELP_STRING([--with-chicken=path], [Set location of CHICKEN executable]),[ CHICKENBIN="$withval"], [CHICKENBIN=yes]) # First, check for "--without-chicken" or "--with-chicken=no". -if test x"${CHICKENBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${CHICKENBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CHICKEN]) else @@ -1787,7 +1684,7 @@ AC_ARG_WITH(cil-interpreter, [ --with-cil-interpreter=path Set location of AC_ARG_WITH(csharp-compiler, [ --with-csharp-compiler=path Set location of CSharp compiler],[CSHARPCOMPILERBIN="$withval"], [CSHARPCOMPILERBIN=]) # First, check for "--without-csharp" or "--with-csharp=no". -if test x"${with_csharp}" = xno -o x"${with_alllang}" = xno ; then +if test x"${with_csharp}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CSharp]) CSHARPCOMPILER= else @@ -1827,7 +1724,7 @@ if test -z "$CSHARPBIN" ; then # The Mono compiler should emit: Mono C# compiler version a.b.c.d csharp_version_raw=`(mcs --version) 2>/dev/null` csharp_version_searched=`(mcs --version | sed -e "/C#/b" -e "/Mono/b" -e d) 2>/dev/null` # return string if contains 'Mono' or 'C#' - CSHARPCOMPILER=""; + CSHARPCOMPILER="" if test -n "$csharp_version_raw" ; then if test "$csharp_version_raw" = "$csharp_version_searched" ; then CSHARPCOMPILER="mcs" @@ -1840,7 +1737,7 @@ if test -z "$CSHARPBIN" ; then if test "mcs" = "$CSHARPCOMPILER" || test "gmcs" = "$CSHARPCOMPILER"; then AC_CHECK_PROGS(CSHARPCILINTERPRETER, mono) # Mono JIT CSHARPCILINTERPRETER_FLAGS="--debug" - else + else if test "csc" = "$CSHARPCOMPILER"; then CSHARPPATHSEPARATOR="\\\\" CSHARPCYGPATH_W='cygpath -w' @@ -1915,7 +1812,7 @@ AC_ARG_WITH(lualib,[ --with-lualib=path Set location of Lua library direct LUALIB="$withval"], [LUALIB=]) # First, check for "--without-lua" or "--with-lua=no". -if test x"${LUABIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${LUABIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Lua]) else @@ -1956,8 +1853,8 @@ if test "$LUABIN"; then else LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=package.loadlib("no_such_lib","") if c~="absent" then print "1" end'` fi - - if test -z "$LUADYNAMICLOADLIB"; then + + if test -z "$LUADYNAMICLOADLIB"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) @@ -1984,7 +1881,7 @@ else if test -r $i/lua.h; then AC_MSG_RESULT($i/lua.h) LUAFLAGS="$ISYSTEM$i" - break; + break fi done if test -z "$LUAFLAGS"; then @@ -1997,7 +1894,7 @@ fi # look for the library files & set LUALINK accordingly # will clear LUABIN if not present lua_save_LIBS=$LIBS # the code seems to disrupt LIBS, so saving - + if test -n "$LUALIB"; then AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=]) else @@ -2028,7 +1925,7 @@ AC_ARG_WITH(allegrocl, AS_HELP_STRING([--without-allegrocl], [Disable Allegro CL AS_HELP_STRING([--with-allegrocl=path], [Set location of Allegro CL executable (alisp)]),[ ALLEGROCLBIN="$withval"], [ALLEGROCLBIN=yes]) # First, check for "--without-allegrocl" or "--with-allegrocl=no". -if test x"${ALLEGROCLBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${ALLEGROCLBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Allegro CL]) ALLEGROCLBIN= else @@ -2051,7 +1948,7 @@ AC_ARG_WITH(clisp, AS_HELP_STRING([--without-clisp], [Disable CLISP]) AS_HELP_STRING([--with-clisp=path], [Set location of CLISP executable (clisp)]),[ CLISPBIN="$withval"], [CLISPBIN=yes]) # First, check for "--without-clisp" or "--with-clisp=no". -if test x"${CLISPBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${CLISPBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling CLISP]) CLISPBIN= else @@ -2074,7 +1971,7 @@ AC_ARG_WITH(r, AS_HELP_STRING([--without-r], [Disable R]) AS_HELP_STRING([--with-r=path], [Set location of R executable (r)]),[ RBIN="$withval"], [RBIN=yes]) # First, check for "--without-r" or "--with-r=no". -if test x"${RBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${RBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling R]) RBIN= else @@ -2094,13 +1991,14 @@ AC_SUBST(RBIN) AC_ARG_WITH(go, AS_HELP_STRING([--without-go], [Disable Go]) AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN=yes]) -if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then +if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Go]) GO= GOC= GO1=false GOGCC=false GOOPT= + GOVERSIONOPTION= else if test "x$GOBIN" = xyes; then @@ -2112,11 +2010,13 @@ else GOGCC=false GO1=false GOOPT= + GOVERSIONOPTION= if test -n "$GO" ; then if $GO --help 2>/dev/null | grep gccgo >/dev/null 2>&1 ; then GOGCC=true + GOVERSIONOPTION=--version AC_MSG_CHECKING([whether gccgo version is too old]) - go_version=`$GO --version | sed -e 's/[^0-9]* \([0-9.]*\) .*$/\1/' -e 's/[.]//g'` + go_version=`$GO $GOVERSIONOPTION | sed -e 's/[^0-9]* \([0-9.]*\) .*$/\1/' -e 's/[.]//g'` if test "$go_version" -lt 470; then AC_MSG_RESULT([yes - minimum version is 4.7.0]) else @@ -2134,8 +2034,9 @@ else fi elif test "`echo $GO | sed -e 's|.*/||'`" = "go"; then GO1=true + GOVERSIONOPTION=version GOC=$(sh -c "$(go env) && echo \$GOCHAR")c - go_version=$($GO version | sed -e 's/go version //') + go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //') case $go_version in go1.0*) GOOPT="-intgosize 32" ;; *) if test "$GOC" = "6c"; then @@ -2147,8 +2048,9 @@ else esac else GOC=`echo $GO | sed -e 's/g/c/'` + GOVERSIONOPTION=-V AC_MSG_CHECKING([whether Go ($GO) version is too old]) - go_version=`$GO -V 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'` + go_version=`$GO $GOVERSIONOPTION 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'` go_min_version=7077 if test "$go_version" != "" -a "$go_version" -lt $go_min_version; then AC_MSG_RESULT([yes - minimum version is $go_min_version]) @@ -2166,6 +2068,7 @@ AC_SUBST(GO) AC_SUBST(GOC) AC_SUBST(GO1) AC_SUBST(GOOPT) +AC_SUBST(GOVERSIONOPTION) #---------------------------------------------------------------- # Look for D @@ -2277,14 +2180,14 @@ AC_SUBST(SKIP_OCTAVE) SKIP_PYTHON= -if (test -z "$PYINCLUDE" || test -z "$PYLIB") && - (test -z "$PY3INCLUDE" || test -z "PY3LIB") ; then +if (test -z "$PYINCLUDE") && + (test -z "$PY3INCLUDE") ; then SKIP_PYTHON="1" fi AC_SUBST(SKIP_PYTHON) SKIP_PYTHON3= -if test -z "$PY3INCLUDE" || test -z "$PY3LIB" ; then +if test -z "$PY3INCLUDE" ; then SKIP_PYTHON3="1" fi AC_SUBST(SKIP_PYTHON3) @@ -2297,17 +2200,11 @@ AC_SUBST(SKIP_JAVA) SKIP_GUILE= -if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_GH_INTERFACE"; then +if test -z "$GUILE" || test -z "$GUILE_LIBS" ; then SKIP_GUILE="1" fi AC_SUBST(SKIP_GUILE) -SKIP_GUILESCM= -if test -z "$GUILEINCLUDE" || test -z "$GUILELIB" || test -z "$GUILE_SCM_INTERFACE"; then - SKIP_GUILESCM="1" -fi -AC_SUBST(SKIP_GUILESCM) - SKIP_MZSCHEME= if test -z "$MZC" || test -z "$MZDYNOBJ" ; then @@ -2337,7 +2234,7 @@ fi AC_SUBST(SKIP_OCAML) -SKIP_PIKE="1" # Always skipped! +SKIP_PIKE= if test -z "$PIKE" || test -z "$PIKEINCLUDE" ; then SKIP_PIKE="1" fi @@ -2477,13 +2374,11 @@ AC_CONFIG_FILES([ \ swig.spec \ Source/Makefile \ Examples/Makefile \ - Examples/guile/Makefile \ Examples/xml/Makefile \ Examples/test-suite/chicken/Makefile \ Examples/test-suite/csharp/Makefile \ Examples/test-suite/d/Makefile \ Examples/test-suite/guile/Makefile \ - Examples/test-suite/guilescm/Makefile \ Examples/test-suite/java/Makefile \ Examples/test-suite/mzscheme/Makefile \ Examples/test-suite/ocaml/Makefile \ @@ -2507,4 +2402,4 @@ AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) AC_CONFIG_FILES([CCache/ccache_swig_config.h]) AC_OUTPUT -dnl configure.in ends here +dnl configure.ac ends here