1999-09-11 00:03:10 +02:00
|
|
|
// gcj/cni.h -*- c++ -*-
|
2003-07-08 23:27:37 +02:00
|
|
|
// This file describes the Compiled Native Interface, CNI.
|
1999-09-11 00:03:10 +02:00
|
|
|
// It provides a nicer interface to many of the things in gcj/javaprims.h.
|
1999-04-07 16:42:40 +02:00
|
|
|
|
2002-04-10 22:36:04 +02:00
|
|
|
/* Copyright (C) 1998, 1999, 2002 Free Software Foundation
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
This file is part of libgcj.
|
|
|
|
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
1999-09-11 00:03:10 +02:00
|
|
|
#ifndef __GCJ_CNI_H__
|
|
|
|
#define __GCJ_CNI_H__
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
#include <java/lang/Object.h>
|
|
|
|
#include <java/lang/Class.h>
|
|
|
|
|
1999-09-11 00:03:10 +02:00
|
|
|
#include <gcj/array.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
2000-06-01 00:49:19 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-04-07 16:42:40 +02:00
|
|
|
extern "C" void _Jv_InitClass (jclass);
|
2004-05-28 20:53:06 +02:00
|
|
|
extern "C" void *_Jv_AllocBytes (jsize size) __attribute__((__malloc__));
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
extern inline void
|
|
|
|
JvInitClass (jclass cls)
|
|
|
|
{
|
|
|
|
return _Jv_InitClass (cls);
|
|
|
|
}
|
|
|
|
|
2004-05-28 20:53:06 +02:00
|
|
|
extern inline void *
|
|
|
|
JvAllocBytes (jsize sz)
|
|
|
|
{
|
|
|
|
return _Jv_AllocBytes (sz);
|
|
|
|
}
|
|
|
|
|
1999-04-07 16:42:40 +02:00
|
|
|
extern inline jstring
|
|
|
|
JvAllocString (jsize sz)
|
|
|
|
{
|
|
|
|
return _Jv_AllocString (sz);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jstring
|
|
|
|
JvNewString (const jchar *chars, jsize len)
|
|
|
|
{
|
|
|
|
return _Jv_NewString (chars, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jstring
|
|
|
|
JvNewStringLatin1 (const char *bytes, jsize len)
|
|
|
|
{
|
|
|
|
return _Jv_NewStringLatin1 (bytes, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jstring
|
|
|
|
JvNewStringLatin1 (const char *bytes)
|
|
|
|
{
|
|
|
|
return _Jv_NewStringLatin1 (bytes, strlen (bytes));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jchar *
|
|
|
|
_Jv_GetStringChars (jstring str)
|
|
|
|
{
|
|
|
|
return (jchar*)((char*) str->data + str->boffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jchar*
|
|
|
|
JvGetStringChars (jstring str)
|
|
|
|
{
|
|
|
|
return _Jv_GetStringChars (str);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jsize
|
|
|
|
JvGetStringUTFLength (jstring string)
|
|
|
|
{
|
|
|
|
return _Jv_GetStringUTFLength (string);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jsize
|
|
|
|
JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf)
|
|
|
|
{
|
|
|
|
return _Jv_GetStringUTFRegion (str, start, len, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jstring
|
|
|
|
JvNewStringUTF (const char *bytes)
|
|
|
|
{
|
|
|
|
return _Jv_NewStringUTF (bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
class JvSynchronize
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
jobject obj;
|
|
|
|
public:
|
|
|
|
JvSynchronize (const jobject &o) : obj (o)
|
|
|
|
{ _Jv_MonitorEnter (obj); }
|
|
|
|
~JvSynchronize ()
|
|
|
|
{ _Jv_MonitorExit (obj); }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Call malloc, but throw exception if insufficient memory. */
|
|
|
|
extern inline void *
|
|
|
|
JvMalloc (jsize size)
|
|
|
|
{
|
|
|
|
return _Jv_Malloc (size);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline void
|
|
|
|
JvFree (void *ptr)
|
|
|
|
{
|
|
|
|
return _Jv_Free (ptr);
|
|
|
|
}
|
2001-05-22 08:47:48 +02:00
|
|
|
|
|
|
|
extern inline jint
|
|
|
|
JvCreateJavaVM (void* vm_args)
|
|
|
|
{
|
|
|
|
return _Jv_CreateJavaVM (vm_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline java::lang::Thread*
|
|
|
|
JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group)
|
|
|
|
{
|
|
|
|
return _Jv_AttachCurrentThread (name, group);
|
|
|
|
}
|
|
|
|
|
2002-04-10 22:36:04 +02:00
|
|
|
extern inline java::lang::Thread*
|
|
|
|
JvAttachCurrentThreadAsDaemon (jstring name, java::lang::ThreadGroup* group)
|
|
|
|
{
|
|
|
|
return _Jv_AttachCurrentThreadAsDaemon (name, group);
|
|
|
|
}
|
|
|
|
|
2001-05-22 08:47:48 +02:00
|
|
|
extern inline jint
|
|
|
|
JvDetachCurrentThread (void)
|
|
|
|
{
|
|
|
|
return _Jv_DetachCurrentThread ();
|
|
|
|
}
|
1999-09-11 00:03:10 +02:00
|
|
|
#endif /* __GCJ_CNI_H__ */
|