Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into travis-osx

* master:
  Add 3.0.2 release date
  changes file updates
  CHANGES update
  Add runtime test for %extend and nested union
  Fix bug in DohNewStringWithSize(): guarantee string is nul-terminated
  Fix std::vector<bool> compile problems on OSX for Javascript
  test fixed
  Octave: remove deprecated -global/-noglobal command-line arguments
  Octave: use common example.mk for examples, patterned after javascript
  Octave: whitespace/indentation cleanup of octave.cxx
  Octave: remove Python code from std_carray.i
  Octave: ignore generated files
  .gitignore: add Source/TAGS
  Update AX_BOOST_BASE autoconf macro to serial 23
  Search for 64bit webkit during configure
  Fix cleaning of Python runme.py scripts for in-source-tree builds
  check-maintainer-clean: print skipping message for in-source-tree builds
  Fix errors test-suite on windows
  Correct infinity testcase
  Fix infinity testcase on windows
  Add check-maintainer-clean target: fails if files are missed by maintainer-clean
  Set SRCDIR when calling test-suite clean targets, in case it's needed
  Fully clean Python examples and test-suite
  Fully clean PHP test-suite
  Fully clean Javascript test-suite with jsc and v8
  Fix Javascript examples so that "make clean" works properly with node
  Fully clean Go test-suite
  Distclean Tools/javascript
  CCache: always generate docs in source directory
  Test-suite makefile fixes for Windows
  %extend symbols for nested structs get into a wrong C symbol table
  More tests for equality operator overloading
  Moving variable declaration to the beginning of the block
  Add default __eq implementation
  Bump version to 3.0.2
  Fix unused variable warning in Lua bindings
  Javascript: fixed a missing link in documentation.
  Add Javascript to announcements
  Add 3.0.1 release date
  Javascript html links and typo fixes
  Python 3 byte string output: use errors="surrogateescape" change note
  Warning fixes compiling with Visual Studio
  Javascript: added a link to the v8 web-site to the documentation.
  Javascript: updated documentation about known issues.
  JavascriptCore: updated documentation about how to register an initialized module.
  JavascriptCore: added documentation about how to extract details from JSC errors.
  JavaScriptCore: Improved code that uses JSObjectMakeError instead of JSValueToObject to create the exception object.
  JavaScriptCore: Reverted 2 of the JSValueMakeUndefined replacements because those functions are tied to JSObjectRef instead of JSValueRef. The C compiler will allow this, but C++ will reject the conversion.
  JavaScriptCore: Returning NULL for wrapper functions that expect JSValueRef may crash program.
  JavaScriptCore: Fixed exception object so sourceURL (file name), line (number), and message can be recovered.
  Javascript: added a section about known issues.
  • Loading branch information...
commit 73047f444cc21d0bcee9c80561b6ce19993dfec7 2 parents 530b9f5 + 37c09b0
@wsfulton wsfulton authored
Showing with 1,024 additions and 886 deletions.
  1. +6 −0 .gitignore
  2. +1 −1  .travis.yml
  3. +9 −9 ANNOUNCE
  4. +9 −9 CCache/Makefile.in
  5. +84 −0 CHANGES
  6. +12 −67 CHANGES.current
  7. +3 −1 Doc/Manual/Contents.html
  8. +120 −28 Doc/Manual/Javascript.html
  9. +1 −1  Doc/Manual/Python.html
  10. +2 −2 Doc/Manual/Sections.html
  11. +6 −5 Examples/Makefile.in
  12. +1 −1  Examples/javascript/class/binding.gyp.in
  13. +1 −1  Examples/javascript/enum/binding.gyp.in
  14. +1 −1  Examples/javascript/exception/binding.gyp.in
  15. +1 −1  Examples/javascript/pointer/binding.gyp.in
  16. +1 −1  Examples/javascript/reference/binding.gyp.in
  17. +1 −1  Examples/javascript/simple/binding.gyp.in
  18. +1 −1  Examples/javascript/variables/binding.gyp.in
  19. +2 −16 Examples/octave/callback/Makefile
  20. +2 −16 Examples/octave/class/Makefile
  21. +2 −16 Examples/octave/constants/Makefile
  22. +2 −14 Examples/octave/contract/Makefile
  23. +2 −16 Examples/octave/enum/Makefile
  24. +32 −0 Examples/octave/example.mk
  25. +2 −16 Examples/octave/extend/Makefile
  26. +2 −14 Examples/octave/funcptr/Makefile
  27. +2 −14 Examples/octave/funcptr2/Makefile
  28. +2 −16 Examples/octave/functor/Makefile
  29. +6 −17 Examples/octave/module_load/Makefile
  30. +2 −16 Examples/octave/operator/Makefile
  31. +2 −14 Examples/octave/pointer/Makefile
  32. +2 −16 Examples/octave/reference/Makefile
  33. +2 −14 Examples/octave/simple/Makefile
  34. +2 −16 Examples/octave/template/Makefile
  35. +2 −14 Examples/octave/variables/Makefile
  36. +5 −0 Examples/python/import_packages/Makefile
  37. +1 −1  Examples/test-suite/allegrocl/Makefile.in
  38. +1 −1  Examples/test-suite/cffi/Makefile.in
  39. +1 −1  Examples/test-suite/chicken/Makefile.in
  40. +1 −1  Examples/test-suite/clisp/Makefile.in
  41. +1 −0  Examples/test-suite/common.mk
  42. +67 −0 Examples/test-suite/equality.i
  43. +11 −12 Examples/test-suite/errors/Makefile.in
  44. +2 −1  Examples/test-suite/go/Makefile.in
  45. +1 −1  Examples/test-suite/guile/Makefile.in
  46. +21 −7 Examples/test-suite/infinity.i
  47. +7 −0 Examples/test-suite/java/nested_extend_c_runme.java
  48. +12 −4 Examples/test-suite/java/preproc_line_file_runme.java
  49. +12 −4 Examples/test-suite/javascript/Makefile.in
  50. +1 −0  Examples/test-suite/javascript/infinity_runme.js
  51. +1 −1  Examples/test-suite/lua/Makefile.in
  52. +11 −0 Examples/test-suite/lua/cpp_basic_runme.lua
  53. +47 −0 Examples/test-suite/lua/equality_runme.lua
  54. +1 −1  Examples/test-suite/mzscheme/Makefile.in
  55. +7 −0 Examples/test-suite/nested_extend_c.i
  56. +1 −1  Examples/test-suite/ocaml/Makefile.in
  57. +1 −1  Examples/test-suite/octave/Makefile.in
  58. +1 −1  Examples/test-suite/perl5/Makefile.in
  59. +8 −2 Examples/test-suite/php/Makefile.in
  60. +1 −1  Examples/test-suite/pike/Makefile.in
  61. +3 −4 Examples/test-suite/python/Makefile.in
  62. +1 −1  Examples/test-suite/r/Makefile.in
  63. +1 −1  Examples/test-suite/ruby/Makefile.in
  64. +1 −1  Examples/test-suite/tcl/Makefile.in
  65. +1 −1  Examples/test-suite/uffi/Makefile.in
  66. +3 −3 Lib/javascript/jsc/javascriptcode.swg
  67. +18 −3 Lib/javascript/jsc/javascriptrun.swg
  68. +1 −1  Lib/javascript/jsc/std_vector.i
  69. +1 −1  Lib/javascript/v8/std_vector.i
  70. +39 −25 Lib/lua/luarun.swg
  71. +1 −1  Lib/lua/luaruntime.swg
  72. +0 −56 Lib/octave/std_carray.i
  73. +15 −1 Makefile.in
  74. +1 −1  README
  75. +3 −0  RELEASENOTES
  76. +1 −0  Source/DOH/string.c
  77. +13 −13 Source/Modules/javascript.cxx
  78. +8 −6 Source/Modules/nested.cxx
  79. +338 −345 Source/Modules/octave.cxx
  80. +18 −3 Tools/config/ax_boost_base.m4
  81. +3 −0  Tools/javascript/Makefile.in
  82. +3 −3 configure.ac
