|
1 /* |
|
2 * Copyright (c) 2003 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 |
|
18 |
|
19 /*! |
|
20 * \file \brief Java bindings for the K Virtual Machine native API |
|
21 * |
|
22 */ |
|
23 |
|
24 |
|
25 |
|
26 #ifndef M3G_JAVA_INCLUDE |
|
27 # error included by m3g_<platform>_java_api.c; do not compile separately. |
|
28 #endif |
|
29 |
|
30 /*! |
|
31 * \brief Macros for dispatching exceptions to vm. |
|
32 * |
|
33 */ |
|
34 #include <jni.h> |
|
35 #define M3G_RAISE_EXCEPTION(aEnv, aException){\ |
|
36 if (aEnv != NULL){\ |
|
37 jclass jException = aEnv->FindClass(aException);\ |
|
38 if (jException != NULL){\ |
|
39 aEnv->ThrowNew(jException, NULL);\ |
|
40 }}}\ |
|
41 |
|
42 |
|
43 /*! |
|
44 * \brief Macros for serializing m3gcore function calls |
|
45 * in native threading environment. |
|
46 */ |
|
47 #include "CSynchronization.h" |
|
48 #define M3G_DO_LOCK CSynchronization::InstanceL()->Lock(); |
|
49 #define M3G_DO_UNLOCK(aEnv) {\ |
|
50 TInt errorCode = CSynchronization::InstanceL()->GetErrorCode();\ |
|
51 if ( errorCode != 0){\ |
|
52 M3G_RAISE_EXCEPTION(aEnv, jsr184Exception(errorCode));\ |
|
53 }\ |
|
54 CSynchronization::InstanceL()->Unlock();\ |
|
55 }\ |
|
56 |
|
57 |
|
58 /*---------------------------------------------------------------------- |
|
59 * Internal data types |
|
60 *--------------------------------------------------------------------*/ |
|
61 |
|
62 |
|
63 |
|
64 /*---------------------------------------------------------------------- |
|
65 * Internal utility functions |
|
66 *--------------------------------------------------------------------*/ |
|
67 |
|
68 /*! |
|
69 * \brief Checks that a Java array is non-null and meets a minimum |
|
70 * length requirement |
|
71 * |
|
72 * Throws NullPointerException or IllegalArgumentException if |
|
73 * constraints violated. |
|
74 */ |
|
75 static M3Gbool validateArray(JNIEnv* aEnv, const jbyteArray aArray, M3Gsizei aMinLength) |
|
76 { |
|
77 if (aArray == NULL) |
|
78 { |
|
79 M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); |
|
80 return M3G_FALSE; |
|
81 } |
|
82 |
|
83 if (aEnv->GetArrayLength(aArray) < aMinLength) |
|
84 { |
|
85 M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); |
|
86 return M3G_FALSE; |
|
87 } |
|
88 |
|
89 return M3G_TRUE; |
|
90 } |
|
91 |
|
92 #include "m3g_jsr184.inl" |
|
93 #include "jni/triangleStripArray.inl" |
|
94 #include "jni/vertexBuffer.inl" |
|
95 #include "jni/fog.inl" |
|
96 #include "jni/polygonMode.inl" |
|
97 #include "jni/object3d.inl" |
|
98 #include "jni/node.inl" |
|
99 #include "jni/group.inl" |
|
100 #include "jni/skinnedMesh.inl" |
|
101 #include "jni/camera.inl" |
|
102 #include "jni/vertexArray.inl" |
|
103 #include "jni/transform.inl" |
|
104 #include "jni/graphics3d.inl" |
|
105 #include "jni/platform.inl" |
|
106 #include "jni/compositingMode.inl" |
|
107 #include "jni/world.inl" |
|
108 #include "jni/material.inl" |
|
109 #include "jni/keyframeSequence.inl" |
|
110 #include "jni/sprite3d.inl" |
|
111 #include "jni/mesh.inl" |
|
112 #include "jni/animationTrack.inl" |
|
113 #include "jni/texture2d.inl" |
|
114 #include "jni/morphingMesh.inl" |
|
115 #include "jni/transformable.inl" |
|
116 #include "jni/background.inl" |
|
117 #include "jni/image2d.inl" |
|
118 #include "jni/appearance.inl" |
|
119 #include "jni/light.inl" |
|
120 #include "jni/animationController.inl" |
|
121 #include "jni/interface.inl" |
|
122 #include "jni/loader.inl" |
|
123 |