Mercurial > dwindows
comparison android/dw.cpp @ 2482:4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
Make eventHandler() second View and string parameters nullable.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 26 Apr 2021 18:34:51 +0000 |
parents | 94f0d61d6953 |
children | 9f7af6d8c6a4 |
comparison
equal
deleted
inserted
replaced
2481:94f0d61d6953 | 2482:4888503c3e3e |
---|---|
346 const char *utf81 = str1 ? env->GetStringUTFChars(str1, NULL) : NULL; | 346 const char *utf81 = str1 ? env->GetStringUTFChars(str1, NULL) : NULL; |
347 const char *utf82 = str2 ? env->GetStringUTFChars(str2, NULL) : NULL; | 347 const char *utf82 = str2 ? env->GetStringUTFChars(str2, NULL) : NULL; |
348 void *params[8] = { (void *)obj2, (void *)utf81, (void *)utf82, | 348 void *params[8] = { (void *)obj2, (void *)utf81, (void *)utf82, |
349 DW_INT_TO_POINTER(int1), DW_INT_TO_POINTER(int2), | 349 DW_INT_TO_POINTER(int1), DW_INT_TO_POINTER(int2), |
350 DW_INT_TO_POINTER(int3), DW_INT_TO_POINTER(int4), NULL }; | 350 DW_INT_TO_POINTER(int3), DW_INT_TO_POINTER(int4), NULL }; |
351 | |
351 return _dw_event_handler(obj1, params, message); | 352 return _dw_event_handler(obj1, params, message); |
352 } | 353 } |
353 | 354 |
354 /* This function adds a signal handler callback into the linked list. | 355 /* This function adds a signal handler callback into the linked list. |
355 */ | 356 */ |
541 */ | 542 */ |
542 void API dw_debug(const char *format, ...) | 543 void API dw_debug(const char *format, ...) |
543 { | 544 { |
544 va_list args; | 545 va_list args; |
545 char outbuf[1025] = {0}; | 546 char outbuf[1025] = {0}; |
547 JNIEnv *env; | |
546 | 548 |
547 va_start(args, format); | 549 va_start(args, format); |
548 vsnprintf(outbuf, 1024, format, args); | 550 vsnprintf(outbuf, 1024, format, args); |
549 va_end(args); | 551 va_end(args); |
550 | 552 |
551 /* Output to stderr, if there is another way to send it | 553 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
552 * on the implementation platform, change this. | 554 { |
553 */ | 555 // Construct a String |
554 fprintf(stderr, "%s", outbuf); | 556 jstring jstr = env->NewStringUTF(outbuf); |
557 // First get the class that contains the method you need to call | |
558 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
559 // Get the method that you want to call | |
560 jmethodID debugMessage = env->GetMethodID(clazz, "debugMessage", | |
561 "(Ljava/lang/String;)V"); | |
562 // Call the method on the object | |
563 env->CallVoidMethod(_dw_obj, debugMessage, jstr); | |
564 } | |
565 else { | |
566 /* Output to stderr, if there is another way to send it | |
567 * on the implementation platform, change this. | |
568 */ | |
569 fprintf(stderr, "%s", outbuf); | |
570 } | |
555 } | 571 } |
556 | 572 |
557 /* | 573 /* |
558 * Displays a Message Box with given text and title.. | 574 * Displays a Message Box with given text and title.. |
559 * Parameters: | 575 * Parameters: |