diff options
-rw-r--r-- | core/extension/gdnative_interface.cpp | 17 | ||||
-rw-r--r-- | core/extension/gdnative_interface.h | 5 | ||||
-rw-r--r-- | doc/classes/Node.xml | 8 |
3 files changed, 30 insertions, 0 deletions
diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp index a65408fdda..19988a26cb 100644 --- a/core/extension/gdnative_interface.cpp +++ b/core/extension/gdnative_interface.cpp @@ -783,6 +783,18 @@ static GDNativeVariantPtr gdnative_array_operator_index_const(const GDNativeType return (GDNativeVariantPtr)&self->operator[](p_index); } +/* Dictionary functions */ + +static GDNativeVariantPtr gdnative_dictionary_operator_index(GDNativeTypePtr p_self, const GDNativeVariantPtr p_key) { + Dictionary *self = (Dictionary *)p_self; + return (GDNativeVariantPtr)&self->operator[](*(const Variant *)p_key); +} + +static GDNativeVariantPtr gdnative_dictionary_operator_index_const(const GDNativeTypePtr p_self, const GDNativeVariantPtr p_key) { + const Dictionary *self = (const Dictionary *)p_self; + return (GDNativeVariantPtr)&self->operator[](*(const Variant *)p_key); +} + /* OBJECT API */ static void gdnative_object_method_bind_call(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error) { @@ -1001,6 +1013,11 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) { gdni.array_operator_index = gdnative_array_operator_index; gdni.array_operator_index_const = gdnative_array_operator_index_const; + /* Dictionary functions */ + + gdni.dictionary_operator_index = gdnative_dictionary_operator_index; + gdni.dictionary_operator_index_const = gdnative_dictionary_operator_index_const; + /* OBJECT */ gdni.object_method_bind_call = gdnative_object_method_bind_call; diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index 8f8cb5a3e0..e411a9d85b 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -417,6 +417,11 @@ typedef struct { GDNativeVariantPtr (*array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr GDNativeVariantPtr (*array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr + /* Dictionary functions */ + + GDNativeVariantPtr (*dictionary_operator_index)(GDNativeTypePtr p_self, const GDNativeVariantPtr p_key); // p_self should be an Dictionary ptr + GDNativeVariantPtr (*dictionary_operator_index_const)(const GDNativeTypePtr p_self, const GDNativeVariantPtr p_key); // p_self should be an Dictionary ptr + /* OBJECT */ void (*object_method_bind_call)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_ret, GDNativeCallError *r_error); diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 423002d058..6b3aa30dd2 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -233,6 +233,14 @@ <description> Returns an array listing the groups that the node is a member of. [b]Note:[/b] For performance reasons, the order of node groups is [i]not[/i] guaranteed. The order of node groups should not be relied upon as it can vary across project runs. + [b]Note:[/b] The engine uses some group names internally (all starting with an underscore). To avoid conflicts with internal groups, do not add custom groups whose name starts with an underscore. To exclude internal groups while looping over [method get_groups], use the following snippet: + [codeblock] + # Stores the node's non-internal groups only (as an array of Strings). + var non_internal_groups = [] + for group in get_groups(): + if not group.begins_with("_"): + non_internal_groups.push_back(group) + [/codeblock] </description> </method> <method name="get_index" qualifiers="const"> |