⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kni.c

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 C
📖 第 1 页 / 共 4 页
字号:
    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return 0;    return (jbyte)(object->data[fid->u.offset].cell);}jchar KNI_GetCharField(jobject objectHandle, jfieldID fid) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return 0;    return (jchar)(object->data[fid->u.offset].cell);}jshort KNI_GetShortField(jobject objectHandle, jfieldID fid) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return 0;    return (jshort)(object->data[fid->u.offset].cell);}jint KNI_GetIntField(jobject objectHandle, jfieldID fid) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return 0;    return (jint)(object->data[fid->u.offset].cell);}jlong KNI_GetLongField(jobject objectHandle, jfieldID fid) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    union {        jlong j; /* Platform dependent */        cell v[2];    } tmp;    int offset = fid->u.offset;    tmp.v[0] = object->data[offset+0].cell;    tmp.v[1] = object->data[offset+1].cell;    return tmp.j;}#if IMPLEMENTS_FLOATjfloat KNI_GetFloatField(jobject objectHandle, jfieldID fid) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return 0;    return *(jfloat*)&(object->data[fid->u.offset].cell);}jdouble KNI_GetDoubleField(jobject objectHandle, jfieldID fid) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    union {        jdouble d; /* Platform dependent */        cell v[2];    } tmp;    int offset = fid->u.offset;    tmp.v[0] = object->data[offset+0].cell;    tmp.v[1] = object->data[offset+1].cell;    return tmp.d;}#endif/*======================================================================= * FUNCTION:       KNI_GetObjectField() * OVERVIEW:       Return the value of an instance field  *                 containing an object. No type checking is *                 performed. * INTERFACE: *   parameter(s): objectHandle: handle to an object whose field  *                 is to be accessed *                 fid: a fieldID *                 toHandle: handle to which the value is to  *                 be assigned *   returns:      nothing directly, but 'toHandle' will contain *                 the value of the field *=======================================================================*/void KNI_GetObjectField(jobject objectHandle, jfieldID fid, jobject toHandle) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    KNI_SETHAND(toHandle, object->data[fid->u.offset].cell);}/*======================================================================= * FUNCTION:       KNI_Set<Type>Field() * OVERVIEW:       Set the value of a primitive instance field. *                 No type checking is performed. * INTERFACE: *   parameter(s): objectHandle: handle to an object whose field *                 is to be changed. *                 fid: a fieldID *                 value: the value to be assigned *   returns:      <nothing> *=======================================================================*/void KNI_SetBooleanField(jobject objectHandle, jfieldID fid, jboolean value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    object->data[fid->u.offset].cell = value;}void KNI_SetByteField(jobject objectHandle, jfieldID fid, jbyte value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    object->data[fid->u.offset].cell = value;}void KNI_SetCharField(jobject objectHandle, jfieldID fid, jchar value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    object->data[fid->u.offset].cell = value;}void KNI_SetShortField(jobject objectHandle, jfieldID fid, jshort value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    object->data[fid->u.offset].cell = value;}void KNI_SetIntField(jobject objectHandle, jfieldID fid, jint value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    object->data[fid->u.offset].cell = value;}void KNI_SetLongField(jobject objectHandle, jfieldID fid, jlong value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    union {        jlong j; /* Platform dependent */        cell v[2];    } tmp;    int offset = fid->u.offset;    tmp.j = value;    object->data[offset+0].cell = tmp.v[0];    object->data[offset+1].cell = tmp.v[1];}#if IMPLEMENTS_FLOATvoid KNI_SetFloatField(jobject objectHandle, jfieldID fid, jfloat value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    *(jfloat*)&object->data[fid->u.offset].cell = value;}void KNI_SetDoubleField(jobject objectHandle, jfieldID fid, jdouble value) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    union {        jdouble d; /* Platform dependent */        cell v[2];    } tmp;    int offset = fid->u.offset;    tmp.d = value;    object->data[offset+0].cell = tmp.v[0];    object->data[offset+1].cell = tmp.v[1];}#endif/*======================================================================= * FUNCTION:       KNI_SetObjectField() * OVERVIEW:       Set the value of an instance field containing *                 an object.  No type checking is performed. * INTERFACE: *   parameter(s): objectHandle: a handle to an object whose field *                 is to be changed. *                 fid: a fieldID *                 fromHandle: a handle to an object that is to be *                 to be assigned to 'toHandle'. *   returns:      <nothing> *=======================================================================*/void KNI_SetObjectField(jobject objectHandle, jfieldID fid, jobject fromHandle) {    INSTANCE object = (INSTANCE)KNI_UNHAND(objectHandle);    if (INCLUDEDEBUGCODE && (object == 0 || fid == 0)) return;    object->data[fid->u.offset].cell = (cell)KNI_UNHAND(fromHandle);}/*========================================================================= * Static field access *=======================================================================*//*========================================================================= * FUNCTION:       KNI_GetStaticFieldID() * OVERVIEW:       Get the fieldID of the static field with the given *                 name and signature.  This operation is used before *                 accessing the static variables of an object. * INTERFACE: *   parameter(s): - classHandle: handle to a class *                 - name: UTF8 string containing the name of the field. *                 - signature: UTF8 string containing the signature *                   of the field (using the standard Java field *                   signature format, e.g., "I", "Ljava/lang/Object;") *   returns:      - A jfieldID *=======================================================================*/jfieldIDKNI_GetStaticFieldID(jclass classHandle, const char* name, const char* signature) {    FIELD field;    INSTANCE_CLASS clazz = (INSTANCE_CLASS)KNI_UNHAND(classHandle);    if (clazz == 0) return NULL;    field = lookupField(clazz, getNameAndTypeKey(name, signature));    return (jfieldID)(field == NULL || field->accessFlags & ACC_STATIC)                     ? field : NULL;}/*======================================================================= * FUNCTION:       KNI_GetStatic<Type>Field() * OVERVIEW:       Return the value of a primitive static field. *                 No type checking is performed. * INTERFACE: *   parameter(s): classHandle: handle to an class *                 fid: a fieldID *   returns:      The value of the field * NOTE:           The KVM implementation of KNI does not need the *                 'classHandle' parameter. *=======================================================================*/jbooleanKNI_GetStaticBooleanField(jclass classHandle, jfieldID fid) {    if (INCLUDEDEBUGCODE && fid == 0) return 0;    return *((jint*)fid->u.staticAddress);}jbyteKNI_GetStaticByteField(jclass classHandle, jfieldID fid) {    if (INCLUDEDEBUGCODE && fid == 0) return 0;    return *((jint*)fid->u.staticAddress);}jcharKNI_GetStaticCharField(jclass classHandle, jfieldID fid) {    if (INCLUDEDEBUGCODE && fid == 0) return 0;    return *((jint*)fid->u.staticAddress);}jshortKNI_GetStaticShortField(jclass classHandle, jfieldID fid) {    if (INCLUDEDEBUGCODE && fid == 0) return 0;    return *((jint*)fid->u.staticAddress);}jintKNI_GetStaticIntField(jclass classHandle, jfieldID fid) {    if (INCLUDEDEBUGCODE && fid == 0) return 0;    return *((jint*)fid->u.staticAddress);}jlongKNI_GetStaticLongField(jclass classHandle, jfieldID fid) {    union {        jlong j; /* Platform dependent */        cell v[2];    } tmp;    tmp.v[0] = *((cell*)fid->u.staticAddress);    tmp.v[1] = *((cell*)fid->u.staticAddress + 1);    return tmp.j;}#if IMPLEMENTS_FLOATjfloatKNI_GetStaticFloatField(jclass classHandle, jfieldID fid) {    return *((jfloat*)fid->u.staticAddress);}jdoubleKNI_GetStaticDoubleField(jclass classHandle, jfieldID fid) {    union {        jdouble d; /* Platform dependent */        cell v[2];    } tmp;    tmp.v[0] = *((cell*)fid->u.staticAddress);    tmp.v[1] = *((cell*)fid->u.staticAddress + 1);    return tmp.d;}#endif/*======================================================================= * FUNCTION:       KNI_GetStaticObjectField() * OVERVIEW:       Return the value of a static field  *                 containing an object. No type checking is *                 performed. * INTERFACE: *   parameter(s): classHandle: handle to a class whose field  *                 is to be accessed *                 fid: a fieldID *                 toHandle: handle to which the value is to  *                 be assigned *   returns:      nothing directly, but 'toHandle' will contain *                 the value of the field * NOTE:           The KVM implementation of KNI does not need the *                 'classHandle' parameter. *=======================================================================*/void KNI_GetStaticObjectField(jclass classHandle, jfieldID fid, jobject toHandle) {    if (INCLUDEDEBUGCODE && fid == 0) return;    KNI_SETHAND(toHandle, *((cell*)fid->u.staticAddress));}/*=======================================================================

⌨️ 快捷键说明

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