00001
00017 #include "CoreMidi4JUtilities.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 void ThrowException(JNIEnv *env, CFStringRef function, OSStatus status) {
00029
00030 CFMutableStringRef string = CFStringCreateMutable(NULL, 0);
00031
00032
00033 if (string) {
00034
00035 CFStringAppend(string, CFSTR("Exception in CoreMIDI JNI Library by \""));
00036 CFStringAppend(string, function);
00037 CFStringAppend(string, CFSTR("\" - OS STatus Code: "));
00038 CFStringAppend(string, CFStringCreateWithFormat(NULL, NULL, CFSTR("%8.8x"), status));
00039
00040 }
00041
00042 jclass Exception = env->FindClass("uk/co/xfactorylibrarians/coremidi4j/CoreMidiException");
00043 env->ThrowNew(Exception,CFStringGetCStringPtr(CFStringCreateCopy(NULL, string), kCFStringEncodingMacRoman ));
00044
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054 void printJniStatus(int status) {
00055
00056 switch (status) {
00057
00058 case JNI_OK:
00059 std::cout << "JNI_OK - success";
00060 break;
00061
00062 case JNI_ERR:
00063 std::cout << "JNI_ERR - unknown error";
00064 break;
00065
00066 case JNI_EDETACHED:
00067 std::cout << "JNI_EDETACHED - thread detached from the VM";
00068 break;
00069
00070 case JNI_EVERSION:
00071 std::cout << "JNI_EVERSION - JNI version error";
00072 break;
00073
00074 case JNI_ENOMEM:
00075 std::cout << "JNI_ENOMEM - not enough memory";
00076 break;
00077
00078 case JNI_EEXIST:
00079 std::cout << "JNI_EEXIST - VM already created";
00080 break;
00081
00082 case JNI_EINVAL:
00083 std::cout << "JNI_EINVAL - invalid arguments";
00084 break;
00085
00086 default:
00087 std::cout << "!! Undefined Error Code";
00088 break;
00089
00090 }
00091
00092 std::cout << std::endl;
00093
00094 }
00095