1999-09-11 00:03:10 +02:00
|
|
|
// array.h - Header file for CNI arrays. -*- c++ -*-
|
1999-04-07 16:42:40 +02:00
|
|
|
|
2000-11-24 22:02:36 +01:00
|
|
|
/* Copyright (C) 1998, 1999, 2000 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_ARRAY_H__
|
|
|
|
#define __GCJ_ARRAY_H__
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
#include <java/lang/Object.h>
|
|
|
|
|
|
|
|
extern "Java" {
|
|
|
|
|
|
|
|
class __JArray : public java::lang::Object
|
|
|
|
{
|
2000-11-27 05:05:23 +01:00
|
|
|
protected:
|
|
|
|
// This is just a hack to work around a warning emitted by the C++
|
|
|
|
// compiler. We initialize `length' evilly, but it doesn't know
|
|
|
|
// that.
|
|
|
|
__JArray () : length (0)
|
|
|
|
{
|
|
|
|
}
|
1999-04-07 16:42:40 +02:00
|
|
|
public:
|
2000-11-27 05:05:23 +01:00
|
|
|
const jsize length;
|
1999-04-07 16:42:40 +02:00
|
|
|
friend jsize JvGetArrayLength (__JArray*);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
class JArray : public __JArray
|
|
|
|
{
|
|
|
|
T data[0];
|
|
|
|
public:
|
|
|
|
friend T* elements<>(JArray<T>& x);
|
|
|
|
friend T* elements<>(JArray<T>* x);
|
|
|
|
// T* getData() { return data; }
|
|
|
|
// T& operator[](jint i) { return data[i]; }
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T>
|
2000-04-09 03:26:20 +02:00
|
|
|
inline T* elements(JArray<T>& x) { return x.data; }
|
1999-04-07 16:42:40 +02:00
|
|
|
template<class T>
|
2000-04-09 03:26:20 +02:00
|
|
|
inline T* elements(JArray<T>* x) { return x->data; }
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
}; // end extern "Java"
|
|
|
|
|
|
|
|
/* These typesdefs match those in JNI. */
|
|
|
|
typedef __JArray *jarray;
|
|
|
|
typedef JArray<jobject> *jobjectArray;
|
|
|
|
typedef JArray<jboolean> *jbooleanArray;
|
|
|
|
typedef JArray<jbyte> *jbyteArray;
|
|
|
|
typedef JArray<jchar> *jcharArray;
|
|
|
|
typedef JArray<jshort> *jshortArray;
|
|
|
|
typedef JArray<jint> *jintArray;
|
|
|
|
typedef JArray<jlong> *jlongArray;
|
|
|
|
typedef JArray<jfloat> *jfloatArray;
|
|
|
|
typedef JArray<jdouble> *jdoubleArray;
|
|
|
|
typedef JArray<jstring> *jstringArray;
|
|
|
|
|
resolve.cc (_Jv_SearchMethodInClass): New function.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* resolve.cc (_Jv_SearchMethodInClass): New function.
(_Jv_ResolvePoolEntry): Search superinterfaces for interface
methods.
* java/lang/Class.h (_Jv_SearchMethodInClass): New prototype.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/Class.h (union _Jv_IDispatchTable): New declaration.
(struct _Jv_ifaces): New declaration.
JV_CLASS: New macro definition.
(getComponentType): Relocate below isArray() for inlining.
(getModifiers): Declare `inline'.
(getSuperclass): Ditto.
(isArray): Ditto.
(isPrimitive): Ditto.
(_Jv_IsAssignableFrom): New prototype.
(_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C"
linkage.
(_Jv_InitClass): Move from natClass.cc. Declare `inline'.
Check for JV_STATE_DONE before invoking initializeClass().
(_Jv_PrepareConstantTimeTables): New prototype.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
(_Jv_FindIIndex): Ditto.
depth, ancestors, idt: New class fields.
* java/lang/natClass.cc (isAssignableFrom): Move functionality to
inline function `_Jv_IsAssignableFrom'. Use that function.
(isInstance): Declare `inline'.
(initializeClass): Get lock on class before checking `state'. Unlock
before calling resolveClass0. Call _Jv_PrepareConstantTimeTables
with the lock held.
(_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString.
(_Jv_IsAssignableFrom): New inline function. Test assignability
using class->depth and ancestor table.
(_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom.
(_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and
_Jv_IsAssignableFrom.
(_Jv_CheckArrayStore): Ditto.
(_Jv_LookupInterfaceMethodIdx): New function.
INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines.
(_Jv_PrepareConstantTimeTables): New function.
(_Jv_IndexOf): Ditto.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
iindex_mutex, iindex_mutex_initialized: New static fields.
(_Jv_FindIIndex): New function.
* java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields.
* prims.cc (_Jv_CheckCast): Moved to natClass.cc.
(_Jv_CheckArrayStore): Ditto.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray,
JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray):
Moved to gcj/array.h.
(_Jv_Realloc): New function.
* gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h.
* gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray,
JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray,
JvNewDoubleArray): Implementations moved from prims.cc and
declared `inline'.
* gcj/javaprims.h (_Jv_Realloc): Prototype.
* include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype.
From-SVN: r32382
2000-03-07 10:52:56 +01:00
|
|
|
extern class _Jv_PrimClass _Jv_byteClass, _Jv_shortClass, _Jv_intClass,
|
|
|
|
_Jv_longClass, _Jv_booleanClass, _Jv_charClass, _Jv_floatClass,
|
|
|
|
_Jv_doubleClass, _Jv_voidClass;
|
|
|
|
#define JvPrimClass(TYPE) ((jclass) & _Jv_##TYPE##Class)
|
|
|
|
|
1999-04-07 16:42:40 +02:00
|
|
|
extern "C" jobjectArray _Jv_NewObjectArray(jsize length, jclass, jobject init);
|
resolve.cc (_Jv_SearchMethodInClass): New function.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* resolve.cc (_Jv_SearchMethodInClass): New function.
(_Jv_ResolvePoolEntry): Search superinterfaces for interface
methods.
* java/lang/Class.h (_Jv_SearchMethodInClass): New prototype.
2000-03-07 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/Class.h (union _Jv_IDispatchTable): New declaration.
(struct _Jv_ifaces): New declaration.
JV_CLASS: New macro definition.
(getComponentType): Relocate below isArray() for inlining.
(getModifiers): Declare `inline'.
(getSuperclass): Ditto.
(isArray): Ditto.
(isPrimitive): Ditto.
(_Jv_IsAssignableFrom): New prototype.
(_Jv_LookupInterfaceMethodIdx): New prototype. Predeclare with "C"
linkage.
(_Jv_InitClass): Move from natClass.cc. Declare `inline'.
Check for JV_STATE_DONE before invoking initializeClass().
(_Jv_PrepareConstantTimeTables): New prototype.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
(_Jv_FindIIndex): Ditto.
depth, ancestors, idt: New class fields.
* java/lang/natClass.cc (isAssignableFrom): Move functionality to
inline function `_Jv_IsAssignableFrom'. Use that function.
(isInstance): Declare `inline'.
(initializeClass): Get lock on class before checking `state'. Unlock
before calling resolveClass0. Call _Jv_PrepareConstantTimeTables
with the lock held.
(_Jv_LookupInterfaceMethod): Use _Jv_GetMessageString.
(_Jv_IsAssignableFrom): New inline function. Test assignability
using class->depth and ancestor table.
(_Jv_IsInstanceOf): Use _Jv_IsAssignableFrom.
(_Jv_CheckCast): Move from prims.cc. Use JV_CLASS and
_Jv_IsAssignableFrom.
(_Jv_CheckArrayStore): Ditto.
(_Jv_LookupInterfaceMethodIdx): New function.
INITIAL_IOFFSETS_LEN, INITIAL_IFACES_LEN: New #defines.
(_Jv_PrepareConstantTimeTables): New function.
(_Jv_IndexOf): Ditto.
(_Jv_GetInterfaces): Ditto.
(_Jv_GenerateITable): Ditto.
(_Jv_GetMethodString): Ditto.
(_Jv_AppendPartialITable): Ditto.
iindex_mutex, iindex_mutex_initialized: New static fields.
(_Jv_FindIIndex): New function.
* java/lang/natClassLoader.cc (_Jv_NewClass): Set new jclass fields.
* prims.cc (_Jv_CheckCast): Moved to natClass.cc.
(_Jv_CheckArrayStore): Ditto.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray, JvNewShortArray,
JvNewIntArray, JvNewLongArray, JvNewFloatArray, JvNewDoubleArray):
Moved to gcj/array.h.
(_Jv_Realloc): New function.
* gcj/cni.h: Move _Jv_PrimClass definitions to gcj/array.h.
* gcj/array.h: _Jv_PrimClass definitions moved from gcj/cni.h.
(JvNewCharArray, JvNewBooleanArray, JvNewByteArray,
JvNewShortArray, JvNewIntArray, JvNewLongArray, JvNewFloatArray,
JvNewDoubleArray): Implementations moved from prims.cc and
declared `inline'.
* gcj/javaprims.h (_Jv_Realloc): Prototype.
* include/jvm.h (_Jv_LookupInterfaceMethodIdx): Prototype.
From-SVN: r32382
2000-03-07 10:52:56 +01:00
|
|
|
extern "C" jobject _Jv_NewPrimArray (jclass eltype, jint count);
|
|
|
|
|
|
|
|
extern inline jobjectArray
|
|
|
|
JvNewObjectArray (jsize length, jclass cls, jobject init)
|
|
|
|
{
|
|
|
|
return _Jv_NewObjectArray (length, cls, init);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jcharArray
|
|
|
|
JvNewCharArray (jint length)
|
|
|
|
{
|
|
|
|
return (jcharArray) _Jv_NewPrimArray (JvPrimClass (char), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jbooleanArray
|
|
|
|
JvNewBooleanArray (jint length)
|
|
|
|
{
|
|
|
|
return (jbooleanArray) _Jv_NewPrimArray (JvPrimClass (boolean), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jbyteArray
|
|
|
|
JvNewByteArray (jint length)
|
|
|
|
{
|
|
|
|
return (jbyteArray) _Jv_NewPrimArray (JvPrimClass (byte), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jshortArray
|
|
|
|
JvNewShortArray (jint length)
|
|
|
|
{
|
|
|
|
return (jshortArray) _Jv_NewPrimArray (JvPrimClass (short), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jintArray
|
|
|
|
JvNewIntArray (jint length)
|
|
|
|
{
|
|
|
|
return (jintArray) _Jv_NewPrimArray (JvPrimClass (int), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jlongArray
|
|
|
|
JvNewLongArray (jint length)
|
|
|
|
{
|
|
|
|
return (jlongArray) _Jv_NewPrimArray (JvPrimClass (long), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jfloatArray
|
|
|
|
JvNewFloatArray (jint length)
|
|
|
|
{
|
|
|
|
return (jfloatArray) _Jv_NewPrimArray (JvPrimClass (float), length);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern inline jdoubleArray
|
|
|
|
JvNewDoubleArray (jint length)
|
|
|
|
{
|
|
|
|
return (jdoubleArray) _Jv_NewPrimArray (JvPrimClass (double), length);
|
|
|
|
}
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
extern "C" jstringArray JvConvertArgv(int argc, const char **argv);
|
|
|
|
|
|
|
|
inline jsize JvGetArrayLength (jarray array) { return array->length; }
|
|
|
|
|
1999-09-11 00:03:10 +02:00
|
|
|
#endif /* __GCJ_ARRAY_H__ */
|