'oficially' add fastdispatch option

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7953 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-12-08 21:30:06 +00:00
commit 3db0e56b49
7 changed files with 215 additions and 10 deletions

View file

@ -59,7 +59,8 @@ static const char *usage1 = (const char*)"\
-features directors,autodoc=1 \n\
if not explicit value is given to the feature, a '1' is used \n\
-fvirtual - Compile in virtual elimination mode\n\
-fdispatch - Use fast dispatch mode, which produces faster overload dispatcher code\n\
-fastdispatch - Enable fast dispatch mode, which produces faster overload dispatcher code\n\
-nofastdispatch - Disable fast dispatch mode (default)\n\
-Fstandard - Display error/warning messages in commonly used format\n\
-Fmicrosoft - Display error/warning messages in Microsoft format\n\
-help - This output\n\
@ -389,9 +390,12 @@ void SWIG_getoptions(int argc, char *argv[])
} else if (strcmp(argv[i],"-fvirtual") == 0) {
Wrapper_virtual_elimination_mode_set(1);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-fdispatch") == 0) {
} else if (strcmp(argv[i],"-fastdispatch") == 0) {
Wrapper_fast_dispatch_mode_set(1);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-nofastdispatch") == 0) {
Wrapper_fast_dispatch_mode_set(0);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-directors") == 0) {
Hash *features_hash = Swig_cparse_features();
String *name = NewString("");

View file

@ -372,6 +372,7 @@ Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
/* Loop over the functions */
for (i = 0; i < nfunc; i++) {
int fn = 0;
Node *ni = Getitem(dispatch,i);
Parm *pi = Getattr(ni,"wrap:parms");
int num_required = emit_num_required(pi);
@ -410,8 +411,7 @@ Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
int num_braces = 0;
bool test=(Len(coll)>0 && num_arguments);
if (test) {
Printf(f,"int _v=1;\n");
int need_v = 1;
j = 0;
Parm *pj = pi;
while (pj) {
@ -459,6 +459,10 @@ Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
}
if (emitcheck) {
if (need_v) {
Printf(f,"int _v = 1;\n");
need_v = 0;
}
if (j >= num_required) {
Printf(f, "if (%s > %d) {\n", argc_template_string, j);
num_braces++;
@ -466,7 +470,8 @@ Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
String *tmp=NewStringf(argv_template_string, j);
Replaceall(tm,"$input", tmp);
Printv(f,"{\n",tm,"}\n",NIL);
Printf(f, "if (!_v) goto fail_%s;\n", Getattr(ni, "wrap:name"));
fn = i + 1;
Printf(f, "if (!_v) goto check_%d;\n", fn);
}
}
if (!Getattr(pj,"tmap:in:SWIGTYPE") && Getattr(pj,"tmap:typecheck:SWIGTYPE")) {
@ -491,7 +496,7 @@ Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
Printf(f, Char(lfmt),Getattr(ni,"wrap:name"));
Printf(f,"}\n"); /* braces closes "if" for this method */
Printf(f, "fail_%s:\n\n", Getattr(ni,"wrap:name"));
if (fn) Printf(f, "check_%d:\n\n", fn);
Delete (lfmt);
Delete(coll);