本文整理汇总了C++中MethodBind::has_default_argument方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodBind::has_default_argument方法的具体用法?C++ MethodBind::has_default_argument怎么用?C++ MethodBind::has_default_argument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodBind
的用法示例。
在下文中一共展示了MethodBind::has_default_argument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump
void DocDump::dump(const String &p_file) {
List<StringName> class_list;
ClassDB::get_class_list(&class_list);
class_list.sort_custom<StringName::AlphCompare>();
FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE);
_write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
_write_string(f, 0, "<doc version=\"" + String(VERSION_MKSTRING) + "\" name=\"Engine Types\">");
while (class_list.size()) {
String name = class_list.front()->get();
String header = "<class name=\"" + name + "\"";
String inherits = ClassDB::get_parent_class(name);
if (inherits != "")
header += " inherits=\"" + inherits + "\"";
String category = ClassDB::get_category(name);
if (category == "")
category = "Core";
header += " category=\"" + category + "\"";
header += ">";
_write_string(f, 0, header);
_write_string(f, 1, "<brief_description>");
_write_string(f, 1, "</brief_description>");
_write_string(f, 1, "<description>");
_write_string(f, 1, "</description>");
_write_string(f, 1, "<methods>");
List<MethodInfo> method_list;
ClassDB::get_method_list(name, &method_list, true);
method_list.sort();
for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
if (E->get().name == "" || E->get().name[0] == '_')
continue; //hiden
MethodBind *m = ClassDB::get_method(name, E->get().name);
String qualifiers;
if (E->get().flags & METHOD_FLAG_CONST)
qualifiers += "qualifiers=\"const\"";
_write_string(f, 2, "<method name=\"" + _escape_string(E->get().name) + "\" " + qualifiers + " >");
for (int i = -1; i < E->get().arguments.size(); i++) {
PropertyInfo arginfo;
if (i == -1) {
arginfo = E->get().return_val;
String type_name = (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) ? arginfo.hint_string : Variant::get_type_name(arginfo.type);
if (arginfo.type == Variant::NIL)
continue;
_write_string(f, 3, "<return type=\"" + type_name + "\">");
} else {
arginfo = E->get().arguments[i];
String type_name;
if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE)
type_name = arginfo.hint_string;
else if (arginfo.type == Variant::NIL)
type_name = "var";
else
type_name = Variant::get_type_name(arginfo.type);
if (m && m->has_default_argument(i)) {
Variant default_arg = m->get_default_argument(i);
String default_arg_text = String(_escape_string(m->get_default_argument(i)));
switch (default_arg.get_type()) {
case Variant::NIL:
default_arg_text = "NULL";
break;
// atomic types
case Variant::BOOL:
if (bool(default_arg))
default_arg_text = "true";
else
default_arg_text = "false";
break;
case Variant::INT:
case Variant::REAL:
//keep it
break;
case Variant::STRING: // 15
case Variant::NODE_PATH: // 15
default_arg_text = "\"" + default_arg_text + "\"";
break;
case Variant::TRANSFORM:
if (default_arg.operator Transform() == Transform()) {
default_arg_text = "";
//.........这里部分代码省略.........
示例2: get_method_list
void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance, bool p_exclude_from_properties) {
OBJTYPE_RLOCK;
ClassInfo *type = classes.getptr(p_class);
while (type) {
if (type->disabled) {
if (p_no_inheritance)
break;
type = type->inherits_ptr;
continue;
}
#ifdef DEBUG_METHODS_ENABLED
for (List<MethodInfo>::Element *E = type->virtual_methods.front(); E; E = E->next()) {
p_methods->push_back(E->get());
}
for (List<StringName>::Element *E = type->method_order.front(); E; E = E->next()) {
MethodBind *method = type->method_map.get(E->get());
MethodInfo minfo;
minfo.name = E->get();
minfo.id = method->get_method_id();
if (p_exclude_from_properties && type->methods_in_properties.has(minfo.name))
continue;
for (int i = 0; i < method->get_argument_count(); i++) {
//Variant::Type t=method->get_argument_type(i);
minfo.arguments.push_back(method->get_argument_info(i));
}
minfo.return_val = method->get_return_info();
minfo.flags = method->get_hint_flags();
for (int i = 0; i < method->get_argument_count(); i++) {
if (method->has_default_argument(i))
minfo.default_arguments.push_back(method->get_default_argument(i));
}
p_methods->push_back(minfo);
}
#else
const StringName *K = NULL;
while ((K = type->method_map.next(K))) {
MethodBind *m = type->method_map[*K];
MethodInfo mi;
mi.name = m->get_name();
p_methods->push_back(mi);
}
#endif
if (p_no_inheritance)
break;
type = type->inherits_ptr;
}
}
示例3: generate
void DocData::generate(bool p_basic_types) {
List<StringName> classes;
ObjectTypeDB::get_type_list(&classes);
classes.sort_custom<StringName::AlphCompare>();
while(classes.size()) {
String name=classes.front()->get();
String cname=name;
if (cname.begins_with("_")) //proxy class
cname=cname.substr(1,name.length());
class_list[cname]=ClassDoc();
ClassDoc& c = class_list[cname];
c.name=cname;
c.inherits=ObjectTypeDB::type_inherits_from(name);
c.category=ObjectTypeDB::get_category(name);
List<MethodInfo> method_list;
ObjectTypeDB::get_method_list(name,&method_list,true);
method_list.sort();
for(List<MethodInfo>::Element *E=method_list.front();E;E=E->next()) {
if (E->get().name=="" || (E->get().name[0]=='_' && !(E->get().flags&METHOD_FLAG_VIRTUAL)))
continue; //hiden, dont count
MethodDoc method;
method.name=E->get().name;
MethodBind *m = ObjectTypeDB::get_method(name,E->get().name);
if (E->get().flags&METHOD_FLAG_VIRTUAL)
method.qualifiers="virtual";
if (E->get().flags&METHOD_FLAG_CONST) {
if (method.qualifiers!="")
method.qualifiers+=" ";
method.qualifiers+="const";
}
for(int i=-1;i<E->get().arguments.size();i++) {
PropertyInfo arginfo;
if (i==-1) {
arginfo=E->get().return_val;
#ifdef DEBUG_METHODS_ENABLED
if (m && m->get_return_type()!=StringName())
method.return_type=m->get_return_type();
else if (method.name.find(":")!=-1) {
method.return_type=method.name.get_slice(":",1);
method.name=method.name.get_slice(":",0);
} else if (arginfo.type!=Variant::NIL) // {
#endif
method.return_type=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type);
// }
} else {
ArgumentDoc argument;
arginfo=E->get().arguments[i];
String type_name;
if (arginfo.name.find(":")!=-1) {
type_name=arginfo.name.get_slice(":",1);
arginfo.name=arginfo.name.get_slice(":",0);
} else if (arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE) {
type_name=arginfo.hint_string;
} else if (arginfo.type==Variant::NIL)
type_name="Variant";
else
type_name=Variant::get_type_name(arginfo.type);
if (arginfo.type==Variant::OBJECT) {
//print_line("validate: "+cname+"::"+method.name);
}
if (m && m->has_default_argument(i)) {
Variant default_arg=m->get_default_argument(i);
String default_arg_text=m->get_default_argument(i);
switch(default_arg.get_type()) {
case Variant::NIL:
default_arg_text="NULL";
break;
// atomic types
case Variant::BOOL:
//.........这里部分代码省略.........