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 Red Hat, Inc.
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
);
101 JvSynchronize (const jobject
&o
) : obj (o
)
102 { _Jv_MonitorEnter (obj
); }
104 { _Jv_MonitorExit (obj
); }
107 #ifdef SJLJ_EXCEPTIONS
108 #define _Jv_Throw _Jv_Sjlj_Throw
111 // Throw some exception.
112 extern void JvThrow (jobject obj
) __attribute__ ((__noreturn__
));
114 JvThrow (jobject obj
)
116 _Jv_Throw ((void *) obj
);
119 /* Call malloc, but throw exception if insufficient memory. */
121 JvMalloc (jsize size
)
123 return _Jv_Malloc (size
);
129 return _Jv_Free (ptr
);
131 #endif /* __GCJ_CNI_H__ */