Mercurial > dwindows
diff android/dw.cpp @ 2901:761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
dw_vdebug() and dw_vmessagebox() work similarly to the standard library versions.
DW::App:Debug() and DW::App:MessageBox() use them for variable arguments.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 25 Dec 2022 00:20:49 +0000 |
parents | de1a0cd26691 |
children | 3fe7641f027c |
line wrap: on
line diff
--- a/android/dw.cpp Sat Dec 24 14:28:39 2022 +0000 +++ b/android/dw.cpp Sun Dec 25 00:20:49 2022 +0000 @@ -1166,15 +1166,22 @@ void API dw_debug(const char *format, ...) { va_list args; - char outbuf[1025] = {0}; - JNIEnv *env; va_start(args, format); - vsnprintf(outbuf, 1024, format, args); + vfprintf(stderr, format, args); va_end(args); +} + +void API dw_vdebug(const char *format, va_list args) +{ + JNIEnv *env; if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) { + char outbuf[1025] = {0}; + + vsnprintf(outbuf, 1024, format, args); + // Construct a String jstring jstr = env->NewStringUTF(outbuf); // First get the class that contains the method you need to call @@ -1191,7 +1198,7 @@ /* Output to stderr, if there is another way to send it * on the implementation platform, change this. */ - fprintf(stderr, "%s", outbuf); + vfprintf(stderr, format, args); } } @@ -1209,16 +1216,25 @@ int API dw_messagebox(const char *title, int flags, const char *format, ...) { va_list args; - char outbuf[1025] = {0}; - JNIEnv *env; - int retval = 0; + int rc; va_start(args, format); - vsnprintf(outbuf, 1024, format, args); + rc = dw_vmessagebox(title, flags, format, args); va_end(args); + return rc; +} + +int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) +{ + JNIEnv *env; + int retval = 0; if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) { + char outbuf[1025] = {0}; + + vsnprintf(outbuf, 1024, format, args); + // Construct a String jstring jstr = env->NewStringUTF(outbuf); jstring jstrtitle = env->NewStringUTF(title);