Webkit IDL的各種自訂介面,webkitidl自訂
[JSCustomToNativeObject](i), [JSCustomFinalize](i), [CustomIsReachable](i), [JSCustomMarkFunction](i), [JSCustomNamedGetterOnPrototype](i),[JSCustomPushEventHandlerScope](i), [JSCustomDefineOwnProperty](i), [JSCustomDefineOwnPropertyOnPrototype](i),[JSCustomGetOwnPropertySlotAndDescriptor](i)
概述: 這些文法讓你編寫JavaScriptCore相關的綁定代碼,本來這些綁定代碼預設會被自動產生.
用法:
[ JSCustomToNativeObject, JSCustomFinalize, CustomIsReachable, JSCustomMarkFunction, JSCustomNamedGetterOnPrototype, JSCustomPushEventHandlerScope, JSCustomDefineOwnProperty, JSCustomDefineOwnPropertyOnPrototype, JSCustomGetOwnPropertySlotAndDescriptor ] interface XXX { };
你可以在這個檔案裡編寫如下系列函數: WebCore/bindings/js/JSXXXCustom.cpp. 更多例子,請參考檔案WebCore/bindings/js/JSXXXCustom.cpp
- [JSCustomToNativeObject]: 比如,你可以編寫自己的toDOMWindow(...):
PassRefPtr<DOMWindow> toDOMWindow(JSGlobalData& globalData, JSValue value) { ...; }
- [JSCustomFinalize]: 定義自己的finalize函數:
void JSXXXOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { ...; }
- [CustomIsReachable]: 定義自己的isReachableFromOpaqueRoots函數:
bool JSXXXOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, SlotVisitor& visitor) { ...; }
- [JSCustomMarkFunction]: 定義自己的 JSXXX::visitChildren(...)函數:
void JSXXX::visitChildren(JSCell* cell, SlotVisitor& visitor) { ...; }
- [JSCustomNamedGetterOnPrototype]: 定義自己的 JSXXXPrototype::putDelegate(...)函數:
bool JSXXXPrototype::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { ...; }
- [JSCustomPushEventHandlerScope]: 定義自己的 JSXXX::pushEventHandlerScope(...)函數:
ScopeChainNode* JSXXX::pushEventHandlerScope(ExecState* exec, ScopeChainNode* node) const { ...; }
- [JSCustomDefineOwnProperty]: 定義自己的 JSXXX::defineOwnProperty(...)函數:
bool JSXXX::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException) { ...; }
- [JSCustomDefineOwnPropertyOnPrototype]:定義自己的原型屬性 JSXXXPrototype::defineOwnProperty(...):
bool JSXXXPrototype::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException) { ...; }
- [JSCustomGetOwnPropertySlotAndDescriptor]: 定義自己的 JSXXX::getOwnPropertySlotDelegate(...) 以及 JSXXX::getOwnPropertyDescriptorDelegate(...)函數:
bool JSXXX::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { ...; } bool JSXXX::getOwnPropertyDescriptorDelegate(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { ...; }