|
1 /******************************************************************************* |
|
2 * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - initial implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 #ifndef _SWT_H_ |
|
13 #define _SWT_H_ |
|
14 |
|
15 #include "swterror.h" |
|
16 |
|
17 // Pointer-handle conversion macros |
|
18 |
|
19 #define POINTER_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QObject*>(pointer)) |
|
20 #define HANDLE_TO_POINTER(type, variable, handle) type variable = qobject_cast<type>(static_cast<type>(reinterpret_cast<QObject*>( handle ))) |
|
21 |
|
22 #define QCOLOR_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QColor*>(pointer)) |
|
23 #define HANDLE_TO_QCOLOR(variable, handle) QColor* variable = static_cast<QColor*>(reinterpret_cast<QColor*>( handle )) |
|
24 |
|
25 #define QTABLEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QTableWidgetItem*>(pointer)) |
|
26 #define HANDLE_TO_QTABLEWIDGETITEM(variable, handle) QTableWidgetItem* variable = static_cast<QTableWidgetItem*>(reinterpret_cast<QTableWidgetItem*>( handle )) |
|
27 #define QTREEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast<jint>(static_cast<QTreeWidgetItem*>(pointer)) |
|
28 #define HANDLE_TO_QTREEWIDGETITEM(variable, handle) QTreeWidgetItem* variable = static_cast<QTreeWidgetItem*>(reinterpret_cast<QTreeWidgetItem*>( handle )) |
|
29 |
|
30 // Try-catch macros for to be used in the JNI functions |
|
31 |
|
32 #define SWT_TRY try |
|
33 #define SWT_CATCH \ |
|
34 catch(std::bad_alloc const&)\ |
|
35 {\ |
|
36 swtApp->jniUtils().Throw( aJniEnv, ESwtErrorNoHandles );\ |
|
37 }\ |
|
38 catch(std::exception const&)\ |
|
39 {\ |
|
40 swtApp->jniUtils().Throw( aJniEnv, ESwtErrorUnspecified );\ |
|
41 } |
|
42 #define SWT_CATCH_1(err) \ |
|
43 catch(std::exception const&)\ |
|
44 {\ |
|
45 swtApp->jniUtils().Throw( aJniEnv, err );\ |
|
46 } |
|
47 |
|
48 #endif // _SWT_H_ |