add castmode in python and cleaning the castdispatch mechanism

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8051 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-12-23 09:22:17 +00:00
commit 6bf5187168
16 changed files with 461 additions and 101 deletions

View file

@ -1,6 +1,46 @@
Version 1.3.28 (unreleased).
===========================
12/23/2005: mmatus
[python] Add the castmode that allows the python
type casting to occurr.
For example, if you have 'int foo(int)', now
class Ai():
def __init__(self,x):
self.x = x
def __int__(self):
return self.x
foo(1) // Ok
foo(1.0) // Ok
foo(1.3) // Error
a = Ai(4)
foo(ai) // Ok
The castmode, which can be enable either with the
'-castmode' option or the %module("castmode") option, uses
the new cast/rank dispatch mechanism. Hence, now if you
have 'int foo(int); int foo(double);', the following works
as expected:
foo(1) -> foo(int)
foo(1.0) -> foo(double)
ai = Ai(4)
foo(ai) -> foo(int)
Note1: the 'castmode' could disrupt some specialized
typemaps. In particular, the "implicit.i" library seems to
have problem with the castmode. But besides that one, the
entire test-suite compiles fine with and without the
castmode.
Note2: the castmode disables the -fatdispatch option.
See the file overload_dispatch_cast_runme.py file for
new cases and examples.
12/22/2005: mmatus
Add the cast and rank mechanism to dispatch overloading
functions. The UTF supports it now, but for each language