Merge branch 'master' into javascript
* master:
Fix some typos
[PHP] The generated __isset() method now returns true for read-only properties.
Eliminate needless casting away const from string constants
Fix typos
Fix missing ")" in code example
Fix comment typos
Fix m4 quoting of checks for yodl2man and yodl2html versions
Fixed errors from previous commit.
Removed all unnecessary asserts
Remove unused variable
Another go html fix
Fix intgosize arg documentation
Optimize metamethods inheritance resolving
Updating documentation
Whitespace cleanup of Example Makefiles
.gitignore: ignore Lib/swigwarn.swg
Fixing unused variable warnings
Finish implementation with proxy functions
Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
Ignored enum fixes.
Further shift operator regression fixes
Fix use of shift operators in expressions regression since 3.0.0
Fix seg fault with extra ) brackets and >>
More efficient end of template bracket (>>) handling
beautify scanner.c
Tidy up scanner.c
DOH readme correction
Fix typo in -lua -help output
Remove extra </div>
Update documentation for deprecation and removal of Close()
Fix segfault when there are too many closing round brackets in parsed code
Refix operator<< definition giving a syntax error
Fix regression in 3.0.0 where legal code following an operator<< definition might give a syntax error.
Remove unnecessary block from PHP version of SWIG_exception macro
[PHP] Fix wrapping director constructors with default parameters with a ZTS-enabled build of PHP.
Fix potential bugs found by Coverity analysis
Eliminate unused parameter from SWIG_Php_GetModule()
Fix comment typo
Fix compiler warnings in generated Lua code
[PHP] Pass the ZTS context we already have to avoid needing to call TSRMLS_FETCH, which is relatively expensive.
[PHP] Pass ZTS context through to t_output_helper() so it works with a ZTS-enabled build of PHP. Reported by Pierre Labastie in github PR#155.
Lua test-suite can now be run out of source
Fix out of source test-suite runs for Octave
Add runtime test for commit 7a96fba836
Add C++11 constexpr runtime test
This commit is contained in:
commit
f51be1ca5c
150 changed files with 935 additions and 410 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -85,6 +85,7 @@ swig.spec
|
||||||
.dirstamp
|
.dirstamp
|
||||||
CCache/ccache-swig
|
CCache/ccache-swig
|
||||||
CCache/ccache-swig.1
|
CCache/ccache-swig.1
|
||||||
|
Lib/swigwarn.swg
|
||||||
Source/CParse/parser.c
|
Source/CParse/parser.c
|
||||||
Source/CParse/parser.h
|
Source/CParse/parser.h
|
||||||
Source/eswig
|
Source/eswig
|
||||||
|
|
|
||||||
6
CHANGES
6
CHANGES
|
|
@ -9970,7 +9970,7 @@ Version 1.3.23 (November 11, 2004)
|
||||||
- Remove the ability to share type information by using c linking.
|
- Remove the ability to share type information by using c linking.
|
||||||
All type sharing happens through a global variable in the target language.
|
All type sharing happens through a global variable in the target language.
|
||||||
+ Remove SWIG_NOIMPORT, SWIG_RUNTIME, and related defines.
|
+ Remove SWIG_NOIMPORT, SWIG_RUNTIME, and related defines.
|
||||||
+ Depreciate -runtime, -noruntime command line options
|
+ Deprecate -runtime, -noruntime command line options
|
||||||
+ Update test-suite common.mk to correctly build multicpptest
|
+ Update test-suite common.mk to correctly build multicpptest
|
||||||
+ Remove reference to precommon.swg
|
+ Remove reference to precommon.swg
|
||||||
+ Update the guile_gh interface to share data by a global var instead
|
+ Update the guile_gh interface to share data by a global var instead
|
||||||
|
|
@ -21212,9 +21212,9 @@ Version 1.3 Alpha 1 (February 11, 2000)
|
||||||
*** POTENTIAL INCOMPATIBILITY ***
|
*** POTENTIAL INCOMPATIBILITY ***
|
||||||
|
|
||||||
1/30/00 : loic
|
1/30/00 : loic
|
||||||
Conditionaly compile experimental code with --enable-experiment
|
Conditionally compile experimental code with --enable-experiment
|
||||||
configure flag.
|
configure flag.
|
||||||
Fix .cvsignore to ignore configrue & yacc generated files
|
Fix .cvsignore to ignore configure & yacc generated files
|
||||||
|
|
||||||
1/28/00 : loic
|
1/28/00 : loic
|
||||||
Apply automake everywhere
|
Apply automake everywhere
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,35 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.1 (in progress)
|
Version 3.0.1 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2014-05-01: olly
|
||||||
|
[PHP] The generated __isset() method now returns true for read-only properties.
|
||||||
|
|
||||||
|
2014-04-08: wsfulton
|
||||||
|
SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
|
||||||
|
|
||||||
|
2014-04-08: wsfulton
|
||||||
|
[Java C#] Enums which have been ignored via %ignore and are subsequently
|
||||||
|
used are handled slightly differently. Type wrapper classes are now generated
|
||||||
|
which are effectively a wrapper of an empty enum. Previously in Java uncompilable
|
||||||
|
code was generated and in C# an int was used.
|
||||||
|
|
||||||
|
2014-04-04: wsfulton
|
||||||
|
Fix regression in 3.0.0 where legal code following an operator<< definition might
|
||||||
|
give a syntax error. SF Bug #1365.
|
||||||
|
|
||||||
|
2014-04-03: olly
|
||||||
|
[PHP] Fix wrapping director constructors with default parameters
|
||||||
|
with a ZTS-enabled build of PHP.
|
||||||
|
|
||||||
|
2014-04-02: olly
|
||||||
|
[PHP] Pass the ZTS context we already have to avoid needing to
|
||||||
|
call TSRMLS_FETCH, which is relatively expensive.
|
||||||
|
|
||||||
|
2014-04-02: olly
|
||||||
|
[PHP] Pass ZTS context through to t_output_helper() so it works
|
||||||
|
with a ZTS-enabled build of PHP. Reported by Pierre Labastie in
|
||||||
|
github PR#155.
|
||||||
|
|
||||||
2014-03-28: wsfulton
|
2014-03-28: wsfulton
|
||||||
[Java C# D Go] Fixes for C enums used in an API and the definition of the enum
|
[Java C# D Go] Fixes for C enums used in an API and the definition of the enum
|
||||||
has not been parsed. For D, this fixes a segfault in SWIG. The other languages
|
has not been parsed. For D, this fixes a segfault in SWIG. The other languages
|
||||||
|
|
|
||||||
|
|
@ -1500,12 +1500,11 @@ Create a File object wrapper around an existing <tt>FILE *</tt> object.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<b><tt>int Close(String_or_FILE *f)</tt></b>
|
There's no explicit function to close a file, just call <tt>Delete(f)</tt> -
|
||||||
|
this decreases the reference count, and the file will be closed when the
|
||||||
|
reference count reaches zero.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="indent">
|
|
||||||
<p>Closes a file. Has no effect on strings.</p>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The use of the above I/O functions and strings play a critical role in SWIG. It is
|
The use of the above I/O functions and strings play a critical role in SWIG. It is
|
||||||
common to see small code fragments of code generated using code like this:
|
common to see small code fragments of code generated using code like this:
|
||||||
|
|
@ -1529,8 +1528,6 @@ Printf(f, "%s\n", s);
|
||||||
Similarly, the preprocessor and parser all operate on string-files.
|
Similarly, the preprocessor and parser all operate on string-files.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<H2><a name="Extending_nn21"></a>39.6 Navigating and manipulating parse trees</H2>
|
<H2><a name="Extending_nn21"></a>39.6 Navigating and manipulating parse trees</H2>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2832,7 +2829,6 @@ int Python::top(Node *n) {
|
||||||
Delete(f_header);
|
Delete(f_header);
|
||||||
Delete(f_wrappers);
|
Delete(f_wrappers);
|
||||||
Delete(f_init);
|
Delete(f_init);
|
||||||
Close(f_begin);
|
|
||||||
Delete(f_begin);
|
Delete(f_begin);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,9 @@ swig -go -help
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>-intgo-type-size %lt;s%gt;</td>
|
<td>-intgosize <s></td>
|
||||||
<td>Set the size for the Go type <tt>int</tt>. This controls the size
|
<td>Set the size for the Go type <tt>int</tt>. This controls the size
|
||||||
that the C/C++ code expects to see. The %lt;s%gt; argument should
|
that the C/C++ code expects to see. The <s> argument should
|
||||||
be 32 or 64. This option is currently required during the
|
be 32 or 64. This option is currently required during the
|
||||||
transition from Go 1.0 to Go 1.1, as the size of <tt>int</tt> on
|
transition from Go 1.0 to Go 1.1, as the size of <tt>int</tt> on
|
||||||
64-bit x86 systems changes between those releases (from 32 bits to
|
64-bit x86 systems changes between those releases (from 32 bits to
|
||||||
|
|
@ -125,7 +125,7 @@ swig -go -help
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>-soname %lt;name%gt;</td>
|
<td>-soname <name></td>
|
||||||
<td>Set the runtime name of the shared library that the dynamic linker
|
<td>Set the runtime name of the shared library that the dynamic linker
|
||||||
should include at runtime. The default is the package name with
|
should include at runtime. The default is the package name with
|
||||||
".so" appended. This is only used when generating code for
|
".so" appended. This is only used when generating code for
|
||||||
|
|
|
||||||
|
|
@ -990,7 +990,7 @@ The current list of operators which can be overloaded (and the alternative funct
|
||||||
<li><tt>__sub__</tt> operator-
|
<li><tt>__sub__</tt> operator-
|
||||||
<li><tt>__mul__</tt> operator *
|
<li><tt>__mul__</tt> operator *
|
||||||
<li><tt>__div__</tt> operator/
|
<li><tt>__div__</tt> operator/
|
||||||
<li><tt>__neg__</tt> unary minus
|
<li><tt>__unm__</tt> unary minus
|
||||||
<li><tt>__call__</tt> operator<tt>()</tt> (often used in functor classes)
|
<li><tt>__call__</tt> operator<tt>()</tt> (often used in functor classes)
|
||||||
<li><tt>__pow__</tt> the exponential fn (no C++ equivalent, Lua uses <tt>^</tt>)
|
<li><tt>__pow__</tt> the exponential fn (no C++ equivalent, Lua uses <tt>^</tt>)
|
||||||
<li><tt>__concat__</tt> the concatenation operator (SWIG maps C++'s <tt>~</tt> to Lua's <tt>..</tt>)
|
<li><tt>__concat__</tt> the concatenation operator (SWIG maps C++'s <tt>~</tt> to Lua's <tt>..</tt>)
|
||||||
|
|
@ -1037,7 +1037,29 @@ It is also possible to overload the operator<tt>[]</tt>, but currently this cann
|
||||||
void __setitem__(int i,double d); // i is the index, d is the data
|
void __setitem__(int i,double d); // i is the index, d is the data
|
||||||
};
|
};
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
<p>
|
||||||
|
C++ operators are mapped to Lua predefined metafunctions. Class inherits from its bases the following list of metafunctions ( thus inheriting the folloging
|
||||||
|
operators and pseudo-operators):</p>
|
||||||
|
<ul>
|
||||||
|
<li><tt>__add__</tt>
|
||||||
|
<li><tt>__sub__</tt>
|
||||||
|
<li><tt>__mul__</tt>
|
||||||
|
<li><tt>__div__</tt>
|
||||||
|
<li><tt>__unm__</tt>
|
||||||
|
<li><tt>__mod__</tt>
|
||||||
|
<li><tt>__call__</tt>
|
||||||
|
<li><tt>__pow__</tt>
|
||||||
|
<li><tt>__concat__</tt>
|
||||||
|
<li><tt>__eq__</tt>
|
||||||
|
<li><tt>__lt__</tt>
|
||||||
|
<li><tt>__le__</tt>
|
||||||
|
<li><tt>__len__</tt>
|
||||||
|
<li><tt>__getitem__</tt>
|
||||||
|
<li><tt>__setitem__</tt>
|
||||||
|
<li><tt>__tostring</tt> used internally by Lua for tostring() function. __str__ is mapped to this function
|
||||||
|
</ul>
|
||||||
|
<p>No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. <tt>__tostring</tt> is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG</p>
|
||||||
|
</p>
|
||||||
<H3><a name="Lua_nn19"></a>27.3.12 Class extension with %extend</H3>
|
<H3><a name="Lua_nn19"></a>27.3.12 Class extension with %extend</H3>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1073,7 +1095,7 @@ Now we extend it with some new code
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
bool operator==(const Complex& c)
|
bool operator==(const Complex& c)
|
||||||
{ return ($self->re()==c.re() && $self->im()==c.im();}
|
{ return ($self->re()==c.re() && $self->im()==c.im());}
|
||||||
};
|
};
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -4690,7 +4690,7 @@ public:
|
||||||
C++ constructor, thus creating a new <tt>foo</tt> object.
|
C++ constructor, thus creating a new <tt>foo</tt> object.
|
||||||
By default, SWIG will assign the new Ruby object a "free" function.
|
By default, SWIG will assign the new Ruby object a "free" function.
|
||||||
When the Ruby object is garbage collected, the "free" function will be
|
When the Ruby object is garbage collected, the "free" function will be
|
||||||
called. It in turn will call <tt>Foo's</tt> destructor.</p>
|
called. It in turn will call <tt>Foo</tt>'s destructor.</p>
|
||||||
|
|
||||||
<p>Next, consider this code: </p>
|
<p>Next, consider this code: </p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ math.randomseed(0) -- init random
|
||||||
|
|
||||||
|
|
||||||
--[[ version 1: passing a C array to the code
|
--[[ version 1: passing a C array to the code
|
||||||
lets test call sort_int()
|
let's test call sort_int()
|
||||||
this requires a C array, so is the hardest to use]]
|
this requires a C array, so is the hardest to use]]
|
||||||
ARRAY_SIZE=10
|
ARRAY_SIZE=10
|
||||||
arr=example.new_int(ARRAY_SIZE)
|
arr=example.new_int(ARRAY_SIZE)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
dual.cpp a test for multiple modules and multiple intrepreters staticly linked together.
|
dual.cpp a test for multiple modules and multiple interpreters statically linked together.
|
||||||
|
|
||||||
Earlier version of lua bindings for SWIG would fail if staticly linked.
|
Earlier version of lua bindings for SWIG would fail if statically linked.
|
||||||
|
|
||||||
What is happening is as follows:
|
What is happening is as follows:
|
||||||
example.i declares a type Foo
|
example.i declares a type Foo
|
||||||
|
|
@ -28,7 +28,7 @@ both Foo and Bar.
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// the 2 libraries which are wrappered via SWIG
|
// the 2 libraries which are wrapped via SWIG
|
||||||
extern "C" int luaopen_example(lua_State*L);
|
extern "C" int luaopen_example(lua_State*L);
|
||||||
extern "C" int luaopen_example2(lua_State*L);
|
extern "C" int luaopen_example2(lua_State*L);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
/* embed.c a simple test for an embeded interpreter
|
/* embed.c a simple test for an embedded interpreter
|
||||||
|
|
||||||
The idea is that we wrapper a few simple function (example.c)
|
The idea is that we wrapper a few simple function (example.c)
|
||||||
and write our own app to call it.
|
and write our own app to call it.
|
||||||
|
|
||||||
What it will do is load the wrappered lib, load runme.lua and then call some functions.
|
What it will do is load the wrapped lib, load runme.lua and then call some functions.
|
||||||
To make life easier, all the printf's have either [C] or [Lua] at the start
|
To make life easier, all the printf's have either [C] or [Lua] at the start
|
||||||
so you can see where they are coming from.
|
so you can see where they are coming from.
|
||||||
|
|
||||||
|
|
@ -28,8 +28,8 @@ extern int luaopen_example(lua_State*L);
|
||||||
/* a really simple way of calling lua from C
|
/* a really simple way of calling lua from C
|
||||||
just give it a lua state & a string to execute
|
just give it a lua state & a string to execute
|
||||||
Unfortunately lua keeps changing its API's.
|
Unfortunately lua keeps changing its API's.
|
||||||
In lua 5.0.X its lua_dostring()
|
In lua 5.0.X it's lua_dostring()
|
||||||
In lua 5.1.X its luaL_dostring()
|
In lua 5.1.X it's luaL_dostring()
|
||||||
so we have a few extra compiles
|
so we have a few extra compiles
|
||||||
*/
|
*/
|
||||||
int dostring(lua_State *L, char* str) {
|
int dostring(lua_State *L, char* str) {
|
||||||
|
|
@ -58,11 +58,11 @@ int main(int argc,char* argv[]) {
|
||||||
luaopen_base(L);
|
luaopen_base(L);
|
||||||
luaopen_string(L);
|
luaopen_string(L);
|
||||||
luaopen_math(L);
|
luaopen_math(L);
|
||||||
printf("[C] now loading the SWIG wrappered library\n");
|
printf("[C] now loading the SWIG wrapped library\n");
|
||||||
luaopen_example(L);
|
luaopen_example(L);
|
||||||
printf("[C] all looks ok\n");
|
printf("[C] all looks ok\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C] lets load the file 'runme.lua'\n");
|
printf("[C] let's load the file 'runme.lua'\n");
|
||||||
printf("[C] any lua code in this file will be executed\n");
|
printf("[C] any lua code in this file will be executed\n");
|
||||||
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||||
printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
|
printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
|
||||||
|
|
@ -70,16 +70,16 @@ int main(int argc,char* argv[]) {
|
||||||
}
|
}
|
||||||
printf("[C] We are now back in C, all looks ok\n");
|
printf("[C] We are now back in C, all looks ok\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C] lets call the function 'do_tests()'\n");
|
printf("[C] let's call the function 'do_tests()'\n");
|
||||||
ok=dostring(L,"do_tests()");
|
ok=dostring(L,"do_tests()");
|
||||||
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C] Lets call lua again, but create an error\n");
|
printf("[C] Let's call lua again, but create an error\n");
|
||||||
ok=dostring(L,"no_such_function()");
|
ok=dostring(L,"no_such_function()");
|
||||||
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
printf("[C] We are back in C, the dostring() function returned %d\n",ok);
|
||||||
printf("[C] it should also have returned 1 and printed an error message\n");
|
printf("[C] it should also have returned 1 and printed an error message\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C] Lets call lua again, calling the greeting function\n");
|
printf("[C] Let's call lua again, calling the greeting function\n");
|
||||||
ok=dostring(L,"call_greeting()");
|
ok=dostring(L,"call_greeting()");
|
||||||
printf("[C] This was C=>Lua=>C (getting a bit complex)\n");
|
printf("[C] This was C=>Lua=>C (getting a bit complex)\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
print "[lua] This is runme.lua"
|
print "[lua] This is runme.lua"
|
||||||
-- test program for embeded lua
|
-- test program for embedded lua
|
||||||
-- we do not need to load the library, as it was already in the intrepreter
|
-- we do not need to load the library, as it was already in the interpreter
|
||||||
-- but lets check anyway
|
-- but let's check anyway
|
||||||
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
||||||
|
|
||||||
-- a test function to run the tests
|
-- a test function to run the tests
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
/* embed2.c some more test for an embeded interpreter
|
/* embed2.c some more tests for an embedded interpreter
|
||||||
|
|
||||||
This will go a bit further as it will pass values to and from the lua code.
|
This will go a bit further as it will pass values to and from the lua code.
|
||||||
It uses less of the SWIG code, and more of the raw lua API's
|
It uses less of the SWIG code, and more of the raw lua API's
|
||||||
|
|
||||||
What it will do is load the wrappered lib, load runme.lua and then call some functions.
|
What it will do is load the wrapped lib, load runme.lua and then call some functions.
|
||||||
To make life easier, all the printf's have either [C] or [Lua] at the start
|
To make life easier, all the printf's have either [C] or [Lua] at the start
|
||||||
so you can see where they are coming from.
|
so you can see where they are coming from.
|
||||||
|
|
||||||
|
|
@ -35,12 +35,12 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua
|
||||||
#define lua_open luaL_newstate
|
#define lua_open luaL_newstate
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the SWIG wrappered library */
|
/* the SWIG wrapped library */
|
||||||
extern int luaopen_example(lua_State*L);
|
extern int luaopen_example(lua_State*L);
|
||||||
|
|
||||||
/* This is an example of how to call the Lua function
|
/* This is an example of how to call the Lua function
|
||||||
int add(int,int)
|
int add(int,int)
|
||||||
its very tedious, but gives you an idea of the issues involded.
|
its very tedious, but gives you an idea of the issues involved.
|
||||||
(look below for a better idea)
|
(look below for a better idea)
|
||||||
*/
|
*/
|
||||||
int call_add(lua_State *L,int a,int b,int* res) {
|
int call_add(lua_State *L,int a,int b,int* res) {
|
||||||
|
|
@ -78,7 +78,7 @@ int call_add(lua_State *L,int a,int b,int* res) {
|
||||||
Original Code from Programming in Lua (PIL) by Roberto Ierusalimschy
|
Original Code from Programming in Lua (PIL) by Roberto Ierusalimschy
|
||||||
ISBN 85-903798-1-7
|
ISBN 85-903798-1-7
|
||||||
http://www.lua.org/pil/25.3.html
|
http://www.lua.org/pil/25.3.html
|
||||||
This has been modified slightly to make it compile, and its still a bit rough.
|
This has been modified slightly to make it compile, and it's still a bit rough.
|
||||||
But it gives the idea of how to make it work.
|
But it gives the idea of how to make it work.
|
||||||
*/
|
*/
|
||||||
int call_va (lua_State *L,const char *func, const char *sig, ...) {
|
int call_va (lua_State *L,const char *func, const char *sig, ...) {
|
||||||
|
|
@ -189,7 +189,7 @@ int main(int argc,char* argv[]) {
|
||||||
luaopen_example(L);
|
luaopen_example(L);
|
||||||
printf("[C] all looks ok\n");
|
printf("[C] all looks ok\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C] lets load the file 'runme.lua'\n");
|
printf("[C] let's load the file 'runme.lua'\n");
|
||||||
printf("[C] any lua code in this file will be executed\n");
|
printf("[C] any lua code in this file will be executed\n");
|
||||||
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||||
printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
|
printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
|
||||||
|
|
@ -197,12 +197,12 @@ int main(int argc,char* argv[]) {
|
||||||
}
|
}
|
||||||
printf("[C] We are now back in C, all looks ok\n");
|
printf("[C] We are now back in C, all looks ok\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C] lets call the Lua function 'add(1,1)'\n");
|
printf("[C] let's call the Lua function 'add(1,1)'\n");
|
||||||
printf("[C] using the C function 'call_add'\n");
|
printf("[C] using the C function 'call_add'\n");
|
||||||
ok=call_add(L,1,1,&res);
|
ok=call_add(L,1,1,&res);
|
||||||
printf("[C] the function returned %d with value %d\n",ok,res);
|
printf("[C] the function returned %d with value %d\n",ok,res);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C] lets do this rather easier\n");
|
printf("[C] let's do this rather easier\n");
|
||||||
printf("[C] we will call the same Lua function using a generic C function 'call_va'\n");
|
printf("[C] we will call the same Lua function using a generic C function 'call_va'\n");
|
||||||
ok=call_va(L,"add","ii>i",1,1,&res);
|
ok=call_va(L,"add","ii>i",1,1,&res);
|
||||||
printf("[C] the function returned %d with value %d\n",ok,res);
|
printf("[C] the function returned %d with value %d\n",ok,res);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
print "[lua] This is runme.lua"
|
print "[lua] This is runme.lua"
|
||||||
-- test program for embeded lua
|
-- test program for embedded lua
|
||||||
-- we do not need to load the library, as it was already in the intrepreter
|
-- we do not need to load the library, as it was already in the interpreter
|
||||||
-- but lets check anyway
|
-- but let's check anyway
|
||||||
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
||||||
|
|
||||||
-- note: we will copy the functions from example table into global
|
-- note: we will copy the functions from example table into global
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* embed3.cpp A C++ embeded interpreter
|
/* embed3.cpp A C++ embedded interpreter
|
||||||
|
|
||||||
This will register a C++ class with Lua, and then call a Lua function
|
This will register a C++ class with Lua, and then call a Lua function
|
||||||
passing C++ objects to this function.
|
passing C++ objects to this function.
|
||||||
|
|
@ -33,12 +33,12 @@ extern "C" {
|
||||||
|
|
||||||
/* The SWIG external runtime is generated by using.
|
/* The SWIG external runtime is generated by using.
|
||||||
swig -lua -externalruntime swigluarun.h
|
swig -lua -externalruntime swigluarun.h
|
||||||
It contains useful function used by SWIG in its wrappering
|
It contains useful function used by SWIG in its wrapper
|
||||||
SWIG_TypeQuery() SWIG_NewPointerObj()
|
SWIG_TypeQuery() SWIG_NewPointerObj()
|
||||||
*/
|
*/
|
||||||
#include "swigluarun.h" // the SWIG external runtime
|
#include "swigluarun.h" // the SWIG external runtime
|
||||||
|
|
||||||
/* the SWIG wrappered library */
|
/* the SWIG wrapped library */
|
||||||
extern "C" int luaopen_example(lua_State*L);
|
extern "C" int luaopen_example(lua_State*L);
|
||||||
|
|
||||||
// the code itself
|
// the code itself
|
||||||
|
|
@ -100,10 +100,10 @@ int main(int argc, char* argv[]) {
|
||||||
luaopen_example(L);
|
luaopen_example(L);
|
||||||
printf("[C++] all looks ok\n");
|
printf("[C++] all looks ok\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("[C++] lets create an Engine and pass a pointer to Lua\n");
|
printf("[C++] let's create an Engine and pass a pointer to Lua\n");
|
||||||
Engine engine;
|
Engine engine;
|
||||||
/* this code will pass a pointer into lua, but C++ still owns the object
|
/* this code will pass a pointer into lua, but C++ still owns the object
|
||||||
this is a little tedious, to do, but lets do it
|
this is a little tedious, to do, but let's do it
|
||||||
we need to pass the pointer (obviously), the type name
|
we need to pass the pointer (obviously), the type name
|
||||||
and a flag which states if Lua should delete the pointer once its finished with it
|
and a flag which states if Lua should delete the pointer once its finished with it
|
||||||
The type name is a class name string which is registered with SWIG
|
The type name is a class name string which is registered with SWIG
|
||||||
|
|
@ -113,7 +113,7 @@ int main(int argc, char* argv[]) {
|
||||||
push_pointer(L,&engine,"Engine *",0);
|
push_pointer(L,&engine,"Engine *",0);
|
||||||
lua_setglobal(L, "pEngine"); // set as global variable
|
lua_setglobal(L, "pEngine"); // set as global variable
|
||||||
|
|
||||||
printf("[C++] now lets load the file 'runme.lua'\n");
|
printf("[C++] now let's load the file 'runme.lua'\n");
|
||||||
printf("[C++] any lua code in this file will be executed\n");
|
printf("[C++] any lua code in this file will be executed\n");
|
||||||
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||||
printf("[C++] ERROR: cannot run lua file: %s", lua_tostring(L, -1));
|
printf("[C++] ERROR: cannot run lua file: %s", lua_tostring(L, -1));
|
||||||
|
|
@ -122,7 +122,7 @@ int main(int argc, char* argv[]) {
|
||||||
printf("[C++] We are now back in C++, all looks ok\n");
|
printf("[C++] We are now back in C++, all looks ok\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("[C++] Lets call the Lua function onEvent(e)\n");
|
printf("[C++] Let's call the Lua function onEvent(e)\n");
|
||||||
printf("[C++] We will give it different events, as we wish\n");
|
printf("[C++] We will give it different events, as we wish\n");
|
||||||
printf("[C++] Starting with STARTUP\n");
|
printf("[C++] Starting with STARTUP\n");
|
||||||
Event ev;
|
Event ev;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* We also want to pass some events to Lua, so lets have a few classes
|
/* We also want to pass some events to Lua, so let's have a few classes
|
||||||
to do this.
|
to do this.
|
||||||
*/
|
*/
|
||||||
class Event
|
class Event
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
print "[lua] This is runme.lua"
|
print "[lua] This is runme.lua"
|
||||||
-- test program for embeded lua
|
-- test program for embedded lua
|
||||||
-- we do not need to load the library, as it was already in the intrepreter
|
-- we do not need to load the library, as it was already in the interpreter
|
||||||
-- but lets check anyway
|
-- but let's check anyway
|
||||||
|
|
||||||
assert(type(example)=='table',"Don't appear to have loaded the example module. Do not run this file directly, run the embed3 executable")
|
assert(type(example)=='table',"Don't appear to have loaded the example module. Do not run this file directly, run the embed3 executable")
|
||||||
|
|
||||||
|
|
@ -13,12 +13,12 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- the embed program expects a function void onEvent(Event)
|
-- the embedded program expects a function void onEvent(Event)
|
||||||
-- this is it
|
-- this is it
|
||||||
|
|
||||||
function onEvent(e)
|
function onEvent(e)
|
||||||
print("[Lua] onEvent with event",e.mType)
|
print("[Lua] onEvent with event",e.mType)
|
||||||
-- lets do something with the Engine
|
-- let's do something with the Engine
|
||||||
-- nothing clever, but ...
|
-- nothing clever, but ...
|
||||||
if e.mType==example.Event_STARTUP then
|
if e.mType==example.Event_STARTUP then
|
||||||
pEngine:start()
|
pEngine:start()
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ function b()
|
||||||
t:message()
|
t:message()
|
||||||
end
|
end
|
||||||
print [[
|
print [[
|
||||||
Now lets call function a()
|
Now let's call function a()
|
||||||
which calls b()
|
which calls b()
|
||||||
which calls into C++
|
which calls into C++
|
||||||
which will throw an exception!]]
|
which will throw an exception!]]
|
||||||
|
|
@ -80,7 +80,7 @@ if ok then
|
||||||
else
|
else
|
||||||
print(" call failed with error:",res)
|
print(" call failed with error:",res)
|
||||||
end
|
end
|
||||||
print "Now lets do the same using xpcall(a,debug.traceback)"
|
print "Now let's do the same using xpcall(a,debug.traceback)"
|
||||||
ok,res=xpcall(a,debug.traceback)
|
ok,res=xpcall(a,debug.traceback)
|
||||||
if ok then
|
if ok then
|
||||||
print " that worked! Funny"
|
print " that worked! Funny"
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,15 @@ else
|
||||||
require('example')
|
require('example')
|
||||||
end
|
end
|
||||||
|
|
||||||
print "ok, lets test Lua's ownership of C++ objects"
|
print "ok, let's test Lua's ownership of C++ objects"
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
||||||
|
|
||||||
print "\nLets make a couple"
|
print "\nLet's make a couple"
|
||||||
a=example.Square(10)
|
a=example.Square(10)
|
||||||
b=example.Circle(1)
|
b=example.Circle(1)
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 2)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 2)")
|
||||||
|
|
||||||
print "\nNote lets use the createX functions"
|
print "\nNote let's use the createX functions"
|
||||||
c=example.createCircle(5)
|
c=example.createCircle(5)
|
||||||
d=example.createSquare(3)
|
d=example.createSquare(3)
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
|
||||||
|
|
@ -26,12 +26,12 @@ print "\nWe will run the garbage collector & see if they are till here"
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 4)")
|
||||||
|
|
||||||
print "\nLets get rid of them all, collect garbage & see if they are till here"
|
print "\nLet's get rid of them all, collect garbage & see if they are till here"
|
||||||
a,b,c,d=nil,nil,nil,nil
|
a,b,c,d=nil,nil,nil,nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
||||||
|
|
||||||
print "\nLets start putting stuff into the ShapeOwner"
|
print "\nLet's start putting stuff into the ShapeOwner"
|
||||||
print "The ShapeOwner now owns the shapes, but Lua still has pointers to them"
|
print "The ShapeOwner now owns the shapes, but Lua still has pointers to them"
|
||||||
o=example.ShapeOwner()
|
o=example.ShapeOwner()
|
||||||
a=example.Square(10)
|
a=example.Square(10)
|
||||||
|
|
@ -41,7 +41,7 @@ o:add(b)
|
||||||
o:add(example.createSquare(5))
|
o:add(example.createSquare(5))
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 3)")
|
||||||
|
|
||||||
print "\nWe will nil our references,run the garbage collector & see if they are till here"
|
print "\nWe will nil our references,run the garbage collector & see if they are still here"
|
||||||
print "they should be, as the ShapeOwner owns them"
|
print "they should be, as the ShapeOwner owns them"
|
||||||
a,b=nil,nil
|
a,b=nil,nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
|
|
@ -101,4 +101,4 @@ print "done"
|
||||||
o,sh=nil,nil
|
o,sh=nil,nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
print("Currently there are",example.Shape_nshapes,"shapes (there should be 0)")
|
||||||
print "thats all folks!"
|
print "that's all folks!"
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,3 @@ clean:
|
||||||
Example.class: Example.java
|
Example.class: Example.java
|
||||||
gcj -fPIC -C -c -g Example.java
|
gcj -fPIC -C -c -g Example.java
|
||||||
gcjh Example
|
gcjh Example
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,3 @@ clean:
|
||||||
Example.class: Example.java
|
Example.class: Example.java
|
||||||
gcj -fPIC -C -c -g Example.java
|
gcj -fPIC -C -c -g Example.java
|
||||||
gcjh Example
|
gcjh Example
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,3 @@ run:
|
||||||
Example.class: Example.java
|
Example.class: Example.java
|
||||||
gcj -fPIC -C -c -g Example.java
|
gcj -fPIC -C -c -g Example.java
|
||||||
gcjh Example
|
gcjh Example
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,7 @@ CPP_TEST_CASES += \
|
||||||
disown \
|
disown \
|
||||||
dynamic_cast \
|
dynamic_cast \
|
||||||
empty \
|
empty \
|
||||||
|
enum_ignore \
|
||||||
enum_plus \
|
enum_plus \
|
||||||
enum_rename \
|
enum_rename \
|
||||||
enum_scope_template \
|
enum_scope_template \
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,14 @@ public:
|
||||||
int operator<<(ABC &) { return 0; }
|
int operator<<(ABC &) { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DEF {
|
||||||
|
public:
|
||||||
|
int a;
|
||||||
|
int operator<<(DEF &) { return 0; }
|
||||||
|
int operator>>(DEF &) { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class ABC2 {
|
class ABC2 {
|
||||||
public:
|
public:
|
||||||
|
|
@ -37,3 +45,9 @@ public:
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
// Test shifts are still working
|
||||||
|
%inline %{
|
||||||
|
int shift_init1 = 4 << 2 >> 1;
|
||||||
|
int shift_init2 = 4 >> 2 << 1 << 1 >> 2;
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,19 @@ class Foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
int (Foo::*func_ptr)(int);
|
int (Foo::*func_ptr)(int);
|
||||||
|
|
||||||
|
const char* __str__() const { return "Foo"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class FooSub : public Foo {
|
||||||
|
public:
|
||||||
|
FooSub() :Foo(42) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class FooSubSub : public FooSub {
|
||||||
|
public:
|
||||||
|
FooSubSub() : FooSub() {}
|
||||||
|
const char* __str__() const { return "FooSubSub"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ void main() {
|
||||||
assert(-a == a);
|
assert(-a == a);
|
||||||
assert(-b == new Op(-5));
|
assert(-b == new Op(-5));
|
||||||
|
|
||||||
// Unfortunaly, there is no way to override conversion to boolean for
|
// Unfortunately, there is no way to override conversion to boolean for
|
||||||
// classes in D, opCast!("bool") is only used for structs.
|
// classes in D, opCast!("bool") is only used for structs.
|
||||||
|
|
||||||
// test []
|
// test []
|
||||||
|
|
|
||||||
20
Examples/test-suite/enum_ignore.i
Normal file
20
Examples/test-suite/enum_ignore.i
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
%module enum_ignore
|
||||||
|
|
||||||
|
// Similar to enum_missing C test, but with namespaces and using %ignore
|
||||||
|
|
||||||
|
%ignore N::C;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
namespace N {
|
||||||
|
enum C { Red, Green, Blue };
|
||||||
|
|
||||||
|
struct Draw {
|
||||||
|
void DrawBW() {}
|
||||||
|
void DrawC(C c) {}
|
||||||
|
void DrawC_Ptr(C* c) {}
|
||||||
|
void DrawC_ConstRef(C const& c) {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
6
Examples/test-suite/errors/cpp_extra_brackets.i
Normal file
6
Examples/test-suite/errors/cpp_extra_brackets.i
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
%module cpp_extra_brackets
|
||||||
|
|
||||||
|
// Extra brackets was segfaulting in SWIG-3.0.0
|
||||||
|
struct ABC {
|
||||||
|
int operator<<(ABC &))) { return 0; }
|
||||||
|
};
|
||||||
1
Examples/test-suite/errors/cpp_extra_brackets.stderr
Normal file
1
Examples/test-suite/errors/cpp_extra_brackets.stderr
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
cpp_extra_brackets.i:5: Error: Syntax error in input(3).
|
||||||
9
Examples/test-suite/errors/cpp_extra_brackets2.i
Normal file
9
Examples/test-suite/errors/cpp_extra_brackets2.i
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
%module cpp_extra_brackets
|
||||||
|
|
||||||
|
// Extra brackets was segfaulting in SWIG-3.0.0
|
||||||
|
struct ABC {
|
||||||
|
;
|
||||||
|
)))
|
||||||
|
int operator<<(ABC &) { return 0; }
|
||||||
|
int operator>>(ABC &) { return 0; }
|
||||||
|
};
|
||||||
1
Examples/test-suite/errors/cpp_extra_brackets2.stderr
Normal file
1
Examples/test-suite/errors/cpp_extra_brackets2.stderr
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
cpp_extra_brackets2.i:6: Error: Syntax error in input(3).
|
||||||
33
Examples/test-suite/java/cpp11_constexpr_runme.java
Normal file
33
Examples/test-suite/java/cpp11_constexpr_runme.java
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
import cpp11_constexpr.*;
|
||||||
|
|
||||||
|
public class cpp11_constexpr_runme {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("cpp11_constexpr");
|
||||||
|
} catch (UnsatisfiedLinkError e) {
|
||||||
|
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void check(int received, int expected) {
|
||||||
|
if (expected != received)
|
||||||
|
throw new RuntimeException("check failed, expected: " + expected + " received: " + received);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String argv[])
|
||||||
|
{
|
||||||
|
check(cpp11_constexpr.getAAA(), 10);
|
||||||
|
check(cpp11_constexpr.getBBB(), 20);
|
||||||
|
check(cpp11_constexpr.CCC(), 30);
|
||||||
|
check(cpp11_constexpr.DDD(), 40);
|
||||||
|
|
||||||
|
ConstExpressions ce = new ConstExpressions();
|
||||||
|
check(ce.JJJ, 100);
|
||||||
|
check(ce.KKK, 200);
|
||||||
|
check(ce.LLL, 300);
|
||||||
|
check(ce.MMM(), 400);
|
||||||
|
check(ce.NNN(), 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ lua_no_module_global.%: SWIGOPT += -nomoduleglobal
|
||||||
# a file is found which has _runme.lua appended after the testcase name.
|
# a file is found which has _runme.lua appended after the testcase name.
|
||||||
run_testcase = \
|
run_testcase = \
|
||||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
env LUA_PATH="$(srcdir)/?.lua;" $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean: (does nothing, we dont generate extra lua code)
|
# Clean: (does nothing, we dont generate extra lua code)
|
||||||
|
|
|
||||||
|
|
@ -76,3 +76,13 @@ assert(cb.test_func_ptr(f,2)==-8)
|
||||||
|
|
||||||
-- Test that __tostring metamethod produce no internal asserts
|
-- Test that __tostring metamethod produce no internal asserts
|
||||||
f2_name = tostring(f2)
|
f2_name = tostring(f2)
|
||||||
|
|
||||||
|
f3 = cb.FooSub()
|
||||||
|
f3_name = tostring(f3)
|
||||||
|
|
||||||
|
f4 = cb.FooSubSub()
|
||||||
|
f4_name = tostring(f4)
|
||||||
|
|
||||||
|
assert( f2_name == "Foo" )
|
||||||
|
assert( f3_name == "Foo" )
|
||||||
|
assert( f4_name == "FooSubSub" )
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,38 @@ assert(i(1,2)==6)
|
||||||
assert(tostring(Op(1))=="Op(1)")
|
assert(tostring(Op(1))=="Op(1)")
|
||||||
assert(tostring(Op(-3))=="Op(-3)")
|
assert(tostring(Op(-3))=="Op(-3)")
|
||||||
|
|
||||||
|
|
||||||
|
-- check that operator overloads are correctly propogated down inheritance hierarchy
|
||||||
|
|
||||||
|
a_d=OpDerived()
|
||||||
|
b_d=OpDerived(5)
|
||||||
|
c_d=OpDerived(5)
|
||||||
|
d_d=OpDerived(2)
|
||||||
|
-- test equality
|
||||||
|
assert(a_d~=b_d)
|
||||||
|
assert(b_d==c_d)
|
||||||
|
assert(a_d~=d_d)
|
||||||
|
|
||||||
|
-- test <
|
||||||
|
assert(a_d<b_d)
|
||||||
|
assert(a_d<=b_d)
|
||||||
|
assert(b_d<=c_d)
|
||||||
|
assert(b_d>=c_d)
|
||||||
|
assert(b_d>d_d)
|
||||||
|
assert(b_d>=d_d)
|
||||||
|
--
|
||||||
|
-- test + inheritance
|
||||||
|
f_d=OpDerived(1)
|
||||||
|
g_d=OpDerived(1)
|
||||||
|
assert(f_d+g_d==Op(2))
|
||||||
|
assert(f_d-g_d==Op(0))
|
||||||
|
assert(f_d*g_d==Op(1))
|
||||||
|
assert(f_d/g_d==Op(1))
|
||||||
|
--
|
||||||
|
-- plus add some code to check the __str__ fn inheritance
|
||||||
|
assert(tostring(OpDerived(1))=="Op(1)")
|
||||||
|
assert(tostring(OpDerived(-3))=="Op(-3)")
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
/* Sample test code in C++
|
/* Sample test code in C++
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ include $(srcdir)/../common.mk
|
||||||
|
|
||||||
# Overridden variables here
|
# Overridden variables here
|
||||||
LIBS = -L.
|
LIBS = -L.
|
||||||
CSRCS = octave_empty.c
|
CSRCS = $(srcdir)/octave_empty.c
|
||||||
|
|
||||||
# Custom tests - tests with additional commandline options
|
# Custom tests - tests with additional commandline options
|
||||||
# none!
|
# none!
|
||||||
|
|
|
||||||
|
|
@ -230,10 +230,10 @@ __rshift__,__lshift__ >>,<<
|
||||||
|
|
||||||
__getitem__,__setitem__ for operator[]
|
__getitem__,__setitem__ for operator[]
|
||||||
|
|
||||||
Operators overloaded without C++ equivilents
|
Operators overloaded without C++ equivalents
|
||||||
__pow__ for power operator
|
__pow__ for power operator
|
||||||
__str__ converts object to a string (should return a const char*)
|
__str__ converts object to a string (should return a const char*)
|
||||||
__concat__ for contatenation (if language supports)
|
__concat__ for concatenation (if language supports)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ check::classname(simplestruct,$ss);
|
||||||
$as=new arraystruct();
|
$as=new arraystruct();
|
||||||
$as->array_c="abc";
|
$as->array_c="abc";
|
||||||
check::equal($as->array_c,"a",'$as->array_c=="a"');
|
check::equal($as->array_c,"a",'$as->array_c=="a"');
|
||||||
|
check::equal(isset($as->array_const_i),TRUE,'isset($as->array_const_i)');
|
||||||
|
|
||||||
check::done();
|
check::done();
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
35
Examples/test-suite/python/global_vars_runme.py
Normal file
35
Examples/test-suite/python/global_vars_runme.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import global_vars
|
||||||
|
|
||||||
|
global_vars.init()
|
||||||
|
b = global_vars.cvar.b
|
||||||
|
if b != "string b":
|
||||||
|
raise RuntimeError("Unexpected string: " + b)
|
||||||
|
global_vars.cvar.b = "a string value"
|
||||||
|
b = global_vars.cvar.b
|
||||||
|
if b != "a string value":
|
||||||
|
raise RuntimeError("Unexpected string: " + b)
|
||||||
|
|
||||||
|
x = global_vars.cvar.x
|
||||||
|
if x != 1234:
|
||||||
|
raise RuntimeError("Unexpected x: " + str(x))
|
||||||
|
global_vars.cvar.x = 9876
|
||||||
|
x = global_vars.cvar.x
|
||||||
|
if x != 9876:
|
||||||
|
raise RuntimeError("Unexpected string: " + str(x))
|
||||||
|
|
||||||
|
fail = True
|
||||||
|
try:
|
||||||
|
global_vars.cvar.notexist = "something"
|
||||||
|
except AttributeError, e:
|
||||||
|
fail = False
|
||||||
|
if fail:
|
||||||
|
raise RuntimeError("AttributeError should have been thrown")
|
||||||
|
|
||||||
|
fail = True
|
||||||
|
try:
|
||||||
|
g = global_vars.cvar.notexist
|
||||||
|
except AttributeError, e:
|
||||||
|
fail = False
|
||||||
|
if fail:
|
||||||
|
raise RuntimeError("AttributeError should have been thrown")
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#ifdef SWIGPHP
|
#ifdef SWIGPHP
|
||||||
%{
|
%{
|
||||||
#include "zend_exceptions.h"
|
#include "zend_exceptions.h"
|
||||||
#define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); }
|
#define SWIG_exception(code, msg) zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC)
|
||||||
%}
|
%}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,6 @@ extern "C" {
|
||||||
/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
|
/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
|
||||||
extern imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom);
|
extern imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom);
|
||||||
|
|
||||||
/* Like `strtol' but convert to `intmax_t'. */
|
|
||||||
extern intmax_t strtoimax (const char *nptr, char **endptr, int base);
|
|
||||||
|
|
||||||
/* Like `strtoul' but convert to `uintmax_t'. */
|
|
||||||
extern uintmax_t strtoumax (const char *nptr, char ** endptr, int base);
|
|
||||||
|
|
||||||
#ifdef SWIG_WCHAR
|
#ifdef SWIG_WCHAR
|
||||||
/* Like `wcstol' but convert to `intmax_t'. */
|
/* Like `wcstol' but convert to `intmax_t'. */
|
||||||
extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base);
|
extern intmax_t wcstoimax (const wchar_t *nptr, wchar_t **endptr, int base);
|
||||||
|
|
@ -84,7 +78,7 @@ extern "C" {
|
||||||
extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base);
|
extern uintmax_t wcstoumax (const wchar_t *nptr, wchar_t **endptr, int base);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* SWIGWORDSIZE32 */
|
#endif /* SWIGWORDSIZE64 */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -332,6 +332,11 @@ typedef struct {
|
||||||
lua_pushcfunction(L, f), \
|
lua_pushcfunction(L, f), \
|
||||||
lua_rawset(L,-3))
|
lua_rawset(L,-3))
|
||||||
|
|
||||||
|
#define SWIG_Lua_add_boolean(L,n,b) \
|
||||||
|
(lua_pushstring(L, n), \
|
||||||
|
lua_pushboolean(L, b), \
|
||||||
|
lua_rawset(L,-3))
|
||||||
|
|
||||||
/* special helper for allowing 'nil' for usertypes */
|
/* special helper for allowing 'nil' for usertypes */
|
||||||
#define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))
|
#define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))
|
||||||
|
|
||||||
|
|
@ -402,7 +407,7 @@ SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_ent
|
||||||
lua_rawsetp(L, parsed_tables_array, table);
|
lua_rawsetp(L, parsed_tables_array, table);
|
||||||
int i;
|
int i;
|
||||||
int table_parsed = 0;
|
int table_parsed = 0;
|
||||||
int pairs_start = lua_gettop(L);
|
const int SWIGUNUSED pairs_start = lua_gettop(L);
|
||||||
for(i = 0;table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL;i++)
|
for(i = 0;table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL;i++)
|
||||||
{
|
{
|
||||||
const swig_elua_entry *entry = table + i;
|
const swig_elua_entry *entry = table + i;
|
||||||
|
|
@ -646,7 +651,7 @@ SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace
|
||||||
SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg)
|
SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg)
|
||||||
{
|
{
|
||||||
/* 1 argument - table on the top of the stack */
|
/* 1 argument - table on the top of the stack */
|
||||||
int begin = lua_gettop(L);
|
const int SWIGUNUSED begin = lua_gettop(L);
|
||||||
assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */
|
assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */
|
||||||
lua_checkstack(L,5);
|
lua_checkstack(L,5);
|
||||||
lua_newtable(L); /* namespace itself */
|
lua_newtable(L); /* namespace itself */
|
||||||
|
|
@ -703,10 +708,11 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);
|
||||||
/* Macros for iteration among class bases */
|
/* Macros for iteration among class bases */
|
||||||
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
|
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
|
||||||
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
|
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
|
||||||
|
(void)swig_type;\
|
||||||
SWIG_Lua_get_table(L,".bases");\
|
SWIG_Lua_get_table(L,".bases");\
|
||||||
assert(lua_istable(L,-1));\
|
assert(lua_istable(L,-1));\
|
||||||
bases_count = lua_rawlen(L,-1);\
|
bases_count = lua_rawlen(L,-1);\
|
||||||
int bases_table = lua_gettop(L);
|
const int bases_table = lua_gettop(L);
|
||||||
#define SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type, valid)\
|
#define SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type, valid)\
|
||||||
lua_rawgeti(L,bases_table,i+1);\
|
lua_rawgeti(L,bases_table,i+1);\
|
||||||
base_swig_type = 0;\
|
base_swig_type = 0;\
|
||||||
|
|
@ -716,7 +722,7 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);
|
||||||
} else\
|
} else\
|
||||||
valid = 1;
|
valid = 1;
|
||||||
|
|
||||||
#else /* en elua .bases table doesn't exist. Use table from swig_lua_class */
|
#else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
|
||||||
|
|
||||||
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
|
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
|
||||||
assert(swig_type!=0);\
|
assert(swig_type!=0);\
|
||||||
|
|
@ -741,21 +747,22 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);
|
||||||
|
|
||||||
typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret);
|
typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret);
|
||||||
|
|
||||||
SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info *swig_type, int first_arg, swig_lua_base_iterator_func func, int *const ret)
|
SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type,
|
||||||
|
int first_arg, swig_lua_base_iterator_func func, int *const ret)
|
||||||
{
|
{
|
||||||
/* first_arg - position of the object in stack. Everything that is above are arguments
|
/* first_arg - position of the object in stack. Everything that is above are arguments
|
||||||
* and is passed to every evocation of the func */
|
* and is passed to every evocation of the func */
|
||||||
int last_arg = lua_gettop(L);/* position of last argument */
|
int last_arg = lua_gettop(L);/* position of last argument */
|
||||||
lua_getmetatable(L,first_arg);
|
lua_getmetatable(L,first_arg);
|
||||||
int original_metatable = last_arg + 1;
|
int original_metatable = last_arg + 1;
|
||||||
int bases_count;
|
size_t bases_count;
|
||||||
SWIG_LUA_INIT_BASE_SEARCH(bases_count);
|
SWIG_LUA_INIT_BASE_SEARCH(bases_count);
|
||||||
int result = SWIG_ERROR;
|
int result = SWIG_ERROR;
|
||||||
if(ret)
|
if(ret)
|
||||||
*ret = 0;
|
*ret = 0;
|
||||||
if(bases_count>0)
|
if(bases_count>0)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
int j;
|
int j;
|
||||||
int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */
|
int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */
|
||||||
int valid = 1;
|
int valid = 1;
|
||||||
|
|
@ -797,7 +804,7 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info *swig_type, i
|
||||||
* It returns an error code. Number of function return values is passed inside 'ret'.
|
* It returns an error code. Number of function return values is passed inside 'ret'.
|
||||||
* first_arg is not used in this function because function always has 2 arguments.
|
* first_arg is not used in this function because function always has 2 arguments.
|
||||||
*/
|
*/
|
||||||
SWIGINTERN int SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int first_arg, int *ret)
|
SWIGINTERN int SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int SWIGUNUSED first_arg, int *ret)
|
||||||
{
|
{
|
||||||
/* there should be 2 params passed in
|
/* there should be 2 params passed in
|
||||||
(1) userdata (not the meta table)
|
(1) userdata (not the meta table)
|
||||||
|
|
@ -1015,7 +1022,51 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gets the swig class registry (or creates it) */
|
/* populate table at the top of the stack with metamethods that ought to be inherited */
|
||||||
|
SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L)
|
||||||
|
{
|
||||||
|
SWIG_Lua_add_boolean(L, "__add", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__sub", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__mul", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__div", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__mod", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__pow", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__unm", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__len", 1 );
|
||||||
|
SWIG_Lua_add_boolean(L, "__concat", 1 );
|
||||||
|
SWIG_Lua_add_boolean(L, "__eq", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__lt", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__le", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__call", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__tostring", 1);
|
||||||
|
SWIG_Lua_add_boolean(L, "__gc", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* creates the swig registry */
|
||||||
|
SWIGINTERN void SWIG_Lua_create_class_registry(lua_State *L)
|
||||||
|
{
|
||||||
|
/* create main SWIG registry table */
|
||||||
|
lua_pushstring(L,"SWIG");
|
||||||
|
lua_newtable(L);
|
||||||
|
/* populate it with some predefined data */
|
||||||
|
|
||||||
|
/* .library table. Placeholder */
|
||||||
|
lua_pushstring(L,".library");
|
||||||
|
lua_newtable(L);
|
||||||
|
{
|
||||||
|
/* list of metamethods that class inherits from its bases */
|
||||||
|
lua_pushstring(L,"inheritable_metamethods");
|
||||||
|
lua_newtable(L);
|
||||||
|
/* populate with list of metamethods */
|
||||||
|
SWIG_Lua_populate_inheritable_metamethods(L);
|
||||||
|
lua_rawset(L,-3);
|
||||||
|
}
|
||||||
|
lua_rawset(L,-3);
|
||||||
|
|
||||||
|
lua_rawset(L,LUA_REGISTRYINDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* gets the swig registry (or creates it) */
|
||||||
SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L)
|
SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L)
|
||||||
{
|
{
|
||||||
/* add this all into the swig registry: */
|
/* add this all into the swig registry: */
|
||||||
|
|
@ -1024,15 +1075,27 @@ SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L)
|
||||||
if (!lua_istable(L,-1)) /* not there */
|
if (!lua_istable(L,-1)) /* not there */
|
||||||
{ /* must be first time, so add it */
|
{ /* must be first time, so add it */
|
||||||
lua_pop(L,1); /* remove the result */
|
lua_pop(L,1); /* remove the result */
|
||||||
lua_pushstring(L,"SWIG");
|
SWIG_Lua_create_class_registry(L);
|
||||||
lua_newtable(L);
|
|
||||||
lua_rawset(L,LUA_REGISTRYINDEX);
|
|
||||||
/* then get it */
|
/* then get it */
|
||||||
lua_pushstring(L,"SWIG");
|
lua_pushstring(L,"SWIG");
|
||||||
lua_rawget(L,LUA_REGISTRYINDEX);
|
lua_rawget(L,LUA_REGISTRYINDEX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWIGINTERN void SWIG_Lua_get_inheritable_metamethods(lua_State *L)
|
||||||
|
{
|
||||||
|
SWIG_Lua_get_class_registry(L);
|
||||||
|
lua_pushstring(L, ".library");
|
||||||
|
lua_rawget(L,-2);
|
||||||
|
assert( !lua_isnil(L,-1) );
|
||||||
|
lua_pushstring(L, "inheritable_metamethods");
|
||||||
|
lua_rawget(L,-2);
|
||||||
|
|
||||||
|
/* Remove class registry and library table */
|
||||||
|
lua_remove(L,-2);
|
||||||
|
lua_remove(L,-2);
|
||||||
|
}
|
||||||
|
|
||||||
/* Helper function to get the classes metatable from the register */
|
/* Helper function to get the classes metatable from the register */
|
||||||
SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname)
|
SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname)
|
||||||
{
|
{
|
||||||
|
|
@ -1162,14 +1225,16 @@ SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State *L, swig_lua_class *
|
||||||
SWIG_Lua_add_namespace_details(L, clss->cls_static);
|
SWIG_Lua_add_namespace_details(L, clss->cls_static);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss); /* forward declaration */
|
||||||
|
|
||||||
/* helper to recursively add class details (attributes & operations) */
|
/* helper to recursively add class details (attributes & operations) */
|
||||||
SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L,swig_lua_class *clss)
|
SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
/* Add bases to .bases table */
|
/* Add bases to .bases table */
|
||||||
SWIG_Lua_get_table(L,".bases");
|
SWIG_Lua_get_table(L,".bases");
|
||||||
assert(lua_istable(L,-1)); /* just in case */
|
assert(lua_istable(L,-1)); /* just in case */
|
||||||
int bases_count = 0;
|
size_t bases_count = 0;
|
||||||
for(i=0;clss->bases[i];i++)
|
for(i=0;clss->bases[i];i++)
|
||||||
{
|
{
|
||||||
SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
|
SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
|
||||||
|
|
@ -1200,12 +1265,195 @@ SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L,swig_lua_class
|
||||||
SWIG_Lua_add_function(L,clss->metatable[i].name,clss->metatable[i].func);
|
SWIG_Lua_add_function(L,clss->metatable[i].name,clss->metatable[i].func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(SWIG_LUA_SQUASH_BASES)
|
||||||
|
/* Adding metamethods that are defined in base classes. If bases were squashed
|
||||||
|
* then it is obviously unnecessary
|
||||||
|
*/
|
||||||
|
SWIG_Lua_add_class_user_metamethods(L, clss);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Helpers to add user defined class metamedhods - __add, __sub etc. The helpers are needed
|
||||||
|
for the following issue: Lua runtime checks for metamethod existence with rawget function
|
||||||
|
ignoring our SWIG-provided __index and __newindex functions. Thus our inheritance-aware method
|
||||||
|
search algorithm doesn't work in such case. (Not to say that Lua runtime queries metamethod directly
|
||||||
|
in metatable and not in object).
|
||||||
|
Current solution is this: if somewhere in hierarchy metamethod __x is defined, then all descendants
|
||||||
|
are automatically given a special proxy __x that calls the real __x method.
|
||||||
|
Obvious idea - to copy __x instead of creating __x-proxy is wrong because if someone changes __x in runtime,
|
||||||
|
those changes must be reflected in all descendants.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration*/
|
||||||
|
|
||||||
|
/* The real function that resolves a metamethod.
|
||||||
|
* Function searches given class and all it's bases(recursively) for first instance of something that is
|
||||||
|
* not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actuall metamethod implementation
|
||||||
|
* and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the
|
||||||
|
* answer.
|
||||||
|
* Returns 1 if found, 0 otherwise.
|
||||||
|
* clss is class which metatable we will search for method
|
||||||
|
* metamethod_name_idx is index in L where metamethod name (as string) lies
|
||||||
|
* skip_check allows to skip searching metamethod in givel clss and immideatelly go to searching in bases. skip_check
|
||||||
|
* is not caried to subsequent recursive calls - false is always passed. It is set to true only at first call from
|
||||||
|
* SWIG_Lua_resolve_metamethod
|
||||||
|
* */
|
||||||
|
SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class *clss, int metamethod_name_idx,
|
||||||
|
int skip_check)
|
||||||
|
{
|
||||||
|
/* This function is called recursively */
|
||||||
|
if (!skip_check) {
|
||||||
|
SWIG_Lua_get_class_metatable(L, clss->fqname);
|
||||||
|
lua_pushvalue(L, metamethod_name_idx);
|
||||||
|
lua_rawget(L,-2);
|
||||||
|
/* If this is cfunction and it is equal to SWIG_Lua_resolve_metamethod then
|
||||||
|
* this isn't the function we are looking for :)
|
||||||
|
* lua_tocfunction will return NULL if not cfunction
|
||||||
|
*/
|
||||||
|
if (!lua_isnil(L,-1) && lua_tocfunction(L,-1) != SWIG_Lua_resolve_metamethod ) {
|
||||||
|
lua_remove(L,-2); /* removing class metatable */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lua_pop(L,2); /* remove class metatable and query result */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Forwarding calls to bases */
|
||||||
|
int result = 0;
|
||||||
|
int i = 0;
|
||||||
|
for(i=0;clss->bases[i];i++)
|
||||||
|
{
|
||||||
|
result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0);
|
||||||
|
if (result)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The proxy function for metamethod. All parameters are passed as cclosure. Searches for actual method
|
||||||
|
* and calls it */
|
||||||
|
SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_checkstack(L,5);
|
||||||
|
const int numargs = lua_gettop(L); /* number of arguments to pass to actuall metamethod */
|
||||||
|
|
||||||
|
/* Get upvalues from closure */
|
||||||
|
lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/
|
||||||
|
const int metamethod_name_idx = lua_gettop(L);
|
||||||
|
|
||||||
|
lua_pushvalue(L, lua_upvalueindex(2));
|
||||||
|
const swig_lua_class* clss = (const swig_lua_class*)(lua_touserdata(L,-1));
|
||||||
|
lua_pop(L,1); /* remove lightuserdata with clss from stack */
|
||||||
|
|
||||||
|
/* Actuall work */
|
||||||
|
const int result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1);
|
||||||
|
if (!result) {
|
||||||
|
SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actuall metamethod. Memory corruption is most likely explanation.");
|
||||||
|
lua_error(L);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_remove(L,-2); /* remove metamethod key */
|
||||||
|
lua_insert(L,1); /* move function to correct position */
|
||||||
|
lua_call(L, numargs, LUA_MULTRET);
|
||||||
|
return lua_gettop(L); /* return all results */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* If given metamethod must be present in given class, then creates appropriate proxy
|
||||||
|
* Returns 1 if successfully added, 0 if not added because no base class has it, -1
|
||||||
|
* if method is defined in the class metatable itself
|
||||||
|
*/
|
||||||
|
SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index)
|
||||||
|
{
|
||||||
|
/* metamethod name - on the top of the stack */
|
||||||
|
assert(lua_isstring(L,-1));
|
||||||
|
|
||||||
|
const int key_index = lua_gettop(L);
|
||||||
|
|
||||||
|
/* Check whether method is already defined in metatable */
|
||||||
|
lua_pushvalue(L,key_index); /* copy of the key */
|
||||||
|
lua_gettable(L,metatable_index);
|
||||||
|
if( !lua_isnil(L,-1) ) {
|
||||||
|
lua_pop(L,1);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
lua_pop(L,1);
|
||||||
|
|
||||||
|
/* Iterating over immediate bases */
|
||||||
|
int success = 0;
|
||||||
|
int i = 0;
|
||||||
|
for(i=0;clss->bases[i];i++)
|
||||||
|
{
|
||||||
|
const swig_lua_class *base = clss->bases[i];
|
||||||
|
SWIG_Lua_get_class_metatable(L, base->fqname);
|
||||||
|
lua_pushvalue(L, key_index);
|
||||||
|
lua_rawget(L, -2);
|
||||||
|
if( !lua_isnil(L,-1) ) {
|
||||||
|
lua_pushvalue(L, key_index);
|
||||||
|
|
||||||
|
/* Add proxy function */
|
||||||
|
lua_pushvalue(L, key_index); /* first closure value is function name */
|
||||||
|
lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */
|
||||||
|
lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2);
|
||||||
|
|
||||||
|
lua_rawset(L, metatable_index);
|
||||||
|
success = 1;
|
||||||
|
}
|
||||||
|
lua_pop(L,1); /* remove function or nil */
|
||||||
|
lua_pop(L,1); /* remove base class metatable */
|
||||||
|
|
||||||
|
if( success )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss)
|
||||||
|
{
|
||||||
|
SWIG_Lua_get_class_metatable(L, clss->fqname);
|
||||||
|
const int metatable_index = lua_gettop(L);
|
||||||
|
SWIG_Lua_get_inheritable_metamethods(L);
|
||||||
|
assert(lua_istable(L,-1));
|
||||||
|
const int metamethods_info_index = lua_gettop(L);
|
||||||
|
lua_pushnil(L); /* first key */
|
||||||
|
while(lua_next(L, metamethods_info_index) != 0 ) {
|
||||||
|
/* key at index -2, value at index -1 */
|
||||||
|
const int is_inheritable = lua_toboolean(L,-2);
|
||||||
|
lua_pop(L,1); /* remove value - we don't need it anymore */
|
||||||
|
|
||||||
|
if(is_inheritable) { /* if metamethod is inheritable */
|
||||||
|
SWIG_Lua_add_class_user_metamethod(L,clss,metatable_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_pop(L,1); /* remove inheritable metatmethods table */
|
||||||
|
|
||||||
|
/* Special handling for __tostring method */
|
||||||
|
lua_pushstring(L, "__tostring");
|
||||||
|
lua_pushvalue(L,-1);
|
||||||
|
lua_rawget(L,metatable_index);
|
||||||
|
const int tostring_undefined = lua_isnil(L,-1);
|
||||||
|
lua_pop(L,1);
|
||||||
|
if( tostring_undefined ) {
|
||||||
|
lua_pushcfunction(L, SWIG_Lua_class_tostring);
|
||||||
|
lua_rawset(L, metatable_index);
|
||||||
|
} else {
|
||||||
|
lua_pop(L,1); /* remove copy of the key */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Warning: __index and __newindex are SWIG-defined. For user-defined operator[]
|
||||||
|
* a __getitem/__setitem method should be defined
|
||||||
|
*/
|
||||||
|
lua_pop(L,1); /* pop class metatable */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register class static methods,attributes etc as well as constructor proxy */
|
/* Register class static methods,attributes etc as well as constructor proxy */
|
||||||
SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *clss)
|
SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *clss)
|
||||||
{
|
{
|
||||||
int begin = lua_gettop(L);
|
const int SWIGUNUSED begin = lua_gettop(L);
|
||||||
lua_checkstack(L,5); /* just in case */
|
lua_checkstack(L,5); /* just in case */
|
||||||
assert(lua_istable(L,-1)); /* just in case */
|
assert(lua_istable(L,-1)); /* just in case */
|
||||||
assert(strcmp(clss->name, clss->cls_static->name) == 0); /* in class those 2 must be equal */
|
assert(strcmp(clss->name, clss->cls_static->name) == 0); /* in class those 2 must be equal */
|
||||||
|
|
@ -1239,7 +1487,7 @@ SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *cls
|
||||||
*/
|
*/
|
||||||
SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss)
|
SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss)
|
||||||
{
|
{
|
||||||
int begin = lua_gettop(L);
|
const int SWIGUNUSED begin = lua_gettop(L);
|
||||||
/* if name already there (class is already registered) then do nothing */
|
/* if name already there (class is already registered) then do nothing */
|
||||||
SWIG_Lua_get_class_registry(L); /* get the registry */
|
SWIG_Lua_get_class_registry(L); /* get the registry */
|
||||||
lua_pushstring(L,clss->fqname); /* get the name */
|
lua_pushstring(L,clss->fqname); /* get the name */
|
||||||
|
|
@ -1265,11 +1513,11 @@ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *c
|
||||||
* It would get us all special methods: __getitem, __add etc.
|
* It would get us all special methods: __getitem, __add etc.
|
||||||
* This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away
|
* This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away
|
||||||
*/
|
*/
|
||||||
int new_metatable_index = lua_absindex(L,-1);
|
const int new_metatable_index = lua_absindex(L,-1);
|
||||||
for(i=0;clss->bases[i];i++)
|
for(i=0;clss->bases[i];i++)
|
||||||
{
|
{
|
||||||
SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
|
SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
|
||||||
int base_metatable = lua_absindex(L,-1);
|
const int base_metatable = lua_absindex(L,-1);
|
||||||
SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
|
SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
}
|
}
|
||||||
|
|
@ -1301,12 +1549,10 @@ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *c
|
||||||
SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get);
|
SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get);
|
||||||
SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set);
|
SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set);
|
||||||
SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct);
|
SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct);
|
||||||
/* add tostring method for better output */
|
|
||||||
SWIG_Lua_add_function(L,"__tostring",SWIG_Lua_class_tostring);
|
|
||||||
/* add it */
|
/* add it */
|
||||||
lua_rawset(L,-3); /* metatable into registry */
|
lua_rawset(L,-3); /* metatable into registry */
|
||||||
lua_pop(L,1); /* tidy stack (remove registry) */
|
lua_pop(L,1); /* tidy stack (remove registry) */
|
||||||
assert(lua_gettop(L)==begin);
|
assert(lua_gettop(L) == begin);
|
||||||
|
|
||||||
#if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
|
#if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
|
||||||
/* Now merge all symbols from .fn, .set, .get etc from bases to our tables */
|
/* Now merge all symbols from .fn, .set, .get etc from bases to our tables */
|
||||||
|
|
@ -1334,7 +1580,7 @@ SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss)
|
||||||
* | ".set" --> ....
|
* | ".set" --> ....
|
||||||
* |=============================== ".instance"
|
* |=============================== ".instance"
|
||||||
*/
|
*/
|
||||||
int begin = lua_gettop(L);
|
const int SWIGUNUSED begin = lua_gettop(L);
|
||||||
lua_pushstring(L,clss->cls_static->name);
|
lua_pushstring(L,clss->cls_static->name);
|
||||||
lua_rawget(L,-2); /* get class static table */
|
lua_rawget(L,-2); /* get class static table */
|
||||||
assert(lua_istable(L,-1));
|
assert(lua_istable(L,-1));
|
||||||
|
|
@ -1357,7 +1603,7 @@ SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss)
|
||||||
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
||||||
SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss)
|
SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss)
|
||||||
{
|
{
|
||||||
int begin = lua_gettop(L);
|
const int SWIGUNUSED begin = lua_gettop(L);
|
||||||
/* if name already there (class is already registered) then do nothing */
|
/* if name already there (class is already registered) then do nothing */
|
||||||
SWIG_Lua_get_class_registry(L); /* get the registry */
|
SWIG_Lua_get_class_registry(L); /* get the registry */
|
||||||
lua_pushstring(L,clss->fqname); /* get the name */
|
lua_pushstring(L,clss->fqname); /* get the name */
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,10 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
|
||||||
|
|
||||||
#if defined(SWIG_LUA_ELUA_EMULATE)
|
#if defined(SWIG_LUA_ELUA_EMULATE)
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
SWIG_Lua_elua_emulate_register(L,swig___Module.ns_methods);
|
SWIG_Lua_elua_emulate_register(L,swig_SwigModule.ns_methods);
|
||||||
SWIG_Lua_elua_emulate_register_clear(L);
|
SWIG_Lua_elua_emulate_register_clear(L);
|
||||||
if(globalRegister) {
|
if(globalRegister) {
|
||||||
lua_pushstring(L,swig___Module.name);
|
lua_pushstring(L,swig_SwigModule.name);
|
||||||
lua_pushvalue(L,-2);
|
lua_pushvalue(L,-2);
|
||||||
lua_rawset(L,-4);
|
lua_rawset(L,-4);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ static int default_error_code = E_ERROR;
|
||||||
if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else
|
if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else
|
||||||
|
|
||||||
/* Standard SWIG API */
|
/* Standard SWIG API */
|
||||||
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule(clientdata)
|
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule()
|
||||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer)
|
#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer)
|
||||||
|
|
||||||
/* used to wrap returned objects in so we know whether they are newobject
|
/* used to wrap returned objects in so we know whether they are newobject
|
||||||
|
|
@ -252,7 +252,7 @@ SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC
|
||||||
}
|
}
|
||||||
|
|
||||||
static char const_name[] = "swig_runtime_data_type_pointer";
|
static char const_name[] = "swig_runtime_data_type_pointer";
|
||||||
static swig_module_info *SWIG_Php_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
static swig_module_info *SWIG_Php_GetModule() {
|
||||||
zval *pointer;
|
zval *pointer;
|
||||||
swig_module_info *ret = 0;
|
swig_module_info *ret = 0;
|
||||||
TSRMLS_FETCH();
|
TSRMLS_FETCH();
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
zval *o;
|
zval *o;
|
||||||
MAKE_STD_ZVAL(o);
|
MAKE_STD_ZVAL(o);
|
||||||
ZVAL_BOOL(o,temp$argnum);
|
ZVAL_BOOL(o,temp$argnum);
|
||||||
t_output_helper( &$result, o );
|
t_output_helper( &$result, o TSRMLS_CC );
|
||||||
}
|
}
|
||||||
%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
|
%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
|
||||||
%{
|
%{
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
zval *o;
|
zval *o;
|
||||||
MAKE_STD_ZVAL(o);
|
MAKE_STD_ZVAL(o);
|
||||||
ZVAL_DOUBLE(o,temp$argnum);
|
ZVAL_DOUBLE(o,temp$argnum);
|
||||||
t_output_helper( &$result, o );
|
t_output_helper( &$result, o TSRMLS_CC );
|
||||||
}
|
}
|
||||||
%typemap(in) TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue)
|
%typemap(in) TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue)
|
||||||
%{
|
%{
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
zval *o;
|
zval *o;
|
||||||
MAKE_STD_ZVAL(o);
|
MAKE_STD_ZVAL(o);
|
||||||
ZVAL_LONG(o,temp$argnum);
|
ZVAL_LONG(o,temp$argnum);
|
||||||
t_output_helper( &$result, o );
|
t_output_helper( &$result, o TSRMLS_CC );
|
||||||
}
|
}
|
||||||
%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
|
%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
|
||||||
%{
|
%{
|
||||||
|
|
@ -137,7 +137,7 @@ INT_TYPEMAP(long long);
|
||||||
sprintf(temp, "%lld", (long long)temp$argnum);
|
sprintf(temp, "%lld", (long long)temp$argnum);
|
||||||
ZVAL_STRING(o, temp, 1);
|
ZVAL_STRING(o, temp, 1);
|
||||||
}
|
}
|
||||||
t_output_helper( &$result, o );
|
t_output_helper( &$result, o TSRMLS_CC );
|
||||||
}
|
}
|
||||||
%typemap(in) TYPE *REFERENCE (long long lvalue)
|
%typemap(in) TYPE *REFERENCE (long long lvalue)
|
||||||
%{
|
%{
|
||||||
|
|
@ -178,7 +178,7 @@ INT_TYPEMAP(unsigned long long);
|
||||||
sprintf(temp, "%llu", (unsigned long long)temp$argnum);
|
sprintf(temp, "%llu", (unsigned long long)temp$argnum);
|
||||||
ZVAL_STRING(o, temp, 1);
|
ZVAL_STRING(o, temp, 1);
|
||||||
}
|
}
|
||||||
t_output_helper( &$result, o );
|
t_output_helper( &$result, o TSRMLS_CC );
|
||||||
}
|
}
|
||||||
%typemap(in) TYPE *REFERENCE (unsigned long long lvalue)
|
%typemap(in) TYPE *REFERENCE (unsigned long long lvalue)
|
||||||
%{
|
%{
|
||||||
|
|
@ -276,12 +276,12 @@ INT_TYPEMAP(unsigned long long);
|
||||||
%}
|
%}
|
||||||
%typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] )
|
%typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] )
|
||||||
"$1 = temp;";
|
"$1 = temp;";
|
||||||
%typemap(argout) char OUTPUT[ANY]
|
%typemap(argout,fragment="t_output_helper") char OUTPUT[ANY]
|
||||||
{
|
{
|
||||||
zval *o;
|
zval *o;
|
||||||
MAKE_STD_ZVAL(o);
|
MAKE_STD_ZVAL(o);
|
||||||
ZVAL_STRINGL(o,temp$argnum,$1_dim0);
|
ZVAL_STRINGL(o,temp$argnum,$1_dim0);
|
||||||
t_output_helper( &$result, o );
|
t_output_helper( &$result, o TSRMLS_CC );
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(in,numinputs=0) void **OUTPUT (int force),
|
%typemap(in,numinputs=0) void **OUTPUT (int force),
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@
|
||||||
|
|
||||||
%fragment("t_output_helper","header") %{
|
%fragment("t_output_helper","header") %{
|
||||||
static void
|
static void
|
||||||
t_output_helper( zval **target, zval *o) {
|
t_output_helper(zval **target, zval *o TSRMLS_DC) {
|
||||||
if ( (*target)->type == IS_ARRAY ) {
|
if ( (*target)->type == IS_ARRAY ) {
|
||||||
/* it's already an array, just append */
|
/* it's already an array, just append */
|
||||||
add_next_index_zval( *target, o );
|
add_next_index_zval( *target, o );
|
||||||
|
|
|
||||||
|
|
@ -1418,7 +1418,7 @@ static void mark_nodes_as_extend(Node *n) {
|
||||||
String *nexcept;
|
String *nexcept;
|
||||||
} dtype;
|
} dtype;
|
||||||
struct {
|
struct {
|
||||||
char *type;
|
const char *type;
|
||||||
String *filename;
|
String *filename;
|
||||||
int line;
|
int line;
|
||||||
} loc;
|
} loc;
|
||||||
|
|
@ -2002,8 +2002,8 @@ include_directive: includetype options string BEGINFILE {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
includetype : INCLUDE { $$.type = (char *) "include"; }
|
includetype : INCLUDE { $$.type = "include"; }
|
||||||
| IMPORT { $$.type = (char *) "import"; ++import_mode;}
|
| IMPORT { $$.type = "import"; ++import_mode;}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
|
|
@ -4292,7 +4292,7 @@ cpp_namespace_decl : NAMESPACE idcolon LBRACE {
|
||||||
| NAMESPACE LBRACE {
|
| NAMESPACE LBRACE {
|
||||||
Hash *h;
|
Hash *h;
|
||||||
$1 = Swig_symbol_current();
|
$1 = Swig_symbol_current();
|
||||||
h = Swig_symbol_clookup((char *)" ",0);
|
h = Swig_symbol_clookup(" ",0);
|
||||||
if (h && (Strcmp(nodeType(h),"namespace") == 0)) {
|
if (h && (Strcmp(nodeType(h),"namespace") == 0)) {
|
||||||
Swig_symbol_setscope(Getattr(h,"symtab"));
|
Swig_symbol_setscope(Getattr(h,"symtab"));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -5271,7 +5271,7 @@ notso_direct_declarator : idcolon {
|
||||||
SwigType *t;
|
SwigType *t;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
t = NewStringEmpty();
|
t = NewStringEmpty();
|
||||||
SwigType_add_array(t,(char*)"");
|
SwigType_add_array(t,"");
|
||||||
if ($$.type) {
|
if ($$.type) {
|
||||||
SwigType_push(t,$$.type);
|
SwigType_push(t,$$.type);
|
||||||
Delete($$.type);
|
Delete($$.type);
|
||||||
|
|
@ -5370,7 +5370,7 @@ direct_declarator : idcolon {
|
||||||
SwigType *t;
|
SwigType *t;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
t = NewStringEmpty();
|
t = NewStringEmpty();
|
||||||
SwigType_add_array(t,(char*)"");
|
SwigType_add_array(t,"");
|
||||||
if ($$.type) {
|
if ($$.type) {
|
||||||
SwigType_push(t,$$.type);
|
SwigType_push(t,$$.type);
|
||||||
Delete($$.type);
|
Delete($$.type);
|
||||||
|
|
@ -5540,7 +5540,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
|
||||||
SwigType *t;
|
SwigType *t;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
t = NewStringEmpty();
|
t = NewStringEmpty();
|
||||||
SwigType_add_array(t,(char*)"");
|
SwigType_add_array(t,"");
|
||||||
if ($$.type) {
|
if ($$.type) {
|
||||||
SwigType_push(t,$$.type);
|
SwigType_push(t,$$.type);
|
||||||
Delete($$.type);
|
Delete($$.type);
|
||||||
|
|
@ -5563,7 +5563,7 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
|
||||||
$$.id = 0;
|
$$.id = 0;
|
||||||
$$.parms = 0;
|
$$.parms = 0;
|
||||||
$$.have_parms = 0;
|
$$.have_parms = 0;
|
||||||
SwigType_add_array($$.type,(char*)"");
|
SwigType_add_array($$.type,"");
|
||||||
}
|
}
|
||||||
| LBRACKET expr RBRACKET {
|
| LBRACKET expr RBRACKET {
|
||||||
$$.type = NewStringEmpty();
|
$$.type = NewStringEmpty();
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ Sequence Operations
|
||||||
-------------------
|
-------------------
|
||||||
Getitem(list,index) Get an item
|
Getitem(list,index) Get an item
|
||||||
Setitem(list,index,val) Set an item
|
Setitem(list,index,val) Set an item
|
||||||
Delitem(list,index,val) Delete an item
|
Delitem(list,index) Delete an item
|
||||||
Insert(list,index,val) Insert an item
|
Insert(list,index,val) Insert an item
|
||||||
Append(list,val) Append to end
|
Append(list,val) Append to end
|
||||||
Push(list,val) Insert at beginning
|
Push(list,val) Insert at beginning
|
||||||
|
|
@ -65,7 +65,7 @@ Putc(ch,obj) Put a character
|
||||||
Ungetc(ch,obj) Put character back on input stream
|
Ungetc(ch,obj) Put character back on input stream
|
||||||
Seek(obj,offset,whence) Seek
|
Seek(obj,offset,whence) Seek
|
||||||
Tell(obj) Return file pointer
|
Tell(obj) Return file pointer
|
||||||
Close(obj) Close
|
Delete(obj) Decrease the reference count, close file if zero
|
||||||
|
|
||||||
String Operations
|
String Operations
|
||||||
-----------------
|
-----------------
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
// #define ALLEGROCL_TYPE_DEBUG
|
// #define ALLEGROCL_TYPE_DEBUG
|
||||||
// #define ALLEGROCL_CLASS_DEBUG
|
// #define ALLEGROCL_CLASS_DEBUG
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Allegro CL Options (available with -allegrocl)\n\
|
Allegro CL Options (available with -allegrocl)\n\
|
||||||
-identifier-converter <type or funcname> - \n\
|
-identifier-converter <type or funcname> - \n\
|
||||||
Specifies the type of conversion to do on C identifiers to convert\n\
|
Specifies the type of conversion to do on C identifiers to convert\n\
|
||||||
|
|
|
||||||
|
|
@ -714,7 +714,7 @@ Allocate():
|
||||||
|
|
||||||
/* Check if base classes allow smart pointers, but might be hidden */
|
/* Check if base classes allow smart pointers, but might be hidden */
|
||||||
if (!Getattr(n, "allocate:smartpointer")) {
|
if (!Getattr(n, "allocate:smartpointer")) {
|
||||||
Node *sp = Swig_symbol_clookup((char *) "operator ->", 0);
|
Node *sp = Swig_symbol_clookup("operator ->", 0);
|
||||||
if (sp) {
|
if (sp) {
|
||||||
/* Look for parent */
|
/* Look for parent */
|
||||||
Node *p = parentNode(sp);
|
Node *p = parentNode(sp);
|
||||||
|
|
@ -833,7 +833,7 @@ Allocate():
|
||||||
or reference. We're going to chase it to see if another operator->()
|
or reference. We're going to chase it to see if another operator->()
|
||||||
can be found */
|
can be found */
|
||||||
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
|
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
|
||||||
Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab"));
|
Node *nn = Swig_symbol_clookup("operator ->", Getattr(sc, "symtab"));
|
||||||
if (nn) {
|
if (nn) {
|
||||||
Delete(base);
|
Delete(base);
|
||||||
Delete(type);
|
Delete(type);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
//#define CFFI_DEBUG
|
//#define CFFI_DEBUG
|
||||||
//#define CFFI_WRAP_DEBUG
|
//#define CFFI_WRAP_DEBUG
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
CFFI Options (available with -cffi)\n\
|
CFFI Options (available with -cffi)\n\
|
||||||
-generate-typedef - Use defctype to generate shortcuts according to the\n\
|
-generate-typedef - Use defctype to generate shortcuts according to the\n\
|
||||||
typedefs in the input.\n\
|
typedefs in the input.\n\
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
\
|
\
|
||||||
CHICKEN Options (available with -chicken)\n\
|
CHICKEN Options (available with -chicken)\n\
|
||||||
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
|
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
|
||||||
|
|
@ -29,7 +29,7 @@ CHICKEN Options (available with -chicken)\n\
|
||||||
\n";
|
\n";
|
||||||
|
|
||||||
static char *module = 0;
|
static char *module = 0;
|
||||||
static char *chicken_path = (char *) "chicken";
|
static const char *chicken_path = "chicken";
|
||||||
static int num_methods = 0;
|
static int num_methods = 0;
|
||||||
|
|
||||||
static File *f_begin = 0;
|
static File *f_begin = 0;
|
||||||
|
|
@ -620,7 +620,7 @@ int CHICKEN::functionWrapper(Node *n) {
|
||||||
if (in_class)
|
if (in_class)
|
||||||
clos_name = NewString(member_name);
|
clos_name = NewString(member_name);
|
||||||
else
|
else
|
||||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
clos_name = chickenNameMapping(scmname, "");
|
||||||
|
|
||||||
if (!any_specialized_arg) {
|
if (!any_specialized_arg) {
|
||||||
method_def = NewString("");
|
method_def = NewString("");
|
||||||
|
|
@ -775,7 +775,7 @@ int CHICKEN::variableWrapper(Node *n) {
|
||||||
if (in_class)
|
if (in_class)
|
||||||
clos_name = NewString(member_name);
|
clos_name = NewString(member_name);
|
||||||
else
|
else
|
||||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
clos_name = chickenNameMapping(scmname, "");
|
||||||
|
|
||||||
Node *class_node = classLookup(t);
|
Node *class_node = classLookup(t);
|
||||||
String *clos_code = Getattr(n, "tmap:varin:closcode");
|
String *clos_code = Getattr(n, "tmap:varin:closcode");
|
||||||
|
|
@ -942,7 +942,7 @@ int CHICKEN::constantWrapper(Node *n) {
|
||||||
if (in_class)
|
if (in_class)
|
||||||
clos_name = NewString(member_name);
|
clos_name = NewString(member_name);
|
||||||
else
|
else
|
||||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
clos_name = chickenNameMapping(scmname, "");
|
||||||
if (GetFlag(n, "feature:constasvar")) {
|
if (GetFlag(n, "feature:constasvar")) {
|
||||||
Printv(clos_methods, "(define ", clos_name, " (", chickenPrimitiveName(scmname), "))\n", NIL);
|
Printv(clos_methods, "(define ", clos_name, " (", chickenPrimitiveName(scmname), "))\n", NIL);
|
||||||
Printv(scm_const_defs, "(set! ", scmname, " (", scmname, "))\n", NIL);
|
Printv(scm_const_defs, "(set! ", scmname, " (", scmname, "))\n", NIL);
|
||||||
|
|
@ -1372,7 +1372,7 @@ void CHICKEN::dispatchFunction(Node *n) {
|
||||||
} else if (in_class)
|
} else if (in_class)
|
||||||
clos_name = NewString(member_name);
|
clos_name = NewString(member_name);
|
||||||
else
|
else
|
||||||
clos_name = chickenNameMapping(scmname, (char *) "");
|
clos_name = chickenNameMapping(scmname, "");
|
||||||
|
|
||||||
Iterator f;
|
Iterator f;
|
||||||
List *prev = 0;
|
List *prev = 0;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include "swigmod.h"
|
#include "swigmod.h"
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
CLISP Options (available with -clisp)\n\
|
CLISP Options (available with -clisp)\n\
|
||||||
-extern-all - Create clisp definitions for all the functions and\n\
|
-extern-all - Create clisp definitions for all the functions and\n\
|
||||||
global variables otherwise only definitions for\n\
|
global variables otherwise only definitions for\n\
|
||||||
|
|
|
||||||
|
|
@ -3175,8 +3175,8 @@ public:
|
||||||
if (anonymous_enum) {
|
if (anonymous_enum) {
|
||||||
replacementname = NewString("int");
|
replacementname = NewString("int");
|
||||||
} else {
|
} else {
|
||||||
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition)
|
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum
|
||||||
replacementname = SwigType_base(classnametype);
|
replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype));
|
||||||
Replace(replacementname, "enum ", "", DOH_REPLACE_ANY);
|
Replace(replacementname, "enum ", "", DOH_REPLACE_ANY);
|
||||||
Setattr(swig_types_hash, replacementname, classnametype);
|
Setattr(swig_types_hash, replacementname, classnametype);
|
||||||
}
|
}
|
||||||
|
|
@ -4303,7 +4303,7 @@ extern "C" Language *swig_csharp(void) {
|
||||||
* Static member variables
|
* Static member variables
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const char *CSHARP::usage = (char *) "\
|
const char *CSHARP::usage = "\
|
||||||
C# Options (available with -csharp)\n\
|
C# Options (available with -csharp)\n\
|
||||||
-dllimport <dl> - Override DllImport attribute name to <dl>\n\
|
-dllimport <dl> - Override DllImport attribute name to <dl>\n\
|
||||||
-namespace <nm> - Generate wrappers into C# namespace <nm>\n\
|
-namespace <nm> - Generate wrappers into C# namespace <nm>\n\
|
||||||
|
|
|
||||||
|
|
@ -4649,7 +4649,7 @@ extern "C" Language *swig_d(void) {
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Usage information displayed at the command line.
|
* Usage information displayed at the command line.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
const char *D::usage = (char *) "\
|
const char *D::usage = "\
|
||||||
D Options (available with -d)\n\
|
D Options (available with -d)\n\
|
||||||
-d2 - Generate code for D2/Phobos (default: D1/Tango)\n\
|
-d2 - Generate code for D2/Phobos (default: D1/Tango)\n\
|
||||||
-package <pkg> - Write generated D modules into package <pkg>\n\
|
-package <pkg> - Write generated D modules into package <pkg>\n\
|
||||||
|
|
|
||||||
|
|
@ -4514,10 +4514,12 @@ private:
|
||||||
} else if (Strcmp(t, "enum ") == 0) {
|
} else if (Strcmp(t, "enum ") == 0) {
|
||||||
ret = NewString("int");
|
ret = NewString("int");
|
||||||
} else {
|
} else {
|
||||||
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition)
|
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum
|
||||||
ret = SwigType_base(t);
|
String *tt = Copy(t);
|
||||||
Replace(ret, "enum ", "", DOH_REPLACE_ANY);
|
Replace(tt, "enum ", "", DOH_REPLACE_ANY);
|
||||||
|
ret = exportedName(tt);
|
||||||
Setattr(undefined_enum_types, t, ret);
|
Setattr(undefined_enum_types, t, ret);
|
||||||
|
Delete(tt);
|
||||||
}
|
}
|
||||||
} else if (SwigType_isfunctionpointer(type) || SwigType_isfunction(type)) {
|
} else if (SwigType_isfunctionpointer(type) || SwigType_isfunction(type)) {
|
||||||
ret = NewString("_swig_fnptr");
|
ret = NewString("_swig_fnptr");
|
||||||
|
|
@ -5017,7 +5019,7 @@ extern "C" Language *swig_go(void) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
// Usage message.
|
// Usage message.
|
||||||
const char * const GO::usage = (char *) "\
|
const char * const GO::usage = "\
|
||||||
Go Options (available with -go)\n\
|
Go Options (available with -go)\n\
|
||||||
-gccgo - Generate code for gccgo rather than 6g/8g\n\
|
-gccgo - Generate code for gccgo rather than 6g/8g\n\
|
||||||
-go-pkgpath <p> - Like gccgo -fgo-pkgpath option\n\
|
-go-pkgpath <p> - Like gccgo -fgo-pkgpath option\n\
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
// Note string broken in half for compilers that can't handle long strings
|
// Note string broken in half for compilers that can't handle long strings
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Guile Options (available with -guile)\n\
|
Guile Options (available with -guile)\n\
|
||||||
-emitsetters - Emit procedures-with-setters for variables\n\
|
-emitsetters - Emit procedures-with-setters for variables\n\
|
||||||
and structure slots.\n\
|
and structure slots.\n\
|
||||||
|
|
@ -1018,7 +1018,7 @@ public:
|
||||||
if (in_class)
|
if (in_class)
|
||||||
goops_name = NewString(memberfunction_name);
|
goops_name = NewString(memberfunction_name);
|
||||||
else
|
else
|
||||||
goops_name = goopsNameMapping(proc_name, (char *) "");
|
goops_name = goopsNameMapping(proc_name, "");
|
||||||
String *primitive_name = NewString("");
|
String *primitive_name = NewString("");
|
||||||
if (primRenamer)
|
if (primRenamer)
|
||||||
Printv(primitive_name, "primitive:", proc_name, NIL);
|
Printv(primitive_name, "primitive:", proc_name, NIL);
|
||||||
|
|
@ -1204,7 +1204,7 @@ public:
|
||||||
// export wrapper into goops file
|
// export wrapper into goops file
|
||||||
if (!in_class) { // only if the variable is not part of a class
|
if (!in_class) { // only if the variable is not part of a class
|
||||||
String *class_name = SwigType_typedef_resolve_all(SwigType_base(t));
|
String *class_name = SwigType_typedef_resolve_all(SwigType_base(t));
|
||||||
String *goops_name = goopsNameMapping(proc_name, (char *) "");
|
String *goops_name = goopsNameMapping(proc_name, "");
|
||||||
String *primitive_name = NewString("");
|
String *primitive_name = NewString("");
|
||||||
if (primRenamer)
|
if (primRenamer)
|
||||||
Printv(primitive_name, "primitive:", NIL);
|
Printv(primitive_name, "primitive:", NIL);
|
||||||
|
|
|
||||||
|
|
@ -3090,8 +3090,8 @@ public:
|
||||||
if (anonymous_enum) {
|
if (anonymous_enum) {
|
||||||
replacementname = NewString("int");
|
replacementname = NewString("int");
|
||||||
} else {
|
} else {
|
||||||
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition)
|
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum
|
||||||
replacementname = SwigType_base(classnametype);
|
replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype));
|
||||||
Replace(replacementname, "enum ", "", DOH_REPLACE_ANY);
|
Replace(replacementname, "enum ", "", DOH_REPLACE_ANY);
|
||||||
Setattr(swig_types_hash, replacementname, classnametype);
|
Setattr(swig_types_hash, replacementname, classnametype);
|
||||||
}
|
}
|
||||||
|
|
@ -4643,7 +4643,7 @@ extern "C" Language *swig_java(void) {
|
||||||
* Static member variables
|
* Static member variables
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const char *JAVA::usage = (char *) "\
|
const char *JAVA::usage = "\
|
||||||
Java Options (available with -java)\n\
|
Java Options (available with -java)\n\
|
||||||
-nopgcpp - Suppress premature garbage collection prevention parameter\n\
|
-nopgcpp - Suppress premature garbage collection prevention parameter\n\
|
||||||
-noproxy - Generate the low-level functional interface instead\n\
|
-noproxy - Generate the low-level functional interface instead\n\
|
||||||
|
|
|
||||||
|
|
@ -86,11 +86,11 @@ extern "C"
|
||||||
you can add new ones here
|
you can add new ones here
|
||||||
(though for now I have not bothered)
|
(though for now I have not bothered)
|
||||||
NEW LANGUAGE NOTE:END ************************************************/
|
NEW LANGUAGE NOTE:END ************************************************/
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Lua Options (available with -lua)\n\
|
Lua Options (available with -lua)\n\
|
||||||
-elua - Generates LTR compatible wrappers for smaller devices running elua\n\
|
-elua - Generates LTR compatible wrappers for smaller devices running elua\n\
|
||||||
-eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\
|
-eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\
|
||||||
-elua-emulate - Emulates behaviour of eLua. Usefull only for testing.\n\
|
-elua-emulate - Emulates behaviour of eLua. Useful only for testing.\n\
|
||||||
Incompatible with -elua/-eluac options.\n\
|
Incompatible with -elua/-eluac options.\n\
|
||||||
-nomoduleglobal - Do not register the module name as a global variable \n\
|
-nomoduleglobal - Do not register the module name as a global variable \n\
|
||||||
but return the module table from calls to require.\n\
|
but return the module table from calls to require.\n\
|
||||||
|
|
@ -205,7 +205,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
This is called to initalise the system & read any command line args
|
This is called to initialise the system & read any command line args
|
||||||
most of this is boilerplate code, except the command line args
|
most of this is boilerplate code, except the command line args
|
||||||
which depends upon what args your code supports
|
which depends upon what args your code supports
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
|
|
@ -380,7 +380,7 @@ public:
|
||||||
Dump(f_header, f_begin);
|
Dump(f_header, f_begin);
|
||||||
Dump(f_wrappers, f_begin);
|
Dump(f_wrappers, f_begin);
|
||||||
Dump(f_initbeforefunc, f_begin);
|
Dump(f_initbeforefunc, f_begin);
|
||||||
/* for the Lua code it needs to be properly excaped to be added into the C/C++ code */
|
/* for the Lua code it needs to be properly escaped to be added into the C/C++ code */
|
||||||
escapeCode(s_luacode);
|
escapeCode(s_luacode);
|
||||||
Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n", s_luacode);
|
Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n", s_luacode);
|
||||||
Wrapper_pretty_print(f_init, f_begin);
|
Wrapper_pretty_print(f_init, f_begin);
|
||||||
|
|
@ -436,9 +436,9 @@ public:
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
This is it!
|
This is it!
|
||||||
you get this one right, and most of your work is done
|
you get this one right, and most of your work is done
|
||||||
but its going to take soem file to get it working right
|
but its going to take some file to get it working right
|
||||||
quite a bit of this is generally boilerplate code
|
quite a bit of this is generally boilerplate code
|
||||||
(or stuff I dont understand)
|
(or stuff I don't understand)
|
||||||
that which matters will have extra added comments
|
that which matters will have extra added comments
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
|
|
@ -534,7 +534,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
the wrapper object holds all the wrappering code
|
the wrapper object holds all the wrapper code
|
||||||
we need to add a couple of local variables
|
we need to add a couple of local variables
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
|
|
@ -554,7 +554,7 @@ public:
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
the format of a lua fn is:
|
the format of a lua fn is:
|
||||||
static int wrap_XXX(lua_State* L){...}
|
static int wrap_XXX(lua_State* L){...}
|
||||||
this line adds this into the wrappering code
|
this line adds this into the wrapper code
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL);
|
Printv(f->def, "static int ", wname, "(lua_State* L) {", NIL);
|
||||||
|
|
||||||
|
|
@ -657,7 +657,7 @@ public:
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
// why is this code not called when I dont have a typemap?
|
// why is this code not called when I don't have a typemap?
|
||||||
// instead of giving a warning, no code is generated
|
// instead of giving a warning, no code is generated
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
|
||||||
|
|
@ -792,7 +792,7 @@ public:
|
||||||
Replaceall(f->code, "$result", Swig_cresult_name());
|
Replaceall(f->code, "$result", Swig_cresult_name());
|
||||||
|
|
||||||
/* Dump the function out */
|
/* Dump the function out */
|
||||||
/* in Lua we will not emit the destructor as a wrappered function,
|
/* in Lua we will not emit the destructor as a wrapper function,
|
||||||
Lua will automatically call the destructor when the object is free'd
|
Lua will automatically call the destructor when the object is free'd
|
||||||
However: you cannot just skip this function as it will not emit
|
However: you cannot just skip this function as it will not emit
|
||||||
any custom destructor (using %extend), as you need to call emit_action()
|
any custom destructor (using %extend), as you need to call emit_action()
|
||||||
|
|
@ -835,7 +835,7 @@ public:
|
||||||
/* NEW LANGUAGE NOTE:***********************************************
|
/* NEW LANGUAGE NOTE:***********************************************
|
||||||
This is an extra function used for overloading of functions
|
This is an extra function used for overloading of functions
|
||||||
it checks the args & then calls the relevant fn
|
it checks the args & then calls the relevant fn
|
||||||
nost of the real work in again typemaps:
|
most of the real work in again typemaps:
|
||||||
look for %typecheck(SWIG_TYPECHECK_*) in the .swg file
|
look for %typecheck(SWIG_TYPECHECK_*) in the .swg file
|
||||||
NEW LANGUAGE NOTE:END *********************************************** */
|
NEW LANGUAGE NOTE:END *********************************************** */
|
||||||
int dispatchFunction(Node *n) {
|
int dispatchFunction(Node *n) {
|
||||||
|
|
@ -1958,6 +1958,10 @@ public:
|
||||||
|
|
||||||
SetFlag(carrays_hash, "lua:closed");
|
SetFlag(carrays_hash, "lua:closed");
|
||||||
|
|
||||||
|
// Do arrays describe class instance part or class static part
|
||||||
|
const int is_instance = GetFlag(carrays_hash, "lua:class_instance");
|
||||||
|
|
||||||
|
|
||||||
String *attr_tab = Getattr(carrays_hash, "attributes");
|
String *attr_tab = Getattr(carrays_hash, "attributes");
|
||||||
Printf(attr_tab, " {0,0,0}\n};\n");
|
Printf(attr_tab, " {0,0,0}\n};\n");
|
||||||
Printv(output, attr_tab, NIL);
|
Printv(output, attr_tab, NIL);
|
||||||
|
|
@ -1968,7 +1972,17 @@ public:
|
||||||
Printv(const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
Printv(const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||||
else
|
else
|
||||||
Printf(const_tab, " {0,0,0,0,0,0}\n};\n");
|
Printf(const_tab, " {0,0,0,0,0,0}\n};\n");
|
||||||
Printv(output, const_tab, NIL);
|
|
||||||
|
// For the sake of compiling with -Wall -Werror we print constants
|
||||||
|
// only when necessary
|
||||||
|
int need_constants = 0;
|
||||||
|
if ( (elua_ltr || eluac_ltr) && (old_metatable_bindings) )
|
||||||
|
need_constants = 1;
|
||||||
|
else if (!is_instance) // static part need constants tab
|
||||||
|
need_constants = 1;
|
||||||
|
|
||||||
|
if (need_constants)
|
||||||
|
Printv(output, const_tab, NIL);
|
||||||
|
|
||||||
if (elua_ltr) {
|
if (elua_ltr) {
|
||||||
// Put forward declaration of metatable array
|
// Put forward declaration of metatable array
|
||||||
|
|
@ -2009,7 +2023,18 @@ public:
|
||||||
Printv(output, set_tab, NIL);
|
Printv(output, set_tab, NIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eluac_ltr) {
|
// Heuristic whether we need to print metatable or not.
|
||||||
|
// For the sake of compiling with -Wall -Werror we don't print
|
||||||
|
// metatable for static part.
|
||||||
|
int need_metatable = 0;
|
||||||
|
if (eluac_ltr)
|
||||||
|
need_metatable = 0;
|
||||||
|
else if(!is_instance)
|
||||||
|
need_metatable = 0;
|
||||||
|
else
|
||||||
|
need_metatable = 1;
|
||||||
|
|
||||||
|
if (need_metatable) {
|
||||||
String *metatable_tab = Getattr(carrays_hash, "metatable");
|
String *metatable_tab = Getattr(carrays_hash, "metatable");
|
||||||
assert(metatable_tab);
|
assert(metatable_tab);
|
||||||
if (elua_ltr) {
|
if (elua_ltr) {
|
||||||
|
|
|
||||||
|
|
@ -160,9 +160,9 @@ static String *SwigLib = 0; // Library directory
|
||||||
static String *SwigLibWinUnix = 0; // Extra library directory on Windows
|
static String *SwigLibWinUnix = 0; // Extra library directory on Windows
|
||||||
static int freeze = 0;
|
static int freeze = 0;
|
||||||
static String *lang_config = 0;
|
static String *lang_config = 0;
|
||||||
static char *hpp_extension = (char *) "h";
|
static const char *hpp_extension = "h";
|
||||||
static char *cpp_extension = (char *) "cxx";
|
static const char *cpp_extension = "cxx";
|
||||||
static char *depends_extension = (char *) "d";
|
static const char *depends_extension = "d";
|
||||||
static String *outdir = 0;
|
static String *outdir = 0;
|
||||||
static String *xmlout = 0;
|
static String *xmlout = 0;
|
||||||
static int outcurrentdir = 0;
|
static int outcurrentdir = 0;
|
||||||
|
|
@ -324,7 +324,7 @@ const String *SWIG_output_directory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SWIG_config_cppext(const char *ext) {
|
void SWIG_config_cppext(const char *ext) {
|
||||||
cpp_extension = (char *) ext;
|
cpp_extension = ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
List *SWIG_output_files() {
|
List *SWIG_output_files() {
|
||||||
|
|
@ -465,7 +465,7 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
||||||
String *d = NewString(argv[i] + 2);
|
String *d = NewString(argv[i] + 2);
|
||||||
Replace(d, (char *) "=", (char *) " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
Replace(d, "=", " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||||
Preprocessor_define((DOH *) d, 0);
|
Preprocessor_define((DOH *) d, 0);
|
||||||
Delete(d);
|
Delete(d);
|
||||||
// Create a symbol
|
// Create a symbol
|
||||||
|
|
|
||||||
|
|
@ -3956,7 +3956,7 @@ extern "C" Language *swig_modula3(void) {
|
||||||
* Static member variables
|
* Static member variables
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const char *MODULA3::usage = (char *) "\
|
const char *MODULA3::usage = "\
|
||||||
Modula 3 Options (available with -modula3)\n\
|
Modula 3 Options (available with -modula3)\n\
|
||||||
-generateconst <file> - Generate code for computing numeric values of constants\n\
|
-generateconst <file> - Generate code for computing numeric values of constants\n\
|
||||||
-generaterename <file> - Generate suggestions for %rename\n\
|
-generaterename <file> - Generate suggestions for %rename\n\
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Mzscheme Options (available with -mzscheme)\n\
|
Mzscheme Options (available with -mzscheme)\n\
|
||||||
-declaremodule - Create extension that declares a module\n\
|
-declaremodule - Create extension that declares a module\n\
|
||||||
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
|
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
|
||||||
|
|
@ -36,7 +36,7 @@ static bool declaremodule = false;
|
||||||
static bool noinit = false;
|
static bool noinit = false;
|
||||||
static String *load_libraries = NULL;
|
static String *load_libraries = NULL;
|
||||||
static String *module = 0;
|
static String *module = 0;
|
||||||
static char *mzscheme_path = (char *) "mzscheme";
|
static const char *mzscheme_path = "mzscheme";
|
||||||
static String *init_func_def = 0;
|
static String *init_func_def = 0;
|
||||||
|
|
||||||
static File *f_begin = 0;
|
static File *f_begin = 0;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Ocaml Options (available with -ocaml)\n\
|
Ocaml Options (available with -ocaml)\n\
|
||||||
-oldvarnames - Old intermediary method names for variable wrappers\n\
|
-oldvarnames - Old intermediary method names for variable wrappers\n\
|
||||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||||
|
|
@ -29,7 +29,7 @@ static int const_enum = 0;
|
||||||
static int static_member_function = 0;
|
static int static_member_function = 0;
|
||||||
static int generate_sizeof = 0;
|
static int generate_sizeof = 0;
|
||||||
static String *prefix = 0;
|
static String *prefix = 0;
|
||||||
static char *ocaml_path = (char *) "ocaml";
|
static const char *ocaml_path = "ocaml";
|
||||||
static bool old_variable_names = false;
|
static bool old_variable_names = false;
|
||||||
static String *classname = 0;
|
static String *classname = 0;
|
||||||
static String *module = 0;
|
static String *module = 0;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
static String *global_name = 0;
|
static String *global_name = 0;
|
||||||
static String *op_prefix = 0;
|
static String *op_prefix = 0;
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Octave Options (available with -octave)\n\
|
Octave Options (available with -octave)\n\
|
||||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||||
Use '.' to load C global variables into module namespace\n\
|
Use '.' to load C global variables into module namespace\n\
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ static int treduce = SWIG_cparse_template_reduce(0);
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Perl5 Options (available with -perl5)\n\
|
Perl5 Options (available with -perl5)\n\
|
||||||
-compat - Compatibility mode\n\
|
-compat - Compatibility mode\n\
|
||||||
-const - Wrap constants as constants and not variables (implies -proxy)\n\
|
-const - Wrap constants as constants and not variables (implies -proxy)\n\
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
PHP Options (available with -php)\n\
|
PHP Options (available with -php)\n\
|
||||||
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
|
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
|
||||||
-noproxy - Don't generate proxy classes.\n\
|
-noproxy - Don't generate proxy classes.\n\
|
||||||
|
|
@ -414,10 +414,9 @@ public:
|
||||||
* which has to be dynamically generated as it depends on the module name.
|
* which has to be dynamically generated as it depends on the module name.
|
||||||
*/
|
*/
|
||||||
Append(s_header, "#ifdef __GNUC__\n");
|
Append(s_header, "#ifdef __GNUC__\n");
|
||||||
Append(s_header, "static void SWIG_FAIL() __attribute__ ((__noreturn__));\n");
|
Append(s_header, "static void SWIG_FAIL(TSRMLS_D) __attribute__ ((__noreturn__));\n");
|
||||||
Append(s_header, "#endif\n\n");
|
Append(s_header, "#endif\n\n");
|
||||||
Append(s_header, "static void SWIG_FAIL() {\n");
|
Append(s_header, "static void SWIG_FAIL(TSRMLS_D) {\n");
|
||||||
Append(s_header, " TSRMLS_FETCH();\n");
|
|
||||||
Append(s_header, " zend_error(SWIG_ErrorCode(), \"%s\", SWIG_ErrorMsg());\n");
|
Append(s_header, " zend_error(SWIG_ErrorCode(), \"%s\", SWIG_ErrorMsg());\n");
|
||||||
// zend_error() should never return with the parameters we pass, but if it
|
// zend_error() should never return with the parameters we pass, but if it
|
||||||
// does, we really don't want to let SWIG_FAIL() return. This also avoids
|
// does, we really don't want to let SWIG_FAIL() return. This also avoids
|
||||||
|
|
@ -433,8 +432,7 @@ public:
|
||||||
Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module);
|
Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module);
|
||||||
|
|
||||||
Printf(s_header, "\n");
|
Printf(s_header, "\n");
|
||||||
Printf(s_header, "static void SWIG_ResetError() {\n");
|
Printf(s_header, "static void SWIG_ResetError(TSRMLS_D) {\n");
|
||||||
Printf(s_header, " TSRMLS_FETCH();\n");
|
|
||||||
Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n");
|
Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n");
|
||||||
Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n");
|
Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n");
|
||||||
Printf(s_header, "}\n");
|
Printf(s_header, "}\n");
|
||||||
|
|
@ -445,7 +443,7 @@ public:
|
||||||
Append(s_header, " swig_object_wrapper *value;\n");
|
Append(s_header, " swig_object_wrapper *value;\n");
|
||||||
Append(s_header, " int type;\n");
|
Append(s_header, " int type;\n");
|
||||||
Append(s_header, "\n");
|
Append(s_header, "\n");
|
||||||
Append(s_header, " SWIG_ResetError();\n");
|
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
|
||||||
Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n");
|
Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n");
|
||||||
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
||||||
Append(s_header, " }\n");
|
Append(s_header, " }\n");
|
||||||
|
|
@ -460,7 +458,7 @@ public:
|
||||||
Append(s_header, " swig_object_wrapper *value;\n");
|
Append(s_header, " swig_object_wrapper *value;\n");
|
||||||
Append(s_header, " int type;\n");
|
Append(s_header, " int type;\n");
|
||||||
Append(s_header, "\n");
|
Append(s_header, "\n");
|
||||||
Append(s_header, " SWIG_ResetError();\n");
|
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
|
||||||
Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
|
||||||
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
Append(s_header, " WRONG_PARAM_COUNT;\n");
|
||||||
Append(s_header, " }\n");
|
Append(s_header, " }\n");
|
||||||
|
|
@ -736,7 +734,7 @@ public:
|
||||||
|
|
||||||
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
|
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
|
||||||
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
|
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
|
||||||
Printv(f->code, "SWIG_FAIL();\n", NIL);
|
Printv(f->code, "SWIG_FAIL(TSRMLS_C);\n", NIL);
|
||||||
|
|
||||||
Printv(f->code, "}\n", NIL);
|
Printv(f->code, "}\n", NIL);
|
||||||
Wrapper_print(f, s_wrappers);
|
Wrapper_print(f, s_wrappers);
|
||||||
|
|
@ -854,7 +852,7 @@ public:
|
||||||
|
|
||||||
// NOTE: possible we ignore this_ptr as a param for native constructor
|
// NOTE: possible we ignore this_ptr as a param for native constructor
|
||||||
|
|
||||||
Printf(f->code, "SWIG_ResetError();\n");
|
Printf(f->code, "SWIG_ResetError(TSRMLS_C);\n");
|
||||||
|
|
||||||
if (numopt > 0) { // membervariable wrappers do not have optional args
|
if (numopt > 0) { // membervariable wrappers do not have optional args
|
||||||
Wrapper_add_local(f, "arg_count", "int arg_count");
|
Wrapper_add_local(f, "arg_count", "int arg_count");
|
||||||
|
|
@ -1019,7 +1017,7 @@ public:
|
||||||
/* Error handling code */
|
/* Error handling code */
|
||||||
Printf(f->code, "fail:\n");
|
Printf(f->code, "fail:\n");
|
||||||
Printv(f->code, cleanup, NIL);
|
Printv(f->code, cleanup, NIL);
|
||||||
Append(f->code, "SWIG_FAIL();\n");
|
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||||
|
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
|
|
@ -2056,7 +2054,6 @@ done:
|
||||||
|
|
||||||
// Write property SET handlers
|
// Write property SET handlers
|
||||||
ki = First(shadow_set_vars);
|
ki = First(shadow_set_vars);
|
||||||
|
|
||||||
if (ki.key) {
|
if (ki.key) {
|
||||||
// This class has setters.
|
// This class has setters.
|
||||||
Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n");
|
Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n");
|
||||||
|
|
@ -2079,17 +2076,6 @@ done:
|
||||||
Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA);
|
Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA);
|
||||||
}
|
}
|
||||||
Printf(s_phpclasses, "\t}\n");
|
Printf(s_phpclasses, "\t}\n");
|
||||||
|
|
||||||
/* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */
|
|
||||||
Printf(s_phpclasses, "\n\tfunction __isset($var) {\n");
|
|
||||||
Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_set')) return true;\n", shadow_classname);
|
|
||||||
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n");
|
|
||||||
if (baseclass) {
|
|
||||||
Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass);
|
|
||||||
} else {
|
|
||||||
Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA);
|
|
||||||
}
|
|
||||||
Printf(s_phpclasses, "\t}\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n");
|
Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n");
|
||||||
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR);
|
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR);
|
||||||
|
|
@ -2099,18 +2085,10 @@ done:
|
||||||
Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA);
|
Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA);
|
||||||
}
|
}
|
||||||
Printf(s_phpclasses, "\t}\n");
|
Printf(s_phpclasses, "\t}\n");
|
||||||
Printf(s_phpclasses, "\n\tfunction __isset($var) {\n");
|
|
||||||
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n");
|
|
||||||
if (baseclass) {
|
|
||||||
Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass);
|
|
||||||
} else {
|
|
||||||
Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA);
|
|
||||||
}
|
|
||||||
Printf(s_phpclasses, "\t}\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write property GET handlers
|
// Write property GET handlers
|
||||||
ki = First(shadow_get_vars);
|
ki = First(shadow_get_vars);
|
||||||
|
|
||||||
if (ki.key) {
|
if (ki.key) {
|
||||||
// This class has getters.
|
// This class has getters.
|
||||||
Printf(s_phpclasses, "\n\tfunction __get($var) {\n");
|
Printf(s_phpclasses, "\n\tfunction __get($var) {\n");
|
||||||
|
|
@ -2146,6 +2124,19 @@ done:
|
||||||
Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA);
|
Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA);
|
||||||
}
|
}
|
||||||
Printf(s_phpclasses, "\t}\n");
|
Printf(s_phpclasses, "\t}\n");
|
||||||
|
|
||||||
|
/* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */
|
||||||
|
/* __isset() should return true for read-only properties, so check for
|
||||||
|
* *_get() not *_set(). */
|
||||||
|
Printf(s_phpclasses, "\n\tfunction __isset($var) {\n");
|
||||||
|
Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_get')) return true;\n", shadow_classname);
|
||||||
|
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n");
|
||||||
|
if (baseclass) {
|
||||||
|
Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass);
|
||||||
|
} else {
|
||||||
|
Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA);
|
||||||
|
}
|
||||||
|
Printf(s_phpclasses, "\t}\n");
|
||||||
} else {
|
} else {
|
||||||
Printf(s_phpclasses, "\n\tfunction __get($var) {\n");
|
Printf(s_phpclasses, "\n\tfunction __get($var) {\n");
|
||||||
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR);
|
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR);
|
||||||
|
|
@ -2155,6 +2146,14 @@ done:
|
||||||
Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA);
|
Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA);
|
||||||
}
|
}
|
||||||
Printf(s_phpclasses, "\t}\n");
|
Printf(s_phpclasses, "\t}\n");
|
||||||
|
Printf(s_phpclasses, "\n\tfunction __isset($var) {\n");
|
||||||
|
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n");
|
||||||
|
if (baseclass) {
|
||||||
|
Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass);
|
||||||
|
} else {
|
||||||
|
Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA);
|
||||||
|
}
|
||||||
|
Printf(s_phpclasses, "\t}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!class_has_ctor) {
|
if (!class_has_ctor) {
|
||||||
|
|
@ -2274,8 +2273,8 @@ done:
|
||||||
if (i) {
|
if (i) {
|
||||||
Insert(args, 0, ", ");
|
Insert(args, 0, ", ");
|
||||||
}
|
}
|
||||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||||
Delete(args);
|
Delete(args);
|
||||||
|
|
||||||
wrapperType = directorconstructor;
|
wrapperType = directorconstructor;
|
||||||
|
|
@ -2336,7 +2335,7 @@ done:
|
||||||
|
|
||||||
Append(f->code, "return;\n");
|
Append(f->code, "return;\n");
|
||||||
Append(f->code, "fail:\n");
|
Append(f->code, "fail:\n");
|
||||||
Append(f->code, "SWIG_FAIL();\n");
|
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||||
Printf(f->code, "}\n");
|
Printf(f->code, "}\n");
|
||||||
|
|
||||||
Wrapper_print(f, s_wrappers);
|
Wrapper_print(f, s_wrappers);
|
||||||
|
|
@ -2387,17 +2386,23 @@ done:
|
||||||
parms = p;
|
parms = p;
|
||||||
|
|
||||||
if (!Getattr(n, "defaultargs")) {
|
if (!Getattr(n, "defaultargs")) {
|
||||||
|
// There should always be a "self" parameter first.
|
||||||
|
assert(ParmList_len(parms) > 0);
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
{
|
{
|
||||||
Wrapper *w = NewWrapper();
|
Wrapper *w = NewWrapper();
|
||||||
String *call;
|
String *call;
|
||||||
String *basetype = Getattr(parent, "classtype");
|
String *basetype = Getattr(parent, "classtype");
|
||||||
|
|
||||||
|
// We put TSRMLS_DC after the self parameter in order to cope with
|
||||||
|
// any default parameters.
|
||||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
const char * p = Char(target);
|
||||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
const char * comma = strchr(p, ',');
|
||||||
} else {
|
size_t ins = comma ? comma - p : Len(target) - 1;
|
||||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
Insert(target, ins, " TSRMLS_DC");
|
||||||
}
|
|
||||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||||
Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call);
|
Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call);
|
||||||
Append(w->def, "}");
|
Append(w->def, "}");
|
||||||
|
|
@ -2409,12 +2414,14 @@ done:
|
||||||
|
|
||||||
/* constructor header */
|
/* constructor header */
|
||||||
{
|
{
|
||||||
|
// We put TSRMLS_DC after the self parameter in order to cope with
|
||||||
|
// any default parameters.
|
||||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
const char * p = Char(target);
|
||||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
const char * comma = strchr(p, ',');
|
||||||
} else {
|
size_t ins = comma ? comma - p : Len(target) - 1;
|
||||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
Insert(target, ins, " TSRMLS_DC");
|
||||||
}
|
|
||||||
Printf(f_directors_h, " %s;\n", target);
|
Printf(f_directors_h, " %s;\n", target);
|
||||||
Delete(target);
|
Delete(target);
|
||||||
}
|
}
|
||||||
|
|
@ -2700,7 +2707,7 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
Append(w->code, "fail:\n");
|
Append(w->code, "fail:\n");
|
||||||
Append(w->code, "SWIG_FAIL();\n");
|
Append(w->code, "SWIG_FAIL(TSRMLS_C);\n");
|
||||||
Append(w->code, "}\n");
|
Append(w->code, "}\n");
|
||||||
|
|
||||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include <ctype.h> // for isalnum()
|
#include <ctype.h> // for isalnum()
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Pike Options (available with -pike)\n\
|
Pike Options (available with -pike)\n\
|
||||||
[no additional options]\n\
|
[no additional options]\n\
|
||||||
\n";
|
\n";
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ enum autodoc_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const char *usage1 = (char *) "\
|
static const char *usage1 = "\
|
||||||
Python Options (available with -python)\n\
|
Python Options (available with -python)\n\
|
||||||
-aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\
|
-aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\
|
||||||
-buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\
|
-buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\
|
||||||
|
|
@ -127,7 +127,7 @@ Python Options (available with -python)\n\
|
||||||
-keyword - Use keyword arguments\n\
|
-keyword - Use keyword arguments\n\
|
||||||
-modern - Use modern python features only, without compatibility code\n\
|
-modern - Use modern python features only, without compatibility code\n\
|
||||||
-modernargs - Use \"modern\" args mechanism to pack/unpack the function arguments\n";
|
-modernargs - Use \"modern\" args mechanism to pack/unpack the function arguments\n";
|
||||||
static const char *usage2 = (char *) "\
|
static const char *usage2 = "\
|
||||||
-newrepr - Use more informative version of __repr__ in proxy classes (default) \n\
|
-newrepr - Use more informative version of __repr__ in proxy classes (default) \n\
|
||||||
-newvwm - New value wrapper mode, use only when everything else fails \n\
|
-newvwm - New value wrapper mode, use only when everything else fails \n\
|
||||||
-noaliasobj0 - Don't generate an obj0 alias when using fastunpack (default) \n\
|
-noaliasobj0 - Don't generate an obj0 alias when using fastunpack (default) \n\
|
||||||
|
|
@ -144,7 +144,7 @@ static const char *usage2 = (char *) "\
|
||||||
-noh - Don't generate the output header file\n\
|
-noh - Don't generate the output header file\n\
|
||||||
-nomodern - Don't use modern python features which are not backwards compatible \n\
|
-nomodern - Don't use modern python features which are not backwards compatible \n\
|
||||||
-nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n";
|
-nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n";
|
||||||
static const char *usage3 = (char *) "\
|
static const char *usage3 = "\
|
||||||
-noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\
|
-noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\
|
||||||
-nooutputtuple - Use a PyList for appending output values (default) \n\
|
-nooutputtuple - Use a PyList for appending output values (default) \n\
|
||||||
-noproxy - Don't generate proxy classes \n\
|
-noproxy - Don't generate proxy classes \n\
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
#include "swigmod.h"
|
#include "swigmod.h"
|
||||||
|
|
||||||
static const double DEFAULT_NUMBER = .0000123456712312312323;
|
static const double DEFAULT_NUMBER = .0000123456712312312323;
|
||||||
static const int MAX_OVERLOAD_ARGS = 5;
|
|
||||||
|
|
||||||
static String* replaceInitialDash(const String *name)
|
static String* replaceInitialDash(const String *name)
|
||||||
{
|
{
|
||||||
|
|
@ -206,7 +205,7 @@ static void writeListByLine(List *l, File *out, bool quote = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *usage = (char *)"\
|
static const char *usage = "\
|
||||||
R Options (available with -r)\n\
|
R Options (available with -r)\n\
|
||||||
-copystruct - Emit R code to copy C structs (on by default)\n\
|
-copystruct - Emit R code to copy C structs (on by default)\n\
|
||||||
-cppcast - Enable C++ casting operators (default) \n\
|
-cppcast - Enable C++ casting operators (default) \n\
|
||||||
|
|
@ -2161,7 +2160,7 @@ int R::functionWrapper(Node *n) {
|
||||||
/* If we are dealing with a method in an C++ class, then
|
/* If we are dealing with a method in an C++ class, then
|
||||||
add the name of the R function and its definition.
|
add the name of the R function and its definition.
|
||||||
XXX need to figure out how to store the Wrapper if possible in the hash/list.
|
XXX need to figure out how to store the Wrapper if possible in the hash/list.
|
||||||
Would like to be able to do this so that we can potentialy insert
|
Would like to be able to do this so that we can potentially insert
|
||||||
*/
|
*/
|
||||||
if(processing_member_access_function || processing_class_member_function) {
|
if(processing_member_access_function || processing_class_member_function) {
|
||||||
addAccessor(member_name, sfun, iname);
|
addAccessor(member_name, sfun, iname);
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ enum autodoc_t {
|
||||||
AUTODOC_NONE
|
AUTODOC_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Ruby Options (available with -ruby)\n\
|
Ruby Options (available with -ruby)\n\
|
||||||
-autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\
|
-autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\
|
||||||
-cppcast - Enable C++ casting operators (default)\n\
|
-cppcast - Enable C++ casting operators (default)\n\
|
||||||
|
|
@ -1111,7 +1111,7 @@ public:
|
||||||
/* typedef void *VALUE */
|
/* typedef void *VALUE */
|
||||||
SwigType *value = NewSwigType(T_VOID);
|
SwigType *value = NewSwigType(T_VOID);
|
||||||
SwigType_add_pointer(value);
|
SwigType_add_pointer(value);
|
||||||
SwigType_typedef(value, (char *) "VALUE");
|
SwigType_typedef(value, "VALUE");
|
||||||
Delete(value);
|
Delete(value);
|
||||||
|
|
||||||
/* Set module name */
|
/* Set module name */
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "cparse.h"
|
#include "cparse.h"
|
||||||
static int treduce = SWIG_cparse_template_reduce(0);
|
static int treduce = SWIG_cparse_template_reduce(0);
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
Tcl 8 Options (available with -tcl)\n\
|
Tcl 8 Options (available with -tcl)\n\
|
||||||
-itcl - Enable ITcl support\n\
|
-itcl - Enable ITcl support\n\
|
||||||
-nosafe - Leave out SafeInit module function.\n\
|
-nosafe - Leave out SafeInit module function.\n\
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "swigmod.h"
|
#include "swigmod.h"
|
||||||
|
|
||||||
static const char *usage = (char *) "\
|
static const char *usage = "\
|
||||||
UFFI Options (available with -uffi)\n\
|
UFFI Options (available with -uffi)\n\
|
||||||
-identifier-converter <type or funcname> - \n\
|
-identifier-converter <type or funcname> - \n\
|
||||||
Specifies the type of conversion to do on C identifiers\n\
|
Specifies the type of conversion to do on C identifiers\n\
|
||||||
|
|
|
||||||
|
|
@ -467,7 +467,7 @@ static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms,
|
||||||
return func;
|
return func;
|
||||||
|
|
||||||
if (!self)
|
if (!self)
|
||||||
self = (char *) "(this)->";
|
self = "(this)->";
|
||||||
Append(func, self);
|
Append(func, self);
|
||||||
|
|
||||||
if (SwigType_istemplate(name) && (strncmp(Char(name), "operator ", 9) == 0)) {
|
if (SwigType_istemplate(name) && (strncmp(Char(name), "operator ", 9) == 0)) {
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ typedef struct Locator {
|
||||||
} Locator;
|
} Locator;
|
||||||
static int follow_locators = 0;
|
static int follow_locators = 0;
|
||||||
|
|
||||||
void Scanner_push_brackets(Scanner*);
|
static void brackets_push(Scanner *);
|
||||||
void Scanner_clear_brackets(Scanner*);
|
static void brackets_clear(Scanner *);
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* NewScanner()
|
* NewScanner()
|
||||||
|
|
@ -70,7 +70,7 @@ Scanner *NewScanner(void) {
|
||||||
s->error_line = 0;
|
s->error_line = 0;
|
||||||
s->freeze_line = 0;
|
s->freeze_line = 0;
|
||||||
s->brackets = NewList();
|
s->brackets = NewList();
|
||||||
Scanner_push_brackets(s);
|
brackets_push(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ Scanner *NewScanner(void) {
|
||||||
* Delete a scanner object.
|
* Delete a scanner object.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void DelScanner(Scanner * s) {
|
void DelScanner(Scanner *s) {
|
||||||
assert(s);
|
assert(s);
|
||||||
Delete(s->scanobjs);
|
Delete(s->scanobjs);
|
||||||
Delete(s->brackets);
|
Delete(s->brackets);
|
||||||
|
|
@ -98,12 +98,12 @@ void DelScanner(Scanner * s) {
|
||||||
* Clear the contents of a scanner object.
|
* Clear the contents of a scanner object.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Scanner_clear(Scanner * s) {
|
void Scanner_clear(Scanner *s) {
|
||||||
assert(s);
|
assert(s);
|
||||||
Delete(s->str);
|
Delete(s->str);
|
||||||
Clear(s->text);
|
Clear(s->text);
|
||||||
Clear(s->scanobjs);
|
Clear(s->scanobjs);
|
||||||
Scanner_clear_brackets(s);
|
brackets_clear(s);
|
||||||
Delete(s->error);
|
Delete(s->error);
|
||||||
s->str = 0;
|
s->str = 0;
|
||||||
s->error = 0;
|
s->error = 0;
|
||||||
|
|
@ -126,7 +126,7 @@ void Scanner_clear(Scanner * s) {
|
||||||
* immediately before returning to the old text.
|
* immediately before returning to the old text.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Scanner_push(Scanner * s, String *txt) {
|
void Scanner_push(Scanner *s, String *txt) {
|
||||||
assert(s && txt);
|
assert(s && txt);
|
||||||
Push(s->scanobjs, txt);
|
Push(s->scanobjs, txt);
|
||||||
if (s->str) {
|
if (s->str) {
|
||||||
|
|
@ -145,7 +145,7 @@ void Scanner_push(Scanner * s, String *txt) {
|
||||||
* call to Scanner_token().
|
* call to Scanner_token().
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Scanner_pushtoken(Scanner * s, int nt, const_String_or_char_ptr val) {
|
void Scanner_pushtoken(Scanner *s, int nt, const_String_or_char_ptr val) {
|
||||||
assert(s);
|
assert(s);
|
||||||
assert((nt >= 0) && (nt < SWIG_MAXTOKENS));
|
assert((nt >= 0) && (nt < SWIG_MAXTOKENS));
|
||||||
s->nexttoken = nt;
|
s->nexttoken = nt;
|
||||||
|
|
@ -161,7 +161,7 @@ void Scanner_pushtoken(Scanner * s, int nt, const_String_or_char_ptr val) {
|
||||||
* Set the file and line number location of the scanner.
|
* Set the file and line number location of the scanner.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Scanner_set_location(Scanner * s, String *file, int line) {
|
void Scanner_set_location(Scanner *s, String *file, int line) {
|
||||||
Setline(s->str, line);
|
Setline(s->str, line);
|
||||||
Setfile(s->str, file);
|
Setfile(s->str, file);
|
||||||
s->line = line;
|
s->line = line;
|
||||||
|
|
@ -173,7 +173,7 @@ void Scanner_set_location(Scanner * s, String *file, int line) {
|
||||||
* Get the current file.
|
* Get the current file.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *Scanner_file(Scanner * s) {
|
String *Scanner_file(Scanner *s) {
|
||||||
return Getfile(s->str);
|
return Getfile(s->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ String *Scanner_file(Scanner * s) {
|
||||||
*
|
*
|
||||||
* Get the current line number
|
* Get the current line number
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
int Scanner_line(Scanner * s) {
|
int Scanner_line(Scanner *s) {
|
||||||
return s->line;
|
return s->line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ int Scanner_line(Scanner * s) {
|
||||||
*
|
*
|
||||||
* Get the line number on which the current token starts
|
* Get the line number on which the current token starts
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
int Scanner_start_line(Scanner * s) {
|
int Scanner_start_line(Scanner *s) {
|
||||||
return s->start_line;
|
return s->start_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,7 +201,7 @@ int Scanner_start_line(Scanner * s) {
|
||||||
* Change the set of additional characters that can be used to start an identifier.
|
* Change the set of additional characters that can be used to start an identifier.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Scanner_idstart(Scanner * s, const char *id) {
|
void Scanner_idstart(Scanner *s, const char *id) {
|
||||||
free(s->idstart);
|
free(s->idstart);
|
||||||
s->idstart = Swig_copy_string(id);
|
s->idstart = Swig_copy_string(id);
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +211,7 @@ void Scanner_idstart(Scanner * s, const char *id) {
|
||||||
*
|
*
|
||||||
* Returns the next character from the scanner or 0 if end of the string.
|
* Returns the next character from the scanner or 0 if end of the string.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
static char nextchar(Scanner * s) {
|
static char nextchar(Scanner *s) {
|
||||||
int nc;
|
int nc;
|
||||||
if (!s->str)
|
if (!s->str)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -253,8 +253,7 @@ String *Scanner_errmsg(Scanner *s) {
|
||||||
return s->error;
|
return s->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int Scanner_errline(Scanner *s) {
|
||||||
Scanner_errline(Scanner *s) {
|
|
||||||
return s->error_line;
|
return s->error_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,71 +268,99 @@ static void freeze_line(Scanner *s, int val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Scanner_brackets()
|
* brackets_count()
|
||||||
*
|
*
|
||||||
* Returns the number of brackets at the current depth.
|
* Returns the number of brackets at the current depth.
|
||||||
|
* A syntax error with unbalanced ) brackets will result in a NULL pointer return.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
int*
|
static int *brackets_count(Scanner *s) {
|
||||||
Scanner_brackets(Scanner *s) {
|
int *count;
|
||||||
return (int*)(**((void***)Getitem(s->brackets, 0))); /* TODO: Use VoidObj*->ptr instead of void** */
|
if (Len(s->brackets) > 0)
|
||||||
|
count = (int *)Data(Getitem(s->brackets, 0));
|
||||||
|
else
|
||||||
|
count = 0;
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Scanner_clear_brackets()
|
* brackets_clear()
|
||||||
*
|
*
|
||||||
* Resets the current depth and clears all brackets.
|
* Resets the current depth and clears all brackets.
|
||||||
* Usually called at the end of statements;
|
* Usually called at the end of statements;
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
static void brackets_clear(Scanner *s) {
|
||||||
Scanner_clear_brackets(Scanner *s) {
|
|
||||||
Clear(s->brackets);
|
Clear(s->brackets);
|
||||||
Scanner_push_brackets(s); /* base bracket count should always be created */
|
brackets_push(s); /* base bracket count should always be created */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Scanner_inc_brackets()
|
* brackets_increment()
|
||||||
*
|
*
|
||||||
* Increases the number of brackets at the current depth.
|
* Increases the number of brackets at the current depth.
|
||||||
* Usually called when '<' was found.
|
* Usually called when a single '<' is found.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
static void brackets_increment(Scanner *s) {
|
||||||
Scanner_inc_brackets(Scanner *s) {
|
int *count = brackets_count(s);
|
||||||
(*Scanner_brackets(s))++;
|
if (count)
|
||||||
|
(*count)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Scanner_dec_brackets()
|
* brackets_decrement()
|
||||||
*
|
*
|
||||||
* Decreases the number of brackets at the current depth.
|
* Decreases the number of brackets at the current depth.
|
||||||
* Usually called when '>' was found.
|
* Usually called when a single '>' is found.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
static void brackets_decrement(Scanner *s) {
|
||||||
Scanner_dec_brackets(Scanner *s) {
|
int *count = brackets_count(s);
|
||||||
(*Scanner_brackets(s))--;
|
if (count)
|
||||||
|
(*count)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Scanner_push_brackets()
|
* brackets_reset()
|
||||||
|
*
|
||||||
|
* Sets the number of '<' brackets back to zero. Called at the point where
|
||||||
|
* it is no longer possible to have a matching closing >> pair for a template.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
static void brackets_reset(Scanner *s) {
|
||||||
|
int *count = brackets_count(s);
|
||||||
|
if (count)
|
||||||
|
*count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* brackets_push()
|
||||||
*
|
*
|
||||||
* Increases the depth of brackets.
|
* Increases the depth of brackets.
|
||||||
* Usually called when '(' was found.
|
* Usually called when '(' is found.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
static void brackets_push(Scanner *s) {
|
||||||
Scanner_push_brackets(Scanner *s) {
|
|
||||||
int *newInt = malloc(sizeof(int));
|
int *newInt = malloc(sizeof(int));
|
||||||
*newInt = 0;
|
*newInt = 0;
|
||||||
Push(s->brackets, NewVoid(newInt, free));
|
Push(s->brackets, NewVoid(newInt, free));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Scanner_pop_brackets()
|
* brackets_pop()
|
||||||
*
|
*
|
||||||
* Decreases the depth of brackets.
|
* Decreases the depth of brackets.
|
||||||
* Usually called when ')' was found.
|
* Usually called when ')' is found.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
static void brackets_pop(Scanner *s) {
|
||||||
Scanner_pop_brackets(Scanner *s) {
|
if (Len(s->brackets) > 0) /* protect against unbalanced ')' brackets */
|
||||||
Delitem(s->brackets, 0);
|
Delitem(s->brackets, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* brackets_allow_shift()
|
||||||
|
*
|
||||||
|
* Return 1 to allow shift (>>), or 0 if (>>) should be split into (> >).
|
||||||
|
* This is for C++11 template syntax for closing templates.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
static int brackets_allow_shift(Scanner *s) {
|
||||||
|
int *count = brackets_count(s);
|
||||||
|
return !count || (*count <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -341,7 +368,7 @@ Scanner_pop_brackets(Scanner *s) {
|
||||||
*
|
*
|
||||||
* Retract n characters
|
* Retract n characters
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
static void retract(Scanner * s, int n) {
|
static void retract(Scanner *s, int n) {
|
||||||
int i, l;
|
int i, l;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
|
|
@ -482,7 +509,7 @@ static void get_escape(Scanner *s) {
|
||||||
* Return the raw value of the next token.
|
* Return the raw value of the next token.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int look(Scanner * s) {
|
static int look(Scanner *s) {
|
||||||
int state = 0;
|
int state = 0;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
String *str_delimiter = 0;
|
String *str_delimiter = 0;
|
||||||
|
|
@ -526,15 +553,15 @@ static int look(Scanner * s) {
|
||||||
/* Look for single character symbols */
|
/* Look for single character symbols */
|
||||||
|
|
||||||
else if (c == '(') {
|
else if (c == '(') {
|
||||||
Scanner_push_brackets(s);
|
brackets_push(s);
|
||||||
return SWIG_TOKEN_LPAREN;
|
return SWIG_TOKEN_LPAREN;
|
||||||
}
|
}
|
||||||
else if (c == ')') {
|
else if (c == ')') {
|
||||||
Scanner_pop_brackets(s);
|
brackets_pop(s);
|
||||||
return SWIG_TOKEN_RPAREN;
|
return SWIG_TOKEN_RPAREN;
|
||||||
}
|
}
|
||||||
else if (c == ';') {
|
else if (c == ';') {
|
||||||
Scanner_clear_brackets(s);
|
brackets_clear(s);
|
||||||
return SWIG_TOKEN_SEMI;
|
return SWIG_TOKEN_SEMI;
|
||||||
}
|
}
|
||||||
else if (c == ',')
|
else if (c == ',')
|
||||||
|
|
@ -543,8 +570,10 @@ static int look(Scanner * s) {
|
||||||
state = 220;
|
state = 220;
|
||||||
else if (c == '}')
|
else if (c == '}')
|
||||||
return SWIG_TOKEN_RBRACE;
|
return SWIG_TOKEN_RBRACE;
|
||||||
else if (c == '{')
|
else if (c == '{') {
|
||||||
|
brackets_reset(s);
|
||||||
return SWIG_TOKEN_LBRACE;
|
return SWIG_TOKEN_LBRACE;
|
||||||
|
}
|
||||||
else if (c == '=')
|
else if (c == '=')
|
||||||
state = 33;
|
state = 33;
|
||||||
else if (c == '+')
|
else if (c == '+')
|
||||||
|
|
@ -848,28 +877,32 @@ static int look(Scanner * s) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 60: /* shift operators */
|
case 60: /* shift operators */
|
||||||
Scanner_inc_brackets(s);
|
if ((c = nextchar(s)) == 0) {
|
||||||
if ((c = nextchar(s)) == 0)
|
brackets_increment(s);
|
||||||
return SWIG_TOKEN_LESSTHAN;
|
return SWIG_TOKEN_LESSTHAN;
|
||||||
|
}
|
||||||
if (c == '<')
|
if (c == '<')
|
||||||
state = 240;
|
state = 240;
|
||||||
else if (c == '=')
|
else if (c == '=')
|
||||||
return SWIG_TOKEN_LTEQUAL;
|
return SWIG_TOKEN_LTEQUAL;
|
||||||
else {
|
else {
|
||||||
retract(s, 1);
|
retract(s, 1);
|
||||||
|
brackets_increment(s);
|
||||||
return SWIG_TOKEN_LESSTHAN;
|
return SWIG_TOKEN_LESSTHAN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 61:
|
case 61:
|
||||||
Scanner_dec_brackets(s);
|
if ((c = nextchar(s)) == 0) {
|
||||||
if ((c = nextchar(s)) == 0)
|
brackets_decrement(s);
|
||||||
return SWIG_TOKEN_GREATERTHAN;
|
return SWIG_TOKEN_GREATERTHAN;
|
||||||
if (c == '>' && ((*Scanner_brackets(s))<0)) /* go to double >> only, if no template < has been used */
|
}
|
||||||
|
if (c == '>' && brackets_allow_shift(s))
|
||||||
state = 250;
|
state = 250;
|
||||||
else if (c == '=')
|
else if (c == '=')
|
||||||
return SWIG_TOKEN_GTEQUAL;
|
return SWIG_TOKEN_GTEQUAL;
|
||||||
else {
|
else {
|
||||||
retract(s, 1);
|
retract(s, 1);
|
||||||
|
brackets_decrement(s);
|
||||||
return SWIG_TOKEN_GREATERTHAN;
|
return SWIG_TOKEN_GREATERTHAN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1311,7 +1344,6 @@ static int look(Scanner * s) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 240: /* LSHIFT, LSEQUAL */
|
case 240: /* LSHIFT, LSEQUAL */
|
||||||
Scanner_inc_brackets(s);
|
|
||||||
if ((c = nextchar(s)) == 0)
|
if ((c = nextchar(s)) == 0)
|
||||||
return SWIG_TOKEN_LSHIFT;
|
return SWIG_TOKEN_LSHIFT;
|
||||||
else if (c == '=')
|
else if (c == '=')
|
||||||
|
|
@ -1323,7 +1355,6 @@ static int look(Scanner * s) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 250: /* RSHIFT, RSEQUAL */
|
case 250: /* RSHIFT, RSEQUAL */
|
||||||
Scanner_dec_brackets(s);
|
|
||||||
if ((c = nextchar(s)) == 0)
|
if ((c = nextchar(s)) == 0)
|
||||||
return SWIG_TOKEN_RSHIFT;
|
return SWIG_TOKEN_RSHIFT;
|
||||||
else if (c == '=')
|
else if (c == '=')
|
||||||
|
|
@ -1361,7 +1392,7 @@ static int look(Scanner * s) {
|
||||||
* Real entry point to return the next token. Returns 0 if at end of input.
|
* Real entry point to return the next token. Returns 0 if at end of input.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Scanner_token(Scanner * s) {
|
int Scanner_token(Scanner *s) {
|
||||||
int t;
|
int t;
|
||||||
Delete(s->error);
|
Delete(s->error);
|
||||||
if (s->nexttoken >= 0) {
|
if (s->nexttoken >= 0) {
|
||||||
|
|
@ -1385,7 +1416,7 @@ int Scanner_token(Scanner * s) {
|
||||||
* Return the lexene associated with the last returned token.
|
* Return the lexene associated with the last returned token.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *Scanner_text(Scanner * s) {
|
String *Scanner_text(Scanner *s) {
|
||||||
return s->text;
|
return s->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1395,7 +1426,7 @@ String *Scanner_text(Scanner * s) {
|
||||||
* Skips to the end of a line
|
* Skips to the end of a line
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Scanner_skip_line(Scanner * s) {
|
void Scanner_skip_line(Scanner *s) {
|
||||||
char c;
|
char c;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
Clear(s->text);
|
Clear(s->text);
|
||||||
|
|
@ -1420,7 +1451,7 @@ void Scanner_skip_line(Scanner * s) {
|
||||||
* (...). Ignores symbols inside comments or strings.
|
* (...). Ignores symbols inside comments or strings.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
int Scanner_skip_balanced(Scanner *s, int startchar, int endchar) {
|
||||||
char c;
|
char c;
|
||||||
int num_levels = 1;
|
int num_levels = 1;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
|
@ -1557,7 +1588,7 @@ String *Scanner_get_raw_text_balanced(Scanner *s, int startchar, int endchar) {
|
||||||
char c;
|
char c;
|
||||||
int old_line = s->line;
|
int old_line = s->line;
|
||||||
String *old_text = Copy(s->text);
|
String *old_text = Copy(s->text);
|
||||||
int position = Tell(s->str);
|
long position = Tell(s->str);
|
||||||
|
|
||||||
int num_levels = 1;
|
int num_levels = 1;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,13 @@ AC_CHECK_PROGS(YODL2HTML, yodl2html)
|
||||||
|
|
||||||
if test -n "$YODL2MAN"; then
|
if test -n "$YODL2MAN"; then
|
||||||
AC_MSG_CHECKING([yodl2man version >= 2.02])
|
AC_MSG_CHECKING([yodl2man version >= 2.02])
|
||||||
yodl_version=`$YODL2MAN --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.*[0-9]*\).*/\1/g'`
|
[yodl_version=`$YODL2MAN --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.*[0-9]*\).*/\1/g'`]
|
||||||
AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])])
|
AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$YODL2HTML"; then
|
if test -n "$YODL2HTML"; then
|
||||||
AC_MSG_CHECKING([yodl2html version >= 2.02])
|
AC_MSG_CHECKING([yodl2html version >= 2.02])
|
||||||
yodl_version=`$YODL2HTML --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`
|
[yodl_version=`$YODL2HTML --version 2>&1 | grep 'yodl version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
|
||||||
AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])])
|
AX_COMPARE_VERSION([$yodl_version],[ge],[2.02], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no - $yodl_version found])])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue