Source/WebCore/ChangeLog

 12015-07-28 Xabier Rodriguez Calvar <calvaris@igalia.com>
 2
 3 Create [StaticToPrototype] extended IDL attribute
 4 https://bugs.webkit.org/show_bug.cgi?id=146593
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 I added the [CustomObjectGenerateNoBindings] IDL extended attribute. The idea is that when using this attribute,
 9 bindings generate only the headers of the JS functions and we have to implement all the access in the Custom.cpp
 10 files, meaning accessing the implementations at our wish.
 11
 12 Added customObjectGenerateNoBindingsAttr, customObjectGenerateNoBindingsMethod,
 13 customObjectGenerateNoBindingsMethodWithArgs to the generator tests.
 14
 15 * bindings/scripts/CodeGeneratorGObject.pm:
 16 (SkipAttribute):
 17 (SkipFunction): Skipped [CustomObjectGenerateNoBindings] attributes and methods.
 18 * bindings/scripts/CodeGeneratorJS.pm:
 19 (GenerateImplementation): Avoided generating the code for [CustomObjectGenerateNoBindings] methods and attributes.
 20 * bindings/scripts/IDLAttributes.txt: Added [CustomObjectGenerateNoBindings] IDL extended attribute
 21 * bindings/scripts/test/JS/JSTestObj.cpp: Expectations: added headers and methods to the VTables.
 22 * bindings/scripts/test/ObjC/DOMTestObj.h:
 23 * bindings/scripts/test/ObjC/DOMTestObj.mm:
 24 (-[DOMTestObj customObjectGenerateNoBindingsAttr]):
 25 (-[DOMTestObj setCustomObjectGenerateNoBindingsAttr:]):
 26 (-[DOMTestObj customObjectGenerateNoBindingsMethod]):
 27 (-[DOMTestObj customObjectGenerateNoBindingsMethodWithArgs:strArg:objArg:]): Expectations behaving same way as [Custom].
 28 * bindings/scripts/test/TestObj.idl: Added customObjectGenerateNoBindingsAttr,
 29 customObjectGenerateNoBindingsMethod, customObjectGenerateNoBindingsMethodWithArgs.
 30
1312015-07-28 Carlos Garcia Campos <cgarcia@igalia.com>
232
333 [GTK] Use fastMalloc instead of g_slice

Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm

@@sub SkipAttribute {
223223 my $attribute = shift;
224224
225225 if ($attribute->signature->extendedAttributes->{"Custom"}
226  || $attribute->signature->extendedAttributes->{"CustomGetter"}) {
 226 || $attribute->signature->extendedAttributes->{"CustomGetter"}
 227 || $attribute->signature->extendedAttributes->{"CustomObjectGenerateNoBindings"}) {
227228 return 1;
228229 }
229230

@@sub SkipFunction {
283284
284285 my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($function->signature->name);
285286 my $functionReturnType = $prefix eq "set_" ? "void" : $function->signature->type;
286  my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"};
 287 my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"CustomObjectGenerateNoBindings"};
287288 my $callWith = $function->signature->extendedAttributes->{"CallWith"};
288289 my $isUnsupportedCallWith = $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments") || $codeGenerator->ExtendedAttributeContains($callWith, "CallStack");
289290

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

@@sub GenerateImplementation
22082208
22092209 }
22102210 $numAttributes = $numAttributes + 1 if NeedsConstructorProperty($interface);
 2211 my @nonCustomObjectGenerateNoBindingsAttributes;
 2212 foreach my $attribute (@{$interface->attributes}) {
 2213 if (!$attribute->signature->extendedAttributes->{"CustomObjectGenerateNoBindings"}) {
 2214 push(@nonCustomObjectGenerateNoBindingsAttributes, $attribute);
 2215 }
 2216 }
22112217 if ($numAttributes > 0) {
2212  foreach my $attribute (@{$interface->attributes}) {
 2218 foreach my $attribute (@nonCustomObjectGenerateNoBindingsAttributes) {
22132219 my $name = $attribute->signature->name;
22142220 my $type = $attribute->signature->type;
22152221 my $isNullable = $attribute->signature->isNullable;

@@sub GenerateImplementation
25522558 }
25532559 }
25542560
2555  foreach my $attribute (@{$interface->attributes}) {
 2561 foreach my $attribute (@nonCustomObjectGenerateNoBindingsAttributes) {
25562562 if (!IsReadonly($attribute)) {
25572563 my $name = $attribute->signature->name;
25582564 my $type = $attribute->signature->type;

@@sub GenerateImplementation
27592765 # Functions
27602766 if ($numFunctions > 0) {
27612767 my $inAppleCopyright = 0;
 2768 my @nonCustomObjectGenerateNoBindingsFunctions;
27622769 foreach my $function (@{$interface->functions}) {
 2770 if (!$function->signature->extendedAttributes->{"CustomObjectGenerateNoBindings"}) {
 2771 push(@nonCustomObjectGenerateNoBindingsFunctions, $function);
 2772 }
 2773 }
 2774 foreach my $function (@nonCustomObjectGenerateNoBindingsFunctions) {
27632775 my $needsAppleCopyright = $function->signature->extendedAttributes->{"AppleCopyright"};
27642776 if ($needsAppleCopyright) {
27652777 if (!$inAppleCopyright) {

Source/WebCore/bindings/scripts/IDLAttributes.txt

@@CustomPutFunction
4949CustomReturn
5050CustomSetter
5151CustomToJSObject
 52CustomObjectGenerateNoBindings
5253Default=NullString|Undefined
5354Deletable
5455DoNotCheckConstants

Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

@@JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(JSC::E
9797JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*);
9898JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*);
9999JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*);
 100JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomObjectGenerateNoBindingsMethod(JSC::ExecState*);
 101JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomObjectGenerateNoBindingsMethodWithArgs(JSC::ExecState*);
100102JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(JSC::ExecState*);
101103JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(JSC::ExecState*);
102104JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*);

@@JSC::EncodedJSValue jsTestObjStringAttrWithSetterException(JSC::ExecState*, JSC:
227229void setJSTestObjStringAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
228230JSC::EncodedJSValue jsTestObjCustomAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
229231void setJSTestObjCustomAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 232JSC::EncodedJSValue jsTestObjCustomObjectGenerateNoBindingsAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
 233void setJSTestObjCustomObjectGenerateNoBindingsAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
230234JSC::EncodedJSValue jsTestObjOnfoo(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
231235void setJSTestObjOnfoo(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
232236JSC::EncodedJSValue jsTestObjWithScriptStateAttribute(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);

@@static const HashTableValue JSTestObjPrototypeTableValues[] =
519523 { "attrWithSetterException", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttrWithSetterException) },
520524 { "stringAttrWithGetterException", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithGetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjStringAttrWithGetterException) },
521525 { "stringAttrWithSetterException", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithSetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjStringAttrWithSetterException) },
 526 { "customObjectGenerateNoBindingsAttr", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomObjectGenerateNoBindingsAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjCustomObjectGenerateNoBindingsAttr) },
522527 { "onfoo", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjOnfoo), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjOnfoo) },
523528 { "withScriptStateAttribute", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjWithScriptStateAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjWithScriptStateAttribute) },
524529 { "withScriptExecutionContextAttribute", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjWithScriptExecutionContextAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjWithScriptExecutionContextAttribute) },

