| 33 | | const JSObjectCallbacks kJSObjectCallbacksNone = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| | 33 | const JSClassDefinition kJSClassDefinitionNull = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 35 | | JSClassRef JSClassCreate(JSStaticValue* staticValues, JSStaticFunction* staticFunctions, const JSObjectCallbacks* callbacks, JSClassRef parentClass) |
| | 35 | __JSClass::__JSClass(JSClassDefinition* definition) |
| | 36 | : refCount(0) |
| | 37 | , className(definition->className) |
| | 38 | , parentClass(definition->parentClass) |
| | 39 | , staticValues(0) |
| | 40 | , staticFunctions(0) |
| | 41 | , initialize(definition->initialize) |
| | 42 | , finalize(definition->finalize) |
| | 43 | , hasProperty(definition->hasProperty) |
| | 44 | , getProperty(definition->getProperty) |
| | 45 | , setProperty(definition->setProperty) |
| | 46 | , deleteProperty(definition->deleteProperty) |
| | 47 | , addPropertiesToList(definition->addPropertiesToList) |
| | 48 | , callAsFunction(definition->callAsFunction) |
| | 49 | , callAsConstructor(definition->callAsConstructor) |
| | 50 | , hasInstance(definition->hasInstance) |
| | 51 | , convertToType(definition->convertToType) |
| 37 | | JSClassRef jsClass = new __JSClass; |
| 38 | | if (staticValues) { |
| 39 | | jsClass->staticValues = new __JSClass::StaticValuesTable(); |
| 40 | | while (staticValues->name) { |
| 41 | | jsClass->staticValues->add(Identifier(staticValues->name).ustring().rep(), |
| 42 | | new StaticValueEntry(staticValues->getProperty, staticValues->setProperty, staticValues->attributes)); |
| 43 | | ++staticValues; |
| | 53 | if (JSStaticValue* staticValue = definition->staticValues) { |
| | 54 | staticValues = new StaticValuesTable(); |
| | 55 | while (staticValue->name) { |
| | 56 | staticValues->add(Identifier(staticValue->name).ustring().rep(), |
| | 57 | new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes)); |
| | 58 | ++staticValue; |
| 47 | | if (staticFunctions) { |
| 48 | | jsClass->staticFunctions = new __JSClass::StaticFunctionsTable(); |
| 49 | | while (staticFunctions->name) { |
| 50 | | jsClass->staticFunctions->add(Identifier(staticFunctions->name).ustring().rep(), |
| 51 | | new StaticFunctionEntry(staticFunctions->callAsFunction, staticFunctions->attributes)); |
| 52 | | ++staticFunctions; |
| | 62 | if (JSStaticFunction* staticFunction = definition->staticFunctions) { |
| | 63 | staticFunctions = new StaticFunctionsTable(); |
| | 64 | while (staticFunction->name) { |
| | 65 | staticFunctions->add(Identifier(staticFunction->name).ustring().rep(), |
| | 66 | new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes)); |
| | 67 | ++staticFunction; |
| 72 | | void JSClassRelease(JSClassRef jsClass) |
| 73 | | { |
| 74 | | if (--jsClass->refCount == 0) { |
| 75 | | if (jsClass->staticValues) { |
| 76 | | deleteAllValues(*jsClass->staticValues); |
| 77 | | delete jsClass->staticValues; |
| 78 | | } |
| 79 | | |
| 80 | | if (jsClass->staticFunctions) { |
| 81 | | deleteAllValues(*jsClass->staticFunctions); |
| 82 | | delete jsClass->staticFunctions; |
| 83 | | } |
| 84 | | |
| 85 | | delete jsClass; |
| | 79 | if (staticFunctions) { |
| | 80 | deleteAllValues(*staticFunctions); |
| | 81 | delete staticFunctions; |