// The name is ambiguous, but the main purpose here is dry things out a bit
// and let us do a better job of reporting errors albeit not halting.
// This is necessary in the threaded callbacks where access to the interpreter 
// is unavailable:
int report(int result) {
  if (result == EPHIDGET_OK) return result;

  const char *description;
  CPhidget_getErrorDescription(result, &description);

  CPhidget_log(PHIDGET_LOG_ERROR, "N/A", "PhidgetNative report error: %s", description);

  return result;
}
JNIEXPORT void JNICALL
Java_com_phidgets_Phidget_nativeLog(JNIEnv *env, jclass cls, jint level, jstring id, jstring log)
{
	int error;
    jboolean iscopy1;
    const char *textString1 = (*env)->GetStringUTFChars(
                env, id, &iscopy1);
    jboolean iscopy2;
    const char *textString2 = (*env)->GetStringUTFChars(
                env, log, &iscopy2);
	if ((error = CPhidget_log(level, (char *)textString1, (char *)textString2)))
		PH_THROW(error);
	(*env)->ReleaseStringUTFChars(env, id, textString1);
	(*env)->ReleaseStringUTFChars(env, log, textString2);
}
Beispiel #3
0
int _log(CPhidgetLog_level l, const char * id, const char * message) {
  return CPhidget_log(l, id, message);
}