@@static const HashTableValue JSTestObjPrototypeTableValues[] =
598603 { "methodWithException", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t) (0) },
599604 { "customMethod", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t) (0) },
600605 { "customMethodWithArgs", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t) (3) },
 606 { "customObjectGenerateNoBindingsMethod", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomObjectGenerateNoBindingsMethod), (intptr_t) (0) },
 607 { "customObjectGenerateNoBindingsMethodWithArgs", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomObjectGenerateNoBindingsMethodWithArgs), (intptr_t) (3) },
601608 { "addEventListener", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t) (2) },
602609 { "removeEventListener", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t) (2) },
603610 { "withScriptStateVoid", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t) (0) },

Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h

@@WEBCORE_EXPORT @interface DOMTestObj : DOMObject
9090@property (copy) NSString *stringAttrWithGetterException;
9191@property (copy) NSString *stringAttrWithSetterException;
9292@property int customAttr;
 93@property int customObjectGenerateNoBindingsAttr;
9394@property int withScriptStateAttribute;
9495@property (strong) DOMTestObj *withScriptExecutionContextAttribute;
9596@property (strong) DOMTestObj *withScriptStateAttributeRaises;

@@WEBCORE_EXPORT @interface DOMTestObj : DOMObject
140141- (void)methodWithException;
141142- (void)customMethod;
142143- (void)customMethodWithArgs:(int)longArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg;
 144- (void)customObjectGenerateNoBindingsMethod;
 145- (void)customObjectGenerateNoBindingsMethodWithArgs:(int)longArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg;
143146- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture;
144147- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture;
145148- (void)withScriptStateVoid;

Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm

438438 IMPL->setCustomAttr(newCustomAttr);
439439}
440440
 441- (int)customObjectGenerateNoBindingsAttr
 442{
 443 WebCore::JSMainThreadNullState state;
 444 return IMPL->customObjectGenerateNoBindingsAttr();
 445}
 446
 447- (void)setCustomObjectGenerateNoBindingsAttr:(int)newCustomObjectGenerateNoBindingsAttr
 448{
 449 WebCore::JSMainThreadNullState state;
 450 IMPL->setCustomObjectGenerateNoBindingsAttr(newCustomObjectGenerateNoBindingsAttr);
 451}
 452
441453- (int)withScriptStateAttribute
442454{
443455 WebCore::JSMainThreadNullState state;

919931 IMPL->customMethodWithArgs(longArg, strArg, core(objArg));
920932}
921933
 934- (void)customObjectGenerateNoBindingsMethod
 935{
 936 WebCore::JSMainThreadNullState state;
 937 IMPL->customObjectGenerateNoBindingsMethod();
 938}
 939
 940- (void)customObjectGenerateNoBindingsMethodWithArgs:(int)longArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg
 941{
 942 WebCore::JSMainThreadNullState state;
 943 IMPL->customObjectGenerateNoBindingsMethodWithArgs(longArg, strArg, core(objArg));
 944}
 945
922946- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture
923947{
924948 WebCore::JSMainThreadNullState state;

Source/WebCore/bindings/scripts/test/TestObj.idl

@@enum _optional { "", "OptionalValue1", "OptionalValue2", "OptionalValue3" };
109109 [Custom] void customMethod();
110110 [Custom] void customMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
111111
 112 // 'CustomObjectGenerateNoBindings' extended attribute
 113 [CustomObjectGenerateNoBindings] attribute long customObjectGenerateNoBindingsAttr;
 114 [CustomObjectGenerateNoBindings] void customObjectGenerateNoBindingsMethod();
 115 [CustomObjectGenerateNoBindings] void customObjectGenerateNoBindingsMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
 116
112117 void addEventListener(DOMString type, EventListener listener, optional boolean useCapture);
113118 void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture);
114119 attribute EventHandler onfoo;