diff --git a/.gitignore b/.gitignore
index c375a7c77..d4d70b010 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,8 @@
# Editor files and various other junk
.*.sw?
*.bak
+*.log
+.DS_Store
# Local PCRE
pcre
@@ -23,6 +25,7 @@ pcre
*.so
*.so.*
*.dylib
+*.bundle
# C/C++ static libraries, based on:
# https://github.com/github/gitignore/blob/master/C.gitignore
@@ -71,6 +74,7 @@ Examples/xml/Makefile
Source/Include/stamp-h1
Source/Include/swigconfig.h
Source/Makefile
+Tools/javascript/Makefile
.deps
config.log
config.status
@@ -86,6 +90,7 @@ Source/CParse/parser.c
Source/CParse/parser.h
Source/eswig
swig
+Tools/javascript/javascript
# Generated documentation
Doc/Manual/CCache.html
@@ -103,6 +108,7 @@ Examples/test-suite/d/*/
Examples/test-suite/go/*/
Examples/test-suite/guile/*/
Examples/test-suite/java/*/
+Examples/test-suite/javascript/*/
Examples/test-suite/lua/*/
Examples/test-suite/mzscheme/*/
Examples/test-suite/ocaml/*/
@@ -115,6 +121,8 @@ Examples/test-suite/r/*/
Examples/test-suite/ruby/*/
Examples/test-suite/tcl/*/
Examples/test-suite/uffi/*/
+*_wrap.c
+*_wrap.cxx
# Python generated files, based on:
# https://github.com/github/gitignore/blob/master/Python.gitignore
diff --git a/.travis.yml b/.travis.yml
index 7983d0ecd..890382c40 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,12 @@ matrix:
env: SWIGLANG=guile
- compiler: gcc
env: SWIGLANG=java
+ - compiler: gcc
+ env: SWIGLANG=javascript ENGINE=node
+ - compiler: gcc
+ env: SWIGLANG=javascript ENGINE=jsc
+ - compiler: gcc
+ env: SWIGLANG=javascript ENGINE=v8
- compiler: gcc
env: SWIGLANG=lua
- compiler: gcc
@@ -51,6 +57,9 @@ before_install:
- if test -z "$SWIGLANG"; then sudo apt-get -qq install yodl; fi
- if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi
- if test "$SWIGLANG" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed
+ - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "node"; then sudo apt-get install -qq rlwrap python-software-properties && echo 'yes' | sudo add-apt-repository ppa:chris-lea/node.js && sudo apt-get -qq update && sudo apt-get install -qq nodejs && sudo npm install -g node-gyp; fi
+ - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "jsc"; then sudo apt-get install -qq libwebkitgtk-dev; fi
+ - if test "$SWIGLANG" = "javascript" -a "$ENGINE" = "v8"; then sudo apt-get install -qq libv8-dev; fi
- if test "$SWIGLANG" = "guile"; then sudo apt-get -qq install guile-2.0-dev; fi
- if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi
- if test "$SWIGLANG" = "octave"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi
diff --git a/CCache/Makefile.in b/CCache/Makefile.in
index d8f9042fe..abe78c277 100644
--- a/CCache/Makefile.in
+++ b/CCache/Makefile.in
@@ -69,9 +69,9 @@ distclean: clean
maintainer-clean: distclean
/bin/rm -f $(PACKAGE_NAME).1 web/ccache-man.html
-
+
# FIXME: To fix this, test.sh needs to be able to take ccache from the
# installed prefix, not from the source dir.
-installcheck:
+installcheck:
@echo "WARNING! This is not really \"installcheck\" yet."
$(MAKE) check
diff --git a/CHANGES.current b/CHANGES.current
index 11682c9dd..8b67392b2 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,31 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.1 (in progress)
===========================
+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
+ * 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
+ 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
diff --git a/COPYRIGHT b/COPYRIGHT
index 188af4876..6fbf6c0b0 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -16,6 +16,8 @@ Active SWIG Developers:
Joseph Wang (joequant@gmail.com) (R)
Xavier Delacour (xavier.delacour@gmail.com) (Octave)
David Nadlinger (code@klickverbot.at) (D)
+ Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript)
+ Neha Narang (narangneha03@gmail.com) (Javascript)
Past SWIG developers and major contributors include:
Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl)
diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html
new file mode 100644
index 000000000..e589d9d09
--- /dev/null
+++ b/Doc/Manual/Javascript.html
@@ -0,0 +1,808 @@
+
+
+
+
+
+
+
+
+SWIG and Javascript
+This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.
+
+Overview
+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 node.js , it is also used as a backend development language.
+Native Javascript extensions can be used for applications that embed a web-browser view or that embed a Javascript engine (such as node.js ). Extending a general purpose web-browser is not possible as this would be a severe security issue.
+SWIG Javascript currently supports JavascriptCore , the Javascript engine used by Safari/Webkit, and v8 , which is used by Chromium and node.js.
+WebKit is a modern browser implementation available as open-source which can be embedded into an application.
+With node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.
+
+
+Preliminaries
+
+Running SWIG
+
+Suppose that you defined a SWIG module such as the following:
+
+
+%module example
+%{
+#include "example.h"
+%}
+int gcd(int x, int y);
+extern double Foo;
+
+To build a Javascript module, run SWIG using the -javascript option and a desired target engine -jsc, -v8, or -node. The generator for node is essentially delegating to the v8 generator and adds some necessary preprocessor definitions.
+
+
+$ swig -javascript -jsc example.i
+
+If building a C++ extension, add the -c++ option:
+
+
+$ swig -c++ -javascript -jsc example.i
+
+This creates a C/C++ source file example_wrap.c or example_wrap.cxx. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.
+The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrapped module will export one function which must be called to register the module with the Javascript interpreter. For example, if your module is named example the corresponding initializer for JavascriptCore would be
+
+
+bool example_initialize(JSGlobalContextRef context, JSObjectRef *exports)
+
+and for v8:
+
+
+void example_initialize(v8::Handle exports)
+
+
+
Note : be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.
+
+
+Running Tests and Examples
+The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.
+The default interpreter is node.js as it is available on all platforms and convenient to use.
+Running the examples with JavascriptCore requires libjavascriptcoregtk-1.0 to be installed, e.g., under Ubuntu with
+
+
+$ sudo apt-get install libjavascriptcoregtk-1.0-dev
+
+Running with V8 requires libv8:
+
+
+$ sudo apt-get install libv8-dev
+
+Examples can be run using
+
+
+$ make check-javascript-examples ENGINE=jsc
+
+ENGINE can be node, jsc, or v8.
+The test-suite can be run using
+
+
+$ make check-javascript-test-suite ENGINE=jsc
+
+Tests should run without any problems, i.e., have been tried out, on the following platforms/interpreters:
+
+
+- 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
+
+
+
+
Future work
+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:
+
+More typemaps: compared to other modules there are only a few typemaps implemented. For instance a lot of the std_*.i typemaps are missing, such as std_iostream, for instance.
+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.
+
+
+Integration
+This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.
+
+Creating node.js Extensions
+To install node.js you can download an installer from their web-site for OSX and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.
+
+
+$ sudo add-apt-repository ppa:chris-lea/node.js
+$ sudo apt-get update
+$ sudo apt-get install nodejs
+
+As v8 is written in C++ and comes as a C++ library it is crucial to compile your module using the same compiler flags as used for building v8. To make things easier, node.js provides a build tool called node-gyp.
+You have to install it using npm:
+
+
+$ sudo npm install -g node-gyp
+
+node-gyp expects a configuration file named binding.gyp which is basically in JSON format and conforms to the same format that is used with Google's build-tool gyp.
+binding.gyp:
+
+
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
+
+First create the wrapper using SWIG:
+
+
+$ swig -javascript -node -c++ example.cxx
+
+Then run node-gyp
+
+This will create a build folder containing the native module. To use the extension you need to 'require' it in your Javascript source file:
+
+
+require("./build/Release/example")
+
+A more detailed explanation is given in the Examples section.
+
+Troubleshooting
+
+'module' object has no attribute 'script_main'
+
+This error happens when gyp is installed as a distribution package. It seems to be outdated. Removing it resolves the problem.
+
+
+$ sudo apt-get remove gyp
+
+
+Embedded Webkit
+Webkit is pre-installed on OSX and available as a library for GTK.
+
+OSX
+There is general information about programming with WebKit on Apple Developer Documentation . Details about Cocoa programming are not covered here.
+An integration of a native extension 'example' would look like this:
+
+
+#import "appDelegate.h"
+
+extern bool example_initialize(JSGlobalContextRef context);
+
+
+@implementation ExampleAppDelegate
+
+@synthesize webView;
+
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
+
+ // Start a webview with the bundled index.html file
+ NSString *path = [[NSBundle mainBundle] bundlePath];
+ NSString *url = [NSString stringWithFormat: @"file://%@/Contents/Assets/index.html", path];
+
+ WebFrame *webframe = [webView mainFrame];
+ JSGlobalContextRef context = [webframe globalContext];
+
+ example_initialize(context);
+
+ [ [webView mainFrame] loadRequest:
+ [NSURLRequest requestWithURL: [NSURL URLWithString:url] ]
+ ];
+}
+
+@end
+
+
+GTK
+There is general information about programming GTK at GTK documentation and in the GTK tutorial , and for Webkit there is a Webkit GTK+ API Reference .
+An integration of a native extension 'example' would look like this:
+
+
+#include
+#include
+
+extern bool example_initialize(JSGlobalContextRef context);
+
+int main(int argc, char* argv[])
+{
+ // Initialize GTK+
+ gtk_init(&argc, &argv);
+
+ ...
+
+ // Create a browser instance
+ 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);
+
+ ...
+
+ // Load a web page into the browser instance
+ webkit_web_view_load_uri(webView, "http://www.webkitgtk.org/");
+
+ ...
+
+ // Run the main GTK+ event loop
+ gtk_main();
+
+ return 0;
+}
+
+
+Creating Applications with node-webkit
+
+
To get started with node-webkit there is a very informative set of wiki pages .
+Similar to node.js, node-webkit is started from command line within a node.js project directory.
+Native extensions are created in the very same way as for node.js, except that a customized gyp derivate has to be used: nw-gyp .
+
+
+
+A simple example would have the following structure:
+
+
+
+
+- package.json
+- app.html
+- app.js
+- node_modules
+ / example
+ ... (as known from node.js)
+
+
+
+
+The configuration file essentially conforms to node.js syntax.
+It has some extras to configure node-webkit. See the Manifest specification for more details.
+
+
+
+ package.json:
+
+
+
+{
+ "name": "example"
+ "main": "app.html"
+ "window": {
+ "show": true,
+ "width": 800,
+ "height": 600
+ }
+}
+
+
+
+The 'main' property of package.json specifies a web-page to be rendered in
+the main window.
+
+
+ app.html:
+
+
+
+
+<html>
+ <head>
+ <script src="app.js"></script>
+ </head>
+ <body>
+ <div>
+ The greatest common divisor of
+ <span id="x"></span> and
+ <span id="y"></span> is
+ <span id="z"></span>.
+ </div>
+ </body>
+</html>
+
+
+
+As known from node.js one can use require to load javascript modules.
+Additionally, node-webkit provides an API that allows to manipulate the window's menu,
+open new windows, and many more things.
+
+
+
+ app.js:
+
+
+
+
window.onload = function() {
+ var example = require("example");
+ var x = 18;
+ var y = 24;
+ var z = example.gcd(x,y);
+ document.querySelector('#x').innerHTML = x;
+ document.querySelector('#y').innerHTML = y;
+ document.querySelector('#z').innerHTML = z;
+};
+
+
+
+Some basic examples are shown here in more detail.
+
+Simple
+The common example simple looks like this:
+
+
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
+
+To make this available as a node extension a binding.gyp has to be created:
+
+
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
+
+Then node-gyp is used to build the extension:
+
+
+$ node-gyp configure build
+
+From a 'nodejs` application the extension would be used like this:
+
+
+// import the extension via require
+var example = require("./build/Release/example");
+
+// calling the global method
+var x = 42;
+var y = 105;
+var g = example.gcd(x,y);
+
+// Accessing the globak variable
+var f = example.Foo;
+example.Foo = 3.1415926;
+
+First the module example is loaded from the previously built extension. Global methods and variables are available in the scope of the module.
+
+
Note : ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify , for instance.
+
+
+Class
+The common example class defines three classes, Shape, Circle, and Square:
+
+
+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);
+};
+
+Circle and Square inherit from Shape. Shape has a static variable nshapes, a function move that can't be overridden (non-virtual), and two abstract functions area and perimeter (pure virtual) that must be overridden by the sub-classes.
+A nodejs extension is built the same way as for the simple example.
+In Javascript it can be used as follows:
+
+
+var example = require("./build/Release/example");
+
+// local aliases for convenience
+var Shape = example.Shape;
+var Circle = example.Circle;
+var Square = example.Square;
+
+// creating new instances using the 'new' operator
+var c = new Circle(10);
+var s = new Square(10);
+
+// accessing a static member
+Shape.nshapes;
+
+// accessing member variables
+c.x = 20;
+c.y = 30;
+s.x = -10;
+s.y = 5;
+
+// calling some methods
+c.area();
+c.perimeter();
+s.area();
+s.perimeter();
+
+// instantiation of Shape is not permitted
+new Shape();
+
+Running these commands in an interactive node shell results in the following output:
+
+
+$ node -i
+> var example = require("./build/Release/example");
+undefined
+> var Shape = example.Shape;
+undefined
+> var Circle = example.Circle;
+undefined
+> var Square = example.Square;
+undefined
+> var c = new Circle(10);
+undefined
+> var s = new Square(10);
+undefined
+> Shape.nshapes;
+2
+> c.x = 20;
+20
+> c.y = 30;
+30
+> s.x = -10;
+-10
+> s.y = 5;
+5
+> c.area();
+314.1592653589793
+> c.perimeter();
+62.83185307179586
+> s.area();
+100
+> s.perimeter();
+40
+> c.move(40, 40)
+undefined
+> c.x
+60
+> c.y
+70
+> new Shape()
+Error: Class Shape can not be instantiated
+at repl:1:2
+at REPLServer.self.eval (repl.js:110:21)
+at Interface. (repl.js:239:12)
+at Interface.EventEmitter.emit (events.js:95:17)
+at Interface._onLine (readline.js:202:10)
+at Interface._line (readline.js:531:8)
+at Interface._ttyWrite (readline.js:760:14)
+at ReadStream.onkeypress (readline.js:99:10)
+at ReadStream.EventEmitter.emit (events.js:98:17)
+at emitKey (readline.js:1095:12)
+
+
+
Note : In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain , for instance.
+
+
+Implementation
+The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.
+
+Source Code
+The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:
+
+
+// module wide defines
+
+#define NAME "name"
+...
+
+// ###############################
+// # Helper class declarations
+
+class JSEmitterState { ... };
+
+class Template { ... };
+
+// ###############################
+// # JSEmitter declaration
+
+class JSEmitter { ... };
+
+// Emitter factory declarations
+
+JSEmitter *swig_javascript_create_JSCEmitter();
+JSEmitter *swig_javascript_create_V8Emitter();
+
+// ###############################
+// # Javascript module
+
+// Javascript module declaration
+
+class JAVASCRIPT:public Language { ... };
+
+// Javascript module implementation
+
+int JAVASCRIPT::functionWrapper(Node *n) { ... }
+...
+
+// Module factory implementation
+
+static Language *new_swig_javascript() { ... }
+
+extern "C" Language *swig_javascript(void) { ... }
+
+// ###############################
+// # JSEmitter base implementation
+
+JSEmitter::JSEmitter() { ... }
+
+Template JSEmitter::getTemplate(const String *name) { ... }
+...
+
+// ###############################
+// # JSCEmitter
+
+// JSCEmitter declaration
+
+class JSCEmitter: public JSEmitter { ... };
+
+// JSCEmitter implementation
+
+JSCEmitter::JSCEmitter() { ... }
+
+void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) { ... }
+...
+
+// JSCEmitter factory
+
+JSEmitter *swig_javascript_create_JSCEmitter() { ... }
+
+
+// ###############################
+// # V8Emitter
+
+// V8Emitter declaration
+
+class V8Emitter: public JSEmitter { ... };
+
+// V8Emitter implementation
+
+V8Emitter::V8Emitter() { ... }
+
+int V8Emitter::initialize(Node *n) { ... }
+
+// V8Emitter factory
+
+JSEmitter *swig_javascript_create_V8Emitter() { ... }
+
+
+// ###############################
+// # Helper implementation (JSEmitterState, Template)
+
+JSEmitterState::JSEmitterState() { ... }
+...
+
+Template::Template(const String *code_) { ... }
+...
+
+
+Code Templates
+All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.
+To track the originating code template for generated code you can run
+
+
+$ swig -javascript -jsc -debug-codetemplates
+
+which wraps generated code with a descriptive comment
+
+
+/* begin fragment("template_name") */
+
+...generated code ...
+
+/* end fragment("template_name") */
+
+The Template class is used like this:
+
+
+Template t_register = getTemplate("jsv8_register_static_variable");
+t_register.replace("$jsparent", state.clazz(NAME_MANGLED))
+ .replace("$jsname", state.variable(NAME))
+ .replace("$jsgetter", state.variable(GETTER))
+ .replace("$jssetter", state.variable(SETTER))
+ .trim().
+ print(f_init_static_wrappers);
+
+A code template is registered with the JSEmitter via fragment(name, "template"), e.g.,
+
+
+%fragment ("jsc_variable_declaration", "templates")
+%{
+ {"$jsname", $jsgetter, $jssetter, kJSPropertyAttributeNone},
+%}
+
+Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.
+
+Emitter
+The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:
+
+
+class JSEmitter {
+ ...
+
+ /**
+ * Opens output files and temporary output DOHs.
+ */
+ virtual int initialize(Node *n);
+
+ /**
+ * Writes all collected code into the output file(s).
+ */
+ virtual int dump(Node *n) = 0;
+
+ /**
+ * Cleans up all open output DOHs.
+ */
+ virtual int close() = 0;
+
+ ...
+
+ /**
+ * Invoked at the beginning of the classHandler.
+ */
+ virtual int enterClass(Node *);
+
+ /**
+ * Invoked at the end of the classHandler.
+ */
+ virtual int exitClass(Node *) {
+ return SWIG_OK;
+ };
+
+ /**
+ * Invoked at the beginning of the variableHandler.
+ */
+ virtual int enterVariable(Node *);
+
+ /**
+ * Invoked at the end of the variableHandler.
+ */
+ virtual int exitVariable(Node *) {
+ return SWIG_OK;
+ };
+
+ /**
+ * Invoked at the beginning of the functionHandler.
+ */
+ virtual int enterFunction(Node *);
+
+ /**
+ * Invoked at the end of the functionHandler.
+ */
+ virtual int exitFunction(Node *) {
+ return SWIG_OK;
+ };
+
+ /**
+ * Invoked by functionWrapper callback after call to Language::functionWrapper.
+ */
+ virtual int emitWrapperFunction(Node *n);
+
+ /**
+ * Invoked from constantWrapper after call to Language::constantWrapper.
+ **/
+ virtual int emitConstant(Node *n);
+
+ /**
+ * Registers a given code snippet for a given key name.
+ *
+ * This method is called by the fragmentDirective handler
+ * of the JAVASCRIPT language module.
+ **/
+ int registerTemplate(const String *name, const String *code);
+
+ /**
+ * Retrieve the code template registered for a given name.
+ */
+ Template getTemplate(const String *name);
+
+ State &getState();
+
+ ...
+
+}
+
+The module calls initialize, dump, and close from within the top method:
+
+
+int JAVASCRIPT::top(Node *n) {
+ emitter->initialize(n);
+
+ Language::top(n);
+
+ emitter->dump(n);
+ emitter->close();
+
+ return SWIG_OK;
+}
+
+The methods enterClass and exitClass are called from within the classHandler method:
+
+
+int JAVASCRIPT::classHandler(Node *n) {
+
+ emitter->enterClass(n);
+ Language::classHandler(n);
+ emitter->exitClass(n);
+
+ return SWIG_OK;
+}
+
+In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.
+
+Emitter states
+For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.
+
+
+class JSEmitterState {
+
+public:
+
+ JSEmitterState();
+
+ ~JSEmitterState();
+
+ DOH *global();
+
+ DOH *global(const char* key, DOH *initial = 0);
+
+ DOH *clazz(bool reset = false);
+
+ DOH *clazz(const char* key, DOH *initial = 0);
+
+ DOH *function(bool reset = false);
+
+ DOH *function(const char* key, DOH *initial = 0);
+
+ DOH *variable(bool reset = false);
+
+ DOH *variable(const char* key, DOH *initial = 0);
+
+ static int IsSet(DOH *val);
+
+ ...
+};
+
+When entering a scope, such as in enterClass, the corresponding state is reset and new data is stored:
+
+
+state.clazz(RESET);
+state.clazz(NAME, Getattr(n, "sym:name"));
+
+State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.
+
+
diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
index c67e08834..269cb2801 100644
--- a/Doc/Manual/Lua.html
+++ b/Doc/Manual/Lua.html
@@ -993,7 +993,7 @@ The current list of operators which can be overloaded (and the alternative funct
__unm__ unary minus
__call__ operator() (often used in functor classes)
__pow__ the exponential fn (no C++ equivalent, Lua uses ^ )
-__concat__ the concatenation operator (SWIG maps C++'s ~ to Lua's .. )
+__concat__ the concatenation operator (Lua's .. )
__eq__ operator==
__lt__ operator<
__le__ operator<=
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 42149ba3a..5112afa33 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -75,4 +75,3 @@ linkchecker:
@echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
@echo -----------------------------------------------------------------------
linkchecker --config=./linkchecker.config index.html
-
diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
index d5c41dde7..745570ca4 100644
--- a/Doc/Manual/Preprocessor.html
+++ b/Doc/Manual/Preprocessor.html
@@ -115,6 +115,9 @@ SWIGCLISP Defined when using CLISP
SWIGCSHARP Defined when using C#
SWIGGUILE Defined when using Guile
SWIGJAVA Defined when using Java
+SWIGJAVASCRIPT Defined when using Javascript
+SWIG_JAVASCRIPT_JSC Defined when using Javascript for JavascriptCore
+SWIG_JAVASCRIPT_V8 Defined when using Javascript for v8 or node.js
SWIGLUA Defined when using Lua
SWIGMODULA3 Defined when using Modula-3
SWIGMZSCHEME Defined when using Mzscheme
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 877ca2fae..99d1dfe0d 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -42,6 +42,7 @@ Last update : SWIG-3.0.1 (in progress)
Go support
Guile support
Java support
+Javascript support
Common Lisp support
Lua support
Modula3 support
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 9c376b636..32cf0b2dd 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -23,6 +23,7 @@ D.html
Go.html
Guile.html
Java.html
+Javascript.html
Lisp.html
Lua.html
Modula3.html
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 218d8eca5..326f678c7 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -88,7 +88,7 @@ endif
##################################################################
CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
- -L/usr/local/lib -lg++ -lstdc++ -lgcc
+ -L/usr/local/lib -lg++ -lstdc++ -lgcc
# Solaris workshop 5.0
# CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun
@@ -589,6 +589,117 @@ java_clean:
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@JAVASO@
+##################################################################
+##### JAVASCRIPT ######
+##################################################################
+
+# Note: These targets are also from within Makefiles in the Example directories.
+# There is a common makefile, 'Examples/javascript/js_example.mk' to simplify
+# create a configuration for a new example.
+
+ROOT_DIR = @ROOT_DIR@
+JSINCLUDES = @JSCOREINC@ @JSV8INC@
+JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
+JSSO =@JSSO@
+JSLDSHARED = @JSLDSHARED@
+JSCXXSHARED = @JSCXXSHARED@
+NODEJS = @NODEJS@
+NODEGYP = @NODEGYP@
+
+# ----------------------------------------------------------------
+# Creating and building Javascript wrappers
+# ----------------------------------------------------------------
+
+javascript_wrapper:
+ $(SWIG) -javascript $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH)
+
+javascript_wrapper_cpp: $(SRCS)
+ $(SWIG) -javascript -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cxx $(INTERFACEPATH)
+
+javascript_build: $(SRCS)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+javascript_build_cpp: $(SRCS)
+ifeq (node,$(JSENGINE))
+ $(NODEGYP) --loglevel=silent configure build 1>>/dev/null
+else
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+endif
+
+# These targets are used by the test-suite:
+
+javascript: $(SRCS) javascript_custom_interpreter
+ $(SWIG) -javascript $(SWIGOPT) $(INTERFACEPATH)
+ifeq (jsc, $(ENGINE))
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+else # (v8 | node) # v8 and node must be compiled as c++
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+endif
+
+javascript_cpp: $(SRCS) javascript_custom_interpreter
+ $(SWIG) -javascript -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Running a Javascript example
+# -----------------------------------------------------------------
+
+javascript_custom_interpreter:
+ (cd $(ROOT_DIR)/Tools/javascript && $(MAKE) JSENGINE='$(JSENGINE)')
+
+ifeq (node,$(JSENGINE))
+javascript_run:
+ $(RUNTOOL) $(NODEJS) $(RUNME).js $(RUNPIPE)
+else
+javascript_run: javascript_custom_interpreter
+ $(RUNTOOL) $(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) -L $(TARGET) $(RUNME).js $(RUNPIPE)
+endif
+
+# -----------------------------------------------------------------
+# Version display
+# -----------------------------------------------------------------
+
+javascript_version:
+ifeq (, $(ENGINE))
+ @if [ "$(NODEJS)" != "" ]; then \
+ echo "Node.js: `($(NODEJS) --version)`"; \
+ echo "node-gyp: `($(NODEGYP) --version)`"; \
+ else \
+ echo "Version depends on the interpreter"; \
+ fi
+endif
+ifeq (node, $(ENGINE))
+ echo "Node.js: `($(NODEJS) --version)`"
+ echo "node-gyp: `($(NODEGYP) --version)`"
+endif
+ifeq (jsc, $(ENGINE))
+ @if [ "@JSCOREVERSION@" != "" ]; then \
+ echo "@JSCOREVERSION@"; \
+ else \
+ echo "Unknown JavascriptCore version."; \
+ fi
+endif
+ifeq (v8, $(ENGINE))
+ echo "Unknown v8 version."
+endif
+
+# -----------------------------------------------------------------
+# Cleaning the Javascript examples
+# -----------------------------------------------------------------
+
+javascript_clean:
+ rm -rf build
+ rm -f *_wrap* $(RUNME)
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
+ (cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean)
+
##################################################################
##### ANDROID ######
##################################################################
@@ -1510,7 +1621,7 @@ R_SCRIPT=$(RUNME).R
r: $(SRCS)
$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
ifneq ($(SRCS),)
- $(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES)
+ $(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES)
endif
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
@@ -1521,7 +1632,7 @@ endif
r_cpp: $(CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
ifneq ($(CXXSRCS),)
- $(CXX) -g -c $(CXXFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
+ $(CXX) -g -c $(CXXFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
endif
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
diff --git a/Examples/chicken/class/example.cxx b/Examples/chicken/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/chicken/class/example.cxx
+++ b/Examples/chicken/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/csharp/class/example.cxx b/Examples/csharp/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/csharp/class/example.cxx
+++ b/Examples/csharp/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/d/class/example.cxx b/Examples/d/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/d/class/example.cxx
+++ b/Examples/d/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/go/class/class.cxx b/Examples/go/class/class.cxx
index 1e8e203dd..f87c7ec8f 100644
--- a/Examples/go/class/class.cxx
+++ b/Examples/go/class/class.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : class.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/go/class/index.html b/Examples/go/class/index.html
index b39119d12..df93b5672 100644
--- a/Examples/go/class/index.html
+++ b/Examples/go/class/index.html
@@ -33,8 +33,8 @@ public:
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
@@ -45,7 +45,7 @@ class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
+ Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
@@ -54,7 +54,7 @@ class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
+ Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};
diff --git a/Examples/guile/class/example.cxx b/Examples/guile/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/guile/class/example.cxx
+++ b/Examples/guile/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/guile/matrix/runme.scm b/Examples/guile/matrix/runme.scm
old mode 100755
new mode 100644
diff --git a/Examples/javascript/check.list b/Examples/javascript/check.list
new file mode 100644
index 000000000..9707e77d4
--- /dev/null
+++ b/Examples/javascript/check.list
@@ -0,0 +1,13 @@
+class
+constant
+enum
+exception
+functor
+nspace
+operator
+overload
+pointer
+#reference
+simple
+template
+variables
diff --git a/Examples/javascript/class/Makefile b/Examples/javascript/class/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/class/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/class/binding.gyp b/Examples/javascript/class/binding.gyp
new file mode 100644
index 000000000..54eebfaa0
--- /dev/null
+++ b/Examples/javascript/class/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/class/example.cxx b/Examples/javascript/class/example.cxx
new file mode 100644
index 000000000..046304519
--- /dev/null
+++ b/Examples/javascript/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.cxx */
+
+#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() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
diff --git a/Examples/javascript/class/example.h b/Examples/javascript/class/example.h
new file mode 100644
index 000000000..642130cd0
--- /dev/null
+++ b/Examples/javascript/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() = 0;
+ virtual double perimeter() = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
+};
diff --git a/Examples/javascript/class/example.i b/Examples/javascript/class/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Examples/javascript/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/javascript/class/example.js b/Examples/javascript/class/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/class/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/class/runme.js b/Examples/javascript/class/runme.js
new file mode 100644
index 000000000..e1d5d9797
--- /dev/null
+++ b/Examples/javascript/class/runme.js
@@ -0,0 +1,46 @@
+var example = require("./example");
+
+// ----- Object creation -----
+
+console.log("Creating some objects:");
+c = new example.Circle(10);
+console.log("Created circle " + c);
+s = new example.Square(10);
+console.log("Created square " + s);
+
+// ----- Access a static member -----
+console.log("\nA total of " + example.Shape.nshapes + " shapes were created"); // access static member as properties of the class object
+
+// ----- Member data access -----
+// Set the location of the object.
+// Note: methods in the base class Shape are used since
+// x and y are defined there.
+
+c.x = 20;
+c.y = 30;
+s.x = -10;
+s.y = 5;
+
+console.log("\nHere is their new position:");
+console.log("Circle = (" + c.x + "," + c.y + ")");
+console.log("Square = (" + s.x + "," + s.y + ")");
+
+// ----- Call some methods -----
+console.log("\nHere are some properties of the shapes:");
+console.log("Circle:");
+console.log("area = " + c.area() + "");
+console.log("perimeter = " + c.perimeter() + "");
+console.log("\n");
+console.log("Square:");
+console.log("area = " + s.area() + "");
+console.log("perimeter = " + s.perimeter() + "");
+
+// ----- Delete everything -----
+console.log("\nGuess I'll clean up now");
+// Note: this invokes the virtual destructor
+delete c;
+delete s;
+
+console.log(example.Shape.nshapes + " shapes remain");
+
+console.log("Goodbye");
diff --git a/Examples/javascript/constant/Makefile b/Examples/javascript/constant/Makefile
new file mode 100644
index 000000000..ea04c7df8
--- /dev/null
+++ b/Examples/javascript/constant/Makefile
@@ -0,0 +1,3 @@
+SRCS =
+
+include ../example.mk
diff --git a/Examples/javascript/constant/binding.gyp b/Examples/javascript/constant/binding.gyp
new file mode 100644
index 000000000..69af46b22
--- /dev/null
+++ b/Examples/javascript/constant/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/constant/example.h b/Examples/javascript/constant/example.h
new file mode 100644
index 000000000..2c88ebd1e
--- /dev/null
+++ b/Examples/javascript/constant/example.h
@@ -0,0 +1,8 @@
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+#define EXTERN extern
+#define FOO (ICONST + BAR)
diff --git a/Examples/javascript/constant/example.i b/Examples/javascript/constant/example.i
new file mode 100644
index 000000000..a6d28e7c9
--- /dev/null
+++ b/Examples/javascript/constant/example.i
@@ -0,0 +1,24 @@
+/* File : example.i */
+%module example
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following directives also produce constants */
+%constant int iconst = 37;
+%constant double fconst = 3.14;
diff --git a/Examples/javascript/constant/example.js b/Examples/javascript/constant/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/constant/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/constant/runme.js b/Examples/javascript/constant/runme.js
new file mode 100644
index 000000000..f4b55881e
--- /dev/null
+++ b/Examples/javascript/constant/runme.js
@@ -0,0 +1,14 @@
+var example = require("./example");
+
+console.log("ICONST = " + example.ICONST + " (should be 42)");
+console.log("FCONST = " + example.FCONST + " (should be 2.1828)");
+console.log("CCONST = " + example.CCONST + " (should be 'x')");
+console.log("CCONST2 = " + example.CCONST2 + " (this should be on a new line)");
+console.log("SCONST = " + example.SCONST + " (should be 'Hello World')");
+console.log("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')");
+console.log("EXPR = " + example.EXPR + " (should be 48.5484)");
+console.log("iconst = " + example.iconst + " (should be 37)");
+console.log("fconst = " + example.fconst + " (should be 3.14)");
+
+console.log("EXTERN = " + example.EXTERN + " (should be undefined)");
+console.log("FOO = " + example.FOO + " (should be undefined)");
diff --git a/Examples/javascript/enum/Makefile b/Examples/javascript/enum/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/enum/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/enum/binding.gyp b/Examples/javascript/enum/binding.gyp
new file mode 100644
index 000000000..54eebfaa0
--- /dev/null
+++ b/Examples/javascript/enum/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/enum/example.cxx b/Examples/javascript/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/Examples/javascript/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.c */
+
+#include "example.h"
+#include
+
+void Foo::enum_test(speed s) {
+ if (s == IMPULSE) {
+ printf("IMPULSE speed\n");
+ } else if (s == WARP) {
+ printf("WARP speed\n");
+ } else if (s == LUDICROUS) {
+ printf("LUDICROUS speed\n");
+ } else {
+ printf("Unknown speed\n");
+ }
+}
+
+void enum_test(color c, Foo::speed s) {
+ if (c == RED) {
+ printf("color = RED, ");
+ } else if (c == BLUE) {
+ printf("color = BLUE, ");
+ } else if (c == GREEN) {
+ printf("color = GREEN, ");
+ } else {
+ printf("color = Unknown color!, ");
+ }
+ if (s == Foo::IMPULSE) {
+ printf("speed = IMPULSE speed\n");
+ } else if (s == Foo::WARP) {
+ printf("speed = WARP speed\n");
+ } else if (s == Foo::LUDICROUS) {
+ printf("speed = LUDICROUS speed\n");
+ } else {
+ printf("speed = Unknown speed!\n");
+ }
+}
diff --git a/Examples/javascript/enum/example.h b/Examples/javascript/enum/example.h
new file mode 100644
index 000000000..9119cd9fc
--- /dev/null
+++ b/Examples/javascript/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/Examples/javascript/enum/example.i b/Examples/javascript/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/Examples/javascript/enum/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/Examples/javascript/enum/example.js b/Examples/javascript/enum/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/enum/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/enum/runme.js b/Examples/javascript/enum/runme.js
new file mode 100644
index 000000000..d4e89e8c8
--- /dev/null
+++ b/Examples/javascript/enum/runme.js
@@ -0,0 +1,34 @@
+var example = require("./example");
+
+// ----- Object creation -----
+
+// Print out the value of some enums
+console.log("*** color ***");
+console.log(" RED =" + example.RED);
+console.log(" BLUE =" + example.BLUE);
+console.log(" GREEN =" + example.GREEN);
+
+console.log("\n*** Foo::speed ***");
+console.log(" Foo_IMPULSE =" + example.Foo.IMPULSE);
+console.log(" Foo_WARP =" + example.Foo.WARP);
+console.log(" Foo_LUDICROUS =" + example.Foo.LUDICROUS);
+
+console.log("\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);
+
+console.log("\nTesting use of enum with class method");
+f = new example.Foo();
+
+f.enum_test(example.Foo.IMPULSE);
+f.enum_test(example.Foo.WARP);
+f.enum_test(example.Foo.LUDICROUS);
+
+// enum value BLUE of enum color is accessed as property of cconst
+console.log("example.BLUE= " + example.BLUE);
+
+// enum value LUDICROUS of enum Foo::speed is accessed as as property of cconst
+console.log("example.speed.LUDICROUS= " + example.Foo.LUDICROUS);
diff --git a/Examples/javascript/example.mk b/Examples/javascript/example.mk
new file mode 100644
index 000000000..274eff1a3
--- /dev/null
+++ b/Examples/javascript/example.mk
@@ -0,0 +1,27 @@
+# Note: as a convention an example must be in a child directory of this.
+# These paths are relative to such an example directory
+
+ifneq (, $(ENGINE))
+ JSENGINE=$(ENGINE)
+else
+ JSENGINE=node
+endif
+
+EXAMPLES_TOP=../..
+SWIG_TOP=../../..
+SWIG = $(SWIG_TOP)/preinst-swig
+TARGET = example
+INTERFACE = example.i
+SWIGOPT=-$(JSENGINE)
+
+check: build
+ $(MAKE) -f $(EXAMPLES_TOP)/Makefile JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run
+
+build:
+ $(MAKE) -f $(EXAMPLES_TOP)/Makefile CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_wrapper_cpp
+ $(MAKE) -f $(EXAMPLES_TOP)/Makefile CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' JSENGINE='$(JSENGINE)' javascript_build_cpp
+
+clean:
+ $(MAKE) -f $(EXAMPLES_TOP)/Makefile javascript_clean
diff --git a/Examples/javascript/exception/Makefile b/Examples/javascript/exception/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/exception/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/exception/binding.gyp b/Examples/javascript/exception/binding.gyp
new file mode 100644
index 000000000..2be0a17a2
--- /dev/null
+++ b/Examples/javascript/exception/binding.gyp
@@ -0,0 +1,29 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ],
+ 'defines': [
+ 'BUILDING_NODE_EXTENSION=1',
+ ],
+ 'conditions': [
+ ['OS=="mac"',
+ {
+ 'xcode_settings': {
+ 'GCC_ENABLE_CPP_RTTI': 'YES',
+ 'GCC_ENABLE_CPP_EXCEPTIONS' : 'YES'
+ }
+ }
+ ],
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"',
+ {
+ 'cflags': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter"],
+ 'cflags_cc': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter"],
+ 'cflags!': [ '-fno-exceptions' ],
+ 'cflags_cc!': [ '-fno-exceptions', '-fno-rtti' ]
+ }
+ ]
+ ]
+ }
+ ]
+}
diff --git a/Examples/javascript/exception/example.cxx b/Examples/javascript/exception/example.cxx
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/Examples/javascript/exception/example.cxx
@@ -0,0 +1 @@
+
diff --git a/Examples/javascript/exception/example.h b/Examples/javascript/exception/example.h
new file mode 100644
index 000000000..7cf917d01
--- /dev/null
+++ b/Examples/javascript/exception/example.h
@@ -0,0 +1,53 @@
+/* File : example.h */
+
+#include
+#ifndef SWIG
+struct A {
+};
+#endif
+
+class Exc {
+public:
+ Exc(int c, const char *m) {
+ code = c;
+ strncpy(msg,m,256);
+ }
+ int code;
+ char msg[256];
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
+class Test {
+public:
+ int simple() throw(int) {
+ throw(37);
+ return 1;
+ }
+ int message() throw(const char *) {
+ throw("I died.");
+ return 1;
+ }
+ int hosed() throw(Exc) {
+ throw(Exc(42,"Hosed"));
+ return 1;
+ }
+ int unknown() throw(A*) {
+ static A a;
+ throw &a;
+ return 1;
+ }
+ int multi(int x) throw(int, const char *, Exc) {
+ if (x == 1) throw(37);
+ if (x == 2) throw("Bleah!");
+ if (x == 3) throw(Exc(42,"No-go-diggy-die"));
+ return 1;
+ }
+};
+
+#if defined(_MSC_VER)
+ #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+
diff --git a/Examples/javascript/exception/example.i b/Examples/javascript/exception/example.i
new file mode 100644
index 000000000..08672c3a8
--- /dev/null
+++ b/Examples/javascript/exception/example.i
@@ -0,0 +1,12 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/javascript/exception/example.js b/Examples/javascript/exception/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/exception/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/exception/runme.js b/Examples/javascript/exception/runme.js
new file mode 100644
index 000000000..977f51ebc
--- /dev/null
+++ b/Examples/javascript/exception/runme.js
@@ -0,0 +1,64 @@
+var example = require("./example");
+
+console.log("Trying to catch some exceptions.");
+t = new example.Test();
+try{
+ t.unknown();
+ throw -1;
+} catch(error)
+{
+ if(error == -1) {
+ console.log("t.unknown() didn't throw");
+ } else {
+ console.log("successfully catched throw in Test::unknown().");
+ }
+}
+
+try{
+ t.simple();
+ throw -1;
+}
+catch(error){
+ if(error == -1) {
+ console.log("t.simple() did not throw");
+ } else {
+ console.log("successfully catched throw in Test::simple().");
+ }
+}
+
+try{
+ t.message();
+ throw -1;
+} catch(error){
+ if(error == -1) {
+ console.log("t.message() did not throw");
+ } else {
+ console.log("successfully catched throw in Test::message().");
+ }
+}
+
+try{
+ t.hosed();
+ throw -1;
+}
+catch(error){
+ if(error == -1) {
+ console.log("t.hosed() did not throw");
+ } else {
+ console.log("successfully catched throw in Test::hosed().");
+ }
+}
+
+for (var i=1; i<4; i++) {
+ try{
+ t.multi(i);
+ throw -1;
+ }
+ catch(error){
+ if(error == -1) {
+ console.log("t.multi(" + i + ") did not throw");
+ } else {
+ console.log("successfully catched throw in Test::multi().");
+ }
+ }
+}
diff --git a/Examples/javascript/functor/Makefile b/Examples/javascript/functor/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/functor/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/functor/binding.gyp b/Examples/javascript/functor/binding.gyp
new file mode 100644
index 000000000..54eebfaa0
--- /dev/null
+++ b/Examples/javascript/functor/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/functor/example.cxx b/Examples/javascript/functor/example.cxx
new file mode 100644
index 000000000..e69de29bb
diff --git a/Examples/javascript/functor/example.i b/Examples/javascript/functor/example.i
new file mode 100644
index 000000000..0450c2124
--- /dev/null
+++ b/Examples/javascript/functor/example.i
@@ -0,0 +1,25 @@
+/* File : example.i */
+%module example
+
+
+%inline %{
+// From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514
+template class Sum {
+ T res;
+public:
+ Sum(T i = 0) : res(i) { }
+ void operator() (T x) { res += x; }
+ T result() const { return res; }
+};
+
+%}
+
+%rename(call) *::operator(); // the fn call operator
+
+// Instantiate a few versions
+%template(intSum) Sum;
+%template(doubleSum) Sum;
+
+
+
+
diff --git a/Examples/javascript/functor/example.js b/Examples/javascript/functor/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/functor/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/functor/runme.js b/Examples/javascript/functor/runme.js
new file mode 100644
index 000000000..dc12470f4
--- /dev/null
+++ b/Examples/javascript/functor/runme.js
@@ -0,0 +1,15 @@
+var example = require("./example");
+
+a = new example.intSum(0);
+b = new example.doubleSum(100.0);
+
+// Use the objects. They should be callable just like a normal
+// javascript function.
+
+for (i=1;i<=100;i++)
+ a.call(i); // Note: function call
+ b.call(Math.sqrt(i)); // Note: function call
+
+console.log(a.result());
+console.log(b.result());
+
diff --git a/Examples/javascript/nspace/Makefile b/Examples/javascript/nspace/Makefile
new file mode 100644
index 000000000..ea04c7df8
--- /dev/null
+++ b/Examples/javascript/nspace/Makefile
@@ -0,0 +1,3 @@
+SRCS =
+
+include ../example.mk
diff --git a/Examples/javascript/nspace/binding.gyp b/Examples/javascript/nspace/binding.gyp
new file mode 100644
index 000000000..69af46b22
--- /dev/null
+++ b/Examples/javascript/nspace/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/nspace/example.h b/Examples/javascript/nspace/example.h
new file mode 100644
index 000000000..53066980a
--- /dev/null
+++ b/Examples/javascript/nspace/example.h
@@ -0,0 +1,23 @@
+#ifndef _example_guardian_
+#define _example_guardian_
+
+int module_function() { return 7; }
+int module_variable = 9;
+
+namespace MyWorld {
+ class World {
+ public:
+ World() : world_max_count(9) {}
+ int create_world() { return 17; }
+ const int world_max_count; // = 9
+ };
+ namespace Nested {
+ class Dweller {
+ public:
+ enum Gender { MALE = 0, FEMALE = 1 };
+ static int count() { return 19; }
+ };
+ }
+}
+
+#endif
diff --git a/Examples/javascript/nspace/example.i b/Examples/javascript/nspace/example.i
new file mode 100644
index 000000000..c30f87fec
--- /dev/null
+++ b/Examples/javascript/nspace/example.i
@@ -0,0 +1,10 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+%nspace MyWorld::Nested::Dweller;
+%nspace MyWorld::World;
+
+%include "example.h"
diff --git a/Examples/javascript/nspace/example.js b/Examples/javascript/nspace/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/nspace/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/nspace/runme.js b/Examples/javascript/nspace/runme.js
new file mode 100644
index 000000000..d6a49d8d4
--- /dev/null
+++ b/Examples/javascript/nspace/runme.js
@@ -0,0 +1,50 @@
+// File: runme.js
+
+// This file illustrates class C++ interface generated
+// by SWIG.
+
+var example = require("./example");
+
+// Calling a module function ( aka global function )
+if (example.module_function() !== 7) {
+ throw new Error("example.module_function() should equal 7");
+}
+console.log("example.module_function(): " + example.module_function());
+
+// Accessing a module (aka global) variable
+if (example.module_variable !== 9) {
+ throw new Error("example.module_variable should equal 9");
+}
+console.log("example.module_variable: " + example.module_variable);
+
+// Creating an instance of the class
+var w1 = new example.MyWorld.World();
+console.log("Creating class instance: w1 = new example.MyWorld.World(): " + w1);
+
+// Accessing class members
+if (w1.create_world() !== 17) {
+ throw new Error("w1.create_world() should equal 17");
+}
+console.log("w1.create_world() = " + w1.create_world());
+
+if (w1.world_max_count !== 9) {
+ throw new Error("w1.world_max_count should equal 9");
+}
+console.log("w1.world_max_count = " + w1.world_max_count);
+
+// Accessing enums from class within namespace
+if (example.MyWorld.Nested.Dweller.MALE !== 0) {
+ throw new Error("example.MyWorld.Nested.Dweller.MALE should equal 0");
+}
+console.log("Accessing enums: ex.MyWorld.Nested.Dweller.MALE = " + example.MyWorld.Nested.Dweller.MALE);
+
+if (example.MyWorld.Nested.Dweller.FEMALE !== 1) {
+ throw new Error("example.MyWorld.Nested.Dweller.FEMALE should equal 1");
+}
+console.log("Accessing enums: ex.MyWorld.Nested.Dweller.FEMALE = " + example.MyWorld.Nested.Dweller.FEMALE);
+
+// Accessing static member function
+if (example.MyWorld.Nested.Dweller.count() !== 19) {
+ throw new Error("example.MyWorld.Nested.Dweller.count() should equal 19");
+}
+console.log("Accessing static member function: ex.MyWorld.Nested.Dweller.count() = " + example.MyWorld.Nested.Dweller.count());
diff --git a/Examples/javascript/operator/Makefile b/Examples/javascript/operator/Makefile
new file mode 100644
index 000000000..ea04c7df8
--- /dev/null
+++ b/Examples/javascript/operator/Makefile
@@ -0,0 +1,3 @@
+SRCS =
+
+include ../example.mk
diff --git a/Examples/javascript/operator/binding.gyp b/Examples/javascript/operator/binding.gyp
new file mode 100644
index 000000000..69af46b22
--- /dev/null
+++ b/Examples/javascript/operator/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/operator/example.h b/Examples/javascript/operator/example.h
new file mode 100644
index 000000000..4da6a2307
--- /dev/null
+++ b/Examples/javascript/operator/example.h
@@ -0,0 +1,36 @@
+/* File : example.h */
+#include
+
+class Complex {
+private:
+ double rpart, ipart;
+public:
+ Complex(double r = 0, double i = 0) : rpart(r), ipart(i) { }
+ Complex(const Complex &c) : rpart(c.rpart), ipart(c.ipart) { }
+ Complex &operator=(const Complex &c) {
+ rpart = c.rpart;
+ ipart = c.ipart;
+ return *this;
+ }
+ Complex operator+(const Complex &c) const {
+ return Complex(rpart+c.rpart, ipart+c.ipart);
+ }
+ Complex operator-(const Complex &c) const {
+ return Complex(rpart-c.rpart, ipart-c.ipart);
+ }
+ Complex operator*(const Complex &c) const {
+ return Complex(rpart*c.rpart - ipart*c.ipart,
+ rpart*c.ipart + c.rpart*ipart);
+ }
+ Complex operator-() const {
+ return Complex(-rpart, -ipart);
+ }
+
+ double re() const { return rpart; }
+ double im() const { return ipart; }
+};
+
+
+
+
+
diff --git a/Examples/javascript/operator/example.i b/Examples/javascript/operator/example.i
new file mode 100644
index 000000000..7a1bd45e1
--- /dev/null
+++ b/Examples/javascript/operator/example.i
@@ -0,0 +1,34 @@
+/* File : example.i */
+%module example
+#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
+%{
+#include "example.h"
+%}
+
+/* This header file is a little tough to handle because it has overloaded
+ operators and constructors. We're going to try and deal with that here */
+
+/* This turns the copy constructor in a function ComplexCopy() that can
+ be called */
+
+%rename(assign) Complex::operator=;
+%rename(plus) Complex::operator+;
+%rename(minus) Complex::operator-(const Complex &) const;
+%rename(uminus) Complex::operator-() const;
+%rename(times) Complex::operator*;
+
+/* Now grab the original header file */
+%include "example.h"
+
+/* An output method that turns a complex into a short string */
+%extend Complex {
+ char *toString() {
+ static char temp[512];
+ sprintf(temp,"(%g,%g)", $self->re(), $self->im());
+ return temp;
+ }
+ static Complex* copy(const Complex& c) {
+ return new Complex(c);
+ }
+};
+
diff --git a/Examples/javascript/operator/example.js b/Examples/javascript/operator/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/operator/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/operator/runme.js b/Examples/javascript/operator/runme.js
new file mode 100644
index 000000000..a700918d6
--- /dev/null
+++ b/Examples/javascript/operator/runme.js
@@ -0,0 +1,25 @@
+var example = require("./example");
+
+a = new example.Complex(2,3);
+b = new example.Complex(-5,10);
+
+console.log ("a =" + a);
+console.log ("b =" + b);
+
+c = a.plus(b);
+
+console.log("c =" + c);
+console.log("a*b =" + a.times(b));
+console.log("a-c =" + a.minus(c));
+
+e = example.Complex.copy(a.minus(c));
+console.log("e =" + e);
+
+// Big expression
+f = a.plus(b).times(c.plus(b.times(e))).plus(a.uminus());
+console.log("f =" + f);
+
+
+
+
+
diff --git a/Examples/javascript/overload/Makefile b/Examples/javascript/overload/Makefile
new file mode 100644
index 000000000..ea04c7df8
--- /dev/null
+++ b/Examples/javascript/overload/Makefile
@@ -0,0 +1,3 @@
+SRCS =
+
+include ../example.mk
diff --git a/Examples/javascript/overload/binding.gyp b/Examples/javascript/overload/binding.gyp
new file mode 100644
index 000000000..69af46b22
--- /dev/null
+++ b/Examples/javascript/overload/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/overload/example.h b/Examples/javascript/overload/example.h
new file mode 100644
index 000000000..2f112f1e1
--- /dev/null
+++ b/Examples/javascript/overload/example.h
@@ -0,0 +1,28 @@
+#include
+
+void f() {
+ std::cout << "Called f()." << std::endl;
+}
+
+void f(int val) {
+ std::cout << "Called f(int)." << std::endl;
+}
+void f(int val1, int val2) {
+ std::cout << "Called f(int, int)." << std::endl;
+}
+
+void f(const char* s) {
+ std::cout << "Called f(const char*)." << std::endl;
+}
+
+void f(bool val) {
+ std::cout << "Called f(bool)." << std::endl;
+}
+
+void f(long val) {
+ std::cout << "Called f(long)." << std::endl;
+}
+
+void f(double val) {
+ std::cout << "Called f(double)." << std::endl;
+}
diff --git a/Examples/javascript/overload/example.i b/Examples/javascript/overload/example.i
new file mode 100644
index 000000000..b86689f8a
--- /dev/null
+++ b/Examples/javascript/overload/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/*
+ Note: overloading is implemented in a sloppy way currently
+ i.e., only the number of arguments is taken into conideration
+ for dispatching.
+ To solve the problem one has to rename such conflicting methods.
+*/
+%rename(f_double) f(double val);
+
+%include "example.h"
diff --git a/Examples/javascript/overload/example.js b/Examples/javascript/overload/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/overload/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/overload/runme.js b/Examples/javascript/overload/runme.js
new file mode 100644
index 000000000..1e6c861a6
--- /dev/null
+++ b/Examples/javascript/overload/runme.js
@@ -0,0 +1,9 @@
+var example = require("./example");
+
+example.f();
+example.f(1);
+example.f(1, 2);
+example.f("bla");
+example.f(false);
+example.f(11111111111);
+example.f_double(1.0);
diff --git a/Examples/javascript/pointer/Makefile b/Examples/javascript/pointer/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/pointer/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/pointer/binding.gyp b/Examples/javascript/pointer/binding.gyp
new file mode 100644
index 000000000..54eebfaa0
--- /dev/null
+++ b/Examples/javascript/pointer/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/pointer/example.cxx b/Examples/javascript/pointer/example.cxx
new file mode 100644
index 000000000..8762329fe
--- /dev/null
+++ b/Examples/javascript/pointer/example.cxx
@@ -0,0 +1,16 @@
+/* File : example.c */
+
+void add(int *x, int *y, int *result) {
+ *result = *x + *y;
+}
+
+void subtract(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+
+int divide(int n, int d, int *r) {
+ int q;
+ q = n/d;
+ *r = n - q*d;
+ return q;
+}
diff --git a/Examples/javascript/pointer/example.i b/Examples/javascript/pointer/example.i
new file mode 100644
index 000000000..38c67d7d2
--- /dev/null
+++ b/Examples/javascript/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void subtract(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void subtract(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/Examples/javascript/pointer/example.js b/Examples/javascript/pointer/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/pointer/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/pointer/runme.js b/Examples/javascript/pointer/runme.js
new file mode 100644
index 000000000..fb8cf0c74
--- /dev/null
+++ b/Examples/javascript/pointer/runme.js
@@ -0,0 +1,35 @@
+var example = require("./example");
+
+// First create some objects using the pointer library.
+console.log("Testing the pointer library");
+a = example.new_intp();
+b = example.new_intp();
+c = example.new_intp();
+
+example.intp_assign(a,37);
+example.intp_assign(b,42);
+
+console.log(" a = " + example.intp_value(a));
+console.log(" b = " + example.intp_value(b));
+console.log(" c = " + example.intp_value(c));
+
+//// Call the add() function with some pointers
+example.add(a, b, c);
+
+//
+//// Now get the result
+r = example.intp_value(c);
+console.log(" 37 + 42 = " + r);
+
+// Clean up the pointers
+example.delete_intp(a);
+example.delete_intp(b);
+example.delete_intp(c);
+
+//// Now try the typemap library
+//// This should be much easier. Now how it is no longer
+//// necessary to manufacture pointers.
+//"OUTPUT" Mapping is not supported
+//console.log("Trying the typemap library");
+//r = example.subtract(37,42);
+//console.log("37 - 42 =" + r);
diff --git a/Examples/javascript/pointer/typemaps.i b/Examples/javascript/pointer/typemaps.i
new file mode 100644
index 000000000..e69de29bb
diff --git a/Examples/javascript/reference/Makefile b/Examples/javascript/reference/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/reference/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/reference/binding.gyp b/Examples/javascript/reference/binding.gyp
new file mode 100644
index 000000000..54eebfaa0
--- /dev/null
+++ b/Examples/javascript/reference/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/reference/example.cxx b/Examples/javascript/reference/example.cxx
new file mode 100644
index 000000000..8a513bf49
--- /dev/null
+++ b/Examples/javascript/reference/example.cxx
@@ -0,0 +1,46 @@
+/* File : example.cxx */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include "example.h"
+#include
+#include
+
+Vector operator+(const Vector &a, const Vector &b) {
+ Vector r;
+ r.x = a.x + b.x;
+ r.y = a.y + b.y;
+ r.z = a.z + b.z;
+ return r;
+}
+
+char *Vector::print() {
+ static char temp[512];
+ sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+ return temp;
+}
+
+VectorArray::VectorArray(int size) {
+ items = new Vector[size];
+ maxsize = size;
+}
+
+VectorArray::~VectorArray() {
+ delete [] items;
+}
+
+Vector &VectorArray::operator[](int index) {
+ if ((index < 0) || (index >= maxsize)) {
+ printf("Panic! Array index out of bounds.\n");
+ exit(1);
+ }
+ return items[index];
+}
+
+int VectorArray::size() {
+ return maxsize;
+}
+
diff --git a/Examples/javascript/reference/example.h b/Examples/javascript/reference/example.h
new file mode 100644
index 000000000..4915adb1b
--- /dev/null
+++ b/Examples/javascript/reference/example.h
@@ -0,0 +1,26 @@
+/* File : example.h */
+
+class Vector {
+private:
+ double x,y,z;
+public:
+ Vector() : x(0), y(0), z(0) { };
+ Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+ friend Vector operator+(const Vector &a, const Vector &b);
+ char *print();
+};
+
+class VectorArray {
+private:
+ Vector *items;
+ int maxsize;
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ Vector &operator[](int);
+ int size();
+};
+
+
+
+
diff --git a/Examples/javascript/reference/example.i b/Examples/javascript/reference/example.i
new file mode 100644
index 000000000..1cf19c82c
--- /dev/null
+++ b/Examples/javascript/reference/example.i
@@ -0,0 +1,42 @@
+/* File : example.i */
+
+/* This file has a few "typical" uses of C++ references. */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+class Vector {
+public:
+ Vector(double x, double y, double z);
+ ~Vector();
+ char *print();
+};
+
+/* This helper function calls an overloaded operator */
+%inline %{
+Vector addv(Vector &a, Vector &b) {
+ return a+b;
+}
+%}
+
+/* Wrapper around an array of vectors class */
+
+class VectorArray {
+public:
+ VectorArray(int maxsize);
+ ~VectorArray();
+ int size();
+
+ /* This wrapper provides an alternative to the [] operator */
+ %extend {
+ Vector &get(int index) {
+ return (*$self)[index];
+ }
+ void set(int index, Vector &a) {
+ (*$self)[index] = a;
+ }
+ }
+};
diff --git a/Examples/javascript/reference/example.js b/Examples/javascript/reference/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/reference/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/reference/runme.js b/Examples/javascript/reference/runme.js
new file mode 100644
index 000000000..88c108314
--- /dev/null
+++ b/Examples/javascript/reference/runme.js
@@ -0,0 +1,67 @@
+// This file illustrates the manipulation of C++ references in Javascript.
+var example = require("./example");
+
+// ----- Object creation -----
+
+console.log("Creating some objects:");
+a = new example.Vector(3,4,5);
+b = new example.Vector(10,11,12);
+
+console.log(" created" + a.print());
+console.log(" created" + b.print());
+
+// ----- Call an overloaded operator -----
+
+// This calls the wrapper we placed around operator+(const Vector &a, const Vector &)
+// It returns a new allocated object.
+
+console.log("Adding a+b");
+c = example.addv(a, b);
+console.log("a+b = " + c.print());
+
+
+// TODO: Note: Unless we free the result, a memory leak will occur
+//delete_Vector(c);
+
+// ----- Create a vector array -----
+
+// Note: Using the high-level interface here
+console.log("Creating an array of vectors");
+va = new example.VectorArray(10);
+console.log("va = " + va);
+
+// ----- Set some values in the array -----
+
+// These operators copy the value of a and b to the vector array
+va.set(0,a);
+va.set(1,b);
+
+// This will work, but it will cause a memory leak!
+va.set(2,example.addv(a,b));
+
+// The non-leaky way to do it
+//c = addv(a,b);
+//va.set(3,c);
+//delete_Vector(c);
+
+// Get some values from the array
+
+console.log("Getting some array values");
+for (i = 0; i < 5; i++) {
+ temp = va.get(i);
+ console.log(i,temp.print());
+}
+
+// Watch under resource meter to check on this
+console.log("Making sure we don't leak memory.");
+for (i = 0; i < 1000000; i++) {
+ c = va.get(i % 10);
+}
+//---------TODO---------
+//----- Clean up -----
+//console.log("Cleaning up");
+
+//example.delete_VectorArray(va);
+//example.delete_Vector(a);
+//example.delete_Vector(b);
+
diff --git a/Examples/javascript/simple/Makefile b/Examples/javascript/simple/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/simple/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/simple/binding.gyp b/Examples/javascript/simple/binding.gyp
new file mode 100644
index 000000000..54eebfaa0
--- /dev/null
+++ b/Examples/javascript/simple/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/simple/example.cxx b/Examples/javascript/simple/example.cxx
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/javascript/simple/example.cxx
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/Examples/javascript/simple/example.i b/Examples/javascript/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/Examples/javascript/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/Examples/javascript/simple/example.js b/Examples/javascript/simple/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/simple/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/simple/runme.js b/Examples/javascript/simple/runme.js
new file mode 100644
index 000000000..be2c18669
--- /dev/null
+++ b/Examples/javascript/simple/runme.js
@@ -0,0 +1,26 @@
+var example = require("./example");
+
+/* Call our gcd() function */
+
+x = 42;
+y = 105;
+g = example.gcd(x,y);
+console.log("GCD of x and y is=" + g);
+
+/* Manipulate the Foo global variable */
+
+/* Output its current value */
+console.log("Global variable Foo=" + example.Foo);
+
+/* Change its value */
+example.Foo = 3.1415926;
+
+/* See if the change took effect */
+console.log("Variable Foo changed to=" + example.Foo);
+
+
+
+
+
+
+
diff --git a/Examples/javascript/template/Makefile b/Examples/javascript/template/Makefile
new file mode 100644
index 000000000..ea04c7df8
--- /dev/null
+++ b/Examples/javascript/template/Makefile
@@ -0,0 +1,3 @@
+SRCS =
+
+include ../example.mk
diff --git a/Examples/javascript/template/binding.gyp b/Examples/javascript/template/binding.gyp
new file mode 100644
index 000000000..69af46b22
--- /dev/null
+++ b/Examples/javascript/template/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/template/example.h b/Examples/javascript/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/Examples/javascript/template/example.h
@@ -0,0 +1,32 @@
+/* File : example.h */
+
+// Some template definitions
+
+template T max(T a, T b) { return a>b ? a : b; }
+
+template class vector {
+ T *v;
+ int sz;
+ public:
+ vector(int _sz) {
+ v = new T[_sz];
+ sz = _sz;
+ }
+ T &get(int index) {
+ return v[index];
+ }
+ void set(int index, T &val) {
+ v[index] = val;
+ }
+#ifdef SWIG
+ %extend {
+ T getitem(int index) {
+ return $self->get(index);
+ }
+ void setitem(int index, T val) {
+ $self->set(index,val);
+ }
+ }
+#endif
+};
+
diff --git a/Examples/javascript/template/example.i b/Examples/javascript/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/Examples/javascript/template/example.i
@@ -0,0 +1,17 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max;
+%template(maxdouble) max;
+%template(vecint) vector;
+%template(vecdouble) vector;
+
diff --git a/Examples/javascript/template/example.js b/Examples/javascript/template/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/template/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/template/runme.js b/Examples/javascript/template/runme.js
new file mode 100644
index 000000000..55894dfd5
--- /dev/null
+++ b/Examples/javascript/template/runme.js
@@ -0,0 +1,30 @@
+var example = require("./example");
+
+//Call some templated functions
+console.log(example.maxint(3,7));
+console.log(example.maxdouble(3.14,2.18));
+
+// Create some class
+
+iv = new example.vecint(100);
+dv = new example.vecdouble(1000);
+
+for(i=0;i<=100;i++)
+ iv.setitem(i,2*i);
+
+for(i=0;i<=1000;i++)
+ dv.setitem(i, 1.0/(i+1));
+
+sum = 0;
+for(i=0;i<=100;i++)
+ sum = sum + iv.getitem(i);
+
+console.log(sum);
+
+sum = 0.0;
+for(i=0;i<=1000;i++)
+ sum = sum + dv.getitem(i);
+console.log(sum);
+
+delete iv;
+delete dv;
diff --git a/Examples/javascript/variables/Makefile b/Examples/javascript/variables/Makefile
new file mode 100644
index 000000000..31846faae
--- /dev/null
+++ b/Examples/javascript/variables/Makefile
@@ -0,0 +1,3 @@
+SRCS = example.cxx
+
+include ../example.mk
diff --git a/Examples/javascript/variables/binding.gyp b/Examples/javascript/variables/binding.gyp
new file mode 100644
index 000000000..54eebfaa0
--- /dev/null
+++ b/Examples/javascript/variables/binding.gyp
@@ -0,0 +1,8 @@
+{
+ "targets": [
+ {
+ "target_name": "example",
+ "sources": [ "example.cxx", "example_wrap.cxx" ]
+ }
+ ]
+}
diff --git a/Examples/javascript/variables/example.cxx b/Examples/javascript/variables/example.cxx
new file mode 100644
index 000000000..f10390a9e
--- /dev/null
+++ b/Examples/javascript/variables/example.cxx
@@ -0,0 +1,96 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include
+#include
+#include "example.h"
+
+int ivar = 0;
+short svar = 0;
+long lvar = 0;
+unsigned int uivar = 0;
+unsigned short usvar = 0;
+unsigned long ulvar = 0;
+signed char scvar = 0;
+unsigned char ucvar = 0;
+char cvar = 0;
+float fvar = 0;
+double dvar = 0;
+char *strvar = 0;
+#ifdef __cplusplus // Note: for v8 this must be linkable with g++, without extern cstrvar is mangled
+extern const char cstrvar[] = "Goodbye";
+#else
+const char cstrvar[] = "Goodbye";
+#endif
+const
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar);
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/Examples/javascript/variables/example.h b/Examples/javascript/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/Examples/javascript/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/Examples/javascript/variables/example.i b/Examples/javascript/variables/example.i
new file mode 100644
index 000000000..591b871ed
--- /dev/null
+++ b/Examples/javascript/variables/example.i
@@ -0,0 +1,49 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/Examples/javascript/variables/example.js b/Examples/javascript/variables/example.js
new file mode 100644
index 000000000..79cd3913f
--- /dev/null
+++ b/Examples/javascript/variables/example.js
@@ -0,0 +1 @@
+module.exports = require("./build/Release/example");
diff --git a/Examples/javascript/variables/runme.js b/Examples/javascript/variables/runme.js
new file mode 100644
index 000000000..537e17296
--- /dev/null
+++ b/Examples/javascript/variables/runme.js
@@ -0,0 +1,68 @@
+var example = require("./example");
+
+// Try to set the values of some global variables
+example.ivar = 42;
+example.svar = -31000;
+example.lvar = 65537;
+example.uivar = 123456;
+example.usvar = 61000;
+example.ulvar = 654321;
+example.scvar = -13;
+example.ucvar = 251;
+example.cvar = "S";
+example.fvar = 3.14159;
+example.dvar = 2.1828;
+example.strvar = "Hello World";
+example.iptrvar= example.new_int(37);
+example.ptptr = example.new_Point(37,42);
+example.name = "Bill";
+
+// Now console.log out the values of the variables
+console.log("Variables (values printed from Javascript)");
+console.log("ivar = " + example.ivar);
+console.log("svar = " + example.svar);
+console.log("lvar = " + example.lvar);
+console.log("uivar = " + example.uivar);
+console.log("usvar = " + example.usvar);
+console.log("ulvar = " + example.ulvar);
+console.log("scvar = " + example.scvar);
+console.log("ucvar = " + example.ucvar);
+console.log("fvar = " + example.fvar);
+console.log("dvar = " + example.dvar);
+console.log("cvar = " + example.cvar);
+console.log("strvar = " + example.strvar);
+console.log("cstrvar = " + example.cstrvar);
+console.log("iptrvar = " + example.iptrvar);
+console.log("name = " + example.name);
+console.log("ptptr = " + example.ptptr + ": " + example.Point_print(example.ptptr));
+console.log("pt = " + example.pt + ": " + example.Point_print(example.pt));
+
+
+console.log("\nVariables (values printed from C)");
+
+example.print_vars();
+
+console.log("\nNow I'm going to try and modify some read only variables");
+
+console.log("Tring to set 'path'");
+try{
+ example.path = "Whoa!";
+ console.log("Hey, what's going on?!?! This shouldn't work");
+}
+catch(e){
+ console.log("Good.");
+}
+
+console.log("Trying to set 'status'");
+try{
+ example.status = 0;
+ console.log("Hey, what's going on?!?! This shouldn't work");
+} catch(e){
+ console.log("Good.");
+}
+
+console.log("\nI'm going to try and update a structure variable.");
+example.pt = example.ptptr;
+console.log("The new value is: ");
+example.pt_print();
+console.log("You should see the value: " + example.Point_print(example.ptptr));
diff --git a/Examples/lua/class/example.cxx b/Examples/lua/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/lua/class/example.cxx
+++ b/Examples/lua/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/lua/class/runme.lua b/Examples/lua/class/runme.lua
index 2c3ad8ced..5d140defe 100644
--- a/Examples/lua/class/runme.lua
+++ b/Examples/lua/class/runme.lua
@@ -53,7 +53,6 @@ print("\nGuess I'll clean up now")
-- Note: this invokes the virtual destructor
c=nil
s=nil
-s = 3
-- call gc to make sure they are collected
collectgarbage()
diff --git a/Examples/modula3/class/example.cxx b/Examples/modula3/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/modula3/class/example.cxx
+++ b/Examples/modula3/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/octave/class/example.cxx b/Examples/octave/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/octave/class/example.cxx
+++ b/Examples/octave/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/perl5/check.list b/Examples/perl5/check.list
index 78d45fc0b..dda849311 100644
--- a/Examples/perl5/check.list
+++ b/Examples/perl5/check.list
@@ -6,6 +6,7 @@ constants2
extend
funcptr
import
+java
multimap
multiple_inheritance
pointer
diff --git a/Examples/perl5/java/Makefile b/Examples/perl5/java/Makefile
index ff3aab0e7..3a0bb215d 100644
--- a/Examples/perl5/java/Makefile
+++ b/Examples/perl5/java/Makefile
@@ -8,15 +8,15 @@ LIBS = -lm
check: build
$(MAKE) -f $(TOP)/Makefile perl5_run
-build: Example.class
+build: Example.class Example.h
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp
clean:
$(MAKE) -f $(TOP)/Makefile perl5_clean
rm -f *.class Example.h
-Example.class: Example.java
+Example.class Example.h: Example.java
gcj -fPIC -C -c -g Example.java
- gcjh Example
+ gcjh Example.class
diff --git a/Examples/python/java/Makefile b/Examples/python/java/Makefile
index 12a9b512a..2ce219969 100644
--- a/Examples/python/java/Makefile
+++ b/Examples/python/java/Makefile
@@ -6,10 +6,11 @@ INTERFACE = example.i
LIBS = -lm
check: build
+ $(MAKE) -f $(TOP)/Makefile python_run
-build: Example.class
+build: Example.class Example.h
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp
clean:
@@ -17,6 +18,6 @@ clean:
rm -f $(TARGET).py
rm -f *.class Example.h
-Example.class: Example.java
+Example.class Example.h: Example.java
gcj -fPIC -C -c -g Example.java
- gcjh Example
+ gcjh Example.class
diff --git a/Examples/python/java/example.i b/Examples/python/java/example.i
index 13d5b5e70..80e08870f 100644
--- a/Examples/python/java/example.i
+++ b/Examples/python/java/example.i
@@ -7,3 +7,7 @@
%include Example.h
+
+%extend Example {
+ ~Example() {}
+}
diff --git a/Examples/r/class/example.cxx b/Examples/r/class/example.cxx
index 1e8e203dd..046304519 100644
--- a/Examples/r/class/example.cxx
+++ b/Examples/r/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
-double Circle::area(void) {
+double Circle::area() {
return M_PI*radius*radius;
}
-double Circle::perimeter(void) {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-double Square::area(void) {
+double Square::area() {
return width*width;
}
-double Square::perimeter(void) {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/ruby/java/Makefile b/Examples/ruby/java/Makefile
index 4d2493493..a71635baa 100644
--- a/Examples/ruby/java/Makefile
+++ b/Examples/ruby/java/Makefile
@@ -8,15 +8,15 @@ LIBS = -lm
check: build
$(MAKE) -f $(TOP)/Makefile ruby_run
-build: Example.class
+build: Example.class Example.h
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp
clean:
$(MAKE) -f $(TOP)/Makefile ruby_clean
rm -f *.class Example.h
-Example.class: Example.java
+Example.class Example.h: Example.java
gcj -fPIC -C -c -g Example.java
- gcjh Example
+ gcjh Example.class
diff --git a/Examples/tcl/java/Makefile b/Examples/tcl/java/Makefile
index 3a9212381..a3819ab7c 100644
--- a/Examples/tcl/java/Makefile
+++ b/Examples/tcl/java/Makefile
@@ -8,18 +8,15 @@ LIBS = -lm
check: build
$(MAKE) -f $(TOP)/Makefile tcl_run
-build: Example.class
+build: Example.class Example.h
$(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
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ TCLCXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp
clean:
$(MAKE) -f $(TOP)/Makefile tcl_clean
rm -f *.class Example.h
-run:
- tclsh runme.tcl
-
-Example.class: Example.java
+Example.class Example.h: Example.java
gcj -fPIC -C -c -g Example.java
- gcjh Example
+ gcjh Example.class
diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in
index 5f75bfc08..697c15a45 100644
--- a/Examples/test-suite/allegrocl/Makefile.in
+++ b/Examples/test-suite/allegrocl/Makefile.in
@@ -12,7 +12,7 @@ top_builddir = @top_builddir@
# these cpp tests generate warnings/errors when compiling
# the wrapper .cxx file.
-CPP_TEST_BROKEN_CXX =
+CPP_TEST_BROKEN_CXX =
# the error is wrap:action code generated by swig. \
# error: can't convert [std::string] 'b' to 'bool' \
# might just need a bool overload op for std::string. \
@@ -71,7 +71,7 @@ CPP_TEST_CASES_ACL_UNSUPPORTED = \
extern_throws \
throw_exception \
using_pointers \
-
+
C_TEST_CASES_ACL_BROKEN = \
# 'cdate.i' module support \
li_cdata \
@@ -96,7 +96,7 @@ include $(srcdir)/../common.mk
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -106,7 +106,7 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -123,4 +123,3 @@ run_testcase = \
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean
-
diff --git a/Examples/test-suite/c_delete.i b/Examples/test-suite/c_delete.i
index 632340629..0c69f9f41 100644
--- a/Examples/test-suite/c_delete.i
+++ b/Examples/test-suite/c_delete.i
@@ -2,9 +2,9 @@
/* check C++ delete keyword is okay in C wrappers */
-#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD
+%warnfilter(SWIGWARN_PARSE_KEYWORD) delete;
-#if !defined(SWIGOCTAVE) /* Octave compiles wrappers as C++ */
+#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */
%inline %{
struct delete {
diff --git a/Examples/test-suite/c_delete_function.i b/Examples/test-suite/c_delete_function.i
index 3739ceadc..8164d066b 100644
--- a/Examples/test-suite/c_delete_function.i
+++ b/Examples/test-suite/c_delete_function.i
@@ -2,7 +2,9 @@
/* check C++ delete keyword is okay in C wrappers */
-#if !defined(SWIGOCTAVE) /* Octave compiles wrappers as C++ */
+%warnfilter(SWIGWARN_PARSE_KEYWORD) delete;
+
+#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */
%inline %{
double delete(double d) { return d; }
diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in
index aa8b40aec..473d395fd 100644
--- a/Examples/test-suite/cffi/Makefile.in
+++ b/Examples/test-suite/cffi/Makefile.in
@@ -14,13 +14,13 @@ include $(srcdir)/../common.mk
# Overridden variables here
# no C++ tests for now
CPP_TEST_CASES =
-#C_TEST_CASES +=
+#C_TEST_CASES +=
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -30,7 +30,7 @@ CPP_TEST_CASES =
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -44,8 +44,7 @@ run_testcase = \
# Clean: (does nothing, we dont generate extra cffi code)
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile cffi_clean
-
diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in
index 3c2f3de54..4ee8cb0fa 100644
--- a/Examples/test-suite/chicken/Makefile.in
+++ b/Examples/test-suite/chicken/Makefile.in
@@ -3,7 +3,7 @@
#######################################################################
LANGUAGE = chicken
-VARIANT =
+VARIANT =
SCRIPTSUFFIX = _runme.ss
PROXYSUFFIX = _runme_proxy.ss
srcdir = @srcdir@
@@ -17,7 +17,7 @@ SO = @SO@
# Skip the STD cases for now, except for li_std_string.i
SKIP_CPP_STD_CASES = Yes
-CPP_TEST_CASES += li_std_string
+CPP_TEST_CASES += li_std_string
EXTRA_TEST_CASES += chicken_ext_test.externaltest
@@ -39,7 +39,7 @@ SWIGOPT += -nounit
%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -55,7 +55,7 @@ SWIGOPT += -nounit
$(MAKE) $*.cproxy; \
fi
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -92,7 +92,7 @@ run_testcase = \
# Clean
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile chicken_clean
diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in
index 24655a60f..1fe3c23ac 100644
--- a/Examples/test-suite/clisp/Makefile.in
+++ b/Examples/test-suite/clisp/Makefile.in
@@ -14,13 +14,13 @@ include $(srcdir)/../common.mk
# Overridden variables here
# no C++ tests for now
CPP_TEST_CASES =
-#C_TEST_CASES +=
+#C_TEST_CASES +=
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -30,7 +30,7 @@ CPP_TEST_CASES =
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -44,8 +44,7 @@ run_testcase = \
# Clean: (does nothing, we dont generate extra clisp code)
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile clisp_clean
-
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index d0463badd..3614f0467 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -609,6 +609,7 @@ C_TEST_CASES += \
global_functions \
immutable_values \
inctest \
+ infinity \
integers \
keyword_rename \
lextype \
@@ -635,6 +636,7 @@ C_TEST_CASES += \
simple_array \
sizeof_pointer \
sneaky1 \
+ string_simple \
struct_rename \
struct_initialization \
typedef_struct \
diff --git a/Examples/test-suite/constructor_copy.i b/Examples/test-suite/constructor_copy.i
index bfbd706f4..8e92e7840 100644
--- a/Examples/test-suite/constructor_copy.i
+++ b/Examples/test-suite/constructor_copy.i
@@ -73,7 +73,7 @@ public:
%include "std_vector.i"
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT)
#define SWIG_GOOD_VECTOR
%ignore std::vector::vector(size_type);
%ignore std::vector::resize(size_type);
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 993699bc8..e54edcc35 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -40,7 +40,7 @@ csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+(cd $* && $(swig_and_compile_cpp))
+$(run_testcase)
@@ -50,7 +50,7 @@ csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP
+(cd $* && $(swig_and_compile_c))
+$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+(cd $* && $(swig_and_compile_multi_cpp))
+$(run_testcase)
diff --git a/Examples/test-suite/director_nspace.i b/Examples/test-suite/director_nspace.i
index fdea75e2f..f24227c68 100644
--- a/Examples/test-suite/director_nspace.i
+++ b/Examples/test-suite/director_nspace.i
@@ -40,7 +40,7 @@ namespace TopLevel
%include
// nspace feature only supported by these languages
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
%nspace TopLevel::Bar::Foo;
%nspace TopLevel::Bar::FooBar;
#else
diff --git a/Examples/test-suite/director_nspace_director_name_collision.i b/Examples/test-suite/director_nspace_director_name_collision.i
index 8fd27c968..190bdf4fa 100644
--- a/Examples/test-suite/director_nspace_director_name_collision.i
+++ b/Examples/test-suite/director_nspace_director_name_collision.i
@@ -34,7 +34,7 @@ namespace TopLevel
%include
// nspace feature only supported by these languages
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
%nspace TopLevel::A::Foo;
%nspace TopLevel::B::Foo;
#else
diff --git a/Examples/test-suite/enum_forward.i b/Examples/test-suite/enum_forward.i
index 1609fa8e9..c82e17be7 100644
--- a/Examples/test-suite/enum_forward.i
+++ b/Examples/test-suite/enum_forward.i
@@ -1,7 +1,7 @@
%module enum_forward
-/* This contains C code that is not valid C++03 and Octave wrappers are always compiled as C++ */
-#if !defined(SWIGOCTAVE)
+/* This contains C code that is not valid C++03 and Octave, and Javascript(v8) wrappers are always compiled as C++ */
+#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
%{
enum ForwardEnum1 { AAA, BBB };
enum ForwardEnum2 { CCC, DDD };
diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in
index 601dcd303..e4ba7b751 100644
--- a/Examples/test-suite/errors/Makefile.in
+++ b/Examples/test-suite/errors/Makefile.in
@@ -29,13 +29,13 @@ CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES))
C_ERROR_TEST_CASES := $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES))
ERROR_TEST_CASES := $(CPP_ERROR_TEST_CASES:=.cpptest) \
- $(C_ERROR_TEST_CASES:=.ctest)
+ $(C_ERROR_TEST_CASES:=.ctest)
include $(srcdir)/../common.mk
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
echo "$(ACTION)ing errors testcase $*"
-$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $*.i 2>&1 | $(TODOS) > $*.$(ERROR_EXT)
$(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT)
@@ -46,9 +46,8 @@ include $(srcdir)/../common.mk
$(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT)
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile $(LANGUAGE)_clean
@rm -f *.$(ERROR_EXT) *.py
-
diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in
index 535d05a6e..64a84f820 100644
--- a/Examples/test-suite/go/Makefile.in
+++ b/Examples/test-suite/go/Makefile.in
@@ -29,7 +29,7 @@ include $(srcdir)/../common.mk
.SUFFIXES: .cpptest .ctest .multicpptest
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase_cpp)
@@ -39,7 +39,7 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_multi_testcase)
diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in
index 0c7b3137c..493dde4f5 100644
--- a/Examples/test-suite/guile/Makefile.in
+++ b/Examples/test-suite/guile/Makefile.in
@@ -14,9 +14,9 @@ GUILE = @GUILE@
GUILE_RUNTIME=
C_TEST_CASES = long_long \
- list_vector \
- multivalue \
- pointer_in_out
+ list_vector \
+ multivalue \
+ pointer_in_out
include $(srcdir)/../common.mk
@@ -28,7 +28,7 @@ INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile
%.multicpptest: SWIGOPT += $(GUILE_RUNTIME)
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -38,7 +38,7 @@ INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
diff --git a/Examples/test-suite/infinity.i b/Examples/test-suite/infinity.i
new file mode 100644
index 000000000..726150f02
--- /dev/null
+++ b/Examples/test-suite/infinity.i
@@ -0,0 +1,47 @@
+%module infinity
+
+/* C99 defines INFINITY
+ Because INFINITY may be defined by compiler built-ins, we can't use #define.
+ Instead, expose the variable MYINFINITY and then use %rename to make it INFINITY in the scripting language.
+*/
+%rename(INFINITY) MYINFINITY;
+
+%{
+#include
+
+/* C99 math.h defines INFINITY. If not available, this is the fallback. */
+#ifndef INFINITY
+ #ifdef _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}};
+ #define INFINITY (INFINITY_HACK.Value)
+ #endif
+
+ #ifdef __GNUC__
+ #define INFINITY (__builtin_inf())
+ #elif defined(__clang__)
+ #if __has_builtin(__builtin_inf)
+ #define INFINITY (__builtin_inf())
+ #endif
+ #endif
+
+ #ifndef INFINITY
+ #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. */
+const double MYINFINITY = INFINITY;
+
+/* 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;
+}
+%}
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index 453d29be8..c708c5c09 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -59,7 +59,7 @@ director_nspace.%: JAVA_PACKAGE = $*Package
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_cpp))
$(run_testcase)
@@ -69,7 +69,7 @@ director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_c))
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_multi_cpp))
$(run_testcase)
diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
new file mode 100644
index 000000000..7368ea9a3
--- /dev/null
+++ b/Examples/test-suite/javascript/Makefile.in
@@ -0,0 +1,114 @@
+#######################################################################
+# Makefile for javascript test-suite
+#######################################################################
+
+LANGUAGE = javascript
+NODEGYP = @NODEGYP@
+SCRIPTSUFFIX = _runme.js
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+SWIG = $(top_builddir)/preinst_swig
+
+ifneq (, $(ENGINE))
+ JSENGINE=$(ENGINE)
+else
+ JSENGINE=node
+endif
+
+include $(srcdir)/../common.mk
+
+_setup = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $* (with run test)" ; \
+ else \
+ echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $*" ; \
+ fi;
+
+ifneq (jsc,$(ENGINE))
+
+ # This test can not be run with v8 as it uses v8 API incompatible output typemaps
+ typemap_variables.cpptest:
+ echo "skipping $(LANGUAGE) ($(JSENGINE)) testcase typemap_variables" ;
+
+endif
+
+ifeq (node,$(JSENGINE))
+
+ SWIGOPT += -v8 -DBUILDING_NODE_EXTENSION=1
+
+ # shut up some warnings
+ # contract macro has an empty 'else' at the end...
+ aggregate.cpptest: GYP_CFLAGS = \"-Wno-empty-body\"
+ contract.cpptest: GYP_CFLAGS = \"-Wno-empty-body\"
+
+ # dunno... ignoring generously
+ apply_signed_char.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
+ constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
+ enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
+
+ # Note: we need to use swig in C parse mode, but make node-gyp believe it is c++ (via file extension)
+ swig_and_compile_c = \
+ sh ./setup_test.sh $* $(GYP_CFLAGS); \
+ $(SWIG) -javascript $(SWIGOPT) -o $*_wrap.cxx ../$*.i; \
+ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
+
+ swig_and_compile_cpp = \
+ sh ./setup_test.sh $* $(GYP_CFLAGS); \
+ $(SWIG) -c++ -javascript $(SWIGOPT) ../$*.i; \
+ $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
+
+ run_testcase = \
+ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
+ node $(srcdir)/$*$(SCRIPTSUFFIX); \
+ fi
+
+
+ %.ctest:
+ $(_setup)
+ $(swig_and_compile_c)
+ $(run_testcase)
+
+ %.cpptest:
+ $(_setup)
+ $(swig_and_compile_cpp)
+ $(run_testcase)
+
+ %.multicpptest:
+ $(_setup)
+
+else
+
+ SWIGOPT += -$(JSENGINE)
+
+ run_testcase = \
+ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
+ $(top_srcdir)/Tools/javascript/javascript -$(JSENGINE) $(srcdir)/$*$(SCRIPTSUFFIX); \
+ fi
+
+ %.ctest:
+ $(_setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+ %.cpptest:
+ $(_setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+ %.multicpptest:
+ $(_setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+endif
+
+
+%.clean:
+ rm -rf $*
+
+clean:
+ rm -f *_wrap.cxx
+ rm -f *_wrap.c
+ rm -f *.so
+ rm -f *.o
diff --git a/Examples/test-suite/javascript/abstract_access_runme.js b/Examples/test-suite/javascript/abstract_access_runme.js
new file mode 100644
index 000000000..8f87d2105
--- /dev/null
+++ b/Examples/test-suite/javascript/abstract_access_runme.js
@@ -0,0 +1,6 @@
+var abstract_access = require("./abstract_access");
+
+var d = new abstract_access.D()
+if (d.do_x() != 1) {
+ throw "Error";
+}
diff --git a/Examples/test-suite/javascript/abstract_inherit_runme.js b/Examples/test-suite/javascript/abstract_inherit_runme.js
new file mode 100644
index 000000000..3af2eae74
--- /dev/null
+++ b/Examples/test-suite/javascript/abstract_inherit_runme.js
@@ -0,0 +1,40 @@
+var abstract_inherit = require("./abstract_inherit");
+
+// Shouldn't be able to instantiate any of these classes
+// since none of them implements the pure virtual function
+// declared in the base class (Foo).
+var Foo = abstract_inherit.Foo;
+var Bar = abstract_inherit.Bar;
+var Spam = abstract_inherit.Spam;
+
+var caughtException = false;
+try {
+ new Foo();
+} catch (err) {
+ caughtException = true;
+}
+if (!caughtException) {
+ throw new Error("Foo should be instantiated as it is abstract");
+}
+
+caughtException = false;
+try {
+ new Bar();
+} catch (err) {
+ caughtException = true;
+}
+
+if (!caughtException) {
+ throw new Error("Bar should be instantiated as it is abstract");
+}
+
+caughtException = false;
+try {
+ new Spam();
+} catch (err) {
+ caughtException = true;
+}
+
+if (!caughtException) {
+ throw new Error("Spam should be instantiated as it is abstract");
+}
diff --git a/Examples/test-suite/javascript/abstract_typedef2_runme.js b/Examples/test-suite/javascript/abstract_typedef2_runme.js
new file mode 100644
index 000000000..c177e49c3
--- /dev/null
+++ b/Examples/test-suite/javascript/abstract_typedef2_runme.js
@@ -0,0 +1,6 @@
+var abstract_typedef2 = require("./abstract_typedef2");
+
+var a = new abstract_typedef2.A_UF();
+
+if (a == undefined)
+ throw "Error";
diff --git a/Examples/test-suite/javascript/abstract_typedef_runme.js b/Examples/test-suite/javascript/abstract_typedef_runme.js
new file mode 100644
index 000000000..abcfc581d
--- /dev/null
+++ b/Examples/test-suite/javascript/abstract_typedef_runme.js
@@ -0,0 +1,8 @@
+var abstract_typedef = require("./abstract_typedef");
+
+var e = new abstract_typedef.Engine();
+var a = new abstract_typedef.A()
+
+if (a.write(e) != 1) {
+ throw "Error";
+}
diff --git a/Examples/test-suite/javascript/abstract_virtual_runme.js b/Examples/test-suite/javascript/abstract_virtual_runme.js
new file mode 100644
index 000000000..9e2814e41
--- /dev/null
+++ b/Examples/test-suite/javascript/abstract_virtual_runme.js
@@ -0,0 +1,11 @@
+var abstract_virtual = require("./abstract_virtual");
+
+d = new abstract_virtual.D()
+
+if (d == undefined)
+ throw "Error";
+
+e = new abstract_virtual.E()
+
+if (e == undefined)
+ throw "Error";
diff --git a/Examples/test-suite/javascript/array_member_runme.js b/Examples/test-suite/javascript/array_member_runme.js
new file mode 100644
index 000000000..8c4ef1da5
--- /dev/null
+++ b/Examples/test-suite/javascript/array_member_runme.js
@@ -0,0 +1,22 @@
+var array_member = require("./array_member");
+
+var f = new array_member.Foo();
+f.data = array_member.global_data;
+
+for (var i=0; i<8; i++) {
+ if (array_member.get_value(f.data,i) != array_member.get_value(array_member.global_data,i)) {
+ throw "Bad array assignment (1)";
+ }
+}
+
+for (var i=0; i<8; i++) {
+ array_member.set_value(f.data,i,-i);
+}
+
+array_member.global_data = f.data;
+
+for (var i=0; i<8; i++){
+ if (array_member.get_value(f.data,i) != array_member.get_value(array_member.global_data,i)) {
+ throw "Bad array assignment (2)";
+ }
+}
diff --git a/Examples/test-suite/javascript/arrays_global_runme.js b/Examples/test-suite/javascript/arrays_global_runme.js
new file mode 100644
index 000000000..fdb365f83
--- /dev/null
+++ b/Examples/test-suite/javascript/arrays_global_runme.js
@@ -0,0 +1,18 @@
+var arrays_global = require("./arrays_global");
+
+arrays_global.array_i = arrays_global.array_const_i;
+
+arrays_global.BeginString_FIX44a;
+arrays_global.BeginString_FIX44b;
+arrays_global.BeginString_FIX44c;
+arrays_global.BeginString_FIX44d;
+arrays_global.BeginString_FIX44d;
+arrays_global.BeginString_FIX44b = "12"+'\0'+"45";
+arrays_global.BeginString_FIX44b;
+arrays_global.BeginString_FIX44d;
+arrays_global.BeginString_FIX44e;
+arrays_global.BeginString_FIX44f;
+
+arrays_global.test_a("hello","hi","chello","chi");
+
+arrays_global.test_b("1234567","hi");
diff --git a/Examples/test-suite/javascript/callback_runme.js b/Examples/test-suite/javascript/callback_runme.js
new file mode 100644
index 000000000..9b1ef01a3
--- /dev/null
+++ b/Examples/test-suite/javascript/callback_runme.js
@@ -0,0 +1,30 @@
+var callback = require("./callback");
+
+if (callback.foo(2) !== 2) {
+ throw new Error("Failed.");
+}
+if (callback.A_bar(2) !== 4) {
+ throw new Error("Failed.");
+}
+if (callback.foobar(3, callback.foo) != callback.foo(3)) {
+ throw new Error("Failed.");
+}
+if (callback.foobar(3, foo) != callback.foo(3)) {
+ throw new Error("Failed.");
+}
+if (callback.foobar(3, callback.A_bar) != callback.A_bar(3)) {
+ throw new Error("Failed.");
+}
+if (callback.foobar(3, callback.foof) != callback.foof(3)) {
+ throw new Error("Failed.");
+}
+if (callback.foobar_i(3, callback.foo_i) != callback.foo_i(3)) {
+ throw new Error("Failed.");
+}
+if (callback.foobar_d(3.5, callback.foo_d) != callback.foo_d(3.5)) {
+ throw new Error("Failed.");
+}
+var a = new callback.A();
+if (callback.foobarm(3, a, callback.A.foom_cb_ptr) != a.foom(3)) {
+ throw new Error("Failed.");
+}
diff --git a/Examples/test-suite/javascript/char_binary_runme.js b/Examples/test-suite/javascript/char_binary_runme.js
new file mode 100644
index 000000000..42abe6060
--- /dev/null
+++ b/Examples/test-suite/javascript/char_binary_runme.js
@@ -0,0 +1,38 @@
+var char_binary = require("./char_binary");
+
+var t = new char_binary.Test();
+if (t.strlen('hile') != 4) {
+ print(t.strlen('hile'));
+ throw("bad multi-arg typemap 1");
+}
+
+if (t.strlen('hil\0') != 4) {
+ throw("bad multi-arg typemap 2");
+}
+
+/*
+ * creating a raw char*
+ */
+var pc = char_binary.new_pchar(5);
+char_binary.pchar_setitem(pc, 0, 'h');
+char_binary.pchar_setitem(pc, 1, 'o');
+char_binary.pchar_setitem(pc, 2, 'l');
+char_binary.pchar_setitem(pc, 3, 'a');
+char_binary.pchar_setitem(pc, 4, 0);
+
+
+if (t.strlen(pc) != 4) {
+ throw("bad multi-arg typemap (3)");
+}
+
+char_binary.var_pchar = pc;
+if (char_binary.var_pchar != "hola") {
+ print(char_binary.var_pchar);
+ throw("bad pointer case (1)");
+}
+
+char_binary.var_namet = pc;
+if (char_binary.var_namet != "hola") {
+ throw("bad pointer case (2)");
+}
+char_binary.delete_pchar(pc);
diff --git a/Examples/test-suite/javascript/char_strings_runme.js b/Examples/test-suite/javascript/char_strings_runme.js
new file mode 100644
index 000000000..cca50d851
--- /dev/null
+++ b/Examples/test-suite/javascript/char_strings_runme.js
@@ -0,0 +1,11 @@
+var char_strings = require("./char_strings");
+
+var assertIsEqual = function(expected, actual) {
+ if (expected !== actual) {
+ throw new Error("Expected "+expected+", was "+actual);
+ }
+};
+
+assertIsEqual("hi there", char_strings.CharPingPong("hi there"));
+assertIsEqual("hi there", char_strings.CharArrayPingPong("hi there"));
+assertIsEqual("hi there", char_strings.CharArrayDimsPingPong("hi there"));
diff --git a/Examples/test-suite/javascript/class_ignore_runme.js b/Examples/test-suite/javascript/class_ignore_runme.js
new file mode 100644
index 000000000..f0a32a1c4
--- /dev/null
+++ b/Examples/test-suite/javascript/class_ignore_runme.js
@@ -0,0 +1,6 @@
+var class_ignore = require("./class_ignore");
+
+a = new class_ignore.Bar();
+
+if (class_ignore.do_blah(a) != "Bar::blah")
+ throw "Error";
diff --git a/Examples/test-suite/javascript/class_scope_weird_runme.js b/Examples/test-suite/javascript/class_scope_weird_runme.js
new file mode 100644
index 000000000..ac745d023
--- /dev/null
+++ b/Examples/test-suite/javascript/class_scope_weird_runme.js
@@ -0,0 +1,6 @@
+var class_scope_weird = require("./class_scope_weird");
+
+f = new class_scope_weird.Foo();
+g = new class_scope_weird.Foo(3);
+if (f.bar(3) != 3)
+ throw RuntimeError;
diff --git a/Examples/test-suite/javascript/complextest_runme.js b/Examples/test-suite/javascript/complextest_runme.js
new file mode 100644
index 000000000..1fcc97648
--- /dev/null
+++ b/Examples/test-suite/javascript/complextest_runme.js
@@ -0,0 +1,22 @@
+var complextest = require("./complextest");
+
+a = [-1,2];
+
+expected = [-1, -2];
+
+a_c = complextest.Conj(a);
+if (a_c.toString() != expected.toString())
+ throw "Error in Conj(a)";
+
+a_c_f = complextest.Conjf(a);
+if (a_c_f.toString() != expected.toString())
+ throw "Error in Conjf(a)";
+
+v = new complextest.VectorStdCplx();
+v.add([1,2]);
+v.add([2,3]);
+v.add([4,3]);
+v.add(1);
+
+// TODO: how to check validity?
+complextest.Copy_h(v);
diff --git a/Examples/test-suite/javascript/constover_runme.js b/Examples/test-suite/javascript/constover_runme.js
new file mode 100644
index 000000000..764d8b328
--- /dev/null
+++ b/Examples/test-suite/javascript/constover_runme.js
@@ -0,0 +1,33 @@
+var constover = require("./constover");
+
+p = constover.test("test");
+if (p != "test") {
+ throw "test failed!";
+}
+
+p = constover.test_pconst("test");
+if (p != "test_pconst") {
+ throw "test_pconst failed!";
+}
+
+f = new constover.Foo();
+
+p = f.test("test");
+if (p != "test") {
+ throw "member-test failed!";
+}
+
+p = f.test_pconst("test");
+if (p != "test_pconst") {
+ throw "member-test_pconst failed!";
+}
+
+p = f.test_constm("test");
+if (p != "test_constmethod") {
+ throw "member-test_constm failed!";
+}
+
+p = f.test_pconstm("test");
+if (p != "test_pconstmethod") {
+ throw "member-test_pconstm failed!";
+}
diff --git a/Examples/test-suite/javascript/constructor_copy_runme.js b/Examples/test-suite/javascript/constructor_copy_runme.js
new file mode 100644
index 000000000..39dce52ce
--- /dev/null
+++ b/Examples/test-suite/javascript/constructor_copy_runme.js
@@ -0,0 +1,42 @@
+var constructor_copy = require("./constructor_copy");
+
+f1 = new constructor_copy.Foo1(3);
+f11 = new constructor_copy.Foo1(f1);
+
+if (f1.x != f11.x) {
+ throw "error in ctor copy for Foo1";
+}
+
+var good = 0;
+
+f8 = new constructor_copy.Foo8()
+try {
+ f81 = new constructor_copy.Foo8(f8);
+ good = 0;
+} catch (err) {
+ good = 1;
+}
+
+if (good == 0) {
+ throw "Error: should not allow calling copy ctor for Foo8";
+}
+
+
+bi = new constructor_copy.Bari(5);
+bc = new constructor_copy.Bari(bi);
+
+if (bi.x != bc.x) {
+ throw "Error in copy ctor of Bari";
+}
+
+bd = new constructor_copy.Bard(5);
+try {
+ bc = new constructor_copy.Bard(bd);
+ good = 0;
+} catch (err) {
+ good = 1;
+}
+
+if (good == 0) {
+ throw "Error: should not allow calling copy ctor for Bard";
+}
diff --git a/Examples/test-suite/javascript/cpp_enum_runme.js b/Examples/test-suite/javascript/cpp_enum_runme.js
new file mode 100644
index 000000000..35f7c60ac
--- /dev/null
+++ b/Examples/test-suite/javascript/cpp_enum_runme.js
@@ -0,0 +1,28 @@
+var cpp_enum = require("./cpp_enum");
+
+var f = new cpp_enum.Foo()
+
+if(f.hola != cpp_enum.Hello){
+ print(f.hola);
+ throw "Error";
+}
+
+f.hola = cpp_enum.Foo.Hi
+if(f.hola != cpp_enum.Foo.Hi){
+ print(f.hola);
+ throw "Error";
+}
+
+f.hola = cpp_enum.Hello
+
+if(f.hola != cpp_enum.Hello){
+ print(f.hola);
+ throw "Error";
+}
+
+cpp_enum.Foo.hi = cpp_enum.Hello
+if(cpp_enum.Foo.hi != cpp_enum.Hello){
+ print(cpp_enum.Foo.hi);
+ throw "Error";
+}
+
diff --git a/Examples/test-suite/javascript/cpp_namespace_runme.js b/Examples/test-suite/javascript/cpp_namespace_runme.js
new file mode 100644
index 000000000..3bdfef3e9
--- /dev/null
+++ b/Examples/test-suite/javascript/cpp_namespace_runme.js
@@ -0,0 +1,47 @@
+var cpp_namespace = require("./cpp_namespace");
+
+var n = cpp_namespace.fact(4);
+if (n != 24){
+ throw ("Bad return value error!");
+}
+if (cpp_namespace.Foo != 42){
+ throw ("Bad variable value error!");
+}
+
+t = new cpp_namespace.Test();
+if (t.method() != "Test::method"){
+ throw ("Bad method return value error!");
+}
+if (cpp_namespace.do_method(t) != "Test::method"){
+ throw ("Bad return value error!");
+}
+
+if (cpp_namespace.do_method2(t) != "Test::method"){
+ throw ("Bad return value error!");
+}
+cpp_namespace.weird("hello", 4);
+delete t;
+
+t2 = new cpp_namespace.Test2();
+t3 = new cpp_namespace.Test3();
+t4 = new cpp_namespace.Test4();
+t5 = new cpp_namespace.Test5();
+if (cpp_namespace.foo3(42) != 42){
+ throw ("Bad return value error!");
+}
+
+if (cpp_namespace.do_method3(t2,40) != "Test2::method"){
+ throw ("Bad return value error!");
+}
+
+if (cpp_namespace.do_method3(t3,40) != "Test3::method"){
+ throw ("Bad return value error!");
+}
+
+if (cpp_namespace.do_method3(t4,40) != "Test4::method"){
+ throw ("Bad return value error!");
+}
+
+if (cpp_namespace.do_method3(t5,40) != "Test5::method"){
+ throw ("Bad return value error!");
+}
diff --git a/Examples/test-suite/javascript/cpp_static_runme.js b/Examples/test-suite/javascript/cpp_static_runme.js
new file mode 100644
index 000000000..2579aeafe
--- /dev/null
+++ b/Examples/test-suite/javascript/cpp_static_runme.js
@@ -0,0 +1,9 @@
+var cpp_static = require("./cpp_static");
+
+cpp_static.StaticFunctionTest.static_func();
+cpp_static.StaticFunctionTest.static_func_2(1);
+cpp_static.StaticFunctionTest.static_func_3(1,2);
+cpp_static.StaticMemberTest.static_int = 10;
+if (cpp_static.StaticMemberTest.static_int != 10)
+throw "error";
+
diff --git a/Examples/test-suite/javascript/director_alternating_runme.js b/Examples/test-suite/javascript/director_alternating_runme.js
new file mode 100644
index 000000000..a0411eace
--- /dev/null
+++ b/Examples/test-suite/javascript/director_alternating_runme.js
@@ -0,0 +1,5 @@
+var director_alternating = require("./director_alternating");
+
+id = director_alternating.getBar().id();
+if (id != director_alternating.idFromGetBar())
+ throw ("Error, Got wrong id: " + str(id));
diff --git a/Examples/test-suite/javascript/disown_runme.js b/Examples/test-suite/javascript/disown_runme.js
new file mode 100644
index 000000000..a4a6fd880
--- /dev/null
+++ b/Examples/test-suite/javascript/disown_runme.js
@@ -0,0 +1,22 @@
+var disown = require("./disown");
+
+var a = new disown.A();
+var tmp = a.thisown;
+a.thisown = 0
+if (a.thisown) {
+ throw new Error("Failed.");
+}
+a.thisown = 1
+if (!a.thisown) {
+ throw new Error("Failed.");
+}
+a.thisown = tmp
+if (a.thisown != tmp) {
+ throw new Error("Failed.");
+}
+
+var b = new disown.B();
+b.acquire(a);
+if (a.thisown) {
+ throw new Error("Failed.");
+}
diff --git a/Examples/test-suite/javascript/dynamic_cast_runme.js b/Examples/test-suite/javascript/dynamic_cast_runme.js
new file mode 100644
index 000000000..0029cb0f8
--- /dev/null
+++ b/Examples/test-suite/javascript/dynamic_cast_runme.js
@@ -0,0 +1,12 @@
+var dynamic_cast = require("./dynamic_cast");
+
+var f = new dynamic_cast.Foo();
+var b = new dynamic_cast.Bar();
+
+var x = f.blah();
+var y = b.blah();
+
+var a = dynamic_cast.do_test(y);
+if (a != "Bar::test") {
+ throw new Error("Failed.");
+}
diff --git a/Examples/test-suite/javascript/empty_runme.js b/Examples/test-suite/javascript/empty_runme.js
new file mode 100644
index 000000000..db06b3902
--- /dev/null
+++ b/Examples/test-suite/javascript/empty_runme.js
@@ -0,0 +1 @@
+var empty = require("./empty");
\ No newline at end of file
diff --git a/Examples/test-suite/javascript/enum_template_runme.js b/Examples/test-suite/javascript/enum_template_runme.js
new file mode 100644
index 000000000..20f8c3482
--- /dev/null
+++ b/Examples/test-suite/javascript/enum_template_runme.js
@@ -0,0 +1,8 @@
+var enum_template = require("./enum_template");
+
+if (enum_template.MakeETest() != 1)
+ throw "RuntimeError";
+
+if (enum_template.TakeETest(0) != null)
+ throw "RuntimeError";
+
diff --git a/Examples/test-suite/javascript/infinity_runme.js b/Examples/test-suite/javascript/infinity_runme.js
new file mode 100644
index 000000000..7b5182ff6
--- /dev/null
+++ b/Examples/test-suite/javascript/infinity_runme.js
@@ -0,0 +1,4 @@
+var infinity = require("./infinity");
+
+var my_infinity = infinity.INFINITY;
+var ret_val = infinity.use_infinity(my_infinity);
diff --git a/Examples/test-suite/javascript/namespace_virtual_method_runme.js b/Examples/test-suite/javascript/namespace_virtual_method_runme.js
new file mode 100644
index 000000000..24d3bd487
--- /dev/null
+++ b/Examples/test-suite/javascript/namespace_virtual_method_runme.js
@@ -0,0 +1,3 @@
+var namespace_virtual_method = require("./namespace_virtual_method");
+
+x = new namespace_virtual_method.Spam();
diff --git a/Examples/test-suite/javascript/node_template/binding.gyp.in b/Examples/test-suite/javascript/node_template/binding.gyp.in
new file mode 100644
index 000000000..209774ae0
--- /dev/null
+++ b/Examples/test-suite/javascript/node_template/binding.gyp.in
@@ -0,0 +1,30 @@
+{
+ "targets": [
+ {
+ "target_name": "$testcase",
+ "sources":[ "../$testcase_wrap.cxx" ],
+ "include_dirs": ["../.."],
+ 'defines': [
+ 'BUILDING_NODE_EXTENSION=1',
+ ],
+ 'conditions': [
+ ['OS=="mac"',
+ {
+ 'xcode_settings': {
+ 'GCC_ENABLE_CPP_RTTI': 'YES',
+ 'GCC_ENABLE_CPP_EXCEPTIONS' : 'YES'
+ }
+ }
+ ],
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"',
+ {
+ 'cflags': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter", $cflags],
+ 'cflags_cc': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter", $cflags],
+ 'cflags!': [ '-fno-exceptions' ],
+ 'cflags_cc!': [ '-fno-exceptions', '-fno-rtti' ]
+ }
+ ]
+ ],
+ }
+ ],
+}
diff --git a/Examples/test-suite/javascript/node_template/index.js.in b/Examples/test-suite/javascript/node_template/index.js.in
new file mode 100644
index 000000000..72330499d
--- /dev/null
+++ b/Examples/test-suite/javascript/node_template/index.js.in
@@ -0,0 +1 @@
+module.exports = require('./build/Release/$testcase');
diff --git a/Examples/test-suite/javascript/nspace_extend_runme.js b/Examples/test-suite/javascript/nspace_extend_runme.js
new file mode 100644
index 000000000..ab81c19d3
--- /dev/null
+++ b/Examples/test-suite/javascript/nspace_extend_runme.js
@@ -0,0 +1,27 @@
+var nspace_extend = require("./nspace_extend");
+
+// constructors and destructors
+var color1 = new nspace_extend.Outer.Inner1.Color();
+var color = new nspace_extend.Outer.Inner1.Color(color1);
+delete color1;
+
+// class methods
+color.colorInstanceMethod(20.0);
+nspace_extend.Outer.Inner1.Color.colorStaticMethod(20.0);
+var created = nspace_extend.Outer.Inner1.Color.create();
+
+
+// constructors and destructors
+var color2 = new nspace_extend.Outer.Inner2.Color();
+color = new nspace_extend.Outer.Inner2.Color(color2);
+delete color2;
+
+// class methods
+color.colorInstanceMethod(20.0);
+nspace_extend.Outer.Inner2.Color.colorStaticMethod(20.0);
+created = nspace_extend.Outer.Inner2.Color.create();
+
+// Same class different namespaces
+var col1 = new nspace_extend.Outer.Inner1.Color();
+var col2 = nspace_extend.Outer.Inner2.Color.create();
+col2.colors(col1, col1, col2, col2, col2);
diff --git a/Examples/test-suite/javascript/nspace_runme.js b/Examples/test-suite/javascript/nspace_runme.js
new file mode 100644
index 000000000..f1afff428
--- /dev/null
+++ b/Examples/test-suite/javascript/nspace_runme.js
@@ -0,0 +1,76 @@
+var nspace = require("./nspace");
+
+var color1 = new nspace.Outer.Inner1.Color();
+var color = new nspace.Outer.Inner1.Color(color1);
+delete color1;
+
+// class methods
+color.colorInstanceMethod(20.0);
+nspace.Outer.Inner1.Color.colorStaticMethod(20.0);
+var created = nspace.Outer.Inner1.Color.create();
+
+// class enums
+var someClass = new nspace.Outer.SomeClass();
+var channel = someClass.GetInner1ColorChannel();
+if (channel != nspace.Outer.Inner1.Color.Transmission) {
+ throw new Error("Failed.");
+}
+
+// class anonymous enums
+var val1 = nspace.Outer.Inner1.Color.ColorEnumVal1;
+var val2 = nspace.Outer.Inner1.Color.ColorEnumVal2;
+if (val1 !== 0 || val2 !== 0x22) {
+ throw new Error("Failed.");
+}
+
+// instance member variables
+color.instanceMemberVariable = 123;
+if (color.instanceMemberVariable !== 123) {
+ throw new Error("Failed.");
+}
+
+// static member variables
+nspace.Outer.Inner1.Color.staticMemberVariable = 789;
+if (nspace.Outer.Inner1.Color.staticMemberVariable !== 789) {
+ throw new Error("Failed.");
+}
+
+if (nspace.Outer.Inner1.Color.staticConstMemberVariable !== 222) {
+ throw new Error("Failed.");
+}
+
+if (nspace.Outer.Inner1.Color.staticConstEnumMemberVariable !== nspace.Outer.Inner1.Color.Transmission) {
+ throw new Error("Failed.");
+}
+
+// Same class different namespaces
+var col1 = new nspace.Outer.Inner1.Color();
+var col2 = nspace.Outer.Inner2.Color.create();
+col2.colors(col1, col1, col2, col2, col2);
+
+nspace.Outer.Inner1.namespaceFunction(color);
+nspace.Outer.Inner1.namespaceVar = 111;
+if (nspace.Outer.Inner1.namespaceVar !== 111) {
+ throw new Error("Failed.");
+}
+
+// global enums
+var outerChannel1 = someClass.GetInner1Channel();
+if (outerChannel1 != nspace.Outer.Inner1.Transmission1) {
+ throw new Error("Failed.");
+}
+
+var outerChannel2 = someClass.GetInner2Channel();
+if (outerChannel2 !== nspace.Outer.Inner2.Transmission2) {
+ throw new Error("Failed.");
+}
+
+// turn feature off / ignoring
+var ns = new nspace.Outer.namespce();
+var nons = new nspace.NoNSpacePlease();
+
+// Derived class
+var blue3 = new nspace.Outer.Inner3.Blue();
+blue3.blueInstanceMethod();
+var blue4 = new nspace.Outer.Inner4.Blue();
+blue4.blueInstanceMethod();
diff --git a/Examples/test-suite/javascript/overload_copy_runme.js b/Examples/test-suite/javascript/overload_copy_runme.js
new file mode 100644
index 000000000..1039ffda1
--- /dev/null
+++ b/Examples/test-suite/javascript/overload_copy_runme.js
@@ -0,0 +1,4 @@
+var overload_copy = require("./overload_copy");
+
+f = new overload_copy.Foo();
+g = new overload_copy.Foo(f);
diff --git a/Examples/test-suite/javascript/preproc_include_runme.js b/Examples/test-suite/javascript/preproc_include_runme.js
new file mode 100644
index 000000000..4b827fbcc
--- /dev/null
+++ b/Examples/test-suite/javascript/preproc_include_runme.js
@@ -0,0 +1,23 @@
+var preproc_include = require("./preproc_include");
+
+if (preproc_include.multiply10(10) != 100)
+ throw "RuntimeError";
+
+if (preproc_include.multiply20(10) != 200)
+ throw "RuntimeError";
+
+if (preproc_include.multiply30(10) != 300)
+ throw "RuntimeError";
+
+if (preproc_include.multiply40(10) != 400)
+ throw "RuntimeError";
+
+if (preproc_include.multiply50(10) != 500)
+ throw "RuntimeError";
+
+if (preproc_include.multiply60(10) != 600)
+ throw "RuntimeError";
+
+if (preproc_include.multiply70(10) != 700)
+ throw "RuntimeError";
+
diff --git a/Examples/test-suite/javascript/preproc_runme.js b/Examples/test-suite/javascript/preproc_runme.js
new file mode 100644
index 000000000..669f9d1f0
--- /dev/null
+++ b/Examples/test-suite/javascript/preproc_runme.js
@@ -0,0 +1,14 @@
+var preproc = require("./preproc");
+
+if (preproc.endif != 1)
+ throw "RuntimeError";
+
+if (preproc.define != 1)
+ throw "RuntimeError";
+
+if (preproc.defined != 1)
+ throw "RuntimeError";
+
+if (2*preproc.one != preproc.two)
+ throw "RuntimeError";
+
diff --git a/Examples/test-suite/javascript/rename1_runme.js b/Examples/test-suite/javascript/rename1_runme.js
new file mode 100644
index 000000000..8374e6a89
--- /dev/null
+++ b/Examples/test-suite/javascript/rename1_runme.js
@@ -0,0 +1,68 @@
+var rename = require("./rename1");
+
+function part1() {
+ var xyz = new rename.XYZInt();
+ notxyz = new rename.NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+}
+
+function part2() {
+ var xyz = new rename.XYZDouble();
+ var notxyz = new rename.NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+}
+
+function part3(){
+ var xyz = new rename.XYZKlass();
+ var notxyz = new rename.NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new rename.Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+}
+
+function part4() {
+ var xyz = new rename.XYZEnu();
+ var notxyz = new rename.NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(rename.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+}
+
+function part5() {
+ var abc = new rename.ABC();
+ abc.methodABC(abc);
+ var k = new rename.Klass();
+ abc.methodKlass(k);
+ var a = abc.opABC();
+ k = abc.opKlass();
+}
+
+part1();
+part2();
+part3();
+part4();
+part5();
diff --git a/Examples/test-suite/javascript/rename2_runme.js b/Examples/test-suite/javascript/rename2_runme.js
new file mode 100644
index 000000000..bc6a95a59
--- /dev/null
+++ b/Examples/test-suite/javascript/rename2_runme.js
@@ -0,0 +1,68 @@
+var rename = require("./rename2");
+
+function part1() {
+ var xyz = new rename.XYZInt();
+ notxyz = new rename.NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+}
+
+function part2() {
+ var xyz = new rename.XYZDouble();
+ var notxyz = new rename.NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+}
+
+function part3(){
+ var xyz = new rename.XYZKlass();
+ var notxyz = new rename.NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new rename.Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+}
+
+function part4() {
+ var xyz = new rename.XYZEnu();
+ var notxyz = new rename.NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(rename.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+}
+
+function part5() {
+ var abc = new rename.ABC();
+ abc.methodABC(abc);
+ var k = new rename.Klass();
+ abc.methodKlass(k);
+ var a = abc.opABC();
+ k = abc.opKlass();
+}
+
+part1();
+part2();
+part3();
+part4();
+part5();
diff --git a/Examples/test-suite/javascript/rename3_runme.js b/Examples/test-suite/javascript/rename3_runme.js
new file mode 100644
index 000000000..9e57e80ea
--- /dev/null
+++ b/Examples/test-suite/javascript/rename3_runme.js
@@ -0,0 +1,68 @@
+var rename = require("./rename3");
+
+function part1() {
+ var xyz = new rename.XYZInt();
+ notxyz = new rename.NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+}
+
+function part2() {
+ var xyz = new rename.XYZDouble();
+ var notxyz = new rename.NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+}
+
+function part3(){
+ var xyz = new rename.XYZKlass();
+ var notxyz = new rename.NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new rename.Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+}
+
+function part4() {
+ var xyz = new rename.XYZEnu();
+ var notxyz = new rename.NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(rename.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+}
+
+function part5() {
+ var abc = new rename.ABC();
+ abc.methodABC(abc);
+ var k = new rename.Klass();
+ abc.methodKlass(k);
+ var a = abc.opABC();
+ k = abc.opKlass();
+}
+
+part1();
+part2();
+part3();
+part4();
+part5();
diff --git a/Examples/test-suite/javascript/rename4_runme.js b/Examples/test-suite/javascript/rename4_runme.js
new file mode 100644
index 000000000..d651fc7a1
--- /dev/null
+++ b/Examples/test-suite/javascript/rename4_runme.js
@@ -0,0 +1,68 @@
+var rename = require("./rename4");
+
+function part1() {
+ var xyz = new rename.XYZInt();
+ notxyz = new rename.NotXYZInt();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother2();
+ xyz.opT2();
+ xyz.tMethod2(0);
+ xyz.tMethodNotXYZ2(notxyz);
+ xyz.opNotXYZ2();
+ xyz.opXYZ2();
+}
+
+function part2() {
+ var xyz = new rename.XYZDouble();
+ var notxyz = new rename.NotXYZDouble();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother1();
+ xyz.opT1();
+ xyz.tMethod1(0);
+ xyz.tMethodNotXYZ1(notxyz);
+ xyz.opNotXYZ1();
+ xyz.opXYZ1();
+}
+
+function part3(){
+ var xyz = new rename.XYZKlass();
+ var notxyz = new rename.NotXYZKlass();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother3();
+ xyz.opT3();
+ xyz.tMethod3(new rename.Klass());
+ xyz.tMethodNotXYZ3(notxyz);
+ xyz.opNotXYZ3();
+ xyz.opXYZ3();
+}
+
+function part4() {
+ var xyz = new rename.XYZEnu();
+ var notxyz = new rename.NotXYZEnu();
+ xyz.opIntPtrA();
+ xyz.opIntPtrB();
+ xyz.opAnother4();
+ xyz.opT4();
+ xyz.tMethod4(rename.En1);
+ xyz.tMethodNotXYZ4(notxyz);
+ xyz.opNotXYZ4();
+ xyz.opXYZ4();
+}
+
+function part5() {
+ var abc = new rename.ABC();
+ abc.methodABC(abc);
+ var k = new rename.Klass();
+ abc.methodKlass(k);
+ var a = abc.opABC();
+ k = abc.opKlass();
+}
+
+part1();
+part2();
+part3();
+part4();
+part5();
diff --git a/Examples/test-suite/javascript/rename_scope_runme.js b/Examples/test-suite/javascript/rename_scope_runme.js
new file mode 100644
index 000000000..c0226df69
--- /dev/null
+++ b/Examples/test-suite/javascript/rename_scope_runme.js
@@ -0,0 +1,17 @@
+var rename_scope = require("./rename_scope");
+
+var a = new rename_scope.Natural_UP();
+var b = new rename_scope.Natural_BP();
+
+if (a.rtest() !== 1) {
+ throw new Error("a.rtest(): Expected 1, was " + a.rtest());
+}
+
+if (b.rtest() !== 1) {
+ throw new Error("b.rtest(): Expected 1, was " + b.rtest());
+}
+
+var f = rename_scope.equals;
+if (f === undefined) {
+ throw new Error("Equality operator has not been renamed.");
+}
diff --git a/Examples/test-suite/javascript/rename_simple_runme.js b/Examples/test-suite/javascript/rename_simple_runme.js
new file mode 100644
index 000000000..918dd68a5
--- /dev/null
+++ b/Examples/test-suite/javascript/rename_simple_runme.js
@@ -0,0 +1,50 @@
+var rename_simple = require("./rename_simple");
+var NewStruct = rename_simple.NewStruct;
+
+var s = new NewStruct();
+
+// renamed instance variable
+if (s.NewInstanceVariable !== 111) {
+ throw new Error("NewInstanceVariable: Expected 111, was " + s.NewInstanceVariable);
+}
+
+// renamed instance method
+if (s.NewInstanceMethod() !== 222) {
+ throw new Error("NewInstanceMethod(): Expected 222, was " + s.NewInstanceMethod());
+}
+
+// renamed static method
+if (NewStruct.NewStaticMethod() !== 333) {
+ throw new Error("NewInstanceMethod(): Expected 333, was " + NewStruct.NewStaticMethod());
+}
+
+// renamed static variable
+if (NewStruct.NewStaticVariable !== 444) {
+ throw new Error("NewInstanceMethod(): Expected 444, was " + NewStruct.NewStaticVariable);
+}
+
+// renamed global function
+if (rename_simple.NewFunction() !== 555) {
+ throw new Error("rename_simple.NewFunction(): Expected 555, was " + rename_simple.NewFunction());
+}
+
+// renamed global variable
+if (rename_simple.NewGlobalVariable !== 666) {
+ throw new Error("rename_simple.NewGlobalVariable: Expected 666, was " + rename_simple.NewGlobalVariable);
+}
+
+// setting renamed variables
+s.NewInstanceVariable = 1111;
+if (s.NewInstanceVariable !== 1111) {
+ throw new Error("NewInstanceVariable: Expected 1111, was " + s.NewInstanceVariable);
+}
+
+NewStruct.NewStaticVariable = 4444;
+if (NewStruct.NewStaticVariable !== 4444) {
+ throw new Error("NewInstanceMethod(): Expected 4444, was " + NewStruct.NewStaticVariable);
+}
+
+rename_simple.NewGlobalVariable = 6666;
+if (rename_simple.NewGlobalVariable !== 6666) {
+ throw new Error("rename_simple.NewGlobalVariable: Expected 6666, was " + rename_simple.NewGlobalVariable);
+}
diff --git a/Examples/test-suite/javascript/ret_by_value_runme.js b/Examples/test-suite/javascript/ret_by_value_runme.js
new file mode 100644
index 000000000..d9a77a20b
--- /dev/null
+++ b/Examples/test-suite/javascript/ret_by_value_runme.js
@@ -0,0 +1,8 @@
+var ret_by_value = require("./ret_by_value");
+
+a = ret_by_value.get_test();
+if (a.myInt != 100)
+ throw "RuntimeError";
+
+if (a.myShort != 200)
+ throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/setup_test.sh b/Examples/test-suite/javascript/setup_test.sh
new file mode 100644
index 000000000..913a74c4b
--- /dev/null
+++ b/Examples/test-suite/javascript/setup_test.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+if [ ! -d $1 ]; then
+ mkdir $1;
+fi
+sed -e "s/\$testcase/$1/" -e "s/\$cflags/$2/" < node_template/binding.gyp.in > $1/binding.gyp
+sed s/\$testcase/$1/ node_template/index.js.in > $1/index.js
diff --git a/Examples/test-suite/javascript/string_simple_runme.js b/Examples/test-suite/javascript/string_simple_runme.js
new file mode 100644
index 000000000..dbdd4136d
--- /dev/null
+++ b/Examples/test-suite/javascript/string_simple_runme.js
@@ -0,0 +1,10 @@
+var string_simple = require("./string_simple");
+
+// Test unicode string
+var str = "olé";
+
+var copy = string_simple.copy_string(str);
+
+if (str !== copy) {
+ throw "Error: copy is not equal: original="+str+", copy="+copy;
+}
diff --git a/Examples/test-suite/javascript/struct_value_runme.js b/Examples/test-suite/javascript/struct_value_runme.js
new file mode 100644
index 000000000..d6b26f726
--- /dev/null
+++ b/Examples/test-suite/javascript/struct_value_runme.js
@@ -0,0 +1,11 @@
+var struct_value = require("./struct_value");
+
+b = new struct_value.Bar();
+
+b.a.x = 3;
+if (b.a.x != 3)
+throw "RuntimeError";
+
+b.b.x = 3;
+if (b.b.x != 3)
+throw "RuntimeError"
diff --git a/Examples/test-suite/javascript/template_static_runme.js b/Examples/test-suite/javascript/template_static_runme.js
new file mode 100644
index 000000000..477d97249
--- /dev/null
+++ b/Examples/test-suite/javascript/template_static_runme.js
@@ -0,0 +1,3 @@
+var template_static = require("./template_static");
+
+template_static.Foo.bar_double(1);
diff --git a/Examples/test-suite/javascript/typedef_class_runme.js b/Examples/test-suite/javascript/typedef_class_runme.js
new file mode 100644
index 000000000..3e4dc9093
--- /dev/null
+++ b/Examples/test-suite/javascript/typedef_class_runme.js
@@ -0,0 +1,7 @@
+var typedef_class = require("./typedef_class");
+
+a = new typedef_class.RealA();
+a.a = 3;
+
+b = new typedef_class.B();
+b.testA(a);
diff --git a/Examples/test-suite/javascript/typedef_inherit_runme.js b/Examples/test-suite/javascript/typedef_inherit_runme.js
new file mode 100644
index 000000000..4abcc2536
--- /dev/null
+++ b/Examples/test-suite/javascript/typedef_inherit_runme.js
@@ -0,0 +1,23 @@
+var typedef_inherit = require("./typedef_inherit");
+
+a = new typedef_inherit.Foo();
+b = new typedef_inherit.Bar();
+
+x = typedef_inherit.do_blah(a);
+if (x != "Foo::blah")
+ print("Whoa! Bad return" + x);
+
+x = typedef_inherit.do_blah(b);
+if (x != "Bar::blah")
+ print("Whoa! Bad return" + x);
+
+c = new typedef_inherit.Spam();
+d = new typedef_inherit.Grok();
+
+x = typedef_inherit.do_blah2(c);
+if (x != "Spam::blah")
+ print("Whoa! Bad return" + x);
+
+x = typedef_inherit.do_blah2(d);
+if (x != "Grok::blah")
+ print ("Whoa! Bad return" + x);
diff --git a/Examples/test-suite/javascript/typedef_scope_runme.js b/Examples/test-suite/javascript/typedef_scope_runme.js
new file mode 100644
index 000000000..0ac56884c
--- /dev/null
+++ b/Examples/test-suite/javascript/typedef_scope_runme.js
@@ -0,0 +1,12 @@
+var typedef_scope = require("./typedef_scope");
+
+b = new typedef_scope.Bar();
+x = b.test1(42,"hello");
+if (x != 42)
+ print("Failed!!");
+
+x = b.test2(42,"hello");
+if (x != "hello")
+ print("Failed!!");
+
+
diff --git a/Examples/test-suite/javascript/typemap_arrays_runme.js b/Examples/test-suite/javascript/typemap_arrays_runme.js
new file mode 100644
index 000000000..cd6827ac9
--- /dev/null
+++ b/Examples/test-suite/javascript/typemap_arrays_runme.js
@@ -0,0 +1,5 @@
+var typemap_arrays = require("./typemap_arrays");
+
+if (typemap_arrays.sumA(null) != 60)
+ throw "RuntimeError, Sum is wrong";
+
diff --git a/Examples/test-suite/javascript/typemap_delete_runme.js b/Examples/test-suite/javascript/typemap_delete_runme.js
new file mode 100644
index 000000000..4b3174956
--- /dev/null
+++ b/Examples/test-suite/javascript/typemap_delete_runme.js
@@ -0,0 +1,5 @@
+var typemap_delete = require("./typemap_delete");
+
+r = new typemap_delete.Rect(123);
+if (r.val != 123)
+ throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/typemap_namespace_runme.js b/Examples/test-suite/javascript/typemap_namespace_runme.js
new file mode 100644
index 000000000..614e0ffeb
--- /dev/null
+++ b/Examples/test-suite/javascript/typemap_namespace_runme.js
@@ -0,0 +1,7 @@
+var typemap_namespace = require("./typemap_namespace");
+
+if (typemap_namespace.test1("hello") != "hello")
+ throw "RuntimeError";
+
+if (typemap_namespace.test2("hello") != "hello")
+ throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/typemap_ns_using_runme.js b/Examples/test-suite/javascript/typemap_ns_using_runme.js
new file mode 100644
index 000000000..9115c16ae
--- /dev/null
+++ b/Examples/test-suite/javascript/typemap_ns_using_runme.js
@@ -0,0 +1,4 @@
+var typemap_ns_using = require("./typemap_ns_using");
+
+if (typemap_ns_using.spam(37) != 37)
+ throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/using1_runme.js b/Examples/test-suite/javascript/using1_runme.js
new file mode 100644
index 000000000..a2e37fcb6
--- /dev/null
+++ b/Examples/test-suite/javascript/using1_runme.js
@@ -0,0 +1,4 @@
+var using1 = require("./using1");
+
+if (using1.spam(37) != 37)
+ throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/using2_runme.js b/Examples/test-suite/javascript/using2_runme.js
new file mode 100644
index 000000000..aa5e9b15f
--- /dev/null
+++ b/Examples/test-suite/javascript/using2_runme.js
@@ -0,0 +1,4 @@
+var using2 = require("./using2");
+
+if (using2.spam(37) != 37)
+ throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/varargs_runme.js b/Examples/test-suite/javascript/varargs_runme.js
new file mode 100644
index 000000000..69d761e63
--- /dev/null
+++ b/Examples/test-suite/javascript/varargs_runme.js
@@ -0,0 +1,44 @@
+var varargs = require("./varargs");
+
+if (varargs.test("Hello") != "Hello") {
+ throw new Error("Failed");
+}
+
+var f = new varargs.Foo("Greetings")
+if (f.str != "Greetings") {
+ throw new Error("Failed");
+}
+
+if (f.test("Hello") != "Hello") {
+ throw new Error("Failed");
+}
+
+if (varargs.test_def("Hello",1) != "Hello") {
+ throw new Error("Failed");
+}
+
+if (varargs.test_def("Hello") != "Hello") {
+ throw new Error("Failed");
+}
+
+if (varargs.test_plenty("Hello") != "Hello") {
+ throw new Error("Failed");
+}
+
+if (varargs.test_plenty("Hello", 1) != "Hello") {
+ throw new Error("Failed");
+}
+
+if (varargs.test_plenty("Hello", 1, 2) != "Hello") {
+ throw new Error("Failed");
+}
+
+var thrown = false;
+try {
+ varargs.test_plenty("Hello", 1, 2, 3);
+} catch (err) {
+ thrown = true;
+}
+if (!thrown) {
+ throw new Error("Failed");
+}
diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in
index 66a0d2da9..0950c9d91 100644
--- a/Examples/test-suite/lua/Makefile.in
+++ b/Examples/test-suite/lua/Makefile.in
@@ -28,7 +28,7 @@ LIBS = -L.
lua_no_module_global.%: SWIGOPT += -nomoduleglobal
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -38,7 +38,7 @@ lua_no_module_global.%: SWIGOPT += -nomoduleglobal
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -52,7 +52,7 @@ run_testcase = \
# Clean: (does nothing, we dont generate extra lua code)
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile lua_clean
@@ -60,5 +60,5 @@ clean:
cvsignore:
@echo '*wrap* *.so *.dll *.exp *.lib'
@echo Makefile
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done
diff --git a/Examples/test-suite/lua/operator_overload_runme.lua b/Examples/test-suite/lua/operator_overload_runme.lua
index f3753749b..5ba06ff08 100644
--- a/Examples/test-suite/lua/operator_overload_runme.lua
+++ b/Examples/test-suite/lua/operator_overload_runme.lua
@@ -79,7 +79,7 @@ assert(tostring(Op(1))=="Op(1)")
assert(tostring(Op(-3))=="Op(-3)")
--- check that operator overloads is correctly propogated accross hierarchy
+-- check that operator overloads are correctly propogated down inheritance hierarchy
a_d=OpDerived()
b_d=OpDerived(5)
diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in
index fcaf33a48..67b8bddf2 100644
--- a/Examples/test-suite/mzscheme/Makefile.in
+++ b/Examples/test-suite/mzscheme/Makefile.in
@@ -18,7 +18,7 @@ include $(srcdir)/../common.mk
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -28,7 +28,7 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -42,7 +42,7 @@ run_testcase = \
# Clean
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile mzscheme_clean
diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i
index 1520b3652..25e7104b2 100644
--- a/Examples/test-suite/nspace.i
+++ b/Examples/test-suite/nspace.i
@@ -2,7 +2,7 @@
%module nspace
// nspace feature only supported by these languages
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
#if defined(SWIGJAVA)
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i
index e92ff8c1d..2f7c6fbe1 100644
--- a/Examples/test-suite/nspace_extend.i
+++ b/Examples/test-suite/nspace_extend.i
@@ -2,7 +2,7 @@
%module nspace_extend
// nspace feature only supported by these languages
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
#if defined(SWIGJAVA)
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
index f16c3da95..63edec26a 100644
--- a/Examples/test-suite/ocaml/Makefile.in
+++ b/Examples/test-suite/ocaml/Makefile.in
@@ -10,7 +10,7 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-C_TEST_CASES =
+C_TEST_CASES =
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
@@ -21,7 +21,7 @@ run_testcase = \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \
$(RUNTOOL) ./runme; \
- fi ;
+ fi ;
check_quant:
cat /dev/null > testing
diff --git a/Examples/test-suite/ocaml/makedebugtop b/Examples/test-suite/ocaml/makedebugtop
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in
index dc309e8c6..e48d36a64 100644
--- a/Examples/test-suite/octave/Makefile.in
+++ b/Examples/test-suite/octave/Makefile.in
@@ -21,7 +21,7 @@ CPP_TEST_BROKEN += \
li_std_set \
li_std_stream
-#C_TEST_CASES +=
+#C_TEST_CASES +=
#
# This test only works with modern C compilers
@@ -39,7 +39,7 @@ CSRCS = $(srcdir)/octave_empty.c
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -49,7 +49,7 @@ CSRCS = $(srcdir)/octave_empty.c
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -72,13 +72,13 @@ clean:
cvsignore:
@echo '*wrap* *.mc *.so *.dll *.exp *.lib'
@echo Makefile
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done
- @echo clientdata_prop_a.m
- @echo clientdata_prop_b.m
- @echo imports_a.m
- @echo imports_b.m
- @echo mod_a.m mod_b.m
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done
+ @echo clientdata_prop_a.m
+ @echo clientdata_prop_b.m
+ @echo imports_a.m
+ @echo imports_b.m
+ @echo mod_a.m mod_b.m
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m
@echo template_typedef_import.m
diff --git a/Examples/test-suite/octave/iadd_runme.m b/Examples/test-suite/octave/iadd_runme.m
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/octave/overload_complicated_runme.m b/Examples/test-suite/octave/overload_complicated_runme.m
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in
index 67eaf5c9a..68f32a54a 100644
--- a/Examples/test-suite/perl5/Makefile.in
+++ b/Examples/test-suite/perl5/Makefile.in
@@ -31,7 +31,7 @@ include $(srcdir)/../common.mk
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -41,7 +41,7 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
diff --git a/Examples/test-suite/perl5/char_binary_runme.pl b/Examples/test-suite/perl5/char_binary_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/class_ignore_runme.pl b/Examples/test-suite/perl5/class_ignore_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/contract_runme.pl b/Examples/test-suite/perl5/contract_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/enum_template_runme.pl b/Examples/test-suite/perl5/enum_template_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/grouping_runme.pl b/Examples/test-suite/perl5/grouping_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/ignore_parameter_runme.pl b/Examples/test-suite/perl5/ignore_parameter_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/inherit_missing_runme.pl b/Examples/test-suite/perl5/inherit_missing_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/li_std_except_runme.pl b/Examples/test-suite/perl5/li_std_except_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/minherit_runme.pl b/Examples/test-suite/perl5/minherit_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/naturalvar_runme.pl b/Examples/test-suite/perl5/naturalvar_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/preproc_runme.pl b/Examples/test-suite/perl5/preproc_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/primitive_types_runme.pl b/Examples/test-suite/perl5/primitive_types_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/reference_global_vars_runme.pl b/Examples/test-suite/perl5/reference_global_vars_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/rename_scope_runme.pl b/Examples/test-suite/perl5/rename_scope_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/return_const_value_runme.pl b/Examples/test-suite/perl5/return_const_value_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/run-perl-test.pl b/Examples/test-suite/perl5/run-perl-test.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/sizet_runme.pl b/Examples/test-suite/perl5/sizet_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/sneaky1_runme.pl b/Examples/test-suite/perl5/sneaky1_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl b/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/typedef_class_runme.pl b/Examples/test-suite/perl5/typedef_class_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/typename_runme.pl b/Examples/test-suite/perl5/typename_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/using1_runme.pl b/Examples/test-suite/perl5/using1_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/using2_runme.pl b/Examples/test-suite/perl5/using2_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/wrapmacro_runme.pl b/Examples/test-suite/perl5/wrapmacro_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in
index fcdcac2b9..735a3137e 100644
--- a/Examples/test-suite/php/Makefile.in
+++ b/Examples/test-suite/php/Makefile.in
@@ -29,7 +29,7 @@ missingctests:
missingtests: missingcpptests missingctests
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
+$(run_testcase)
@@ -39,7 +39,7 @@ missingtests: missingcpptests missingctests
+$(swig_and_compile_c)
+$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
+$(run_testcase)
diff --git a/Examples/test-suite/php/arrays_runme.php b/Examples/test-suite/php/arrays_runme.php
index 23490e61e..ae17d05e7 100644
--- a/Examples/test-suite/php/arrays_runme.php
+++ b/Examples/test-suite/php/arrays_runme.php
@@ -12,6 +12,7 @@ check::classname(simplestruct,$ss);
$as=new arraystruct();
$as->array_c="abc";
check::equal($as->array_c,"a",'$as->array_c=="a"');
+check::equal(isset($as->array_const_i),TRUE,'isset($as->array_const_i)');
check::done();
?>
diff --git a/Examples/test-suite/pike/Makefile.in b/Examples/test-suite/pike/Makefile.in
index 389dc74f8..c1ebb747b 100644
--- a/Examples/test-suite/pike/Makefile.in
+++ b/Examples/test-suite/pike/Makefile.in
@@ -18,7 +18,7 @@ include $(srcdir)/../common.mk
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -28,7 +28,7 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -46,4 +46,3 @@ run_testcase = \
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile pike_clean
-
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index e7db32fb7..389aed9ea 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -26,7 +26,7 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-PY2TO3 = 2to3 -x import
+PY2TO3 = 2to3 -x import
CPP_TEST_CASES += \
@@ -109,7 +109,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_cpp)
@@ -121,7 +121,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_multi_cpp)
@@ -131,7 +131,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file
%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX)
cp $< $@
- $(PY2TO3) -w $@ >/dev/null 2>&1
+ $(PY2TO3) -w $@ >/dev/null 2>&1
# Runs the testcase. A testcase is only run if
@@ -172,12 +172,12 @@ clean:
cvsignore:
@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
@echo Makefile
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
- @echo clientdata_prop_a.py
- @echo clientdata_prop_b.py
- @echo imports_a.py
- @echo imports_b.py
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
+ @echo clientdata_prop_a.py
+ @echo clientdata_prop_b.py
+ @echo imports_a.py
+ @echo imports_b.py
@echo mod_a.py mod_b.py
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@echo template_typedef_import.py
@@ -185,9 +185,8 @@ cvsignore:
hugemod_runme = hugemod$(SCRIPTPREFIX)
hugemod:
- perl hugemod.pl $(hugemod_runme)
+ perl hugemod.pl $(hugemod_runme)
$(MAKE) hugemod_a.cpptest
$(MAKE) hugemod_b.cpptest
sh -c "time $(PYTHON) $(hugemod_runme)"
sh -c "time $(PYTHON) $(hugemod_runme)"
-
diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in
index 18e2d4b25..32d9b85da 100644
--- a/Examples/test-suite/r/Makefile.in
+++ b/Examples/test-suite/r/Makefile.in
@@ -28,7 +28,7 @@ include $(srcdir)/../common.mk
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -38,14 +38,14 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_multitestcase)
# Runs the testcase.
-#
-# Run the runme if it exists. If not just load the R wrapper to
+#
+# Run the runme if it exists. If not just load the R wrapper to
# check for syntactic correctness
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
@@ -58,7 +58,7 @@ run_multitestcase = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \
- $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
+ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
else \
$(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \
fi; \
@@ -74,5 +74,3 @@ clean:
rm -f $${f}.R $${f}.Rout ; \
done \
fi
-
-
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index ab366ccd4..40985e532 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -42,7 +42,7 @@ SWIGOPT += -w801 -noautorename -features autodoc=4
ruby_naming.cpptest: SWIGOPT += -autorename
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -52,7 +52,7 @@ ruby_naming.cpptest: SWIGOPT += -autorename
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -66,7 +66,7 @@ run_testcase = \
# Clean
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ruby_clean
diff --git a/Examples/test-suite/ruby/abstract_access_runme.rb b/Examples/test-suite/ruby/abstract_access_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/access_change_runme.rb b/Examples/test-suite/ruby/access_change_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/add_link_runme.rb b/Examples/test-suite/ruby/add_link_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/anonymous_bitfield_runme.rb b/Examples/test-suite/ruby/anonymous_bitfield_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/apply_signed_char_runme.rb b/Examples/test-suite/ruby/apply_signed_char_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/apply_strings_runme.rb b/Examples/test-suite/ruby/apply_strings_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/argout_runme.rb b/Examples/test-suite/ruby/argout_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/arrays_runme.rb b/Examples/test-suite/ruby/arrays_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/cast_operator_runme.rb b/Examples/test-suite/ruby/cast_operator_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/casts_runme.rb b/Examples/test-suite/ruby/casts_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/check_missing_tests.rb b/Examples/test-suite/ruby/check_missing_tests.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/class_ignore_runme.rb b/Examples/test-suite/ruby/class_ignore_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/const_const_runme.rb b/Examples/test-suite/ruby/const_const_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/constover_runme.rb b/Examples/test-suite/ruby/constover_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/cpp_namespace_runme.rb b/Examples/test-suite/ruby/cpp_namespace_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/default_constructor_runme.rb b/Examples/test-suite/ruby/default_constructor_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/dynamic_cast_runme.rb b/Examples/test-suite/ruby/dynamic_cast_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/enum_thorough_runme.rb b/Examples/test-suite/ruby/enum_thorough_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/function_typedef_runme.rb b/Examples/test-suite/ruby/function_typedef_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/imports_runme.rb b/Examples/test-suite/ruby/imports_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/integers_runme.rb b/Examples/test-suite/ruby/integers_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_cstring_runme.rb b/Examples/test-suite/ruby/li_cstring_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_math_runme.rb b/Examples/test-suite/ruby/li_math_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_functors_runme.rb b/Examples/test-suite/ruby/li_std_functors_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_map_runme.rb b/Examples/test-suite/ruby/li_std_map_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_multimap_runme.rb b/Examples/test-suite/ruby/li_std_multimap_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_pair_runme.rb b/Examples/test-suite/ruby/li_std_pair_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_queue_runme.rb b/Examples/test-suite/ruby/li_std_queue_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_set_runme.rb b/Examples/test-suite/ruby/li_std_set_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_speed2_runme.rb b/Examples/test-suite/ruby/li_std_speed2_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_stack_runme.rb b/Examples/test-suite/ruby/li_std_stack_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_stream_runme.rb b/Examples/test-suite/ruby/li_std_stream_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_vector_enum_runme.rb b/Examples/test-suite/ruby/li_std_vector_enum_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/namespace_typemap_runme.rb b/Examples/test-suite/ruby/namespace_typemap_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_bool_runme.rb b/Examples/test-suite/ruby/overload_bool_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_copy_runme.rb b/Examples/test-suite/ruby/overload_copy_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_extend_runme.rb b/Examples/test-suite/ruby/overload_extend_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_extendc_runme.rb b/Examples/test-suite/ruby/overload_extendc_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_simple_runme.rb b/Examples/test-suite/ruby/overload_simple_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_template_runme.rb b/Examples/test-suite/ruby/overload_template_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/primitive_ref_runme.rb b/Examples/test-suite/ruby/primitive_ref_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/sneaky1_runme.rb b/Examples/test-suite/ruby/sneaky1_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/std_containers_runme.rb b/Examples/test-suite/ruby/std_containers_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/stl_new_runme.rb b/Examples/test-suite/ruby/stl_new_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/swig_assert.rb b/Examples/test-suite/ruby/swig_assert.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/swig_gc.rb b/Examples/test-suite/ruby/swig_gc.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_inherit_runme.rb b/Examples/test-suite/ruby/template_inherit_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_ns4_runme.rb b/Examples/test-suite/ruby/template_ns4_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_ns_runme.rb b/Examples/test-suite/ruby/template_ns_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_rename_runme.rb b/Examples/test-suite/ruby/template_rename_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typedef_inherit_runme.rb b/Examples/test-suite/ruby/typedef_inherit_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typedef_scope_runme.rb b/Examples/test-suite/ruby/typedef_scope_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typemap_namespace_runme.rb b/Examples/test-suite/ruby/typemap_namespace_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typename_runme.rb b/Examples/test-suite/ruby/typename_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/string_simple.i b/Examples/test-suite/string_simple.i
new file mode 100644
index 000000000..c319aa1ef
--- /dev/null
+++ b/Examples/test-suite/string_simple.i
@@ -0,0 +1,13 @@
+%module string_simple
+
+%newobject copy_string;
+
+%inline %{
+#include
+const char* copy_string(const char* str) {
+ size_t len = strlen(str);
+ char* newstring = (char*) malloc(len + 1);
+ strcpy(newstring, str);
+ return newstring;
+}
+%}
diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in
index 49d2a7826..6ab293fb9 100644
--- a/Examples/test-suite/tcl/Makefile.in
+++ b/Examples/test-suite/tcl/Makefile.in
@@ -4,7 +4,7 @@
LANGUAGE = tcl
TCLSH = tclsh
-SCRIPTSUFFIX = _runme.tcl
+SCRIPTSUFFIX = _runme.tcl
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
@@ -27,7 +27,7 @@ include $(srcdir)/../common.mk
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -37,7 +37,7 @@ include $(srcdir)/../common.mk
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -51,7 +51,7 @@ run_testcase = \
# Clean
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile tcl_clean
diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in
index 8ad153961..5fd000a96 100644
--- a/Examples/test-suite/uffi/Makefile.in
+++ b/Examples/test-suite/uffi/Makefile.in
@@ -14,13 +14,13 @@ include $(srcdir)/../common.mk
# Overridden variables here
# no C++ tests for now
CPP_TEST_CASES =
-#C_TEST_CASES +=
+#C_TEST_CASES +=
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
-%.cpptest:
+%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
@@ -30,7 +30,7 @@ CPP_TEST_CASES =
+$(swig_and_compile_c)
$(run_testcase)
-%.multicpptest:
+%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@@ -44,8 +44,7 @@ run_testcase = \
# Clean: (does nothing, we dont generate extra uffi code)
%.clean:
-
+ @exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile uffi_clean
-
diff --git a/Lib/gcj/cni.i b/Lib/gcj/cni.i
index b12148e91..fcc56687a 100644
--- a/Lib/gcj/cni.i
+++ b/Lib/gcj/cni.i
@@ -4,10 +4,6 @@
%include
-extern jobject JvAllocObject (jclass cls);
-
-extern jobject JvAllocObject (jclass cls, jsize sz);
-
extern void JvInitClass (jclass cls);
extern jstring JvAllocString (jsize sz);
@@ -30,7 +26,7 @@ extern void *JvMalloc (jsize size);
extern void JvFree (void *ptr);
-extern jint JvCreateJavaVM (void* vm_args);
+extern jint JvCreateJavaVM (JvVMInitArgs* vm_args);
extern java::lang::Thread* JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group);
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index 612f83086..bbc602b0d 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -116,7 +116,7 @@ extern void _cgo_panic(const char *);
file is the same as the version of gccgo. */
#define SWIG_GCC_VERSION \
- (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC__PATH_LEVEL__)
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if SWIG_GCC_VERSION < 40700
#define SwigDoCgocall()
diff --git a/Lib/guile/Makefile b/Lib/guile/Makefile
index 17f5feced..fba7fd5d3 100644
--- a/Lib/guile/Makefile
+++ b/Lib/guile/Makefile
@@ -1,4 +1,3 @@
co:
co RCS/*.i* RCS/*.swg*
-
diff --git a/Lib/javascript/jsc/arrays_javascript.i b/Lib/javascript/jsc/arrays_javascript.i
new file mode 100644
index 000000000..b9199d86b
--- /dev/null
+++ b/Lib/javascript/jsc/arrays_javascript.i
@@ -0,0 +1,123 @@
+/* -----------------------------------------------------------------------------
+ * arrays_javascript.i
+ *
+ * These typemaps give more natural support for arrays. The typemaps are not efficient
+ * as there is a lot of copying of the array values whenever the array is passed to C/C++
+ * from JavaScript and vice versa. The JavaScript array is expected to be the same size as the C array.
+ * An exception is thrown if they are not.
+ *
+ * Example usage:
+ * Wrapping:
+ *
+ * %include
+ * %inline %{
+ * extern int FiddleSticks[3];
+ * %}
+ *
+ * Use from JavaScript like this:
+ *
+ * var fs = [10, 11, 12];
+ * example.FiddleSticks = fs;
+ * fs = example.FiddleSticks;
+ * ----------------------------------------------------------------------------- */
+
+%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
+%fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {}
+
+%typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY]
+ (int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
+ if (JSValueIsObject(context, $input))
+ {
+ // Convert into Array
+ array = JSValueToObject(context, $input, NULL);
+
+ length = $1_dim0;
+
+ $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
+
+ // Get each element from array
+ for (i = 0; i < length; i++)
+ {
+ jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL);
+
+ // Get primitive value from JSObject
+ res = SWIG_AsVal(int)(jsvalue, &temp);
+ if (!SWIG_IsOK(res))
+ {
+ SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
+ }
+ arg$argnum[i] = temp;
+ }
+
+ }
+ else
+ {
+ SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef");
+ }
+}
+
+%typemap(freearg) int[], int[ANY] {
+ free($1);
+}
+
+%typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0)
+{
+ length = $1_dim0;
+ JSValueRef values[length];
+
+ for (i = 0; i < length; i++)
+ {
+ values[i] = SWIG_From(int)($1[i]);
+ }
+
+ $result = JSObjectMakeArray(context, length, values, NULL);
+}
+
+%typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY]
+ (int length = 0, JSObjectRef array, JSValueRef jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
+ if (JSValueIsObject(context, $input))
+ {
+ // Convert into Array
+ array = JSValueToObject(context, $input, NULL);
+
+ length = $1_dim0;
+
+ $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
+
+ // Get each element from array
+ for (i = 0; i < length; i++)
+ {
+ jsvalue = JSObjectGetPropertyAtIndex(context, array, i, NULL);
+
+ // Get primitive value from JSObject
+ res = SWIG_AsVal(double)(jsvalue, &temp);
+ if (!SWIG_IsOK(res))
+ {
+ SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
+ }
+ arg$argnum[i] = temp;
+ }
+
+ }
+ else
+ {
+ SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef");
+ }
+}
+
+%typemap(freearg) double[], double[ANY] {
+ free($1);
+}
+
+%typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0)
+{
+ length = $1_dim0;
+ JSValueRef values[length];
+
+ for (i = 0; i < length; i++)
+ {
+ values[i] = SWIG_From(double)($1[i]);
+ }
+
+ $result = JSObjectMakeArray(context, length, values, NULL);
+}
diff --git a/Lib/javascript/jsc/ccomplex.i b/Lib/javascript/jsc/ccomplex.i
new file mode 100644
index 000000000..50f0f95fe
--- /dev/null
+++ b/Lib/javascript/jsc/ccomplex.i
@@ -0,0 +1,26 @@
+/* -----------------------------------------------------------------------------
+ * ccomplex.i
+ *
+ * C complex typemaps
+ * ISO C99: 7.3 Complex arithmetic
+ * ----------------------------------------------------------------------------- */
+
+
+%include
+
+%{
+#include
+%}
+
+
+/* C complex constructor */
+#define CCplxConst(r, i) ((r) + I*(i))
+
+%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
+%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
+%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
+
+/* declaring the typemaps */
+%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
diff --git a/Lib/javascript/jsc/cdata.i b/Lib/javascript/jsc/cdata.i
new file mode 100644
index 000000000..367965990
--- /dev/null
+++ b/Lib/javascript/jsc/cdata.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/javascript/jsc/complex.i b/Lib/javascript/jsc/complex.i
new file mode 100644
index 000000000..4c3b3c5e2
--- /dev/null
+++ b/Lib/javascript/jsc/complex.i
@@ -0,0 +1,6 @@
+#ifdef __cplusplus
+%include
+#else
+%include
+#endif
+
diff --git a/Lib/javascript/jsc/exception.i b/Lib/javascript/jsc/exception.i
new file mode 100644
index 000000000..0246cfde8
--- /dev/null
+++ b/Lib/javascript/jsc/exception.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/javascript/jsc/javascript.swg b/Lib/javascript/jsc/javascript.swg
new file mode 100644
index 000000000..3a83b6495
--- /dev/null
+++ b/Lib/javascript/jsc/javascript.swg
@@ -0,0 +1,19 @@
+/* -----------------------------------------------------------------------------
+ * javascript.swg
+ *
+ * Javascript typemaps
+ * ----------------------------------------------------------------------------- */
+
+%include
+
+%include
+
+%include
+
+%include
+
+%include
+
+%include
+
+%include
diff --git a/Lib/javascript/jsc/javascriptcode.swg b/Lib/javascript/jsc/javascriptcode.swg
new file mode 100644
index 000000000..738b54d70
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptcode.swg
@@ -0,0 +1,418 @@
+/* -----------------------------------------------------------------------------
+ * js_ctor: template for wrapping a ctor.
+ * - $jswrapper: wrapper of called ctor
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * - $jsargcount: number of arguments
+ * - $jsmangledtype: mangled type of class
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_ctor", "templates")
+%{
+JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ $jslocals
+ if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
+
+ $jscode
+ return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
+ goto fail;
+ fail:
+ return NULL;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_veto_ctor: a vetoing ctor for abstract classes
+ * - $jswrapper: name of wrapper
+ * - $jsname: class name
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_veto_ctor", "templates")
+%{
+JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
+ size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
+ return 0;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_ctor_dispatcher: dispatcher for overloaded constructors
+ * - $jswrapper: name of wrapper
+ * - $jsname: class name
+ * - $jsdispatchcases: part containing code for dispatching
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_ctor_dispatcher", "templates")
+%{
+JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
+ size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ JSObjectRef thisObject = NULL;
+
+ // switch all cases by means of series of if-returns.
+ $jsdispatchcases
+
+ // default:
+ SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsname");
+
+ fail:
+ return thisObject;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_overloaded_ctor: template for wrapping a ctor.
+ * - $jswrapper: wrapper of called ctor
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * - $jsargcount: number of arguments
+ * - $jsmangledtype: mangled type of class
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_overloaded_ctor", "templates")
+%{
+JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ $jslocals
+ $jscode
+ return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
+
+ goto fail;
+ fail:
+ return NULL;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor.
+ * - $jsargcount: number of arguments of called ctor
+ * - $jswrapper: wrapper of called ctor
+ *
+ * Note: a try-catch-like mechanism is used to switch cases
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_ctor_dispatch_case", "templates")
+%{
+ if(argc == $jsargcount) {
+ thisObject = $jswrapper(context, NULL, argc, argv, exception);
+ if(thisObject != NULL) { *exception=0; return thisObject; } /* reset exception and return */
+ }
+%}
+
+
+/* -----------------------------------------------------------------------------
+ * js_dtor: template for a destructor wrapper
+ * - $jsmangledname: mangled class name
+ * - $jstype: class type
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_dtor", "templates")
+%{
+void $jswrapper(JSObjectRef thisObject)
+{
+ SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject);
+ if(t && t->swigCMemOwn) free (($jstype)t->swigCObject);
+ if(t) free(t);
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_dtor: template for a destructor wrapper
+ * - $jsmangledname: mangled class name
+ * - $jstype: class type
+ * - ${destructor_action}: The custom destructor action to invoke.
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_dtoroverride", "templates")
+%{
+void $jswrapper(JSObjectRef thisObject)
+{
+ SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject);
+ if(t && t->swigCMemOwn) {
+ $jstype arg1 = ($jstype)t->swigCObject;
+ ${destructor_action}
+ }
+ if(t) free(t);
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_getter: template for getter function wrappers
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_getter", "templates")
+%{
+JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+ $jslocals
+ JSValueRef jsresult;
+
+ $jscode
+ return jsresult;
+
+ goto fail;
+ fail:
+ return NULL;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_setter: template for setter function wrappers
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_setter", "templates")
+%{
+bool $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+ $jslocals
+ $jscode
+
+ return true;
+
+ goto fail;
+ fail:
+ return false;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_function: template for function wrappers
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_function", "templates")
+%{
+JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ $jslocals
+ JSValueRef jsresult;
+
+ if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
+
+ $jscode
+ return jsresult;
+
+ goto fail;
+ fail:
+ return NULL;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_function_dispatcher: template for a function dispatcher for overloaded functions
+ * - $jswrapper: wrapper function name
+ * - $jsname: name of the wrapped function
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_function_dispatcher", "templates")
+%{
+JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ $jslocals
+ JSValueRef jsresult;
+ int res;
+ $jscode
+
+ SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname.");
+ return jsresult;
+
+ goto fail;
+ fail:
+ return NULL;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_overloaded_function: template for a overloaded function
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_overloaded_function", "templates")
+%{
+int $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* p_result)
+{
+ $jslocals
+ JSValueRef jsresult;
+
+ if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
+
+ $jscode
+ *p_result = jsresult;
+ return SWIG_OK;
+
+ goto fail;
+ fail:
+ return SWIG_TypeError;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_function_dispatch_case: template for a case used in the function dispatcher
+ * - $jswrapper: wrapper function name
+ * - $jsargcount: number of arguments of overloaded function
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_function_dispatch_case", "templates")
+%{
+ if(argc == $jsargcount) {
+ res = $jswrapper(context, function, thisObject, argc, argv, exception, &jsresult);
+ if(res == SWIG_OK) { *exception = 0; return jsresult; }
+ }
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsc_variable_declaration: template for a variable table entry
+ * - $jsname: name of the variable
+ * - $jsgetter: wrapper of getter function
+ * - $jssetter: wrapper of setter function
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_variable_declaration", "templates")
+%{
+ {"$jsname", $jsgetter, $jssetter, kJSPropertyAttributeNone},
+%}
+
+
+/* -----------------------------------------------------------------------------
+ * jsc_function_declaration: template for a function table entry
+ * - $jsname: name of the variable
+ * - $jswrapper: wrapper function
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_function_declaration", "templates")
+%{
+ {"$jsname", $jswrapper, kJSPropertyAttributeNone},
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsc_classtemplate_declaration: template for a namespace declaration
+ * - $jsmangledname: mangled class name
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_class_declaration", "templates")
+%{
+JSClassDefinition $jsmangledname_classDefinition;
+
+JSClassDefinition $jsmangledname_objectDefinition;
+
+JSClassRef $jsmangledname_classRef;
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsc_class_tables: template for a namespace declaration
+ * - $jsmangledname: mangled class name
+ * - $jsstaticclassvariables: list of static variable entries
+ * - $jsstaticclassfunctions: list of static function entries
+ * - $jsclassvariables: list of member variable entries
+ * - $jsclassfunctions: list of member function entries
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_class_tables", "templates")
+%{
+JSStaticValue $jsmangledname_staticValues[] = {
+ $jsstaticclassvariables
+ { 0, 0, 0, 0 }
+};
+
+JSStaticFunction $jsmangledname_staticFunctions[] = {
+ $jsstaticclassfunctions
+ { 0, 0, 0 }
+};
+
+JSStaticValue $jsmangledname_values[] = {
+ $jsclassvariables
+ { 0, 0, 0, 0 }
+};
+
+JSStaticFunction $jsmangledname_functions[] = {
+ $jsclassfunctions
+ { 0, 0, 0 }
+};
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsc_define_class_template: template for defining a class template
+ * - $jsmangledname: mangled class name
+ * - $jsmangledtype: mangled class type
+ * - $jsctor: wrapper of ctor
+ * - $jsbaseclass: mangled name of base class
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_class_definition", "templates")
+%{
+ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_staticFunctions;
+ $jsmangledname_classDefinition.staticValues = $jsmangledname_staticValues;
+ $jsmangledname_classDefinition.callAsConstructor = $jsctor;
+ $jsmangledname_classDefinition.finalize = $jsdtor;
+ $jsmangledname_objectDefinition.staticValues = $jsmangledname_values;
+ $jsmangledname_objectDefinition.staticFunctions = $jsmangledname_functions;
+ $jsclass_inheritance
+ JSClassRef $jsmangledname_classRef = JSClassCreate(&$jsmangledname_objectDefinition);
+ SWIGTYPE_$jsmangledtype->clientdata = $jsmangledname_classRef;
+%}
+
+%fragment ("jsc_class_inherit", templates)
+%{
+ if (SWIGTYPE_p$jsbaseclassmangled != NULL) {
+ $jsmangledname_objectDefinition.parentClass = (JSClassRef) SWIGTYPE_p$jsbaseclassmangled->clientdata;
+ }
+%}
+
+%fragment ("jsc_class_noinherit", templates)
+%{
+ $jsmangledname_objectDefinition.parentClass = _SwigObject_classRef;
+%}
+
+
+/* -----------------------------------------------------------------------------
+ * jsc_register_class: template for registration of a class
+ * - $jsname: class name
+ * - $jsmangledname: mangled class name
+ * - $jsnspace: mangled name of namespace
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_class_registration", "templates")
+%{
+ JS_registerClass(context, $jsnspace_object, "$jsname", &$jsmangledname_classDefinition);
+%}
+
+
+/* -----------------------------------------------------------------------------
+ * jsc_nspace_declaration: template for a namespace declaration
+ * - $jsnspace: mangled name of the namespace
+ * - $jsglobalvariables: list of variable entries
+ * - $jsglobalfunctions: list if fuction entries
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_nspace_declaration", "templates")
+%{
+JSStaticValue $jsnspace_values[] = {
+ $jsglobalvariables
+ { 0, 0, 0, 0 }
+};
+
+JSStaticFunction $jsnspace_functions[] = {
+ $jsglobalfunctions
+ { 0, 0, 0 }
+};
+
+JSClassDefinition $jsnspace_classDefinition;
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsc_nspace_definition: template for definition of a namespace object
+ * - $jsmangledname: mangled name of namespace
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_nspace_definition", "templates")
+%{
+ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_functions;
+ $jsmangledname_classDefinition.staticValues = $jsmangledname_values;
+ JSObjectRef $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL);
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsc_nspace_registration: template for registration of a namespace object
+ * - $jsname: name of namespace
+ * - $jsmangledname: mangled name of namespace
+ * - $jsparent: mangled name of parent namespace
+ * ----------------------------------------------------------------------------- */
+%fragment ("jsc_nspace_registration", "templates")
+%{
+ JS_registerNamespace(context, $jsmangledname_object, $jsparent_object, "$jsname");
+%}
diff --git a/Lib/javascript/jsc/javascriptcomplex.swg b/Lib/javascript/jsc/javascriptcomplex.swg
new file mode 100644
index 000000000..7d165dce4
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptcomplex.swg
@@ -0,0 +1,146 @@
+/*
+ Defines the As/From converters for double/float complex, you need to
+ provide complex Type, the Name you want to use in the converters,
+ the complex Constructor method, and the Real and Imag complex
+ accessor methods.
+
+ See the std_complex.i and ccomplex.i for concret examples.
+*/
+
+/* the common from converter */
+%define %swig_fromcplx_conv(Type, Real, Imag)
+%fragment(SWIG_From_frag(Type),"header",
+ fragment=SWIG_From_frag(double))
+{
+SWIGINTERNINLINE JSObjectRef
+SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
+{
+ JSValueRef vals[2];
+ vals[0] = SWIG_From(double)(Real(c));
+ vals[1] = SWIG_From(double)(Imag(c));
+ return JSObjectMakeArray(context, 2, vals, NULL);
+}
+}
+%enddef
+
+/* the double case */
+%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(double))
+{
+SWIGINTERN int
+SWIG_AsVal_dec(Type) (JSValueRef o, Type* val)
+{
+ if (JSValueIsObject(context, o)) {
+ JSObjectRef array;
+ JSValueRef exception, js_re, js_im;
+ double re, im;
+ int res;
+
+ exception = 0;
+ res = 0;
+
+ array = JSValueToObject(context, o, &exception);
+ if(exception != 0)
+ return SWIG_TypeError;
+
+ js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception);
+ if(exception != 0)
+ return SWIG_TypeError;
+
+ js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception);
+ if(exception != 0)
+ return SWIG_TypeError;
+
+ res = SWIG_AsVal(double)(js_re, &re);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ res = SWIG_AsVal(double)(js_im, &im);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ if (val) *val = Constructor(re, im);
+ return SWIG_OK;
+ } else {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
+ if (SWIG_IsOK(res)) {
+ if (val) *val = Constructor(d, 0.0);
+ return res;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+%swig_fromcplx_conv(Type, Real, Imag);
+%enddef
+
+/* the float case */
+%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(float)) {
+SWIGINTERN int
+SWIG_AsVal_dec(Type)(JSValueRef o, Type *val)
+{
+ if (JSValueIsObject(context, o)) {
+ JSObjectRef array;
+ JSValueRef exception, js_re, js_im;
+ double re, im;
+ int res;
+
+ exception = 0;
+ res = 0;
+
+ array = JSValueToObject(context, o, &exception);
+ if(exception != 0)
+ return SWIG_TypeError;
+
+ js_re = JSObjectGetPropertyAtIndex(context, array, 0, &exception);
+ if(exception != 0)
+ return SWIG_TypeError;
+
+ js_im = JSObjectGetPropertyAtIndex(context, array, 1, &exception);
+ if(exception != 0)
+ return SWIG_TypeError;
+
+ res = SWIG_AsVal(double)(js_re, &re);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ res = SWIG_AsVal(double)(js_im, &im);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
+ if (val) *val = Constructor(%numeric_cast(re, float),
+ %numeric_cast(im, float));
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else {
+ float re;
+ int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
+ if (SWIG_IsOK(res)) {
+ if (val) *val = Constructor(re, 0.0);
+ return res;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+
+%swig_fromcplx_conv(Type, Real, Imag);
+%enddef
+
+#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
+%swig_cplxflt_conv(Type, Constructor, Real, Imag)
+
+
+#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
+%swig_cplxdbl_conv(Type, Constructor, Real, Imag)
diff --git a/Lib/javascript/jsc/javascriptfragments.swg b/Lib/javascript/jsc/javascriptfragments.swg
new file mode 100644
index 000000000..4778bf033
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptfragments.swg
@@ -0,0 +1,23 @@
+/*
+
+ Create a file with this name, 'javascriptfragments.swg', in your working
+ directory and add all the %fragments you want to take precedence
+ over the default ones defined by swig.
+
+ For example, if you add:
+
+ %fragment(SWIG_AsVal_frag(int),"header") {
+ SWIGINTERNINLINE int
+ SWIG_AsVal(int)(PyObject *obj, int *val)
+ {
+ ;
+ }
+ }
+
+ this will replace the code used to retrieve an integer value for all
+ the typemaps that need it, including:
+
+ int, std::vector, std::list >, etc.
+
+
+*/
diff --git a/Lib/javascript/jsc/javascripthelpers.swg b/Lib/javascript/jsc/javascripthelpers.swg
new file mode 100644
index 000000000..820075ca6
--- /dev/null
+++ b/Lib/javascript/jsc/javascripthelpers.swg
@@ -0,0 +1,69 @@
+%insert(wrapper) %{
+
+bool JS_registerClass(JSGlobalContextRef context, JSObjectRef parentObject,
+ const char* className,
+ JSClassDefinition* definition) {
+
+ JSStringRef js_className = JSStringCreateWithUTF8CString(className);
+ JSObjectRef classObject = JSObjectMake(context, JSClassCreate(definition), NULL);
+ JSObjectSetProperty(context, parentObject,
+ js_className, classObject,
+ kJSPropertyAttributeNone, NULL);
+ JSStringRelease(js_className);
+
+ return true;
+}
+
+bool JS_registerNamespace(JSGlobalContextRef context,
+ JSObjectRef namespaceObj, JSObjectRef parentNamespace,
+ const char* name)
+{
+ JSStringRef js_name = JSStringCreateWithUTF8CString(name);
+ JSObjectSetProperty(context, parentNamespace,
+ js_name, namespaceObj,
+ kJSPropertyAttributeNone, NULL);
+ JSStringRelease(js_name);
+
+ return true;
+}
+
+
+bool JS_registerFunction(JSGlobalContextRef context, JSObjectRef object,
+ const char* functionName, JSObjectCallAsFunctionCallback callback)
+{
+ JSStringRef js_functionName = JSStringCreateWithUTF8CString(functionName);
+ JSObjectSetProperty(context, object, js_functionName,
+ JSObjectMakeFunctionWithCallback(context, js_functionName, callback),
+ kJSPropertyAttributeNone, NULL);
+ JSStringRelease(js_functionName);
+ return true;
+}
+
+bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+ char buffer[256];
+ char msg[512];
+ int res;
+
+ JSStringGetUTF8CString(propertyName, buffer, 256);
+ res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
+
+ if(res<0) {
+ SWIG_exception(SWIG_ERROR, "Tried to write read-only variable.");
+ } else {
+ SWIG_exception(SWIG_ERROR, msg);
+ }
+
+ return false;
+}
+
+JSValueRef JS_CharPtrToJSValue(JSContextRef context, char* cstr) {
+ JSValueRef val;
+
+ JSStringRef jsstring = JSStringCreateWithUTF8CString((char*) cstr);
+ val = JSValueMakeString(context, jsstring);
+ JSStringRelease(jsstring);
+
+ return val;
+}
+%}
diff --git a/Lib/javascript/jsc/javascriptinit.swg b/Lib/javascript/jsc/javascriptinit.swg
new file mode 100644
index 000000000..a32ba336c
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptinit.swg
@@ -0,0 +1,67 @@
+%insert(init) %{
+SWIGRUNTIME void
+SWIG_JSC_SetModule(swig_module_info *swig_module) {}
+
+SWIGRUNTIME swig_module_info *
+SWIG_JSC_GetModule(void) {
+ return 0;
+}
+
+#define SWIG_GetModule(clientdata) SWIG_JSC_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(pointer)
+%}
+
+%insert(init) "swiginit.swg"
+
+%fragment ("js_initializer_define", "templates") %{
+#define SWIGJSC_INIT $jsname_initialize
+%}
+
+// Open the initializer function
+%insert(init)
+%{
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool SWIGJSC_INIT (JSGlobalContextRef context, JSObjectRef *exports) {
+ SWIG_InitializeModule(0);
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_initializer: template for the module initializer function
+ * - $jsname: module name
+ * - $jscreatenamespaces: part with code for creating namespace objects
+ * - $jscreateclasses: part with code for creating classes
+ * - $jsregisternamespaces: part with code for registration of namespaces
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_initializer", "templates") %{
+ /* Initialize the base swig type object */
+ _SwigObject_objectDefinition.staticFunctions = _SwigObject_functions;
+ _SwigObject_objectDefinition.staticValues = _SwigObject_values;
+ _SwigObject_classRef = JSClassCreate(&_SwigObject_objectDefinition);
+
+ /* Initialize the PackedData class */
+ _SwigPackedData_objectDefinition.staticFunctions = _SwigPackedData_functions;
+ _SwigPackedData_objectDefinition.staticValues = _SwigPackedData_values;
+ _SwigPackedData_objectDefinition.finalize = _wrap_SwigPackedData_delete;
+ _SwigPackedData_classRef = JSClassCreate(&_SwigPackedData_objectDefinition);
+
+ /* Create objects for namespaces */
+ $jscreatenamespaces
+
+ /* Register classes */
+ $jsregisterclasses
+
+ /* Register namespaces */
+ $jsregisternamespaces
+
+ *exports = exports_object;
+
+ return true;
+}
+#ifdef __cplusplus
+}
+#endif
+%}
diff --git a/Lib/javascript/jsc/javascriptkw.swg b/Lib/javascript/jsc/javascriptkw.swg
new file mode 100644
index 000000000..c3c118391
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptkw.swg
@@ -0,0 +1,40 @@
+#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_
+#define JAVASCRIPT_JAVASCRIPTKW_SWG_
+
+/* Warnings for Java keywords */
+#define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x`
+
+/* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */
+
+JAVASCRIPTKW(break);
+JAVASCRIPTKW(case);
+JAVASCRIPTKW(catch);
+JAVASCRIPTKW(continue);
+JAVASCRIPTKW(default);
+JAVASCRIPTKW(delete);
+JAVASCRIPTKW(do);
+JAVASCRIPTKW(else);
+JAVASCRIPTKW(finally);
+JAVASCRIPTKW(for);
+JAVASCRIPTKW(function);
+JAVASCRIPTKW(if);
+JAVASCRIPTKW(in);
+JAVASCRIPTKW(instanceof);
+JAVASCRIPTKW(new);
+JAVASCRIPTKW(return);
+JAVASCRIPTKW(switch);
+JAVASCRIPTKW(this);
+JAVASCRIPTKW(throw);
+JAVASCRIPTKW(try);
+JAVASCRIPTKW(typeof);
+JAVASCRIPTKW(var);
+JAVASCRIPTKW(void);
+JAVASCRIPTKW(while);
+JAVASCRIPTKW(with);
+
+/* others bad names if any*/
+// for example %namewarn("321:clone() is a javascript bad method name") *::clone();
+
+#undef JAVASCRIPTKW
+
+#endif //JAVASCRIPT_JAVASCRIPTKW_SWG_
diff --git a/Lib/javascript/jsc/javascriptprimtypes.swg b/Lib/javascript/jsc/javascriptprimtypes.swg
new file mode 100644
index 000000000..7e9898a24
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptprimtypes.swg
@@ -0,0 +1,182 @@
+/* ------------------------------------------------------------
+ * Primitive Types
+ * ------------------------------------------------------------ */
+
+/* boolean */
+
+%fragment(SWIG_From_frag(bool),"header") {
+SWIGINTERNINLINE
+JSValueRef SWIG_From_dec(bool)(bool value)
+{
+ return JSValueMakeBoolean(context, value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(bool),"header",
+ fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN
+int SWIG_AsVal_dec(bool)(JSValueRef obj, bool *val)
+{
+ if(!JSValueIsBoolean(context, obj)) {
+ return SWIG_ERROR;
+ }
+ if (val) *val = JSValueToBoolean(context, obj);
+ return SWIG_OK;
+}
+}
+
+/* int */
+
+%fragment(SWIG_From_frag(int),"header") {
+SWIGINTERNINLINE JSValueRef
+ SWIG_From_dec(int)(int value)
+{
+ return JSValueMakeNumber(context, value);
+}
+}
+
+/* long */
+
+%fragment(SWIG_From_frag(long),"header") {
+SWIGINTERNINLINE JSValueRef
+SWIG_From_dec(long)(long value)
+{
+ return JSValueMakeNumber(context, value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(long),"header",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN int
+SWIG_AsVal_dec(long)(JSValueRef obj, long* val)
+{
+ if (!JSValueIsNumber(context, obj)) {
+ return SWIG_TypeError;
+ }
+ if(val) *val = (long) JSValueToNumber(context, obj, NULL);
+
+ return SWIG_OK;
+}
+}
+
+/* unsigned long */
+
+%fragment(SWIG_From_frag(unsigned long),"header",
+ fragment=SWIG_From_frag(long)) {
+SWIGINTERNINLINE JSValueRef
+SWIG_From_dec(unsigned long)(unsigned long value)
+{
+ return (value > LONG_MAX) ?
+ JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long));
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long),"header",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long)(JSValueRef obj, unsigned long *val)
+{
+ if(!JSValueIsNumber(context, obj)) {
+ return SWIG_TypeError;
+ }
+
+ long longVal = (long) JSValueToNumber(context, obj, NULL);
+
+ if(longVal < 0) {
+ return SWIG_OverflowError;
+ }
+
+ if(val) *val = longVal;
+
+ return SWIG_OK;
+}
+}
+
+/* long long */
+// Note: these are copied from 'long' and probably need fixing
+
+%fragment(SWIG_From_frag(long long),"header",
+ fragment=SWIG_From_frag(long),
+ fragment="") {
+SWIGINTERNINLINE JSValueRef
+SWIG_From_dec(long long)(long long value)
+{
+ return JSValueMakeNumber(context, value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(long long),"header",
+ fragment=SWIG_AsVal_frag(long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="") {
+SWIGINTERN int
+SWIG_AsVal_dec(long long)(JSValueRef obj, long long* val)
+{
+ if (!JSValueIsNumber(context, obj)) {
+ return SWIG_TypeError;
+ }
+ if(val) *val = (long long) JSValueToNumber(context, obj, NULL);
+
+ return SWIG_OK;
+}
+}
+
+/* unsigned long long */
+// Note: these are copied from 'unsigned long' and probably need fixing
+
+%fragment(SWIG_From_frag(unsigned long long),"header",
+ fragment=SWIG_From_frag(long long),
+ fragment="") {
+SWIGINTERN JSValueRef
+SWIG_From_dec(unsigned long long)(unsigned long long value)
+{
+ return (value > LONG_MAX) ?
+ JSValueMakeNumber(context, value) : JSValueMakeNumber(context, %numeric_cast(value,long));
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long long),"header",
+ fragment=SWIG_AsVal_frag(unsigned long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="") {
+SWIGINTERN int
+SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val)
+{
+ if(!JSValueIsNumber(context, obj)) {
+ return SWIG_TypeError;
+ }
+
+ long long longVal = (unsigned long long) JSValueToNumber(context, obj, NULL);
+
+ if(longVal < 0) {
+ return SWIG_OverflowError;
+ }
+
+ if(val) *val = longVal;
+
+ return SWIG_OK;
+}
+}
+
+/* double */
+
+%fragment(SWIG_From_frag(double),"header") {
+SWIGINTERN JSValueRef
+SWIG_From_dec(double) (double val)
+{
+ return JSValueMakeNumber(context, val);
+}
+}
+
+%fragment(SWIG_AsVal_frag(double),"header") {
+SWIGINTERN int
+SWIG_AsVal_dec(double)(JSValueRef obj, double *val)
+{
+ if(!JSValueIsNumber(context, obj)) {
+ return SWIG_TypeError;
+ }
+ if(val) *val = JSValueToNumber(context, obj, NULL);
+
+ return SWIG_OK;
+}
+}
diff --git a/Lib/javascript/jsc/javascriptrun.swg b/Lib/javascript/jsc/javascriptrun.swg
new file mode 100644
index 000000000..3463d2351
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptrun.swg
@@ -0,0 +1,298 @@
+/* ----------------------------------------------------------------------------
+ * Errors and exceptions
+ *
+ * ---------------------------------------------------------------------------*/
+
+#define SWIG_Error(code, msg) SWIG_JSC_exception(context, exception, code, msg)
+#define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg)
+#define SWIG_fail goto fail
+
+void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) {
+ JSStringRef message = JSStringCreateWithUTF8CString(type);
+ *exception = JSValueMakeString(context, message);
+ JSStringRelease(message);
+}
+
+void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) {
+ SWIG_Javascript_Raise(context, exception, msg);
+}
+
+/* ----------------------------------------------------------------------------
+ * The parent class of all Proxies
+ *
+ * ---------------------------------------------------------------------------*/
+
+typedef struct {
+ bool swigCMemOwn;
+ void *swigCObject;
+ swig_type_info *info;
+} SwigPrivData;
+
+JSValueRef _wrap_SwigObject_disown(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ JSValueRef jsresult;
+
+ JSObjectRef obj = JSValueToObject(context, thisObject, NULL);
+ SwigPrivData *cdata = (SwigPrivData *) JSObjectGetPrivate(obj);
+
+ cdata->swigCMemOwn = false;
+
+ jsresult = JSValueMakeUndefined(context);
+ return jsresult;
+}
+
+JSValueRef _wrap_SwigObject_getCPtr(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ JSValueRef jsresult;
+ long result;
+
+ JSObjectRef obj = JSValueToObject(context, thisObject, NULL);
+ SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj);
+
+ result = (long) cdata->swigCObject;
+ jsresult = JSValueMakeNumber(context, result);
+
+ return jsresult;
+}
+
+JSValueRef _wrap_SwigObject_equals(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+{
+ JSValueRef jsresult;
+ bool result;
+
+ JSObjectRef obj = JSValueToObject(context, thisObject, NULL);
+ SwigPrivData *cdata = (SwigPrivData*) JSObjectGetPrivate(obj);
+
+ JSObjectRef obj2 = JSValueToObject(context, argv[0], NULL);
+ SwigPrivData *cdata2 = (SwigPrivData*) JSObjectGetPrivate(obj2);
+
+ result = (cdata->swigCObject == cdata2->swigCObject);
+ jsresult = JSValueMakeBoolean(context, result);
+
+ return jsresult;
+}
+
+JSStaticValue _SwigObject_values[] = {
+ {
+ 0, 0, 0, 0
+ }
+};
+
+JSStaticFunction _SwigObject_functions[] = {
+ {
+ "disown",_wrap_SwigObject_disown, kJSPropertyAttributeNone
+ },
+ {
+ "equals",_wrap_SwigObject_equals, kJSPropertyAttributeNone
+ },
+ {
+ "getCPtr",_wrap_SwigObject_getCPtr, kJSPropertyAttributeNone
+ },
+ {
+ 0, 0, 0
+ }
+};
+
+JSClassDefinition _SwigObject_objectDefinition;
+
+JSClassRef _SwigObject_classRef;
+
+
+int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef objRef, void** ptr, swig_type_info *info, int flags) {
+ SwigPrivData *cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
+ if(cdata == NULL) {
+ return SWIG_ERROR;
+ }
+ if(cdata->info != info) {
+ bool type_valid = false;
+ swig_cast_info *t = info->cast;
+ while(t != NULL) {
+ if(t->type == cdata->info) {
+ type_valid = true;
+ break;
+ }
+ t = t->next;
+ }
+ if(!type_valid) {
+ return SWIG_TypeError;
+ }
+ }
+
+ *ptr = cdata->swigCObject;
+
+ if(flags & SWIG_POINTER_DISOWN) {
+ cdata->swigCMemOwn = false;
+ }
+
+ return SWIG_OK;
+}
+
+int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) {
+ if(!JSValueIsObject(context, valRef)) {
+ return SWIG_TypeError;
+ }
+
+ JSObjectRef objRef = JSValueToObject(context, valRef, NULL);
+ if(objRef == NULL) {
+ return SWIG_ERROR;
+ }
+
+ return SWIG_JSC_ConvertInstancePtr(context, objRef, ptr, info, flags);
+}
+
+JSObjectRef SWIG_JSC_NewPointerObj(JSContextRef context, void *ptr, swig_type_info *info, int flags) {
+
+ JSClassRef classRef;
+ if(info->clientdata == NULL) {
+ classRef = _SwigObject_classRef;
+ } else {
+ classRef = (JSClassRef) info->clientdata;
+ }
+
+ JSObjectRef result = JSObjectMake(context, classRef, NULL);
+
+ SwigPrivData* cdata = (SwigPrivData*) malloc(sizeof(SwigPrivData));
+ cdata->swigCObject = ptr;
+ cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
+ cdata->info = info;
+
+ JSObjectSetPrivate(result, cdata);
+
+ return result;
+}
+
+#define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_JSC_ConvertPtr(context, obj, ptr, info, flags)
+#define SWIG_NewPointerObj(ptr, info, flags) SWIG_JSC_NewPointerObj(context, ptr, info, flags)
+
+#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_JSC_ConvertInstancePtr(context, obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_JSC_NewPointerObj(context, thisvalue, type, flags)
+
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_JSC_ConvertPtr(context, obj, pptr, type, 0)
+#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_JSC_NewPointerObj(context, ptr, type, 0)
+
+/* ----------------------------------------------------------------------------
+ * A class for packed data
+ *
+ * ---------------------------------------------------------------------------*/
+
+typedef struct {
+ void *data;
+ size_t size;
+ swig_type_info *type;
+} SwigPackedData;
+
+JSStaticValue _SwigPackedData_values[] = {
+ {
+ 0, 0, 0, 0
+ }
+};
+JSStaticFunction _SwigPackedData_functions[] = {
+ {
+ 0, 0, 0
+ }
+};
+JSClassDefinition _SwigPackedData_objectDefinition;
+JSClassRef _SwigPackedData_classRef;
+
+SWIGRUNTIMEINLINE
+int SwigJSCPacked_Check(JSContextRef context, JSValueRef valRef) {
+ return JSValueIsObjectOfClass(context, valRef, _SwigPackedData_classRef);
+}
+
+SWIGRUNTIME
+swig_type_info* SwigJSCPacked_UnpackData(JSContextRef context, JSValueRef valRef, void *ptr, size_t size) {
+ if (SwigJSCPacked_Check(context, valRef)) {
+ JSObjectRef objRef = JSValueToObject(context, valRef, NULL);
+ SwigPackedData *sobj = (SwigPackedData *) JSObjectGetPrivate(objRef);
+ if (sobj->size != size) return 0;
+ memcpy(ptr, sobj->data, size);
+ return sobj->type;
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIME
+int SWIG_JSC_ConvertPacked(JSContextRef context, JSValueRef valRef, void *ptr, size_t sz, swig_type_info *ty) {
+ swig_type_info *to = SwigJSCPacked_UnpackData(context, valRef, ptr, sz);
+ if (!to) return SWIG_ERROR;
+ if (ty) {
+ if (to != ty) {
+ /* check type cast? */
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) return SWIG_ERROR;
+ }
+ }
+ return SWIG_OK;
+}
+
+SWIGRUNTIME
+JSValueRef SWIG_JSC_NewPackedObj(JSContextRef context, void *data, size_t size, swig_type_info *type) {
+
+ JSClassRef classRef = _SwigObject_classRef;
+ JSObjectRef result = JSObjectMake(context, classRef, NULL);
+
+ SwigPackedData* cdata = (SwigPackedData*) malloc(sizeof(SwigPackedData));
+ cdata->data = data;
+ cdata->size = size;
+ cdata->type = type;
+
+ JSObjectSetPrivate(result, cdata);
+
+ return result;
+}
+
+/* SwigPackedData wrappers */
+
+void _wrap_SwigPackedData_delete(JSObjectRef obj)
+{
+ SwigPackedData* cdata = (SwigPackedData*) JSObjectGetPrivate(obj);
+ if (cdata) {
+ free(cdata->data);
+ }
+}
+
+/* for C++ member pointers, ie, member methods */
+
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_JSC_ConvertPacked(context, obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIG_JSC_NewPackedObj(context, ptr, sz, type)
+
+
+/* ---------------------------------------------------------------------------
+ * Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg)
+ *
+ * ---------------------------------------------------------------------------*/
+
+unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) {
+ static JSStringRef LENGTH = 0;
+ JSValueRef exception = NULL;
+ JSValueRef js_length;
+ double length;
+
+ if (LENGTH == 0) {
+ LENGTH = JSStringCreateWithUTF8CString("length");
+ }
+
+ js_length = JSObjectGetProperty(context, arr, LENGTH, &exception);
+ if (exception == 0 && JSValueIsNumber(context, js_length)) {
+ length = JSValueToNumber(context, js_length, 0);
+ return (unsigned int) length;
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIME
+JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) {
+ JSObjectRef arr;
+ unsigned int length;
+
+ if (JSValueIsUndefined(context, value)) {
+ arr = JSObjectMakeArray(context, 0, 0, 0);
+ } else {
+ arr = JSValueToObject(context, value, 0);
+ }
+
+ length = SWIGJSC_ArrayLength(context, arr);
+ JSObjectSetPropertyAtIndex(context, arr, length, obj, 0);
+}
diff --git a/Lib/javascript/jsc/javascriptruntime.swg b/Lib/javascript/jsc/javascriptruntime.swg
new file mode 100644
index 000000000..8f8390890
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptruntime.swg
@@ -0,0 +1,19 @@
+/* -----------------------------------------------------------------------------
+ * javascriptruntime.swg
+ *
+ * Javascript support code
+ * ----------------------------------------------------------------------------- */
+
+%insert(runtime) %{
+#include
+#include
+#include
+#include
+#include
+#include
+%}
+
+%insert(runtime) "swigrun.swg"; /* SWIG API */
+%insert(runtime) "swigerrors.swg"; /* SWIG errors */
+
+%insert(runtime) "javascriptrun.swg"; /* SWIG errors */
diff --git a/Lib/javascript/jsc/javascriptstrings.swg b/Lib/javascript/jsc/javascriptstrings.swg
new file mode 100644
index 000000000..0581c1920
--- /dev/null
+++ b/Lib/javascript/jsc/javascriptstrings.swg
@@ -0,0 +1,184 @@
+/* ------------------------------------------------------------
+ * utility methods for char strings
+ * ------------------------------------------------------------ */
+%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
+SWIGINTERN int
+SWIG_JSC_AsCharPtrAndSize(JSContextRef context, JSValueRef valRef, char** cptr, size_t* psize, int *alloc)
+{
+ if(JSValueIsString(context, valRef)) {
+ JSStringRef js_str = JSValueToStringCopy(context, valRef, NULL);
+ size_t len = JSStringGetMaximumUTF8CStringSize(js_str);
+ char* cstr = (char*) malloc(len * sizeof(char));
+ /* JSStringGetUTF8CString returns the length including 0-terminator */
+ len = JSStringGetUTF8CString(js_str, cstr, len);
+
+ if(alloc) *alloc = SWIG_NEWOBJ;
+ if(psize) *psize = len;
+ if(cptr) *cptr = cstr;
+
+ return SWIG_OK;
+ } else {
+ if(JSValueIsObject(context, valRef)) {
+ JSObjectRef obj = JSValueToObject(context, valRef, NULL);
+ // try if the object is a wrapped char[]
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ if (pchar_descriptor) {
+ void* vptr = 0;
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
+ if (cptr) *cptr = (char *) vptr;
+ if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
+ if (alloc) *alloc = SWIG_OLDOBJ;
+ return SWIG_OK;
+ }
+ }
+ return SWIG_TypeError;
+ } else {
+ return SWIG_TypeError;
+ }
+ }
+}
+}
+
+%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
+SWIGINTERNINLINE JSValueRef
+SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t size)
+{
+ if (carray) {
+ if (size > INT_MAX) {
+ // TODO: handle extra long strings
+ //swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ //return pchar_descriptor ?
+ // SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
+ return JSValueMakeUndefined(context);
+ } else {
+ JSStringRef jsstring;
+ if(size < 2) {
+ char c[size+1];
+ int i;
+ for(i=0;i
+
+/* Look for user fragments file. */
+%include
+
+/* Javascript fragments for fundamental types */
+%include
+
+/* Javascript fragments for char* strings */
+%include
+
+/* ------------------------------------------------------------
+ * Unified typemap section
+ * ------------------------------------------------------------ */
+
+#define SWIG_Object JSValueRef
+#define VOID_Object JSValueMakeUndefined(context)
+
+/* append output */
+#define SWIG_AppendOutput(result, obj) SWIGJSC_AppendOutput(context, result, obj)
+
+/* set constant */
+#define SWIG_SetConstant(name, obj)
+
+/* raise */
+#define SWIG_Raise(obj, type, desc) SWIG_Javascript_Raise(context, exception, type)
+
+%insert("runtime") %{
+#define SWIG_JSC_FROM_DECL_ARGS(arg1) (JSContextRef context, arg1)
+#define SWIG_JSC_FROM_CALL_ARGS(arg1) (context, arg1)
+#define SWIG_JSC_AS_DECL_ARGS(arg1, arg2) (JSContextRef context, arg1, arg2)
+#define SWIG_JSC_AS_CALL_ARGS(arg1, arg2) (context, arg1, arg2)
+%}
+
+/* Include the unified typemap library */
+%include
diff --git a/Lib/javascript/jsc/std_common.i b/Lib/javascript/jsc/std_common.i
new file mode 100644
index 000000000..cee11e8ca
--- /dev/null
+++ b/Lib/javascript/jsc/std_common.i
@@ -0,0 +1,5 @@
+%include
+
+%apply size_t { std::size_t };
+%apply const size_t& { const std::size_t& };
+
diff --git a/Lib/javascript/jsc/std_complex.i b/Lib/javascript/jsc/std_complex.i
new file mode 100644
index 000000000..088a4fe7b
--- /dev/null
+++ b/Lib/javascript/jsc/std_complex.i
@@ -0,0 +1,19 @@
+/*
+ * STD C++ complex typemaps
+ */
+
+%include
+
+%{
+#include
+%}
+
+/* defining the complex as/from converters */
+
+%swig_cplxdbl_convn(std::complex, std::complex, std::real, std::imag)
+%swig_cplxflt_convn(std::complex, std::complex, std::real, std::imag)
+
+/* defining the typemaps */
+
+%typemaps_primitive(%checkcode(CPLXDBL), std::complex);
+%typemaps_primitive(%checkcode(CPLXFLT), std::complex);
diff --git a/Lib/javascript/jsc/std_deque.i b/Lib/javascript/jsc/std_deque.i
new file mode 100644
index 000000000..cb98f6c2f
--- /dev/null
+++ b/Lib/javascript/jsc/std_deque.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/javascript/jsc/std_except.i b/Lib/javascript/jsc/std_except.i
new file mode 100644
index 000000000..af98428f6
--- /dev/null
+++ b/Lib/javascript/jsc/std_except.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/javascript/jsc/std_map.i b/Lib/javascript/jsc/std_map.i
new file mode 100644
index 000000000..e7812f38a
--- /dev/null
+++ b/Lib/javascript/jsc/std_map.i
@@ -0,0 +1,74 @@
+/* -----------------------------------------------------------------------------
+ * std_map.i
+ *
+ * SWIG typemaps for std::map
+ * ----------------------------------------------------------------------------- */
+
+%include
+
+// ------------------------------------------------------------------------
+// std::map
+// ------------------------------------------------------------------------
+
+%{
+#include
+#include
+#include
+%}
+
+// exported class
+
+namespace std {
+
+ template class map {
+ // add typemaps here
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef K key_type;
+ typedef T mapped_type;
+ map();
+ map(const map &);
+
+ unsigned int size() const;
+ bool empty() const;
+ void clear();
+ %extend {
+ const T& get(const K& key) throw (std::out_of_range) {
+ std::map::iterator i = self->find(key);
+ if (i != self->end())
+ return i->second;
+ else
+ throw std::out_of_range("key not found");
+ }
+ void set(const K& key, const T& x) {
+ (*self)[key] = x;
+ }
+ void del(const K& key) throw (std::out_of_range) {
+ std::map::iterator i = self->find(key);
+ if (i != self->end())
+ self->erase(i);
+ else
+ throw std::out_of_range("key not found");
+ }
+ bool has_key(const K& key) {
+ std::map::iterator i = self->find(key);
+ return i != self->end();
+ }
+ }
+ };
+
+// Legacy macros (deprecated)
+%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
+#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
+%enddef
+
+%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
+#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
+%enddef
+
+%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
+#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
+%enddef
+
+}
diff --git a/Lib/javascript/jsc/std_pair.i b/Lib/javascript/jsc/std_pair.i
new file mode 100644
index 000000000..fe45ee676
--- /dev/null
+++ b/Lib/javascript/jsc/std_pair.i
@@ -0,0 +1,34 @@
+/* -----------------------------------------------------------------------------
+ * std_pair.i
+ *
+ * SWIG typemaps for std::pair
+ * ----------------------------------------------------------------------------- */
+
+%include
+%include
+
+// ------------------------------------------------------------------------
+// std::pair
+// ------------------------------------------------------------------------
+
+%{
+#include
+%}
+
+namespace std {
+
+ template struct pair {
+
+ pair();
+ pair(T first, U second);
+ pair(const pair& p);
+
+ template pair(const pair &p);
+
+ T first;
+ U second;
+ };
+
+ // add specializations here
+
+}
diff --git a/Lib/javascript/jsc/std_string.i b/Lib/javascript/jsc/std_string.i
new file mode 100644
index 000000000..fb1bd62b5
--- /dev/null
+++ b/Lib/javascript/jsc/std_string.i
@@ -0,0 +1,69 @@
+/* -----------------------------------------------------------------------------
+ * std_string.i
+ *
+ * Typemaps for const std::string&.
+ * To use non-const std::string references use the following %apply:
+ * %apply const std::string & {std::string &};
+ *
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include
+
+std::string SWIGJSC_valueToString(JSContextRef context, JSValueRef value) {
+ JSStringRef jsstring = JSValueToStringCopy(context, value, /* JSValueRef *exception */ 0);
+ unsigned int length = JSStringGetLength(jsstring);
+ char *cstr = new char[length + 1];
+ JSStringGetUTF8CString(jsstring, cstr, length + 1);
+
+ // create a copy
+ std::string result(cstr);
+
+ JSStringRelease(jsstring);
+ delete[] cstr;
+
+ return result;
+}
+
+JSValueRef SWIGJSC_stringToValue(JSContextRef context, const std::string& s)
+{
+ JSValueRef result;
+ JSStringRef jsstring = JSStringCreateWithUTF8CString(s.c_str());
+ result = JSValueMakeString(context, jsstring);
+ JSStringRelease(jsstring);
+ return result;
+}
+%}
+
+namespace std {
+ %naturalvar string;
+
+ class string;
+
+
+ %typemap(in) string
+ %{
+ $1 = SWIGJSC_valueToString(context, $input);
+ %}
+
+ %typemap(in) const string &
+ %{
+ $1 = new std::string(SWIGJSC_valueToString(context, $input));
+ %}
+
+ %typemap(freearg) const string &
+ %{
+ delete $1;
+ %}
+
+ %typemap(out) string
+ %{
+ $result = SWIGJSC_stringToValue(context, $1);
+ %}
+
+ %typemap(out) const string &
+ %{
+ $result = SWIGJSC_stringToValue(context, *$1);
+ %}
+
+}
diff --git a/Lib/javascript/jsc/std_vector.i b/Lib/javascript/jsc/std_vector.i
new file mode 100644
index 000000000..3f29b19c7
--- /dev/null
+++ b/Lib/javascript/jsc/std_vector.i
@@ -0,0 +1,85 @@
+/* -----------------------------------------------------------------------------
+ * std_vector.i
+ * ----------------------------------------------------------------------------- */
+
+%include
+
+%{
+#include
+#include
+%}
+
+namespace std {
+
+ template class vector {
+ public:
+ typedef size_t size_type;
+ typedef T value_type;
+ typedef const value_type& const_reference;
+ vector();
+ vector(size_type n);
+ size_type size() const;
+ size_type capacity() const;
+ void reserve(size_type n);
+ %rename(isEmpty) empty;
+ bool empty() const;
+ void clear();
+ %rename(add) push_back;
+ void push_back(const value_type& x);
+ %extend {
+ const_reference get(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i>=0 && isize());
+ if (i>=0 && i class vector {
+ public:
+ typedef size_t size_type;
+ typedef bool value_type;
+ typedef bool const_reference;
+ vector();
+ vector(size_type n);
+ size_type size() const;
+ size_type capacity() const;
+ void reserve(size_type n);
+ %rename(isEmpty) empty;
+ bool empty() const;
+ void clear();
+ %rename(add) push_back;
+ void push_back(const value_type& x);
+ %extend {
+ const_reference get(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i>=0 && isize());
+ if (i>=0 && i
+%include
+%include
+%include
+%include
+
diff --git a/Lib/javascript/jsc/typemaps.i b/Lib/javascript/jsc/typemaps.i
new file mode 100644
index 000000000..d3d8afb19
--- /dev/null
+++ b/Lib/javascript/jsc/typemaps.i
@@ -0,0 +1,148 @@
+/* -----------------------------------------------------------------------------
+ * typemaps.i
+ *
+ * Pointer handling
+ * These mappings provide support for input/output arguments and common
+ * uses for C/C++ pointers.
+ * ----------------------------------------------------------------------------- */
+
+// INPUT typemaps.
+// These remap a C pointer to be an "INPUT" value which is passed by value
+// instead of reference.
+
+/*
+The following methods can be applied to turn a pointer into a simple
+"input" value. That is, instead of passing a pointer to an object,
+you would use a real value instead.
+
+ int *INPUT
+ short *INPUT
+ long *INPUT
+ long long *INPUT
+ unsigned int *INPUT
+ unsigned short *INPUT
+ unsigned long *INPUT
+ unsigned long long *INPUT
+ unsigned char *INPUT
+ bool *INPUT
+ float *INPUT
+ double *INPUT
+
+To use these, suppose you had a C function like this :
+
+ double fadd(double *a, double *b) {
+ return *a+*b;
+ }
+
+You could wrap it with SWIG as follows :
+
+ %include
+ double fadd(double *INPUT, double *INPUT);
+
+or you can use the %apply directive :
+
+ %include
+ %apply double *INPUT { double *a, double *b };
+ double fadd(double *a, double *b);
+
+*/
+
+// OUTPUT typemaps. These typemaps are used for parameters that
+// are output only. The output value is appended to the result as
+// a list element.
+
+/*
+The following methods can be applied to turn a pointer into an "output"
+value. When calling a function, no input value would be given for
+a parameter, but an output value would be returned. In the case of
+multiple output values, they are returned in the form of a Python tuple.
+
+ int *OUTPUT
+ short *OUTPUT
+ long *OUTPUT
+ long long *OUTPUT
+ unsigned int *OUTPUT
+ unsigned short *OUTPUT
+ unsigned long *OUTPUT
+ unsigned long long *OUTPUT
+ unsigned char *OUTPUT
+ bool *OUTPUT
+ float *OUTPUT
+ double *OUTPUT
+
+For example, suppose you were trying to wrap the modf() function in the
+C math library which splits x into integral and fractional parts (and
+returns the integer part in one of its parameters).K:
+
+ double modf(double x, double *ip);
+
+You could wrap it with SWIG as follows :
+
+ %include
+ double modf(double x, double *OUTPUT);
+
+or you can use the %apply directive :
+
+ %include
+ %apply double *OUTPUT { double *ip };
+ double modf(double x, double *ip);
+
+The Python output of the function would be a tuple containing both
+output values.
+
+*/
+
+// INOUT
+// Mappings for an argument that is both an input and output
+// parameter
+
+/*
+The following methods can be applied to make a function parameter both
+an input and output value. This combines the behavior of both the
+"INPUT" and "OUTPUT" methods described earlier. Output values are
+returned in the form of a Python tuple.
+
+ int *INOUT
+ short *INOUT
+ long *INOUT
+ long long *INOUT
+ unsigned int *INOUT
+ unsigned short *INOUT
+ unsigned long *INOUT
+ unsigned long long *INOUT
+ unsigned char *INOUT
+ bool *INOUT
+ float *INOUT
+ double *INOUT
+
+For example, suppose you were trying to wrap the following function :
+
+ void neg(double *x) {
+ *x = -(*x);
+ }
+
+You could wrap it with SWIG as follows :
+
+ %include
+ void neg(double *INOUT);
+
+or you can use the %apply directive :
+
+ %include
+ %apply double *INOUT { double *x };
+ void neg(double *x);
+
+Unlike C, this mapping does not directly modify the input value (since
+this makes no sense in Python). Rather, the modified input value shows
+up as the return value of the function. Thus, to apply this function
+to a Python variable you might do this :
+
+ x = neg(x)
+
+Note : previous versions of SWIG used the symbol 'BOTH' to mark
+input/output arguments. This is still supported, but will be slowly
+phased out in future releases.
+
+*/
+
+%include
diff --git a/Lib/javascript/v8/arrays_javascript.i b/Lib/javascript/v8/arrays_javascript.i
new file mode 100644
index 000000000..22b50be8f
--- /dev/null
+++ b/Lib/javascript/v8/arrays_javascript.i
@@ -0,0 +1,125 @@
+/* -----------------------------------------------------------------------------
+ * arrays_javascript.i
+ *
+ * These typemaps give more natural support for arrays. The typemaps are not efficient
+ * as there is a lot of copying of the array values whenever the array is passed to C/C++
+ * from JavaScript and vice versa. The JavaScript array is expected to be the same size as the C array.
+ * An exception is thrown if they are not.
+ *
+ * Example usage:
+ * Wrapping:
+ *
+ * %include
+ * %inline %{
+ * extern int FiddleSticks[3];
+ * %}
+ *
+ * Use from JavaScript like this:
+ *
+ * var fs = [10, 11, 12];
+ * example.FiddleSticks = fs;
+ * fs = example.FiddleSticks;
+ * ----------------------------------------------------------------------------- */
+
+%fragment("SWIG_JSCGetIntProperty", "header", fragment=SWIG_AsVal_frag(int)) {}
+%fragment("SWIG_JSCGetNumberProperty", "header", fragment=SWIG_AsVal_frag(double)) {}
+
+%typemap(in, fragment="SWIG_JSCGetIntProperty") int[], int[ANY]
+ (int length = 0, v8::Local array, v8::Local jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
+ if ($input->IsArray())
+ {
+ // Convert into Array
+ array = v8::Local::Cast($input);
+
+ length = $1_dim0;
+
+ $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
+
+ // Get each element from array
+ for (i = 0; i < length; i++)
+ {
+ jsvalue = array->Get(i);
+
+ // Get primitive value from JSObject
+ res = SWIG_AsVal(int)(jsvalue, &temp);
+ if (!SWIG_IsOK(res))
+ {
+ SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
+ }
+ arg$argnum[i] = temp;
+ }
+
+ }
+ else
+ {
+ SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef");
+ }
+}
+
+%typemap(freearg) int[], int[ANY] {
+ free($1);
+}
+
+%typemap(out, fragment=SWIG_From_frag(int)) int[], int[ANY] (int length = 0, int i = 0)
+{
+ length = $1_dim0;
+ v8::Local array = v8::Array::New(length);
+
+ for (i = 0; i < length; i++)
+ {
+ array->Set(i, SWIG_From(int)($1[i]));
+ }
+
+
+ $result = array;
+}
+
+%typemap(in, fragment="SWIG_JSCGetNumberProperty") double[], double[ANY]
+ (int length = 0, v8::Local array, v8::Local jsvalue, int i = 0, int res = 0, $*1_ltype temp) {
+ if ($input->IsArray())
+ {
+ // Convert into Array
+ array = v8::Local::Cast($input);
+
+ length = $1_dim0;
+
+ $1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
+
+ // Get each element from array
+ for (i = 0; i < length; i++)
+ {
+ jsvalue = array->Get(i);
+
+ // Get primitive value from JSObject
+ res = SWIG_AsVal(double)(jsvalue, &temp);
+ if (!SWIG_IsOK(res))
+ {
+ SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
+ }
+ arg$argnum[i] = temp;
+ }
+
+ }
+ else
+ {
+ SWIG_exception_fail(SWIG_ERROR, "$input is not JSObjectRef");
+ }
+}
+
+%typemap(freearg) double[], double[ANY] {
+ free($1);
+}
+
+%typemap(out, fragment=SWIG_From_frag(double)) double[], double[ANY] (int length = 0, int i = 0)
+{
+ length = $1_dim0;
+ v8::Local array = v8::Array::New(length);
+
+ for (i = 0; i < length; i++)
+ {
+ array->Set(i, SWIG_From(double)($1[i]));
+ }
+
+
+ $result = array;
+}
diff --git a/Lib/javascript/v8/ccomplex.i b/Lib/javascript/v8/ccomplex.i
new file mode 100644
index 000000000..8eda920bb
--- /dev/null
+++ b/Lib/javascript/v8/ccomplex.i
@@ -0,0 +1,26 @@
+/* -----------------------------------------------------------------------------
+ * ccomplex.i
+ *
+ * C complex typemaps
+ * ISO C99: 7.3 Complex arithmetic
+ * ----------------------------------------------------------------------------- */
+
+
+%include
+
+%{
+#include
+%}
+
+
+/* C complex constructor */
+#define CCplxConst(r, i) ((r) + I*(i))
+
+%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
+%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
+%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
+
+/* declaring the typemaps */
+%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
+%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
diff --git a/Lib/javascript/v8/cdata.i b/Lib/javascript/v8/cdata.i
new file mode 100644
index 000000000..367965990
--- /dev/null
+++ b/Lib/javascript/v8/cdata.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/javascript/v8/complex.i b/Lib/javascript/v8/complex.i
new file mode 100644
index 000000000..4c3b3c5e2
--- /dev/null
+++ b/Lib/javascript/v8/complex.i
@@ -0,0 +1,6 @@
+#ifdef __cplusplus
+%include
+#else
+%include
+#endif
+
diff --git a/Lib/javascript/v8/exception.i b/Lib/javascript/v8/exception.i
new file mode 100644
index 000000000..0246cfde8
--- /dev/null
+++ b/Lib/javascript/v8/exception.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/javascript/v8/javascript.swg b/Lib/javascript/v8/javascript.swg
new file mode 100644
index 000000000..3a83b6495
--- /dev/null
+++ b/Lib/javascript/v8/javascript.swg
@@ -0,0 +1,19 @@
+/* -----------------------------------------------------------------------------
+ * javascript.swg
+ *
+ * Javascript typemaps
+ * ----------------------------------------------------------------------------- */
+
+%include
+
+%include
+
+%include
+
+%include
+
+%include
+
+%include
+
+%include
diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg
new file mode 100644
index 000000000..67a81146e
--- /dev/null
+++ b/Lib/javascript/v8/javascriptcode.swg
@@ -0,0 +1,468 @@
+/* -----------------------------------------------------------------------------
+ * js_ctor: template for wrapping a ctor.
+ * - $jswrapper: wrapper of called ctor
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * - $jsargcount: number of arguments
+ * - $jsmangledtype: mangled type of class
+ * ----------------------------------------------------------------------------- */
+
+%fragment("js_ctor", "templates") %{
+SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
+ v8::HandleScope scope;
+ v8::Handle self = args.Holder();
+ $jslocals
+ if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
+ $jscode
+
+ SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
+ SWIGV8_RETURN(self);
+
+ goto fail;
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_veto_ctor: a vetoing ctor for abstract classes
+ * - $jswrapper: name of wrapper
+ * - $jsname: class name
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_veto_ctor", "templates")
+%{
+SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
+ v8::HandleScope scope;
+ SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
+ SWIGV8_RETURN(v8::Undefined());
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_ctor_dispatcher: dispatcher for overloaded constructors
+ * - $jswrapper: name of wrapper
+ * - $jsname: class name
+ * - $jsdispatchcases: part containing code for dispatching
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_ctor_dispatcher", "templates")
+%{
+SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
+ v8::HandleScope scope;
+ OverloadErrorHandler errorHandler;
+ v8::Handle self;
+
+ // switch all cases by means of series of if-returns.
+ $jsdispatchcases
+
+ // default:
+ SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsmangledname");
+
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_overloaded_ctor: template for wrapping a ctor.
+ * - $jswrapper: wrapper of called ctor
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * - $jsargcount: number of arguments
+ * - $jsmangledtype: mangled type of class
+ * ----------------------------------------------------------------------------- */
+%fragment("js_overloaded_ctor", "templates") %{
+SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler) {
+ v8::HandleScope scope;
+ v8::Handle self = args.Holder();
+ $jslocals
+ if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
+ $jscode
+
+ SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
+ SWIGV8_RETURN(self);
+
+ goto fail;
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_ctor_dispatch_case: template for a dispatch case for calling an overloaded ctor.
+ * - $jsargcount: number of arguments of called ctor
+ * - $jswrapper: wrapper of called ctor
+ *
+ * Note: a try-catch-like mechanism is used to switch cases
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_ctor_dispatch_case", "templates")
+%{
+ if(args.Length() == $jsargcount) {
+ errorHandler.err.Clear();
+#if SWIG_V8_VERSION < 0x031900
+ self = $jswrapper(args, errorHandler);
+ if(errorHandler.err.IsEmpty()) {
+ return scope.Close(self);
+ }
+#else
+ $jswrapper(args, errorHandler);
+ if(errorHandler.err.IsEmpty()) {
+ return;
+ }
+#endif
+ }
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_dtor: template for a destructor wrapper
+ * - $jsmangledname: mangled class name
+ * - $jstype: class type
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_dtor", "templates")
+%{
+
+#if (SWIG_V8_VERSION < 0x031900)
+void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
+{
+ SWIGV8_Proxy *proxy = static_cast(parameter);
+#else
+void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
+{
+#endif
+
+ if(proxy->swigCMemOwn && proxy->swigCObject) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("Deleting wrapped instance: %s\n", proxy->info->name);
+#endif
+ $jsfree proxy->swigCObject;
+ }
+ delete proxy;
+
+ object.Clear();
+#if (SWIG_V8_VERSION < 0x031900)
+ object.Dispose();
+#elif (SWIG_V8_VERSION < 0x032100)
+ object->Dispose(isolate);
+#else
+ object->Dispose();
+#endif
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_dtoroverride: template for a destructor wrapper
+ * - $jsmangledname: mangled class name
+ * - $jstype: class type
+ * - ${destructor_action}: The custom destructor action to invoke.
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_dtoroverride", "templates")
+%{
+#if (SWIG_V8_VERSION < 0x031900)
+void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
+{
+ SWIGV8_Proxy *proxy = static_cast(parameter);
+#else
+void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
+{
+#endif
+ if(proxy->swigCMemOwn && proxy->swigCObject) {
+ $jstype arg1 = ($jstype)proxy->swigCObject;
+ ${destructor_action}
+ }
+ delete proxy;
+
+#if (SWIG_V8_VERSION < 0x031900)
+ object.Dispose();
+#elif (SWIG_V8_VERSION < 0x032100)
+ object->Dispose(isolate);
+#else
+ object->Dispose();
+#endif
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_getter: template for getter function wrappers
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment("js_getter", "templates")
+%{
+SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8PropertyCallbackInfo& info) {
+ v8::HandleScope scope;
+ v8::Handle jsresult;
+ $jslocals
+ $jscode
+ SWIGV8_RETURN_INFO(jsresult, info);
+
+ goto fail;
+fail:
+ SWIGV8_RETURN_INFO(v8::Undefined(), info);
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_setter: template for setter function wrappers
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment("js_setter", "templates")
+%{
+void $jswrapper(v8::Local property, v8::Local value,
+ const SwigV8PropertyCallbackInfoVoid& info) {
+ v8::HandleScope scope;
+ $jslocals
+ $jscode
+ goto fail;
+fail:
+ return;
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_function: template for function wrappers
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment("js_function", "templates")
+%{
+SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
+ v8::HandleScope scope;
+ v8::Handle jsresult;
+ $jslocals
+ if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
+
+ $jscode
+ SWIGV8_RETURN(jsresult);
+
+ goto fail;
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_function_dispatcher: template for a function dispatcher for overloaded functions
+ * - $jswrapper: wrapper function name
+ * - $jsname: name of the wrapped function
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment("js_function_dispatcher", "templates")
+%{
+SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
+ v8::HandleScope scope;
+ v8::Handle jsresult;
+ OverloadErrorHandler errorHandler;
+ $jscode
+
+ SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname.");
+
+ goto fail;
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_overloaded_function: template for a overloaded function
+ * - $jswrapper: wrapper function name
+ * - $jslocals: locals part of wrapper
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_overloaded_function", "templates")
+%{
+SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler)
+{
+ v8::HandleScope scope;
+ v8::Handle jsresult;
+ $jslocals
+ $jscode
+ SWIGV8_RETURN(jsresult);
+
+ goto fail;
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+%}
+
+/* -----------------------------------------------------------------------------
+ * js_function_dispatch_case: template for a case used in the function dispatcher
+ * - $jswrapper: wrapper function name
+ * - $jsargcount: number of arguments of overloaded function
+ * - $jscode: code part of wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment ("js_function_dispatch_case", "templates")
+%{
+
+ if(args.Length() == $jsargcount) {
+ errorHandler.err.Clear();
+#if (SWIG_V8_VERSION < 0x031900)
+ jsresult = $jswrapper(args, errorHandler);
+ if(errorHandler.err.IsEmpty()) {
+ return scope.Close(jsresult);
+ }
+#else
+ $jswrapper(args, errorHandler);
+ if(errorHandler.err.IsEmpty()) {
+ return;
+ }
+#endif
+ }
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_declare_class_template: template for a class template declaration.
+ * - $jsmangledname: mangled class name
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_declare_class_template", "templates")
+%{
+ SWIGV8_ClientData $jsmangledname_clientData;
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_define_class_template: template for a class template definition.
+ * - $jsmangledname: mangled class name
+ * - $jsmangledtype: mangled class type
+ * - $jsdtor: the dtor wrapper
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_define_class_template", "templates")
+%{
+ v8::Handle $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
+#if (SWIG_V8_VERSION < 0x031900)
+ $jsmangledname_clientData.class_templ = v8::Persistent::New($jsmangledname_class);
+#else
+ $jsmangledname_clientData.class_templ.Reset(v8::Isolate::GetCurrent(), $jsmangledname_class);
+#endif
+ $jsmangledname_clientData.dtor = $jsdtor;
+ if (SWIGTYPE_$jsmangledtype->clientdata == 0) {
+ SWIGTYPE_$jsmangledtype->clientdata = &$jsmangledname_clientData;
+ }
+%}
+
+
+/* -----------------------------------------------------------------------------
+ * jsv8_inherit: template for an class inherit statement.
+ * - $jsmangledname: mangled class name
+ * - $jsbaseclass: mangled name of the base class
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_inherit", "templates")
+%{
+ if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
+ {
+#if (SWIG_V8_VERSION < 0x031900)
+ $jsmangledname_class->Inherit(static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
+#else
+ $jsmangledname_class->Inherit(
+ v8::Handle::New(
+ v8::Isolate::GetCurrent(),
+ static_cast(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ)
+ );
+#endif
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("Inheritance successful $jsmangledname $jsbaseclass\n");
+#endif
+ } else {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("Unable to inherit baseclass, it didn't exist $jsmangledname $jsbaseclass\n");
+#endif
+ }
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_create_class_instance: template for creating an class object.
+ * - $jsname: class name
+ * - $jsmangledname: mangled class name
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_create_class_instance", "templates")
+%{
+ v8::Handle $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
+ $jsmangledname_class_0->SetCallHandler($jsctor);
+ $jsmangledname_class_0->Inherit($jsmangledname_class);
+ $jsmangledname_class_0->SetHiddenPrototype(true);
+ v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_register_class: template for a statement that registers a class in a parent namespace.
+ * - $jsname: class name
+ * - $jsmangledname: mangled class name
+ * - $jsparent: mangled name of parent namespace
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_register_class", "templates")
+%{
+ $jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_create_namespace: template for a statement that creates a namespace object.
+ * - $jsmangledname: mangled namespace name
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_create_namespace", "templates")
+%{
+ v8::Handle $jsmangledname_obj = v8::Object::New();
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_register_namespace: template for a statement that registers a namespace in a parent namespace.
+ * - $jsname: name of namespace
+ * - $jsmangledname: mangled name of namespace
+ * - $jsparent: mangled name of parent namespace
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_register_namespace", "templates")
+%{
+ $jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_register_member_function: template for a statement that registers a member function.
+ * - $jsmangledname: mangled class name
+ * - $jsname: name of the function
+ * - $jswrapper: wrapper of the member function
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_register_member_function", "templates")
+%{
+ SWIGV8_AddMemberFunction($jsmangledname_class, "$jsname", $jswrapper);
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_register_member_variable: template for a statement that registers a member variable.
+ * - $jsmangledname: mangled class name
+ * - $jsname: name of the function
+ * - $jsgetter: wrapper of the getter function
+ * - $jssetter: wrapper of the setter function
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_register_member_variable", "templates")
+%{
+ SWIGV8_AddMemberVariable($jsmangledname_class, "$jsname", $jsgetter, $jssetter);
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_register_static_function: template for a statement that registers a static class function.
+ * - $jsname: function name
+ * - $jswrapper: wrapper of the function
+ * - $jsparent: mangled name of parent namespace
+ *
+ * Note: this template is also used for global functions.
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_register_static_function", "templates")
+%{
+ SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper);
+%}
+
+/* -----------------------------------------------------------------------------
+ * jsv8_register_static_variable: template for a statement that registers a static variable.
+ * - $jsname: variable name
+ * - $jsparent: mangled name of parent namespace
+ * - $jsgetter: wrapper of the getter function
+ * - $jssetter: wrapper of the setter function
+ *
+ * Note: this template is also used for global variables.
+ * ----------------------------------------------------------------------------- */
+%fragment("jsv8_register_static_variable", "templates")
+%{
+ SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter);
+%}
diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg
new file mode 100644
index 000000000..70c5baffb
--- /dev/null
+++ b/Lib/javascript/v8/javascriptcomplex.swg
@@ -0,0 +1,123 @@
+/*
+ Defines the As/From converters for double/float complex, you need to
+ provide complex Type, the Name you want to use in the converters,
+ the complex Constructor method, and the Real and Imag complex
+ accessor methods.
+
+ See the std_complex.i and ccomplex.i for concret examples.
+*/
+
+/* the common from converter */
+%define %swig_fromcplx_conv(Type, Real, Imag)
+%fragment(SWIG_From_frag(Type),"header",
+ fragment=SWIG_From_frag(double))
+{
+SWIGINTERNINLINE v8::Handle
+SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
+{
+ v8::HandleScope scope;
+ v8::Local vals = v8::Array::New(2);
+
+ vals->Set(0, SWIG_From(double)(Real(c)));
+ vals->Set(1, SWIG_From(double)(Imag(c)));
+ return scope.Close(vals);
+}
+}
+%enddef
+
+/* the double case */
+%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(double))
+{
+SWIGINTERN int
+SWIG_AsVal_dec(Type) (v8::Handle o, Type* val)
+{
+ v8::HandleScope scope;
+
+ if (o->IsArray()) {
+ v8::Handle array = v8::Handle::Cast(o);
+
+ if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
+ double re, im;
+ int res;
+
+ res = SWIG_AsVal(double)(array->Get(0), &re);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ res = SWIG_AsVal(double)(array->Get(1), &im);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ if (val) *val = Constructor(re, im);
+ return SWIG_OK;
+ } else if(o->IsNumber()){
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
+ if (SWIG_IsOK(res)) {
+ if (val) *val = Constructor(d, 0.0);
+ return res;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+%swig_fromcplx_conv(Type, Real, Imag);
+%enddef
+
+/* the float case */
+%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
+%fragment(SWIG_AsVal_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(float)) {
+SWIGINTERN int
+SWIG_AsVal_dec(Type) (v8::Handle o, Type* val)
+{
+ v8::HandleScope scope;
+
+ if (o->IsArray()) {
+ v8::Handle array = v8::Handle::Cast(o);
+
+ if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
+ double re, im;
+ int res;
+
+ res = SWIG_AsVal(double)(array->Get(0), &re);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ res = SWIG_AsVal(double)(array->Get(1), &im);
+ if(!SWIG_IsOK(res)) {
+ return SWIG_TypeError;
+ }
+
+ if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
+ if (val) *val = Constructor(%numeric_cast(re, float),
+ %numeric_cast(im, float));
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else if(o->IsNumber()){
+ float re;
+ int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
+ if (SWIG_IsOK(res)) {
+ if (val) *val = Constructor(re, 0.0);
+ return res;
+ }
+ }
+ return SWIG_TypeError;
+}
+}
+%swig_fromcplx_conv(Type, Real, Imag);
+%enddef
+
+#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
+%swig_cplxflt_conv(Type, Constructor, Real, Imag)
+
+
+#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
+%swig_cplxdbl_conv(Type, Constructor, Real, Imag)
diff --git a/Lib/javascript/v8/javascriptfragments.swg b/Lib/javascript/v8/javascriptfragments.swg
new file mode 100644
index 000000000..4778bf033
--- /dev/null
+++ b/Lib/javascript/v8/javascriptfragments.swg
@@ -0,0 +1,23 @@
+/*
+
+ Create a file with this name, 'javascriptfragments.swg', in your working
+ directory and add all the %fragments you want to take precedence
+ over the default ones defined by swig.
+
+ For example, if you add:
+
+ %fragment(SWIG_AsVal_frag(int),"header") {
+ SWIGINTERNINLINE int
+ SWIG_AsVal(int)(PyObject *obj, int *val)
+ {
+ ;
+ }
+ }
+
+ this will replace the code used to retrieve an integer value for all
+ the typemaps that need it, including:
+
+ int, std::vector, std::list >, etc.
+
+
+*/
diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg
new file mode 100644
index 000000000..8da6627e2
--- /dev/null
+++ b/Lib/javascript/v8/javascripthelpers.swg
@@ -0,0 +1,87 @@
+%insert(runtime) %{
+
+// Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed
+#if SWIG_V8_VERSION < 0x031900
+typedef v8::InvocationCallback SwigV8FunctionCallback;
+typedef v8::AccessorGetter SwigV8AccessorGetterCallback;
+typedef v8::AccessorSetter SwigV8AccessorSetterCallback;
+typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid;
+#else
+typedef v8::FunctionCallback SwigV8FunctionCallback;
+typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback;
+typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback;
+typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfoVoid;
+#endif
+
+/**
+ * Creates a class template for a class with specified initialization function.
+ */
+v8::Handle SWIGV8_CreateClassTemplate(const char* symbol) {
+ v8::HandleScope scope;
+ v8::Local class_templ = v8::FunctionTemplate::New();
+ class_templ->SetClassName(v8::String::NewSymbol(symbol));
+
+ v8::Handle inst_templ = class_templ->InstanceTemplate();
+ inst_templ->SetInternalFieldCount(1);
+
+ v8::Handle equals_templ = class_templ->PrototypeTemplate();
+ equals_templ->Set(v8::String::NewSymbol("equals"), v8::FunctionTemplate::New(_SWIGV8_wrap_equals));
+
+ v8::Handle cptr_templ = class_templ->PrototypeTemplate();
+ cptr_templ->Set(v8::String::NewSymbol("getCPtr"), v8::FunctionTemplate::New(_wrap_getCPtr));
+
+ return scope.Close(class_templ);
+}
+
+/**
+ * Registers a class method with given name for a given class template.
+ */
+void SWIGV8_AddMemberFunction(v8::Handle class_templ, const char* symbol,
+ SwigV8FunctionCallback _func) {
+ v8::Handle proto_templ = class_templ->PrototypeTemplate();
+ proto_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func));
+}
+
+/**
+ * Registers a class property with given name for a given class template.
+ */
+void SWIGV8_AddMemberVariable(v8::Handle class_templ, const char* symbol,
+ SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
+ v8::Handle proto_templ = class_templ->InstanceTemplate();
+ proto_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
+}
+
+/**
+ * Registers a class method with given name for a given object.
+ */
+void SWIGV8_AddStaticFunction(v8::Handle obj, const char* symbol,
+ const SwigV8FunctionCallback& _func) {
+ obj->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction());
+}
+
+/**
+ * Registers a class method with given name for a given object.
+ */
+void SWIGV8_AddStaticVariable(v8::Handle obj, const char* symbol,
+ SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
+ obj->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
+}
+
+void JS_veto_set_variable(v8::Local property, v8::Local value,
+ const SwigV8PropertyCallbackInfoVoid& info)
+{
+ char buffer[256];
+ char msg[512];
+ int res;
+
+ property->WriteUtf8(buffer, 256);
+ res = sprintf(msg, "Tried to write read-only variable: %s.", buffer);
+
+ if(res<0) {
+ SWIG_exception(SWIG_ERROR, "Tried to write read-only variable.");
+ } else {
+ SWIG_exception(SWIG_ERROR, msg);
+ }
+}
+
+%} // v8_helper_functions
diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg
new file mode 100644
index 000000000..de1fe91f4
--- /dev/null
+++ b/Lib/javascript/v8/javascriptinit.swg
@@ -0,0 +1,118 @@
+%insert(init) %{
+
+#include
+
+SWIGRUNTIME void
+SWIG_V8_SetModule(void *, swig_module_info *swig_module) {
+ v8::Local global_obj = v8::Context::GetCurrent()->Global();
+ v8::Local mod = v8::External::New(swig_module);
+ assert(!mod.IsEmpty());
+ global_obj->SetHiddenValue(v8::String::New("swig_module_info_data"), mod);
+}
+
+SWIGRUNTIME swig_module_info *
+SWIG_V8_GetModule(void *) {
+ v8::Local global_obj = v8::Context::GetCurrent()->Global();
+ v8::Local moduleinfo = global_obj->GetHiddenValue(v8::String::New("swig_module_info_data"));
+
+ if (moduleinfo.IsEmpty())
+ {
+ // It's not yet loaded
+ return 0;
+ }
+
+ v8::Local moduleinfo_extern = v8::Local::Cast(moduleinfo);
+
+ if (moduleinfo_extern.IsEmpty())
+ {
+ // Something's not right
+ return 0;
+ }
+
+ void *ptr = moduleinfo_extern->Value();
+ assert(ptr);
+ swig_module_info *retptr = static_cast(ptr);
+ assert(retptr);
+ return retptr;
+}
+
+#define SWIG_GetModule(clientdata) SWIG_V8_GetModule(clientdata)
+#define SWIG_SetModule(clientdata, pointer) SWIG_V8_SetModule(clientdata, pointer)
+
+%}
+
+%insert(init) "swiginit.swg"
+
+// Open the initializer function definition here
+
+%fragment ("js_initializer_define", "templates") %{
+#define SWIGV8_INIT $jsname_initialize
+%}
+
+%insert(init) %{
+// Note: 'extern "C"'' disables name mangling which makes it easier to load the symbol manually
+// TODO: is it ok to do that?
+extern "C"
+#if (NODE_MODULE_VERSION < 0x000C)
+void SWIGV8_INIT (v8::Handle exports)
+#else
+void SWIGV8_INIT (v8::Handle exports, v8::Handle /*module*/)
+#endif
+{
+ SWIG_InitializeModule(static_cast(&exports));
+
+ v8::HandleScope scope;
+ v8::Handle exports_obj = exports;
+%}
+
+
+/* -----------------------------------------------------------------------------
+ * js_initializer: template for the module initializer function
+ * - $jsname: module name
+ * - $jsv8nspaces: part with code creating namespace objects
+ * - $jsv8classtemplates: part with code creating class templates
+ * - $jsv8wrappers: part with code that registers wrapper functions
+ * - $jsv8inheritance: part with inherit statements
+ * - $jsv8classinstances: part with code creating class objects
+ * - $jsv8staticwrappers: part with code adding static functions to class objects
+ * - $jsv8registerclasses: part with code that registers class objects in namespaces
+ * - $jsv8registernspaces: part with code that registers namespaces in parent namespaces
+ * ----------------------------------------------------------------------------- */
+%fragment("js_initializer", "templates")
+%{
+ // a class template for creating proxies of undefined types
+#if (SWIG_V8_VERSION < 0x031900)
+ SWIGV8_SWIGTYPE_Proxy_class_templ = v8::Persistent::New(SWIGV8_CreateClassTemplate("SwigProxy"));
+#else
+ SWIGV8_SWIGTYPE_Proxy_class_templ.Reset(v8::Isolate::GetCurrent(), SWIGV8_CreateClassTemplate("SwigProxy"));
+#endif
+
+ /* create objects for namespaces */
+ $jsv8nspaces
+
+ /* create class templates */
+ $jsv8classtemplates
+
+ /* register wrapper functions */
+ $jsv8wrappers
+
+ /* setup inheritances */
+ $jsv8inheritance
+
+ /* class instances */
+ $jsv8classinstances
+
+ /* add static class functions and variables */
+ $jsv8staticwrappers
+
+ /* register classes */
+ $jsv8registerclasses
+
+ /* create and register namespace objects */
+ $jsv8registernspaces
+}
+
+#if defined(BUILDING_NODE_EXTENSION)
+NODE_MODULE($jsname, $jsname_initialize);
+#endif
+%}
diff --git a/Lib/javascript/v8/javascriptkw.swg b/Lib/javascript/v8/javascriptkw.swg
new file mode 100644
index 000000000..c3c118391
--- /dev/null
+++ b/Lib/javascript/v8/javascriptkw.swg
@@ -0,0 +1,40 @@
+#ifndef JAVASCRIPT_JAVASCRIPTKW_SWG_
+#define JAVASCRIPT_JAVASCRIPTKW_SWG_
+
+/* Warnings for Java keywords */
+#define JAVASCRIPTKW(x) %keywordwarn("'" `x` "' is a javascript keyword, renaming to '_"`x`"'",rename="_%s") `x`
+
+/* Taken from https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Reserved_Words */
+
+JAVASCRIPTKW(break);
+JAVASCRIPTKW(case);
+JAVASCRIPTKW(catch);
+JAVASCRIPTKW(continue);
+JAVASCRIPTKW(default);
+JAVASCRIPTKW(delete);
+JAVASCRIPTKW(do);
+JAVASCRIPTKW(else);
+JAVASCRIPTKW(finally);
+JAVASCRIPTKW(for);
+JAVASCRIPTKW(function);
+JAVASCRIPTKW(if);
+JAVASCRIPTKW(in);
+JAVASCRIPTKW(instanceof);
+JAVASCRIPTKW(new);
+JAVASCRIPTKW(return);
+JAVASCRIPTKW(switch);
+JAVASCRIPTKW(this);
+JAVASCRIPTKW(throw);
+JAVASCRIPTKW(try);
+JAVASCRIPTKW(typeof);
+JAVASCRIPTKW(var);
+JAVASCRIPTKW(void);
+JAVASCRIPTKW(while);
+JAVASCRIPTKW(with);
+
+/* others bad names if any*/
+// for example %namewarn("321:clone() is a javascript bad method name") *::clone();
+
+#undef JAVASCRIPTKW
+
+#endif //JAVASCRIPT_JAVASCRIPTKW_SWG_
diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg
new file mode 100644
index 000000000..706a799b7
--- /dev/null
+++ b/Lib/javascript/v8/javascriptprimtypes.swg
@@ -0,0 +1,198 @@
+/* ------------------------------------------------------------
+ * Primitive Types
+ * ------------------------------------------------------------ */
+
+/* boolean */
+
+%fragment(SWIG_From_frag(bool),"header") {
+SWIGINTERNINLINE
+v8::Handle
+SWIG_From_dec(bool)(bool value)
+{
+ return v8::Boolean::New(value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(bool),"header",
+ fragment=SWIG_AsVal_frag(long)) {
+SWIGINTERN
+int SWIG_AsVal_dec(bool)(v8::Handle obj, bool *val)
+{
+ if(!obj->IsBoolean()) {
+ return SWIG_ERROR;
+ }
+
+ if (val) *val = obj->BooleanValue();
+ return SWIG_OK;
+}
+}
+
+/* int */
+
+%fragment(SWIG_From_frag(int),"header") {
+SWIGINTERNINLINE
+v8::Handle SWIG_From_dec(int)(int value)
+{
+ return v8::Int32::New(value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(int),"header") {
+SWIGINTERN
+int SWIG_AsVal_dec(int)(v8::Handle valRef, int* val)
+{
+ if (!valRef->IsNumber()) {
+ return SWIG_TypeError;
+ }
+ if(val) *val = valRef->IntegerValue();
+
+ return SWIG_OK;
+}
+}
+
+/* long */
+
+%fragment(SWIG_From_frag(long),"header") {
+SWIGINTERNINLINE
+v8::Handle SWIG_From_dec(long)(long value)
+{
+ return v8::Number::New(value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(long),"header",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN
+int SWIG_AsVal_dec(long)(v8::Handle obj, long* val)
+{
+ if (!obj->IsNumber()) {
+ return SWIG_TypeError;
+ }
+ if(val) *val = (long) obj->IntegerValue();
+
+ return SWIG_OK;
+}
+}
+
+/* unsigned long */
+
+%fragment(SWIG_From_frag(unsigned long),"header",
+ fragment=SWIG_From_frag(long)) {
+SWIGINTERNINLINE
+v8::Handle SWIG_From_dec(unsigned long)(unsigned long value)
+{
+ return (value > LONG_MAX) ?
+ v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long));
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long),"header",
+ fragment="SWIG_CanCastAsInteger") {
+SWIGINTERN
+int SWIG_AsVal_dec(unsigned long)(v8::Handle obj, unsigned long *val)
+{
+ if(!obj->IsNumber()) {
+ return SWIG_TypeError;
+ }
+
+ long longVal = (long) obj->NumberValue();
+
+ if(longVal < 0) {
+ return SWIG_OverflowError;
+ }
+
+ if(val) *val = longVal;
+
+ return SWIG_OK;
+}
+}
+
+/* long long */
+// Note: these are copied from 'long' and probably need fixing
+
+%fragment(SWIG_From_frag(long long),"header",
+ fragment=SWIG_From_frag(long),
+ fragment="") {
+SWIGINTERNINLINE
+v8::Handle SWIG_From_dec(long long)(long long value)
+{
+ return v8::Number::New(value);
+}
+}
+
+%fragment(SWIG_AsVal_frag(long long),"header",
+ fragment=SWIG_AsVal_frag(long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="") {
+SWIGINTERN
+int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val)
+{
+ if (!obj->IsNumber()) {
+ return SWIG_TypeError;
+ }
+ if(val) *val = (long long) obj->IntegerValue();
+
+ return SWIG_OK;
+}
+}
+
+/* unsigned long long */
+// Note: these are copied from 'unsigned long' and probably need fixing
+
+%fragment(SWIG_From_frag(unsigned long long),"header",
+ fragment=SWIG_From_frag(long long),
+ fragment="") {
+SWIGINTERNINLINE
+v8::Handle SWIG_From_dec(unsigned long long)(unsigned long long value)
+{
+ return (value > LONG_MAX) ?
+ v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long));
+}
+}
+
+%fragment(SWIG_AsVal_frag(unsigned long long),"header",
+ fragment=SWIG_AsVal_frag(unsigned long),
+ fragment="SWIG_CanCastAsInteger",
+ fragment="") {
+SWIGINTERN
+int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long long *val)
+{
+ if(!obj->IsNumber()) {
+ return SWIG_TypeError;
+ }
+
+ long long longVal = (long long) obj->NumberValue();
+
+ if(longVal < 0) {
+ return SWIG_OverflowError;
+ }
+
+ if(val) *val = longVal;
+
+ return SWIG_OK;
+}
+}
+
+/* double */
+
+%fragment(SWIG_From_frag(double),"header") {
+SWIGINTERN
+v8::Handle SWIG_From_dec(double) (double val)
+{
+ return v8::Number::New(val);
+}
+}
+
+%fragment(SWIG_AsVal_frag(double),"header") {
+SWIGINTERN
+int SWIG_AsVal_dec(double)(v8::Handle obj, double *val)
+{
+ if(!obj->IsNumber()) {
+ return SWIG_TypeError;
+ }
+ if(val) *val = obj->NumberValue();
+
+ return SWIG_OK;
+}
+}
+
diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg
new file mode 100644
index 000000000..2e0a46717
--- /dev/null
+++ b/Lib/javascript/v8/javascriptrun.swg
@@ -0,0 +1,462 @@
+/* ---------------------------------------------------------------------------
+ * Error handling
+ *
+ * ---------------------------------------------------------------------------*/
+
+#define SWIG_Error(code, msg) SWIGV8_ErrorHandler.error(code, msg)
+#define SWIG_exception(code, msg) SWIGV8_ErrorHandler.error(code, msg)
+#define SWIG_fail goto fail
+#define SWIGV8_OVERLOAD false
+
+void SWIG_V8_Raise(const char* msg) {
+ v8::ThrowException(v8::Exception::Error(v8::String::New(msg)));
+}
+
+/*
+ Note: There are two contexts for handling errors.
+ A static V8ErrorHandler is used in not overloaded methods.
+ For overloaded methods the throwing type checking mechanism is used
+ during dispatching. As V8 exceptions can not be resetted properly
+ the trick is to use a dynamic ErrorHandler with same local name as the global
+ one.
+
+ - See defintion of SWIG_Error above.
+ - See code templates 'JS_function_dispatcher', 'JS_functionwrapper_overload',
+ and 'JS_function_dispatch_case' in javascriptcode.swg
+
+*/
+class V8ErrorHandler {
+public:
+ virtual ~V8ErrorHandler() {}
+ virtual void error(int code, const char* msg) {
+ SWIG_V8_Raise(msg);
+ }
+};
+// this is used in usually
+V8ErrorHandler SWIGV8_ErrorHandler;
+
+// instances of this are used in overloaded functions
+class OverloadErrorHandler: public V8ErrorHandler {
+public:
+ virtual void error(int code, const char* msg) {
+ err = v8::Exception::Error(v8::String::New(msg));
+ if(code != SWIG_TypeError) {
+ v8::ThrowException(err);
+ }
+ }
+ v8::Handle err;
+};
+
+// Note: these typedefs and defines are used to deal with v8 API changes since version 3.19.00
+
+#if (SWIG_V8_VERSION < 0x031900)
+typedef v8::Handle SwigV8ReturnValue;
+typedef v8::Arguments SwigV8Arguments;
+typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
+#define SWIGV8_RETURN(val) return scope.Close(val)
+#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
+#else
+typedef void SwigV8ReturnValue;
+typedef v8::FunctionCallbackInfo SwigV8Arguments;
+typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo;
+#define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
+#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
+#endif
+
+
+/* ---------------------------------------------------------------------------
+ * Basic Proxy object
+ *
+ * ---------------------------------------------------------------------------*/
+
+// Note: to trigger the v8 gc more often one can tell v8 about the memory consumption
+// TODO: we could add a v8 specific parameter to control this value
+#define SWIGV8_AVG_OBJ_SIZE 1000
+
+class SWIGV8_Proxy {
+public:
+ SWIGV8_Proxy(): swigCMemOwn(false), swigCObject(0), info(0) {
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(SWIGV8_AVG_OBJ_SIZE);
+ };
+
+ ~SWIGV8_Proxy() {
+#if (SWIG_V8_VERSION < 0x031900 || SWIG_V8_VERSION >= 0x032100)
+ handle.ClearWeak();
+ handle.Dispose();
+#else
+ handle.ClearWeak(v8::Isolate::GetCurrent());
+ handle.Dispose(v8::Isolate::GetCurrent());
+#endif
+
+ handle.Clear();
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(-SWIGV8_AVG_OBJ_SIZE);
+ }
+
+ bool swigCMemOwn;
+ void *swigCObject;
+ swig_type_info *info;
+ v8::Persistent handle;
+};
+
+class SWIGV8_ClientData {
+public:
+ v8::Persistent class_templ;
+
+#if (SWIG_V8_VERSION < 0x031900)
+ void (*dtor) (v8::Persistent< v8::Value> object, void *parameter);
+#else
+ void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy);
+#endif
+};
+
+v8::Persistent SWIGV8_SWIGTYPE_Proxy_class_templ;
+
+int SWIG_V8_ConvertInstancePtr(v8::Handle objRef, void** ptr, swig_type_info *info, int flags) {
+ v8::HandleScope scope;
+
+ if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
+
+#if (SWIG_V8_VERSION < 0x031900)
+ v8::Handle cdataRef = objRef->GetInternalField(0);
+ SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef));
+#else
+ SWIGV8_Proxy *cdata = static_cast(objRef->GetAlignedPointerFromInternalField(0));
+#endif
+
+ if(cdata == NULL) {
+ return SWIG_ERROR;
+ }
+ if(cdata->info != info) {
+ swig_cast_info *tc = SWIG_TypeCheckStruct(cdata->info, info);
+ if (!tc && cdata->info->name) {
+ tc = SWIG_TypeCheck(cdata->info->name, info);
+ }
+ bool type_valid = tc != 0;
+ if(!type_valid) {
+ return SWIG_TypeError;
+ }
+ }
+ *ptr = cdata->swigCObject;
+ if(flags & SWIG_POINTER_DISOWN) {
+ cdata->swigCMemOwn = false;
+ }
+ return SWIG_OK;
+}
+
+#if (SWIG_V8_VERSION < 0x031900)
+void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter)
+#else
+void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy)
+#endif
+{
+#if (SWIG_V8_VERSION < 0x031900)
+ SWIGV8_Proxy *proxy = static_cast(parameter);
+#endif
+
+ delete proxy;
+}
+
+int SWIG_V8_GetInstancePtr(v8::Handle valRef, void** ptr) {
+ if(!valRef->IsObject()) {
+ return SWIG_TypeError;
+ }
+ v8::Handle objRef = valRef->ToObject();
+
+ if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
+
+#if (SWIG_V8_VERSION < 0x031900)
+ v8::Handle cdataRef = objRef->GetInternalField(0);
+ SWIGV8_Proxy *cdata = static_cast(v8::External::Unwrap(cdataRef));
+#else
+ SWIGV8_Proxy *cdata = static_cast(objRef->GetAlignedPointerFromInternalField(0));
+#endif
+
+ if(cdata == NULL) {
+ return SWIG_ERROR;
+ }
+
+ *ptr = cdata->swigCObject;
+
+ return SWIG_OK;
+}
+
+void SWIGV8_SetPrivateData(v8::Handle obj, void* ptr, swig_type_info *info, int flags) {
+ SWIGV8_Proxy* cdata = new SWIGV8_Proxy();
+ cdata->swigCObject = ptr;
+ cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
+ cdata->info = info;
+
+#if (SWIG_V8_VERSION < 0x031900)
+ obj->SetPointerInInternalField(0, cdata);
+ cdata->handle = v8::Persistent::New(obj);
+#else
+ obj->SetAlignedPointerInInternalField(0, cdata);
+ cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
+#endif
+
+#if (SWIG_V8_VERSION < 0x031900)
+ // clientdata must be set for owned data as we need to register the dtor
+ if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
+ cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
+ } else {
+ cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
+ }
+ cdata->handle.MarkIndependent();
+#else
+ if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
+ cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
+ } else {
+ cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor);
+ }
+
+#if (SWIG_V8_VERSION < 0x032100)
+ cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
+#else
+ cdata->handle.MarkIndependent();
+#endif
+
+#endif
+}
+
+int SWIG_V8_ConvertPtr(v8::Handle valRef, void** ptr, swig_type_info *info, int flags) {
+ v8::HandleScope scope;
+
+ if(!valRef->IsObject()) {
+ return SWIG_TypeError;
+ }
+ v8::Handle objRef = valRef->ToObject();
+ return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
+}
+
+v8::Handle SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
+ v8::HandleScope scope;
+ v8::Handle class_templ;
+
+#if (SWIG_V8_VERSION < 0x031900)
+ if(info->clientdata != 0) {
+ class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ;
+ } else {
+ class_templ = SWIGV8_SWIGTYPE_Proxy_class_templ;
+ }
+#else
+ v8::Isolate *iso = v8::Isolate::GetCurrent();
+
+ if(info->clientdata != 0) {
+ class_templ = v8::Handle::New(iso, ((SWIGV8_ClientData*) info->clientdata)->class_templ);
+ } else {
+ class_templ = v8::Handle::New(iso, SWIGV8_SWIGTYPE_Proxy_class_templ);
+ }
+#endif
+
+ v8::Handle result = class_templ->InstanceTemplate()->NewInstance();
+ SWIGV8_SetPrivateData(result, ptr, info, flags);
+
+ return scope.Close(result);
+}
+
+#define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_V8_ConvertPtr(obj, ptr, info, flags)
+#define SWIG_NewPointerObj(ptr, info, flags) SWIG_V8_NewPointerObj(ptr, info, flags)
+
+#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_V8_ConvertInstancePtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_V8_NewPointerObj(thisvalue, type, flags)
+
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_V8_ConvertPtr(obj, pptr, type, 0)
+#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_V8_NewPointerObj(ptr, type, 0)
+
+#define SWIG_GetInstancePtr(obj, ptr) SWIG_V8_GetInstancePtr(obj, ptr)
+
+#if (SWIG_V8_VERSION < 0x031900)
+v8::Handle _SWIGV8_wrap_equals(const v8::Arguments &args) {
+#else
+void _SWIGV8_wrap_equals(const v8::FunctionCallbackInfo& args) {
+#endif
+ v8::HandleScope scope;
+ v8::Handle jsresult;
+ void *arg1 = (void *) 0 ;
+ void *arg2 = (void *) 0 ;
+ bool result;
+ int res1;
+ int res2;
+
+ if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for equals.");
+
+ res1 = SWIG_GetInstancePtr(args.Holder(), &arg1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ERROR, "Could not get pointer from 'this' object for equals.");
+ }
+ res2 = SWIG_GetInstancePtr(args[0], &arg2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "equals" "', argument " "1"" of type '" "void *""'");
+ }
+
+ result = (bool)(arg1 == arg2);
+ jsresult = v8::Boolean::New(result);
+
+ SWIGV8_RETURN(jsresult);
+ goto fail;
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+
+#if (SWIG_V8_VERSION < 0x031900)
+v8::Handle _wrap_getCPtr(const v8::Arguments &args) {
+#else
+void _wrap_getCPtr(const v8::FunctionCallbackInfo& args) {
+#endif
+ v8::HandleScope scope;
+ v8::Handle jsresult;
+ void *arg1 = (void *) 0 ;
+ long result;
+ int res1;
+
+ res1 = SWIG_GetInstancePtr(args.Holder(), &arg1);
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "getCPtr" "', argument " "1"" of type '" "void *""'");
+ }
+
+ result = (long)arg1;
+ jsresult = v8::Number::New(result);
+
+ SWIGV8_RETURN(jsresult);
+ goto fail;
+fail:
+ SWIGV8_RETURN(v8::Undefined());
+}
+
+/* ---------------------------------------------------------------------------
+ * PackedData object
+ *
+ * ---------------------------------------------------------------------------*/
+
+class SwigV8PackedData {
+public:
+ SwigV8PackedData(void *data, size_t size, swig_type_info *type): data(data), size(size), type(type) {};
+
+ ~SwigV8PackedData() {
+ };
+
+ void* data;
+ size_t size;
+ swig_type_info *type;
+
+ v8::Persistent handle;
+};
+
+SWIGRUNTIMEINLINE
+int SwigV8Packed_Check(v8::Handle valRef) {
+ v8::HandleScope scope;
+ v8::Handle objRef = valRef->ToObject();
+ if(objRef->InternalFieldCount() < 1) return false;
+ v8::Handle flag = objRef->GetHiddenValue(v8::String::New("__swig__packed_data__"));
+ return (flag->IsBoolean() && flag->BooleanValue());
+}
+
+SWIGRUNTIME
+swig_type_info* SwigV8Packed_UnpackData(v8::Handle valRef, void *ptr, size_t size) {
+ if (SwigV8Packed_Check(valRef)) {
+ v8::HandleScope scope;
+ SwigV8PackedData *sobj;
+
+ v8::Handle objRef = valRef->ToObject();
+
+#if (SWIG_V8_VERSION < 0x031900)
+ v8::Handle cdataRef = objRef->GetInternalField(0);
+ sobj = static_cast(v8::External::Unwrap(cdataRef));
+#else
+ sobj = static_cast(objRef->GetAlignedPointerFromInternalField(0));
+#endif
+ if (sobj == NULL || sobj->size != size) return 0;
+ memcpy(ptr, sobj->data, size);
+ return sobj->type;
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIME
+int SWIGV8_ConvertPacked(v8::Handle valRef, void *ptr, size_t sz, swig_type_info *ty) {
+ swig_type_info *to = SwigV8Packed_UnpackData(valRef, ptr, sz);
+ if (!to) return SWIG_ERROR;
+ if (ty) {
+ if (to != ty) {
+ /* check type cast? */
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) return SWIG_ERROR;
+ }
+ }
+ return SWIG_OK;
+}
+
+#if (SWIG_V8_VERSION < 0x031900)
+void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter)
+{
+ SwigV8PackedData *cdata = static_cast(parameter);
+#else
+void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SwigV8PackedData *cdata)
+{
+#endif
+
+ delete cdata;
+
+#if (SWIG_V8_VERSION < 0x031900)
+ object.Clear();
+ object.Dispose();
+#elif (SWIG_V8_VERSION < 0x032100)
+ object->Dispose(isolate);
+#else
+ object->Dispose();
+#endif
+}
+
+SWIGRUNTIME
+v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
+ v8::HandleScope scope;
+
+ SwigV8PackedData* cdata = new SwigV8PackedData(data, size, type);
+ v8::Handle obj = v8::Object::New();
+
+ obj->SetHiddenValue(v8::String::New("__swig__packed_data__"), v8::Boolean::New(true));
+
+#if (SWIG_V8_VERSION < 0x031900)
+ obj->SetPointerInInternalField(0, cdata);
+ cdata->handle = v8::Persistent::New(obj);
+#else
+ obj->SetAlignedPointerInInternalField(0, cdata);
+ cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
+#endif
+
+#if (SWIG_V8_VERSION < 0x031900)
+ cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
+ cdata->handle.MarkIndependent();
+#else
+ cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete);
+# if (SWIG_V8_VERSION < 0x032100)
+ cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
+# else
+ cdata->handle.MarkIndependent();
+# endif
+#endif
+
+ return scope.Close(obj);
+}
+
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIGV8_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIGV8_NewPackedObj(ptr, sz, type)
+
+
+/* ---------------------------------------------------------------------------
+ * Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg)
+ *
+ * ---------------------------------------------------------------------------*/
+
+SWIGRUNTIME
+v8::Handle SWIGV8_AppendOutput(v8::Handle result, v8::Handle