* gcc_update: Add rules for libf2c/libI77.
[official-gcc.git] / libjava / gcj / cni.h
blob6b103a34517cae7db039d7d60635cbe21dd68884
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 Free Software Foundation
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
11 details. */
13 #ifndef __GCJ_CNI_H__
14 #define __GCJ_CNI_H__
16 #include <java/lang/Object.h>
17 #include <java/lang/Class.h>
19 #include <gcj/array.h>
21 #include <string.h>
23 extern inline jobject
24 JvAllocObject (jclass cls)
26 return _Jv_AllocObject (cls, cls->size());
29 extern inline jobject
30 JvAllocObject (jclass cls, jsize sz)
32 return _Jv_AllocObject (cls, sz);
35 extern "C" jstring _Jv_NewStringUTF (const char *bytes);
36 extern "C" void _Jv_InitClass (jclass);
38 extern inline void
39 JvInitClass (jclass cls)
41 return _Jv_InitClass (cls);
44 extern inline jstring
45 JvAllocString (jsize sz)
47 return _Jv_AllocString (sz);
50 extern inline jstring
51 JvNewString (const jchar *chars, jsize len)
53 return _Jv_NewString (chars, len);
56 extern inline jstring
57 JvNewStringLatin1 (const char *bytes, jsize len)
59 return _Jv_NewStringLatin1 (bytes, len);
62 extern inline jstring
63 JvNewStringLatin1 (const char *bytes)
65 return _Jv_NewStringLatin1 (bytes, strlen (bytes));
68 extern inline jchar *
69 _Jv_GetStringChars (jstring str)
71 return (jchar*)((char*) str->data + str->boffset);
74 extern inline jchar*
75 JvGetStringChars (jstring str)
77 return _Jv_GetStringChars (str);
80 extern inline jsize
81 JvGetStringUTFLength (jstring string)
83 return _Jv_GetStringUTFLength (string);
86 extern inline jsize
87 JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf)
89 return _Jv_GetStringUTFRegion (str, start, len, buf);
92 extern inline jstring
93 JvNewStringUTF (const char *bytes)
95 return _Jv_NewStringUTF (bytes);
98 class JvSynchronize
100 private:
101 jobject obj;
102 public:
103 JvSynchronize (const jobject &o) : obj (o)
104 { _Jv_MonitorEnter (obj); }
105 ~JvSynchronize ()
106 { _Jv_MonitorExit (obj); }
109 /* Call malloc, but throw exception if insufficient memory. */
110 extern inline void *
111 JvMalloc (jsize size)
113 return _Jv_Malloc (size);
116 extern inline void
117 JvFree (void *ptr)
119 return _Jv_Free (ptr);
121 #endif /* __GCJ_CNI_H__ */