changes to support cast ranking for dispatch and/or overloading
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8044 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
1733655950
commit
84b96ab3ad
13 changed files with 63 additions and 42 deletions
|
|
@ -29,12 +29,17 @@ struct Overloaded {
|
|||
};
|
||||
|
||||
static int fast_dispatch_mode = 0;
|
||||
static int cast_dispatch_mode = 0;
|
||||
|
||||
/* Set fast_dispatch_mode */
|
||||
void Wrapper_fast_dispatch_mode_set(int flag) {
|
||||
fast_dispatch_mode = flag;
|
||||
}
|
||||
|
||||
void Wrapper_cast_dispatch_mode_set(int flag) {
|
||||
cast_dispatch_mode = flag;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_overload_rank()
|
||||
*
|
||||
|
|
@ -367,7 +372,7 @@ Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
|
|||
String *sw = NewString("");
|
||||
Printf(f,"{\n");
|
||||
Printf(f,"unsigned long _index = 0;\n");
|
||||
Printf(f,"double _rank = 0;\n");
|
||||
Printf(f,"double _rank = 0; \n");
|
||||
|
||||
/* Get a list of methods ranked by precedence values and argument count */
|
||||
List *dispatch = Swig_overload_rank(n, true);
|
||||
|
|
@ -397,7 +402,7 @@ Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
|
|||
Printf(f,"if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
}
|
||||
Printf(f,"double _ranki = 0;\n");
|
||||
Printf(f,"double _pi = pow(4,%d);\n",num_arguments);
|
||||
Printf(f,"double _pi = 1;\n",num_arguments);
|
||||
|
||||
/* create a list with the wrappers that collide with the
|
||||
current one based on argument number */
|
||||
|
|
@ -466,7 +471,7 @@ Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
|
|||
|
||||
if (emitcheck) {
|
||||
if (need_v) {
|
||||
Printf(f,"int _v = 1;\n");
|
||||
Printf(f,"int _v;\n");
|
||||
need_v = 0;
|
||||
}
|
||||
if (j >= num_required) {
|
||||
|
|
@ -478,8 +483,8 @@ Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
|
|||
Printv(f,"{\n",tm,"}\n",NIL);
|
||||
fn = i + 1;
|
||||
Printf(f, "if (!_v) goto check_%d;\n", fn);
|
||||
Printf(f, "_ranki += _0.25*v*_pi;\n", fn);
|
||||
Printf(f, "_pi *= 0.25;\n", fn);
|
||||
Printf(f, "_ranki += _v*_pi;\n", fn);
|
||||
Printf(f, "_pi *= SWIG_MAX_CAST_RANK;\n", fn);
|
||||
}
|
||||
}
|
||||
if (!Getattr(pj,"tmap:in:SWIGTYPE") && Getattr(pj,"tmap:typecheck:SWIGTYPE")) {
|
||||
|
|
@ -499,7 +504,7 @@ Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
|
|||
/* close braces */
|
||||
for (/* empty */; num_braces > 0; num_braces--) Printf(f, "}\n");
|
||||
|
||||
Printf(f,"if (_ranki > _rank) { _rank = _ranki; _index = %d;}\n",i+1);
|
||||
Printf(f,"if (!_index || (_ranki < _rank)) { _rank = _ranki; _index = %d;}\n",i+1);
|
||||
String *lfmt = ReplaceFormat (fmt, num_arguments);
|
||||
Printf(sw, "case %d:\n", i+1);
|
||||
Printf(sw, Char(lfmt),Getattr(ni,"wrap:name"));
|
||||
|
|
|
|||
|
|
@ -321,6 +321,8 @@ void emit_mark_varargs(ParmList *l);
|
|||
void emit_action(Node *n, Wrapper *f);
|
||||
void Swig_overload_check(Node *n);
|
||||
String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *);
|
||||
String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *);
|
||||
String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *);
|
||||
SwigType *cplus_value_type(SwigType *t);
|
||||
|
||||
/* directors.cxx start */
|
||||
|
|
@ -351,6 +353,7 @@ void Wrapper_virtual_elimination_mode_set(int);
|
|||
void Wrapper_director_mode_set(int);
|
||||
void Wrapper_director_protected_mode_set(int);
|
||||
void Wrapper_fast_dispatch_mode_set(int);
|
||||
void Wrapper_cast_dispatch_mode_set(int);
|
||||
|
||||
void clean_overloaded(Node *n);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue