|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "javax_microedition_m3g_Interface.h" |
|
18 |
|
19 |
|
20 /*! |
|
21 * \brief Error handler for the Java interface |
|
22 * |
|
23 * Converts M3G errors to exceptions and throws them automatically. |
|
24 */ |
|
25 static void errorHandler(M3Genum errorCode, M3GInterface m3g) |
|
26 { |
|
27 CSynchronization::InstanceL()->SetErrorCode(errorCode); |
|
28 } |
|
29 |
|
30 /* |
|
31 static int createInterface(M3Gparams* aCs) |
|
32 { |
|
33 return ((unsigned) m3gCreateInterface(aCs)); |
|
34 } |
|
35 */ |
|
36 |
|
37 /* |
|
38 * Must be executed in UI thread |
|
39 */ |
|
40 JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Interface__1ctor(JNIEnv* aEnv, jclass) |
|
41 { |
|
42 M3Gparams cs; |
|
43 memset(&cs, 0, sizeof(cs)); |
|
44 cs.mallocFunc = malloc; |
|
45 cs.freeFunc = free; |
|
46 cs.errorFunc = errorHandler; |
|
47 |
|
48 M3G_DO_LOCK |
|
49 /* Call to the Eventserver side */ |
|
50 //CJavaM3GEventSource* eventSource = JavaUnhand<CJavaM3GEventSource>(aEventSourceHandle); |
|
51 //jint handle = eventSource->Execute(&createInterface, &cs); |
|
52 jint handle = (unsigned)m3gCreateInterface(&cs); |
|
53 M3G_DO_UNLOCK(aEnv); |
|
54 return handle; |
|
55 } |
|
56 |
|
57 JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Interface__1getClassID |
|
58 (JNIEnv* aEnv, jclass, jint aHObject) |
|
59 { |
|
60 M3G_DO_LOCK |
|
61 jint handle = m3gGetClass((M3GObject)aHObject); |
|
62 M3G_DO_UNLOCK(aEnv); |
|
63 return handle; |
|
64 } |