2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* doc_data.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#include "doc_data.h"
|
2014-02-16 01:16:33 +01:00
|
|
|
|
2017-02-21 04:05:15 +01:00
|
|
|
#include "global_config.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "global_constants.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "io/compression.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "io/marshalls.h"
|
2014-06-30 03:41:02 +02:00
|
|
|
#include "scene/resources/theme.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "script_language.h"
|
|
|
|
#include "version.h"
|
2014-02-16 01:16:33 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void DocData::merge_from(const DocData &p_data) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ClassDoc &c = E->get();
|
|
|
|
|
|
|
|
if (!p_data.class_list.has(c.name))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const ClassDoc &cf = p_data.class_list[c.name];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
c.description = cf.description;
|
|
|
|
c.brief_description = cf.brief_description;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.methods.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
MethodDoc &m = c.methods[i];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int j = 0; j < cf.methods.size(); j++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (cf.methods[j].name != m.name)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (cf.methods[j].arguments.size() != m.arguments.size())
|
2015-04-22 05:25:13 +02:00
|
|
|
continue;
|
2016-05-03 08:45:54 +02:00
|
|
|
// since polymorphic functions are allowed we need to check the type of
|
|
|
|
// the arguments so we make sure they are different.
|
|
|
|
int arg_count = cf.methods[j].arguments.size();
|
2016-05-04 16:46:28 +02:00
|
|
|
Vector<bool> arg_used;
|
|
|
|
arg_used.resize(arg_count);
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int l = 0; l < arg_count; ++l)
|
|
|
|
arg_used[l] = false;
|
2016-05-03 08:45:54 +02:00
|
|
|
// also there is no guarantee that argument ordering will match, so we
|
|
|
|
// have to check one by one so we make sure we have an exact match
|
|
|
|
for (int k = 0; k < arg_count; ++k) {
|
|
|
|
for (int l = 0; l < arg_count; ++l)
|
|
|
|
if (cf.methods[j].arguments[k].type == m.arguments[l].type && !arg_used[l]) {
|
|
|
|
arg_used[l] = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool not_the_same = false;
|
|
|
|
for (int l = 0; l < arg_count; ++l)
|
|
|
|
if (!arg_used[l]) // at least one of the arguments was different
|
|
|
|
not_the_same = true;
|
|
|
|
if (not_the_same)
|
|
|
|
continue;
|
2015-04-22 05:25:13 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
const MethodDoc &mf = cf.methods[j];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
m.description = mf.description;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.signals.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
MethodDoc &m = c.signals[i];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int j = 0; j < cf.signals.size(); j++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (cf.signals[j].name != m.name)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
|
|
|
const MethodDoc &mf = cf.signals[j];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
m.description = mf.description;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.constants.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ConstantDoc &m = c.constants[i];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int j = 0; j < cf.constants.size(); j++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (cf.constants[j].name != m.name)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
|
|
|
const ConstantDoc &mf = cf.constants[j];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
m.description = mf.description;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.properties.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
PropertyDoc &p = c.properties[i];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int j = 0; j < cf.properties.size(); j++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (cf.properties[j].name != p.name)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
|
|
|
const PropertyDoc &pf = cf.properties[j];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p.description = pf.description;
|
|
|
|
p.setter = pf.setter;
|
|
|
|
p.getter = pf.getter;
|
2017-01-04 05:16:14 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.theme_properties.size(); i++) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
PropertyDoc &p = c.theme_properties[i];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int j = 0; j < cf.theme_properties.size(); j++) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (cf.theme_properties[j].name != p.name)
|
2014-06-30 03:41:02 +02:00
|
|
|
continue;
|
|
|
|
const PropertyDoc &pf = cf.theme_properties[j];
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p.description = pf.description;
|
2014-06-30 03:41:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-16 12:12:22 +01:00
|
|
|
void DocData::remove_from(const DocData &p_data) {
|
2017-03-05 16:44:50 +01:00
|
|
|
for (Map<String, ClassDoc>::Element *E = p_data.class_list.front(); E; E = E->next()) {
|
|
|
|
if (class_list.has(E->key()))
|
2016-12-16 12:12:22 +01:00
|
|
|
class_list.erase(E->key());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void DocData::generate(bool p_basic_types) {
|
|
|
|
|
2015-06-29 05:29:49 +02:00
|
|
|
List<StringName> classes;
|
2017-01-03 03:03:46 +01:00
|
|
|
ClassDB::get_class_list(&classes);
|
2015-06-29 05:29:49 +02:00
|
|
|
classes.sort_custom<StringName::AlphCompare>();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (classes.size()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String name = classes.front()->get();
|
|
|
|
String cname = name;
|
2014-02-10 02:10:30 +01:00
|
|
|
if (cname.begins_with("_")) //proxy class
|
2017-03-05 16:44:50 +01:00
|
|
|
cname = cname.substr(1, name.length());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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);
|
2017-01-04 05:16:14 +01:00
|
|
|
|
|
|
|
List<PropertyInfo> properties;
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::get_property_list(name, &properties, true);
|
2017-01-04 05:16:14 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
|
|
|
|
if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY)
|
2017-01-04 05:16:14 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
PropertyDoc prop;
|
2017-03-05 16:44:50 +01:00
|
|
|
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;
|
|
|
|
if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE)
|
|
|
|
prop.type = E->get().hint_string;
|
2017-01-04 05:16:14 +01:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
prop.type = Variant::get_type_name(E->get().type);
|
2017-01-04 05:16:14 +01:00
|
|
|
|
|
|
|
c.properties.push_back(prop);
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
List<MethodInfo> method_list;
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::get_method_list(name, &method_list, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
method_list.sort();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL)))
|
2017-03-24 21:45:31 +01:00
|
|
|
continue; //hidden, don't count
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
MethodDoc method;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
method.name = E->get().name;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
MethodBind *m = ClassDB::get_method(name, E->get().name);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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";
|
2016-09-08 00:39:02 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (E->get().flags & METHOD_FLAG_VARARG) {
|
|
|
|
if (method.qualifiers != "")
|
|
|
|
method.qualifiers += " ";
|
|
|
|
method.qualifiers += "vararg";
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = -1; i < E->get().arguments.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
PropertyInfo arginfo;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (i == -1) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
arginfo = E->get().return_val;
|
2015-11-18 12:33:29 +01:00
|
|
|
#ifdef DEBUG_METHODS_ENABLED
|
2017-03-05 16:44:50 +01:00
|
|
|
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);
|
2016-02-28 03:10:44 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (arginfo.type != Variant::NIL) // {
|
2015-11-18 12:33:29 +01:00
|
|
|
#endif
|
2017-03-05 16:44:50 +01:00
|
|
|
method.return_type = (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) ? arginfo.hint_string : Variant::get_type_name(arginfo.type);
|
2017-01-14 12:26:56 +01:00
|
|
|
//}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ArgumentDoc argument;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
arginfo = E->get().arguments[i];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String type_name;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (arginfo.name.find(":") != -1) {
|
|
|
|
type_name = arginfo.name.get_slice(":", 1);
|
|
|
|
arginfo.name = arginfo.name.get_slice(":", 0);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) {
|
|
|
|
type_name = arginfo.hint_string;
|
|
|
|
} else if (arginfo.type == Variant::NIL)
|
|
|
|
type_name = "Variant";
|
2014-02-10 02:10:30 +01:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
type_name = Variant::get_type_name(arginfo.type);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (arginfo.type == Variant::OBJECT) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
//print_line("validate: "+cname+"::"+method.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m && m->has_default_argument(i)) {
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant default_arg = m->get_default_argument(i);
|
|
|
|
String default_arg_text = m->get_default_argument(i);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
switch (default_arg.get_type()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
case Variant::NIL:
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = "NULL";
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
// atomic types
|
|
|
|
case Variant::BOOL:
|
|
|
|
if (bool(default_arg))
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = "true";
|
2014-02-10 02:10:30 +01:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = "false";
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
case Variant::INT:
|
|
|
|
case Variant::REAL:
|
|
|
|
//keep it
|
|
|
|
break;
|
2017-03-05 16:44:50 +01:00
|
|
|
case Variant::STRING: // 15
|
|
|
|
case Variant::NODE_PATH: // 15
|
|
|
|
default_arg_text = "\"" + default_arg_text + "\"";
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
case Variant::TRANSFORM:
|
2017-03-05 16:44:50 +01:00
|
|
|
if (default_arg.operator Transform() == Transform()) {
|
|
|
|
default_arg_text = "";
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
|
2017-01-11 04:52:51 +01:00
|
|
|
case Variant::RECT3: //sorry naming convention fail :( not like it's used often // 10
|
2014-02-10 02:10:30 +01:00
|
|
|
case Variant::COLOR:
|
2016-08-18 17:26:36 +02:00
|
|
|
case Variant::PLANE:
|
2017-01-11 04:52:51 +01:00
|
|
|
case Variant::POOL_BYTE_ARRAY:
|
|
|
|
case Variant::POOL_INT_ARRAY:
|
|
|
|
case Variant::POOL_REAL_ARRAY:
|
2017-03-05 16:44:50 +01:00
|
|
|
case Variant::POOL_STRING_ARRAY: //25
|
2017-01-11 04:52:51 +01:00
|
|
|
case Variant::POOL_VECTOR2_ARRAY:
|
|
|
|
case Variant::POOL_VECTOR3_ARRAY:
|
|
|
|
case Variant::POOL_COLOR_ARRAY:
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")";
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
2017-03-05 16:44:50 +01:00
|
|
|
case Variant::VECTOR2: // 5
|
2016-08-18 17:26:36 +02:00
|
|
|
case Variant::RECT2:
|
|
|
|
case Variant::VECTOR3:
|
|
|
|
case Variant::QUAT:
|
2017-01-11 04:52:51 +01:00
|
|
|
case Variant::BASIS:
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = Variant::get_type_name(default_arg.get_type()) + default_arg_text;
|
2016-08-18 17:26:36 +02:00
|
|
|
break;
|
2014-02-10 02:10:30 +01:00
|
|
|
case Variant::OBJECT:
|
2016-08-24 18:12:42 +02:00
|
|
|
if (default_arg.is_zero()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = "NULL";
|
2016-08-24 18:12:42 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
case Variant::INPUT_EVENT:
|
2017-03-05 16:44:50 +01:00
|
|
|
case Variant::DICTIONARY: // 20
|
2014-02-10 02:10:30 +01:00
|
|
|
case Variant::ARRAY:
|
|
|
|
case Variant::_RID:
|
|
|
|
case Variant::IMAGE:
|
2017-03-05 16:44:50 +01:00
|
|
|
//case Variant::RESOURCE:
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
default_arg_text = Variant::get_type_name(default_arg.get_type()) + "()";
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
default: {}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
argument.type = type_name;
|
|
|
|
argument.name = arginfo.name;
|
|
|
|
argument.default_value = default_arg_text;
|
2014-02-10 02:10:30 +01:00
|
|
|
} else {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
argument.type = type_name;
|
|
|
|
argument.name = arginfo.name;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (arginfo.type == Variant::OBJECT) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
//print_line("validate: "+cname+"::"+method.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
method.arguments.push_back(argument);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
/*
|
2014-02-10 02:10:30 +01:00
|
|
|
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;
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::get_signal_list(name, &signal_list, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (signal_list.size()) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
MethodDoc signal;
|
2017-03-05 16:44:50 +01:00
|
|
|
signal.name = EV->get().name;
|
|
|
|
for (int i = 0; i < EV->get().arguments.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo arginfo = EV->get().arguments[i];
|
2014-02-10 02:10:30 +01:00
|
|
|
ArgumentDoc argument;
|
2017-03-05 16:44:50 +01:00
|
|
|
argument.name = arginfo.name;
|
|
|
|
argument.type = Variant::get_type_name(arginfo.type);
|
2014-02-10 02:10:30 +01:00
|
|
|
signal.arguments.push_back(argument);
|
|
|
|
}
|
|
|
|
|
|
|
|
c.signals.push_back(signal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String> constant_list;
|
2017-01-03 03:03:46 +01:00
|
|
|
ClassDB::get_integer_constant_list(name, &constant_list, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<String>::Element *E = constant_list.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ConstantDoc constant;
|
2017-03-05 16:44:50 +01:00
|
|
|
constant.name = E->get();
|
|
|
|
constant.value = itos(ClassDB::get_integer_constant(name, E->get()));
|
2014-02-10 02:10:30 +01:00
|
|
|
c.constants.push_back(constant);
|
|
|
|
}
|
|
|
|
|
2014-06-30 03:41:02 +02:00
|
|
|
//theme stuff
|
|
|
|
|
|
|
|
{
|
|
|
|
List<StringName> l;
|
2017-03-05 16:44:50 +01:00
|
|
|
Theme::get_default()->get_constant_list(cname, &l);
|
|
|
|
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
PropertyDoc pd;
|
2017-03-05 16:44:50 +01:00
|
|
|
pd.name = E->get();
|
|
|
|
pd.type = "int";
|
2014-06-30 03:41:02 +02:00
|
|
|
c.theme_properties.push_back(pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
l.clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
Theme::get_default()->get_color_list(cname, &l);
|
|
|
|
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
PropertyDoc pd;
|
2017-03-05 16:44:50 +01:00
|
|
|
pd.name = E->get();
|
|
|
|
pd.type = "Color";
|
2014-06-30 03:41:02 +02:00
|
|
|
c.theme_properties.push_back(pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
l.clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
Theme::get_default()->get_icon_list(cname, &l);
|
|
|
|
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
PropertyDoc pd;
|
2017-03-05 16:44:50 +01:00
|
|
|
pd.name = E->get();
|
|
|
|
pd.type = "Texture";
|
2014-06-30 03:41:02 +02:00
|
|
|
c.theme_properties.push_back(pd);
|
|
|
|
}
|
|
|
|
l.clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
Theme::get_default()->get_font_list(cname, &l);
|
|
|
|
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
PropertyDoc pd;
|
2017-03-05 16:44:50 +01:00
|
|
|
pd.name = E->get();
|
|
|
|
pd.type = "Font";
|
2014-06-30 03:41:02 +02:00
|
|
|
c.theme_properties.push_back(pd);
|
|
|
|
}
|
|
|
|
l.clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
Theme::get_default()->get_stylebox_list(cname, &l);
|
|
|
|
for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
PropertyDoc pd;
|
2017-03-05 16:44:50 +01:00
|
|
|
pd.name = E->get();
|
|
|
|
pd.type = "StyleBox";
|
2014-06-30 03:41:02 +02:00
|
|
|
c.theme_properties.push_back(pd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
classes.pop_front();
|
|
|
|
}
|
|
|
|
|
2016-06-30 00:54:22 +02:00
|
|
|
{
|
|
|
|
//so it can be documented that it does not exist
|
2017-03-05 16:44:50 +01:00
|
|
|
class_list["Variant"] = ClassDoc();
|
|
|
|
class_list["Variant"].name = "Variant";
|
2016-06-30 00:54:22 +02:00
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!p_basic_types)
|
|
|
|
return;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (i == Variant::OBJECT)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue; //use the core type instead
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int loops = 1;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (i == Variant::INPUT_EVENT)
|
|
|
|
loops = InputEvent::TYPE_MAX;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int j = 0; j < loops; j++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String cname = Variant::get_type_name(Variant::Type(i));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (i == Variant::INPUT_EVENT) {
|
|
|
|
static const char *ie_type[InputEvent::TYPE_MAX] = {
|
|
|
|
"", "Key", "MouseMotion", "MouseButton", "JoypadMotion", "JoypadButton", "ScreenTouch", "ScreenDrag", "Action"
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
2017-03-05 16:44:50 +01:00
|
|
|
cname += ie_type[j];
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
class_list[cname] = ClassDoc();
|
|
|
|
ClassDoc &c = class_list[cname];
|
|
|
|
c.name = cname;
|
|
|
|
c.category = "Built-In Types";
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Variant::CallError cerror;
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant v = Variant::construct(Variant::Type(i), NULL, 0, cerror);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (i == Variant::INPUT_EVENT) {
|
|
|
|
v.set("type", j);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
List<MethodInfo> method_list;
|
|
|
|
v.get_method_list(&method_list);
|
|
|
|
method_list.sort();
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant::get_constructor_list(Variant::Type(i), &method_list);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
MethodInfo &mi = E->get();
|
2014-02-10 02:10:30 +01:00
|
|
|
MethodDoc method;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
method.name = mi.name;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < mi.arguments.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ArgumentDoc arg;
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo pi = mi.arguments[i];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
arg.name = pi.name;
|
2014-02-10 02:10:30 +01:00
|
|
|
//print_line("arg name: "+arg.name);
|
2017-03-05 16:44:50 +01:00
|
|
|
if (pi.type == Variant::NIL)
|
|
|
|
arg.type = "var";
|
2014-02-10 02:10:30 +01:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
arg.type = Variant::get_type_name(pi.type);
|
2014-02-10 02:10:30 +01:00
|
|
|
int defarg = mi.default_arguments.size() - mi.arguments.size() + i;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (defarg >= 0)
|
|
|
|
arg.default_value = mi.default_arguments[defarg];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
method.arguments.push_back(arg);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (mi.return_val.type == Variant::NIL) {
|
|
|
|
if (mi.return_val.name != "")
|
|
|
|
method.return_type = "var";
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
method.return_type = Variant::get_type_name(mi.return_val.type);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
c.methods.push_back(method);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<PropertyInfo> properties;
|
|
|
|
v.get_property_list(&properties);
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo pi = E->get();
|
2014-02-10 02:10:30 +01:00
|
|
|
PropertyDoc property;
|
2017-03-05 16:44:50 +01:00
|
|
|
property.name = pi.name;
|
|
|
|
property.type = Variant::get_type_name(pi.type);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
c.properties.push_back(property);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<StringName> constants;
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant::get_numeric_constants_for_type(Variant::Type(i), &constants);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ConstantDoc constant;
|
2017-03-05 16:44:50 +01:00
|
|
|
constant.name = E->get();
|
|
|
|
constant.value = itos(Variant::get_numeric_constant_value(Variant::Type(i), E->get()));
|
2014-02-10 02:10:30 +01:00
|
|
|
c.constants.push_back(constant);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//built in constants and functions
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String cname = "@Global Scope";
|
|
|
|
class_list[cname] = ClassDoc();
|
|
|
|
ClassDoc &c = class_list[cname];
|
|
|
|
c.name = cname;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ConstantDoc cd;
|
2017-03-05 16:44:50 +01:00
|
|
|
cd.name = GlobalConstants::get_global_constant_name(i);
|
|
|
|
cd.value = itos(GlobalConstants::get_global_constant_value(i));
|
2014-02-10 02:10:30 +01:00
|
|
|
c.constants.push_back(cd);
|
|
|
|
}
|
|
|
|
|
2017-01-05 13:16:00 +01:00
|
|
|
List<GlobalConfig::Singleton> singletons;
|
|
|
|
GlobalConfig::get_singleton()->get_singletons(&singletons);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
//servers (this is kind of hackish)
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<GlobalConfig::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
PropertyDoc pd;
|
2017-03-05 16:44:50 +01:00
|
|
|
GlobalConfig::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);
|
2014-02-10 02:10:30 +01:00
|
|
|
if (pd.type.begins_with("_"))
|
2017-03-05 16:44:50 +01:00
|
|
|
pd.type = pd.type.substr(1, pd.type.length());
|
2014-02-10 02:10:30 +01:00
|
|
|
c.properties.push_back(pd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//built in script reference
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ScriptLanguage *lang = ScriptServer::get_language(i);
|
2017-03-05 16:44:50 +01:00
|
|
|
String cname = "@" + lang->get_name();
|
|
|
|
class_list[cname] = ClassDoc();
|
|
|
|
ClassDoc &c = class_list[cname];
|
|
|
|
c.name = cname;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
List<MethodInfo> minfo;
|
|
|
|
|
|
|
|
lang->get_public_functions(&minfo);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
MethodInfo &mi = E->get();
|
2014-02-10 02:10:30 +01:00
|
|
|
MethodDoc md;
|
2017-03-05 16:44:50 +01:00
|
|
|
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);
|
2016-01-03 01:07:03 +01:00
|
|
|
} else
|
2017-03-05 16:44:50 +01:00
|
|
|
md.return_type = Variant::get_type_name(mi.return_val.type);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < mi.arguments.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyInfo &pi = mi.arguments[i];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ArgumentDoc ad;
|
2017-03-05 16:44:50 +01:00
|
|
|
ad.name = pi.name;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (pi.type == Variant::NIL)
|
|
|
|
ad.type = "Variant";
|
2014-02-10 02:10:30 +01:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
ad.type = Variant::get_type_name(pi.type);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
md.arguments.push_back(ad);
|
|
|
|
}
|
|
|
|
|
|
|
|
c.methods.push_back(md);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
List<Pair<String, Variant> > cinfo;
|
2014-02-23 00:28:19 +01:00
|
|
|
lang->get_public_constants(&cinfo);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (List<Pair<String, Variant> >::Element *E = cinfo.front(); E; E = E->next()) {
|
2014-02-23 00:28:19 +01:00
|
|
|
|
|
|
|
ConstantDoc cd;
|
2017-03-05 16:44:50 +01:00
|
|
|
cd.name = E->get().first;
|
|
|
|
cd.value = E->get().second;
|
2014-02-23 00:28:19 +01:00
|
|
|
c.constants.push_back(cd);
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &methods) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String section = parser->get_node_name();
|
|
|
|
String element = section.substr(0, section.length() - 1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (parser->read() == OK) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_name() == element) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
DocData::MethodDoc method;
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
|
|
|
|
method.name = parser->get_attribute_value("name");
|
2014-02-10 02:10:30 +01:00
|
|
|
if (parser->has_attribute("qualifiers"))
|
2017-03-05 16:44:50 +01:00
|
|
|
method.qualifiers = parser->get_attribute_value("qualifiers");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (parser->read() == OK) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String name = parser->get_node_name();
|
|
|
|
if (name == "return") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
|
|
|
|
method.return_type = parser->get_attribute_value("type");
|
|
|
|
} else if (name == "argument") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
DocData::ArgumentDoc argument;
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
|
|
|
|
argument.name = parser->get_attribute_value("name");
|
|
|
|
ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
|
|
|
|
argument.type = parser->get_attribute_value("type");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
method.arguments.push_back(argument);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (name == "description") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
parser->read();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_TEXT)
|
|
|
|
method.description = parser->get_node_data().strip_edges();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == element)
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
methods.push_back(method);
|
|
|
|
|
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_EXPLAIN("Invalid tag in doc file: " + parser->get_node_name());
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_FILE_CORRUPT);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == section)
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error DocData::load(const String &p_path) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Ref<XMLParser> parser = memnew(XMLParser);
|
2014-02-10 02:10:30 +01:00
|
|
|
Error err = parser->open(p_path);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2014-02-16 01:16:33 +01:00
|
|
|
return _load(parser);
|
|
|
|
}
|
|
|
|
Error DocData::_load(Ref<XMLParser> parser) {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error err = OK;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while ((err = parser->read()) == OK) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
|
|
|
|
|
|
|
if (parser->get_node_name() == "doc") {
|
|
|
|
break;
|
|
|
|
} else if (!parser->is_empty())
|
2017-03-05 16:44:50 +01:00
|
|
|
parser->skip_section(); // unknown section, likely headers
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser->has_attribute("version"))
|
2017-03-05 16:44:50 +01:00
|
|
|
version = parser->get_attribute_value("version");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while ((err = parser->read()) == OK) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "doc")
|
2014-02-10 02:10:30 +01:00
|
|
|
break; //end of <doc>
|
|
|
|
|
|
|
|
if (parser->get_node_type() != XMLParser::NODE_ELEMENT)
|
|
|
|
continue; //no idea what this may be, but skipping anyway
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND_V(parser->get_node_name() != "class", ERR_FILE_CORRUPT);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
|
2014-02-10 02:10:30 +01:00
|
|
|
String name = parser->get_attribute_value("name");
|
2017-03-05 16:44:50 +01:00
|
|
|
class_list[name] = ClassDoc();
|
|
|
|
ClassDoc &c = class_list[name];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-01-14 12:26:56 +01:00
|
|
|
//print_line("class: "+name);
|
2017-03-05 16:44:50 +01:00
|
|
|
c.name = name;
|
2014-02-10 02:10:30 +01:00
|
|
|
if (parser->has_attribute("inherits"))
|
|
|
|
c.inherits = parser->get_attribute_value("inherits");
|
|
|
|
if (parser->has_attribute("category"))
|
|
|
|
c.category = parser->get_attribute_value("category");
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (parser->read() == OK) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String name = parser->get_node_name();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (name == "brief_description") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
parser->read();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_TEXT)
|
|
|
|
c.brief_description = parser->get_node_data().strip_edges();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (name == "description") {
|
2014-02-10 02:10:30 +01:00
|
|
|
parser->read();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_TEXT)
|
|
|
|
c.description = parser->get_node_data().strip_edges();
|
|
|
|
} else if (name == "methods") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error err = _parse_methods(parser, c.methods);
|
|
|
|
ERR_FAIL_COND_V(err, err);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (name == "signals") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error err = _parse_methods(parser, c.signals);
|
|
|
|
ERR_FAIL_COND_V(err, err);
|
|
|
|
} else if (name == "members") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (parser->read() == OK) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String name = parser->get_node_name();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (name == "member") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
PropertyDoc prop;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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");
|
2017-01-04 05:16:14 +01:00
|
|
|
if (parser->has_attribute("setter"))
|
2017-03-05 16:44:50 +01:00
|
|
|
prop.setter = parser->get_attribute_value("setter");
|
2017-01-04 05:16:14 +01:00
|
|
|
if (parser->has_attribute("getter"))
|
2017-03-05 16:44:50 +01:00
|
|
|
prop.getter = parser->get_attribute_value("getter");
|
2017-01-04 05:16:14 +01:00
|
|
|
if (parser->has_attribute("brief"))
|
2017-03-05 16:44:50 +01:00
|
|
|
prop.brief_description = parser->get_attribute_value("brief").xml_unescape();
|
2017-01-04 05:16:14 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
parser->read();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_TEXT)
|
|
|
|
prop.description = parser->get_node_data().strip_edges();
|
2014-02-10 02:10:30 +01:00
|
|
|
c.properties.push_back(prop);
|
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_EXPLAIN("Invalid tag in doc file: " + name);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_FILE_CORRUPT);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members")
|
2014-02-10 02:10:30 +01:00
|
|
|
break; //end of <constants>
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (name == "theme_items") {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (parser->read() == OK) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
String name = parser->get_node_name();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (name == "theme_item") {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
PropertyDoc prop;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
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");
|
2014-06-30 03:41:02 +02:00
|
|
|
parser->read();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_TEXT)
|
|
|
|
prop.description = parser->get_node_data().strip_edges();
|
2014-06-30 03:41:02 +02:00
|
|
|
c.theme_properties.push_back(prop);
|
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_EXPLAIN("Invalid tag in doc file: " + name);
|
2014-06-30 03:41:02 +02:00
|
|
|
ERR_FAIL_V(ERR_FILE_CORRUPT);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items")
|
2014-06-30 03:41:02 +02:00
|
|
|
break; //end of <constants>
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (name == "constants") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
while (parser->read() == OK) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String name = parser->get_node_name();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (name == "constant") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ConstantDoc constant;
|
2017-03-05 16:44:50 +01:00
|
|
|
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");
|
2014-02-10 02:10:30 +01:00
|
|
|
parser->read();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (parser->get_node_type() == XMLParser::NODE_TEXT)
|
|
|
|
constant.description = parser->get_node_data().strip_edges();
|
2014-02-10 02:10:30 +01:00
|
|
|
c.constants.push_back(constant);
|
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_EXPLAIN("Invalid tag in doc file: " + name);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_FILE_CORRUPT);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants")
|
2014-02-10 02:10:30 +01:00
|
|
|
break; //end of <constants>
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_EXPLAIN("Invalid tag in doc file: " + name);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_FILE_CORRUPT);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class")
|
2014-02-10 02:10:30 +01:00
|
|
|
break; //end of <asset>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String tab;
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < p_tablevel; i++)
|
|
|
|
tab += "\t";
|
|
|
|
f->store_string(tab + p_string + "\n");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error DocData::save(const String &p_path) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Error err;
|
2017-03-05 16:44:50 +01:00
|
|
|
FileAccess *f = FileAccess::open(p_path, FileAccess::WRITE, &err);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (err) {
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_EXPLAIN("Can't write doc file: " + p_path);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ERR_FAIL_V(err);
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
|
|
|
|
_write_string(f, 0, "<doc version=\"" + String(VERSION_MKSTRING) + "\" name=\"Engine Types\">");
|
|
|
|
|
|
|
|
for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) {
|
|
|
|
|
|
|
|
ClassDoc &c = E->get();
|
|
|
|
|
|
|
|
String header = "<class name=\"" + c.name + "\"";
|
|
|
|
if (c.inherits != "")
|
|
|
|
header += " inherits=\"" + c.inherits + "\"";
|
|
|
|
|
|
|
|
String category = c.category;
|
|
|
|
if (c.category == "")
|
|
|
|
category = "Core";
|
|
|
|
header += " category=\"" + category + "\"";
|
|
|
|
header += ">";
|
|
|
|
_write_string(f, 0, header);
|
|
|
|
_write_string(f, 1, "<brief_description>");
|
|
|
|
if (c.brief_description != "")
|
|
|
|
_write_string(f, 2, c.brief_description.xml_escape());
|
|
|
|
_write_string(f, 1, "</brief_description>");
|
|
|
|
_write_string(f, 1, "<description>");
|
|
|
|
if (c.description != "")
|
|
|
|
_write_string(f, 2, c.description.xml_escape());
|
|
|
|
_write_string(f, 1, "</description>");
|
|
|
|
_write_string(f, 1, "<methods>");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-06-21 22:20:34 +02:00
|
|
|
c.methods.sort();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.methods.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
MethodDoc &m = c.methods[i];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String qualifiers;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (m.qualifiers != "")
|
|
|
|
qualifiers += " qualifiers=\"" + m.qualifiers.xml_escape() + "\"";
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 2, "<method name=\"" + m.name + "\"" + qualifiers + ">");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (m.return_type != "") {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 3, "<return type=\"" + m.return_type + "\">");
|
|
|
|
_write_string(f, 3, "</return>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int j = 0; j < m.arguments.size(); j++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ArgumentDoc &a = m.arguments[j];
|
2017-03-05 16:44:50 +01:00
|
|
|
if (a.default_value != "")
|
|
|
|
_write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\" default=\"" + a.default_value.xml_escape(true) + "\">");
|
2014-02-10 02:10:30 +01:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 3, "</argument>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 3, "<description>");
|
|
|
|
if (m.description != "")
|
|
|
|
_write_string(f, 4, m.description.xml_escape());
|
|
|
|
_write_string(f, 3, "</description>");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 2, "</method>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "</methods>");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (c.properties.size()) {
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "<members>");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-06-21 22:20:34 +02:00
|
|
|
c.properties.sort();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.properties.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyDoc &p = c.properties[i];
|
|
|
|
_write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" brief=\"" + p.brief_description.xml_escape(true) + "\">");
|
|
|
|
if (p.description != "")
|
|
|
|
_write_string(f, 3, p.description.xml_escape());
|
|
|
|
_write_string(f, 2, "</member>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "</members>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (c.signals.size()) {
|
|
|
|
|
2016-06-21 22:20:34 +02:00
|
|
|
c.signals.sort();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "<signals>");
|
|
|
|
for (int i = 0; i < c.signals.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
MethodDoc &m = c.signals[i];
|
|
|
|
_write_string(f, 2, "<signal name=\"" + m.name + "\">");
|
|
|
|
for (int j = 0; j < m.arguments.size(); j++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
ArgumentDoc &a = m.arguments[j];
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">");
|
|
|
|
_write_string(f, 3, "</argument>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 3, "<description>");
|
|
|
|
if (m.description != "")
|
|
|
|
_write_string(f, 4, m.description.xml_escape());
|
|
|
|
_write_string(f, 3, "</description>");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 2, "</signal>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "</signals>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "<constants>");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < c.constants.size(); i++) {
|
2016-06-21 22:20:34 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ConstantDoc &k = c.constants[i];
|
|
|
|
_write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\">");
|
|
|
|
if (k.description != "")
|
|
|
|
_write_string(f, 3, k.description.xml_escape());
|
|
|
|
_write_string(f, 2, "</constant>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "</constants>");
|
2014-06-30 03:41:02 +02:00
|
|
|
|
|
|
|
if (c.theme_properties.size()) {
|
2016-06-21 22:20:34 +02:00
|
|
|
|
|
|
|
c.theme_properties.sort();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "<theme_items>");
|
|
|
|
for (int i = 0; i < c.theme_properties.size(); i++) {
|
2014-06-30 03:41:02 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
PropertyDoc &p = c.theme_properties[i];
|
|
|
|
_write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
|
|
|
|
_write_string(f, 2, "</theme_item>");
|
2014-06-30 03:41:02 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 1, "</theme_items>");
|
2014-06-30 03:41:02 +02:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 0, "</class>");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_write_string(f, 0, "</doc>");
|
2014-02-10 02:10:30 +01:00
|
|
|
f->close();
|
|
|
|
memdelete(f);
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size) {
|
|
|
|
|
|
|
|
Vector<uint8_t> data;
|
|
|
|
data.resize(p_uncompressed_size);
|
2017-03-05 16:44:50 +01:00
|
|
|
Compression::decompress(data.ptr(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE);
|
2014-02-10 02:10:30 +01:00
|
|
|
class_list.clear();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Ref<XMLParser> parser = memnew(XMLParser);
|
2014-02-16 01:16:33 +01:00
|
|
|
Error err = parser->open_buffer(data);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2014-02-16 01:16:33 +01:00
|
|
|
_load(parser);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|