Merge "DALi C# binding" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / dali.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 %module(directors="1") NDalic
20 #define DALI_EXPORT_API
21 #define DALI_IMPORT_API
22 #define DALI_INTERNAL
23 #else
24 %module Dali
25 #endif
26
27 %include exception.i
28
29 %exception {
30     try {
31         $action
32     } catch (std::out_of_range& e) {
33         SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what()));
34     } catch (std::exception& e) {
35         SWIG_exception(SWIG_RuntimeError,const_cast<char*>(e.what()));
36     } catch (...) {
37         SWIG_exception(SWIG_UnknownError,"unknown error");
38     }
39 }
40
41 #if defined(SWIGCSHARP)
42 %{
43 #define SWIGSTDCALL
44 %}
45 #endif
46
47 %{
48 #include <dali/dali.h>
49 #include <dali-toolkit/dali-toolkit.h>
50
51 #include <dali/public-api/math/matrix.h>
52 #include <dali/public-api/math/matrix3.h>
53 #include <dali/public-api/math/viewport.h>
54
55
56 #include <dali/public-api/adaptor-framework/timer.h>
57 #include <dali/public-api/adaptor-framework/window.h>
58 #include <dali/public-api/adaptor-framework/style-change.h>
59 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
60
61 #include <dali-toolkit/devel-api/builder/builder.h>
62 #include <dali-toolkit/devel-api/controls/popup/popup.h>
63
64 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
65 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
66
67 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-view-declarations.h>
68
69 // add here SWIG version check
70
71 #if defined(_MSC_VER)         // Microsoft Visual C++ 6.0
72 // disable Swig-dependent warnings
73
74 // 'identifier1' has C-linkage specified,
75 // but returns UDT 'identifier2' which is incompatible with C
76 #pragma warning(disable: 4190)
77
78 // 'int' : forcing value to bool 'true' or 'false' (performance warning)
79 #pragma warning(disable: 4800)
80
81 // debug info too long etc etc
82 #pragma warning(disable: 4786)
83 #endif
84 %}
85
86 %include stl.i
87 %include exception.i
88 %include typemaps.i
89 %include std_common.i
90 %include carrays.i
91
92 %include cpointer.i
93 %pointer_class(float, floatp);
94 %pointer_class(int, intp);
95 %pointer_class(double, doublep);
96 %pointer_class(unsigned int, uintp);
97 %pointer_class(unsigned short, ushortp);
98 %pointer_cast(int, unsigned int, int_to_uint);
99
100 %apply unsigned char { uint8_t };
101 %apply unsigned short int { uint16_t };
102 %apply unsigned int { uint32_t };
103 %apply int { int32_t };
104
105 #if defined(SWIGCSHARP)
106
107 %typemap(ctype)  void * "void *"
108 %typemap(imtype) void * "System.IntPtr"
109 %typemap(cstype) void * "System.IntPtr"
110 %typemap(csin)   void * "$csinput"
111 %typemap(in)     void * %{ $1 = $input; %}
112 %typemap(out)    void * %{ $result = $1; %}
113 %typemap(csout)  void * { return $imcall; }
114
115 #endif
116
117 #if defined(SWIGCSHARP)
118
119 // string &
120 %typemap(ctype) std::string & "char**"
121 %typemap(imtype) std::string & "out string"
122 %typemap(cstype) std::string & "out string"
123
124 //C++
125 %typemap(in, canthrow=1) std::string &
126 %{
127   //typemap in
128   std::string temp;
129   $1 = &temp;
130 %}
131
132 %typemap(argout) std::string &
133 %{
134   //Typemap argout in c++ file.
135   //This will convert c++ string to c# string
136   *$input = SWIG_csharp_string_callback($1->c_str());
137 %}
138
139 %typemap(argout) const std::string &
140 %{
141   //argout typemap for const std::string&
142 %}
143
144 %typemap(csin) std::string & "out $csinput"
145
146 %typemap(throws, canthrow=1) string &
147 %{
148   SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
149   return $null;
150 %}
151
152 #endif
153
154 %ignore operator<<;
155 %ignore *::GetImplementation();
156 %ignore *::GetImplementation(Dali::BaseHandle&);
157
158 %{
159 using namespace Dali;
160 using namespace Dali::Toolkit;
161 %}
162
163 //%feature("director") Dali::Internal::CustomActorImpl;
164 //%feature("notabstract") Dali::Internal::CustomActorImpl;
165 //%feature("director") Dali::Toolkit::Internal::Control;
166 //%feature("notabstract") Dali::Toolkit::Internal::Control;
167 %feature("notabstract") Dali::Toolkit::FixedRuler;
168 %feature("notabstract") Dali::Toolkit::DefaultRuler;
169
170 // Note... all the typemap declarations have to be included before the DALi C++ head files are include otherwise
171 // they have no effect.
172
173 %include signal-parameters.i
174 %include signals.i
175 %include dali-operator.i
176 %include dali-core.i
177 %include dali-adaptor.i
178 %include dali-toolkit.i
179