1 // gcj/cni.h -*- c++ -*-
2 // This file describes the Cygnus Native Interface, CNI.
3 // It provides a nicer interface to many of the things in gcj/javaprims.h.
5 /* Copyright (C) 1998, 1999 Cygnus Solutions
7 This file is part of libgcj.
9 This software is copyrighted work licensed under the terms of the
10 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
16 #include <java/lang/Object.h>
17 #include <java/lang/Class.h>
19 #include <gcj/array.h>
22 JvAllocObject (jclass cls
)
24 return _Jv_AllocObject (cls
, cls
->size());
28 JvAllocObject (jclass cls
, jsize sz
)
30 return _Jv_AllocObject (cls
, sz
);
33 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
);
34 extern "C" void _Jv_InitClass (jclass
);
37 JvInitClass (jclass cls
)
39 return _Jv_InitClass (cls
);
43 JvAllocString (jsize sz
)
45 return _Jv_AllocString (sz
);
49 JvNewString (const jchar
*chars
, jsize len
)
51 return _Jv_NewString (chars
, len
);
55 JvNewStringLatin1 (const char *bytes
, jsize len
)
57 return _Jv_NewStringLatin1 (bytes
, len
);
61 JvNewStringLatin1 (const char *bytes
)
63 return _Jv_NewStringLatin1 (bytes
, strlen (bytes
));
67 _Jv_GetStringChars (jstring str
)
69 return (jchar
*)((char*) str
->data
+ str
->boffset
);
73 JvGetStringChars (jstring str
)
75 return _Jv_GetStringChars (str
);
79 JvGetStringUTFLength (jstring string
)
81 return _Jv_GetStringUTFLength (string
);
85 JvGetStringUTFRegion (jstring str
, jsize start
, jsize len
, char *buf
)
87 return _Jv_GetStringUTFRegion (str
, start
, len
, buf
);
91 JvNewStringUTF (const char *bytes
)
93 return _Jv_NewStringUTF (bytes
);
96 extern class _Jv_PrimClass _Jv_byteClass
, _Jv_shortClass
, _Jv_intClass
,
97 _Jv_longClass
, _Jv_booleanClass
, _Jv_charClass
, _Jv_floatClass
,
98 _Jv_doubleClass
, _Jv_voidClass
;
99 #define JvPrimClass(TYPE) ((jclass) & _Jv_##TYPE##Class)
106 JvSynchronize (const jobject
&o
) : obj (o
)
107 { _Jv_MonitorEnter (obj
); }
109 { _Jv_MonitorExit (obj
); }
112 // Throw some exception.
113 extern void JvThrow (jobject obj
) __attribute__ ((__noreturn__
));
115 JvThrow (jobject obj
)
117 _Jv_Throw ((void *) obj
);
120 /* Call malloc, but throw exception if insufficient memory. */
122 JvMalloc (jsize size
)
124 return _Jv_Malloc (size
);
130 return _Jv_Free (ptr
);
132 #endif /* __GCJ_CNI_H__ */