[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)
{
...;
}
本文详细介绍了如何使用JavaScriptCore相关语法自定义绑定代码,包括如何实现转换、终结、可达性判断、标记函数、命名获取器、事件处理等关键功能。
2960

被折叠的 条评论
为什么被折叠?



