source: trunk/gcc/libjava/gcj/cni.h@ 2446

Last change on this file since 2446 was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.8 KB
Line 
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.
4
5/* Copyright (C) 1998, 1999, 2002 Free Software Foundation
6
7 This file is part of libgcj.
8
9This software is copyrighted work licensed under the terms of the
10Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11details. */
12
13#ifndef __GCJ_CNI_H__
14#define __GCJ_CNI_H__
15
16#include <java/lang/Object.h>
17#include <java/lang/Class.h>
18
19#include <gcj/array.h>
20
21#include <string.h>
22
23extern inline jobject
24JvAllocObject (jclass cls)
25{
26 return _Jv_AllocObject (cls, cls->size());
27}
28
29extern inline jobject
30JvAllocObject (jclass cls, jsize sz)
31{
32 return _Jv_AllocObject (cls, sz);
33}
34
35extern "C" jstring _Jv_NewStringUTF (const char *bytes);
36extern "C" void _Jv_InitClass (jclass);
37
38extern inline void
39JvInitClass (jclass cls)
40{
41 return _Jv_InitClass (cls);
42}
43
44extern inline jstring
45JvAllocString (jsize sz)
46{
47 return _Jv_AllocString (sz);
48}
49
50extern inline jstring
51JvNewString (const jchar *chars, jsize len)
52{
53 return _Jv_NewString (chars, len);
54}
55
56extern inline jstring
57JvNewStringLatin1 (const char *bytes, jsize len)
58{
59 return _Jv_NewStringLatin1 (bytes, len);
60}
61
62extern inline jstring
63JvNewStringLatin1 (const char *bytes)
64{
65 return _Jv_NewStringLatin1 (bytes, strlen (bytes));
66}
67
68extern inline jchar *
69_Jv_GetStringChars (jstring str)
70{
71 return (jchar*)((char*) str->data + str->boffset);
72}
73
74extern inline jchar*
75JvGetStringChars (jstring str)
76{
77 return _Jv_GetStringChars (str);
78}
79
80extern inline jsize
81JvGetStringUTFLength (jstring string)
82{
83 return _Jv_GetStringUTFLength (string);
84}
85
86extern inline jsize
87JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf)
88{
89 return _Jv_GetStringUTFRegion (str, start, len, buf);
90}
91
92extern inline jstring
93JvNewStringUTF (const char *bytes)
94{
95 return _Jv_NewStringUTF (bytes);
96}
97
98class JvSynchronize
99{
100private:
101 jobject obj;
102public:
103 JvSynchronize (const jobject &o) : obj (o)
104 { _Jv_MonitorEnter (obj); }
105 ~JvSynchronize ()
106 { _Jv_MonitorExit (obj); }
107};
108
109/* Call malloc, but throw exception if insufficient memory. */
110extern inline void *
111JvMalloc (jsize size)
112{
113 return _Jv_Malloc (size);
114}
115
116extern inline void
117JvFree (void *ptr)
118{
119 return _Jv_Free (ptr);
120}
121
122extern inline jint
123JvCreateJavaVM (void* vm_args)
124{
125 return _Jv_CreateJavaVM (vm_args);
126}
127
128extern inline java::lang::Thread*
129JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group)
130{
131 return _Jv_AttachCurrentThread (name, group);
132}
133
134extern inline java::lang::Thread*
135JvAttachCurrentThreadAsDaemon (jstring name, java::lang::ThreadGroup* group)
136{
137 return _Jv_AttachCurrentThreadAsDaemon (name, group);
138}
139
140extern inline jint
141JvDetachCurrentThread (void)
142{
143 return _Jv_DetachCurrentThread ();
144}
145#endif /* __GCJ_CNI_H__ */
Note: See TracBrowser for help on using the repository browser.