Changeset 54545 in webkit for trunk/JavaScriptCore/API/JSClassRef.cpp
- Timestamp:
- Feb 9, 2010, 3:55:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSClassRef.cpp
r54428 r54545 34 34 #include <runtime/ObjectPrototype.h> 35 35 #include <runtime/Identifier.h> 36 #include <wtf/unicode/UTF8.h> 36 37 37 38 using namespace std; 38 39 using namespace JSC; 40 using namespace WTF::Unicode; 39 41 40 42 const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 43 44 UString tryCreateStringFromUTF8(const char* string) 45 { 46 if (!string) 47 return UString::null(); 48 49 size_t length = strlen(string); 50 Vector<UChar, 1024> buffer(length); 51 UChar* p = buffer.data(); 52 if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length)) 53 return UString::null(); 54 55 return UString(buffer.data(), p - buffer.data()); 56 } 41 57 42 58 OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass) … … 54 70 , hasInstance(definition->hasInstance) 55 71 , convertToType(definition->convertToType) 56 , m_className( UString::createFromUTF8(definition->className).rep()->ref())72 , m_className(tryCreateStringFromUTF8(definition->className)) 57 73 , m_staticValues(0) 58 74 , m_staticFunctions(0) … … 63 79 m_staticValues = new OpaqueJSClassStaticValuesTable(); 64 80 while (staticValue->name) { 65 // Use a local variable here to sidestep an RVCT compiler bug. 66 StaticValueEntry* entry = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes); 67 m_staticValues->add(UString::createFromUTF8(staticValue->name).rep()->ref(), entry); 81 UString valueName = tryCreateStringFromUTF8(staticValue->name); 82 if (!valueName.isNull()) { 83 // Use a local variable here to sidestep an RVCT compiler bug. 84 StaticValueEntry* entry = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes); 85 m_staticValues->add(valueName.rep()->ref(), entry); 86 } 68 87 ++staticValue; 69 88 } … … 73 92 m_staticFunctions = new OpaqueJSClassStaticFunctionsTable(); 74 93 while (staticFunction->name) { 75 // Use a local variable here to sidestep an RVCT compiler bug. 76 StaticFunctionEntry* entry = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes); 77 m_staticFunctions->add(UString::createFromUTF8(staticFunction->name).rep()->ref(), entry); 94 UString functionName = tryCreateStringFromUTF8(staticFunction->name); 95 if (!functionName.isNull()) { 96 // Use a local variable here to sidestep an RVCT compiler bug. 97 StaticFunctionEntry* entry = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes); 98 m_staticFunctions->add(functionName.rep()->ref(), entry); 99 } 78 100 ++staticFunction; 79 101 } … … 147 169 StaticValueEntry* entry = new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes); 148 170 staticValues->add(UString::Rep::create(it->first->data(), it->first->size()), entry); 149 150 } 151 171 } 152 172 } else 153 173 staticValues = 0; 154 155 174 156 175 if (jsClass->m_staticFunctions) {
Note:
See TracChangeset
for help on using the changeset viewer.