View
6 .gitignore
@@ -85,10 +85,12 @@ swig.spec
.dirstamp
CCache/ccache-swig
CCache/ccache-swig.1
+CCache/web/ccache-man.html
Lib/swigwarn.swg
Source/CParse/parser.c
Source/CParse/parser.h
Source/eswig
+Source/TAGS
swig
Tools/javascript/javascript
@@ -123,6 +125,7 @@ Examples/test-suite/tcl/*/
Examples/test-suite/uffi/*/
*_wrap.c
*_wrap.cxx
+*-gypcopy.cxx
# C# generated files
*_runme.exe.mdb
@@ -131,6 +134,9 @@ Examples/test-suite/uffi/*/
# Javascript generated files
*.gyp
+# Octave generated files
+swigexample*.oct
+
# Python generated files, based on:
# https://github.com/github/gitignore/blob/master/Python.gitignore
*.py[cod]
View
2  .travis.yml
@@ -49,7 +49,7 @@ script:
- if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples CFLAGS="${CFLAGS_EXAMPLES[$SWIGLANG]}" CXXFLAGS="${CXXFLAGS_EXAMPLES[$SWIGLANG]}"; fi
- if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi
- echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r'
- - make maintainer-clean && find . -type f | sed 's/^/File left after maintainer-clean - /' && ../../configure $CONFIGOPTS
+ - make check-maintainer-clean && ../../configure $CONFIGOPTS
- echo -en 'travis_fold:end:script.3\\r'
branches:
only:
View
18 ANNOUNCE
@@ -1,8 +1,8 @@
-*** ANNOUNCE: SWIG 3.0.1 (in progress) ***
+*** ANNOUNCE: SWIG 3.0.2 (4 Jun 2014) ***
http://www.swig.org
-We're pleased to announce SWIG-3.0.1, the latest SWIG release.
+We're pleased to announce SWIG-3.0.2, the latest SWIG release.
What is SWIG?
=============
@@ -10,22 +10,22 @@ What is SWIG?
SWIG is a software development tool that reads C/C++ header files and
generates the wrapper code needed to make C and C++ code accessible
from other programming languages including Perl, Python, Tcl, Ruby,
-PHP, C#, Go, Java, Lua, Scheme (Guile, MzScheme, CHICKEN), D, Ocaml,
-Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL, CFFI, UFFI).
-SWIG can also export its parse tree in the form of XML and Lisp
-s-expressions. Major applications of SWIG include generation of
-scripting language extension modules, rapid prototyping, testing,
+PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN),
+D, Ocaml, Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL,
+CFFI, UFFI). SWIG can also export its parse tree in the form of XML
+and Lisp s-expressions. Major applications of SWIG include generation
+of scripting language extension modules, rapid prototyping, testing,
and user interface development for large C/C++ systems.
Availability
============
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-3.0.1.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-3.0.2.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-3.0.1.zip
+ http://prdownloads.sourceforge.net/swig/swigwin-3.0.2.zip
Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html.
View
18 CCache/Makefile.in
@@ -32,27 +32,27 @@ Makefile: $(srcdir)/Makefile.in ./config.status
$(SHELL) ./config.status
# Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile
-docs: $(PACKAGE_NAME).1 web/ccache-man.html
+docs: $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html
$(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
-$(PACKAGE_NAME).1: ccache.yo
- -yodl2man -o $(PACKAGE_NAME).1 $(srcdir)/ccache.yo
+$(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo
+ -yodl2man -o $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/ccache.yo
-web/ccache-man.html: ccache.yo
- yodl2html -o web/ccache-man.html ccache.yo
+$(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo
+ yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo
-install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
+install: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1
@echo "Installing $(PACKAGE_NAME)"
@echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)"
${INSTALLCMD} -d $(DESTDIR)${bindir}
${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
@echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1"
${INSTALLCMD} -d $(DESTDIR)${mandir}/man1
- ${INSTALLCMD} -m 644 $(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
+ ${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
-uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
+uninstall: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1
rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
@@ -69,7 +69,7 @@ distclean: clean
/bin/rm -rf autom4te.cache
maintainer-clean: distclean
- /bin/rm -f $(PACKAGE_NAME).1 web/ccache-man.html
+ /bin/rm -f $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html
# FIXME: To fix this, test.sh needs to be able to take ccache from the
View
84 CHANGES
@@ -3,6 +3,90 @@ 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 3.0.1 (27 May 2014)
+===========================
+
+2014-05-25: hfalcic
+ [Python] Python 3 byte string output: use errors="surrogateescape"
+ if available on the version of Python that's in use. This allows
+ obtaining the original byte string (and potentially trying a fallback
+ encoding) if the bytes can't be decoded as UTF-8.
+
+ Previously, a UnicodeDecodeError would be raised with no way to treat
+ the data as bytes or try another codec.
+
+2014-05-18: vkalinin
+ Bug #175 - Restore %extend to work for unnamed nested structures by using a C
+ symbol comprising the outer structure name and unnamed variable instance name.
+
+2014-05-15: kwwette
+ Add #166 - 'make check' now works out of source. This required te examples to build
+ out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript,
+ Lua, Octave, Perl, PHP, Python, Ruby and Tcl.
+
+2014-05-01: Oliver Buchtala
+ Javascript support added, see Javascript chapter in the documentation.
+
+2014-05-01: olly
+ [PHP] The generated __isset() method now returns true for read-only properties.
+
+2014-04-24: kwwette
+ [Go] Fix go ./configure parsing of gccgo --version, and
+ goruntime.swg typo in __GNUC_PATCHLEVEL__ (SF Bug #1298)
+
+2014-04-24: kwwette
+ Fix {python|perl5|ruby|tcl}/java examples
+
+ In Lib/gcj/cni.i, for compatibility with newer gcj versions:
+
+ - remove JvAllocObject() which gcj no longer defines, from gcj Changelog:
+ 2004-04-16 Bryce McKinlay <mckinlay@redhat.com>
+ * gcj/cni.h (JvAllocObject): Remove these obsolete,
+ undocumented CNI calls.
+
+ - change JvCreateJavaVM() argument from void* to JvVMInitArgs*, from gcj Changelog:
+ 2005-02-23 Thomas Fitzsimmons <fitzsim@redhat.com>
+ PR libgcj/16923
+ ...
+ (JvCreateJavaVM): Declare vm_args as JvVMInitArgs* rather than void*.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2014-04-08: wsfulton
+ SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
+
+2014-04-08: wsfulton
+ [Java C#] Enums which have been ignored via %ignore and are subsequently
+ used are handled slightly differently. Type wrapper classes are now generated
+ which are effectively a wrapper of an empty enum. Previously in Java uncompilable
+ code was generated and in C# an int was used.
+
+2014-04-04: wsfulton
+ Fix regression in 3.0.0 where legal code following an operator<< definition might
+ give a syntax error. SF Bug #1365.
+
+2014-04-03: olly
+ [PHP] Fix wrapping director constructors with default parameters
+ with a ZTS-enabled build of PHP.
+
+2014-04-02: olly
+ [PHP] Pass the ZTS context we already have to avoid needing to
+ call TSRMLS_FETCH, which is relatively expensive.
+
+2014-04-02: olly
+ [PHP] Pass ZTS context through to t_output_helper() so it works
+ with a ZTS-enabled build of PHP. Reported by Pierre Labastie in
+ github PR#155.
+
+2014-03-28: wsfulton
+ [Java C# D Go] Fixes for C enums used in an API and the definition of the enum
+ has not been parsed. For D, this fixes a segfault in SWIG. The other languages
+ now produce code that compiles, although the definition of the enum is needed
+ in order to use the enum properly from the target language.
+
+2014-03-23: v-for-vandal
+ [Lua] Fix for usage of snprintf in Lua runtime which Visual Studio does not have.
+
Version 3.0.0 (16 Mar 2014)
===========================
View
79 CHANGES.current
@@ -2,77 +2,22 @@ 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 3.0.1 (in progress)
+Version 3.0.2 (4 Jun 2014)
===========================
-2014-05-18: vkalinin
- Bug #175 - Restore %extend to work for unnamed nested structures by using a C
- symbol comprising the outer structure name and unnamed variable instance name.
+2014-06-02: v-for-vandal
+ [Lua] Pull request #176:
+ If class has no __eq implemented, then default __eq is generated.
+ Default __eq compares actual pointers stored inside Lua userdata.
-2014-05-15: kwwette
- Add #166 - 'make check' now works out of source. This required te examples to build
- out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript,
- Lua, Octave, Perl, PHP, Python, Ruby and Tcl.
+2014-06-02: vkalinin
+ Fix #183 - %extend and unnamed nested structs
-2014-05-01: Oliver Buchtala
- Javascript support added, see Javascript chapter in the documentation.
+2014-05-28: kwwette
+ Fix install failure when using an 'out of source' build using the shipped
+ tarball - regression introduced in swig-3.0.1.
-2014-05-01: olly
- [PHP] The generated __isset() method now returns true for read-only properties.
-
-2014-04-24: kwwette
- [Go] Fix go ./configure parsing of gccgo --version, and
- goruntime.swg typo in __GNUC_PATCHLEVEL__ (SF Bug #1298)
-
-2014-04-24: kwwette
- Fix {python|perl5|ruby|tcl}/java examples
-
- In Lib/gcj/cni.i, for compatibility with newer gcj versions:
-
- - remove JvAllocObject() which gcj no longer defines, from gcj Changelog:
- 2004-04-16 Bryce McKinlay <mckinlay@redhat.com>
- * gcj/cni.h (JvAllocObject): Remove these obsolete,
- undocumented CNI calls.
-
- - change JvCreateJavaVM() argument from void* to JvVMInitArgs*, from gcj Changelog:
- 2005-02-23 Thomas Fitzsimmons <fitzsim@redhat.com>
- PR libgcj/16923
- ...
- (JvCreateJavaVM): Declare vm_args as JvVMInitArgs* rather than void*.
+2014-05-24: kwwette
+ [Octave] Remove deprecated -global/-noglobal command-line arguments
*** POTENTIAL INCOMPATIBILITY ***
-
-2014-04-08: wsfulton
- SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
-
-2014-04-08: wsfulton
- [Java C#] Enums which have been ignored via %ignore and are subsequently
- used are handled slightly differently. Type wrapper classes are now generated
- which are effectively a wrapper of an empty enum. Previously in Java uncompilable
- code was generated and in C# an int was used.
-
-2014-04-04: wsfulton
- Fix regression in 3.0.0 where legal code following an operator<< definition might
- give a syntax error. SF Bug #1365.
-
-2014-04-03: olly
- [PHP] Fix wrapping director constructors with default parameters
- with a ZTS-enabled build of PHP.
-
-2014-04-02: olly
- [PHP] Pass the ZTS context we already have to avoid needing to
- call TSRMLS_FETCH, which is relatively expensive.
-
-2014-04-02: olly
- [PHP] Pass ZTS context through to t_output_helper() so it works
- with a ZTS-enabled build of PHP. Reported by Pierre Labastie in
- github PR#155.
-
-2014-03-28: wsfulton
- [Java C# D Go] Fixes for C enums used in an API and the definition of the enum
- has not been parsed. For D, this fixes a segfault in SWIG. The other languages
- now produce code that compiles, although the definition of the enum is needed
- in order to use the enum properly from the target language.
-
-2014-03-23: v-for-vandal
- [Lua] Fix for usage of snprintf in Lua runtime which Visual Studio does not have.
View
4 Doc/Manual/Contents.html
@@ -1056,7 +1056,7 @@
<ul>
<li><a href="Javascript.html#Javascript_running_swig">Running SWIG</a>
<li><a href="Javascript.html#Javascript_running_tests_examples">Running Tests and Examples</a>
-<li><a href="Javascript.html#Javascript_future_work">Future work</a>
+<li><a href="Javascript.html#Javascript_known_issues">Known Issues</a>
</ul>
<li><a href="Javascript.html#Javascript_integration">Integration</a>
<ul>
@@ -1082,6 +1082,7 @@
<li><a href="Javascript.html#Javascript_code_templates">Code Templates</a>
<li><a href="Javascript.html#Javascript_emitter">Emitter</a>
<li><a href="Javascript.html#Javascript_emitter_states">Emitter states</a>
+<li><a href="Javascript.html#Javascript_jsc_exceptions">Handling Exceptions in JavascriptCore</a>
</ul>
</ul>
</div>
@@ -1566,6 +1567,7 @@
<li><a href="Python.html#Python_nn74">Function annotation</a>
<li><a href="Python.html#Python_nn75">Buffer interface</a>
<li><a href="Python.html#Python_nn76">Abstract base classes</a>
+<li><a href="Python.html#Python_nn77">Byte string output conversion</a>
</ul>
</ul>
</div>
View
148 Doc/Manual/Javascript.html
@@ -6,7 +6,7 @@
</head>
<body>
-<H1><a name="Javascript_nn1"></a>26 SWIG and Javascript</H1>
+<H1><a name="Javascript"></a>26 SWIG and Javascript</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -15,7 +15,7 @@
<ul>
<li><a href="#Javascript_running_swig">Running SWIG</a>
<li><a href="#Javascript_running_tests_examples">Running Tests and Examples</a>
-<li><a href="#Javascript_future_work">Future work</a>
+<li><a href="#Javascript_known_issues">Known Issues</a>
</ul>
<li><a href="#Javascript_integration">Integration</a>
<ul>
@@ -41,6 +41,7 @@
<li><a href="#Javascript_code_templates">Code Templates</a>
<li><a href="#Javascript_emitter">Emitter</a>
<li><a href="#Javascript_emitter_states">Emitter states</a>
+<li><a href="#Javascript_jsc_exceptions">Handling Exceptions in JavascriptCore</a>
</ul>
</ul>
</div>
@@ -56,7 +57,7 @@
<p>Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development.
Javascript has gone beyond being a browser-based scripting language and with <a href="http://nodejs.org">node.js</a>, it is also used as a backend development language.</p>
<p>Native Javascript extensions can be used for applications that embed a web-browser view or that embed a Javascript engine (such as <em>node.js</em>). Extending a general purpose web-browser is not possible as this would be a severe security issue.</p>
-<p>SWIG Javascript currently supports <strong>JavascriptCore</strong>, the Javascript engine used by <code>Safari/Webkit</code>, and <strong>v8</strong>, which is used by <code>Chromium</code> and <code>node.js</code>.</p>
+<p>SWIG Javascript currently supports <strong>JavascriptCore</strong>, the Javascript engine used by <code>Safari/Webkit</code>, and <a href="https://developers.google.com/v8"><strong>v8</strong></a>, which is used by <code>Chromium</code> and <code>node.js</code>.</p>
<p><a href="http://www.webkit.org/">WebKit</a> is a modern browser implementation available as open-source which can be embedded into an application.
With <a href="https://github.com/rogerwang/node-webkit">node-webkit</a> there is a platform which uses Google's <code>Chromium</code> as Web-Browser widget and <code>node.js</code> for javascript extensions.
</p>
@@ -128,33 +129,24 @@
<pre>
$ make check-javascript-test-suite ENGINE=jsc</pre>
</div>
-<p>Tests should run without any problems, i.e., have been tried out, on the following platforms/interpreters:</p>
-<div class="code">
-<pre>
-- Ubuntu Precise 12.04 64bit
- - JavascriptCore (Webkit 1.8.3)
- - Node.js (0.10.26)
- - v8 (3.7.12)
-- Ubuntu Saucy 13.10 64bit
- - JavascriptCore (Webkit 1.10.2)
- - Node.js
- - v8 (3.14.5)
-- Mac OSX Mountain Lion 10.8
- - JavascriptCore (built-in)
- - Node.js
-- Windows 7 64bit (VS 2010)
- - Node.js</pre>
-</div>
-<H3><a name="Javascript_future_work"></a>26.2.3 Future work</H3>
+<H3><a name="Javascript_known_issues"></a>26.2.3 Known Issues</H3>
+
+<p>At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.</p>
-<p>The Javascript module is not yet as mature as other modules and some things are still missing. As it makes use of SWIG's Unified Typemap Library (UTL), many typemaps are inherited. We could work on that if requested:</p>
<ul>
-<li><p>More typemaps: compared to other modules there are only a few typemaps implemented. For instance a lot of the <code>std_*.i</code> typemaps are missing, such as <code>std_iostream</code>, for instance.</p></li>
-<li><p>Director support: this would allow to extend a C++ abstract base class in Javascript. A pragmatic intermediate step for the most important usecase would be to support Javascript callbacks as arguments.</p></li>
+ <li><p>Default optional arguments do not work for all targeted interpreters</p></li>
+ <li><p>Multiple output arguments do not work for JSC</p></li>
+ <li><p>C89 incompatibily: the JSC generator might still generate C89 violating code</p></li>
+ <li><p><code>long long</code> is not supported</p></li>
+ <li><p><code>%native</code> is not supported</p></li>
+ <li><p>Javascript callbacks are not supported</p></li>
+ <li><p><code>instanceOf</code> does not work under JSC</p></li>
</ul>
+<p>The primary development environment has been Linux (Ubuntu 12.04). Windows and OSX have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.</p>
+
<H2><a name="Javascript_integration"></a>26.3 Integration</H2>
@@ -232,13 +224,21 @@
<pre>
#import "appDelegate.h"
-extern bool example_initialize(JSGlobalContextRef context);
+extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports);
@implementation ExampleAppDelegate
@synthesize webView;
+- (void)addGlobalObject:(JSContextRef) context:(NSString *)objectName:(JSObjectRef) theObject {
+ JSObjectRef global = JSContextGetGlobalObject(context);
+ JSStringRef objectJSName = JSStringCreateWithCFString( (CFStringRef) objectName )
+ if ( objectJSName != NULL ) {
+ JSObjectSetProperty(context, global, objectJSName, theObject, kJSPropertyAttributeReadOnly, NULL);
+ JSStringRelease( objectJSName );
+ }
+}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
@@ -249,7 +249,11 @@
WebFrame *webframe = [webView mainFrame];
JSGlobalContextRef context = [webframe globalContext];
- example_initialize(context);
+ JSObjectRef example;
+ example_initialize(context, &amp;example);
+ [self addGlobalObject:context:@"example":example]
+
+ JSObjectSetProperty(context, global, JSStringRef propertyName, example, JSPropertyAttributes attributes, NULL);
[ [webView mainFrame] loadRequest:
[NSURLRequest requestWithURL: [NSURL URLWithString:url] ]
@@ -282,7 +286,13 @@
WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
WebFrame *webframe = webkit_web_view_get_main_frame(webView);
JSGlobalContextRef context = webkit_web_frame_get_global_context(webFrame);
- example_initialize(context);
+ JSObjectRef global = JSContextGetGlobalObject(context);
+
+ JSObjectRef exampleModule;
+ example_initialize(context, &amp;exampleModule);
+ JSStringRef jsName = JSStringCreateWithUTF8CString("example");
+ JSObjectSetProperty(context, global, jsName, exampleModule, kJSPropertyAttributeReadOnly, NULL);
+ JSStringRelease(jsName);
...
@@ -323,7 +333,7 @@
<p>
The configuration file essentially conforms to <code>node.js</code> syntax.
-It has some extras to configure <code>node-webkit</code>. See the <a href="">Manifest</a> specification for more details.
+It has some extras to configure <code>node-webkit</code>. See the <a href="https://github.com/rogerwang/node-webkit/wiki/Manifest-format">Manifest</a> specification for more details.
</p>
<p>
@@ -880,5 +890,87 @@
state.clazz(NAME, Getattr(n, "sym:name"));</pre>
</div>
<p>State information can be retrieved using <code>state.clazz(NAME)</code> or with <code>Getattr</code> on <code>state.clazz()</code> which actually returns a <code>Hash</code> instance.</p>
+
+
+<H3><a name="Javascript_jsc_exceptions"></a>26.5.5 Handling Exceptions in JavascriptCore</H3>
+
+
+<p>Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.</p>
+<div class="code">
+<pre>
+void script_exception_to_string(JSContextRef js_context,JSValueRef exception_value_ref,char* return_error_string, int return_error_string_max_length)
+{
+ JSObjectRef exception_object;
+ JSValueRef value_ref;
+ JSStringRef jsstring_property_name = NULL;
+ JSValueRef temporary_exception = NULL;
+ JSStringRef js_return_string = NULL;
+ size_t bytes_needed;
+ char* c_result_string = NULL;
+ exception_object = JSValueToObject(js_context, exception_value_ref, NULL);
+
+ /* source url */
+ strcpy(return_error_string,&quot;[&quot;);
+ jsstring_property_name = JSStringCreateWithUTF8CString(&quot;sourceURL&quot;);
+ value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &amp;temporary_exception);
+ JSStringRelease(jsstring_property_name);
+ js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
+ bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
+ c_result_string = (char*)calloc(bytes_needed, sizeof(char));
+ JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
+ JSStringRelease(js_return_string);
+ strncat(return_error_string, c_result_string, return_error_string_max_length-1);
+ free(c_result_string);
+
+ strncat(return_error_string, &quot;:&quot;, return_error_string_max_length-1);
+
+ /* line number */
+
+ jsstring_property_name = JSStringCreateWithUTF8CString(&quot;line&quot;);
+ value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &amp;temporary_exception);
+ JSStringRelease(jsstring_property_name);
+ js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
+ bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
+ c_result_string = (char*)calloc(bytes_needed, sizeof(char));
+ JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
+ JSStringRelease(js_return_string);
+ strncat(return_error_string, c_result_string, return_error_string_max_length-1);
+ free(c_result_string);
+
+ strncat(return_error_string, &quot;]&quot;, return_error_string_max_length-1);
+
+ /* error message */
+
+ jsstring_property_name = JSStringCreateWithUTF8CString(&quot;message&quot;);
+ value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &amp;temporary_exception);
+ JSStringRelease(jsstring_property_name);
+ if(NULL == value_ref)
+ {
+ strncat(return_error_string, &quot;Unknown Error&quot;, return_error_string_max_length-1);
+ }
+ else
+ {
+ js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
+ bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
+ c_result_string = (char*)calloc(bytes_needed, sizeof(char));
+ JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
+ JSStringRelease(js_return_string);
+ strncat(return_error_string, c_result_string, return_error_string_max_length-1);
+ free(c_result_string);
+ }
+}</pre>
+</div>
+
+<p>It would be used in the following way:</p>
+<div class="code">
+<pre>
+if(js_exception)
+{
+ char return_error_string[256];
+ script_exception_to_string(js_context, js_exception, return_error_string, 256);
+ printf("Compile error is %s", return_error_string);
+}</pre>
+</div>
+
</body>
</html>
View
2  Doc/Manual/Python.html
@@ -5929,7 +5929,7 @@
<a href="http://www.python.org/dev/peps/pep-3119/">PEP 3119</a>.
</p>
-<H3><a name="Python_nn77"></a>35.12.4 Byte string output conversion</H3>
+<H3><a name="Python_nn77"></a>36.12.4 Byte string output conversion</H3>
<p>
View
4 Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
<body bgcolor="#ffffff">
<H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
-Last update : SWIG-3.0.1 (in progress)
+Last update : SWIG-3.0.2 (4 Jun 2014)
<H2>Sections</H2>
@@ -42,7 +42,7 @@
<li><a href="Go.html#Go">Go support</a></li>
<li><a href="Guile.html#Guile">Guile support</a></li>
<li><a href="Java.html#Java">Java support</a></li>
-<li><a href="Javascript.html#Java">Javascript support</a></li>
+<li><a href="Javascript.html#Javascript">Javascript support</a></li>
<li><a href="Lisp.html#Lisp">Common Lisp support</a></li>
<li><a href="Lua.html#Lua">Lua support</a></li>
<li><a href="Modula3.html#Modula3">Modula3 support</a></li>
View
11 Examples/Makefile.in
@@ -401,7 +401,8 @@ python_clean:
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@
rm -f $(TARGET).py
- if [ -f $(RUNME).py ]; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
+ if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
+ case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac
##################################################################
@@ -576,7 +577,7 @@ JAVAC = @JAVAC@ -d .
# ----------------------------------------------------------------
java: $(SRCDIR_SRCS)
- $(SWIG) -java $(SWIGOPT) -o $(ISRCS) $(realpath $(INTERFACEPATH))
+ $(SWIG) -java $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(JAVACFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE)
$(JAVALDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
@@ -585,7 +586,7 @@ java: $(SRCDIR_SRCS)
# ----------------------------------------------------------------
java_cpp: $(SRCDIR_SRCS)
- $(SWIG) -java -c++ $(SWIGOPT) -o $(ICXXSRCS) $(realpath $(INTERFACEPATH))
+ $(SWIG) -java -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(JAVACFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
$(JAVACXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
@@ -730,7 +731,7 @@ javascript_clean:
rm -f *_wrap* $(RUNME)
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
- rm -f binding.gyp
+ rm -f binding.gyp example-gypcopy.cxx
cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean
##################################################################
@@ -1373,7 +1374,7 @@ csharp_cpp: $(SRCDIR_SRCS)
# ----------------------------------------------------------------
ifneq (,$(SRCDIR))
-SRCDIR_CSHARPSRCS = $(wildcard $(addprefix $(SRCDIR),$(CSHARPSRCS)))
+SRCDIR_CSHARPSRCS = $(addprefix $(SRCDIR),$(CSHARPSRCS))
else
SRCDIR_CSHARPSRCS =
endif
View
2  Examples/javascript/class/binding.gyp.in
@@ -2,7 +2,7 @@
"targets": [
{
"target_name": "example",
- "sources": [ "$srcdir/example.cxx", "example_wrap.cxx" ],
+ "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
"include_dirs": ["$srcdir"]
}
]
View
2  Examples/javascript/enum/binding.gyp.in
@@ -2,7 +2,7 @@
"targets": [
{
"target_name": "example",
- "sources": [ "$srcdir/example.cxx", "example_wrap.cxx" ],
+ "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
"include_dirs": ["$srcdir"]
}
]
View
2  Examples/javascript/exception/binding.gyp.in
@@ -2,7 +2,7 @@
"targets": [
{
"target_name": "example",
- "sources": [ "$srcdir/example.cxx", "example_wrap.cxx" ],
+ "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
"include_dirs": ["$srcdir"],
'defines': [
'BUILDING_NODE_EXTENSION=1',
View
2  Examples/javascript/pointer/binding.gyp.in
@@ -2,7 +2,7 @@
"targets": [
{
"target_name": "example",
- "sources": [ "$srcdir/example.cxx", "example_wrap.cxx" ],
+ "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
"include_dirs": ["$srcdir"]
}
]
View
2  Examples/javascript/reference/binding.gyp.in
@@ -2,7 +2,7 @@
"targets": [
{
"target_name": "example",
- "sources": [ "$srcdir/example.cxx", "example_wrap.cxx" ],
+ "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
"include_dirs": ["$srcdir"]
}
]
View
2  Examples/javascript/simple/binding.gyp.in
@@ -2,7 +2,7 @@
"targets": [
{
"target_name": "example",
- "sources": [ "$srcdir/example.cxx", "example_wrap.cxx" ],
+ "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
"include_dirs": ["$srcdir"]
}
]
View
2  Examples/javascript/variables/binding.gyp.in
@@ -2,7 +2,7 @@
"targets": [
{
"target_name": "example",
- "sources": [ "$srcdir/example.cxx", "example_wrap.cxx" ],
+ "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
"include_dirs": ["$srcdir"]
}
]
View
18 Examples/octave/callback/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
18 Examples/octave/class/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
18 Examples/octave/constants/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
16 Examples/octave/contract/Makefile
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
18 Examples/octave/enum/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
32 Examples/octave/example.mk
@@ -0,0 +1,32 @@
+# Note: as a convention an example must be in a child directory of this.
+# These paths are relative to such an example directory
+
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = swigexample
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
+
+build:
+ifneq (,$(SRCS))
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+else
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+endif
+ifneq (,$(TARGET2)$(SWIGOPT2))
+ifneq (,$(SRCS))
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave
+else
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp
+endif
+endif
+
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
View
18 Examples/octave/extend/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
16 Examples/octave/funcptr/Makefile
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
16 Examples/octave/funcptr2/Makefile
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
18 Examples/octave/functor/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
23 Examples/octave/module_load/Makefile
@@ -1,18 +1,7 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
+TARGET = swigexample
+SWIGOPT = -module swigexample
+TARGET2 = swigexample2
+SWIGOPT2 = -module swigexample2 -globals .
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' SWIGOPT='-module $$(TARGET)' INTERFACE='$(INTERFACE)' octave
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
- rm -f $(TARGET).m
+include $(SRCDIR)../example.mk
View
18 Examples/octave/operator/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
16 Examples/octave/pointer/Makefile
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
18 Examples/octave/reference/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS = example.cxx
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS = example.cxx
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
16 Examples/octave/simple/Makefile
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
18 Examples/octave/template/Makefile
@@ -1,17 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-CXXSRCS =
-TARGET = swigexample
-INTERFACE = example.i
-LIBS = -lm
-SWIGOPT =
+CXXSRCS =
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
16 Examples/octave/variables/Makefile
@@ -1,15 +1,3 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = swigexample
-INTERFACE = example.i
+SRCS = example.c
-check: build
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
-
-build:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
- $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
+include $(SRCDIR)../example.mk
View
5 Examples/python/import_packages/Makefile
@@ -35,6 +35,11 @@ static:
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+ if test "x$(SRCDIR)" != x; then \
+ for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \
+ rm -f "$$file" || exit 1; \
+ done; \
+ fi; \
for s in $(import_packages_subdirs); do \
(cd $$s && $(MAKE) clean); \
done
View
2  Examples/test-suite/allegrocl/Makefile.in
@@ -123,4 +123,4 @@ run_testcase = \
@rm -f $*.cl
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" allegrocl_clean
View
2  Examples/test-suite/cffi/Makefile.in
@@ -48,4 +48,4 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile cffi_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" cffi_clean
View
2  Examples/test-suite/chicken/Makefile.in
@@ -97,5 +97,5 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile chicken_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" chicken_clean
rm -f *.scm
View
2  Examples/test-suite/clisp/Makefile.in
@@ -48,4 +48,4 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile clisp_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" clisp_clean
View
1  Examples/test-suite/common.mk
@@ -210,6 +210,7 @@ CPP_TEST_CASES += \
enum_template \
enum_thorough \
enum_var \
+ equality \
evil_diamond \
evil_diamond_ns \
evil_diamond_prop \
View
67 Examples/test-suite/equality.i
@@ -0,0 +1,67 @@
+/* File : equality.i */
+/*
+ Specific test for operator== overload. Partially overlaps with
+ operator_overload.i
+*/
+
+%module equality
+
+%inline %{
+
+/* Point has no equality operator */
+typedef struct Point
+{
+ double x;
+ double y;
+} Point;
+
+static const Point s_zeroPoint = { 0.0, 0.0 };
+/* stack version */
+Point MakePoint(double x, double y)
+ { Point new_point = {x, y}; return new_point; }
+
+const Point* GetZeroPointPtr() { return &s_zeroPoint; }
+Point GetZeroPointCopy() { return s_zeroPoint; }
+
+/* EqualOpDefined has correct equality operator */
+class EqualOpDefined {
+public:
+ EqualOpDefined():
+ x(5) {}
+ EqualOpDefined(int val):
+ x(val) {}
+
+ int x;
+};
+
+/* EqualOpWrong has logically incorrect equality operator */
+class EqualOpWrong {
+public:
+ inline static const EqualOpWrong* GetStaticObject();
+};
+
+static const EqualOpWrong s_wrongEqOp;
+
+const EqualOpWrong* EqualOpWrong::GetStaticObject()
+ { return &s_wrongEqOp; }
+
+
+inline bool operator==( const EqualOpDefined& first, const EqualOpDefined& second )
+ { return first.x == second.x; }
+
+inline bool operator==( const EqualOpWrong& first, const EqualOpWrong& second )
+ { return false; }
+
+%}
+
+/*
+ in order to wrapper this correctly
+ we need to extend the class
+ to make the friends & non members part of the class
+*/
+%extend EqualOpDefined {
+ bool operator==(const EqualOpDefined& b){return (*$self) == b;}
+}
+%extend EqualOpWrong {
+ bool operator==(const EqualOpWrong& b){return (*$self) == b;}
+}
View
23 Examples/test-suite/errors/Makefile.in
@@ -15,18 +15,11 @@
LANGUAGE = errors
ERROR_EXT = newerr
-# Portable dos2unix / todos for stripping CR
-TODOS = tr -d '\r'
-#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-# strip source directory from output, so that diffs compare
-srcdir_regexp = $(shell echo $(srcdir)/ | sed 's/\./[.]/g')
-STRIP_SRCDIR = sed 's|^$(srcdir_regexp)||'
-
# All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input
ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i)))
CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES))
@@ -37,21 +30,27 @@ ERROR_TEST_CASES := $(CPP_ERROR_TEST_CASES:=.cpptest) \
include $(srcdir)/../common.mk
+# Portable dos2unix / todos for stripping CR
+TODOS = tr -d '\r'
+#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
+
+# strip source directory from output, so that diffs compare
+STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
# Rules for the different types of tests
%.cpptest:
echo "$(ACTION)ing errors testcase $*"
- -$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(srcdir)/$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
- $(COMPILETOOL) diff -c $(srcdir)/$*.stderr $*.$(ERROR_EXT)
+ -$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+ $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.ctest:
echo "$(ACTION)ing errors testcase $*"
- -$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(srcdir)/$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
- $(COMPILETOOL) diff -c $(srcdir)/$*.stderr $*.$(ERROR_EXT)
+ -$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+ $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.clean:
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean
@rm -f *.$(ERROR_EXT) *.py
View
3  Examples/test-suite/go/Makefile.in
@@ -100,11 +100,12 @@ run_multi_testcase = \
@rm -f $*.go $*_gc.c $*_wrap.* $*_runme
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile go_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" go_clean
rm -f mod_a.go mod_b.go imports_a.go imports_b.go
rm -f clientdata_prop_a.go clientdata_prop_b.go
rm -f multi_import_a.go multi_import_b.go
rm -f packageoption_a.go packageoption_b.go packageoption_c.go
+ rm -f import_stl_a.go import_stl_b.go
cvsignore:
@echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib'
View
2  Examples/test-suite/guile/Makefile.in
@@ -62,4 +62,4 @@ run_testcase = \
@rm -f $*-guile
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile guile_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" guile_clean
View
28 Examples/test-suite/infinity.i
@@ -10,15 +10,16 @@
#include <math.h>
/* C99 math.h defines INFINITY. If not available, this is the fallback. */
-#ifndef INFINITY
- #ifdef _MSC_VER
+#if !defined(INFINITY)
+ #if defined(_MSC_VER)
union MSVC_EVIL_FLOAT_HACK
{
unsigned __int8 Bytes[4];
float Value;
};
- static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
+ const union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
#define INFINITY (INFINITY_HACK.Value)
+ #define INFINITY_NO_CONST
#endif
#ifdef __GNUC__
@@ -33,15 +34,28 @@
#define INFINITY (1e1000)
#endif
#endif
-%}
-%inline %{
-/* This will allow us to bind the real INFINITY value through SWIG via MYINFINITY. Use %rename to fix the name. */
+#ifdef INFINITY_NO_CONST
+/* To void: error C2099: initializer is not a constant */
+double MYINFINITY = 0.0;
+void initialise_MYINFINITY(void) {
+ MYINFINITY = INFINITY;
+}
+#else
const double MYINFINITY = INFINITY;
+void initialise_MYINFINITY(void) {
+}
+#endif
-/* Use of float is intentional because the original bug was in the float conversion due to overflow checking. */
float use_infinity(float inf_val)
{
return inf_val;
}
%}
+
+/* This will allow us to bind the real INFINITY value through SWIG via MYINFINITY. Use %rename to fix the name. */
+const double MYINFINITY = INFINITY;
+void initialise_MYINFINITY(void);
+/* Use of float is intentional because the original bug was in the float conversion due to overflow checking. */
+float use_infinity(float inf_val);
+
View
7 Examples/test-suite/java/nested_extend_c_runme.java
@@ -34,5 +34,12 @@ public static void main(String argv[]) throws Throwable
if (low.low_extend() != 99)
throw new RuntimeException("test failed");
}
+ {
+ FOO_bar foobar = new FOO_bar();
+ foobar.setD(1234);
+ if (foobar.getD() != 1234)
+ throw new RuntimeException("test failed");
+ foobar.bar_extend();
+ }
}
}
View
16 Examples/test-suite/java/preproc_line_file_runme.java
@@ -13,13 +13,21 @@
private static void test_file(String file, String suffix) throws Throwable
{
- String FILENAME_WINDOWS = "Examples\\test-suite\\preproc_line_file.i";
- String FILENAME_UNIX = "Examples/test-suite/preproc_line_file.i";
+// For swig-3.0.1 and earlier
+// String FILENAME_WINDOWS = "Examples\\test-suite\\preproc_line_file.i";
+// String FILENAME_UNIX = "Examples/test-suite/preproc_line_file.i";
+
+ String FILENAME_WINDOWS2 = "Examples\\test-suite\\java\\..\\preproc_line_file.i";
+ String FILENAME_UNIX2 = "Examples/test-suite/java/../preproc_line_file.i";
+
+ String FILENAME_WINDOWS3 = "..\\.\\..\\preproc_line_file.i";
+ String FILENAME_UNIX3 = ".././../preproc_line_file.i";
// We don't test for exact equality here because the file names are relative to the build directory, which can be different from the source directory,
// under Unix. But they do need to end with the same path components.
- if (!file.endsWith(FILENAME_UNIX + suffix) && !file.endsWith(FILENAME_WINDOWS + suffix))
- throw new RuntimeException("file \"" + file + "\" doesn't end with " + FILENAME_UNIX + suffix);
+ if (!file.endsWith(FILENAME_UNIX2 + suffix) && !file.endsWith(FILENAME_WINDOWS2 + suffix) &&
+ !file.endsWith(FILENAME_UNIX3 + suffix) && !file.endsWith(FILENAME_WINDOWS3 + suffix))
+ throw new RuntimeException("file \"" + file + "\" doesn't end with " + FILENAME_UNIX2 + suffix + " or " + FILENAME_UNIX3 + suffix);
}
public static void main(String argv[]) throws Throwable
View
16 Examples/test-suite/javascript/Makefile.in
@@ -107,7 +107,15 @@ endif
%.clean:
- rm -rf $*
- rm -f $*_wrap.*
- rm -f $*.so
- rm -f $*.o
+ @rm -rf $*
+ @rm -f $*_wrap.* $*.so $*.o
+
+clean:
+ for ext in _wrap.cxx _wrap.o .so; do \
+ rm -f clientdata_prop_a$${ext} clientdata_prop_b$${ext}; \
+ rm -f imports_a$${ext} imports_b$${ext}; \
+ rm -f import_stl_a$${ext} import_stl_b$${ext}; \
+ rm -f mod_a$${ext} mod_b$${ext}; \
+ rm -f multi_import_a$${ext} multi_import_b$${ext}; \
+ rm -f packageoption_a$${ext} packageoption_b$${ext} packageoption_c$${ext}; \
+ done
View
1  Examples/test-suite/javascript/infinity_runme.js
@@ -1,4 +1,5 @@
var infinity = require("infinity");
+infinity.initialise_MYINFINITY();
var my_infinity = infinity.INFINITY;
var ret_val = infinity.use_infinity(my_infinity);
View
2  Examples/test-suite/lua/Makefile.in
@@ -56,7 +56,7 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile lua_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" lua_clean
cvsignore:
@echo '*wrap* *.so *.dll *.exp *.lib'
View
11 Examples/test-suite/lua/cpp_basic_runme.lua
@@ -86,3 +86,14 @@ f4_name = tostring(f4)
assert( f2_name == "Foo" )
assert( f3_name == "Foo" )
assert( f4_name == "FooSubSub" )
+
+-- Test __eq implementation supplied by default
+
+-- eq_f1 and eq_f2 must be different userdata with same Foo* pointer. If eq_f1 and eq_f2 are the same userdata (e.g.)
+-- > eq_f1 = smth
+-- > eq_f2 = eq_f1
+-- then default Lua equality comparison kicks in and considers them equal. Access to global_fptr is actually a
+-- function call (internally) and it returns new userdata each time.
+eq_f1 = cb.Bar.global_fptr
+eq_f2 = cb.Bar.global_fptr
+assert( eq_f1 == eq_f2 )
View
47 Examples/test-suite/lua/equality_runme.lua
@@ -0,0 +1,47 @@
+require("import") -- the import fn
+import("equality") -- import code
+eq=equality -- renaming import
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- === No equality operator ===
+
+-- logically same data without equality operator are not equal
+p1 = eq.MakePoint(10,9);
+p2 = eq.MakePoint(10,9);
+
+assert( p1 ~= p2 );
+
+-- different wrappers for same Point* are equal
+p3 = eq.GetZeroPointPtr()
+p4 = eq.GetZeroPointPtr()
+
+assert( p3 == p4 )
+
+
+-- === Logically correct equality operator ===
+
+ed1 = eq.EqualOpDefined(10)
+ed2 = eq.EqualOpDefined(10)
+ed3 = eq.EqualOpDefined(15)
+
+assert( ed1 == ed2 )
+assert( ed1 ~= ed3 )
+
+
+-- === Logically incorrect equality operator ===
+
+ew1 = eq.EqualOpWrong()
+ew2 = eq.EqualOpWrong()
+
+assert( ew1 ~= ew2 );
+
+ew3 = eq.EqualOpWrong.GetStaticObject()
+ew4 = eq.EqualOpWrong.GetStaticObject()
+
+-- Even though these are pointers to same object, operator== overload should
+-- state that they are not equal
+assert( ew3 ~= ew4 )
View
2  Examples/test-suite/mzscheme/Makefile.in
@@ -46,4 +46,4 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile mzscheme_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" mzscheme_clean
View
7 Examples/test-suite/nested_extend_c.i
@@ -10,6 +10,7 @@
char hi_extend() {
return $self->c;
}
+ static const long swig_size = sizeof(union hiA);
}
%extend lowA {
lowA() {
@@ -21,6 +22,7 @@
int low_extend() {
return $self->num;
}
+ static const long swig_size = sizeof(struct lowA);
}
%extend hiB {
@@ -32,6 +34,7 @@
char hi_extend() {
return $self->c;
}
+ static const long swig_size = sizeof(union hiB);
}
%extend lowB {
lowB() {
@@ -43,6 +46,7 @@
int low_extend() {
return $self->num;
}
+ static const long swig_size = sizeof(struct lowB);
}
%extend FOO_bar {
@@ -50,6 +54,9 @@
$self->d = 1;
}
};
+%extend NestedA {
+ static const long swig_size = sizeof(struct NestedA);
+}
#endif
View
2  Examples/test-suite/ocaml/Makefile.in
@@ -81,4 +81,4 @@ include $(srcdir)/../common.mk
@rm -f $*.ml $*.mli;
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ocaml_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" ocaml_clean
View
2  Examples/test-suite/octave/Makefile.in
@@ -68,7 +68,7 @@ run_testcase = \
@rm -f $*.m;
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile octave_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" octave_clean
cvsignore:
@echo '*wrap* *.mc *.so *.dll *.exp *.lib'
View
2  Examples/test-suite/perl5/Makefile.in
@@ -59,4 +59,4 @@ run_testcase = \
@rm -f $*.pm;
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile perl5_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" perl5_clean
View
10 Examples/test-suite/php/Makefile.in
@@ -65,7 +65,13 @@ run_testcase = \
# Clean: remove the generated .php file
%.clean:
- @rm -f $*.php;
+ @rm -f $*.php php_$*.h
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" php_clean
+ rm -f clientdata_prop_a.php clientdata_prop_b.php php_clientdata_prop_a.h php_clientdata_prop_b.h
+ rm -f import_stl_a.php import_stl_b.php php_import_stl_a.h php_import_stl_b.h
+ rm -f imports_a.php imports_b.php php_imports_a.h php_imports_b.h
+ rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h
+ rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h
+ rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h
View
2  Examples/test-suite/pike/Makefile.in
@@ -46,4 +46,4 @@ run_testcase = \
@rm -f $*.pike;
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile pike_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" pike_clean
View
7 Examples/test-suite/python/Makefile.in
@@ -160,12 +160,11 @@ endif
# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
%.clean:
@rm -f $*.py
- @if [ -f $(srcdir)/$(py2_runme) ]; then \
- rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; \
- fi
+ @if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi
+ @if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" 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
View
2  Examples/test-suite/r/Makefile.in
@@ -66,7 +66,7 @@ run_multitestcase = \
done
# Clean
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile r_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" r_clean
%.clean:
@rm -f $*.R $*_wrap.so $*_wrap.cpp $*_wrap.c $*_wrap.o $*_runme.Rout $*.Rout
View
2  Examples/test-suite/ruby/Makefile.in
@@ -70,4 +70,4 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ruby_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" ruby_clean
View
2  Examples/test-suite/tcl/Makefile.in
@@ -55,4 +55,4 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile tcl_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" tcl_clean
View
2  Examples/test-suite/uffi/Makefile.in
@@ -48,4 +48,4 @@ run_testcase = \
@exit 0
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile uffi_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" uffi_clean
View
6 Lib/javascript/jsc/javascriptcode.swg
@@ -159,7 +159,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStr
goto fail;
fail:
- return NULL;
+ return JSValueMakeUndefined(context);
}
%}
@@ -204,7 +204,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjec
goto fail;
fail:
- return NULL;
+ return JSValueMakeUndefined(context);
}
%}
@@ -229,7 +229,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjec
goto fail;
fail:
- return NULL;
+ return JSValueMakeUndefined(context);
}
%}
View
21 Lib/javascript/jsc/javascriptrun.swg
@@ -8,9 +8,24 @@
#define SWIG_fail goto fail
SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) {
- JSStringRef message = JSStringCreateWithUTF8CString(type);
- *exception = JSValueMakeString(context, message);
- JSStringRelease(message);
+ JSStringRef message = JSStringCreateWithUTF8CString(type);
+ JSValueRef error_arguments[1];
+ JSObjectRef exception_object;
+ JSValueRef exception_value;
+ exception_value = JSValueMakeString(context, message);
+ /* Converting the result to an object will let JavascriptCore add
+ "sourceURL" (file) and "line" (number) and "message" to the exception,
+ instead of just returning a raw string. This is extremely important for debugging your errors.
+ Using JSObjectMakeError is better than JSValueToObject because the latter only populates
+ "sourceURL" and "line", but not "message" or any others I don't know about.
+ */
+ error_arguments[0] = exception_value;
+ exception_object = JSObjectMakeError(context, 1, error_arguments, NULL);
+
+ /* Return the exception_object */
+ *exception = exception_object;
+
+ JSStringRelease(message);
}
SWIGRUNTIME void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) {
View
2  Lib/javascript/jsc/std_vector.i
@@ -61,7 +61,7 @@ namespace std {
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
- const_reference get(int i) throw (std::out_of_range) {
+ bool get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
View
2  Lib/javascript/v8/std_vector.i
@@ -61,7 +61,7 @@ namespace std {
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
- const_reference get(int i) throw (std::out_of_range) {
+ bool get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
View
64 Lib/lua/luarun.swg
@@ -1037,6 +1037,23 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State *L)
return 0;
}
+/* lua callable function to compare userdata's value
+the issue is that two userdata may point to the same thing
+but to lua, they are different objects */
+SWIGRUNTIME int SWIG_Lua_class_equal(lua_State *L)
+{
+ int result;
+ swig_lua_userdata *usr1,*usr2;
+ if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */
+ return 0; /* nil reply */
+ usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
+ usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */
+ /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
+ result=(usr1->ptr==usr2->ptr);
+ lua_pushboolean(L,result);
+ return 1;
+}
+
/* populate table at the top of the stack with metamethods that ought to be inherited */
SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L)
{
@@ -1439,6 +1456,7 @@ SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class
int metatable_index;
int metamethods_info_index;
int tostring_undefined;
+ int eq_undefined = 0;
SWIG_Lua_get_class_metatable(L, clss->fqname);
metatable_index = lua_gettop(L);
@@ -1471,6 +1489,18 @@ SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class
lua_pop(L,1); /* remove copy of the key */
}
+ /* Special handling for __eq method */
+ lua_pushstring(L, "__eq");
+ lua_pushvalue(L,-1);
+ lua_rawget(L,metatable_index);
+ eq_undefined = lua_isnil(L,-1);
+ lua_pop(L,1);
+ if( eq_undefined ) {
+ lua_pushcfunction(L, SWIG_Lua_class_equal);
+ lua_rawset(L, metatable_index);
+ } else {
+ lua_pop(L,1); /* remove copy of the key */
+ }
/* Warning: __index and __newindex are SWIG-defined. For user-defined operator[]
* a __getitem/__setitem method should be defined
*/
@@ -1514,7 +1544,6 @@ SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *cls
*/
SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss)
{
- int new_metatable_index;
const int SWIGUNUSED begin = lua_gettop(L);
int i;
/* if name already there (class is already registered) then do nothing */
@@ -1541,14 +1570,16 @@ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *c
* It would get us all special methods: __getitem, __add etc.
* This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away
*/
- new_metatable_index = lua_absindex(L,-1);
- for(i=0;clss->bases[i];i++)
{
- int base_metatable;
- SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
- base_metatable = lua_absindex(L,-1);
- SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
- lua_pop(L,1);
+ int new_metatable_index = lua_absindex(L,-1);
+ for(i=0;clss->bases[i];i++)
+ {
+ int base_metatable;
+ SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
+ base_metatable = lua_absindex(L,-1);
+ SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
+ lua_pop(L,1);
+ }
}
/* And now we will overwrite all incorrectly set data */
#endif
@@ -1787,23 +1818,6 @@ SWIGRUNTIME int SWIG_Lua_type(lua_State *L)
return 1;
}
-/* lua callable function to compare userdata's value
-the issue is that two userdata may point to the same thing
-but to lua, they are different objects */
-SWIGRUNTIME int SWIG_Lua_equal(lua_State *L)
-{
- int result;
- swig_lua_userdata *usr1,*usr2;
- if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */
- return 0; /* nil reply */
- usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
- usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */
- /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
- result=(usr1->ptr==usr2->ptr);
- lua_pushboolean(L,result);
- return 1;
-}
-
/* -----------------------------------------------------------------------------
* global variable support code: class/struct typemap functions
* ----------------------------------------------------------------------------- */
View
2  Lib/lua/luaruntime.swg
@@ -40,7 +40,7 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) || defined(SWIG_LUA_ELUA_EMULATE)
/* add a global fn */
SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
- SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
+ SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_class_equal);
#endif
#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
View
56 Lib/octave/std_carray.i
@@ -1,56 +0,0 @@
-%include <pycontainer.swg>
-
-/*
-%fragment("StdCarrayTraits","header",fragment="StdSequenceTraits")
-{
-namespace swig {
- template <class T, size_t S>
- struct traits_asptr<std::carray<T, S> > {
- static int asptr(PyObject *obj, std::carray<T, S> **array) {
- return traits_asptr_stdseq<std::carray<T, S> >::asptr(obj, array);
- }
- };
-}
-}
-
-%warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[];
-
-%extend std::carray {
- %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
- fragment="SwigPyIterator_T",
- fragment=SWIG_Traits_frag(_Type),
- fragment="StdCarrayTraits") {
- namespace swig {
- template <> struct traits<std::carray<_Type, _Size > > {
- typedef pointer_category category;
- static const char* type_name() {
- return "std::carray<" #_Type "," #_Size " >";
- }
- };
- }
- }
-
- %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr,
- SWIG_Traits_frag(std::carray<_Type, _Size >),
- std::carray<_Type, _Size >);
-
- %typemap(out,noblock=1) iterator, const_iterator {
- $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1),
- swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
- }
-
- inline size_t __len__() const { return self->size(); }
-
- inline const _Type& __getitem__(size_t i) const { return (*self)[i]; }
-
- inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; }
-
-
- swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
- return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
- }
-}
-
-%include <std/std_carray.swg>
-*/
-
View
16 Makefile.in
@@ -403,7 +403,7 @@ clean-ccache:
DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool preinst-swig
-distclean-helper: distclean-test-suite distclean-examples distclean-dead
+distclean-helper: distclean-test-suite distclean-examples distclean-tools distclean-dead
distclean: distclean-source distclean-ccache distclean-helper
@@ -429,6 +429,10 @@ distclean-examples:
distclean-ccache:
@test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) $(FLAGS) distclean)
+distclean-tools:
+ @echo distcleaning Tools
+ @cd Tools/javascript && $(MAKE) $(FLAGS) distclean
+
distclean-dead:
rm -f $(DISTCLEAN-DEAD)
rm -rf autom4te.cache
@@ -451,6 +455,16 @@ maintainer-clean:
@echo distcleaning
@$(MAKE) $(FLAGS) distclean-helper
+check-maintainer-clean: maintainer-clean
+ @if test "x$(srcdir)" = "x."; then \
+ echo "skipping maintainer-clean check (in-source-tree build)"; \
+ exit 0; \
+ fi; \
+ for file in `find . -type f`; do \
+ echo "file missed by maintainer-clean: $$file"; \
+ done; \
+ test "x$$file" = x && echo "all files cleaned by maintainer-clean"
+
#####################################################################
# Update the Lib/swigwarn.swg file
# Note: Generated into the source tree rather than build tree
View
2  README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 3.0.1 (in progress)
+Version: 3.0.2 (4 Jun 2014)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua,
View
3  RELEASENOTES
@@ -4,6 +4,9 @@ and CHANGES files.
Release Notes
=============
+SWIG-3.0.2 summary:
+- Bug fix during install and a couple of other minor changes.
+
SWIG-3.0.1 summary:
- Javascript module added. This supports JavascriptCore (Safari/Webkit),
v8 (Chromium) and node.js currently.