Merge "Match the arguments type in 'max' function" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / property-value.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 #if defined(SWIGCSHARP)
19
20
21  %typemap(cscode) Dali::Property::Value %{
22
23     // Extension to property value class that allows us to create a
24     // PropertyValue from a C# object, e.g. int, float, string
25     static public Property.Value CreateFromObject( System.Object obj)
26     {
27       System.Type type = obj.GetType ();
28
29         Property.Value value;
30
31         if ( type.Equals (typeof(int)) )
32         {
33           System.Console.WriteLine (" got an int property value ");
34           value = new Property.Value ((int) obj );
35         }
36         if ( type.Equals (typeof(System.Int32)) )
37         {
38           System.Console.WriteLine (" got an int property value ");
39           value = new Property.Value ((int) obj );
40         }
41         else if ( type.Equals (typeof(bool)) )
42         {
43           System.Console.WriteLine (" got an bool property value ");
44           value = new Property.Value ((bool) obj );
45         }
46         else if ( type.Equals (typeof(float)) )
47         {
48           System.Console.WriteLine (" got an float property value ");
49           value = new Property.Value ((float) obj );
50         }
51         else if ( type.Equals (typeof(string)) )
52         {
53           System.Console.WriteLine (" got a string property value ");
54           value = new Property.Value ((string) obj );
55         }
56         else if ( type.Equals (typeof(Vector2)) )
57         {
58           System.Console.WriteLine (" got an Vector2 property value ");
59           value = new Property.Value ((Vector2) obj );
60         }
61         else if ( type.Equals (typeof(Vector3)) )
62         {
63           System.Console.WriteLine (" got an Vector3 property value ");
64           value = new Property.Value ((Vector3) obj );
65         }
66         else if ( type.Equals (typeof(Vector4)) )
67         {
68           System.Console.WriteLine (" got an Vector4 property value ");
69
70           value = new Property.Value ((Vector4) obj );
71         }
72         else if ( type.Equals (typeof(Position)) )
73         {
74           System.Console.WriteLine (" got an Position property value ");
75           value = new Property.Value ((Position) obj );
76         }
77         else if ( type.Equals (typeof(Size)) )
78         {
79           System.Console.WriteLine (" got an Size property value ");
80           value = new Property.Value ((Size) obj );
81         }
82         else if ( type.Equals (typeof(Color)) )
83         {
84           System.Console.WriteLine (" got an Color property value ");
85           value = new Property.Value ((Color) obj );
86         }
87         else
88         {
89            throw new global::System.InvalidOperationException("Unimplemented type for Property Value");
90         }
91         return  value;
92     }
93
94
95  %}
96
97
98
99
100 #endif