Changeset 2913
- Timestamp:
- Dec 25, 2022, 1:20:49 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/android/dw.cpp ¶
r2868 r2913 1167 1167 { 1168 1168 va_list args; 1169 char outbuf[1025] = {0};1170 JNIEnv *env;1171 1169 1172 1170 va_start(args, format); 1173 v snprintf(outbuf, 1024, format, args);1171 vfprintf(stderr, format, args); 1174 1172 va_end(args); 1173 } 1174 1175 void API dw_vdebug(const char *format, va_list args) 1176 { 1177 JNIEnv *env; 1175 1178 1176 1179 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 1177 1180 { 1181 char outbuf[1025] = {0}; 1182 1183 vsnprintf(outbuf, 1024, format, args); 1184 1178 1185 // Construct a String 1179 1186 jstring jstr = env->NewStringUTF(outbuf); … … 1192 1199 * on the implementation platform, change this. 1193 1200 */ 1194 fprintf(stderr, "%s", outbuf);1201 vfprintf(stderr, format, args); 1195 1202 } 1196 1203 } … … 1210 1217 { 1211 1218 va_list args; 1212 char outbuf[1025] = {0}; 1219 int rc; 1220 1221 va_start(args, format); 1222 rc = dw_vmessagebox(title, flags, format, args); 1223 va_end(args); 1224 return rc; 1225 } 1226 1227 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 1228 { 1213 1229 JNIEnv *env; 1214 1230 int retval = 0; 1215 1231 1216 va_start(args, format);1217 vsnprintf(outbuf, 1024, format, args);1218 va_end(args);1219 1220 1232 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 1221 1233 { 1234 char outbuf[1025] = {0}; 1235 1236 vsnprintf(outbuf, 1024, format, args); 1237 1222 1238 // Construct a String 1223 1239 jstring jstr = env->NewStringUTF(outbuf); -
TabularUnified trunk/dw.h ¶
r2876 r2913 2188 2188 void API dw_beep(int freq, int dur); 2189 2189 void API dw_debug(const char *format, ...); 2190 void API dw_vdebug(const char *format, va_list args); 2190 2191 int API dw_messagebox(const char *title, int flags, const char *format, ...); 2192 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args); 2191 2193 void API dw_environment_query(DWEnv *env); 2192 2194 int API dw_exec(const char *program, int type, char **params); -
TabularUnified trunk/dw.hpp ¶
r2912 r2913 1396 1396 void MainQuit() { dw_main_quit(); } 1397 1397 void Exit(int exitcode) { dw_exit(exitcode); } 1398 int MessageBox(const char *title, int flags, const char *format) { return dw_messagebox(title, flags, format); } 1398 int MessageBox(const char *title, int flags, const char *format, ...) { 1399 int retval; 1400 va_list args; 1401 1402 va_start(args, format); 1403 retval = dw_vmessagebox(title, flags, format, args); 1404 va_end(args); 1405 1406 return retval; 1407 } 1408 void Debug(const char *format, ...) { 1409 va_list args; 1410 1411 va_start(args, format); 1412 dw_vdebug(format, args); 1413 va_end(args); 1414 } 1399 1415 }; 1400 1416 -
TabularUnified trunk/gtk/dw.c ¶
r2872 r2913 2527 2527 { 2528 2528 va_list args; 2529 char outbuf[1025] = {0};2530 2529 2531 2530 va_start(args, format); 2532 v snprintf(outbuf, 1024, format, args);2531 vfprintf(stderr, format, args); 2533 2532 va_end(args); 2534 2535 fprintf(stderr, "%s", outbuf); 2533 } 2534 2535 void API dw_vdebug(const char *format, va_list args) 2536 { 2537 vfprintf(stderr, format, args); 2536 2538 } 2537 2539 … … 2544 2546 * ...: Additional variables for use in the format. 2545 2547 */ 2546 int dw_messagebox(const char *title, int flags, const char *format, ...) 2548 int API dw_messagebox(const char *title, int flags, const char *format, ...) 2549 { 2550 va_list args; 2551 int rc; 2552 2553 va_start(args, format); 2554 rc = dw_vmessagebox(title, flags, format, args); 2555 va_end(args); 2556 return rc; 2557 } 2558 2559 int dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 2547 2560 { 2548 2561 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext; 2549 2562 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; 2550 2563 DWDialog *dwwait; 2551 va_list args;2552 2564 char outbuf[1025] = {0}; 2553 2565 char **xpm_data = NULL; … … 2555 2567 int width,height; 2556 2568 2557 va_start(args, format);2558 2569 vsnprintf(outbuf, 1024, format, args); 2559 va_end(args);2560 2570 2561 2571 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); -
TabularUnified trunk/gtk3/dw.c ¶
r2872 r2913 2372 2372 { 2373 2373 va_list args; 2374 char outbuf[1025] = {0};2375 2374 2376 2375 va_start(args, format); 2377 v snprintf(outbuf, 1024, format, args);2376 vfprintf(stderr, format, args); 2378 2377 va_end(args); 2379 2380 fprintf(stderr, "%s", outbuf); 2378 } 2379 2380 void API dw_vdebug(const char *format, va_list args) 2381 { 2382 vfprintf(stderr, format, args); 2381 2383 } 2382 2384 … … 2389 2391 * ...: Additional variables for use in the format. 2390 2392 */ 2391 int dw_messagebox(const char *title, int flags, const char *format, ...) 2393 int API dw_messagebox(const char *title, int flags, const char *format, ...) 2394 { 2395 va_list args; 2396 int rc; 2397 2398 va_start(args, format); 2399 rc = dw_vmessagebox(title, flags, format, args); 2400 va_end(args); 2401 return rc; 2402 } 2403 2404 int dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 2392 2405 { 2393 2406 GtkMessageType gtkicon = GTK_MESSAGE_OTHER; … … 2395 2408 GtkWidget *dialog; 2396 2409 int response, _dw_locked_by_me = FALSE; 2397 va_list args;2398 2410 char outbuf[1025] = {0}; 2399 2411 2400 va_start(args, format);2401 2412 vsnprintf(outbuf, 1024, format, args); 2402 va_end(args);2403 2413 2404 2414 if(flags & DW_MB_ERROR) -
TabularUnified trunk/gtk4/dw.c ¶
r2872 r2913 1781 1781 { 1782 1782 va_list args; 1783 char outbuf[1025] = {0};1784 1783 1785 1784 va_start(args, format); 1786 v snprintf(outbuf, 1024, format, args);1785 vfprintf(stderr, format, args); 1787 1786 va_end(args); 1788 1789 fprintf(stderr, "%s", outbuf); 1787 } 1788 1789 void API dw_vdebug(const char *format, va_list args) 1790 { 1791 vfprintf(stderr, format, args); 1790 1792 } 1791 1793 … … 1868 1870 { 1869 1871 va_list args; 1872 int rc; 1873 1874 va_start(args, format); 1875 rc = dw_vmessagebox(title, flags, format, args); 1876 va_end(args); 1877 return rc; 1878 } 1879 1880 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 1881 { 1870 1882 char outbuf[1025] = {0}; 1871 1883 1872 va_start(args, format);1873 1884 vsnprintf(outbuf, 1024, format, args); 1874 va_end(args);1875 1876 1885 return dw_messagebox_int(title, flags, outbuf); 1877 1886 } -
TabularUnified trunk/ios/dw.m ¶
r2900 r2913 4367 4367 { 4368 4368 va_list args; 4369 char outbuf[1025] = {0};4370 4369 4371 4370 va_start(args, format); 4372 vsnprintf(outbuf, 1024,format, args);4371 dw_vdebug(format, args); 4373 4372 va_end(args); 4374 4375 NSLog(@"%s", outbuf); 4373 } 4374 4375 void API dw_vdebug(const char *format, va_list args) 4376 { 4377 NSString *nformat = [[NSString stringWithUTF8String:format] autorelease]; 4378 4379 NSLogv(nformat, args); 4376 4380 } 4377 4381 … … 4385 4389 */ 4386 4390 int API dw_messagebox(const char *title, int flags, const char *format, ...) 4391 { 4392 va_list args; 4393 int rc; 4394 4395 va_start(args, format); 4396 rc = dw_vmessagebox(title, flags, format, args); 4397 va_end(args); 4398 return rc; 4399 } 4400 4401 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 4387 4402 { 4388 4403 NSInteger iResponse; … … 4394 4409 UIAlertControllerStyle mstyle = UIAlertControllerStyleAlert; 4395 4410 NSArray *params; 4396 va_list args;4397 4411 static int in_mb = FALSE; 4398 4412 … … 4418 4432 } 4419 4433 4420 va_start(args, format);4421 4434 mtext = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args]; 4422 va_end(args);4423 4435 4424 4436 params = [NSMutableArray arrayWithObjects:mtitle, mtext, [NSNumber numberWithInteger:mstyle], button1, button2, button3, nil]; -
TabularUnified trunk/mac/dw.m ¶
r2899 r2913 4351 4351 { 4352 4352 va_list args; 4353 char outbuf[1025] = {0};4354 4353 4355 4354 va_start(args, format); 4356 vsnprintf(outbuf, 1024,format, args);4355 dw_vdebug(format, args); 4357 4356 va_end(args); 4358 4359 NSLog(@"%s", outbuf); 4357 } 4358 4359 void API dw_vdebug(const char *format, va_list args) 4360 { 4361 NSString *nformat = [[NSString stringWithUTF8String:format] autorelease]; 4362 4363 NSLogv(nformat, args); 4360 4364 } 4361 4365 … … 4369 4373 */ 4370 4374 int API dw_messagebox(const char *title, int flags, const char *format, ...) 4375 { 4376 va_list args; 4377 int rc; 4378 4379 va_start(args, format); 4380 rc = dw_vmessagebox(title, flags, format, args); 4381 va_end(args); 4382 return rc; 4383 } 4384 4385 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 4371 4386 { 4372 4387 NSInteger iResponse; … … 4378 4393 NSAlertStyle mstyle = DWAlertStyleWarning; 4379 4394 NSArray *params; 4380 va_list args;4381 4395 4382 4396 if(flags & DW_MB_OKCANCEL) … … 4396 4410 } 4397 4411 4398 va_start(args, format);4399 4412 mtext = [[[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args] autorelease]; 4400 va_end(args);4401 4413 4402 4414 if(flags & DW_MB_ERROR) -
TabularUnified trunk/os2/dw.c ¶
r2865 r2913 4674 4674 { 4675 4675 va_list args; 4676 4677 va_start(args, format); 4678 vfprintf(stderr, format, args); 4679 va_end(args); 4680 } 4681 4682 void API dw_vdebug(const char *format, va_list args) 4683 { 4676 4684 char outbuf[1025] = { 0 }; 4677 4685 4678 va_start(args, format);4679 4686 #if defined(__IBMC__) 4680 4687 vsprintf(outbuf, format, args); … … 4682 4689 vsnprintf(outbuf, 1024, format, args); 4683 4690 #endif 4684 va_end(args);4685 4691 4686 4692 if(_PmPrintfString) … … 4708 4714 { 4709 4715 va_list args; 4716 int rc; 4717 4718 va_start(args, format); 4719 rc = dw_vmessagebox(title, flags, format, args); 4720 va_end(args); 4721 return rc; 4722 } 4723 4724 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 4725 { 4710 4726 char outbuf[1025] = { 0 }; 4711 4727 int rc; 4712 4728 4713 va_start(args, format);4714 4729 #if defined(__IBMC__) 4715 4730 vsprintf(outbuf, format, args); … … 4717 4732 vsnprintf(outbuf, 1024, format, args); 4718 4733 #endif 4719 va_end(args);4720 4734 4721 4735 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (PSZ)outbuf, (PSZ)title, 0, flags | MB_MOVEABLE); -
TabularUnified trunk/os2/dw.def ¶
r2543 r2913 29 29 _dw_init_thread @30 30 30 _dw_deinit_thread @31 31 32 dw_vdebug @35 33 dw_vmessagebox @36 31 34 32 35 dw_box_new @40 -
TabularUnified trunk/readme.txt ¶
r2887 r2913 67 67 Added C++ language bindings in dw.hpp and an example C++ test 68 68 application in the form of dwtestoo.cpp, similar to godwindows. 69 69 Added variadic versions of dw_debug() and dw_messagebox(). 70 This is how the standard library does it so we can call the new 71 va_list versions from C++: dw_vdebug() and dw_vmessagebox(). 70 72 71 73 Dynamic Windows Documentation is available at: -
TabularUnified trunk/template/dw.c ¶
r2864 r2913 361 361 { 362 362 va_list args; 363 char outbuf[1025] = {0};364 363 365 364 va_start(args, format); 366 v snprintf(outbuf, 1024, format, args);365 vfprintf(stderr, format, args); 367 366 va_end(args); 368 369 /* Output to stderr, if there is another way to send it 370 * on the implementation platform, change this. 371 */ 372 fprintf(stderr, "%s", outbuf);367 } 368 369 void API dw_vdebug(const char *format, va_list args) 370 { 371 vfprintf(stderr, format, args); 373 372 } 374 373 … … 385 384 */ 386 385 int API dw_messagebox(const char *title, int flags, const char *format, ...) 386 { 387 va_list args; 388 int rc; 389 390 va_start(args, format); 391 rc = dw_vmessagebox(title, flags, format, args); 392 va_end(args); 393 return rc; 394 } 395 396 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 387 397 { 388 398 return 0; -
TabularUnified trunk/win/dw.c ¶
r2864 r2913 5058 5058 { 5059 5059 va_list args; 5060 5061 va_start(args, format); 5062 dw_vdebug(format, args); 5063 va_end(args); 5064 } 5065 5066 void API dw_vdebug(const char *format, va_list args) 5067 { 5060 5068 char outbuf[1025] = {0}, *thisbuf = outbuf; 5061 5069 5062 va_start(args, format);5063 5070 vsnprintf(outbuf, 1024, format, args); 5064 va_end(args);5065 5066 5071 OutputDebugString(UTF8toWide(thisbuf)); 5067 5072 } … … 5077 5082 { 5078 5083 va_list args; 5084 int rc; 5085 5086 va_start(args, format); 5087 rc = dw_vmessagebox(title, flags, format, args); 5088 va_end(args); 5089 return rc; 5090 } 5091 5092 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) 5093 { 5079 5094 char outbuf[1025] = { 0 }, *thisbuf = outbuf; 5080 5095 int rc; 5081 5096 5082 va_start(args, format);5083 5097 vsnprintf(outbuf, 1024, format, args); 5084 va_end(args);5085 5098 5086 5099 rc = MessageBox(HWND_DESKTOP, UTF8toWide(thisbuf), UTF8toWide(title), flags); -
TabularUnified trunk/win/dw.def ¶
r2543 r2913 27 27 _dw_init_thread @30 28 28 _dw_deinit_thread @31 29 30 dw_vdebug @35 31 dw_vmessagebox @36 29 32 30 33 dw_box_new @40
Note:
See TracChangeset
for help on using the changeset viewer.