From d320ee5c363b1209a410eb07e6533a5a065d687a Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 31 May 2023 14:16:18 +0200 Subject: [PATCH] Improved StringName constructors. --- gdnative/string_name.cpp | 13 +++++++++++-- gdnative_api.json | 17 ++++++++++++++++- include/gdn/string_name.h | 7 ++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/gdnative/string_name.cpp b/gdnative/string_name.cpp index 624de0f..3cc51c4 100644 --- a/gdnative/string_name.cpp +++ b/gdnative/string_name.cpp @@ -70,13 +70,22 @@ pandemonium_bool GDAPI pandemonium_string_name_operator_less(const pandemonium_s return *self < *other; } -void GDAPI pandemonium_string_name_new(pandemonium_string_name *r_dest, const pandemonium_string *p_name) { +void GDAPI pandemonium_string_name_new(pandemonium_string_name *r_dest) { + StringName *dest = (StringName *)r_dest; + memnew_placement(dest, StringName); +} + +void GDAPI pandemonium_string_name_new_data_string(pandemonium_string_name *r_dest, const pandemonium_string *p_name) { StringName *dest = (StringName *)r_dest; const String *name = (const String *)p_name; memnew_placement(dest, StringName(*name)); } +void GDAPI pandemonium_string_name_new_data_char(pandemonium_string_name *r_dest, const char *p_name) { + StringName *dest = (StringName *)r_dest; + memnew_placement(dest, StringName(p_name)); +} -void GDAPI pandemonium_string_name_new_data(pandemonium_string_name *r_dest, const char *p_name) { +void GDAPI pandemonium_string_name_new_datac(pandemonium_string_name *r_dest, const pandemonium_char_type *p_name) { StringName *dest = (StringName *)r_dest; memnew_placement(dest, StringName(p_name)); } diff --git a/gdnative_api.json b/gdnative_api.json index d83e2a4..250de63 100644 --- a/gdnative_api.json +++ b/gdnative_api.json @@ -4613,19 +4613,34 @@ { "name": "pandemonium_string_name_new", "return_type": "void", + "arguments": [ + ["pandemonium_string_name *", "r_dest"] + ] + }, + { + "name": "pandemonium_string_name_new_data_string", + "return_type": "void", "arguments": [ ["pandemonium_string_name *", "r_dest"], ["const pandemonium_string *", "p_name"] ] }, { - "name": "pandemonium_string_name_new_data", + "name": "pandemonium_string_name_new_data_char", "return_type": "void", "arguments": [ ["pandemonium_string_name *", "r_dest"], ["const char *", "p_name"] ] }, + { + "name": "pandemonium_string_name_new_datac", + "return_type": "void", + "arguments": [ + ["pandemonium_string_name *", "r_dest"], + ["const pandemonium_char_type *", "p_name"] + ] + }, { "name": "pandemonium_string_name_destroy", "return_type": "void", diff --git a/include/gdn/string_name.h b/include/gdn/string_name.h index 154ead1..29866f1 100644 --- a/include/gdn/string_name.h +++ b/include/gdn/string_name.h @@ -66,9 +66,10 @@ const void GDAPI *pandemonium_string_name_get_data_unique_pointer(const pandemon pandemonium_bool GDAPI pandemonium_string_name_operator_equal(const pandemonium_string_name *p_self, const pandemonium_string_name *p_other); pandemonium_bool GDAPI pandemonium_string_name_operator_less(const pandemonium_string_name *p_self, const pandemonium_string_name *p_other); -void GDAPI pandemonium_string_name_new(pandemonium_string_name *r_dest, const pandemonium_string *p_name); -void GDAPI pandemonium_string_name_new_data(pandemonium_string_name *r_dest, const char *p_name); -//static variant +void GDAPI pandemonium_string_name_new(pandemonium_string_name *r_dest); +void GDAPI pandemonium_string_name_new_data_string(pandemonium_string_name *r_dest, const pandemonium_string *p_name); +void GDAPI pandemonium_string_name_new_data_char(pandemonium_string_name *r_dest, const char *p_name); +void GDAPI pandemonium_string_name_new_datac(pandemonium_string_name *r_dest, const pandemonium_char_type *p_name); void GDAPI pandemonium_string_name_destroy(pandemonium_string_name *p_self);