PageRenderTime 30ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/jritypes.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 243 lines | 128 code | 31 blank | 84 comment | 0 complexity | 6e856de3995e0f78f5f888bd3b0d5b62 MD5 | raw file
  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. /*******************************************************************************
  38. * Java Runtime Interface
  39. ******************************************************************************/
  40. #ifndef JRITYPES_H
  41. #define JRITYPES_H
  42. #include "jri_md.h"
  43. #include "jni.h"
  44. #include <stddef.h>
  45. #include <stdlib.h>
  46. #include <stdarg.h>
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50. /*******************************************************************************
  51. * Types
  52. ******************************************************************************/
  53. struct JRIEnvInterface;
  54. typedef void* JRIRef;
  55. typedef void* JRIGlobalRef;
  56. typedef jint JRIFieldID;
  57. typedef jint JRIMethodID;
  58. /* synonyms: */
  59. typedef JRIGlobalRef jglobal;
  60. typedef union JRIValue {
  61. jbool z;
  62. jbyte b;
  63. jchar c;
  64. jshort s;
  65. jint i;
  66. jlong l;
  67. jfloat f;
  68. jdouble d;
  69. jref r;
  70. } JRIValue;
  71. typedef enum JRIBoolean {
  72. JRIFalse = 0,
  73. JRITrue = 1
  74. } JRIBoolean;
  75. typedef enum JRIConstant {
  76. JRIUninitialized = -1
  77. } JRIConstant;
  78. /* convenience types (these must be distinct struct types for c++ overloading): */
  79. #if 0 /* now in jni.h */
  80. typedef struct jbooleanArrayStruct* jbooleanArray;
  81. typedef struct jbyteArrayStruct* jbyteArray;
  82. typedef struct jcharArrayStruct* jcharArray;
  83. typedef struct jshortArrayStruct* jshortArray;
  84. typedef struct jintArrayStruct* jintArray;
  85. typedef struct jlongArrayStruct* jlongArray;
  86. typedef struct jfloatArrayStruct* jfloatArray;
  87. typedef struct jdoubleArrayStruct* jdoubleArray;
  88. typedef struct jobjectArrayStruct* jobjectArray;
  89. #endif
  90. typedef struct jstringArrayStruct* jstringArray;
  91. typedef struct jarrayArrayStruct* jarrayArray;
  92. #define JRIConstructorMethodName "<init>"
  93. /*******************************************************************************
  94. * Signature Construction Macros
  95. ******************************************************************************/
  96. /*
  97. ** These macros can be used to construct signature strings. Hopefully their names
  98. ** are a little easier to remember than the single character they correspond to.
  99. ** For example, to specify the signature of the method:
  100. **
  101. ** public int read(byte b[], int off, int len);
  102. **
  103. ** you could write something like this in C:
  104. **
  105. ** char* readSig = JRISigMethod(JRISigArray(JRISigByte)
  106. ** JRISigInt
  107. ** JRISigInt) JRISigInt;
  108. **
  109. ** Of course, don't put commas between the types.
  110. */
  111. #define JRISigArray(T) "[" T
  112. #define JRISigByte "B"
  113. #define JRISigChar "C"
  114. #define JRISigClass(name) "L" name ";"
  115. #define JRISigFloat "F"
  116. #define JRISigDouble "D"
  117. #define JRISigMethod(args) "(" args ")"
  118. #define JRISigNoArgs ""
  119. #define JRISigInt "I"
  120. #define JRISigLong "J"
  121. #define JRISigShort "S"
  122. #define JRISigVoid "V"
  123. #define JRISigBoolean "Z"
  124. /*******************************************************************************
  125. * Environments
  126. ******************************************************************************/
  127. extern JRI_PUBLIC_API(const struct JRIEnvInterface**)
  128. JRI_GetCurrentEnv(void);
  129. /*******************************************************************************
  130. * Specific Scalar Array Types
  131. ******************************************************************************/
  132. /*
  133. ** The JRI Native Method Interface does not support boolean arrays. This
  134. ** is to allow Java runtime implementations to optimize boolean array
  135. ** storage. Using the ScalarArray operations on boolean arrays is bound
  136. ** to fail, so convert any boolean arrays to byte arrays in Java before
  137. ** passing them to a native method.
  138. */
  139. #define JRI_NewByteArray(env, length, initialValues) \
  140. JRI_NewScalarArray(env, length, JRISigByte, (jbyte*)(initialValues))
  141. #define JRI_GetByteArrayLength(env, array) \
  142. JRI_GetScalarArrayLength(env, array)
  143. #define JRI_GetByteArrayElements(env, array) \
  144. JRI_GetScalarArrayElements(env, array)
  145. #define JRI_NewCharArray(env, length, initialValues) \
  146. JRI_NewScalarArray(env, ((length) * sizeof(jchar)), JRISigChar, (jbyte*)(initialValues))
  147. #define JRI_GetCharArrayLength(env, array) \
  148. JRI_GetScalarArrayLength(env, array)
  149. #define JRI_GetCharArrayElements(env, array) \
  150. ((jchar*)JRI_GetScalarArrayElements(env, array))
  151. #define JRI_NewShortArray(env, length, initialValues) \
  152. JRI_NewScalarArray(env, ((length) * sizeof(jshort)), JRISigShort, (jbyte*)(initialValues))
  153. #define JRI_GetShortArrayLength(env, array) \
  154. JRI_GetScalarArrayLength(env, array)
  155. #define JRI_GetShortArrayElements(env, array) \
  156. ((jshort*)JRI_GetScalarArrayElements(env, array))
  157. #define JRI_NewIntArray(env, length, initialValues) \
  158. JRI_NewScalarArray(env, ((length) * sizeof(jint)), JRISigInt, (jbyte*)(initialValues))
  159. #define JRI_GetIntArrayLength(env, array) \
  160. JRI_GetScalarArrayLength(env, array)
  161. #define JRI_GetIntArrayElements(env, array) \
  162. ((jint*)JRI_GetScalarArrayElements(env, array))
  163. #define JRI_NewLongArray(env, length, initialValues) \
  164. JRI_NewScalarArray(env, ((length) * sizeof(jlong)), JRISigLong, (jbyte*)(initialValues))
  165. #define JRI_GetLongArrayLength(env, array) \
  166. JRI_GetScalarArrayLength(env, array)
  167. #define JRI_GetLongArrayElements(env, array) \
  168. ((jlong*)JRI_GetScalarArrayElements(env, array))
  169. #define JRI_NewFloatArray(env, length, initialValues) \
  170. JRI_NewScalarArray(env, ((length) * sizeof(jfloat)), JRISigFloat, (jbyte*)(initialValues))
  171. #define JRI_GetFloatArrayLength(env, array) \
  172. JRI_GetScalarArrayLength(env, array)
  173. #define JRI_GetFloatArrayElements(env, array) \
  174. ((jfloat*)JRI_GetScalarArrayElements(env, array))
  175. #define JRI_NewDoubleArray(env, length, initialValues) \
  176. JRI_NewScalarArray(env, ((length) * sizeof(jdouble)), JRISigDouble, (jbyte*)(initialValues))
  177. #define JRI_GetDoubleArrayLength(env, array) \
  178. JRI_GetScalarArrayLength(env, array)
  179. #define JRI_GetDoubleArrayElements(env, array) \
  180. ((jdouble*)JRI_GetScalarArrayElements(env, array))
  181. /******************************************************************************/
  182. /*
  183. ** JDK Stuff -- This stuff is still needed while we're using the JDK
  184. ** dynamic linking strategy to call native methods.
  185. */
  186. typedef union JRI_JDK_stack_item {
  187. /* Non pointer items */
  188. jint i;
  189. jfloat f;
  190. jint o;
  191. /* Pointer items */
  192. void *h;
  193. void *p;
  194. unsigned char *addr;
  195. #ifdef IS_64
  196. double d;
  197. long l; /* == 64bits! */
  198. #endif
  199. } JRI_JDK_stack_item;
  200. typedef union JRI_JDK_Java8Str {
  201. jint x[2];
  202. jdouble d;
  203. jlong l;
  204. void *p;
  205. float f;
  206. } JRI_JDK_Java8;
  207. /******************************************************************************/
  208. #ifdef __cplusplus
  209. }
  210. #endif
  211. #endif /* JRITYPES_H */
  212. /******************************************************************************/