Changeset 19059 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Jan 23, 2007, 2:23:09 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by Maciej Stachowiak.


Fixed <rdar://problem/4885131> Move CFString function declarations from
JSStringRef.h to JSStringRefCF.h


Also removed remaining API FIXMEs and changed them into Radars.

  • API/JSClassRef.cpp: (OpaqueJSClass::OpaqueJSClass): Added Radar numbers for UTF8 conversion.
  • API/JSContextRef.cpp: (JSGlobalContextCreate): Replaced FIXME for NULL JSContextRef with Radar number.
  • API/JSObjectRef.h: Removed FIXME, which is unprofessional in a public header.
  • API/JSStringRef.cpp: Moved CF related implementations to JSStringRefCF.cpp. (JSStringCreateWithUTF8CString): Replaced FIXME with Radar number.
  • API/JSStringRef.h: Moved CF related declarations to JSStringRefCF.h. Added #include of JSStringRefCF.h as a stopgap until clients start #including it as needed by themselves.
  • API/JSStringRefCF.cpp: Added. (JSStringCreateWithCFString): (JSStringCopyCFString): Replaced JSChar cast with UniChar cast, which is more appropriate for a CF call.
  • API/JSStringRefCF.h: Added.
  • JavaScriptCore.xcodeproj/project.pbxproj:
Location:
trunk/JavaScriptCore/API
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSClassRef.cpp

    r17649 r19059  
    3838OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass)
    3939    : refCount(0)
     40    // FIXME: <rdar://problem/4949018>
    4041    , className(definition->className)
    4142    , parentClass(definition->parentClass)
     
    5960        staticValues = new StaticValuesTable();
    6061        while (staticValue->name) {
     62            // FIXME: <rdar://problem/4949018>
    6163            staticValues->add(Identifier(staticValue->name).ustring().rep(),
    6264                              new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes));
     
    6870        staticFunctions = new StaticFunctionsTable();
    6971        while (staticFunction->name) {
     72            // FIXME: <rdar://problem/4949018>
    7073            staticFunctions->add(Identifier(staticFunction->name).ustring().rep(),
    7174                                 new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes));
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r16371 r19059  
    4242    JSObject* globalObject;
    4343    if (globalObjectClass)
    44         // FIXME: We need to pass a real ExecState here to support an initialize callback in globalObjectClass
    45         globalObject = new JSCallbackObject(0, globalObjectClass, 0, 0);
     44        globalObject = new JSCallbackObject(0, globalObjectClass, 0, 0); // FIXME: <rdar://problem/4949002>
    4645    else
    4746        globalObject = new JSObject();
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r18888 r19059  
    286286*/
    287287typedef struct {
    288     const char* const name; // FIXME: convert UTF8
     288    const char* const name;
    289289    JSObjectGetPropertyCallback getProperty;
    290290    JSObjectSetPropertyCallback setProperty;
     
    300300*/
    301301typedef struct {
    302     const char* const name; // FIXME: convert UTF8
     302    const char* const name;
    303303    JSObjectCallAsFunctionCallback callAsFunction;
    304304    JSPropertyAttributes attributes;
  • trunk/JavaScriptCore/API/JSStringRef.cpp

    r17372 r19059  
    4747{
    4848    JSLock lock;
    49     // FIXME: Only works with ASCII
    50     // Use decodeUTF8Sequence or http://www.unicode.org/Public/PROGRAMS/CVTUTF/ instead
     49    // FIXME: <rdar://problem/4949018>
    5150    return toRef(UString(string).rep()->ref());
    5251}
     
    112111    return result;
    113112}
    114 
    115 #if defined(__APPLE__)
    116 JSStringRef JSStringCreateWithCFString(CFStringRef string)
    117 {
    118     JSLock lock;
    119     CFIndex length = CFStringGetLength(string);
    120    
    121     // Optimized path for when CFString backing store is a UTF16 buffer
    122     if (const UniChar* buffer = CFStringGetCharactersPtr(string)) {
    123         UString::Rep* rep = UString(reinterpret_cast<const UChar*>(buffer), length).rep()->ref();
    124         return toRef(rep);
    125     }
    126 
    127     UniChar* buffer = static_cast<UniChar*>(fastMalloc(sizeof(UniChar) * length));
    128     CFStringGetCharacters(string, CFRangeMake(0, length), buffer);
    129     UString::Rep* rep = UString(reinterpret_cast<UChar*>(buffer), length, false).rep()->ref();
    130     return toRef(rep);
    131 }
    132 
    133 CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string)
    134 {
    135     UString::Rep* rep = toJS(string);
    136     return CFStringCreateWithCharacters(alloc, reinterpret_cast<const JSChar*>(rep->data()), rep->size());
    137 }
    138 
    139 #endif // __APPLE__
  • trunk/JavaScriptCore/API/JSStringRef.h

    r15497 r19059  
    3535#ifdef __cplusplus
    3636extern "C" {
     37#endif
     38
     39#if defined(__APPLE__)
     40#include "JSStringRefCF.h"
    3741#endif
    3842
     
    137141bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b);
    138142
    139 #if defined(__APPLE__)
    140 #include <CoreFoundation/CoreFoundation.h>
    141 // CFString convenience methods
    142 /*!
    143 @function
    144 @abstract         Creates a JavaScript string from a CFString.
    145 @discussion       This function is optimized to take advantage of cases when
    146  CFStringGetCharactersPtr returns a valid pointer.
    147 @param string     The CFString to copy into the new JSString.
    148 @result           A JSString containing string. Ownership follows the Create Rule.
    149 */
    150 JSStringRef JSStringCreateWithCFString(CFStringRef string);
    151 /*!
    152 @function
    153 @abstract         Creates a CFString from a JavaScript string.
    154 @param alloc      The alloc parameter to pass to CFStringCreate.
    155 @param string     The JSString to copy into the new CFString.
    156 @result           A CFString containing string. Ownership follows the Create Rule.
    157 */
    158 CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string);
    159 #endif // __APPLE__
    160    
    161143#ifdef __cplusplus
    162144}
Note: See TracChangeset for help on using the changeset viewer.