Merge "Implement wayland clipboard & same behaviour as EFL clipboard" into devel...
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / signals.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 // Example from Swig CSHARP documentation
19 // To allow a CDate class to take
20 // To achieve this mapping, we need to alter the default code generation slightly so that at the C# layer, a System.DateTime is converted into a CDate. The
21 // intermediary layer will still take a pointer to the underlying CDate class. The typemaps to achieve this are shown below.
22
23 // %typemap(cstype) const CDate & "System.DateTime"
24 // %typemap(csin,
25 // pre="
26 // CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
27 // ) const CDate &
28 // "$csclassname.getCPtr(temp$csinput)"
29 // The csin typemap is used for converting function parameter types from the type
30 // used in the proxy, module or type wrapper class to the type used in the PInvoke class.
31
32
33 %include <dali/public-api/signals/dali-signal.h>
34
35 /*
36  * By default SWIG maps Derived types, structs, and classes to C pointers.
37  * So for Signals which have a Connect /Disconnect function, the function parameter just gets maps to a C pointer.
38  * However, call backs in C# are done using delegates, so we change the Connect / Disconnect parameter from
39  * something like  void (*func)( Dali::Actor ) to a C# delegate.
40  * the parameter type is changed using the typemap(cstype)  cstype = csharp-type
41  * The actual conversion from a C# delegate to a c function pointer is done when Connect/Disconnect is called
42  * using  typemap(csin) with GetFunctionPointerForDelegate ( csin = csharp in code?).
43  * So when connect is called on a Signal it will call the   void Signal::Connect( void (*func)( Arg0 arg0 ) ) -- which
44  * just takes a standard C function pointer. Not ideal as there is no delegate / connection tracking.
45  *
46  */
47 %define SIGNAL_TYPEMAP_HELPER( SignalSignature )
48 %typemap(cstype) SignalSignature "System.Delegate"
49 %typemap(csin, pre ="System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate($csinput); ")
50    SignalSignature "new System.Runtime.InteropServices.HandleRef(this, ip)"
51 %enddef
52
53 /**
54  * SWIG can't auto generate wrappers for template parameters that are functions ( which dali-signal has)
55  * so we have make them ourselves
56  */
57
58 %define SIGNAL_TEMPLATE_HELPER_1( returnType,  returnFunc, argumentType )
59   template<> class Signal< returnType ( argumentType ) >
60   {
61   public:
62     %extend
63     {
64       bool Empty() const
65       {
66          return $self->Empty();
67       }
68       std::size_t GetConnectionCount() const
69       {
70         return $self->GetConnectionCount();
71       }
72       void Connect( returnType ( *func ) (  argumentType  ) )
73       {
74           $self->Connect( func );
75       }
76       void Disconnect( returnType ( *func ) (  argumentType  ) )
77       {
78           $self->Disconnect( func );
79       }
80       returnType Emit( argumentType arg)
81       {
82           returnFunc $self->Emit( arg );
83       }
84     }
85   };
86 %enddef
87
88 %define SIGNAL_TEMPLATE_HELPER_2( returnType,  returnFunc, argumentType1, argumentType2 )
89   template<> class Signal< returnType (  argumentType1, argumentType2 ) >
90   {
91   public:
92     %extend
93     {
94       bool Empty() const
95       {
96          return $self->Empty();
97       }
98       std::size_t GetConnectionCount() const
99       {
100         return $self->GetConnectionCount();
101       }
102       void Connect( returnType ( *func ) (  argumentType1, argumentType2   ) )
103       {
104         $self->Connect( func );
105       }
106       void Disconnect( returnType ( *func ) (  argumentType1, argumentType2  ) )
107       {
108         $self->Disconnect( func );
109       }
110       returnType Emit( argumentType1 arg1, argumentType2 arg2 )
111       {
112         returnFunc $self->Emit( arg1, arg2 );
113       }
114     }
115   };
116 %enddef
117
118 %define SIGNAL_TEMPLATE_HELPER_3( returnType, returnFunc, argumentType1, argumentType2, argumentType3 )
119   template<> class Signal< returnType ( argumentType1, argumentType2, argumentType3 ) >
120   {
121   public:
122     %extend
123     {
124       bool Empty() const
125       {
126          return $self->Empty();
127       }
128       std::size_t GetConnectionCount() const
129       {
130         return $self->GetConnectionCount();
131       }
132       void Connect( returnType ( *func ) ( argumentType1, argumentType2, argumentType3  ) )
133       {
134           return $self->Connect( func );
135       }
136       void Disconnect( returnType ( *func ) ( argumentType1, argumentType2, argumentType3  ) )
137       {
138           $self->Disconnect( func );
139       }
140       returnType Emit( argumentType1 arg1, argumentType2 arg2, argumentType3 arg3 )
141       {
142           returnFunc $self->Emit( arg1, arg2, arg3 );
143       }
144     }
145   };
146 %enddef
147
148 ////////////////////////////////
149 /*****************
150  Macros for signals  without return values
151 *****************/
152
153 // the emit for some signal has to emit a return value
154 // this macro is just for signals that don't (instead of return Emit();.. it just does ;Emit();
155 %define NO_RETURN_FUNC;
156 %enddef
157
158 // Macro to define a csharp signal.
159 // 1 param signals ( no return )
160 %define DALI_SIGNAL_1_PARAM( argumentType1 )
161
162   SIGNAL_TYPEMAP_HELPER( void (*func) ( argumentType1 ) );
163   SIGNAL_TEMPLATE_HELPER_1( void, NO_RETURN_FUNC, argumentType1);
164 %enddef
165
166 // 2 param signals ( no return )
167 %define DALI_SIGNAL_2_PARAM( argumentType1, argumentType2)
168
169   SIGNAL_TYPEMAP_HELPER( void (*func) ( argumentType1, argumentType2) );
170   SIGNAL_TEMPLATE_HELPER_2( void, NO_RETURN_FUNC, argumentType1, argumentType2);
171
172 %enddef
173
174 // 3 param signals ( no return )
175 %define DALI_SIGNAL_3_PARAM( argumentType1, argumentType2, argumentType3 )
176
177   SIGNAL_TYPEMAP_HELPER( void (*func) ( argumentType1, argumentType2, argumentType3 ) );
178   SIGNAL_TEMPLATE_HELPER_3( void, NO_RETURN_FUNC, argumentType1, argumentType2, argumentType3);
179
180 %enddef
181
182 /*****************
183  Macros for signals with return values
184 *****************/
185
186 // 1 param signals ( with return )
187 %define DALI_SIGNAL_1_PARAM_RETURN( returnType, argumentType1 )
188
189   SIGNAL_TYPEMAP_HELPER( returnType (*func) ( argumentType1 ) );
190   SIGNAL_TEMPLATE_HELPER_1( returnType, return, argumentType1);
191
192 %enddef
193
194 // 2 param signals ( with return )
195 %define DALI_SIGNAL_2_PARAM_RETURN( returnType, argumentType1, argumentType2)
196
197   SIGNAL_TYPEMAP_HELPER( returnType (*func) ( argumentType1, argumentType2) );
198   SIGNAL_TEMPLATE_HELPER_2( returnType, return, argumentType1, argumentType2);
199
200 %enddef
201
202 // 3 param signals ( with return )
203 %define DALI_SIGNAL_3_PARAM_RETURN( returnType, argumentType1, argumentType2, argumentType3 )
204
205   SIGNAL_TYPEMAP_HELPER( returnType (*func) ( argumentType1, argumentType2, argumentType3 ) );
206   SIGNAL_TEMPLATE_HELPER_3( returnType, return, argumentType1, argumentType2, argumentType3);
207
208 %enddef
209
210 namespace Dali
211 {
212 // Signal< void (Actor) >
213 DALI_SIGNAL_1_PARAM( Dali::Actor );
214
215 //  Signal< void (float) >
216 DALI_SIGNAL_1_PARAM( float );
217
218 // Signal< void (Dali::Application&) >
219 DALI_SIGNAL_1_PARAM( Dali::Application& );
220
221 // Signal< void (Dali::Application&, void*) >
222 DALI_SIGNAL_2_PARAM( Dali::Application& , void* );
223
224 // Signal< void (Dali::Image) >
225 DALI_SIGNAL_1_PARAM( Dali::Image );
226
227 // Signal< void (Dali::ResourceImage) >
228 DALI_SIGNAL_1_PARAM( Dali::ResourceImage );
229
230 // Signal< void (Dali::Animation&) >
231 DALI_SIGNAL_1_PARAM( Dali::Animation& );
232
233 // Signal< void (Dali::Actor, const Dali::TouchEvent&) >
234 DALI_SIGNAL_2_PARAM( Dali::Actor, const Dali::TouchEvent& );
235
236 //  Signal< bool (Dali::Actor, const Dali::TouchData&) >
237 DALI_SIGNAL_2_PARAM_RETURN( bool, Dali::Actor, const Dali::TouchData& );
238
239 // Signal< bool (Dali::Actor, const Dali::HoverEvent&) >
240 DALI_SIGNAL_2_PARAM_RETURN( bool , Dali::Actor, const Dali::HoverEvent& );
241
242 // Signal< bool (Dali::Actor, const Dali::WheelEvent&) >
243 DALI_SIGNAL_2_PARAM_RETURN( bool , Dali::Actor, const Dali::WheelEvent& );
244
245 // Signal< void (const Dali::KeyEvent&) >
246 DALI_SIGNAL_1_PARAM( const Dali::KeyEvent&  );
247
248 // Signal< void (const Dali::TouchData&) >
249 DALI_SIGNAL_1_PARAM( const Dali::TouchData& );
250
251 // Signal< void (const Dali::HoverEvent&) >
252 DALI_SIGNAL_1_PARAM( const Dali::HoverEvent& );
253
254 // Signal< void (const Dali::WheelEvent&) >
255 DALI_SIGNAL_1_PARAM( const Dali::WheelEvent& );
256
257 // Signal< void (const Dali::LongPressGesture&) >
258 DALI_SIGNAL_2_PARAM( Dali::Actor, const Dali::LongPressGesture& );
259
260 // Signal< void (Dali::Actor, const Dali::PanGesture&) >
261 DALI_SIGNAL_2_PARAM( Dali::Actor, const Dali::PanGesture& );
262
263 // Signal< void (Dali::Actor, const Dali::PinchGesture&) >
264 DALI_SIGNAL_2_PARAM( Dali::Actor, const Dali::PinchGesture& );
265
266 // Signal< void (Dali::Actor, const Dali::TapGesture&) >
267 DALI_SIGNAL_2_PARAM( Dali::Actor, const Dali::TapGesture& );
268
269 // Signal< void (Dali::PropertyNotification) >
270 DALI_SIGNAL_1_PARAM( Dali::PropertyNotification& ) ;
271
272 //  Signal< void (Dali::BaseHandle) >
273 DALI_SIGNAL_1_PARAM( Dali::BaseHandle );
274
275 //  Signal< void (const Dali::RefObject*) >
276 DALI_SIGNAL_1_PARAM( const Dali::RefObject* );
277
278 // Signal< void (const Dali::RenderTask&) >
279 DALI_SIGNAL_1_PARAM( const Dali::RenderTask& );
280
281 // Signal< bool ( const Dali::Toolkit::AccessibilityManager& ) >
282 DALI_SIGNAL_1_PARAM_RETURN( bool ,const Dali::Toolkit::AccessibilityManager& );
283
284 // Signal< bool ( const Dali::Toolkit::AccessibilityManager&, const Dali::TouchEvent& ) >
285 DALI_SIGNAL_2_PARAM_RETURN( bool ,const Dali::Toolkit::AccessibilityManager&, const Dali::TouchEvent& );
286
287 // Signal< void ( const Dali::Actor Dali::Toolkit::AccessibilityManager::FocusOvershotDirection ) >
288 DALI_SIGNAL_2_PARAM( Dali::Actor, Dali::Toolkit::AccessibilityManager::FocusOvershotDirection );
289
290 // Signal< bool ( Dali::Toolkit::AccessibilityManager&, const Dali::TouchEvent& ) >
291 DALI_SIGNAL_2_PARAM_RETURN( bool ,Dali::Toolkit::AccessibilityManager&, const Dali::TouchEvent&);
292
293 // Signal< void ( Dali::Actor, Dali::Toolkit::AccessibilityManager::FocusOvershotDirection) >
294 //DALI_SIGNAL_2_PARAM( Dali::Actor, Dali::Toolkit::AccessibilityManager::FocusOvershotDirection );
295
296 // Signal< void (  Dali::Toolkit::StyleManager, Dali::StyleChange::Type) >
297 DALI_SIGNAL_2_PARAM( Dali::Toolkit::StyleManager, Dali::StyleChange::Type);
298
299 // Signal< void (  Dali::Actor, Dali::Toolkit::AccessibilityManager::FocusOvershotDirection )>
300 //DALI_SIGNAL_2_PARAM( Dali::Actor, Dali::Toolkit::AccessibilityManager::FocusOvershotDirection );
301
302 // Signal<  Dali::Actor (  Dali::Actor, Dali::Actor, Dali::Actor, Dali::Toolkit::Control::KeyboardFocus::Direction) >
303 DALI_SIGNAL_3_PARAM_RETURN( Dali::Actor, Dali::Actor, Dali::Actor, Dali::Toolkit::Control::KeyboardFocus::Direction);
304
305 // void Signal<  Dali::Actor, bool >;
306 DALI_SIGNAL_2_PARAM( Dali::Actor, bool);
307
308 // bool Signal< Dali::Toolkit::Button >;
309 DALI_SIGNAL_1_PARAM_RETURN( bool, Dali::Toolkit::Button);
310
311 // void Signal< Dali::Toolkit::GaussianBlurView >;
312 DALI_SIGNAL_1_PARAM( Dali::Toolkit::GaussianBlurView);
313
314 // void Signal< Dali::Toolkit::PageTurnView, unsigned int, bool >;
315 DALI_SIGNAL_3_PARAM( Dali::Toolkit::PageTurnView, unsigned int, bool );
316
317 // void Signal< Dali::Toolkit::PageTurnView >;
318 DALI_SIGNAL_1_PARAM( Dali::Toolkit::PageTurnView );
319
320 // void Signal< const Dali::Toolkit::ScrollView::SnapEvent& >;
321 DALI_SIGNAL_1_PARAM( const Dali::Toolkit::ScrollView::SnapEvent& );
322
323 // void Signal< const Dali::Vector2& >;
324 DALI_SIGNAL_1_PARAM( const Dali::Vector2& );
325
326 // void Signal< Dali::Toolkit::TextEditor >;
327 DALI_SIGNAL_1_PARAM( Dali::Toolkit::TextEditor );
328
329 // void Signal< Dali::Toolkit::TextField >;
330 DALI_SIGNAL_1_PARAM( Dali::Toolkit::TextField )
331
332 // bool Signal< Dali::Toolkit::Control, const Dali::KeyEvent& >;
333 DALI_SIGNAL_2_PARAM_RETURN( bool, Dali::Toolkit::Control, const Dali::KeyEvent& );
334
335 // void Signal< Dali::Toolkit::Control >;
336 DALI_SIGNAL_1_PARAM( Dali::Toolkit::Control );
337
338 // void Signal< Dali::Toolkit::VideoView& >;
339 DALI_SIGNAL_1_PARAM( Dali::Toolkit::VideoView& );
340
341 // Signal< bool (Dali::Toolkit::Slider, float) >;
342 DALI_SIGNAL_2_PARAM_RETURN( bool,Dali::Toolkit::Slider, float );
343
344 //  Signal< bool(Dali::Toolkit::Slider, int) >;
345 DALI_SIGNAL_2_PARAM_RETURN( bool,Dali::Toolkit::Slider, int );
346
347 } // namespace DALi
348
349