Changeset 102065 in webkit for trunk/Source/JavaScriptCore/API/JSClassRef.cpp
- Timestamp:
- Dec 5, 2011, 4:17:34 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSClassRef.cpp
r101945 r102065 72 72 , convertToType(definition->convertToType) 73 73 , m_className(tryCreateStringFromUTF8(definition->className)) 74 , m_staticValues(0)75 , m_staticFunctions(0)76 74 { 77 75 initializeThreading(); 78 76 79 77 if (const JSStaticValue* staticValue = definition->staticValues) { 80 m_staticValues = new OpaqueJSClassStaticValuesTable();78 m_staticValues = adoptPtr(new OpaqueJSClassStaticValuesTable); 81 79 while (staticValue->name) { 82 80 UString valueName = tryCreateStringFromUTF8(staticValue->name); 83 81 if (!valueName.isNull()) { 84 82 // Use a local variable here to sidestep an RVCT compiler bug. 85 StaticValueEntry* entry = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes); 86 StringImpl* impl = valueName.impl(); 87 StaticValueEntry* existingEntry = m_staticValues->get(impl); 88 m_staticValues->set(impl, entry); 89 delete existingEntry; 83 OwnPtr<StaticValueEntry> entry = adoptPtr(new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes)); 84 m_staticValues->set(valueName.impl(), entry.release()); 90 85 } 91 86 ++staticValue; … … 94 89 95 90 if (const JSStaticFunction* staticFunction = definition->staticFunctions) { 96 m_staticFunctions = new OpaqueJSClassStaticFunctionsTable();91 m_staticFunctions = adoptPtr(new OpaqueJSClassStaticFunctionsTable); 97 92 while (staticFunction->name) { 98 93 UString functionName = tryCreateStringFromUTF8(staticFunction->name); 99 94 if (!functionName.isNull()) { 100 95 // Use a local variable here to sidestep an RVCT compiler bug. 101 StaticFunctionEntry* entry = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes); 102 StringImpl* impl = functionName.impl(); 103 StaticFunctionEntry* existingEntry = m_staticFunctions->get(impl); 104 m_staticFunctions->set(impl, entry); 105 delete existingEntry; 96 OwnPtr<StaticFunctionEntry> entry = adoptPtr(new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes)); 97 m_staticFunctions->set(functionName.impl(), entry.release()); 106 98 } 107 99 ++staticFunction; … … 118 110 ASSERT(!m_className.length() || !m_className.impl()->isIdentifier()); 119 111 112 #ifndef NDEBUG 120 113 if (m_staticValues) { 121 114 OpaqueJSClassStaticValuesTable::const_iterator end = m_staticValues->end(); 122 for (OpaqueJSClassStaticValuesTable::const_iterator it = m_staticValues->begin(); it != end; ++it) { 123 ASSERT(!it->first->isIdentifier()); 124 delete it->second; 125 } 126 delete m_staticValues; 115 for (OpaqueJSClassStaticValuesTable::const_iterator it = m_staticValues->begin(); it != end; ++it) 116 ASSERT(!it->first->isIdentifier()); 127 117 } 128 118 129 119 if (m_staticFunctions) { 130 120 OpaqueJSClassStaticFunctionsTable::const_iterator end = m_staticFunctions->end(); 131 for (OpaqueJSClassStaticFunctionsTable::const_iterator it = m_staticFunctions->begin(); it != end; ++it) { 132 ASSERT(!it->first->isIdentifier()); 133 delete it->second; 134 } 135 delete m_staticFunctions; 136 } 121 for (OpaqueJSClassStaticFunctionsTable::const_iterator it = m_staticFunctions->begin(); it != end; ++it) 122 ASSERT(!it->first->isIdentifier()); 123 } 124 #endif 137 125 138 126 if (prototypeClass) … … 163 151 { 164 152 if (jsClass->m_staticValues) { 165 staticValues = new OpaqueJSClassStaticValuesTable;153 staticValues = adoptPtr(new OpaqueJSClassStaticValuesTable); 166 154 OpaqueJSClassStaticValuesTable::const_iterator end = jsClass->m_staticValues->end(); 167 155 for (OpaqueJSClassStaticValuesTable::const_iterator it = jsClass->m_staticValues->begin(); it != end; ++it) { 168 156 ASSERT(!it->first->isIdentifier()); 169 157 // Use a local variable here to sidestep an RVCT compiler bug. 170 StaticValueEntry* entry = new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes); 171 staticValues->add(StringImpl::create(it->first->characters(), it->first->length()), entry); 172 } 173 } else 174 staticValues = 0; 158 OwnPtr<StaticValueEntry> entry = adoptPtr(new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes)); 159 staticValues->add(StringImpl::create(it->first->characters(), it->first->length()), entry.release()); 160 } 161 } 175 162 176 163 if (jsClass->m_staticFunctions) { 177 staticFunctions = new OpaqueJSClassStaticFunctionsTable;164 staticFunctions = adoptPtr(new OpaqueJSClassStaticFunctionsTable); 178 165 OpaqueJSClassStaticFunctionsTable::const_iterator end = jsClass->m_staticFunctions->end(); 179 166 for (OpaqueJSClassStaticFunctionsTable::const_iterator it = jsClass->m_staticFunctions->begin(); it != end; ++it) { 180 167 ASSERT(!it->first->isIdentifier()); 181 168 // Use a local variable here to sidestep an RVCT compiler bug. 182 StaticFunctionEntry* entry = new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes); 183 staticFunctions->add(StringImpl::create(it->first->characters(), it->first->length()), entry); 184 } 185 186 } else 187 staticFunctions = 0; 188 } 189 190 OpaqueJSClassContextData::~OpaqueJSClassContextData() 191 { 192 if (staticValues) { 193 deleteAllValues(*staticValues); 194 delete staticValues; 195 } 196 197 if (staticFunctions) { 198 deleteAllValues(*staticFunctions); 199 delete staticFunctions; 169 OwnPtr<StaticFunctionEntry> entry = adoptPtr(new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes)); 170 staticFunctions->add(StringImpl::create(it->first->characters(), it->first->length()), entry.release()); 171 } 200 172 } 201 173 } … … 217 189 OpaqueJSClassStaticValuesTable* OpaqueJSClass::staticValues(JSC::ExecState* exec) 218 190 { 219 OpaqueJSClassContextData& jsClassData = contextData(exec); 220 return jsClassData.staticValues; 191 return contextData(exec).staticValues.get(); 221 192 } 222 193 223 194 OpaqueJSClassStaticFunctionsTable* OpaqueJSClass::staticFunctions(JSC::ExecState* exec) 224 195 { 225 OpaqueJSClassContextData& jsClassData = contextData(exec); 226 return jsClassData.staticFunctions; 196 return contextData(exec).staticFunctions.get(); 227 197 } 228 198 … … 249 219 prototypeClass = OpaqueJSClass::create(&kJSClassDefinitionEmpty).leakRef(); 250 220 if (!prototypeClass->m_staticFunctions) 251 prototypeClass->m_staticFunctions = new OpaqueJSClassStaticFunctionsTable;221 prototypeClass->m_staticFunctions = adoptPtr(new OpaqueJSClassStaticFunctionsTable); 252 222 const Identifier& toString = exec->propertyNames().toString; 253 223 const Identifier& valueOf = exec->propertyNames().valueOf; 254 prototypeClass->m_staticFunctions->add(StringImpl::create(toString.characters(), toString.length()), new StaticFunctionEntry(&JSCallbackFunction::toStringCallback, 0));255 prototypeClass->m_staticFunctions->add(StringImpl::create(valueOf.characters(), valueOf.length()), new StaticFunctionEntry(&JSCallbackFunction::valueOfCallback, 0));224 prototypeClass->m_staticFunctions->add(StringImpl::create(toString.characters(), toString.length()), adoptPtr(new StaticFunctionEntry(&JSCallbackFunction::toStringCallback, 0))); 225 prototypeClass->m_staticFunctions->add(StringImpl::create(valueOf.characters(), valueOf.length()), adoptPtr(new StaticFunctionEntry(&JSCallbackFunction::valueOfCallback, 0))); 256 226 } 257 227
Note:
See TracChangeset
for help on using the changeset viewer.