Refactor dali-csharp-binder source files
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / common / version-check.cpp
1 /*
2  * Copyright (c) 2018 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 // INTERNAL INCLUDES
19 #include "common.h"
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_NativeVersionCheck(int * ver1, int * ver2, int * ver3 ) {
26   {
27     try {
28       *ver1 = Dali::CORE_MAJOR_VERSION;
29       *ver2 = Dali::CORE_MINOR_VERSION;
30       *ver3 = Dali::CORE_MICRO_VERSION;
31     } CALL_CATCH_EXCEPTION(false);
32   }
33   return true;
34 }
35
36 SWIGEXPORT bool SWIGSTDCALL CSharp_NUI_InternalAPIVersionCheck(int * version, int * reserved1, int * reserved2 )
37 {
38   try
39   {
40     if(Dali::CORE_MAJOR_VERSION == 1 && Dali::CORE_MINOR_VERSION == 2)
41     {
42       //by dali_1.2.85, nui_api_internal_version is set as 400
43       if(Dali::CORE_MICRO_VERSION <= 85)
44       {
45         *version = 400;
46         *reserved1 = 0;
47         *reserved2 = 0;
48         return true;
49       }
50       //from dali_1.2.86, nui_api_internal_version is set as 401
51       else if(Dali::CORE_MICRO_VERSION == 86)
52       {
53         *version = 401;
54         *reserved1 = 0;
55         *reserved2 = 0;
56         return true;
57       }
58       //gotten wrong native wrong version
59       else
60       {
61         *version = Dali::CORE_MAJOR_VERSION;
62         *reserved1 = Dali::CORE_MINOR_VERSION;
63         *reserved2 = Dali::CORE_MICRO_VERSION;
64         return false;
65       }
66     }
67     else if(Dali::CORE_MAJOR_VERSION == 1 && Dali::CORE_MINOR_VERSION == 3)
68     {
69       if(Dali::CORE_MICRO_VERSION <= 22)
70       {
71         //by dali_1.3.22, nui_api_internal_version is set as 500
72         *version = 500;
73         *reserved1 = 0;
74         *reserved2 = 0;
75         return true;
76       }
77       else if(Dali::CORE_MICRO_VERSION <= 27)
78       {
79         //from dali_1.3.23 to dali 1.3.27, nui_api_internal_version is set as 501
80         *version = 501;
81         *reserved1 = 0;
82         *reserved2 = 0;
83         return true;
84       }
85       else if(Dali::CORE_MICRO_VERSION <= 33)
86       {
87         //from dali_1.3.28, nui_api_internal_version is set as 502
88         *version = 502;
89         *reserved1 = 0;
90         *reserved2 = 0;
91         return true;
92       }
93       else if(Dali::CORE_MICRO_VERSION <= 40)
94       {
95         //from dali_1.3.34, nui_api_internal_version is set as 503
96         *version = 503;
97         *reserved1 = 0;
98         *reserved2 = 0;
99         return true;
100       }
101       else if(Dali::CORE_MICRO_VERSION <= 47)
102       {
103         //from dali_1.3.41, nui_api_internal_version is set as 504
104         *version = 504;
105         *reserved1 = 0;
106         *reserved2 = 0;
107         return true;
108       }
109       else if(Dali::CORE_MICRO_VERSION <= 99)
110       {
111         //from dali_1.3.48, nui_api_internal_version is set as 505
112         *version = 505;
113         *reserved1 = 0;
114         *reserved2 = 0;
115         return true;
116       }
117       else
118       {
119         *version = Dali::CORE_MAJOR_VERSION;
120         *reserved1 = Dali::CORE_MINOR_VERSION;
121         *reserved2 = Dali::CORE_MICRO_VERSION;
122         return false;
123       }
124     }
125     //something wrong
126     else
127     {
128       *version = Dali::CORE_MAJOR_VERSION;
129       *reserved1 = Dali::CORE_MINOR_VERSION;
130       *reserved2 = Dali::CORE_MICRO_VERSION;
131       return false;
132     }
133   }
134   CALL_CATCH_EXCEPTION(false);
135   return false;
136 }
137
138 #ifdef __cplusplus
139 }
140 #endif
141