[Substrate-commits] SF.net SVN: substrate: [297] trunk
Brought to you by:
landonf
|
From: <la...@us...> - 2006-09-02 00:10:58
|
Revision: 297
http://svn.sourceforge.net/substrate/?rev=297&view=rev
Author: landonf
Date: 2006-09-01 17:10:54 -0700 (Fri, 01 Sep 2006)
Log Message:
-----------
r305@bluefish: landonf | 2006-09-01 15:30:55 -0700
Empty initWithFormat implementation
Modified Paths:
--------------
trunk/Foundation/LFObjCRuntime.h.in
trunk/Foundation/NSString.h
trunk/Foundation/NSString.m
trunk/Tests/NSString.m
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5716
9c4e9a82-0035-45cc-8f88-5282b51d5481:/local/substrate/trunk:304
+ 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5716
9c4e9a82-0035-45cc-8f88-5282b51d5481:/local/substrate/trunk:305
Modified: trunk/Foundation/LFObjCRuntime.h.in
===================================================================
--- trunk/Foundation/LFObjCRuntime.h.in 2006-09-02 00:10:46 UTC (rev 296)
+++ trunk/Foundation/LFObjCRuntime.h.in 2006-09-02 00:10:54 UTC (rev 297)
@@ -50,6 +50,9 @@
/* Include stdint.h if available */
@LF_STDINT_INC@
+/* vararg prototypes */
+#include <stdarg.h>
+
#if defined(__WIN32__)
#if defined(LF_BUILDING_libFoundation_LIB) // Building libFoundation
#define LF_EXPORT __declspec(dllexport)
Modified: trunk/Foundation/NSString.h
===================================================================
--- trunk/Foundation/NSString.h 2006-09-02 00:10:46 UTC (rev 296)
+++ trunk/Foundation/NSString.h 2006-09-02 00:10:54 UTC (rev 297)
@@ -39,7 +39,7 @@
#include <Foundation/NSObject.h>
#include <Foundation/NSRange.h>
-@class NSData;
+@class NSData, NSDictionary;
/*!
* @ingroup NSString
@@ -123,6 +123,9 @@
- (id) initWithCString:(const char *)cStr encoding:(NSStringEncoding)encoding;
- (id) initWithBytes:(const void *)bytes length:(unsigned int)len encoding:(NSStringEncoding)encoding;
- (id) initWithBytesNoCopy:(void *)bytes length:(unsigned int)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL) shouldFree;
+- (id) initWithFormat:(NSString *)format, ...;
+- (id) initWithFormat:(NSString *)format locale:(NSDictionary *)locale, ...;
+- (id) initWithFormat:(NSString *)format locale:(NSDictionary *)locale arguments:(va_list)args;
/* Encoding */
+ (NSStringEncoding) defaultCStringEncoding;
Modified: trunk/Foundation/NSString.m
===================================================================
--- trunk/Foundation/NSString.m 2006-09-02 00:10:46 UTC (rev 296)
+++ trunk/Foundation/NSString.m 2006-09-02 00:10:54 UTC (rev 297)
@@ -225,8 +225,61 @@
return self;
}
+/*!
+ * Initialize the receiver with format.
+ *
+ * The receiver will be initialized using the supplied printf-style format
+ * string. This method is implemented by calling initWithFormat:locale:arguments
+ * with a nil locale.
+ *
+ * @param format Format string. If nil, raises NSInvalidArgumentException.
+ * @return Newly initialized string.
+ */
+- (id) initWithFormat:(NSString *)format, ... {
+ va_list ap;
+ va_start(ap, format);
+ [self initWithFormat: format locale: nil arguments: ap];
+ va_end(ap);
+ return self;
+}
+
/*!
+ * Initialize the receiver with format and locale.
+ *
+ * The receiver will be initialized using the supplied printf-style format
+ * string, according to locale. If locale is nil,
+ * +[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] will be used.
+ * @param format Format string. If nil, raises NSInvalidArgumentException.
+ * @param locale Locale dictionary. If nil, [[NSUserDefaults standardUserDefaults] dictionaryRepresentation] will be used.
+ * @return Newly initialized string.
+ */
+- (id) initWithFormat:(NSString *)format locale:(NSDictionary *)locale, ... {
+ va_list ap;
+
+ va_start(ap, locale);
+ [self initWithFormat: format locale: locale arguments: ap];
+ va_end(ap);
+ return self;
+}
+
+
+/*!
+ * Initialize the receiver with format, locale, and va_list arguments.
+ *
+ * The receiver will be initialized using the supplied printf-style format
+ * string, according to locale. If locale is nil,
+ * +[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] will be used.
+ * @param format Format string. If nil, raises NSInvalidArgumentException.
+ * @param locale Locale dictionary. If nil, [[NSUserDefaults standardUserDefaults] dictionaryRepresentation] will be used.
+ * @param args Format string arguments (va_list).
+ * @return Newly initialized string.
+ */
+- (id) initWithFormat:(NSString *)format locale:(NSDictionary *)locale arguments:(va_list)args {
+ /* TODO Implement Me ... */
+}
+
+/*!
* @}
* Allocation and Initialization.
*/
Modified: trunk/Tests/NSString.m
===================================================================
--- trunk/Tests/NSString.m 2006-09-02 00:10:46 UTC (rev 296)
+++ trunk/Tests/NSString.m 2006-09-02 00:10:54 UTC (rev 297)
@@ -178,6 +178,15 @@
}
END_TEST
+START_TEST (test_initWithFormatLocale) {
+ NSString *string;
+
+ string = [[NSString alloc] initWithFormat: @"%@ %s" locale: nil, @"Hello, ", "World!"];
+ fail_if(string == nil, "-[NSString initWithFormat: locale:] returned nil");
+ fail_unless(memcmp([string UTF8String], TEST_STRING, [string length]), "-[NSString initWithFormat: locale:] didn't handle our format correctly (Expected: %s, got: %s)", TEST_STRING, [string UTF8String]);
+}
+END_TEST
+
START_TEST (test_cStringUsingEncoding) {
NSString *string;
const char *cStr;
@@ -244,6 +253,7 @@
tcase_add_test(tc_init, test_initWithCStringEncoding);
tcase_add_test(tc_init, test_initWithBytes);
tcase_add_test(tc_init, test_initWithBytesNoCopyLengthEncodingFreeWhenDone);
+ tcase_add_test(tc_init, test_initWithFormatLocale);
TCase *tc_subclass = tcase_create("Subclassing");
tcase_add_checked_fixture(tc_subclass, setUp, tearDown);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|