1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * This source file is part of SableVM. * 3 * * 4 * See the file "LICENSE" for the copyright information and for * 5 * the terms and conditions for copying, distribution and * 6 * modification of this source file. * 7 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 8 9 #ifndef SVM_UTIL_H 10 #define SVM_UTIL_H 11 12 #define _svmm_global_copy_jobject(env,src,dest) \ 13 _svmh_global_copy_jobject (env, src, &dest) 14 15 #define _svmm_zero_memory(var) \ 16 memset(&var, 0, sizeof(var)) 17 18 #define _svmm_set_flag(value,flag) \ 19 _svmh_set_flag(&value, flag) 20 21 #define _svmm_clear_flag(value,flag) \ 22 _svmh_clear_flag(&value, flag) 23 24 #define _svmm_validate_min_max_increment(min,max,incr) \ 25 _svmh_validate_min_max_increment (&min, &max, &incr) 26 27 #define CANNOT_DREF(structure) (*(structure) == NULL) 28 #define CAN_DREF(structure) (*(structure) != NULL) 29 #define DREF(structure,member) ((*(structure))->member) 30 31 #define _svmm_new_native_global_array(env, arrayref) \ 32 _svmh_new_native_global_array (env, &arrayref) 33 34 #define _svmm_free_native_global_array(env, arrayref) \ 35 _svmh_free_native_global_array (env, &arrayref) 36 37 #define _svmm_new_native_local_array(env, arrayref) \ 38 _svmh_new_native_local_array (env, &arrayref) 39 40 #define _svmm_free_native_local_array(env, arrayref) \ 41 _svmh_free_native_local_array (env, &arrayref) 42 43 #define _svmm_local_wrap_pointer(env, pointer, wrapper) \ 44 _svmh_local_wrap_pointer (env, pointer, &wrapper) 45 46 #endif /* NOT SVM_UTIL_H */ 47 48 #ifdef COMMENT 49 50 #define SVM_SET_ARRAY_REFERENCE_ELEMENT(Env,Instance,Index,Value) \ 51 { \ 52 _svmt_array_instance *_array_ = (_svmt_array_instance *) (Instance); \ 53 _svmt_array_info *_array_info_ = (_svmt_array_info *) (_array_->vtable->type); \ 54 jint _dimensions_ = _array_info_->dimensions; \ 55 _svmt_object_instance *_value_ = (_svmt_object_instance *) (Value); \ 56 \ 57 if (_value_ != NULL) \ 58 { \ 59 if (_dimensions_ == 1) \ 60 { \ 61 if (!_svmf_instanceof ((Env), _value_, (_svmt_type_info *) (_array_info_->base_class))) \ 62 { \ 63 goto arraystoreexception; \ 64 } \ 65 } \ 66 else if (!_svmf_instanceof ((Env), _value_, (_svmt_type_info *) (_array_info_->array_element))) \ 67 { \ 68 goto arraystoreexception; \ 69 } \ 70 } \ 71 \ 72 ((_svmt_object_instance **) (Instance))[- _array_->size + (Index)] = (Value); \ 73 WRITE_CARD (((_svmt_object_instance **) (Instance))[- _array_->size + (Index)], ((Env)->vm)); \ 74 } 75 76 char *_svmf_current_working_directory (void); 77 jboolean _svmf_have_same_runtime_package (_svmt_type_info *type1, 78 _svmt_type_info *type2); 79 jint _svmf_max_jint (jint value1, jint value2); 80 81 void _svmf_debug_print_stack_trace (_svmt_JNIEnv *env); 82 jboolean _svmf_instanceof (_svmt_JNIEnv *env, _svmt_object_instance *obj, 83 _svmt_type_info *type); 84 85 #endif /* COMMENT */ 86