Browse Source

Expose get_rpc_config and get_node_rpc_config

Fabio Alessandrelli 2 months ago
parent
commit
b73ec1fa9b

+ 2 - 0
core/object/script_language.cpp

@@ -172,6 +172,8 @@ void Script::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool);
 	ClassDB::bind_method(D_METHOD("is_abstract"), &Script::is_abstract);
 
+	ClassDB::bind_method(D_METHOD("get_rpc_config"), &Script::_get_rpc_config_bind);
+
 	ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_source_code", "get_source_code");
 }
 

+ 4 - 0
core/object/script_language.h

@@ -135,6 +135,10 @@ protected:
 
 	void _set_debugger_break_language();
 
+	Variant _get_rpc_config_bind() const {
+		return get_rpc_config().duplicate(true);
+	}
+
 public:
 	virtual void reload_from_file() override;
 

+ 7 - 0
doc/classes/Node.xml

@@ -495,6 +495,13 @@
 				Fetches a node by [NodePath]. Similar to [method get_node], but does not generate an error if [param path] does not point to a valid node.
 			</description>
 		</method>
+		<method name="get_node_rpc_config" qualifiers="const">
+			<return type="Variant" />
+			<description>
+				Returns a [Dictionary] mapping method names to their RPC configuration defined for this node using [method rpc_config].
+				[b]Note:[/b] This method only returns the RPC configuration assigned via [method rpc_config]. See [method Script.get_rpc_config] to retrieve the RPCs defined by the [Script].
+			</description>
+		</method>
 		<method name="get_orphan_node_ids" qualifiers="static">
 			<return type="int[]" />
 			<description>

+ 6 - 0
doc/classes/Script.xml

@@ -58,6 +58,12 @@
 				Returns the default value of the specified property.
 			</description>
 		</method>
+		<method name="get_rpc_config" qualifiers="const">
+			<return type="Variant" />
+			<description>
+				Returns a [Dictionary] mapping method names to their RPC configuration defined by this script.
+			</description>
+		</method>
 		<method name="get_script_constant_map">
 			<return type="Dictionary" />
 			<description>

+ 7 - 0
misc/extension_api_validation/4.4-stable.expected

@@ -251,3 +251,10 @@ Validate extension JSON: Error: Field 'classes/InputMap/methods/add_action/argum
 Validate extension JSON: Error: Field 'global_enums/KeyModifierMask/values/KEY_MODIFIER_MASK': value changed value in new API, from 532676600.0 to 2130706432.
 
 Precision of string-serialized Variant constants increased.
+
+
+GH-106848
+---------
+Validate extension JSON: API was removed: classes/Node/methods/get_rpc_config
+
+Change Node `get_rpc_config` to `get_node_rpc_config`. Compatibility method registered.

+ 5 - 0
scene/main/node.compat.inc

@@ -34,8 +34,13 @@ void Node::_set_name_bind_compat_76560(const String &p_name) {
 	set_name(p_name);
 }
 
+Variant Node::_get_rpc_config_bind_compat_106848() const {
+	return _get_node_rpc_config_bind();
+}
+
 void Node::_bind_compatibility_methods() {
 	ClassDB::bind_compatibility_method(D_METHOD("set_name", "name"), &Node::_set_name_bind_compat_76560);
+	ClassDB::bind_compatibility_method(D_METHOD("get_rpc_config"), &Node::_get_rpc_config_bind_compat_106848);
 }
 
 #endif

+ 1 - 0
scene/main/node.cpp

@@ -3980,6 +3980,7 @@ void Node::_bind_methods() {
 
 	ClassDB::bind_method(D_METHOD("get_multiplayer"), &Node::get_multiplayer);
 	ClassDB::bind_method(D_METHOD("rpc_config", "method", "config"), &Node::rpc_config);
+	ClassDB::bind_method(D_METHOD("get_node_rpc_config"), &Node::_get_node_rpc_config_bind);
 
 	ClassDB::bind_method(D_METHOD("set_editor_description", "editor_description"), &Node::set_editor_description);
 	ClassDB::bind_method(D_METHOD("get_editor_description"), &Node::get_editor_description);

+ 5 - 0
scene/main/node.h

@@ -388,6 +388,10 @@ protected:
 
 	void _validate_property(PropertyInfo &p_property) const;
 
+	Variant _get_node_rpc_config_bind() const {
+		return get_node_rpc_config().duplicate(true);
+	}
+
 protected:
 	virtual bool _uses_signal_mutex() const override { return false; } // Node uses thread guards instead.
 
@@ -414,6 +418,7 @@ protected:
 
 #ifndef DISABLE_DEPRECATED
 	void _set_name_bind_compat_76560(const String &p_name);
+	Variant _get_rpc_config_bind_compat_106848() const;
 	static void _bind_compatibility_methods();
 #endif