2014-02-10 01:10:30 +00:00
|
|
|
# -*- coding: ibm850 -*-
|
|
|
|
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
template_typed = """
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifdef TYPED_METHOD_BIND
|
|
|
|
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
|
|
|
|
class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind {
|
|
|
|
public:
|
2016-04-02 18:26:12 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
$ifret R$ $ifnoret void$ (T::*method)($arg, P@$) $ifconst const$;
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const { return _get_argument_type(p_arg); }
|
|
|
|
Variant::Type _get_argument_type(int p_argument) const {
|
2017-08-09 09:54:27 +00:00
|
|
|
$ifret if (p_argument==-1) return (Variant::Type)GetTypeInfo<R>::VARIANT_TYPE;$
|
|
|
|
$arg if (p_argument==(@-1)) return (Variant::Type)GetTypeInfo<P@>::VARIANT_TYPE;
|
2014-02-10 01:10:30 +00:00
|
|
|
$
|
|
|
|
return Variant::NIL;
|
|
|
|
}
|
2017-08-23 22:10:32 +00:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_argument) const {
|
|
|
|
$ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_info();$
|
|
|
|
$arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_info();
|
2017-08-09 09:54:27 +00:00
|
|
|
$
|
2017-08-23 22:10:32 +00:00
|
|
|
return PropertyInfo();
|
2017-08-09 09:54:27 +00:00
|
|
|
}
|
2016-04-02 18:26:12 +00:00
|
|
|
#endif
|
2017-01-03 02:03:46 +00:00
|
|
|
virtual String get_instance_class() const {
|
|
|
|
return T::get_class_static();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) {
|
2016-04-02 18:26:12 +00:00
|
|
|
|
2017-08-24 20:58:51 +00:00
|
|
|
T *instance=Object::cast_to<T>(p_object);
|
2014-02-10 01:10:30 +00:00
|
|
|
r_error.error=Variant::CallError::CALL_OK;
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
|
|
|
|
|
|
|
ERR_FAIL_COND_V(!instance,Variant());
|
|
|
|
if (p_arg_count>get_argument_count()) {
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
|
|
|
r_error.argument=get_argument_count();
|
|
|
|
return Variant();
|
|
|
|
|
|
|
|
}
|
|
|
|
if (p_arg_count<(get_argument_count()-get_default_argument_count())) {
|
|
|
|
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
|
|
|
r_error.argument=get_argument_count()-get_default_argument_count();
|
|
|
|
return Variant();
|
|
|
|
}
|
|
|
|
$arg CHECK_ARG(@);
|
|
|
|
$
|
|
|
|
#endif
|
|
|
|
$ifret Variant ret = $(instance->*method)($arg, _VC(@)$);
|
|
|
|
$ifret return Variant(ret);$
|
|
|
|
$ifnoret return Variant();$
|
|
|
|
}
|
2016-04-02 18:26:12 +00:00
|
|
|
|
2016-06-23 05:54:30 +00:00
|
|
|
#ifdef PTRCALL_ENABLED
|
2016-06-23 02:12:20 +00:00
|
|
|
virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
|
2016-06-23 05:54:30 +00:00
|
|
|
|
2017-08-24 20:58:51 +00:00
|
|
|
T *instance=Object::cast_to<T>(p_object);
|
2016-06-23 05:54:30 +00:00
|
|
|
$ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ;
|
|
|
|
}
|
2016-06-23 02:12:20 +00:00
|
|
|
#endif
|
2014-02-10 01:10:30 +00:00
|
|
|
MethodBind$argc$$ifret R$$ifconst C$ () {
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
|
|
|
_set_const($ifconst true$$ifnoconst false$);
|
|
|
|
_generate_argument_types($argc$);
|
|
|
|
#else
|
|
|
|
set_argument_count($argc$);
|
2016-04-02 18:26:12 +00:00
|
|
|
#endif
|
2016-08-02 22:11:05 +00:00
|
|
|
|
|
|
|
$ifret _set_returns(true); $
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
|
|
|
|
MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$) $ifconst const$ ) {
|
|
|
|
|
2016-04-02 18:26:12 +00:00
|
|
|
MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$> * a = memnew( (MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$>) );
|
2014-02-10 01:10:30 +00:00
|
|
|
a->method=p_method;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
"""
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
template = """
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef TYPED_METHOD_BIND
|
|
|
|
$iftempl template<$ $ifret class R$ $ifretargs ,$ $arg, class P@$ $iftempl >$
|
|
|
|
class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
StringName type_name;
|
|
|
|
$ifret R$ $ifnoret void$ (__UnexistingClass::*method)($arg, P@$) $ifconst const$;
|
|
|
|
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
|
|
|
virtual Variant::Type _gen_argument_type(int p_arg) const { return _get_argument_type(p_arg); }
|
|
|
|
|
|
|
|
Variant::Type _get_argument_type(int p_argument) const {
|
2017-08-09 09:54:27 +00:00
|
|
|
$ifret if (p_argument==-1) return (Variant::Type)GetTypeInfo<R>::VARIANT_TYPE;$
|
|
|
|
$arg if (p_argument==(@-1)) return (Variant::Type)GetTypeInfo<P@>::VARIANT_TYPE;
|
2014-02-10 01:10:30 +00:00
|
|
|
$
|
|
|
|
return Variant::NIL;
|
|
|
|
}
|
2017-08-09 09:54:27 +00:00
|
|
|
|
2017-08-23 22:10:32 +00:00
|
|
|
virtual PropertyInfo _gen_argument_type_info(int p_argument) const {
|
|
|
|
$ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_info();$
|
|
|
|
$arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_info();
|
2017-08-09 09:54:27 +00:00
|
|
|
$
|
2017-08-23 22:10:32 +00:00
|
|
|
return PropertyInfo();
|
2017-08-09 09:54:27 +00:00
|
|
|
}
|
2017-08-23 22:10:32 +00:00
|
|
|
|
2016-04-02 18:26:12 +00:00
|
|
|
#endif
|
2017-01-03 02:03:46 +00:00
|
|
|
virtual String get_instance_class() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
return type_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) {
|
|
|
|
|
|
|
|
__UnexistingClass *instance = (__UnexistingClass*)p_object;
|
|
|
|
|
|
|
|
r_error.error=Variant::CallError::CALL_OK;
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
|
|
|
|
|
|
|
ERR_FAIL_COND_V(!instance,Variant());
|
|
|
|
if (p_arg_count>get_argument_count()) {
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
|
|
|
|
r_error.argument=get_argument_count();
|
|
|
|
return Variant();
|
2016-04-02 18:26:12 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
if (p_arg_count<(get_argument_count()-get_default_argument_count())) {
|
|
|
|
|
|
|
|
r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
|
|
|
r_error.argument=get_argument_count()-get_default_argument_count();
|
|
|
|
return Variant();
|
|
|
|
}
|
2016-04-02 18:26:12 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
$arg CHECK_ARG(@);
|
|
|
|
$
|
|
|
|
#endif
|
|
|
|
$ifret Variant ret = $(instance->*method)($arg, _VC(@)$);
|
|
|
|
$ifret return Variant(ret);$
|
|
|
|
$ifnoret return Variant();$
|
|
|
|
}
|
2016-06-23 02:12:20 +00:00
|
|
|
#ifdef PTRCALL_ENABLED
|
|
|
|
virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
|
2016-06-23 05:54:30 +00:00
|
|
|
__UnexistingClass *instance = (__UnexistingClass*)p_object;
|
|
|
|
$ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret) $ ;
|
|
|
|
}
|
|
|
|
#endif
|
2014-02-10 01:10:30 +00:00
|
|
|
MethodBind$argc$$ifret R$$ifconst C$ () {
|
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
|
|
|
_set_const($ifconst true$$ifnoconst false$);
|
|
|
|
_generate_argument_types($argc$);
|
|
|
|
#else
|
|
|
|
set_argument_count($argc$);
|
2016-04-02 18:26:12 +00:00
|
|
|
#endif
|
2016-08-02 22:11:05 +00:00
|
|
|
$ifret _set_returns(true); $
|
|
|
|
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
|
|
|
|
MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$) $ifconst const$ ) {
|
|
|
|
|
|
|
|
MethodBind$argc$$ifret R$$ifconst C$ $iftempl <$ $ifret R$ $ifretargs ,$ $arg, P@$ $iftempl >$ * a = memnew( (MethodBind$argc$$ifret R$$ifconst C$ $iftempl <$ $ifret R$ $ifretargs ,$ $arg, P@$ $iftempl >$) );
|
|
|
|
union {
|
|
|
|
|
|
|
|
$ifret R$ $ifnoret void$ (T::*sm)($arg, P@$) $ifconst const$;
|
|
|
|
$ifret R$ $ifnoret void$ (__UnexistingClass::*dm)($arg, P@$) $ifconst const$;
|
|
|
|
} u;
|
|
|
|
u.sm=p_method;
|
|
|
|
a->method=u.dm;
|
2017-01-03 02:03:46 +00:00
|
|
|
a->type_name=T::get_class_static();
|
2014-02-10 01:10:30 +00:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
def make_version(template, nargs, argmax, const, ret):
|
2016-04-02 18:26:12 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
intext = template
|
|
|
|
from_pos = 0
|
|
|
|
outtext = ""
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
while(True):
|
2016-10-30 17:57:40 +00:00
|
|
|
to_pos = intext.find("$", from_pos)
|
|
|
|
if (to_pos == -1):
|
|
|
|
outtext += intext[from_pos:]
|
2016-10-30 17:44:57 +00:00
|
|
|
break
|
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
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:]
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
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
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
return outtext
|
2016-04-02 18:26:12 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
def run(target, source, env):
|
|
|
|
|
Added all missing VisualServer bindings
- Added bindings for multimesh, immediate, skeleton, light, reflection probe, gi probe, lightmap, particles, camera, environment, scenario, instance
- Removed draw and sync, were duplicates of force_* equivalents
- Bumped binders max arguments from 11 to 13
- Wrote some wrappers as not all methods were variant-friendly
2018-01-20 15:18:51 +00:00
|
|
|
versions = 13
|
2016-10-30 17:57:40 +00:00
|
|
|
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
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
text += t
|
2016-10-30 17:44:57 +00:00
|
|
|
|
2018-03-10 17:37:33 +00:00
|
|
|
with open(target[0].path, "w") as f:
|
|
|
|
f.write(text)
|
2016-10-30 17:44:57 +00:00
|
|
|
|
2018-03-10 17:37:33 +00:00
|
|
|
with open(target[1].path, "w") as f:
|
|
|
|
f.write(text_ext)
|