summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs6
-rw-r--r--modules/mono/editor/editor_internal_calls.cpp9
-rw-r--r--modules/mono/editor/script_class_parser.cpp6
-rw-r--r--scene/resources/visual_shader.cpp30
-rw-r--r--scene/resources/visual_shader.h3
5 files changed, 48 insertions, 6 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs
index 80e45b3a3c..11afa8773e 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs
@@ -25,14 +25,14 @@ namespace GodotTools.Internals
}
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern Error internal_ParseFile(string filePath, Array<Dictionary> classes);
+ private static extern Error internal_ParseFile(string filePath, Array<Dictionary> classes, out string errorStr);
public static void ParseFileOrThrow(string filePath, out IEnumerable<ClassDecl> classes)
{
var classesArray = new Array<Dictionary>();
- var error = internal_ParseFile(filePath, classesArray);
+ var error = internal_ParseFile(filePath, classesArray, out string errorStr);
if (error != Error.Ok)
- throw new Exception($"Failed to determine namespace and class for script: {filePath}. Parse error: {error}");
+ throw new Exception($"Failed to determine namespace and class for script: {filePath}. Parse error: {errorStr ?? error.ToString()}");
var classesList = new List<ClassDecl>();
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp
index cfc869cd39..c8d20e80be 100644
--- a/modules/mono/editor/editor_internal_calls.cpp
+++ b/modules/mono/editor/editor_internal_calls.cpp
@@ -201,7 +201,9 @@ uint32_t godot_icall_BindingsGenerator_CsGlueVersion() {
return CS_GLUE_VERSION;
}
-int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes) {
+int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes, MonoString **r_error_str) {
+ *r_error_str = NULL;
+
String filepath = GDMonoMarshal::mono_string_to_godot(p_filepath);
ScriptClassParser scp;
@@ -220,6 +222,11 @@ int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObje
classDeclDict["base_count"] = classDecl.base.size();
classes.push_back(classDeclDict);
}
+ } else {
+ String error_str = scp.get_error();
+ if (!error_str.empty()) {
+ *r_error_str = GDMonoMarshal::mono_string_from_godot(error_str);
+ }
}
return err;
}
diff --git a/modules/mono/editor/script_class_parser.cpp b/modules/mono/editor/script_class_parser.cpp
index c400479b89..84163dd952 100644
--- a/modules/mono/editor/script_class_parser.cpp
+++ b/modules/mono/editor/script_class_parser.cpp
@@ -302,8 +302,10 @@ Error ScriptClassParser::_skip_generic_type_params() {
Error err = _skip_generic_type_params();
if (err)
return err;
- continue;
- } else if (tk == TK_OP_GREATER) {
+ tk = get_token();
+ }
+
+ if (tk == TK_OP_GREATER) {
return OK;
} else if (tk != TK_COMMA) {
error_str = "Unexpected token: " + get_token_name(tk);
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 37792eaaea..4d2082e3c1 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -378,6 +378,9 @@ void VisualShader::remove_node(Type p_type, int p_id) {
List<Connection>::Element *N = E->next();
if (E->get().from_node == p_id || E->get().to_node == p_id) {
g->connections.erase(E);
+ if (E->get().from_node == p_id) {
+ g->nodes[E->get().to_node].prev_connected_nodes.erase(p_id);
+ }
}
E = N;
}
@@ -399,6 +402,25 @@ bool VisualShader::is_node_connection(Type p_type, int p_from_node, int p_from_p
return false;
}
+bool VisualShader::is_nodes_connected_relatively(const Graph *p_graph, int p_node, int p_target) const {
+ bool result = false;
+
+ const VisualShader::Node &node = p_graph->nodes[p_node];
+
+ for (const List<int>::Element *E = node.prev_connected_nodes.front(); E; E = E->next()) {
+
+ if (E->get() == p_target) {
+ return true;
+ }
+
+ result = is_nodes_connected_relatively(p_graph, E->get(), p_target);
+ if (result) {
+ break;
+ }
+ }
+ return result;
+}
+
bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const {
ERR_FAIL_INDEX_V(p_type, TYPE_MAX, false);
@@ -433,6 +455,9 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po
}
}
+ if (is_nodes_connected_relatively(g, p_from_node, p_to_node))
+ return false;
+
return true;
}
@@ -449,6 +474,8 @@ void VisualShader::connect_nodes_forced(Type p_type, int p_from_node, int p_from
c.to_node = p_to_node;
c.to_port = p_to_port;
g->connections.push_back(c);
+ g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node);
+
_queue_update();
}
@@ -479,6 +506,7 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port,
c.to_node = p_to_node;
c.to_port = p_to_port;
g->connections.push_back(c);
+ g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node);
_queue_update();
return OK;
@@ -492,6 +520,7 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por
if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) {
g->connections.erase(E);
+ g->nodes[p_to_node].prev_connected_nodes.erase(p_from_node);
_queue_update();
return;
}
@@ -1326,6 +1355,7 @@ void VisualShader::_input_type_changed(Type p_type, int p_id) {
List<Connection>::Element *N = E->next();
if (E->get().from_node == p_id) {
g->connections.erase(E);
+ g->nodes[E->get().to_node].prev_connected_nodes.erase(p_id);
}
E = N;
}
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 0a3d5f96bd..b2803d1dfb 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -65,6 +65,7 @@ private:
struct Node {
Ref<VisualShaderNode> node;
Vector2 position;
+ List<int> prev_connected_nodes;
};
struct Graph {
@@ -135,6 +136,8 @@ public:
void remove_node(Type p_type, int p_id);
bool is_node_connection(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const;
+
+ bool is_nodes_connected_relatively(const Graph *p_graph, int p_node, int p_target) const;
bool can_connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const;
Error connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
void disconnect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);