845 | | === * [JSCustomToNativeObject](i), [JSCustomFinalize](i), [JSCustomIsReachable](i), [JSCustomMarkFunction](i), [JSCustomNamedGetterOnPrototype](i), [JSCustomPushEventHandlerScope](i), [JSCustomDefineOwnProperty](i), [JSCustomGetOwnPropertySlotAndDescriptor](i), [JSCustomDefineOwnPropertyOnPrototype](i) === |
| 859 | === * [JSCustomToNativeObject](i), [JSCustomFinalize](i), [JSCustomIsReachable](i), [JSCustomMarkFunction](i), [JSCustomNamedGetterOnPrototype](i), [JSCustomPushEventHandlerScope](i), [JSCustomDefineOwnProperty](i), [JSCustomDefineOwnPropertyOnPrototype](i), [JSCustomGetOwnPropertySlotAndDescriptor](i) === |
| 860 | |
| 861 | Summary: They allow us to write custom code for the JavaScriptCore code which would be generated automatically by default. |
| 862 | |
| 863 | Usage: They can be specified on interfaces: |
| 864 | {{{ |
| 865 | interface [ |
| 866 | JSCustomToNativeObject, |
| 867 | JSCustomFinalize, |
| 868 | JSCustomIsReachable, |
| 869 | JSCustomMarkFunction, |
| 870 | JSCustomNamedGetterOnPrototype, |
| 871 | JSCustomPushEventHandlerScope, |
| 872 | JSCustomDefineOwnProperty, |
| 873 | JSCustomDefineOwnPropertyOnPrototype, |
| 874 | JSCustomGetOwnPropertySlotAndDescriptor |
| 875 | ] XXX { |
| 876 | } |
| 877 | }}} |
| 878 | |
| 879 | You can write the following custom code in WebCore/bindings/js/JSXXXCustom.cpp. |
| 880 | Refer to use cases in WebCore/bindings/js/JSXXXCustom.cpp for more details. |
| 881 | |
| 882 | * With [JSCustomToNativeObject], you can write custom toXXX(...): |
| 883 | {{{ |
| 884 | PassRefPtr<XXX> toXXX(JSGlobalData& globalData, JSValue value) |
| 885 | { |
| 886 | ...; |
| 887 | } |
| 888 | }}} |
| 889 | * With [JSCustomFinalize], you can write custom JSXXXOwner::finalize(...): |
| 890 | {{{ |
| 891 | void JSXXXOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 892 | { |
| 893 | ...; |
| 894 | } |
| 895 | }}} |
| 896 | * With [JSCustomIsReachable], you can write custom JSXXXOwner::isReachableFromOpaqueRoots(...): |
| 897 | {{{ |
| 898 | bool JSXXXOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, SlotVisitor& visitor) |
| 899 | { |
| 900 | ...; |
| 901 | } |
| 902 | }}} |
| 903 | * With [JSCustomMarkFunction], you can write custom JSXXX::visitChildren(...): |
| 904 | {{{ |
| 905 | void JSXXX::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 906 | { |
| 907 | ...; |
| 908 | } |
| 909 | }}} |
| 910 | * With [JSCustomNamedGetterOnPrototype], you can write custom JSXXX::putDelegate(...): |
| 911 | {{{ |
| 912 | bool JSXXX::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) |
| 913 | { |
| 914 | ...; |
| 915 | } |
| 916 | }}} |
| 917 | * With [JSCustomPushEventHandlerScope], you can write custom JSXXX::pushEventHandlerScope(...): |
| 918 | {{{ |
| 919 | ScopeChainNode* JSXXX::pushEventHandlerScope(ExecState* exec, ScopeChainNode* node) const |
| 920 | { |
| 921 | ...; |
| 922 | } |
| 923 | }}} |
| 924 | * With [JSCustomDefineOwnProperty], you can write custom JSXXX::defineOwnProperty(...): |
| 925 | {{{ |
| 926 | bool JSXXX::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException) |
| 927 | { |
| 928 | ...; |
| 929 | } |
| 930 | }}} |
| 931 | * With [JSCustomDefineOwnPropertyOnPrototype], you can write custom JSXXXPrototype::defineOwnProperty(...): |
| 932 | {{{ |
| 933 | bool JSXXXPrototype::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException) |
| 934 | { |
| 935 | ...; |
| 936 | } |
| 937 | }}} |
| 938 | * With [JSCustomGetOwnPropertySlotAndDescriptor], you can write custom JSXXX::getOwnPropertySlotDelegate(...) and JSXXX::getOwnPropertyDescriptorDelegate(...): |
| 939 | {{{ |
| 940 | bool JSXXX::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
| 941 | { |
| 942 | ...; |
| 943 | } |
| 944 | |
| 945 | bool JSXXX::getOwnPropertyDescriptorDelegate(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
| 946 | { |
| 947 | ...; |
| 948 | } |
| 949 | }}} |