| | 126 | Summary: If your bindings require special (i.e. "custom") handling, you can write the bindings code as you like. |
| | 127 | |
| | 128 | Usage: [Custom], [JSCustom] and [V8Custom] can be specified on methods or attributes. [CustomGetter], [JSCustomGetter], [V8CustomGetter], [CustomSetter], [JSCustomSetter], [V8CustomSetter] can be specified on attributes, like this: |
| | 129 | {{{ |
| | 130 | [Custom] void func(); |
| | 131 | attribute [CustomGetter, JSCustomSetter] DOMString str; |
| | 132 | }}} |
| | 133 | |
| | 134 | Before explaining the details, let us clarify the relationship of these IDLs. |
| | 135 | |
| | 136 | * [JSCustom] on a method indicates that you want to write JavaScriptCore custom bindings for the method. |
| | 137 | * [V8Custom] on a method indicates that you want to write V8 custom bindings for the method. |
| | 138 | * [Custom] on a method is equivalent to [JSCustom, V8Custom]. |
| | 139 | * [JSCustomGetter] or [JSCustomSetter] on an attribute indicates that you want to write JavaScriptCore custom bindings for the attribute getter or setter. |
| | 140 | * [V8CustomGetter] or [V8CustomSetter] on an attribute indicates that you want to write V8 custom bindings for the attribute getter or setter. |
| | 141 | * [JSCustom] on an attribute is equivalent to [JSCustomGetter, JSCustomSetter]. |
| | 142 | * [V8Custom] on an attribute is equivalent to [V8CustomGetter, V8CustomSetter]. |
| | 143 | * [Custom] on an attribute is equivalent to [JSCustom, V8Custom], i.e. [JSCustomGetter, JSCustomSetter, V8CustomGetter, V8CustomSetter]. |
| | 144 | |
| | 145 | For example, if you want to write custom bindings only for an attribute getter of JavaScriptCore and V8 and an attribute setter of JavaScriptCore, you can specify [CustomGetter, JSCustomSetter]. |
| | 146 | |
| | 147 | How to write custom bindings are different between JavaScriptCore and V8 or between a method and an attribute getter/setter. |
| | 148 | |
| | 149 | * JavaScriptCore method |
| | 150 | Consider the following example: |
| | 151 | {{{ |
| | 152 | interface XXX { |
| | 153 | [JSCustom] void func(in int a, in int b); |
| | 154 | } |
| | 155 | }}} |
| | 156 | You need to prepare WebCore/bindings/js/JSXXXCustom.cpp and write custom bindings, like this: |
| | 157 | {{{ |
| | 158 | EncodedJSValue JSC_HOST_CALL jsXXXPrototypeFunctionCustomMethod(ExecState* exec) |
| | 159 | { |
| | 160 | ...; |
| | 161 | } |
| | 162 | }}} |
| | 163 | Please refer to WebCore/bindings/js/JSXXXCustom.cpp for more details. |
| | 164 | |
| | 165 | * JavaScriptCore attribute getter |
| | 166 | Consider the following example: |
| | 167 | {{{ |
| | 168 | interface XXX { |
| | 169 | attribute [JSCustomGetter] DOMString str; |
| | 170 | } |
| | 171 | }}} |
| | 172 | You need to prepare WebCore/bindings/js/JSXXXCustom.cpp and write custom bindings, like this: |
| | 173 | {{{ |
| | 174 | JSValue jsXXXCustomAttr(ExecState* exec, JSValue slotBase, const Identifier&) |
| | 175 | { |
| | 176 | ...; |
| | 177 | } |
| | 178 | }}} |
| | 179 | Please refer to WebCore/bindings/js/JSXXXCustom.cpp for more details. |
| | 180 | |
| | 181 | * JavaScriptCore attribute setter |
| | 182 | Consider the following example: |
| | 183 | {{{ |
| | 184 | interface XXX { |
| | 185 | attribute [JSCustomSetter] DOMString str; |
| | 186 | } |
| | 187 | }}} |
| | 188 | You need to prepare WebCore/bindings/js/JSXXXCustom.cpp and write custom bindings, like this: |
| | 189 | {{{ |
| | 190 | void setJSXXXCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value) |
| | 191 | { |
| | 192 | ...; |
| | 193 | } |
| | 194 | }}} |
| | 195 | Please refer to WebCore/bindings/js/JSXXXCustom.cpp for more details. |
| | 196 | |
| | 197 | * V8 method |
| | 198 | Consider the following example: |
| | 199 | {{{ |
| | 200 | interface XXX { |
| | 201 | [V8Custom] void func(in int a, in int b); |
| | 202 | } |
| | 203 | }}} |
| | 204 | You need to prepare WebCore/bindings/v8/custom/V8XXXCustom.cpp and write custom bindings in the following signature: |
| | 205 | {{{ |
| | 206 | v8::Handle<v8::Value> V8XXX::funcCallback(const v8::Arguments& args) |
| | 207 | { |
| | 208 | ...; |
| | 209 | } |
| | 210 | }}} |
| | 211 | Please refer to WebCore/bindings/v8/custom/V8XXXCustom.cpp for more details. |
| | 212 | |
| | 213 | * V8 attribute getter |
| | 214 | Consider the following example: |
| | 215 | {{{ |
| | 216 | interface XXX { |
| | 217 | attribute [V8CustomGetter] DOMString str; |
| | 218 | } |
| | 219 | }}} |
| | 220 | You need to prepare WebCore/bindings/v8/custom/V8XXXCustom.cpp and write custom bindings in the following signature: |
| | 221 | {{{ |
| | 222 | |
| | 223 | { |
| | 224 | ...; |
| | 225 | } |
| | 226 | }}} |
| | 227 | Please refer to WebCore/bindings/v8/custom/V8XXXCustom.cpp for more details. |
| | 228 | |
| | 229 | * V8 attribute setter |
| | 230 | Consider the following example: |
| | 231 | {{{ |
| | 232 | interface XXX { |
| | 233 | [V8Custom] void func(in int a, in int b); |
| | 234 | } |
| | 235 | }}} |
| | 236 | You need to prepare WebCore/bindings/v8/custom/V8XXXCustom.cpp and write custom bindings in the following signature: |
| | 237 | {{{ |
| | 238 | v8::Handle<v8::Value> V8XXX::funcCallback(const v8::Arguments& args) |
| | 239 | { |
| | 240 | ...; |
| | 241 | } |
| | 242 | }}} |
| | 243 | Please refer to WebCore/bindings/v8/custom/V8XXXCustom.cpp for more details. |
| | 244 | |
| | 245 | We should minimize the number of custom bindings as less as possible. Before using [Custom], you should doubly consider if you really need custom bindings. |
| | 246 | |
| | 247 | Note: ObjC, GObject and CPP bindings do not support custom bindings. |
| | 248 | |