Merge "DALi C# binding" into devel/master
[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
75 %typemap(cscode) Dali::Vector3 %{
76   public static Vector3 operator+(Vector3 arg1, Vector3 arg2) {
77     return arg1.Add(arg2);
78   }
79   
80   public static Vector3 operator-(Vector3 arg1, Vector3 arg2) {
81     return arg1.Subtract(arg2);
82   }
83
84   public static Vector3 operator-(Vector3 arg1) {
85     return arg1.Subtract();
86   }
87
88   public static Vector3 operator*(Vector3 arg1, Vector3 arg2) {
89     return arg1.Multiply(arg2);
90   }
91
92   public static Vector3 operator*(Vector3 arg1, float arg2) {
93     return arg1.Multiply(arg2);
94   }
95
96   public static Vector3 operator/(Vector3 arg1, Vector3 arg2) {
97     return arg1.Divide(arg2);
98   }
99
100   public static Vector3 operator/(Vector3 arg1, float arg2) {
101     return arg1.Divide(arg2);
102   }
103
104   public float this[uint index]
105   {
106     get
107     {
108       return ValueOfIndex(index);
109     }
110   }
111 %}
112
113 %typemap(cscode) Dali::Vector4 %{
114   public static Vector4 operator+(Vector4 arg1, Vector4 arg2) {
115     return arg1.Add(arg2);
116   }
117   
118   public static Vector4 operator-(Vector4 arg1, Vector4 arg2) {
119     return arg1.Subtract(arg2);
120   }
121
122   public static Vector4 operator-(Vector4 arg1) {
123     return arg1.Subtract();
124   }
125
126   public static Vector4 operator*(Vector4 arg1, Vector4 arg2) {
127     return arg1.Multiply(arg2);
128   }
129
130   public static Vector4 operator*(Vector4 arg1, float arg2) {
131     return arg1.Multiply(arg2);
132   }
133
134   public static Vector4 operator/(Vector4 arg1, Vector4 arg2) {
135     return arg1.Divide(arg2);
136   }
137
138   public static Vector4 operator/(Vector4 arg1, float arg2) {
139     return arg1.Divide(arg2);
140   }
141
142   public float this[uint index]
143   {
144     get
145     {
146       return ValueOfIndex(index);
147     }
148   }
149 %}
150
151 %typemap(cscode) Dali::Matrix %{
152   public static Vector4 operator*(Matrix arg1, Vector4 arg2) {
153     return arg1.Multiply(arg2);
154   }
155 %}
156
157 %typemap(cscode) Dali::Quaternion %{
158   public static Quaternion operator+(Quaternion arg1, Quaternion arg2) {
159     return arg1.Add(arg2);
160   }
161   
162   public static Quaternion operator-(Quaternion arg1, Quaternion arg2) {
163     return arg1.Subtract(arg2);
164   }
165
166   public static Quaternion operator-(Quaternion arg1) {
167     return arg1.Subtract();
168   }
169
170   public static Quaternion operator*(Quaternion arg1, Quaternion arg2) {
171     return arg1.Multiply(arg2);
172   }
173
174   public static Vector3 operator*(Quaternion arg1, Vector3 arg2) {
175     return arg1.Multiply(arg2);
176   }
177
178   public static Quaternion operator*(Quaternion arg1, float arg2) {
179     return arg1.Multiply(arg2);
180   }
181
182   public static Quaternion operator/(Quaternion arg1, Quaternion arg2) {
183     return arg1.Divide(arg2);
184   }
185
186   public static Quaternion operator/(Quaternion arg1, float arg2) {
187     return arg1.Divide(arg2);
188   }
189 %}
190
191 %typemap(cscode) Dali::Property::Array %{
192   public Property.Value this[uint index]
193   {
194     get
195     {
196       return ValueOfIndex(index);
197     }
198   }
199 %}
200
201 %typemap(cscode) Dali::Property::Map %{
202   public Property.Value this[string key]
203   {
204     get
205     {
206       return ValueOfIndex(key);
207     }
208   }
209
210   public Property.Value this[int key]
211   {
212     get
213     {
214       return ValueOfIndex(key);
215     }
216   }
217 %}
218
219 %typemap(cscode) Dali::Uint16Pair %{
220   public static bool operator<(Uint16Pair arg1, Uint16Pair arg2) {
221     return arg1.LessThan(arg2);
222   }
223   
224   public static bool operator>(Uint16Pair arg1, Uint16Pair arg2) {
225     return arg1.GreaterThan(arg2);
226   }
227  
228 %}
229
230 /**
231  * Extend the C++ base handle to include  a IsHandleEmpty() function
232  * This is because from C# we can't wrap the operator BooleanType() function
233  */
234 %extend Dali::BaseHandle {
235    bool IsHandleEmpty() const {
236      if( *$self )
237      {
238        return true;
239      }
240      else
241      {
242        return false;
243      }
244     }
245 };
246
247 /**
248  * Extend C# base handle to support true / false testing of base handle
249  * so we can do
250  *  if ( actor )
251  *  {
252  *    ...
253  *  }
254  */
255 %typemap(cscode) Dali::BaseHandle %{
256
257  public static bool operator true(BaseHandle  handle)
258  {
259    if( handle!= null  )
260    {
261      return  handle.IsHandleEmpty();
262    }
263    else
264    {
265      return false;
266    }
267  }
268  public static bool operator false(BaseHandle  handle)
269  {
270    return  handle.IsHandleEmpty();
271  }
272 %}
273
274