nodepath_glue.cpp 5.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**************************************************************************/
  2. /* nodepath_glue.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "nodepath_glue.h"
  31. #ifdef MONO_GLUE_ENABLED
  32. #include "core/ustring.h"
  33. NodePath *godot_icall_NodePath_Ctor(MonoString *p_path) {
  34. return memnew(NodePath(GDMonoMarshal::mono_string_to_godot(p_path)));
  35. }
  36. void godot_icall_NodePath_Dtor(NodePath *p_ptr) {
  37. ERR_FAIL_NULL(p_ptr);
  38. memdelete(p_ptr);
  39. }
  40. MonoString *godot_icall_NodePath_operator_String(NodePath *p_np) {
  41. return GDMonoMarshal::mono_string_from_godot(p_np->operator String());
  42. }
  43. MonoBoolean godot_icall_NodePath_is_absolute(NodePath *p_ptr) {
  44. return (MonoBoolean)p_ptr->is_absolute();
  45. }
  46. uint32_t godot_icall_NodePath_get_name_count(NodePath *p_ptr) {
  47. return p_ptr->get_name_count();
  48. }
  49. MonoString *godot_icall_NodePath_get_name(NodePath *p_ptr, uint32_t p_idx) {
  50. return GDMonoMarshal::mono_string_from_godot(p_ptr->get_name(p_idx));
  51. }
  52. uint32_t godot_icall_NodePath_get_subname_count(NodePath *p_ptr) {
  53. return p_ptr->get_subname_count();
  54. }
  55. MonoString *godot_icall_NodePath_get_subname(NodePath *p_ptr, uint32_t p_idx) {
  56. return GDMonoMarshal::mono_string_from_godot(p_ptr->get_subname(p_idx));
  57. }
  58. MonoString *godot_icall_NodePath_get_concatenated_subnames(NodePath *p_ptr) {
  59. return GDMonoMarshal::mono_string_from_godot(p_ptr->get_concatenated_subnames());
  60. }
  61. NodePath *godot_icall_NodePath_get_as_property_path(NodePath *p_ptr) {
  62. return memnew(NodePath(p_ptr->get_as_property_path()));
  63. }
  64. MonoBoolean godot_icall_NodePath_is_empty(NodePath *p_ptr) {
  65. return (MonoBoolean)p_ptr->is_empty();
  66. }
  67. void godot_register_nodepath_icalls() {
  68. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_Ctor", godot_icall_NodePath_Ctor);
  69. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_Dtor", godot_icall_NodePath_Dtor);
  70. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_operator_String", godot_icall_NodePath_operator_String);
  71. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_get_as_property_path", godot_icall_NodePath_get_as_property_path);
  72. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_get_concatenated_subnames", godot_icall_NodePath_get_concatenated_subnames);
  73. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_get_name", godot_icall_NodePath_get_name);
  74. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_get_name_count", godot_icall_NodePath_get_name_count);
  75. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_get_subname", godot_icall_NodePath_get_subname);
  76. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_get_subname_count", godot_icall_NodePath_get_subname_count);
  77. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_is_absolute", godot_icall_NodePath_is_absolute);
  78. GDMonoUtils::add_internal_call("Godot.NodePath::godot_icall_NodePath_is_empty", godot_icall_NodePath_is_empty);
  79. }
  80. #endif // MONO_GLUE_ENABLED