[NUI] Make ReleaseSwigCPtr didn't check HasBody()
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Common / Uint16Pair.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using global::System;
19 using global::System.Runtime.InteropServices;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// Simple class for passing around pairs of small unsigned integers.<br />
25     /// Use this for integer dimensions and points with limited range such as image
26     /// sizes and pixel coordinates where a pair of floating point numbers is
27     /// inefficient and illogical (i.e.the data is inherently integer).<br />
28     /// One of these can be passed in a single 32 bit integer register on
29     /// common architectures.<br />
30     /// </summary>
31     internal class Uint16Pair : Disposable
32     {
33
34         internal Uint16Pair(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
35         {
36         }
37
38         protected override void ReleaseSwigCPtr(HandleRef swigCPtr)
39         {
40             Interop.Uint16Pair.DeleteUint16Pair(swigCPtr);
41         }
42
43         /// <summary>
44         /// Less than comparison operator for storing in collections (not geometrically meaningful).
45         /// </summary>
46         /// <param name="arg1">A reference for comparison.</param>
47         /// <param name="arg2">A reference for comparison</param>
48         /// <return>True if arg1 less than arg2</return>
49         public static bool operator <(Uint16Pair arg1, Uint16Pair arg2)
50         {
51             return arg1.LessThan(arg2);
52         }
53
54         /// <summary>
55         /// More than comparison operator for storing in collections (not geometrically meaningful).
56         /// </summary>
57         /// <param name="arg1">A reference for comparison.</param>
58         /// <param name="arg2">A reference for comparison</param>
59         /// <return>True if arg1 > arg2</return>
60         public static bool operator >(Uint16Pair arg1, Uint16Pair arg2)
61         {
62             return arg1.GreaterThan(arg2);
63         }
64
65         /// <summary>
66         /// Default constructor for the(0, 0) tuple.
67         /// </summary>
68         public Uint16Pair() : this(Interop.Uint16Pair.NewUint16Pair(), true)
69         {
70             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71         }
72
73         /// <summary>
74         /// Default constructor for the(0, 0) tuple.
75         /// </summary>
76         /// <param name="width">The width or X dimension of the tuple. Make sure it is less than 65536.</param>
77         /// <param name="height">The height or Y dimension of the tuple.Make sure it is less than 65536.</param>
78         public Uint16Pair(uint width, uint height) : this(Interop.Uint16Pair.NewUint16Pair(width, height), true)
79         {
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81         }
82
83         /// <summary>
84         /// Constructor taking separate x and y (width and height) parameters.
85         /// </summary>
86         /// <param name="rhs">A reference to assign.</param>
87         public Uint16Pair(Uint16Pair rhs) : this(Interop.Uint16Pair.NewUint16Pair(Uint16Pair.getCPtr(rhs)), true)
88         {
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90         }
91
92         /// <summary>
93         /// Sets the width.
94         /// </summary>
95         /// <param name="width">The x dimension to be stored in this 2-tuple.</param>
96         public void SetWidth(ushort width)
97         {
98             if (SwigCPtr.Handle == IntPtr.Zero)
99             {
100                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
101             }
102             Interop.Uint16Pair.SetWidth(SwigCPtr, width);
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104         }
105
106         /// <summary>
107         /// Get the width.
108         /// </summary>
109         /// <return>
110         /// The x dimension stored in this 2-tuple.
111         /// </return>
112         public ushort GetWidth()
113         {
114             if (SwigCPtr.Handle == IntPtr.Zero)
115             {
116                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
117             }
118             ushort ret = Interop.Uint16Pair.GetWidth(SwigCPtr);
119             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120             return ret;
121         }
122
123         /// <summary>
124         /// Sets the height.
125         /// </summary>
126         /// <param name="height">The y dimension to be stored in this 2-tuple.</param>
127         public void SetHeight(ushort height)
128         {
129             if (SwigCPtr.Handle == IntPtr.Zero)
130             {
131                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
132             }
133             Interop.Uint16Pair.SetHeight(SwigCPtr, height);
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135         }
136
137         /// <summary>
138         /// Get the height.
139         /// </summary>
140         /// <return>
141         /// The y dimension stored in this 2-tuple.
142         /// </return>
143         public ushort GetHeight()
144         {
145             if (SwigCPtr.Handle == IntPtr.Zero)
146             {
147                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
148             }
149             ushort ret = Interop.Uint16Pair.GetHeight(SwigCPtr);
150             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
151             return ret;
152         }
153
154         /// <summary>
155         /// Sets the x dimension.
156         /// </summary>
157         /// <param name="x">The x dimension to be stored in this 2-tuple.</param>
158         public void SetX(ushort x)
159         {
160             if (SwigCPtr.Handle == IntPtr.Zero)
161             {
162                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
163             }
164             Interop.Uint16Pair.SetX(SwigCPtr, x);
165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166         }
167
168         /// <summary>
169         /// Get the x dimension.
170         /// </summary>
171         /// <return>
172         /// The x dimension stored in this 2-tuple.
173         /// </return>
174         public ushort GetX()
175         {
176             if (SwigCPtr.Handle == IntPtr.Zero)
177             {
178                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
179             }
180             ushort ret = Interop.Uint16Pair.GetX(SwigCPtr);
181             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182             return ret;
183         }
184
185         /// <summary>
186         /// Sets the y dimension.
187         /// </summary>
188         /// <param name="y">The y dimension to be stored in this 2-tuple.</param>
189         public void SetY(ushort y)
190         {
191             if (SwigCPtr.Handle == IntPtr.Zero)
192             {
193                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
194             }
195             Interop.Uint16Pair.SetY(SwigCPtr, y);
196             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197         }
198
199         /// <summary>
200         /// Get the y dimension.
201         /// </summary>
202         /// <return>
203         /// The y dimension stored in this 2-tuple.
204         /// </return>
205         public ushort GetY()
206         {
207             if (SwigCPtr.Handle == IntPtr.Zero)
208             {
209                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
210             }
211             ushort ret = Interop.Uint16Pair.GetY(SwigCPtr);
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213             return ret;
214         }
215
216         /// <summary>
217         /// Constructor taking separate x and y (width and height) parameters.
218         /// </summary>
219         /// <param name="rhs">A reference to assign.</param>
220         /// <return>The created object.</return>
221         public Uint16Pair Assign(Uint16Pair rhs)
222         {
223             if (SwigCPtr.Handle == IntPtr.Zero)
224             {
225                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
226             }
227             Uint16Pair ret = new Uint16Pair(Interop.Uint16Pair.Assign(SwigCPtr, Uint16Pair.getCPtr(rhs)), false);
228             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229             return ret;
230         }
231
232         private bool EqualTo(Uint16Pair rhs)
233         {
234             if (SwigCPtr.Handle == IntPtr.Zero)
235             {
236                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
237             }
238             bool ret = Interop.Uint16Pair.EqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240             return ret;
241         }
242
243         private bool NotEqualTo(Uint16Pair rhs)
244         {
245             if (SwigCPtr.Handle == IntPtr.Zero)
246             {
247                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
248             }
249             bool ret = Interop.Uint16Pair.NotEqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs));
250             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251             return ret;
252         }
253
254         private bool LessThan(Uint16Pair rhs)
255         {
256             if (SwigCPtr.Handle == IntPtr.Zero)
257             {
258                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
259             }
260             bool ret = Interop.Uint16Pair.LessThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262             return ret;
263         }
264
265         private bool GreaterThan(Uint16Pair rhs)
266         {
267             if (SwigCPtr.Handle == IntPtr.Zero)
268             {
269                 throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!");
270             }
271             bool ret = Interop.Uint16Pair.GreaterThan(SwigCPtr, Uint16Pair.getCPtr(rhs));
272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273             return ret;
274         }
275
276     }
277 }