diff options
Diffstat (limited to 'core/make_binders.py')
-rw-r--r-- | core/make_binders.py | 189 |
1 files changed, 94 insertions, 95 deletions
diff --git a/core/make_binders.py b/core/make_binders.py index 7584722965..74b5e9fda3 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -1,7 +1,7 @@ # -*- coding: ibm850 -*- -template_typed=""" +template_typed = """ #ifdef TYPED_METHOD_BIND template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$> class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind { @@ -17,8 +17,8 @@ public: return Variant::NIL; } #endif - virtual String get_instance_type() const { - return T::get_type_static(); + virtual String get_instance_class() const { + return T::get_class_static(); } virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) { @@ -77,7 +77,7 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$ #endif """ -template=""" +template = """ #ifndef TYPED_METHOD_BIND $iftempl template<$ $ifret class R$ $ifretargs ,$ $arg, class P@$ $iftempl >$ class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind { @@ -97,7 +97,7 @@ public: return Variant::NIL; } #endif - virtual String get_instance_type() const { + virtual String get_instance_class() const { return type_name; } @@ -159,103 +159,102 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$ } u; u.sm=p_method; a->method=u.dm; - a->type_name=T::get_type_static(); + a->type_name=T::get_class_static(); return a; } #endif """ -def make_version(template,nargs,argmax,const,ret): - - intext=template - from_pos=0 - outtext="" - - while(True): - to_pos=intext.find("$",from_pos) - if (to_pos==-1): - outtext+=intext[from_pos:] - break - else: - outtext+=intext[from_pos:to_pos] - end=intext.find("$",to_pos+1) - if (end==-1): - break # ignore - macro=intext[to_pos+1:end] - cmd="" - data="" - - if (macro.find(" ")!=-1): - cmd=macro[0:macro.find(" ")] - data=macro[macro.find(" ")+1:] - else: - cmd=macro - - if (cmd=="argc"): - outtext+=str(nargs) - if (cmd=="ifret" and ret): - outtext+=data - if (cmd=="ifargs" and nargs): - outtext+=data - if (cmd=="ifretargs" and nargs and ret): - outtext+=data - if (cmd=="ifconst" and const): - outtext+=data - elif (cmd=="ifnoconst" and not const): - outtext+=data - elif (cmd=="ifnoret" and not ret): - outtext+=data - elif (cmd=="iftempl" and (nargs>0 or ret)): - outtext+=data - elif (cmd=="arg,"): - for i in range(1,nargs+1): - if (i>1): - outtext+=", " - outtext+=data.replace("@",str(i)) - elif (cmd=="arg"): - for i in range(1,nargs+1): - outtext+=data.replace("@",str(i)) - elif (cmd=="noarg"): - for i in range(nargs+1,argmax+1): - outtext+=data.replace("@",str(i)) - elif (cmd=="noarg"): - for i in range(nargs+1,argmax+1): - outtext+=data.replace("@",str(i)) - - from_pos=end+1 - - return outtext +def make_version(template, nargs, argmax, const, ret): + + intext = template + from_pos = 0 + outtext = "" + + while(True): + to_pos = intext.find("$", from_pos) + if (to_pos == -1): + outtext += intext[from_pos:] + break + else: + outtext += intext[from_pos:to_pos] + end = intext.find("$", to_pos + 1) + if (end == -1): + break # ignore + macro = intext[to_pos + 1:end] + cmd = "" + data = "" + + if (macro.find(" ") != -1): + cmd = macro[0:macro.find(" ")] + data = macro[macro.find(" ") + 1:] + else: + cmd = macro + + if (cmd == "argc"): + outtext += str(nargs) + if (cmd == "ifret" and ret): + outtext += data + if (cmd == "ifargs" and nargs): + outtext += data + if (cmd == "ifretargs" and nargs and ret): + outtext += data + if (cmd == "ifconst" and const): + outtext += data + elif (cmd == "ifnoconst" and not const): + outtext += data + elif (cmd == "ifnoret" and not ret): + outtext += data + elif (cmd == "iftempl" and (nargs > 0 or ret)): + outtext += data + elif (cmd == "arg,"): + for i in range(1, nargs + 1): + if (i > 1): + outtext += ", " + outtext += data.replace("@", str(i)) + elif (cmd == "arg"): + for i in range(1, nargs + 1): + outtext += data.replace("@", str(i)) + elif (cmd == "noarg"): + for i in range(nargs + 1, argmax + 1): + outtext += data.replace("@", str(i)) + elif (cmd == "noarg"): + for i in range(nargs + 1, argmax + 1): + outtext += data.replace("@", str(i)) + + from_pos = end + 1 + + return outtext def run(target, source, env): - versions=10 - versions_ext=6 - text="" - text_ext="" - - for i in range(0,versions+1): - - t="" - t+=make_version(template,i,versions,False,False) - t+=make_version(template_typed,i,versions,False,False) - t+=make_version(template,i,versions,False,True) - t+=make_version(template_typed,i,versions,False,True) - t+=make_version(template,i,versions,True,False) - t+=make_version(template_typed,i,versions,True,False) - t+=make_version(template,i,versions,True,True) - t+=make_version(template_typed,i,versions,True,True) - if (i>=versions_ext): - text_ext+=t - else: - text+=t - - - f=open(target[0].path,"w") - f.write(text) - f.close() - - f=open(target[1].path,"w") - f.write(text_ext) - f.close() + versions = 10 + versions_ext = 6 + text = "" + text_ext = "" + + for i in range(0, versions + 1): + + t = "" + t += make_version(template, i, versions, False, False) + t += make_version(template_typed, i, versions, False, False) + t += make_version(template, i, versions, False, True) + t += make_version(template_typed, i, versions, False, True) + t += make_version(template, i, versions, True, False) + t += make_version(template_typed, i, versions, True, False) + t += make_version(template, i, versions, True, True) + t += make_version(template_typed, i, versions, True, True) + if (i >= versions_ext): + text_ext += t + else: + text += t + + f = open(target[0].path, "w") + f.write(text) + f.close() + + f = open(target[1].path, "w") + f.write(text_ext) + f.close() |