From 4e63c4f720728cc9b54e6033da897b5a785836eb Mon Sep 17 00:00:00 2001
From: Olly Betts
We edit pkg1/mod2.py and want to import module
-pkg1/pkg2/pkg3.py in order to derive from class M3. We can
+pkg1/pkg2/mod3.py in order to derive from class M3. We can
write appropriate Python code in several ways, for example:
Imports in __init__.py are handy when you want to populate a
package's namespace with names imported from other modules. In SWIG based
projects this approach may also be used to split large pieces of code into
-smaller modules, compile them in parallel and then re-assemble everything at another
-level by importing submodules' contents in __init__.py, for
+smaller modules, compile them in parallel and then re-assemble everything at
+runtime by importing submodules' contents in __init__.py, for
example. Unfortunately import directives in __init__.py may cause problems,
--
cgit v1.2.1
From 8d01b145f7d368348e702f88df6c091f5d7175a5 Mon Sep 17 00:00:00 2001
From: William S Fulton This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module. 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. Suppose that you defined a SWIG module such as the following: and for v8:
- Note: be aware that The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet. The default interpreter is Running the examples with JavascriptCore requires
- 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 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. This chapter gives a short introduction how to use a native Javascript extension: as a To install A more detailed explanation is given in the Examples section. Webkit is pre-installed on OSX and available as a library for GTK. There is general information about programming with WebKit on Apple Developer Documentation. Details about An integration of a native extension 'example' would look like this: 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:
+ To get started with Similar to Some basic examples are shown here in more detail. The common example First the module
+
Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. SWIG and Javascript
+26 SWIG and Javascript
+
+
+
+Overview
+26.1 Overview
+
+
Chromium
as Web-Browser widget and node.js
for javascript extensions.
Preliminaries
+26.2 Preliminaries
+
+
+26.2.1 Running SWIG
-Running SWIG
-void example_initialize(v8::Handle
+void example_initialize(v8::Handle<v8::Object> exports)
v8
has a C++ API, and thus, the generated modules must be compiled as C++.v8
has a C++ API, and thus, the generated modules must be compiled as C++.
-Running Tests and Examples
+26.2.2 Running Tests and Examples
+
+
node.js
as it is available on all platforms and convenient to use.libjavascriptcoregtk-1.0
to be installed, e.g., under Ubuntu withFuture work
+26.2.3 Future work
+
+
-std_*.i
typemaps are missing, such as std_iostream
, for instance.Integration
+26.3 Integration
+
+
node.js
module, and as an extension for an embedded Webkit.Creating
+node.js
Extensions26.3.1 Creating node.js Extensions
+
+
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.
@@ -154,7 +206,9 @@ require("./build/Release/example")
Troubleshooting
+26.3.1.1 Troubleshooting
+
+
@@ -164,10 +218,14 @@ require("./build/Release/example")
$ sudo apt-get remove gyp
-Embedded Webkit
+26.3.2 Embedded Webkit
+
+
OSX
+26.3.2.1 OSX
+
+
Cocoa
programming are not covered here.GTK
+26.3.2.2 GTK
+
+
-#include
Creating Applications with
-node-webkit
26.3.3 Creating Applications with node-webkit
+
+
node-webkit
there is a very informative set of wiki pages.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.
@@ -328,10 +389,14 @@ open new windows, and many more things.
};
-Examples
+26.4 Examples
+
+
Simple
+26.4.1 Simple
+
+
simple
looks like this:
@@ -376,11 +441,12 @@ var f = example.Foo;
example.Foo = 3.1415926;
example
is loaded from the previously built extension. Global methods and variables are available in the scope of the module.node.js
and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.
The common example class
defines three classes, Shape
, Circle
, and Square
:
@@ -455,47 +521,47 @@ new Shape();
$ node -i -> var example = require("./build/Release/example"); +& var example = require("./build/Release/example"); undefined -> var Shape = example.Shape; +& var Shape = example.Shape; undefined -> var Circle = example.Circle; +& var Circle = example.Circle; undefined -> var Square = example.Square; +& var Square = example.Square; undefined -> var c = new Circle(10); +& var c = new Circle(10); undefined -> var s = new Square(10); +& var s = new Square(10); undefined -> Shape.nshapes; +& Shape.nshapes; 2 -> c.x = 20; +& c.x = 20; 20 -> c.y = 30; +& c.y = 30; 30 -> s.x = -10; +& s.x = -10; -10 -> s.y = 5; +& s.y = 5; 5 -> c.area(); +& c.area(); 314.1592653589793 -> c.perimeter(); +& c.perimeter(); 62.83185307179586 -> s.area(); +& s.area(); 100 -> s.perimeter(); +& s.perimeter(); 40 -> c.move(40, 40) +& c.move(40, 40) undefined -> c.x +& c.x 60 -> c.y +& c.y 70 -> new Shape() +& 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.<anonymous> (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) @@ -505,13 +571,17 @@ 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.
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.
-The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.
-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:
@@ -610,7 +680,9 @@ Template::Template(const String *code_) { ... } ...
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
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.
The Javascript module delegates code generation to a JSEmitter
instance. The following extract shows the essential interface:
@@ -730,7 +804,7 @@ class JSEmitter { */ Template getTemplate(const String *name); - State &getState(); + State &getState(); ... @@ -740,12 +814,12 @@ class JSEmitter {int JAVASCRIPT::top(Node *n) { - emitter->initialize(n); + emitter->initialize(n); Language::top(n); - emitter->dump(n); - emitter->close(); + emitter->dump(n); + emitter->close(); return SWIG_OK; }@@ -755,16 +829,18 @@ int JAVASCRIPT::top(Node *n) {int JAVASCRIPT::classHandler(Node *n) { - emitter->enterClass(n); + emitter->enterClass(n); Language::classHandler(n); - emitter->exitClass(n); + emitter->exitClass(n); return SWIG_OK; }In
-enterClass
the emitter stores state information that is necessary when processing class members. InexitClass
the wrapper code for the whole class is generated.Emitter states
+26.5.4 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.-diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 269cb2801..61f19be68 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -6,7 +6,7 @@ -27 SWIG and Lua
+28 SWIG and Lua
-@@ -82,14 +82,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net -
27.1 Preliminaries
+28.1 Preliminaries
The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.
-27.2 Running SWIG
+28.2 Running SWIG
@@ -137,7 +137,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.
-27.2.1 Additional command line options
+28.2.1 Additional command line options
@@ -178,7 +178,7 @@ swig -lua -help -
27.2.2 Compiling and Linking and Interpreter
+28.2.2 Compiling and Linking and Interpreter
@@ -249,7 +249,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html
-27.2.3 Compiling a dynamic module
+28.2.3 Compiling a dynamic module
@@ -317,7 +317,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -
27.2.4 Using your module
+28.2.4 Using your module
@@ -335,19 +335,19 @@ $ ./my_lua >
27.3 A tour of basic C/C++ wrapping
+28.3 A tour of basic C/C++ wrapping
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
-27.3.1 Modules
+28.3.1 Modules
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
-27.3.2 Functions
+28.3.2 Functions
@@ -388,7 +388,7 @@ It is also possible to rename the module with an assignment. 24
27.3.3 Global variables
+28.3.3 Global variables
@@ -476,7 +476,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.
-27.3.4 Constants and enums
+28.3.4 Constants and enums
@@ -511,7 +511,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World
@@ -567,7 +567,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.
-@@ -605,7 +605,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor nil
@@ -709,7 +709,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)
-@@ -784,7 +784,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.
-@@ -809,7 +809,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas
It is safe to use multiple inheritance with SWIG.
-@@ -840,7 +840,7 @@ Foo spam7();
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
-@@ -926,7 +926,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
-@@ -1058,9 +1058,9 @@ operators and pseudo-operators):
No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG
+No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.
-@@ -1116,7 +1116,7 @@ true Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
-If you have a function that allocates memory like this,
@@ -1140,7 +1140,7 @@ char *foo();This will release the allocated memory.
-@@ -1175,7 +1175,7 @@ In Lua:
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
-
@@ -1227,7 +1227,7 @@ If you ever need to access the underlying pointer returned by operator->(
> f = p:__deref__() -- Returns underlying Foo *
-27.3.16 C++ Exceptions
+28.3.16 C++ Exceptions
@@ -1370,7 +1370,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).
-@@ -1421,7 +1421,7 @@ Now, from Lua usage is as follows: 19 > -
@@ -1437,7 +1437,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m
-27.3.17.2 Names
+28.3.17.2 Names
If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1481,7 +1481,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -
The internal organization of inheritance has changed. @@ -1522,12 +1522,12 @@ function > -
This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect
-A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:
@@ -1555,7 +1555,7 @@ Received an integer : 6 720 -There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.
@@ -1608,7 +1608,7 @@ void swap(int *sx, int *sy);Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).
-Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor @@ -1672,7 +1672,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In
Note: SWIG also can support arrays of pointers in a similar manner.
-Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:
@@ -1706,7 +1706,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.
@@ -1715,7 +1715,7 @@ ptr=nil -- the iMath* will be GC'ed as normalBefore proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).
-There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.
@@ -1728,7 +1728,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details).This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.
@@ -1777,7 +1777,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp@@ -1786,7 +1786,7 @@ This section covers adding of some small extra bits to your module to add the la -
@@ -1805,7 +1805,7 @@ int native_function(lua_State*L) // my native code The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.
-@@ -1843,7 +1843,7 @@ Good uses for this feature is adding of new code, or writing helper functions to See Examples/lua/arrays for an example of this code.
-@@ -1854,7 +1854,7 @@ See Examples/lua/arrays for an example of this code.
-@@ -1914,7 +1914,7 @@ end
That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
-@@ -1994,7 +1994,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
-
--
cgit v1.2.1
From 4a680e5545af57bd866a8211679b3d953e286545 Mon Sep 17 00:00:00 2001
From: William S Fulton
@@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po
you should probably look at one of SWIG's existing modules.
@@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
@@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno
based on pattern matching and interact heavily with the underlying type system.
@@ -203,7 +203,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
@@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
@@ -385,7 +385,7 @@ returning a foo and taking types a and b as
arguments).
@@ -640,7 +640,7 @@ $ swig -c++ -python -debug-module 4 example.i
@@ -659,7 +659,7 @@ that matches the name of the target language. For example, python:foo
perl:foo.
@@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int )
@@ -806,7 +806,7 @@ For example, the exception code above is simply
stored without any modifications.
@@ -928,7 +928,7 @@ public :
The role of these functions is described shortly.
@@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
@@ -987,7 +987,7 @@ typedef Hash Typetab;
-
@@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
-
@@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
-
@@ -1294,7 +1294,7 @@ If t is not a standard object, it is assumed to be a char *
and is used to create a String object.
-26 SWIG and Common Lisp
+26 SWIG and Javascript
+
+
+
+
+27 SWIG and Common Lisp
27 SWIG and Lua
+28 SWIG and Lua
28 SWIG and Modula-3
+29 SWIG and Modula-3
29 SWIG and MzScheme/Racket
+30 SWIG and MzScheme/Racket
30 SWIG and Ocaml
+31 SWIG and Ocaml
31 SWIG and Octave
+32 SWIG and Octave
32 SWIG and Perl5
+33 SWIG and Perl5
33 SWIG and PHP
+34 SWIG and PHP
34 SWIG and Pike
+35 SWIG and Pike
35 SWIG and Python
+36 SWIG and Python
36 SWIG and R
+37 SWIG and R
37 SWIG and Ruby
+38 SWIG and Ruby
38 SWIG and Tcl
+39 SWIG and Tcl
39 Extending SWIG to support new languages
+40 Extending SWIG to support new languages
39 Extending SWIG to support new languages
+40 Extending SWIG to support new languages
@@ -75,7 +75,7 @@
-
39.1 Introduction
+40.1 Introduction
39.2 Prerequisites
+40.2 Prerequisites
39.3 The Big Picture
+40.3 The Big Picture
39.4 Execution Model
+40.4 Execution Model
39.4.1 Preprocessing
+40.4.1 Preprocessing
39.4.2 Parsing
+40.4.2 Parsing
39.4.3 Parse Trees
+40.4.3 Parse Trees
39.4.4 Attribute namespaces
+40.4.4 Attribute namespaces
39.4.5 Symbol Tables
+40.4.5 Symbol Tables
39.4.6 The %feature directive
+40.4.6 The %feature directive
39.4.7 Code Generation
+40.4.7 Code Generation
39.4.8 SWIG and XML
+40.4.8 SWIG and XML
39.5 Primitive Data Structures
+40.5 Primitive Data Structures
39.5.1 Strings
+40.5.1 Strings
39.5.2 Hashes
+40.5.2 Hashes
39.5.3 Lists
+40.5.3 Lists
39.5.4 Common operations
+40.5.4 Common operations
The following operations are applicable to all datatypes.
@@ -1349,7 +1349,7 @@ objects and report errors.
Gets the line number associated with x.
-39.5.5 Iterating over Lists and Hashes
+40.5.5 Iterating over Lists and Hashes
To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) {
-39.5.6 I/O
+40.5.6 I/O
Special I/O functions are used for all internal I/O. These operations
@@ -1528,7 +1528,7 @@ Printf(f, "%s\n", s);
Similarly, the preprocessor and parser all operate on string-files.
@@ -1779,7 +1779,7 @@ the attribute is optional. Swig_restore() must always be called after function. -
@@ -1788,7 +1788,7 @@ pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.
-@@ -1889,7 +1889,7 @@ make the final type, the two parts are just joined together using string concatenation.
-@@ -2058,7 +2058,7 @@ Returns the prefix of a type. For example, if ty is ty is unmodified. -
@@ -2145,7 +2145,7 @@ Checks if ty is a varargs type. Checks if ty is a templatized type. -
@@ -2247,7 +2247,7 @@ Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames. -
@@ -2284,7 +2284,7 @@ Literal y; // type = 'Literal', ltype='p.char' -
@@ -2346,7 +2346,7 @@ SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double). -
@@ -2445,7 +2445,7 @@ included. Used to emit prototypes. Returns the number of required (non-optional) arguments in p. -
@@ -2460,7 +2460,7 @@ describes the creation of a minimal Python module. You should be able to extra this to other languages.
-@@ -2470,7 +2470,7 @@ the parsing of command line options, all aspects of code generation are controll different methods of the Language that must be defined by your module.
-@@ -2578,7 +2578,7 @@ that activates your module. For example, swig -python foo.i. The messages from your new module should appear.
-@@ -2637,7 +2637,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit unrecognized command line option error.
-@@ -2686,7 +2686,7 @@ an implementation file python.cxx and a configuration file python.swg.
-@@ -2744,7 +2744,7 @@ int Python::top(Node *n) { -
@@ -3199,7 +3199,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g. the SWIG files that implement those functions.
-@@ -3218,7 +3218,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.
-@@ -3247,7 +3247,7 @@ during this process, see the section on .
-@@ -3306,7 +3306,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.
-@@ -3498,7 +3498,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.
-@@ -3530,7 +3530,7 @@ Some topics that you'll want to be sure to address include: if available. -
@@ -3587,7 +3587,7 @@ should be added should there be an area not already covered by the existing tests.
-@@ -3611,7 +3611,7 @@ The generated C/C++ code should also follow this style as close as possible. How should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
-@@ -3638,7 +3638,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.
-@@ -4046,7 +4046,7 @@ extern "X" { ... } declaration. -
diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 7ea9139ac..0b8d47846 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -6,7 +6,7 @@
-@@ -50,7 +50,7 @@ here
-@@ -77,7 +77,7 @@ swig -cffi -module module-name file-name files and the various things which you can do with them.
-@@ -118,7 +118,7 @@ swig -cffi -help -
This feature to SWIG (for CFFI) is very new and still far from @@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI module feel free to contact us on the SWIG mailing list, and also please add a "[CFFI]" tag in the subject line. -
@@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for
-@@ -638,7 +638,7 @@ swig -clisp -module module-name file-name interface file for the CLISP module. The CLISP module tries to produce code which is both human readable and easily modifyable.
-
@@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
-
@@ -795,7 +795,7 @@ struct bar { -
@@ -84,7 +84,7 @@ FFTW -
@@ -131,10 +131,10 @@ functions), but it doesn't allow you to easily integrate a Modula-3 module into a C/C++ project.
-@@ -283,7 +283,7 @@ and the principal type must be renamed (%typemap).
-@@ -384,10 +384,10 @@ There is no C++ library I wrote a SWIG interface for, so I'm not sure if this is possible or sensible, yet.
-@@ -400,7 +400,7 @@ For testing examples I use Critical Mass cm3.
-@@ -477,10 +477,10 @@ Instead generate templates for some basic typemaps. -
@@ -694,7 +694,7 @@ consist of the following parts: -
@@ -746,7 +746,7 @@ that I'd like to automate.
-@@ -759,7 +759,7 @@ is not really useful, yet.
-@@ -792,7 +792,7 @@ IMPORT M3toC;
@@ -816,7 +816,7 @@ you should declare %typemap("m3wrapinconv:throws") blah * %{OSError.E%}.
-@@ -863,10 +863,10 @@ where almost everything is generated by a typemap: -
@@ -166,7 +166,7 @@ Some points of interest:
diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index ec46d6e50..aa6679f9a 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -6,7 +6,7 @@
-@@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that will be loaded dynamically. This has only been tested on Linux so far.
-@@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or the resulting .ml and .mli files as well, and do the final link with -custom (not needed for native link).
-@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH") -
@@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom option is not needed when you build native code.
-@@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.
-@@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a signature for a function that uses value in this way.
-@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions. -
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a -
@@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.
-@@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.
-@@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array, so you have to specify it for yourself in the form of a typemap.
-@@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.
-@@ -572,7 +572,7 @@ void printfloats( float *tab, int len ); -
@@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.
-@@ -695,7 +695,7 @@ baz # -
@@ -725,7 +725,7 @@ public: }; -
@@ -743,7 +743,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \ -L$QTPATH/lib -cclib -lqt
@@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window containing the string "hi" in a button. -30.2.5 Director Classes
+31.2.5 Director Classes
-30.2.5.1 Director Introduction
+31.2.5.1 Director Introduction
@@ -800,7 +800,7 @@ class foo { };
@@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing an overloaded class. This example is contained in Examples/ocaml/shapes.
-The "arginit" typemap is used to set the initial value of a @@ -2802,7 +2802,7 @@ applications. For example:
} -The "default" typemap is used to turn an argument into a @@ -2827,7 +2827,7 @@ arguments that follow must have default values. See the 37.7.6.6 "check" typemap +
The "check" typemap is used to supply value checking code @@ -2842,7 +2842,7 @@ arguments have been converted. For example:
} -The "argout" typemap is used to return values from arguments. @@ -2896,7 +2896,7 @@ some function like SWIG_Ruby_AppendOutput.
See the typemaps.i library for examples.
-The "freearg" typemap is used to cleanup argument data. It is @@ -2923,7 +2923,7 @@ This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.
-The "newfree" typemap is used in conjunction with the %newobject @@ -2947,7 +2947,7 @@ string *foo();
See Object ownership and %newobject for further details.
-The "memberin" typemap is used to copy data from an @@ -2965,21 +2965,21 @@ example:
already provides a default implementation for arrays, strings, and other objects. -The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.
-The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.
-The "throws" typemap is only used when SWIG parses a C++ @@ -3020,7 +3020,7 @@ specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.
-Converts C++ objects in director @@ -3079,7 +3079,7 @@ referring to the class itself. -
Converts Ruby objects in director @@ -3152,7 +3152,7 @@ exception.
-Output argument processing in director @@ -3210,19 +3210,19 @@ referring to the instance of the class itself -
Cleanup of function return values
-Setting of C global variables
-@@ -3272,7 +3272,7 @@ so that their values can be properly assigned.
When you write a typemap, you usually have to work directly @@ -3287,7 +3287,7 @@ stick to the swig functions instead of the native Ruby functions. That should help you avoid having to rewrite a lot of typemaps across multiple languages.
-Here, while the Ruby versions return the value directly, the SWIG @@ -3397,7 +3397,7 @@ versions do not, but return a status value to indicate success (SWIG_OK -
RSTRING_LEN(str)
@@ -3420,7 +3420,7 @@ versions do not, but return a status value to indicate success (SWIG_OK void rb_raise(VALUE exception, const char *fmt,
@@ -3499,7 +3499,7 @@ message to standard error if Ruby was invoked with the -w
flag. The given format string fmt and remaining
arguments are interpreted as with printf().
-37.7.8.5 Iterators
+38.7.8.5 Iterators
void rb_iter_break()
@@ -3545,14 +3545,14 @@ VALUE), VALUE value)This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.
-A common problem in many C programs is the processing of @@ -3617,7 +3617,7 @@ array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.
-Ruby's solution to the "keyword arguments" capability of some @@ -3831,7 +3831,7 @@ memory leak. Fortunately, this typemap is a lot easier to write:
program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution. -Occasionally, it might be necessary to convert pointer values @@ -3890,7 +3890,7 @@ For example:
} - VALUE Data_Wrap_Struct(VALUE class, void
@@ -3917,7 +3917,7 @@ as above.
type c-type from the data object obj
and assigns that pointer to ptr.
-37.7.13 Example: STL Vector to Ruby Array
+38.7.13 Example: STL Vector to Ruby Array
Another use for macros and type maps is to create a Ruby array @@ -4009,7 +4009,7 @@ STL with ruby, you are advised to use the standard swig STL library, which does much more than this. Refer to the section called the C++ Standard Template Library. -
@@ -4043,7 +4043,7 @@ generate ri documentation from a c wrap file, you could do:
$ rdoc -r file_wrap.c -@@ -4073,7 +4073,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." %module(docstring=DOCSTRING) xrc -
Since SWIG does know everything about the function it wraps, @@ -4094,7 +4094,7 @@ several options for autodoc controlled by the value given to the feature, described below.
-@@ -4118,7 +4118,7 @@ Then Ruby code like this will be generated: ... -
@@ -4138,7 +4138,7 @@ this: ... -
@@ -4150,7 +4150,7 @@ parameter types with the "2" option will result in Ruby code like this:
-@@ -4171,7 +4171,7 @@ Parameters: bar - Bar -
@@ -4187,7 +4187,7 @@ generated string. For example: void GetPosition(int* OUTPUT, int* OUTPUT); -
@@ -4198,10 +4198,10 @@ docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.
-SWIG allows operator overloading with, by using the %extend @@ -4382,7 +4382,7 @@ separate method for handling inequality since Ruby parses the expression a != b as !(a == b).
- The chapter on Working
@@ -4508,7 +4508,7 @@ irb(main):005:0> c.getX()
5.0
- The Ruby language doesn't support multiple inheritance, but
@@ -4575,7 +4575,7 @@ matching rules used for other kinds of features apply (see the chapter
on "Customization
Features") for more details). One of the most common issues in generating SWIG bindings for
@@ -4598,7 +4598,7 @@ to C++ (or vice versa) depending on what function or methods are
invoked. Clearly, developing a SWIG wrapper requires a thorough
understanding of how the underlying library manages memory. Ruby uses a mark and sweep garbage collector. When the garbage
@@ -4630,7 +4630,7 @@ any memory has been allocated in creating the underlying C struct or
C++ struct, then a "free" function must be defined that deallocates
this memory. As described above, memory management depends on clearly
@@ -4775,7 +4775,7 @@ public:
This code can be seen in swig/examples/ruby/tracking. The remaining parts of this section will use the class library
@@ -5000,7 +5000,7 @@ However, if you implement your own free functions (see below) you may
also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects
methods. With a bit more testing, we see that our class library still
@@ -5129,7 +5129,7 @@ irb(main):016:0>
This code can be seen in swig/examples/ruby/mark_function. By default, SWIG creates a "free" function that is called when
@@ -5296,7 +5296,7 @@ been freed, and thus raises a runtime exception. This code can be seen in swig/examples/ruby/free_function. As has been said, the Ruby GC runs and marks objects before
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index 45eebbf5e..c12701ac9 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -6,7 +6,7 @@
@@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
@@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h
-
@@ -163,7 +163,7 @@ The name of the module is specified using the %module directive or the
-module command line option.
@@ -229,7 +229,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
@@ -357,7 +357,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
@@ -440,7 +440,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
@@ -467,7 +467,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
@@ -486,7 +486,7 @@ option will append the prefix to the name when creating a command and
call it "Foo_bar".
@@ -508,7 +508,7 @@ When the -namespace option is used, objects in the module
are always accessed with the namespace name such as Foo::bar.
@@ -519,7 +519,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
@@ -577,7 +577,7 @@ MSDOS > tclsh80
%
@@ -640,7 +640,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
@@ -651,7 +651,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
@@ -685,7 +685,7 @@ To fix this, supply an extra argument to load like this:
-
@@ -710,7 +710,7 @@ like you think it does:
%
-
@@ -790,7 +790,7 @@ extern char *path; // Read-only (due to %immutable)
-
@@ -874,7 +874,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the global statement to be omitted.
@@ -970,7 +970,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
@@ -1252,7 +1252,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
@@ -1319,7 +1319,7 @@ In Tcl, the static member is accessed as follows:
-
@@ -1368,7 +1368,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
@@ -1422,7 +1422,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
@@ -1545,7 +1545,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
@@ -1647,7 +1647,7 @@ There are ways to make this operator appear as part of the class using the %
Keep reading.
@@ -1711,7 +1711,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
@@ -1763,7 +1763,7 @@ More details can be found in the SWIG and C++
examples will appear later.
@@ -1847,7 +1847,7 @@ simply use the __deref__() method. For example:
-
@@ -1860,7 +1860,7 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
@@ -1925,7 +1925,7 @@ function. This allows objects to be encapsulated objects that look a lot like
as shown in the last section.
@@ -2113,7 +2113,7 @@ typemaps--an advanced topic discussed later.
@@ -2301,7 +2301,7 @@ set c [lindex $dim 1]
-
@@ -2435,7 +2435,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "Customization Features" for more examples.
@@ -2452,7 +2452,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
@@ -2569,7 +2569,7 @@ parameter is omitted):
-
@@ -2707,7 +2707,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
@@ -2778,7 +2778,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
@@ -2840,7 +2840,7 @@ argv[2] = Larry
3
-
@@ -2882,7 +2882,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
@@ -2959,7 +2959,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
@@ -3043,7 +3043,7 @@ work)
-
@@ -3119,7 +3119,7 @@ For example:
-
@@ -3191,7 +3191,7 @@ As a final note, most SWIG examples do not yet use the
to use the load command instead.
@@ -3290,7 +3290,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
@@ -3411,7 +3411,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
--
cgit v1.2.1
From a6d71e6c57dedcdf520f1d62026fe35a43fbb549 Mon Sep 17 00:00:00 2001
From: Karl Wette
+By default, any byte string (char* or std::string) returned
+from C or C++ code is decoded to text as UTF-8. This decoding uses the
+surrogateescape error handler under Python 3.1 or higher -- this
+error handler decodes invalid byte sequences to high surrogate characters
+in the range U+DC80 to U+DCFF.
+
+As an example, consider the following SWIG interface, which exposes a byte
+string that cannot be completely decoded as UTF-8:
+
+When this method is called from Python 3, the return value is the following
+text string:
+
+Since the C string contains bytes that cannot be decoded as UTF-8, those raw
+bytes are represented as high surrogate characters that can be used to obtain
+the original byte sequence:
+
+One can then attempt a different encoding, if desired (or simply leave the
+byte string as a raw sequence of bytes for use in binary protocols):
+
+Note, however, that text strings containing surrogate characters are rejected
+with the default strict codec error handler. For example:
+
+This requires the user to check most strings returned by SWIG bindings, but
+the alternative is for a non-UTF8 byte string to be completely inaccessible
+in Python 3 code.
+
+For more details about the surrogateescape error handler, please see
+PEP 383.
+37.9.3 Specifying Mixin Modules
+38.9.3 Specifying Mixin Modules
37.10 Memory Management
+38.10 Memory Management
37.10.1 Mark and Sweep Garbage Collector
+38.10.1 Mark and Sweep Garbage Collector
37.10.2 Object Ownership
+38.10.2 Object Ownership
37.10.3 Object Tracking
+38.10.3 Object Tracking
37.10.4 Mark Functions
+38.10.4 Mark Functions
37.10.5 Free Functions
+38.10.5 Free Functions
37.10.6 Embedded Ruby and the C++ Stack
+38.10.6 Embedded Ruby and the C++ Stack
38 SWIG and Tcl
+39 SWIG and Tcl
@@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
-
38.1 Preliminaries
+39.1 Preliminaries
38.1.1 Getting the right header files
+39.1.1 Getting the right header files
38.1.2 Compiling a dynamic module
+39.1.2 Compiling a dynamic module
38.1.3 Static linking
+39.1.3 Static linking
38.1.4 Using your module
+39.1.4 Using your module
38.1.5 Compilation of C++ extensions
+39.1.5 Compilation of C++ extensions
38.1.6 Compiling for 64-bit platforms
+39.1.6 Compiling for 64-bit platforms
38.1.7 Setting a package prefix
+39.1.7 Setting a package prefix
38.1.8 Using namespaces
+39.1.8 Using namespaces
38.2 Building Tcl/Tk Extensions under Windows 95/NT
+39.2 Building Tcl/Tk Extensions under Windows 95/NT
38.2.1 Running SWIG from Developer Studio
+39.2.1 Running SWIG from Developer Studio
38.2.2 Using NMAKE
+39.2.2 Using NMAKE
38.3 A tour of basic C/C++ wrapping
+39.3 A tour of basic C/C++ wrapping
38.3.1 Modules
+39.3.1 Modules
38.3.2 Functions
+39.3.2 Functions
38.3.3 Global variables
+39.3.3 Global variables
38.3.4 Constants and enums
+39.3.4 Constants and enums
38.3.5 Pointers
+39.3.5 Pointers
38.3.6 Structures
+39.3.6 Structures
38.3.7 C++ classes
+39.3.7 C++ classes
38.3.8 C++ inheritance
+39.3.8 C++ inheritance
38.3.9 Pointers, references, values, and arrays
+39.3.9 Pointers, references, values, and arrays
38.3.10 C++ overloaded functions
+39.3.10 C++ overloaded functions
38.3.11 C++ operators
+39.3.11 C++ operators
38.3.12 C++ namespaces
+39.3.12 C++ namespaces
38.3.13 C++ templates
+39.3.13 C++ templates
38.3.14 C++ Smart Pointers
+39.3.14 C++ Smart Pointers
38.4 Further details on the Tcl class interface
+39.4 Further details on the Tcl class interface
38.4.1 Proxy classes
+39.4.1 Proxy classes
38.4.2 Memory management
+39.4.2 Memory management
38.5 Input and output parameters
+39.5 Input and output parameters
38.6 Exception handling
+39.6 Exception handling
38.7 Typemaps
+39.7 Typemaps
38.7.1 What is a typemap?
+39.7.1 What is a typemap?
38.7.2 Tcl typemaps
+39.7.2 Tcl typemaps
38.7.3 Typemap variables
+39.7.3 Typemap variables
38.7.4 Converting a Tcl list to a char **
+39.7.4 Converting a Tcl list to a char **
38.7.5 Returning values in arguments
+39.7.5 Returning values in arguments
38.7.6 Useful functions
+39.7.6 Useful functions
38.7.7 Standard typemaps
+39.7.7 Standard typemaps
38.7.8 Pointer handling
+39.7.8 Pointer handling
38.8 Turning a SWIG module into a Tcl Package.
+39.8 Turning a SWIG module into a Tcl Package.
38.9 Building new kinds of Tcl interfaces (in Tcl)
+39.9 Building new kinds of Tcl interfaces (in Tcl)
38.9.1 Proxy classes
+39.9.1 Proxy classes
38.10 Tcl/Tk Stubs
+39.10 Tcl/Tk Stubs
35.12.4 Byte string output conversion
+
+
+
+%module example
+
+%include <std_string.i>
+
+%inline %{
+
+const char* non_utf8_c_str(void) {
+ return "h\xe9llo w\xc3\xb6rld";
+}
+
+%}
+
+>>> s = test.non_utf8_c_str()
+>>> s
+'h\udce9llo wörld'
+
+>>> b = s.encode('utf-8', errors='surrogateescape')
+>>> b
+b'h\xe9llo w\xc3\xb6rld'
+
+>>> b.decode('latin-1')
+'héllo wörld'
+
+>>> with open('test', 'w') as f:
+... print(s, file=f)
+...
+Traceback (most recent call last):
+ File "<stdin>", line 2, in <module>
+UnicodeEncodeError: 'utf-8' codec can't encode character '\udce9' in position 1: surrogates not allowed
+
->>> s = test.non_utf8_c_str() +@@ -5974,7 +5974,7 @@ bytes are represented as high surrogate characters that can be used to obtain the original byte sequence: -+>>> s = example.non_utf8_c_str() >>> s 'h\udce9llo wörld'diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index bfe91aa09..fc2c45126 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -6,7 +6,7 @@ -+@@ -1566,6 +1567,7 @@>>> b = s.encode('utf-8', errors='surrogateescape') >>> b b'h\xe9llo w\xc3\xb6rld' @@ -5985,7 +5985,7 @@ One can then attempt a different encoding, if desired (or simply leave the byte string as a raw sequence of bytes for use in binary protocols): -+@@ -5995,7 +5995,7 @@ Note, however, that text strings containing surrogate characters are rejected with the default strict codec error handler. For example: ->>> b.decode('latin-1') 'héllo wörld'@@ -870,5 +871,87 @@ state.clazz(RESET); state.clazz(NAME, Getattr(n, "sym:name"));+->>> with open('test', 'w') as f: ... print(s, file=f) ... -- cgit v1.2.1 From bdc63e5a9faf8b2cc0a8b311ab0eea9edd026d02 Mon Sep 17 00:00:00 2001 From: Karl WetteDate: Sat, 24 May 2014 20:07:52 +0200 Subject: Remove example Makefiles when running distclean-examples in out-of-src build --- Makefile.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile.in b/Makefile.in index da9dfdce5..a040d41a1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -420,6 +420,11 @@ distclean-examples: @echo distcleaning Examples @$(MAKE) $(FLAGS) clean-examples @cd Examples && $(MAKE) $(FLAGS) distclean + @if test "x$(srcdir)" != "x."; then \ + for mkfile in `cd $(srcdir) && find Examples/ -type f -name Makefile`; do \ + rm -f "$$mkfile"; \ + done; \ + fi distclean-ccache: @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) $(FLAGS) distclean) -- cgit v1.2.1 From 3e978fce9ff9d655a7e9469a59c5d6ccc73fb7cb Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 24 May 2014 20:25:56 +0200 Subject: Record files left over after maintainer-clean in Travis build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5859c946f..89bed90a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,7 +113,7 @@ script: - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples CFLAGS="${CFLAGS_EXAMPLES[$SWIGLANG]}" CXXFLAGS="${CXXFLAGS_EXAMPLES[$SWIGLANG]}"; fi - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi - echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r' - - make maintainer-clean && ../../configure $CONFIGOPTS + - make maintainer-clean && find . -type f | sed 's/^/File left after maintainer-clean - /' && ../../configure $CONFIGOPTS - echo -en 'travis_fold:end:script.3\\r' branches: only: -- cgit v1.2.1 From 5c5dfc106f00b4125f1ae7a173463afc8cdeccad Mon Sep 17 00:00:00 2001 From: Harvey Falcic Date: Sat, 24 May 2014 15:39:53 -0400 Subject: Python unicode_strings test case: restrict to Python > 3.0 Also adjust the test method names and content to match the docs. --- Examples/test-suite/python/unicode_strings_runme.py | 7 +++++-- Examples/test-suite/unicode_strings.i | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 2d26599aa..162f40972 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -1,4 +1,7 @@ +import sys + import unicode_strings -unicode_strings.test_c_str() -unicode_strings.test_std_string() +if sys.version_info > (3, 0): + unicode_strings.non_utf8_c_str() + unicode_strings.non_utf8_std_string() diff --git a/Examples/test-suite/unicode_strings.i b/Examples/test-suite/unicode_strings.i index f4a8b8b50..56063c8a4 100644 --- a/Examples/test-suite/unicode_strings.i +++ b/Examples/test-suite/unicode_strings.i @@ -4,12 +4,12 @@ %inline %{ -const char* test_c_str(void) { - return "h\xe9llo"; +const char* non_utf8_c_str(void) { + return "h\xe9llo w\xc3\xb6rld"; } -std::string test_std_string(void) { - return std::string("h\xe9llo"); +std::string non_utf8_std_string(void) { + return std::string("h\xe9llo w\xc3\xb6rld"); } %} -- cgit v1.2.1 From 2533d0210fb2f3b2e9f441c38bd03b99f4a57a44 Mon Sep 17 00:00:00 2001 From: Harvey Falcic Date: Sat, 24 May 2014 16:50:33 -0400 Subject: unicode_strings test: check return values --- Examples/test-suite/python/unicode_strings_runme.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 162f40972..0e2e1af06 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -2,6 +2,11 @@ import sys import unicode_strings +# The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant +# in 3.3+. Since this file is run through 2to3 before testing, though, +# mark this as a unicode string in 2.x so it'll become a str in 3.x. +test_string = u'h\udce9llo w\u00f6rld' + if sys.version_info > (3, 0): - unicode_strings.non_utf8_c_str() - unicode_strings.non_utf8_std_string() + assert unicode_strings.non_utf8_c_str() == test_string + assert unicode_strings.non_utf8_std_string() == test_string -- cgit v1.2.1 From ab527b0e4bf592e55b038a6de0fb8fe4540eea92 Mon Sep 17 00:00:00 2001 From: Harvey Falcic Date: Sat, 24 May 2014 17:54:53 -0400 Subject: unicode_strings_runme.py: fix version check Python 3.0.1 shouldn't pass. --- Examples/test-suite/python/unicode_strings_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 0e2e1af06..2110c5ce7 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -7,6 +7,6 @@ import unicode_strings # mark this as a unicode string in 2.x so it'll become a str in 3.x. test_string = u'h\udce9llo w\u00f6rld' -if sys.version_info > (3, 0): +if sys.version_info[0:2] >= (3, 1): assert unicode_strings.non_utf8_c_str() == test_string assert unicode_strings.non_utf8_std_string() == test_string -- cgit v1.2.1 From 91e93838fc6dbc181181f6ffacb024b6a87cfe63 Mon Sep 17 00:00:00 2001 From: Harvey Falcic Date: Sat, 24 May 2014 18:00:04 -0400 Subject: unicode_strings test: manually check values instead of using assert --- Examples/test-suite/python/unicode_strings_runme.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 2110c5ce7..e1fc7adec 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -8,5 +8,7 @@ import unicode_strings test_string = u'h\udce9llo w\u00f6rld' if sys.version_info[0:2] >= (3, 1): - assert unicode_strings.non_utf8_c_str() == test_string - assert unicode_strings.non_utf8_std_string() == test_string + if unicode_strings.non_utf8_c_str() != test_string: + raise ValueError('Test comparison mismatch') + if unicode_strings.non_utf8_std_string() != test_string: + raise ValueError('Test comparison mismatch') -- cgit v1.2.1 From 575ac1c170cbfb9de6ced5f9e7075b928d4a4227 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 25 May 2014 00:01:24 +0100 Subject: Add 3.0.1 release notes summary --- RELEASENOTES | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RELEASENOTES b/RELEASENOTES index 949f58e38..542ff4b10 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -4,6 +4,14 @@ and CHANGES files. Release Notes ============= +SWIG-3.0.1 summary: +- Javascript module added. This supports JavascriptCore (Safari/Webkit), + v8 (Chromium) and node.js currently. +- A few notable regressions introduced in 3.0.0 have been fixed - in + Lua, nested classes and parsing of operator <<. +- The usual round of bug fixes and minor improvements for: + C#, GCJ, Go, Java, Lua, PHP and Python. + SWIG-3.0.0 summary: - This is a major new release focusing primarily on C++ improvements. - C++11 support added. Please see documentation for details of supported -- cgit v1.2.1 From 4ab2eb96cd34503f2ceaa3ee88c22801cb546dda Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 25 May 2014 00:29:32 +0100 Subject: R examples building out-of-source They still don't run though --- Examples/Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 3a91cddd3..caf848596 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -14,7 +14,7 @@ # # 2. To use this makefile, set required variables, eg SRCS, INTERFACE, # INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a -# $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \ +# $(MAKE) -f Makefile.template.in SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ # INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method # @@ -1660,7 +1660,7 @@ r: $(SRCDIR_SRCS) ifneq ($(SRCDIR_SRCS),) $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(R_CFLAGS) $(SRCDIR_SRCS) $(INCLUDES) endif - +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) + +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) # ---------------------------------------------------------------- # Build a R dynamically loadable module (C++) @@ -1671,7 +1671,7 @@ r_cpp: $(SRCDIR_CXXSRCS) ifneq ($(SRCDIR_CXXSRCS),) $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(R_CFLAGS) $(SRCDIR_CXXSRCS) $(INCLUDES) endif - +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) + +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) # ----------------------------------------------------------------- # Run R example -- cgit v1.2.1 From 597c671e8630f959b48d716ffbc0be57990dc585 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 25 May 2014 12:00:42 +0100 Subject: More diagnostics for csharp_exceptions testcase for diagnosing erratic failures --- Examples/test-suite/csharp/csharp_exceptions_runme.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/csharp_exceptions_runme.cs b/Examples/test-suite/csharp/csharp_exceptions_runme.cs index 43585b106..51805ce87 100644 --- a/Examples/test-suite/csharp/csharp_exceptions_runme.cs +++ b/Examples/test-suite/csharp/csharp_exceptions_runme.cs @@ -323,7 +323,9 @@ public class TestThread { } catch (ArgumentOutOfRangeException e) { String expectedMessage = "caught:" + i + "\n" + "Parameter name: input"; if (e.Message.Replace(runme.CRLF,"\n") != expectedMessage) - throw new Exception("Exception message incorrect. Expected:\n[" + expectedMessage + "]\n" + "Received:\n[" + e.Message + "]"); + throw new Exception("Exception message incorrect. Expected:\n[" + + expectedMessage + "]\n" + "Received:\n[" + + e.Message + "]"); if (e.ParamName != "input") throw new Exception("Exception ParamName incorrect. Expected:\n[input]\n" + "Received:\n[" + e.ParamName + "]"); if (e.InnerException != null) @@ -333,7 +335,7 @@ public class TestThread { throw new Exception("throwsException.dub = " + throwsClass.dub + " expected: 1234.5678"); } } catch (Exception e) { - Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message); + Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message + "\n TestThread Inner stack trace: " + e.StackTrace); Failed = true; } } -- cgit v1.2.1 From 01f8253b192224d8996e5bffd3c8121fa32ad0ea Mon Sep 17 00:00:00 2001 From: Oliver Buchtala Date: Mon, 26 May 2014 21:38:00 +0200 Subject: Javascript: added a section about known issues. --- Doc/Manual/Javascript.html | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 011e61051..e6f422bd8 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -128,33 +128,23 @@ $ make check-javascript-examples ENGINE=jsc $ make check-javascript-test-suite ENGINE=jscTests 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-26.2.3 Future work
+26.2.1 Known Issues
+At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.
-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 asstd_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.
- +
Default optional arguments do not work for all targeted interpreters
- +
Mutliple output arguments do not work for JSC
- +
Memory leaks have been observed for all generators
- +
C89 incompatibily: the JSC generator might still generate C89 violating code
- +
long long
is not supported q- +
Javascript callbacks are not supported
instanceOf
does not work under JSCThe primary development environment has been Linux (Ubuntu 12.04). Windows and OSX have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.
+26.3 Integration
-- cgit v1.2.1 From 6f69555225d818530e60cc50a7cd57f8bafd46f1 Mon Sep 17 00:00:00 2001 From: Eric WingDate: Mon, 19 May 2014 17:15:49 -0700 Subject: JavaScriptCore: Fixed exception object so sourceURL (file name), line (number), and message can be recovered. The current implementation only returns an error string. But this is insufficient for debugging (what file and line number did it fail at?). As documented here: http://parmanoir.com/Taming_JavascriptCore_within_and_without_WebView converting the JSValueRef of string to an JSObjectRef (via JSValueToObject) will trigger JSCore into filling the "sourceURL" and "line" properties into the object so they can be inspected by the caller. Additionally, JavaScriptCore has a "message" property which contains the message string. JSCore doesn't seem to be filling this in for us automatically, unlike "sourceURL" and "line". So this patch also fills that property in too. Thanks to Brian Barnes for the detailed information about "sourceURL", "line", and "message". Below is an example (derived from Brian Barnes's information) on how you typically use/extract these exception details. void script_exception_to_string(JSContextRef js_context,JSValueRef exception_value_ref,char* return_error_string, int return_error_string_max_length) { JSObjectRef exception_object; JSValueRef value_ref; JSStringRef jsstring_property_name = NULL; JSValueRef temporary_exception = NULL; JSStringRef js_return_string = NULL; size_t bytes_needed; char* c_result_string = NULL; exception_object = JSValueToObject(js_context, exception_value_ref, NULL); // source and line numbers strcpy(return_error_string,"["); jsstring_property_name = JSStringCreateWithUTF8CString("sourceURL"); value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception); JSStringRelease(jsstring_property_name); js_return_string = JSValueToStringCopy(js_context, value_ref, NULL); bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string); c_result_string = (char*)calloc(bytes_needed, sizeof(char)); JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed); SDL_Log("c_result_string: %s\n", c_result_string); JSStringRelease(js_return_string); strncat(return_error_string, c_result_string, return_error_string_max_length-1); free(c_result_string); strncat(return_error_string, ":", return_error_string_max_length-1); jsstring_property_name = JSStringCreateWithUTF8CString("line"); value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception); JSStringRelease(jsstring_property_name); js_return_string = JSValueToStringCopy(js_context, value_ref, NULL); bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string); c_result_string = (char*)calloc(bytes_needed, sizeof(char)); JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed); SDL_Log("c_result_string: %s\n", c_result_string); JSStringRelease(js_return_string); strncat(return_error_string, c_result_string, return_error_string_max_length-1); //SDL_Log("c_result_string: %s\n", c_result_string); free(c_result_string); strncat(return_error_string, "]", return_error_string_max_length-1); /* get message */ jsstring_property_name = JSStringCreateWithUTF8CString("message"); value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception); JSStringRelease(jsstring_property_name); if(NULL == value_ref) { strncat(return_error_string, "Unknown Error", return_error_string_max_length-1); } else { js_return_string = JSValueToStringCopy(js_context, value_ref, NULL); bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string); c_result_string = (char*)calloc(bytes_needed, sizeof(char)); JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed); SDL_Log("c_result_string: %s\n", c_result_string); JSStringRelease(js_return_string); strncat(return_error_string, c_result_string, return_error_string_max_length-1); //SDL_Log("c_result_string: %s\n", c_result_string); free(c_result_string); } } To use: if(js_exception) { char return_error_string[256]; script_exception_to_string(js_context, js_exception, return_error_string, 256); SDL_Log("Compile error is %s", return_error_string); } --- Lib/javascript/jsc/javascriptrun.swg | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Lib/javascript/jsc/javascriptrun.swg b/Lib/javascript/jsc/javascriptrun.swg index ae1567e87..1fde8855b 100644 --- a/Lib/javascript/jsc/javascriptrun.swg +++ b/Lib/javascript/jsc/javascriptrun.swg @@ -9,8 +9,29 @@ SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) { JSStringRef message = JSStringCreateWithUTF8CString(type); - *exception = JSValueMakeString(context, message); - JSStringRelease(message); + JSStringRef message_property_key; + JSObjectRef exception_object; + JSValueRef exception_value; + JSValueRef message_value; + exception_value = JSValueMakeString(context, message); + /* Converting the result to an object will let JavascriptCore add "sourceURL" (file) and "line" (number) to the exception, + instead of just returning a raw string. This is extremely important for debugging your errors. + */ + exception_object = JSValueToObject(context, exception_value, NULL); + + /* Additionally, JSCore uses "message" which contains the error description. + But it seems that unlike "sourceURL" and "line", converting to an object is not automatically doing this. + So we can add it ourselves. + */ + message_property_key = JSStringCreateWithUTF8CString("message"); + message_value = JSValueMakeString(context, message); + JSObjectSetProperty(context, exception_object, message_property_key, message_value, kJSClassAttributeNone, NULL); + + /* Return the exception_object */ + *exception = exception_object; + + JSStringRelease(message_property_key); + JSStringRelease(message); } SWIGRUNTIME void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) { -- cgit v1.2.1 From f1c331f2c5b5df607edb581cf7711b7f40d2fb09 Mon Sep 17 00:00:00 2001 From: Eric Wing Date: Mon, 19 May 2014 17:42:00 -0700 Subject: JavaScriptCore: Returning NULL for wrapper functions that expect JSValueRef may crash program. According to this: http://parmanoir.com/Taming_JavascriptCore_within_and_without_WebView Returning NULL instead of an actual JSValueRef for a return value of a function could lead to crashes. I think I have seen related weirdness in the past when I failed to return a proper type to JSCore which resulted in very hard to understand behavior. So this patch changes those return NULLs to return JSValueMakeUndefined(). I thought about JSObjectMakeError, but I don't fully understand the intent of the Error object and can't find any relevant real world examples of it being used. However, everybody seems to be using JSValueMakeUndefined(). This patch should be low impact since this is only triggered on an error condition. --- Lib/javascript/jsc/javascriptcode.swg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/javascript/jsc/javascriptcode.swg b/Lib/javascript/jsc/javascriptcode.swg index 3fe9d49e9..f8c5a200f 100644 --- a/Lib/javascript/jsc/javascriptcode.swg +++ b/Lib/javascript/jsc/javascriptcode.swg @@ -17,7 +17,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); goto fail; fail: - return NULL; + return JSValueMakeUndefined(context); } %} @@ -78,7 +78,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size goto fail; fail: - return NULL; + return JSValueMakeUndefined(context); } %} @@ -159,7 +159,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStr goto fail; fail: - return NULL; + return JSValueMakeUndefined(context); } %} @@ -204,7 +204,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjec goto fail; fail: - return NULL; + return JSValueMakeUndefined(context); } %} @@ -229,7 +229,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjec goto fail; fail: - return NULL; + return JSValueMakeUndefined(context); } %} -- cgit v1.2.1 From e7b20624cc32d1220d5ad53370bfc1d92c8657c4 Mon Sep 17 00:00:00 2001 From: Eric Wing Date: Mon, 19 May 2014 19:00:43 -0700 Subject: JavaScriptCore: Reverted 2 of the JSValueMakeUndefined replacements because those functions are tied to JSObjectRef instead of JSValueRef. The C compiler will allow this, but C++ will reject the conversion. It is unclear what the correct handling is for JavaScriptCore. (Nobody bothers to document this in JSCore.) Unlike our other problem where we incorrectly assume JSObjectRef when the functions want JSValueRef, this time Apple is demanding the JSObjectRef. Like our other problem, I assume it is unsafe to try to convert Undefined into a JSObjectRef. So reverting to NULL seems like the safer bet for this specific case. Perhaps the other alternative is to return an exception object or an error object. But I would like to see JSCore document this before trying. --- Lib/javascript/jsc/javascriptcode.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/javascript/jsc/javascriptcode.swg b/Lib/javascript/jsc/javascriptcode.swg index f8c5a200f..c18902fce 100644 --- a/Lib/javascript/jsc/javascriptcode.swg +++ b/Lib/javascript/jsc/javascriptcode.swg @@ -17,7 +17,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN); goto fail; fail: - return JSValueMakeUndefined(context); + return NULL; } %} @@ -78,7 +78,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size goto fail; fail: - return JSValueMakeUndefined(context); + return NULL; } %} -- cgit v1.2.1 From 1766e67a1af127f42c908090e8d46b49de30ce19 Mon Sep 17 00:00:00 2001 From: Eric Wing Date: Wed, 21 May 2014 03:43:52 -0700 Subject: JavaScriptCore: Improved code that uses JSObjectMakeError instead of JSValueToObject to create the exception object. JSObjectMakeError automatically populates the "message" field, and possibly other fields I don't know about. This seems to be the most robust way to create an exception object. Thanks to Brian Barnes again for the tip on JSObjectMakeError. --- Lib/javascript/jsc/javascriptrun.swg | 40 +++++++++++++++--------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/Lib/javascript/jsc/javascriptrun.swg b/Lib/javascript/jsc/javascriptrun.swg index 1fde8855b..676a45833 100644 --- a/Lib/javascript/jsc/javascriptrun.swg +++ b/Lib/javascript/jsc/javascriptrun.swg @@ -8,30 +8,24 @@ #define SWIG_fail goto fail SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) { - JSStringRef message = JSStringCreateWithUTF8CString(type); - JSStringRef message_property_key; - JSObjectRef exception_object; - JSValueRef exception_value; - JSValueRef message_value; - exception_value = JSValueMakeString(context, message); - /* Converting the result to an object will let JavascriptCore add "sourceURL" (file) and "line" (number) to the exception, - instead of just returning a raw string. This is extremely important for debugging your errors. - */ - exception_object = JSValueToObject(context, exception_value, NULL); - - /* Additionally, JSCore uses "message" which contains the error description. - But it seems that unlike "sourceURL" and "line", converting to an object is not automatically doing this. - So we can add it ourselves. + JSStringRef message = JSStringCreateWithUTF8CString(type); + JSValueRef error_arguments[1]; + JSObjectRef exception_object; + JSValueRef exception_value; + exception_value = JSValueMakeString(context, message); + /* Converting the result to an object will let JavascriptCore add + "sourceURL" (file) and "line" (number) and "message" to the exception, + instead of just returning a raw string. This is extremely important for debugging your errors. + Using JSObjectMakeError is better than JSValueToObject because the latter only populates + "sourceURL" and "line", but not "message" or any others I don't know about. */ - message_property_key = JSStringCreateWithUTF8CString("message"); - message_value = JSValueMakeString(context, message); - JSObjectSetProperty(context, exception_object, message_property_key, message_value, kJSClassAttributeNone, NULL); - - /* Return the exception_object */ - *exception = exception_object; - - JSStringRelease(message_property_key); - JSStringRelease(message); + error_arguments[0] = exception_value; + exception_object = JSObjectMakeError(context, 1, error_arguments, NULL); + + /* Return the exception_object */ + *exception = exception_object; + + JSStringRelease(message); } SWIGRUNTIME void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) { -- cgit v1.2.1 From 1df7ca77a061b961e054689bc8b61e60ed9ad93d Mon Sep 17 00:00:00 2001 From: Oliver Buchtala Date: Tue, 27 May 2014 10:40:16 +0200 Subject: JavascriptCore: added documentation about how to extract details from JSC errors. This code is necessary for embedding applications to present details about JS exceptions. --- Doc/Manual/Javascript.html | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index e6f422bd8..246669a22 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -41,6 +41,7 @@ Code Templates Emitter Emitter states + Handling Exceptions in JavascriptCore State information can be retrieved using
+ + +state.clazz(NAME)
or withGetattr
onstate.clazz()
which actually returns aHash
instance.26.5.5. Handling Exceptions in JavascriptCore
+ + +Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.
+++ ++void script_exception_to_string(JSContextRef js_context,JSValueRef exception_value_ref,char* return_error_string, int return_error_string_max_length) +{ + JSObjectRef exception_object; + JSValueRef value_ref; + JSStringRef jsstring_property_name = NULL; + JSValueRef temporary_exception = NULL; + JSStringRef js_return_string = NULL; + size_t bytes_needed; + char* c_result_string = NULL; + exception_object = JSValueToObject(js_context, exception_value_ref, NULL); + + /* source url */ + strcpy(return_error_string,"["); + jsstring_property_name = JSStringCreateWithUTF8CString("sourceURL"); + value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception); + JSStringRelease(jsstring_property_name); + js_return_string = JSValueToStringCopy(js_context, value_ref, NULL); + bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string); + c_result_string = (char*)calloc(bytes_needed, sizeof(char)); + JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed); + JSStringRelease(js_return_string); + strncat(return_error_string, c_result_string, return_error_string_max_length-1); + free(c_result_string); + + strncat(return_error_string, ":", return_error_string_max_length-1); + + /* line number */ + + jsstring_property_name = JSStringCreateWithUTF8CString("line"); + value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception); + JSStringRelease(jsstring_property_name); + js_return_string = JSValueToStringCopy(js_context, value_ref, NULL); + bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string); + c_result_string = (char*)calloc(bytes_needed, sizeof(char)); + JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed); + JSStringRelease(js_return_string); + strncat(return_error_string, c_result_string, return_error_string_max_length-1); + free(c_result_string); + + strncat(return_error_string, "]", return_error_string_max_length-1); + + /* error message */ + + jsstring_property_name = JSStringCreateWithUTF8CString("message"); + value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception); + JSStringRelease(jsstring_property_name); + if(NULL == value_ref) + { + strncat(return_error_string, "Unknown Error", return_error_string_max_length-1); + } + else + { + js_return_string = JSValueToStringCopy(js_context, value_ref, NULL); + bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string); + c_result_string = (char*)calloc(bytes_needed, sizeof(char)); + JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed); + JSStringRelease(js_return_string); + strncat(return_error_string, c_result_string, return_error_string_max_length-1); + free(c_result_string); + } +}+It would be used in the following way:
+++ -- cgit v1.2.1 From 5d307b2cbfc9e2caa06805df425161617868bea8 Mon Sep 17 00:00:00 2001 From: Oliver Buchtala+if(js_exception) +{ + char return_error_string[256]; + script_exception_to_string(js_context, js_exception, return_error_string, 256); + printf("Compile error is %s", return_error_string); +}+Date: Tue, 27 May 2014 10:41:39 +0200 Subject: JavascriptCore: updated documentation about how to register an initialized module. --- Doc/Manual/Javascript.html | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 246669a22..97197b670 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -223,13 +223,21 @@ $ sudo apt-get remove gyp #import "appDelegate.h" -extern bool example_initialize(JSGlobalContextRef context); +extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports); @implementation ExampleAppDelegate @synthesize webView; +- (void)addGlobalObject:(JSContextRef) context:(NSString *)objectName:(JSObjectRef) theObject { + JSObjectRef global = JSContextGetGlobalObject(context); + JSStringRef objectJSName = JSStringCreateWithCFString( (CFStringRef) objectName ) + if ( objectJSName != NULL ) { + JSObjectSetProperty(context, global, objectJSName, theObject, kJSPropertyAttributeReadOnly, NULL); + JSStringRelease( objectJSName ); + } +} - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { @@ -240,7 +248,11 @@ extern bool example_initialize(JSGlobalContextRef context); WebFrame *webframe = [webView mainFrame]; JSGlobalContextRef context = [webframe globalContext]; - example_initialize(context); + JSObjectRef example; + example_initialize(context, &example); + [self addGlobalObject:context:@"example":example] + + JSObjectSetProperty(context, global, JSStringRef propertyName, example, JSPropertyAttributes attributes, NULL); [ [webView mainFrame] loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString:url] ] @@ -273,7 +285,13 @@ int main(int argc, char* argv[]) WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); WebFrame *webframe = webkit_web_view_get_main_frame(webView); JSGlobalContextRef context = webkit_web_frame_get_global_context(webFrame); - example_initialize(context); + JSObjectRef global = JSContextGetGlobalObject(context); + + JSObjectRef exampleModule; + example_initialize(context, &exampleModule); + JSStringRef jsName = JSStringCreateWithUTF8CString("example"); + JSObjectSetProperty(context, global, jsName, exampleModule, kJSPropertyAttributeReadOnly, NULL); + JSStringRelease(jsName); ... -- cgit v1.2.1 From a22f97eb3337bdd0b58d6ec764aeb23395c31d70 Mon Sep 17 00:00:00 2001 From: Oliver BuchtalaDate: Tue, 27 May 2014 10:44:13 +0200 Subject: Javascript: updated documentation about known issues. [skip ci] --- Doc/Manual/Javascript.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 97197b670..a4cc02d02 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -15,7 +15,7 @@ Integration @@ -137,9 +137,9 @@ $ make check-javascript-test-suite ENGINE=jsc
-- cgit v1.2.1 From c342bc1b281d9da9a73d88bfe3fca617cc5dab2d Mon Sep 17 00:00:00 2001 From: Oliver Buchtala
Default optional arguments do not work for all targeted interpreters
- -
Mutliple output arguments do not work for JSC
Memory leaks have been observed for all generators
- -
C89 incompatibily: the JSC generator might still generate C89 violating code
- +
long long
is not supported q- +
long long
is not supported
%native
is not supportedJavascript callbacks are not supported
instanceOf
does not work under JSCDate: Tue, 27 May 2014 21:37:18 +0200 Subject: Javascript: added a link to the v8 web-site to the documentation. --- Doc/Manual/Javascript.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index a4cc02d02..bfe91aa09 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -57,7 +57,7 @@ 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 byChromium
andnode.js
.SWIG Javascript currently supports JavascriptCore, the Javascript engine used by
Safari/Webkit
, and v8, which is used byChromium
andnode.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
-- cgit v1.2.1 From b531956467f7e0e064cd9928c044be64fa0a3a0a Mon Sep 17 00:00:00 2001 From: William S FultonChromium
as Web-Browser widget andnode.js
for javascript extensions.Date: Tue, 27 May 2014 21:55:17 +0100 Subject: Warning fixes compiling with Visual Studio --- Source/Modules/javascript.cxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index e535bc179..8b7a74037 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -724,19 +724,19 @@ int JSEmitter::emitWrapperFunction(Node *n) { // detected via the 'view' attribute. || (Equal(kind, "variable") && Equal(Getattr(n, "view"), "globalfunctionHandler")) ) { - bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend"); - bool is_static = GetFlag(state.function(), IS_STATIC); + bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0; + bool is_static = GetFlag(state.function(), IS_STATIC) != 0; ret = emitFunction(n, is_member, is_static); } else if (Cmp(kind, "variable") == 0) { - bool is_static = GetFlag(state.variable(), IS_STATIC); + bool is_static = GetFlag(state.variable(), IS_STATIC) != 0; // HACK: smartpointeraccessed static variables are not treated as statics if (GetFlag(n, "allocate:smartpointeraccess")) { is_static = false; } - bool is_member = GetFlag(n, "ismember"); - bool is_setter = GetFlag(n, "memberset") || GetFlag(n, "varset"); - bool is_getter = GetFlag(n, "memberget") || GetFlag(n, "varget"); + bool is_member = GetFlag(n, "ismember") != 0; + bool is_setter = GetFlag(n, "memberset") != 0 || GetFlag(n, "varset") != 0; + bool is_getter = GetFlag(n, "memberget") != 0 || GetFlag(n, "varget") != 0; if (is_setter) { ret = emitSetter(n, is_member, is_static); } else if (is_getter) { @@ -840,7 +840,7 @@ int JSEmitter::emitCtor(Node *n) { Wrapper *wrapper = NewWrapper(); - bool is_overloaded = GetFlag(n, "sym:overloaded"); + bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; Template t_ctor(getTemplate("js_ctor")); @@ -1160,7 +1160,7 @@ int JSEmitter::emitFunction(Node *n, bool is_member, bool is_static) { Wrapper *wrapper = NewWrapper(); Template t_function(getTemplate("js_function")); - bool is_overloaded = GetFlag(n, "sym:overloaded"); + bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; // prepare the function wrapper name String *iname = Getattr(n, "sym:name"); @@ -1288,7 +1288,7 @@ void JSEmitter::marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, Strin cresult = defaultResultName; tm = Swig_typemap_lookup_out("out", n, cresult, wrapper, actioncode); - bool should_own = GetFlag(n, "feature:new"); + bool should_own = GetFlag(n, "feature:new") != 0; if (tm) { Replaceall(tm, "$objecttype", Swig_scopename_last(SwigType_str(SwigType_strip_qualifiers(type), 0))); @@ -1628,8 +1628,8 @@ int JSCEmitter::enterFunction(Node *n) { int JSCEmitter::exitFunction(Node *n) { Template t_function = getTemplate("jsc_function_declaration"); - bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend"); - bool is_overloaded = GetFlag(n, "sym:overloaded"); + bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0; + bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; // handle overloaded functions if (is_overloaded) { @@ -2077,10 +2077,10 @@ int V8Emitter::exitVariable(Node *n) { } int V8Emitter::exitFunction(Node *n) { - bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend"); + bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0; // create a dispatcher for overloaded functions - bool is_overloaded = GetFlag(n, "sym:overloaded"); + bool is_overloaded = GetFlag(n, "sym:overloaded") != 0; if (is_overloaded) { if (!Getattr(n, "sym:nextSibling")) { //state.function(WRAPPER_NAME, Swig_name_wrapper(Getattr(n, "name"))); -- cgit v1.2.1 From f03bff152c44203ece2084aac03f14ac55a33b5c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 27 May 2014 07:22:46 +0100 Subject: Python 3 byte string output: use errors="surrogateescape" change note --- CHANGES.current | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e73a91c3f..399a05415 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.1 (in progress) =========================== +2014-05-25: hfalcic + [Python] Python 3 byte string output: use errors="surrogateescape" + if available on the version of Python that's in use. This allows + obtaining the original byte string (and potentially trying a fallback + encoding) if the bytes can't be decoded as UTF-8. + + Previously, a UnicodeDecodeError would be raised with no way to treat + the data as bytes or try another codec. + 2014-05-18: vkalinin Bug #175 - Restore %extend to work for unnamed nested structures by using a C symbol comprising the outer structure name and unnamed variable instance name. -- cgit v1.2.1 From eeb113360633fdd69c4d81a3a508853f3cafe9e3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 27 May 2014 07:27:33 +0100 Subject: Javascript html links and typo fixes --- Doc/Manual/Contents.html | 4 +++- Doc/Manual/Javascript.html | 9 +++++---- Doc/Manual/Python.html | 2 +- Doc/Manual/Sections.html | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 37a5aacff..4dd454352 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1056,7 +1056,7 @@ Integration @@ -1082,6 +1082,7 @@
- Code Templates
- Emitter
- Emitter states +
- Handling Exceptions in JavascriptCore
Function annotation Buffer interface Abstract base classes + Byte string output conversion 26 SWIG and Javascript
+26 SWIG and Javascript
-@@ -130,13 +130,14 @@ $ make check-javascript-examples ENGINE=jsc $ make check-javascript-test-suite ENGINE=jsc
26.2.1 Known Issues
+26.2.3 Known Issues
+At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.
Default optional arguments do not work for all targeted interpreters
Mutliple output arguments do not work for JSC
Multiple output arguments do not work for JSC
C89 incompatibily: the JSC generator might still generate C89 violating code
long long
is not supported
%native
is not supported
State information can be retrieved using state.clazz(NAME)
or with Getattr
on state.clazz()
which actually returns a Hash
instance.
Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 6dc0ff9ba..8b4f42a43 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -5929,7 +5929,7 @@ For details of abstract base class, please see PEP 3119. -diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 99d1dfe0d..b616371df 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -42,7 +42,7 @@ Last update : SWIG-3.0.1 (in progress)
The configuration file essentially conforms to node.js
syntax.
-It has some extras to configure node-webkit
. See the Manifest specification for more details.
+It has some extras to configure node-webkit
. See the Manifest specification for more details.
--
cgit v1.2.1
From 703862dc3a1ed01ad705e8884ef8963f8030cacb Mon Sep 17 00:00:00 2001
From: Olly Betts SWIG-3.0 Documentation
-Last update : SWIG-3.0.1 (27 May 2014)
+Last update : SWIG-3.0.2 (in progress)
Sections
diff --git a/README b/README
index e30441be7..e4010bd80 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 3.0.1 (27 May 2014)
+Version: 3.0.2 (27 May 2014)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua,
diff --git a/configure.ac b/configure.ac
index 2ff5dc8db..8af45b69f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl The macros which aren't shipped with the autotools are stored in the
dnl Tools/config directory in .m4 files.
-AC_INIT([swig],[3.0.1],[http://www.swig.org])
+AC_INIT([swig],[3.0.2],[http://www.swig.org])
dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED
dnl definition below can be removed
--
cgit v1.2.1
From 2b4c49d017f526f6622cd54547ab9fab31941176 Mon Sep 17 00:00:00 2001
From: Artem Serebriyskiy
--
cgit v1.2.1
From 227dd356090fb91bd2dd2b19534ce2b3daa22e1d Mon Sep 17 00:00:00 2001
From: Olly Betts
The usual (and recommended) way is to build the extension as a separate
dynamically loaded module (which is supported by all modern operating
-systems). You can then specify that this be loaded
-automatically in php.ini or load it explicitly for any script which
-needs it. As of version 5.3 of PHP, the dl()
-function cannot be used and your only option is to
-add to the php.ini something like
-
-extension = /usr/lib64/php/modules/mymodule.so
+systems).
@@ -147,10 +141,9 @@ least work for Linux though):
-To test the extension from a PHP script, you need to load it first. You
-can load it for every script by adding this line to the [PHP] section of
+To test the extension from a PHP script, you first need to load tell PHP to
+load it. To do this, add a line like this to the [PHP] section of
php.ini:
-Alternatively, you can load it explicitly only for scripts which need it
-by adding this line to the start of each such PHP script::
+If the module is in PHP's default extension directory, you can omit the path.
+
+For some SAPIs (for example, the CLI SAPI) you can instead use the
+dl() function to load
+an extension at run time, by adding a like like this to the start of each
+PHP script which uses your extension:
-SWIG also generates a php module, which
-attempts to do the dl() call for you:
+But note that this doesn't work when running PHP through a webserver in PHP5.3
+and later - you'll need to use extension in php.ini as
+described above.
+
+The PHP module which SWIG generates will also attempt to do the dl()
+call for you if the extension isn't already loaded:
+This PHP module also defines the PHP classes for the wrapped API, so you'll
+almost certainly want to include it anyway.
+34.1.2 Using PHP Extensions
-
@@ -168,14 +167,25 @@ by adding this line to the start of each such PHP script::
include("example.php");
34.2 Basic PHP interface
--
cgit v1.2.1
From 2b2260e9960996654815a6d23bf632ffb57a156c Mon Sep 17 00:00:00 2001
From: Timothee Cour