summaryrefslogtreecommitdiff
path: root/modules/mono/glue/Managed/Files/NodePath.cs
blob: 2c89bec87fef6fe5362014894f8b9966c5e6aa73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Runtime.CompilerServices;

namespace Godot
{
    public partial class NodePath : IDisposable
    {
        private bool disposed = false;

        internal IntPtr ptr;

        internal static IntPtr GetPtr(NodePath instance)
        {
            return instance == null ? IntPtr.Zero : instance.ptr;
        }

        ~NodePath()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
                return;

            if (ptr != IntPtr.Zero)
            {
                godot_icall_NodePath_Dtor(ptr);
                ptr = IntPtr.Zero;
            }

            disposed = true;
        }

        internal NodePath(IntPtr ptr)
        {
            this.ptr = ptr;
        }

        public IntPtr NativeInstance
        {
            get { return ptr; }
        }

        public NodePath() : this(string.Empty) {}

        public NodePath(string path)
        {
            this.ptr = godot_icall_NodePath_Ctor(path);
        }

        public static implicit operator NodePath(string from)
        {
            return new NodePath(from);
        }

        public static implicit operator string(NodePath from)
        {
            return godot_icall_NodePath_operator_String(NodePath.GetPtr(from));
        }

        public override string ToString()
        {
            return (string)this;
        }

        public NodePath GetAsPropertyPath()
        {
            return new NodePath(godot_icall_NodePath_get_as_property_path(NodePath.GetPtr(this)));
        }

        public string GetConcatenatedSubnames()
        {
            return godot_icall_NodePath_get_concatenated_subnames(NodePath.GetPtr(this));
        }

        public string GetName(int idx)
        {
            return godot_icall_NodePath_get_name(NodePath.GetPtr(this), idx);
        }

        public int GetNameCount()
        {
            return godot_icall_NodePath_get_name_count(NodePath.GetPtr(this));
        }

        public string GetSubname(int idx)
        {
            return godot_icall_NodePath_get_subname(NodePath.GetPtr(this), idx);
        }

        public int GetSubnameCount()
        {
            return godot_icall_NodePath_get_subname_count(NodePath.GetPtr(this));
        }

        public bool IsAbsolute()
        {
            return godot_icall_NodePath_is_absolute(NodePath.GetPtr(this));
        }

        public bool IsEmpty()
        {
            return godot_icall_NodePath_is_empty(NodePath.GetPtr(this));
        }

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static IntPtr godot_icall_NodePath_Ctor(string path);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static void godot_icall_NodePath_Dtor(IntPtr ptr);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static string godot_icall_NodePath_operator_String(IntPtr ptr);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static IntPtr godot_icall_NodePath_get_as_property_path(IntPtr ptr);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static string godot_icall_NodePath_get_concatenated_subnames(IntPtr ptr);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static string godot_icall_NodePath_get_name(IntPtr ptr, int arg1);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static int godot_icall_NodePath_get_name_count(IntPtr ptr);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static string godot_icall_NodePath_get_subname(IntPtr ptr, int arg1);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static int godot_icall_NodePath_get_subname_count(IntPtr ptr);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static bool godot_icall_NodePath_is_absolute(IntPtr ptr);

        [MethodImpl(MethodImplOptions.InternalCall)]
        internal extern static bool godot_icall_NodePath_is_empty(IntPtr ptr);
    }
}