diff options
author | ng420 <nish.gupta01@gmail.com> | 2016-08-16 00:32:11 +0100 |
---|---|---|
committer | ng420 <nish.gupta01@gmail.com> | 2016-08-16 00:32:11 +0100 |
commit | 2fdbf26c14447ceaa1783888a6bec540615606dd (patch) | |
tree | 319eb7e56c2a5087cc8f13728fb0a652b897c9e6 | |
parent | d522d41d73dee4b3fb7de644cbac197492b7767d (diff) | |
download | swig-2fdbf26c14447ceaa1783888a6bec540615606dd.tar.gz |
Clean-up self written overload dispatch
-rw-r--r-- | Source/Modules/hhvm.cxx | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/Source/Modules/hhvm.cxx b/Source/Modules/hhvm.cxx index c704b2788..bd43b2276 100644 --- a/Source/Modules/hhvm.cxx +++ b/Source/Modules/hhvm.cxx @@ -490,142 +490,6 @@ public: Printf(f_link, "}\n\n"); } - static bool hhvm_print_typecheck(String *f, int j, Parm *pj, bool implicitconvtypecheckoff) { - char tmp[256], rtmp[256]; - sprintf(tmp, Char(argv_template_string), j); - sprintf(rtmp, "targ%d", j); - String *tm = Getattr(pj, "tmap:typecheck"); - if (tm) { - tm = Copy(tm); - Replaceid(tm, Getattr(pj, "lname"), "_v"); - String *conv = Getattr(pj, "implicitconv"); - if (conv && !implicitconvtypecheckoff) { - Replaceall(tm, "$implicitconv", conv); - } else { - Replaceall(tm, "$implicitconv", "0"); - } - Replaceall(tm, "$input", tmp); - Replaceall(tm, "$result", rtmp); - Printv(f, tm, "\n", NIL); - Delete(tm); - return true; - } else - return false; - } - - String *hhvm_overload_dispatch(Node *n) { - int i, j; - - int maxargs = 1; - - String *f = NewString(""); - - /* Get a list of methods ranked by precedence values and argument count */ - List *dispatch = Swig_overload_rank(n, true); - int nfunc = Len(dispatch); - bool is_void_return; - - /* Loop over the functions */ - - for (i = 0; i < nfunc; i++) { - Node *ni = Getitem(dispatch, i); - Parm *pi = Getattr(ni, "wrap:parms"); - SwigType *return_type = SwigType_namestr(Getattr(n,"type")); - bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0; - int num_required = emit_num_required(pi); - int num_arguments = emit_num_arguments(pi); - if (num_arguments > maxargs) - maxargs = num_arguments; - - if (num_required == num_arguments) { - Printf(f, "if (%s == %d) {\n", argc_template_string, num_required); - } else { - Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments); - } - - if (num_arguments) { - Printf(f, "bool _v;\n"); - } - - int num_braces = 0; - bool prev_comma; - j = 0; - Parm *pj = pi; - while (pj) { - if (checkAttribute(pj, "tmap:in:numinputs", "0")) { - pj = Getattr(pj, "tmap:in:next"); - continue; - } - if (j >= num_required) { - String *lfmt = NewString(""); - prev_comma = false; - is_void_return = (Cmp(return_type, "void") == 0); - if (!is_void_return) { - Printf(lfmt, "return "); - } - Printf(lfmt, "%%s("); - for (int it = 0; it < num_arguments; it++) { - if (prev_comma) { - Printf(lfmt, ", ", it); - } - prev_comma = true; - Printf(lfmt, "targ%d", it); - } - Printf(lfmt, ");\n"); - if (is_void_return) { - Printf(lfmt, "return HPHP::Variant();\n"); - } - Printf(f, "if (%s <= %d) {\n", argc_template_string, j); - Printf(f, Char(lfmt), Getattr(ni, "wrap:name")); - Printf(f, "}\n"); - Delete(lfmt); - } - if (hhvm_print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj, implicitconvtypecheckoff)) { - Printf(f, "if (_v) {\n"); - num_braces++; - } - if (!Getattr(pj, "tmap:in:SWIGTYPE") && Getattr(pj, "tmap:typecheck:SWIGTYPE")) { - /* we emit a warning if the argument defines the 'in' typemap, but not the 'typecheck' one */ - Swig_warning(WARN_TYPEMAP_TYPECHECK_UNDEF, Getfile(ni), Getline(ni), - "Overloaded method %s with no explicit typecheck typemap for arg %d of type '%s'\n", - Swig_name_decl(n), j, SwigType_str(Getattr(pj, "type"), 0)); - } - Parm *pk = Getattr(pj, "tmap:in:next"); - if (pk) - pj = pk; - else - pj = nextSibling(pj); - j++; - } - String *lfmt = NewString(""); - is_void_return = (Cmp(return_type, "void") == 0); - if (!is_void_return) { - Printf(lfmt, "return "); - } - Printf(lfmt, "%%s("); - prev_comma = false; - for (int it = 0; it < num_arguments; it++) { - if (prev_comma) { - Printf(lfmt, ", ", it); - } - prev_comma = true; - Printf(lfmt, "targ%d", it); - } - Printf(lfmt, ");\n"); - if (is_void_return) { - Printf(lfmt, "return HPHP::Variant();\n"); - } - Printf(f, Char(lfmt), Getattr(ni, "wrap:name")); - Delete(lfmt); - /* close braces */ - for ( /* empty */ ; num_braces > 0; num_braces--) - Printf(f, "}\n"); - Printf(f, "}\n"); - } - Delete(dispatch); - return f; - } - void dispatchFunction(Node *n) { /* Last node in overloaded chain */ @@ -639,11 +503,6 @@ public: String *name = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(name); - // Printf(f_register, " HHVM_FE(%s);\n", name); - // Printf(f_phpcode, "<<__Native>>\n"); - // Printf(f_phpcode, "function %s(...$argv): mixed;\n\n", name); - // Printv(wrapper->def, "Variant HHVM_FUNCTION(", name, ", const Array& argv) {\n", NIL); - Printf(wrapper->def, "HPHP::Variant %s(const HPHP::Array& argv) {\n", wname); Wrapper_add_local(wrapper, "argc", "int argc"); Printf(wrapper->code, "argc = argv.size();\n"); |