classmethod.h

来自「基于LWVCL开发的库」· C头文件 代码 · 共 820 行 · 第 1/2 页

H
820
字号
#define FIELD_SIZE(FLD)		((FLD)->bsize)#define FIELD_WSIZE(FLD)	((FLD)->bsize <= sizeof(jint) ? 1 : 2)#define FIELD_BOFFSET(FLD)	((FLD)->info.boffset)#define FIELD_ADDRESS(FLD)	((FLD)->info.addr)#define	FIELD_CONSTIDX(FLD)	((FLD)->info.idx)#define FIELD_ISPRIM(FLD)	(FIELD_RESOLVED(FLD)			\				 && CLASS_IS_PRIMITIVE(FIELD_TYPE(FLD)))#define FIELD_ISREF(FLD)	(!FIELD_ISPRIM(FLD)			\				 && FIELD_TYPE(FLD) != PtrClass)#define FIELD_NAME(FLD)		((FLD)->name->data)#define	CLASSMAXSIG		256struct _Code;struct _method_info;struct _field_info;struct classFile;#define CLASS_NMETHODS(CLASS)  ((CLASS)->method_count)/* An array containing all the Fields, static fields first. */#define CLASS_FIELDS(CLASS)   ((CLASS)->fields)/* An array containing all the static Fields. */#define CLASS_SFIELDS(CLASS)  ((CLASS)->fields)/* The static data of this class */#define CLASS_STATICDATA(CLASS)  ((CLASS)->static_data)/* An array containing all the instance (non-static) Fields. */#define CLASS_IFIELDS(CL)     (&(CL)->fields[CLASS_NSFIELDS(CL)])/* Total number of fields (instance and static). */#define CLASS_NFIELDS(CLASS)  ((CLASS)->field_count)/* Number of instance (non-static) fields. */#define CLASS_NIFIELDS(CLASS) ((CLASS)->field_count - (CLASS)->nsfields)/* Number of static fields. */#define CLASS_NSFIELDS(CLASS) ((CLASS)->nsfields)/* Size of a class fields (including header), in words. */#define CLASS_WFSIZE(CLASS)   ((CLASS)->size_in_bytes / sizeof(jint))/* Size of a class's fields (including header), in bytes. */#define CLASS_FSIZE(CLASS)    ((CLASS)->size_in_bytes)#define OBJECT_CLASS(OBJ)     ((OBJ)->vtable->class)#define CLASS_CNAME(CL)  ((CL)->name->data)#define CLASS_SOURCEFILE(CL)	\	((CL)->sourcefile == 0 ? "source file unknown" : (CL)->sourcefile)#define _PRIMITIVE_DTABLE ((struct _dispatchTable*)(-1))#define CLASS_IS_PRIMITIVE(CL) ((CL)->vtable == _PRIMITIVE_DTABLE)/* Assuming CLASS_IS_PRIMITIVE(CL), return the 1-letter signature code. */#define CLASS_PRIM_SIG(CL) ((CL)->msize)#define	CLASS_PRIM_NAME(CL) (*(Utf8Const**)&(CL)->fields)/* A freshly born class that does have its name set, but the collector * may already want to know whether it'll be a boy or a girl. */#define CLASS_IS_ARRAY(CL) ((CL)->name && CLASS_CNAME(CL)[0] == '[')#define	CLASS_IS_INTERFACE(CL) ((CL)->accflags & ACC_INTERFACE)#define	CLASS_IS_ABSTRACT(CL) ((CL)->accflags & ACC_ABSTRACT)#define	CLASS_IS_FINAL(CL) ((CL)->accflags & ACC_FINAL)/** * get array of methods in class. *  * @param clazz the class * * @return methods in the class */static inline Method * Kaffe_get_class_methods(struct Hjava_lang_Class * clazz){  return clazz->cache.methods;}/** * set array of methods in class. * * @param clazz the class * @param methods the methods to set */static inline void Kaffe_set_class_methods(struct Hjava_lang_Class * clazz,			Method * methods){  clazz->cache.methods = methods;}/** * get type of elements in an array class. *  * @param arrayclazz the class * * @return  type of elements in the array class */static inline Hjava_lang_Class * Kaffe_get_array_element_type(struct Hjava_lang_Class * arrayclazz){  assert(CLASS_IS_ARRAY(arrayclazz));  return arrayclazz->cache.element_type;}/** * set type of elements in an array class. * * @param arrayclazz the class * @param element_type the type to set */static inline void Kaffe_set_array_element_type(struct Hjava_lang_Class * arrayclazz,			     Hjava_lang_Class * element_type){  assert(CLASS_IS_ARRAY(arrayclazz));  arrayclazz->cache.element_type = element_type;}/** * get array cache of a primitive class. *  * @param primitive_clazz the class * * @return  array_cache of the primitive class */static inline Hjava_lang_Class * Kaffe_get_primitive_array_cache(struct Hjava_lang_Class * primitive_clazz){  assert(CLASS_IS_PRIMITIVE(primitive_clazz));  return primitive_clazz->cache.array_cache;}/** * set array cache in primitive class. * * @param primitive_clazz the class * @param array_cache the new value */static inline void Kaffe_set_primitive_array_cache(struct Hjava_lang_Class * primitive_clazz,			     Hjava_lang_Class * array_cache){  assert(CLASS_IS_PRIMITIVE(primitive_clazz));  primitive_clazz->cache.array_cache = array_cache;}#define TYPE_PRIM_SIZE(CL) ((CL)->size_in_bytes)#define TYPE_SIZE(CL) \  (CLASS_IS_PRIMITIVE(CL) ? TYPE_PRIM_SIZE (CL) : PTR_TYPE_SIZE)#define METHOD_IS_PUBLIC(METH)       ((METH)->accflags & ACC_PUBLIC)#define METHOD_IS_PROTECTED(METH)    ((METH)->accflags & ACC_PROTECTED)#define METHOD_IS_PRIVATE(METH)      ((METH)->accflags & ACC_PRIVATE)#define METHOD_IS_CONSTRUCTOR(METH)  ((METH)->kFlags & KFLAG_CONSTRUCTOR)#define METHOD_IS_STATIC(METH)       ((METH)->accflags & ACC_STATIC)#define METHOD_IS_ABSTRACT(METH)     ((METH)->accflags & ACC_ABSTRACT)#define METHOD_IS_FINAL(METH)        ((METH)->accflags & ACC_FINAL)#define METHOD_IS_STRICT(METH)       ((METH)->accflags & ACC_STRICT)#define METHOD_IS_SYNCHRONISED(METH) ((METH)->accflags & ACC_SYNCHRONISED)#define CLASS_GCJ(C)		((C)->kFlags & KFLAG_GCJ)#define SET_CLASS_GCJ(C)	(C)->kFlags |= KFLAG_GCJ/* For manipulating the constant pool in a class */#define CLASS_CONSTANTS(CL) (&(CL)->constants)#define CLASS_CONST_SIZE(CL) ((CL)->constants.size)#define CLASS_CONST_TAG(CL, IDX) ((CL)->constants.tags[IDX])#define CLASS_CONST_DATA(CL, IDX) ((CL)->constants.data[IDX])#define CLASS_CONST_UTF8(CL, IDX) WORD2UTF(CLASS_CONST_DATA(CL, IDX))#define CLASS_CONST_INT(CL, IDX) ((int32) CLASS_CONST_DATA(CL, IDX))#if SIZEOF_VOID_P == 8#define CLASS_CONST_LONG(CL, IDX) \  ((uint64) CLASS_CONST_DATA(CL, IDX))#else#define CLASS_CONST_LONG(CL, IDX) \  WORDS_TO_LONG ((CL)->constants.data[IDX], (CL)->constants.data[(IDX)+1])#endif#define	CLASS_CONST_DOUBLE(CL, IDX) \  CLASS_CONST_LONG(CL, IDX)/* The first uint16 of the INDEX'th constant pool entry. */#define CLASS_CONST_USHORT1(CL, INDEX) ((CL)->constants.data[INDEX] & 0xFFFF)/* The second uint16 of the INDEX'th constant pool entry. */#define CLASS_CONST_USHORT2(CL, INDEX) \  ((uint16)((CL)->constants.data[INDEX] >> 16))/** * 'processClass' is the core of the class initialiser and can prepare a * class from the cradle to the grave. * * @param clazz The class to process. * @param state The state to achieve during this process. * @param einfo An error which may have occured. * * @returns false if an error has occured, true if everything is ok. */bool			processClass(Hjava_lang_Class* clazz, int state, errorInfo *einfo);/** * This function loads a class using the given class loader if non-NULL else it uses the  * internal bootstrap class loader to fetch classes. The classes are processed to the linked state. * This function must not be used to "load" a class representing array. For that use loadArray. *  * @param name The name of the class to load. * @param loader The loader to use. It may be NULL if you want to use the internal VM class loader. * @param einfo The error structure to fill if something bad happens. * * @returns A valid class object if the load is successful, NULL otherwise. */Hjava_lang_Class*	loadClass(Utf8Const* name, Hjava_lang_ClassLoader* loader, errorInfo *einfo);/** * This function loads an array with the given name and using the given class loader. The array is usable directly * after that call. * * @param name The name of the array to load. * @param loader The loader to use. It may be NULL If you want to use the internal VM class loader. * @param einfo The error structure to fill if something bad happens. * * @returns A valid class object if the load is successful, NULL otherwise. */Hjava_lang_Class*	loadArray(Utf8Const* name, Hjava_lang_ClassLoader* loader, errorInfo *einfo);/** * This function finds a class in a directory or in a jar file. It implements the internal VM class loader. * * @param centry The class entry representing the class to be loaded. * @param einfo The error structure to fill if something bad happens. * * @returns A valid class object if the load is successful, NULL otherwise. */Hjava_lang_Class*	findClass(struct _classEntry* centry, errorInfo *einfo);/** * This function is used at the VM boot to preload some classes. The classes are loaded and put in the linked state. * It cannot return an error. If an error happened the VM is aborted. * * @param clazz A pointer to the place where the class object should be put. * @param name The name of the class to load. */void			loadStaticClass(Hjava_lang_Class** clazz, const char* name);Hjava_lang_Class*	setupClass(Hjava_lang_Class*, constIndex,				   constIndex, u2, Hjava_lang_ClassLoader*, errorInfo*);bool 			addSourceFile(Hjava_lang_Class* c, int idx, errorInfo*);bool			addInnerClasses(Hjava_lang_Class* c, size_t len, struct classFile* fp, errorInfo *info);int			startMethods(Hjava_lang_Class*, u2 methct, errorInfo*);Method*			addMethod(Hjava_lang_Class*, u2 access_flags,				  u2 name_index, u2 signature_index, errorInfo*);Method*			addExceptionMethod(Hjava_lang_Class*, Utf8Const*, Utf8Const*);void 			addMethodCode(Method*, struct _Code*);Field*        		addField(Hjava_lang_Class*, u2 access_flags,				 u2 name_index, u2 signature_index, errorInfo* einfo);void			addInterfaces(Hjava_lang_Class*, u2, Hjava_lang_Class**);void			setFieldValue(Hjava_lang_Class*, Field*, u2);Hjava_lang_Class*	resolveFieldType(Field*, Hjava_lang_Class*, errorInfo*);bool			getInheritedMethodIndex(Hjava_lang_Class *clazz, Method *meth);classEntry*		lookupClassEntry(Utf8Const*, Hjava_lang_ClassLoader*,				errorInfo *info);classEntry*		lookupClassEntryInternal(Utf8Const*,				Hjava_lang_ClassLoader*);int			removeClassEntries(Hjava_lang_ClassLoader*);void 			walkClassEntries(Collector *collector, void *gc_info, Hjava_lang_ClassLoader*);Hjava_lang_Class*	lookupClass(const char*, Hjava_lang_ClassLoader*,				errorInfo*);Hjava_lang_Class*	lookupArray(Hjava_lang_Class*, errorInfo*);Hjava_lang_Class*	lookupObjectArrayClass(Hjava_lang_Class*);Field*			lookupClassField(Hjava_lang_Class*, Utf8Const*, bool, errorInfo *einfo);void			countInsAndOuts(const char*, short*, short*, char*);int			sizeofSigChar(char, bool);int			sizeofSigItem(const char**, bool);int			sizeofSig(const char**, bool);int			sizeofSigMethod(Method *, bool);int			sizeofSigClass(Hjava_lang_Class*, bool);void			establishMethod(Method*);Hjava_lang_Class*	getPrimitiveClassFromSignature(const char);Hjava_lang_Class*	getClassFromSignature(const char*, Hjava_lang_ClassLoader*, errorInfo*);Hjava_lang_Class*	getClassFromSignaturePart(const char*, Hjava_lang_ClassLoader*, errorInfo*);int			countArgsInSignature(const char *);int			KaffeVM_countRealNumberOfArgs(parsed_signature_t *);parsed_signature_t*	parseSignature(Utf8Const *, errorInfo*);int			startFields(Hjava_lang_Class*, u2 fieldct, errorInfo*);void			finishFields(Hjava_lang_Class*);void			destroyClassLoader(Collector *, void *);struct Hjava_lang_String* resolveString(Hjava_lang_Class* clazz, int idx,					errorInfo *einfo);int			findPackageLength(const char *name);/** * Start a search for a class.  If no other thread is searching for this * mapping then the responsibility falls on the current thread. * * @param ce The mapping to start searching for. * @param out_cl A placeholder for the class if it has already been bound. * @param einfo An uninitialized errorInfo object. * * @returns True, if the class is already bound or if this thread should be *   responsible for searching/loading the class.  False, if searching for this *   class would result in a class circularity. */int classMappingSearch(classEntry *ce,		       Hjava_lang_Class **out_cl,		       errorInfo *einfo);/** * Start loading a class. * * @param ce The mapping to start searching for. * @param out_cl A placeholder for the class if it has already been bound. * @param einfo An uninitialized errorInfo object. * * @returns True, if the class is already bound or if this thread should be *   responsible for searching/loading the class.  False, if searching for this *   class would result in a class circularity. */int classMappingLoad(classEntry *ce,		     Hjava_lang_Class **out_cl,		     errorInfo *einfo);/** * Transition a mapping to the loaded state. * * ce - The name mapping whose state should be updated. * cl - The class object that should be bound to this mapping. * return - The value of "cl" if the mapping wasn't already updated, otherwise, *   it will be the value previously stored in the mapping. */Hjava_lang_Class *classMappingLoaded(classEntry *ce, Hjava_lang_Class *cl);/** * Force a mapping to a particular state. * * ce - The name mapping whose state should be updated. * nms - The state the mapping should be set to. */void setClassMappingState(classEntry *ce, name_mapping_state_t nms);/** * This function walks through the class pool and execute the given function * for each class of the pool. * * @param walker A class walker. * @param param A user parameter. */void walkClassPool(int (*walker)(Hjava_lang_Class *clazz, void *), void *param);/** * Initialize internal global variables of the class pool. */void KaffeVM_initClassPool(void);/** * Test if a method is a native method. * * @param meth method to test. * @return true if the method is a native method. */bool methodIsNative(Method * method);extern Utf8Const* init_name;		/* "<clinit>" */extern Utf8Const* constructor_name;	/* "<init>" */extern Utf8Const* final_name;		/* "finalize" */extern Utf8Const* void_signature;	/* "()V" */extern Utf8Const* Code_name;		/* "Code" */extern Utf8Const* LineNumberTable_name;	/* "LineNumberTable" */extern Utf8Const* LocalVariableTable_name;	/* "LocalVariableTable" */extern Utf8Const* ConstantValue_name;	/* "ConstantValue" */extern Utf8Const* Exceptions_name;	/* "Exceptions" */extern Utf8Const* SourceFile_name;	/* "SourceFile" */extern Utf8Const* InnerClasses_name;	/* "InnerClasses" */extern Utf8Const* Signature_name;       /* "Signature" */extern Utf8Const* Synthetic_name;       /* "Synthetic" */extern Utf8Const* EnclosingMethod_name;  /* "EnclosingMethod" */void initialiseSecurity (void);/** * get super class for a given class. * * @param class the class * * @return superclass of class */static inline struct Hjava_lang_Class* getSuperclass(struct Hjava_lang_Class* class){  return class->superclass;}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?