Mercurial > dwindows
diff ios/dw.m @ 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 | ec0d34798706 |
children | 3fe7641f027c |
line wrap: on
line diff
--- a/ios/dw.m Sat Dec 24 14:28:39 2022 +0000 +++ b/ios/dw.m Sun Dec 25 00:20:49 2022 +0000 @@ -4366,13 +4366,17 @@ void API dw_debug(const char *format, ...) { va_list args; - char outbuf[1025] = {0}; va_start(args, format); - vsnprintf(outbuf, 1024, format, args); + dw_vdebug(format, args); va_end(args); - - NSLog(@"%s", outbuf); +} + +void API dw_vdebug(const char *format, va_list args) +{ + NSString *nformat = [[NSString stringWithUTF8String:format] autorelease]; + + NSLogv(nformat, args); } /* @@ -4385,6 +4389,17 @@ */ int API dw_messagebox(const char *title, int flags, const char *format, ...) { + va_list args; + int rc; + + va_start(args, format); + 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) +{ NSInteger iResponse; NSString *button1 = @"OK"; NSString *button2 = nil; @@ -4393,7 +4408,6 @@ NSString *mtext; UIAlertControllerStyle mstyle = UIAlertControllerStyleAlert; NSArray *params; - va_list args; static int in_mb = FALSE; /* Prevent recursion */ @@ -4417,9 +4431,7 @@ button3 = @"Cancel"; } - va_start(args, format); mtext = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args]; - va_end(args); params = [NSMutableArray arrayWithObjects:mtitle, mtext, [NSNumber numberWithInteger:mstyle], button1, button2, button3, nil]; [DWObj safeCall:@selector(messageBox:) withObject:params];