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: 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=""; } default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")"; break; case Variant::VECTOR2: // 5 case Variant::RECT2: case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: case Variant::_AABB: //sorry naming convention fail :( not like it's used often // 10 case Variant::MATRIX3: case Variant::COLOR: case Variant::RAW_ARRAY: case Variant::INT_ARRAY: case Variant::REAL_ARRAY: case Variant::STRING_ARRAY: //25 case Variant::VECTOR2_ARRAY: case Variant::VECTOR3_ARRAY: case Variant::COLOR_ARRAY: default_arg_text=Variant::get_type_name(default_arg.get_type())+"("+default_arg_text+")"; break; case Variant::OBJECT: case Variant::INPUT_EVENT: case Variant::DICTIONARY: // 20 case Variant::ARRAY: case Variant::_RID: case Variant::IMAGE: //case Variant::RESOURCE: default_arg_text=Variant::get_type_name(default_arg.get_type())+"()"; break; default: {} } argument.type=type_name; argument.name=arginfo.name; argument.default_value=default_arg_text; } else { argument.type=type_name; argument.name=arginfo.name; } if (arginfo.type==Variant::OBJECT) { //print_line("validate: "+cname+"::"+method.name); } method.arguments.push_back(argument); } /* String hint; switch(arginfo.hint) { case PROPERTY_HINT_DIR: hint="A directory."; break; case PROPERTY_HINT_RANGE: hint="Range - min: "+arginfo.hint_string.get_slice(",",0)+" max: "+arginfo.hint_string.get_slice(",",1)+" step: "+arginfo.hint_string.get_slice(",",2); break; case PROPERTY_HINT_ENUM: hint="Values: "; for(int j=0;j<arginfo.hint_string.get_slice_count(",");j++) { if (j>0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(j); } break; case PROPERTY_HINT_LENGTH: hint="Length: "+arginfo.hint_string; break; case PROPERTY_HINT_FLAGS: hint="Values: "; for(int j=0;j<arginfo.hint_string.get_slice_count(",");j++) { if (j>0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(1<<j); } break; case PROPERTY_HINT_FILE: hint="A file:"; break; //case PROPERTY_HINT_RESOURCE_TYPE: hint="Type: "+arginfo.hint_string; break; }; if (hint!="") _write_string(f,4,hint); */ } c.methods.push_back(method); } List<MethodInfo> signal_list; ObjectTypeDB::get_signal_list(name,&signal_list,true); if (signal_list.size()) { for(List<MethodInfo>::Element *EV=signal_list.front();EV;EV=EV->next()) { MethodDoc signal; signal.name=EV->get().name; for(int i=0;i<EV->get().arguments.size();i++) { PropertyInfo arginfo=EV->get().arguments[i]; ArgumentDoc argument; argument.name=arginfo.name; argument.type=Variant::get_type_name(arginfo.type); signal.arguments.push_back(argument); } c.signals.push_back(signal); } } List<String> constant_list; ObjectTypeDB::get_integer_constant_list(name, &constant_list, true); for(List<String>::Element *E=constant_list.front();E;E=E->next()) { ConstantDoc constant; constant.name=E->get(); constant.value=itos(ObjectTypeDB::get_integer_constant(name, E->get())); c.constants.push_back(constant); } //theme stuff { List<StringName> l; Theme::get_default()->get_constant_list(cname,&l); for (List<StringName>::Element*E=l.front();E;E=E->next()) { PropertyDoc pd; pd.name=E->get(); pd.type="int"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_color_list(cname,&l); for (List<StringName>::Element*E=l.front();E;E=E->next()) { PropertyDoc pd; pd.name=E->get(); pd.type="Color"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_icon_list(cname,&l); for (List<StringName>::Element*E=l.front();E;E=E->next()) { PropertyDoc pd; pd.name=E->get(); pd.type="Texture"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_list(cname,&l); for (List<StringName>::Element*E=l.front();E;E=E->next()) { PropertyDoc pd; pd.name=E->get(); pd.type="Font"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_stylebox_list(cname,&l); for (List<StringName>::Element*E=l.front();E;E=E->next()) { PropertyDoc pd; pd.name=E->get(); pd.type="StyleBox"; c.theme_properties.push_back(pd); } } classes.pop_front(); } { //so it can be documented that it does not exist class_list["Variant"]=ClassDoc(); class_list["Variant"].name="Variant"; } if (!p_basic_types) return; for (int i=0;i<Variant::VARIANT_MAX;i++) { if (i==Variant::OBJECT) continue; //use the core type instead int loops=1; if (i==Variant::INPUT_EVENT) loops=InputEvent::TYPE_MAX; for(int j=0;j<loops;j++) { String cname=Variant::get_type_name(Variant::Type(i)); if (i==Variant::INPUT_EVENT) { static const char* ie_type[InputEvent::TYPE_MAX]={ "","Key","MouseMotion","MouseButton","JoystickMotion","JoystickButton","ScreenTouch","ScreenDrag","Action" }; cname+=ie_type[j]; } class_list[cname]=ClassDoc(); ClassDoc& c = class_list[cname]; c.name=cname; c.category="Built-In Types"; Variant::CallError cerror; Variant v=Variant::construct(Variant::Type(i),NULL,0,cerror); if (i==Variant::INPUT_EVENT) { v.set("type",j); } List<MethodInfo> method_list; v.get_method_list(&method_list); method_list.sort(); Variant::get_constructor_list(Variant::Type(i),&method_list); for(List<MethodInfo>::Element *E=method_list.front();E;E=E->next()) { MethodInfo &mi=E->get(); MethodDoc method; method.name=mi.name; for(int i=0;i<mi.arguments.size();i++) { ArgumentDoc arg; PropertyInfo pi=mi.arguments[i]; arg.name=pi.name; //print_line("arg name: "+arg.name); if (pi.type==Variant::NIL) arg.type="var"; else arg.type=Variant::get_type_name(pi.type); int defarg = mi.default_arguments.size() - mi.arguments.size() + i; if (defarg >=0) arg.default_value=mi.default_arguments[defarg]; method.arguments.push_back(arg); } if (mi.return_val.type==Variant::NIL) { if (mi.return_val.name!="") method.return_type="var"; } else { method.return_type=Variant::get_type_name(mi.return_val.type); } c.methods.push_back(method); } List<PropertyInfo> properties; v.get_property_list(&properties); for(List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) { PropertyInfo pi=E->get(); PropertyDoc property; property.name=pi.name; property.type=Variant::get_type_name(pi.type); c.properties.push_back(property); } List<StringName> constants; Variant::get_numeric_constants_for_type(Variant::Type(i),&constants); for(List<StringName>::Element *E=constants.front();E;E=E->next()) { ConstantDoc constant; constant.name=E->get(); constant.value=itos(Variant::get_numeric_constant_value(Variant::Type(i),E->get())); c.constants.push_back(constant); } } } //built in constants and functions { String cname="@Global Scope"; class_list[cname]=ClassDoc(); ClassDoc& c = class_list[cname]; c.name=cname; for(int i=0;i<GlobalConstants::get_global_constant_count();i++) { ConstantDoc cd; cd.name=GlobalConstants::get_global_constant_name(i); cd.value=itos(GlobalConstants::get_global_constant_value(i)); c.constants.push_back(cd); } List<Globals::Singleton> singletons; Globals::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) for(List<Globals::Singleton>::Element *E=singletons.front();E;E=E->next()) { PropertyDoc pd; Globals::Singleton &s=E->get(); pd.name=s.name; pd.type=s.ptr->get_type(); while (String(ObjectTypeDB::type_inherits_from(pd.type))!="Object") pd.type=ObjectTypeDB::type_inherits_from(pd.type); if (pd.type.begins_with("_")) pd.type=pd.type.substr(1,pd.type.length()); c.properties.push_back(pd); } } //built in script reference { for(int i=0;i<ScriptServer::get_language_count();i++) { ScriptLanguage *lang = ScriptServer::get_language(i); String cname="@"+lang->get_name(); class_list[cname]=ClassDoc(); ClassDoc& c = class_list[cname]; c.name=cname; List<MethodInfo> minfo; lang->get_public_functions(&minfo); for(List<MethodInfo>::Element *E=minfo.front();E;E=E->next()) { MethodInfo &mi=E->get(); MethodDoc md; md.name=mi.name; if (mi.return_val.name!="") md.return_type=mi.return_val.name; else if (mi.name.find(":")!=-1) { md.return_type=mi.name.get_slice(":",1); md.name=mi.name.get_slice(":",0); } else md.return_type=Variant::get_type_name(mi.return_val.type); for(int i=0;i<mi.arguments.size();i++) { PropertyInfo &pi=mi.arguments[i]; ArgumentDoc ad; ad.name=pi.name; if (pi.type==Variant::NIL) ad.type="Variant"; else ad.type=Variant::get_type_name( pi.type ); md.arguments.push_back(ad); } c.methods.push_back(md); } List<Pair<String,Variant> > cinfo; lang->get_public_constants(&cinfo); for(List<Pair<String,Variant> >::Element *E=cinfo.front();E;E=E->next()) { ConstantDoc cd; cd.name=E->get().first; cd.value=E->get().second; c.constants.push_back(cd); } } } }
Error DocData::_load(Ref<XMLParser> parser) { Error err=OK; while((err=parser->read())==OK) { if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { if (parser->get_node_name() == "doc") { break; } else if (!parser->is_empty()) parser->skip_section();// unknown section, likely headers } } if (parser->has_attribute("version")) version=parser->get_attribute_value("version"); while((err=parser->read())==OK) { if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="doc") break; //end of <doc> if (parser->get_node_type() != XMLParser::NODE_ELEMENT) continue; //no idea what this may be, but skipping anyway ERR_FAIL_COND_V( parser->get_node_name()!="class", ERR_FILE_CORRUPT ); ERR_FAIL_COND_V( !parser->has_attribute("name"), ERR_FILE_CORRUPT); String name = parser->get_attribute_value("name"); class_list[name]=ClassDoc(); ClassDoc& c = class_list[name]; // print_line("class: "+name); c.name=name; if (parser->has_attribute("inherits")) c.inherits = parser->get_attribute_value("inherits"); if (parser->has_attribute("category")) c.category = parser->get_attribute_value("category"); while(parser->read()==OK) { if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { String name = parser->get_node_name(); if (name=="brief_description") { parser->read(); if (parser->get_node_type()==XMLParser::NODE_TEXT) c.brief_description=parser->get_node_data().strip_edges(); } else if (name=="description") { parser->read(); if (parser->get_node_type()==XMLParser::NODE_TEXT) c.description=parser->get_node_data().strip_edges(); } else if (name=="methods") { Error err = _parse_methods(parser,c.methods); ERR_FAIL_COND_V(err,err); } else if (name=="signals") { Error err = _parse_methods(parser,c.signals); ERR_FAIL_COND_V(err,err); } else if (name=="members") { while(parser->read()==OK) { if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { String name = parser->get_node_name(); if (name=="member") { PropertyDoc prop; ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT); prop.name=parser->get_attribute_value("name"); ERR_FAIL_COND_V(!parser->has_attribute("type"),ERR_FILE_CORRUPT); prop.type=parser->get_attribute_value("type"); parser->read(); if (parser->get_node_type()==XMLParser::NODE_TEXT) prop.description=parser->get_node_data().strip_edges(); c.properties.push_back(prop); } else { ERR_EXPLAIN("Invalid tag in doc file: "+name); ERR_FAIL_V(ERR_FILE_CORRUPT); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="members") break; //end of <constants> } } else if (name=="theme_items") { while(parser->read()==OK) { if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { String name = parser->get_node_name(); if (name=="theme_item") { PropertyDoc prop; ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT); prop.name=parser->get_attribute_value("name"); ERR_FAIL_COND_V(!parser->has_attribute("type"),ERR_FILE_CORRUPT); prop.type=parser->get_attribute_value("type"); parser->read(); if (parser->get_node_type()==XMLParser::NODE_TEXT) prop.description=parser->get_node_data().strip_edges(); c.theme_properties.push_back(prop); } else { ERR_EXPLAIN("Invalid tag in doc file: "+name); ERR_FAIL_V(ERR_FILE_CORRUPT); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="theme_items") break; //end of <constants> } } else if (name=="constants") { while(parser->read()==OK) { if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { String name=parser->get_node_name(); if (name=="constant") { ConstantDoc constant; ERR_FAIL_COND_V(!parser->has_attribute("name"),ERR_FILE_CORRUPT); constant.name=parser->get_attribute_value("name"); ERR_FAIL_COND_V(!parser->has_attribute("value"),ERR_FILE_CORRUPT); constant.value=parser->get_attribute_value("value"); parser->read(); if (parser->get_node_type()==XMLParser::NODE_TEXT) constant.description=parser->get_node_data().strip_edges(); c.constants.push_back(constant); } else { ERR_EXPLAIN("Invalid tag in doc file: "+name); ERR_FAIL_V(ERR_FILE_CORRUPT); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="constants") break; //end of <constants> } } else { ERR_EXPLAIN("Invalid tag in doc file: "+name); ERR_FAIL_V(ERR_FILE_CORRUPT); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="class") break; //end of <asset> } } return OK; }
void DocData::generate(bool p_basic_types) { List<StringName> classes; ClassDB::get_class_list(&classes); classes.sort_custom<StringName::AlphCompare>(); bool skip_setter_getter_methods = true; while (classes.size()) { Set<StringName> setters_getters; 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 = ClassDB::get_parent_class(name); c.category = ClassDB::get_category(name); List<PropertyInfo> properties; ClassDB::get_property_list(name, &properties, true); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) continue; PropertyDoc prop; StringName setter = ClassDB::get_property_setter(name, E->get().name); StringName getter = ClassDB::get_property_getter(name, E->get().name); prop.name = E->get().name; prop.setter = setter; prop.getter = getter; bool found_type = false; if (getter != StringName()) { MethodBind *mb = ClassDB::get_method(name, getter); if (mb) { PropertyInfo retinfo = mb->get_return_info(); found_type = true; if (retinfo.type == Variant::INT && retinfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { prop.enumeration = retinfo.class_name; prop.type = "int"; } else if (retinfo.class_name != StringName()) { prop.type = retinfo.class_name; } else if (retinfo.hint == PROPERTY_HINT_RESOURCE_TYPE) { prop.type = retinfo.hint_string; } else if (retinfo.type == Variant::NIL && retinfo.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { prop.type = "Variant"; } else if (retinfo.type == Variant::NIL) { prop.type = "void"; } else { prop.type = Variant::get_type_name(retinfo.type); } } setters_getters.insert(getter); } if (setter != StringName()) { setters_getters.insert(setter); } if (!found_type) { if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) prop.type = E->get().hint_string; else prop.type = Variant::get_type_name(E->get().type); } c.properties.push_back(prop); } 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] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) continue; //hidden, don't count if (skip_setter_getter_methods && setters_getters.has(E->get().name) && E->get().name.find("/") == -1) continue; MethodDoc method; 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"; } else if (E->get().flags & METHOD_FLAG_VARARG) { if (method.qualifiers != "") method.qualifiers += " "; method.qualifiers += "vararg"; } for (int i = -1; i < E->get().arguments.size(); i++) { if (i == -1) { #ifdef DEBUG_METHODS_ENABLED return_doc_from_retinfo(method, E->get().return_val); #endif } else { const PropertyInfo &arginfo = E->get().arguments[i]; ArgumentDoc argument; argument_doc_from_arginfo(argument, arginfo); int darg_idx = i - (E->get().arguments.size() - E->get().default_arguments.size()); if (darg_idx >= 0) { Variant default_arg = E->get().default_arguments[darg_idx]; argument.default_value = default_arg.get_construct_string(); } method.arguments.push_back(argument); } /* String hint; switch(arginfo.hint) { case PROPERTY_HINT_DIR: hint="A directory."; break; case PROPERTY_HINT_RANGE: hint="Range - min: "+arginfo.hint_string.get_slice(",",0)+" max: "+arginfo.hint_string.get_slice(",",1)+" step: "+arginfo.hint_string.get_slice(",",2); break; case PROPERTY_HINT_ENUM: hint="Values: "; for(int j=0;j<arginfo.hint_string.get_slice_count(",");j++) { if (j>0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(j); } break; case PROPERTY_HINT_LENGTH: hint="Length: "+arginfo.hint_string; break; case PROPERTY_HINT_FLAGS: hint="Values: "; for(int j=0;j<arginfo.hint_string.get_slice_count(",");j++) { if (j>0) hint+=", "; hint+=arginfo.hint_string.get_slice(",",j)+"="+itos(1<<j); } break; case PROPERTY_HINT_FILE: hint="A file:"; break; //case PROPERTY_HINT_RESOURCE_TYPE: hint="Type: "+arginfo.hint_string; break; }; if (hint!="") _write_string(f,4,hint); */ } c.methods.push_back(method); } List<MethodInfo> signal_list; ClassDB::get_signal_list(name, &signal_list, true); if (signal_list.size()) { for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) { MethodDoc signal; signal.name = EV->get().name; for (int i = 0; i < EV->get().arguments.size(); i++) { PropertyInfo arginfo = EV->get().arguments[i]; ArgumentDoc argument; argument.name = arginfo.name; argument.type = Variant::get_type_name(arginfo.type); signal.arguments.push_back(argument); } c.signals.push_back(signal); } } List<String> constant_list; ClassDB::get_integer_constant_list(name, &constant_list, true); for (List<String>::Element *E = constant_list.front(); E; E = E->next()) { ConstantDoc constant; constant.name = E->get(); constant.value = itos(ClassDB::get_integer_constant(name, E->get())); constant.enumeration = ClassDB::get_integer_constant_enum(name, E->get()); c.constants.push_back(constant); } //theme stuff { List<StringName> l; Theme::get_default()->get_constant_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { PropertyDoc pd; pd.name = E->get(); pd.type = "int"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_color_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { PropertyDoc pd; pd.name = E->get(); pd.type = "Color"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_icon_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { PropertyDoc pd; pd.name = E->get(); pd.type = "Texture"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { PropertyDoc pd; pd.name = E->get(); pd.type = "Font"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { PropertyDoc pd; pd.name = E->get(); pd.type = "StyleBox"; c.theme_properties.push_back(pd); } } classes.pop_front(); } { //so it can be documented that it does not exist class_list["Variant"] = ClassDoc(); class_list["Variant"].name = "Variant"; } if (!p_basic_types) return; for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (i == Variant::OBJECT) continue; //use the core type instead String cname = Variant::get_type_name(Variant::Type(i)); class_list[cname] = ClassDoc(); ClassDoc &c = class_list[cname]; c.name = cname; c.category = "Built-In Types"; Variant::CallError cerror; Variant v = Variant::construct(Variant::Type(i), NULL, 0, cerror); List<MethodInfo> method_list; v.get_method_list(&method_list); method_list.sort(); Variant::get_constructor_list(Variant::Type(i), &method_list); for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { MethodInfo &mi = E->get(); MethodDoc method; method.name = mi.name; for (int i = 0; i < mi.arguments.size(); i++) { PropertyInfo arginfo = mi.arguments[i]; ArgumentDoc ad; ad.name = arginfo.name; if (arginfo.type == Variant::NIL) ad.type = "var"; else ad.type = Variant::get_type_name(arginfo.type); int defarg = mi.default_arguments.size() - mi.arguments.size() + i; if (defarg >= 0) ad.default_value = mi.default_arguments[defarg]; method.arguments.push_back(ad); } if (mi.return_val.type == Variant::NIL) { if (mi.return_val.name != "") method.return_type = "var"; } else { method.return_type = Variant::get_type_name(mi.return_val.type); } c.methods.push_back(method); } List<PropertyInfo> properties; v.get_property_list(&properties); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { PropertyInfo pi = E->get(); PropertyDoc property; property.name = pi.name; property.type = Variant::get_type_name(pi.type); c.properties.push_back(property); } List<StringName> constants; Variant::get_numeric_constants_for_type(Variant::Type(i), &constants); for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { ConstantDoc constant; constant.name = E->get(); constant.value = itos(Variant::get_numeric_constant_value(Variant::Type(i), E->get())); c.constants.push_back(constant); } } //built in constants and functions { String cname = "@GlobalScope"; class_list[cname] = ClassDoc(); ClassDoc &c = class_list[cname]; c.name = cname; for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) { ConstantDoc cd; cd.name = GlobalConstants::get_global_constant_name(i); cd.value = itos(GlobalConstants::get_global_constant_value(i)); cd.enumeration = GlobalConstants::get_global_constant_enum(i); c.constants.push_back(cd); } List<Engine::Singleton> singletons; Engine::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { PropertyDoc pd; Engine::Singleton &s = E->get(); pd.name = s.name; pd.type = s.ptr->get_class(); while (String(ClassDB::get_parent_class(pd.type)) != "Object") pd.type = ClassDB::get_parent_class(pd.type); if (pd.type.begins_with("_")) pd.type = pd.type.substr(1, pd.type.length()); c.properties.push_back(pd); } } //built in script reference { for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptLanguage *lang = ScriptServer::get_language(i); String cname = "@" + lang->get_name(); class_list[cname] = ClassDoc(); ClassDoc &c = class_list[cname]; c.name = cname; List<MethodInfo> minfo; lang->get_public_functions(&minfo); for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { MethodInfo &mi = E->get(); MethodDoc md; md.name = mi.name; if (mi.flags & METHOD_FLAG_VARARG) { if (md.qualifiers != "") md.qualifiers += " "; md.qualifiers += "vararg"; } return_doc_from_retinfo(md, mi.return_val); for (int i = 0; i < mi.arguments.size(); i++) { ArgumentDoc ad; argument_doc_from_arginfo(ad, mi.arguments[i]); int darg_idx = i - (mi.arguments.size() - mi.default_arguments.size()); if (darg_idx >= 0) { Variant default_arg = E->get().default_arguments[darg_idx]; ad.default_value = default_arg.get_construct_string(); } md.arguments.push_back(ad); } c.methods.push_back(md); } List<Pair<String, Variant> > cinfo; lang->get_public_constants(&cinfo); for (List<Pair<String, Variant> >::Element *E = cinfo.front(); E; E = E->next()) { ConstantDoc cd; cd.name = E->get().first; cd.value = E->get().second; c.constants.push_back(cd); } } } }