Fixed SWIG interface files for modified DALi header files
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / dali-operator.i
1 /*
2  * Copyright (c) 2016 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 // 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[];
35 #endif
36
37 %typemap(cscode) Dali::Vector2 %{
38   public static Vector2 operator+(Vector2 arg1, Vector2 arg2) {
39     return arg1.Add(arg2);
40   }
41
42   public static Vector2 operator-(Vector2 arg1, Vector2 arg2) {
43     return arg1.Subtract(arg2);
44   }
45
46   public static Vector2 operator-(Vector2 arg1) {
47     return arg1.Subtract();
48   }
49
50   public static Vector2 operator*(Vector2 arg1, Vector2 arg2) {
51     return arg1.Multiply(arg2);
52   }
53
54   public static Vector2 operator*(Vector2 arg1, float arg2) {
55     return arg1.Multiply(arg2);
56   }
57
58   public static Vector2 operator/(Vector2 arg1, Vector2 arg2) {
59     return arg1.Divide(arg2);
60   }
61
62   public static Vector2 operator/(Vector2 arg1, float arg2) {
63     return arg1.Divide(arg2);
64   }
65
66   public float this[uint index]
67   {
68     get
69     {
70       return ValueOfIndex(index);
71     }
72   }
73
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();
77        return ret;
78   }
79
80 %}
81
82 %typemap(cscode) Dali::Vector3 %{
83   public static Vector3 operator+(Vector3 arg1, Vector3 arg2) {
84     return arg1.Add(arg2);
85   }
86
87   public static Vector3 operator-(Vector3 arg1, Vector3 arg2) {
88     return arg1.Subtract(arg2);
89   }
90
91   public static Vector3 operator-(Vector3 arg1) {
92     return arg1.Subtract();
93   }
94
95   public static Vector3 operator*(Vector3 arg1, Vector3 arg2) {
96     return arg1.Multiply(arg2);
97   }
98
99   public static Vector3 operator*(Vector3 arg1, float arg2) {
100     return arg1.Multiply(arg2);
101   }
102
103   public static Vector3 operator/(Vector3 arg1, Vector3 arg2) {
104     return arg1.Divide(arg2);
105   }
106
107   public static Vector3 operator/(Vector3 arg1, float arg2) {
108     return arg1.Divide(arg2);
109   }
110
111   public float this[uint index]
112   {
113     get
114     {
115       return ValueOfIndex(index);
116     }
117   }
118
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();
122        return ret;
123   }
124
125 %}
126
127 %typemap(cscode) Dali::Vector4 %{
128   public static Vector4 operator+(Vector4 arg1, Vector4 arg2) {
129     return arg1.Add(arg2);
130   }
131
132   public static Vector4 operator-(Vector4 arg1, Vector4 arg2) {
133     return arg1.Subtract(arg2);
134   }
135
136   public static Vector4 operator-(Vector4 arg1) {
137     return arg1.Subtract();
138   }
139
140   public static Vector4 operator*(Vector4 arg1, Vector4 arg2) {
141     return arg1.Multiply(arg2);
142   }
143
144   public static Vector4 operator*(Vector4 arg1, float arg2) {
145     return arg1.Multiply(arg2);
146   }
147
148   public static Vector4 operator/(Vector4 arg1, Vector4 arg2) {
149     return arg1.Divide(arg2);
150   }
151
152   public static Vector4 operator/(Vector4 arg1, float arg2) {
153     return arg1.Divide(arg2);
154   }
155
156   public float this[uint index]
157   {
158     get
159     {
160       return ValueOfIndex(index);
161     }
162   }
163
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();
167        return ret;
168   }
169
170 %}
171
172 %typemap(cscode) Dali::Matrix %{
173   public static Vector4 operator*(Matrix arg1, Vector4 arg2) {
174     return arg1.Multiply(arg2);
175   }
176 %}
177
178 %typemap(cscode) Dali::Quaternion %{
179   public static Quaternion operator+(Quaternion arg1, Quaternion arg2) {
180     return arg1.Add(arg2);
181   }
182
183   public static Quaternion operator-(Quaternion arg1, Quaternion arg2) {
184     return arg1.Subtract(arg2);
185   }
186
187   public static Quaternion operator-(Quaternion arg1) {
188     return arg1.Subtract();
189   }
190
191   public static Quaternion operator*(Quaternion arg1, Quaternion arg2) {
192     return arg1.Multiply(arg2);
193   }
194
195   public static Vector3 operator*(Quaternion arg1, Vector3 arg2) {
196     return arg1.Multiply(arg2);
197   }
198
199   public static Quaternion operator*(Quaternion arg1, float arg2) {
200     return arg1.Multiply(arg2);
201   }
202
203   public static Quaternion operator/(Quaternion arg1, Quaternion arg2) {
204     return arg1.Divide(arg2);
205   }
206
207   public static Quaternion operator/(Quaternion arg1, float arg2) {
208     return arg1.Divide(arg2);
209   }
210 %}
211
212 %typemap(cscode) Dali::Property::Array %{
213   public Property.Value this[uint index]
214   {
215     get
216     {
217       return ValueOfIndex(index);
218     }
219   }
220 %}
221
222 %typemap(cscode) Dali::Property::Map %{
223   public Property.Value this[string key]
224   {
225     get
226     {
227       return ValueOfIndex(key);
228     }
229   }
230
231   public Property.Value this[int key]
232   {
233     get
234     {
235       return ValueOfIndex(key);
236     }
237   }
238 %}
239
240 %typemap(cscode) Dali::Uint16Pair %{
241   public static bool operator<(Uint16Pair arg1, Uint16Pair arg2) {
242     return arg1.LessThan(arg2);
243   }
244
245   public static bool operator>(Uint16Pair arg1, Uint16Pair arg2) {
246     return arg1.GreaterThan(arg2);
247   }
248 %}
249
250 /**
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
253  */
254 %extend Dali::BaseHandle {
255    bool IsHandleEmpty() const {
256      if( *$self )
257      {
258        return true;
259      }
260      else
261      {
262        return false;
263      }
264     }
265 };
266
267 /**
268  * Extend C# base handle to support true / false testing of base handle
269  * so we can do
270  *  if ( actor )
271  *  {
272  *    ...
273  *  }
274  */
275 %typemap(cscode) Dali::BaseHandle %{
276
277  public static bool operator true(BaseHandle  handle)
278  {
279    if( handle!= null  )
280    {
281      return  handle.IsHandleEmpty();
282    }
283    else
284    {
285      return false;
286    }
287  }
288  public static bool operator false(BaseHandle  handle)
289  {
290    return  handle.IsHandleEmpty();
291  }
292 %}
293
294