Open
Bug 346345
Opened 19 years ago
Updated 2 years ago
Should have a category for converting between Gecko and Cocoa strings
Categories
(Core :: Widget: Cocoa, defect, P3)
Tracking
()
NEW
People
(Reporter: hsivonen, Unassigned)
References
Details
Attachments
(3 files, 2 obsolete files)
2.01 KB,
patch
|
Details | Diff | Splinter Review | |
3.29 KB,
text/plain
|
Details | |
8.80 KB,
text/plain
|
Details |
Currently, embedding/browser/cocoa/src/NSString+Utils.h is available to Camino, but is not in the right place for use in the Cocoa widget code.
For the Cocoa widget code, it would be nice to have an NSString category that allowed NSString to be initialized with various Gecko string flavors and that allowed NSString to be converted to various Gecko string flavors.
Comment 1•19 years ago
|
||
I agree.
Reporter | ||
Updated•18 years ago
|
Status: NEW → ASSIGNED
Reporter | ||
Comment 3•18 years ago
|
||
Where should the conversion category be placed in the tree? Should the methods that are not strictly about string conversion be left in embedding/browser/cocoa/src/NSString+Utils.h?
Comment 4•18 years ago
|
||
I suggest xpcom/glue/nsMacString.{h,mm} other utility classes/functions can be moved if mento thinks appropriate.
Comment 5•18 years ago
|
||
See also bug 334670, which is about the Core Foundation type (which is the C struct that the objc-only NSString type uses as its core).
Reporter | ||
Comment 6•18 years ago
|
||
Reporter | ||
Comment 7•18 years ago
|
||
Reporter | ||
Comment 8•18 years ago
|
||
(Will upload new files separately. cvs diff -uN isn't working for me.)
Reporter | ||
Comment 9•18 years ago
|
||
Attachment #235726 -
Attachment is obsolete: true
Reporter | ||
Comment 10•18 years ago
|
||
hwaara, are these changes adequate for your purposes? Would you like to take the bug to add whatever changes you need?
Attachment #235727 -
Attachment is obsolete: true
Comment 11•18 years ago
|
||
Comment on attachment 239022 [details]
mozilla/xpcom/string/public/NSString+Moz.h
I don't think I need any other changes, so I'd be happy to help out reviewing this, if you plan to drive the patch.
>+ (id)ellipsisString;
This is not needed; IIRC 10.3 offers ways to do this. The reason that there was a category method, was that Camino used to support 10.1/10.2
>+ (id)stringWithPRUnichars:(const PRUnichar*)inString;
>+ (id)stringWith_nsAString:(const nsAString&)inString;
>+ (id)stringWithUTF8_nsACString:(const nsACString&)inString;
I think this should be named simply stringWith_nsACString to match what the rest of XPCOM string classes are named.
>+ (id)stringWith_nsISupportsString:(nsISupportsString*)inString;
I think nsISupportsString is deprecated, and thus should not be endorsed by new APIs. That goes for all the nsISupports helper methods.
>- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
>- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet withString:(NSString*)string;
>- (NSString *)stringByTruncatingTo:(unsigned int)maxCharacters at:(ETruncationType)truncationType;
Are these strictly needed? There should be ways to do this with the existing NSString APIs, and they're not really Mozilla-specific.
>// allocate a new unicode buffer with the contents of the current string. Caller
>// is responsible for freeing the buffer.
>- (PRUnichar*)createNewUnicodeBuffer;
Also not sure what this has to do with NSString at all.
Comment 12•18 years ago
|
||
Comment on attachment 239020 [details] [diff] [review]
Diff for existing files
>Index: mozilla/configure.in
>===================================================================
>RCS file: /cvsroot/mozilla/configure.in,v
>retrieving revision 1.1704
>diff -u -r1.1704 configure.in
>--- mozilla/configure.in 31 Jul 2006 18:11:36 -0000 1.1704
>+++ mozilla/configure.in 18 Sep 2006 14:26:30 -0000
>@@ -4537,7 +4537,7 @@
> AC_DEFINE(MOZ_WIDGET_PHOTON)
> ;;
> mac|cocoa)
>- TK_LIBS='-framework Carbon'
>+ TK_LIBS='-framework Carbon -framework Cocoa'
I bet linking to -framework Foundation is enough.
Comment 13•18 years ago
|
||
Comment on attachment 239025 [details]
mozilla/xpcom/string/src/NSString+Moz.mm
The nsA[C]String utilities can be simplified.
Have a look at http://landfill.mozilla.org/mxr-test/mozilla/source/camino/src/extensions/NSString+Utils.mm
(Note that all files in embedding/cocoa are >3 years out out of sync with their camino counterparts, so that code should really not be copied.)
Reporter | ||
Comment 14•18 years ago
|
||
The use case I had for this code was not checked in. Should this be WONTFIXed?
Assignee: hsivonen → joshmoz
Status: ASSIGNED → NEW
Someone was asking about (wanting) string conversion stuff the other day, so presumably there's still some need for either this bug or Håkan's bug 334670....
Comment 16•18 years ago
|
||
This and bug 334670 are probably dupes of each other. CFString and NSString are toll-free bridged. You can just cast the NSString to a CFString, or vice versa.
Updated•7 years ago
|
Priority: -- → P3
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•