Changeset 53657 in webkit for trunk/JavaScriptCore/API/JSClassRef.cpp
- Timestamp:
- Jan 21, 2010, 4:06:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSClassRef.cpp
r53642 r53657 35 35 #include <runtime/Identifier.h> 36 36 37 using namespace std; 37 38 using namespace JSC; 38 39 … … 121 122 } 122 123 123 PassRefPtr<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* definition) 124 { 125 const JSStaticFunction* staticFunctions = definition->staticFunctions; 126 if (staticFunctions || definition->parentClass) { 127 // copy functions into a prototype class 128 JSClassDefinition protoDefinition = kJSClassDefinitionEmpty; 129 protoDefinition.staticFunctions = staticFunctions; 130 protoDefinition.finalize = clearReferenceToPrototype; 131 132 // We are supposed to use JSClassRetain/Release but since we know that we currently have 133 // the only reference to this class object we cheat and use a RefPtr instead. 134 RefPtr<OpaqueJSClass> protoClass = adoptRef(new OpaqueJSClass(&protoDefinition, 0)); 135 136 // remove functions from the original class 137 JSClassDefinition objectDefinition = *definition; 138 objectDefinition.staticFunctions = 0; 139 140 return adoptRef(new OpaqueJSClass(&objectDefinition, protoClass.get())); 141 } 142 143 return adoptRef(new OpaqueJSClass(definition, 0)); 124 PassRefPtr<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* clientDefinition) 125 { 126 JSClassDefinition definition = *clientDefinition; // Avoid modifying client copy. 127 128 JSClassDefinition protoDefinition = kJSClassDefinitionEmpty; 129 protoDefinition.finalize = clearReferenceToPrototype; 130 swap(definition.staticFunctions, protoDefinition.staticFunctions); // Move static functions to the prototype. 131 132 // We are supposed to use JSClassRetain/Release but since we know that we currently have 133 // the only reference to this class object we cheat and use a RefPtr instead. 134 RefPtr<OpaqueJSClass> protoClass = adoptRef(new OpaqueJSClass(&protoDefinition, 0)); 135 return adoptRef(new OpaqueJSClass(&definition, protoClass.get())); 144 136 } 145 137
Note:
See TracChangeset
for help on using the changeset viewer.