summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/etc/SCsub4
-rw-r--r--modules/gdnative/config.py2
-rw-r--r--modules/gdscript/gd_editor.cpp10
-rw-r--r--modules/gdscript/gd_functions.cpp32
-rw-r--r--modules/nativescript/api_generator.cpp82
-rw-r--r--modules/nativescript/config.py2
-rw-r--r--modules/visual_script/visual_script_nodes.cpp9
7 files changed, 103 insertions, 38 deletions
diff --git a/modules/etc/SCsub b/modules/etc/SCsub
index 8f5937017e..f0c1ee64b9 100644
--- a/modules/etc/SCsub
+++ b/modules/etc/SCsub
@@ -35,3 +35,7 @@ env_etc.add_source_files(env.modules_sources, "*.cpp")
# upstream uses c++11
env_etc.Append(CXXFLAGS="-std=gnu++11")
+# -ffast-math seems to be incompatible with ec2comp on recent versions of
+# GCC and Clang
+if '-ffast-math' in env_etc['CCFLAGS']:
+ env_etc['CCFLAGS'].remove('-ffast-math')
diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py
index 4f89ca0d4c..9f57b9bb74 100644
--- a/modules/gdnative/config.py
+++ b/modules/gdnative/config.py
@@ -1,7 +1,7 @@
def can_build(platform):
- return False
+ return True
def configure(env):
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index b10694ddfd..70e7da5748 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -297,23 +297,25 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
//not really "functions", but..
{
MethodInfo mi;
- mi.name = "preload:Resource";
+ mi.name = "preload";
mi.arguments.push_back(PropertyInfo(Variant::STRING, "path"));
mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "Resource");
p_functions->push_back(mi);
}
{
MethodInfo mi;
- mi.name = "yield:GDFunctionState";
+ mi.name = "yield";
mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object"));
mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal"));
mi.default_arguments.push_back(Variant::NIL);
mi.default_arguments.push_back(Variant::STRING);
+ mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDFunctionState");
p_functions->push_back(mi);
}
{
MethodInfo mi;
mi.name = "assert";
+ mi.return_val.type = Variant::NIL;
mi.arguments.push_back(PropertyInfo(Variant::BOOL, "condition"));
p_functions->push_back(mi);
}
@@ -1901,11 +1903,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += ", ";
else
arghint += " ";
- if (i == p_argidx) {
+ if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) {
arghint += String::chr(0xFFFF);
}
arghint += _get_visual_datatype(mi.arguments[i]) + " " + mi.arguments[i].name;
- if (i == p_argidx) {
+ if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) {
arghint += String::chr(0xFFFF);
}
}
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 3bd0ce3fab..f0cfdd6258 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -1572,43 +1572,49 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case TEXT_STR: {
- MethodInfo mi("str", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("str");
mi.return_val.type = Variant::STRING;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINT: {
- MethodInfo mi("print", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("print");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINT_TABBED: {
- MethodInfo mi("printt", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("printt");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINT_SPACED: {
- MethodInfo mi("prints", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("prints");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINTERR: {
- MethodInfo mi("printerr", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("printerr");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINTRAW: {
- MethodInfo mi("printraw", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("printraw");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
@@ -1620,8 +1626,9 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case STR_TO_VAR: {
- MethodInfo mi("str2var:Variant", PropertyInfo(Variant::STRING, "string"));
+ MethodInfo mi(Variant::NIL, "str2var", PropertyInfo(Variant::STRING, "string"));
mi.return_val.type = Variant::NIL;
+ mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case VAR_TO_BYTES: {
@@ -1632,14 +1639,16 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case BYTES_TO_VAR: {
- MethodInfo mi("bytes2var:Variant", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes"));
+ MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes"));
mi.return_val.type = Variant::NIL;
+ mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case GEN_RANGE: {
- MethodInfo mi("range", PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("range");
mi.return_val.type = Variant::ARRAY;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case RESOURCE_LOAD: {
@@ -1663,14 +1672,15 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case VALIDATE_JSON: {
- MethodInfo mi("validate_json:Variant", PropertyInfo(Variant::STRING, "json"));
+ MethodInfo mi("validate_json", PropertyInfo(Variant::STRING, "json"));
mi.return_val.type = Variant::STRING;
return mi;
} break;
case PARSE_JSON: {
- MethodInfo mi("parse_json:Variant", PropertyInfo(Variant::STRING, "json"));
+ MethodInfo mi(Variant::NIL, "parse_json", PropertyInfo(Variant::STRING, "json"));
mi.return_val.type = Variant::NIL;
+ mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case TO_JSON: {
diff --git a/modules/nativescript/api_generator.cpp b/modules/nativescript/api_generator.cpp
index 4490197bdb..fdd5a2ea19 100644
--- a/modules/nativescript/api_generator.cpp
+++ b/modules/nativescript/api_generator.cpp
@@ -33,6 +33,7 @@
#include "class_db.h"
#include "core/global_constants.h"
+#include "core/pair.h"
#include "core/project_settings.h"
#include "os/file_access.h"
@@ -93,6 +94,11 @@ struct SignalAPI {
Map<int, Variant> default_arguments;
};
+struct EnumAPI {
+ String name;
+ List<Pair<int, String> > values;
+};
+
struct ClassAPI {
String class_name;
String super_class_name;
@@ -109,8 +115,28 @@ struct ClassAPI {
List<PropertyAPI> properties;
List<ConstantAPI> constants;
List<SignalAPI> signals_;
+ List<EnumAPI> enums;
};
+static String get_type_name(const PropertyInfo &info) {
+ if (info.type == Variant::INT && (info.usage & PROPERTY_USAGE_CLASS_IS_ENUM)) {
+ return String("enum.") + String(info.class_name).replace(".", "::");
+ }
+ if (info.class_name != StringName()) {
+ return info.class_name;
+ }
+ if (info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ return info.hint_string;
+ }
+ if (info.type == Variant::NIL && (info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
+ return "Variant";
+ }
+ if (info.type == Variant::NIL) {
+ return "void";
+ }
+ return Variant::get_type_name(info.type);
+}
+
/*
* Reads the entire Godot API to a list
*/
@@ -194,12 +220,8 @@ List<ClassAPI> generate_c_api_classes() {
if (argument.name.find(":") != -1) {
type = argument.name.get_slice(":", 1);
name = argument.name.get_slice(":", 0);
- } else if (argument.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- type = argument.hint_string;
- } else if (argument.type == Variant::NIL) {
- type = "Variant";
} else {
- type = Variant::get_type_name(argument.type);
+ type = get_type_name(argument);
}
signal.argument_names.push_back(name);
@@ -233,12 +255,8 @@ List<ClassAPI> generate_c_api_classes() {
if (p->get().name.find(":") != -1) {
property_api.type = p->get().name.get_slice(":", 1);
property_api.name = p->get().name.get_slice(":", 0);
- } else if (p->get().hint == PROPERTY_HINT_RESOURCE_TYPE) {
- property_api.type = p->get().hint_string;
- } else if (p->get().type == Variant::NIL) {
- property_api.type = "Variant";
} else {
- property_api.type = Variant::get_type_name(p->get().type);
+ property_api.type = get_type_name(p->get());
}
if (!property_api.setter.empty() || !property_api.getter.empty()) {
@@ -260,17 +278,11 @@ List<ClassAPI> generate_c_api_classes() {
//method name
method_api.method_name = m->get().name;
//method return type
- if (method_bind && method_bind->get_return_type() != StringName()) {
- method_api.return_type = method_bind->get_return_type();
- } else if (method_api.method_name.find(":") != -1) {
+ if (method_api.method_name.find(":") != -1) {
method_api.return_type = method_api.method_name.get_slice(":", 1);
method_api.method_name = method_api.method_name.get_slice(":", 0);
- } else if (m->get().return_val.type != Variant::NIL) {
- method_api.return_type = m->get().return_val.hint == PROPERTY_HINT_RESOURCE_TYPE ? m->get().return_val.hint_string : Variant::get_type_name(m->get().return_val.type);
- } else if (m->get().return_val.name != "") {
- method_api.return_type = m->get().return_val.name;
} else {
- method_api.return_type = "void";
+ method_api.return_type = get_type_name(m->get().return_val);
}
method_api.argument_count = method_info.arguments.size();
@@ -321,6 +333,25 @@ List<ClassAPI> generate_c_api_classes() {
}
}
+ // enums
+ {
+ List<EnumAPI> enums;
+ List<StringName> enum_names;
+ ClassDB::get_enum_list(class_name, &enum_names, true);
+ for (List<StringName>::Element *E = enum_names.front(); E; E = E->next()) {
+ List<StringName> value_names;
+ EnumAPI enum_api;
+ enum_api.name = E->get();
+ ClassDB::get_enum_constants(class_name, E->get(), &value_names, true);
+ for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) {
+ int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL);
+ enum_api.values.push_back(Pair<int, String>(int_val, val_e->get()));
+ }
+ enum_api.values.sort_custom<PairSort<int, String> >();
+ class_api.enums.push_back(enum_api);
+ }
+ }
+
api.push_back(class_api);
}
@@ -410,11 +441,24 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back("\t\t\t\t]\n");
source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
}
+ source.push_back("\t\t],\n");
+
+ source.push_back("\t\t\"enums\": [\n");
+ for (List<EnumAPI>::Element *e = api.enums.front(); e; e = e->next()) {
+ source.push_back("\t\t\t{\n");
+ source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n");
+ source.push_back("\t\t\t\t\"values\": {\n");
+ for (List<Pair<int, String> >::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) {
+ source.push_back("\t\t\t\t\t\"" + val_e->get().second + "\": " + itos(val_e->get().first));
+ source.push_back(String((val_e->next() ? "," : "")) + "\n");
+ }
+ source.push_back("\t\t\t\t}\n");
+ source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
+ }
source.push_back("\t\t]\n");
source.push_back(String("\t}") + (c->next() ? "," : "") + "\n");
}
-
source.push_back("]");
return source;
diff --git a/modules/nativescript/config.py b/modules/nativescript/config.py
index 4f89ca0d4c..9f57b9bb74 100644
--- a/modules/nativescript/config.py
+++ b/modules/nativescript/config.py
@@ -1,7 +1,7 @@
def can_build(platform):
- return False
+ return True
def configure(env):
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index af7b334e46..1decc004ab 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -2702,7 +2702,10 @@ void VisualScriptCustomNode::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_category"));
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_working_memory_size"));
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_step:Variant", PropertyInfo(Variant::ARRAY, "inputs"), PropertyInfo(Variant::ARRAY, "outputs"), PropertyInfo(Variant::INT, "start_mode"), PropertyInfo(Variant::ARRAY, "working_mem")));
+
+ MethodInfo stepmi(Variant::NIL, "_step", PropertyInfo(Variant::ARRAY, "inputs"), PropertyInfo(Variant::ARRAY, "outputs"), PropertyInfo(Variant::INT, "start_mode"), PropertyInfo(Variant::ARRAY, "working_mem"));
+ stepmi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
+ BIND_VMETHOD(stepmi);
ClassDB::bind_method(D_METHOD("_script_changed"), &VisualScriptCustomNode::_script_changed);
@@ -2839,7 +2842,9 @@ VisualScriptNodeInstance *VisualScriptSubCall::instance(VisualScriptInstance *p_
void VisualScriptSubCall::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_subcall:Variant", PropertyInfo(Variant::NIL, "arguments:Variant")));
+ MethodInfo scmi(Variant::NIL, "_subcall", PropertyInfo(Variant::NIL, "arguments"));
+ scmi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
+ BIND_VMETHOD(scmi);
}
VisualScriptSubCall::VisualScriptSubCall() {