2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 // common name mappings
19 #if defined(SWIGCSHARP)
20 %rename(Assign) operator=;
21 %rename(Add) operator+;
22 %rename(AddAssign) operator+=;
23 %rename(Subtract) operator-;
24 %rename(SubtractAssign) operator-=;
25 %rename(Multiply) operator*;
26 %rename(MultiplyAssign) operator*=;
27 %rename(Divide) operator/;
28 %rename(DivideAssign) operator/=;
29 %rename(Assign) operator=;
30 %rename(EqualTo) operator==;
31 %rename(NotEqualTo) operator!=;
32 %rename(LessThan) operator<;
33 %rename(GreaterThan) operator>;
34 %rename(ValueOfIndex) operator[];
37 %typemap(cscode) Dali::Vector2 %{
38 public static Vector2 operator+(Vector2 arg1, Vector2 arg2) {
39 return arg1.Add(arg2);
42 public static Vector2 operator-(Vector2 arg1, Vector2 arg2) {
43 return arg1.Subtract(arg2);
46 public static Vector2 operator-(Vector2 arg1) {
47 return arg1.Subtract();
50 public static Vector2 operator*(Vector2 arg1, Vector2 arg2) {
51 return arg1.Multiply(arg2);
54 public static Vector2 operator*(Vector2 arg1, float arg2) {
55 return arg1.Multiply(arg2);
58 public static Vector2 operator/(Vector2 arg1, Vector2 arg2) {
59 return arg1.Divide(arg2);
62 public static Vector2 operator/(Vector2 arg1, float arg2) {
63 return arg1.Divide(arg2);
66 public float this[uint index]
70 return ValueOfIndex(index);
74 public static Vector2 GetVector2FromPtr(global::System.IntPtr cPtr) {
75 Vector2 ret = new Vector2(cPtr, false);
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82 %typemap(cscode) Dali::Vector3 %{
83 public static Vector3 operator+(Vector3 arg1, Vector3 arg2) {
84 return arg1.Add(arg2);
87 public static Vector3 operator-(Vector3 arg1, Vector3 arg2) {
88 return arg1.Subtract(arg2);
91 public static Vector3 operator-(Vector3 arg1) {
92 return arg1.Subtract();
95 public static Vector3 operator*(Vector3 arg1, Vector3 arg2) {
96 return arg1.Multiply(arg2);
99 public static Vector3 operator*(Vector3 arg1, float arg2) {
100 return arg1.Multiply(arg2);
103 public static Vector3 operator/(Vector3 arg1, Vector3 arg2) {
104 return arg1.Divide(arg2);
107 public static Vector3 operator/(Vector3 arg1, float arg2) {
108 return arg1.Divide(arg2);
111 public float this[uint index]
115 return ValueOfIndex(index);
119 public static Vector3 GetVector3FromPtr(global::System.IntPtr cPtr) {
120 Vector3 ret = new Vector3(cPtr, false);
121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 %typemap(cscode) Dali::Vector4 %{
128 public static Vector4 operator+(Vector4 arg1, Vector4 arg2) {
129 return arg1.Add(arg2);
132 public static Vector4 operator-(Vector4 arg1, Vector4 arg2) {
133 return arg1.Subtract(arg2);
136 public static Vector4 operator-(Vector4 arg1) {
137 return arg1.Subtract();
140 public static Vector4 operator*(Vector4 arg1, Vector4 arg2) {
141 return arg1.Multiply(arg2);
144 public static Vector4 operator*(Vector4 arg1, float arg2) {
145 return arg1.Multiply(arg2);
148 public static Vector4 operator/(Vector4 arg1, Vector4 arg2) {
149 return arg1.Divide(arg2);
152 public static Vector4 operator/(Vector4 arg1, float arg2) {
153 return arg1.Divide(arg2);
156 public float this[uint index]
160 return ValueOfIndex(index);
164 public static Vector4 GetVector4FromPtr(global::System.IntPtr cPtr) {
165 Vector4 ret = new Vector4(cPtr, false);
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 %typemap(cscode) Dali::Matrix %{
173 public static Vector4 operator*(Matrix arg1, Vector4 arg2) {
174 return arg1.Multiply(arg2);
178 %typemap(cscode) Dali::Quaternion %{
179 public static Quaternion operator+(Quaternion arg1, Quaternion arg2) {
180 return arg1.Add(arg2);
183 public static Quaternion operator-(Quaternion arg1, Quaternion arg2) {
184 return arg1.Subtract(arg2);
187 public static Quaternion operator-(Quaternion arg1) {
188 return arg1.Subtract();
191 public static Quaternion operator*(Quaternion arg1, Quaternion arg2) {
192 return arg1.Multiply(arg2);
195 public static Vector3 operator*(Quaternion arg1, Vector3 arg2) {
196 return arg1.Multiply(arg2);
199 public static Quaternion operator*(Quaternion arg1, float arg2) {
200 return arg1.Multiply(arg2);
203 public static Quaternion operator/(Quaternion arg1, Quaternion arg2) {
204 return arg1.Divide(arg2);
207 public static Quaternion operator/(Quaternion arg1, float arg2) {
208 return arg1.Divide(arg2);
212 %typemap(cscode) Dali::Property::Array %{
213 public Property.Value this[uint index]
217 return ValueOfIndex(index);
222 %typemap(cscode) Dali::Property::Map %{
223 public Property.Value this[string key]
227 return ValueOfIndex(key);
231 public Property.Value this[int key]
235 return ValueOfIndex(key);
240 %typemap(cscode) Dali::Uint16Pair %{
241 public static bool operator<(Uint16Pair arg1, Uint16Pair arg2) {
242 return arg1.LessThan(arg2);
245 public static bool operator>(Uint16Pair arg1, Uint16Pair arg2) {
246 return arg1.GreaterThan(arg2);
251 * Extend the C++ base handle to include a IsHandleEmpty() function
252 * This is because from C# we can't wrap the operator BooleanType() function
254 %extend Dali::BaseHandle {
255 bool HasBody() const {
257 // C++ code. DALi uses Handle <-> Body design pattern.
258 // This function checks the Handle to see if it has a body attached ( possible to have empty handles).
259 // Handles in DALi can be converted into a boolean type
260 // to check if the handle has a valid body attached to it.
261 // Internally checking *$self will checks IntrusivePtr<Dali::RefObject> mObjectHandle in BaseHandle;
272 // Check if two handles point to the same body / ref-object.
273 bool IsEqual( const BaseHandle& rhs ) const {
275 // C++ code. Check if two handles reference the same implemtion
289 * Extend C# base handle to support true / false testing of base handle
296 %typemap(cscode) Dali::BaseHandle %{
298 // Returns the bool value true to indicate that an operand is true and returns false otherwise.
299 public static bool operator true(BaseHandle handle)
301 // if the C# object is null, return false
302 if( BaseHandle.ReferenceEquals( handle, null ) )
306 // returns true if the handle has a body, false otherwise
307 return handle.HasBody();
310 // Returns the bool false to indicate that an operand is false and returns true otherwise.
311 public static bool operator false(BaseHandle handle)
313 // if the C# object is null, return true
314 if( BaseHandle.ReferenceEquals( handle, null ) )
318 return !handle.HasBody();
321 // Explicit conversion from Handle to bool.
322 public static explicit operator bool(BaseHandle handle)
324 // if the C# object is null, return false
325 if( BaseHandle.ReferenceEquals( handle, null ) )
329 // returns true if the handle has a body, false otherwise
330 return handle.HasBody();
334 public static bool operator == (BaseHandle x, BaseHandle y)
336 // if the C# objects are the same return true
337 if( BaseHandle.ReferenceEquals( x, y ) )
341 if ( !BaseHandle.ReferenceEquals( x, null ) && !BaseHandle.ReferenceEquals( y, null ) )
343 // drop into native code to see if both handles point to the same body
344 return x.IsEqual( y) ;
350 // Inequality operator. Returns Null if either operand is Null
351 public static bool operator !=(BaseHandle x, BaseHandle y)
356 // Logical AND operator for &&
357 // It's possible when doing a && this function (opBitwiseAnd) is never called due
358 // to short circuiting. E.g.
359 // If you perform x && y What actually is called is
360 // BaseHandle.op_False( x ) ? BaseHandle.op_True( x ) : BaseHandle.opTrue( BaseHandle.opBitwiseAnd(x,y) )
362 public static BaseHandle operator &(BaseHandle x, BaseHandle y)
371 // Logical OR operator for ||
372 // It's possible when doing a || this function (opBitwiseOr) is never called due
373 // to short circuiting. E.g.
374 // If you perform x || y What actually is called is
375 // BaseHandle.op_True( x ) ? BaseHandle.op_True( x ) : BaseHandle.opTrue( BaseHandle.opBitwiseOr(x,y) )
376 public static BaseHandle operator |(BaseHandle x, BaseHandle y)
378 if ( !BaseHandle.ReferenceEquals( x, null ) || !BaseHandle.ReferenceEquals( y, null ) )
393 // Logical ! operator
394 public static bool operator !(BaseHandle x)
396 // if the C# object is null, return true
397 if( BaseHandle.ReferenceEquals( x, null ) )