Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Source/WebCore/bindings/dart/gyp/scripts/CodeGeneratorDart.pm

Issue 9231022: WebGL support. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Final version. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009 Google Inc. 6 # Copyright (C) 2007, 2008, 2009 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # 10 #
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 # Commit changes! 102 # Commit changes!
103 $object->WriteData(); 103 $object->WriteData();
104 } 104 }
105 105
106 sub GenerateModule 106 sub GenerateModule
107 { 107 {
108 my ($object, $dataNode) = @_; 108 my ($object, $dataNode) = @_;
109 } 109 }
110 110
111 my %overrideConstructorParameters = (
112 "Float32Array" => 3,
113 "Float64Array" => 3,
114 "Int8Array" => 3,
115 "Int16Array" => 3,
116 "Int32Array" => 3,
117 "Uint8Array" => 3,
118 "Uint16Array" => 3,
119 "Uint32Array" => 3,
120 );
121
122 sub ConstructorParameterCount
123 {
124 my ($dataNode) = @_;
125 return $overrideConstructorParameters{$dataNode->name} if (exists $overrideC onstructorParameters{$dataNode->name});
126 return $dataNode->extendedAttributes->{ConstructorParameters} if (exists $da taNode->extendedAttributes->{ConstructorParameters});
127 return 0;
128 }
129
111 sub GenerateInterface 130 sub GenerateInterface
112 { 131 {
113 my ($object, $dataNode, $defines) = @_; 132 my ($object, $dataNode, $defines) = @_;
114 133
115 # Add parent classes (for multiple-inheritance) fields as needed. 134 # Add parent classes (for multiple-inheritance) fields as needed.
116 @allParents = (); 135 @allParents = ();
117 $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 0); 136 $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 0);
118 # Prepare internal structures. 137 # Prepare internal structures.
119 $codeGenerator->LinkOverloadedFunctions($dataNode); 138 $codeGenerator->LinkOverloadedFunctions($dataNode);
120 139
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 # FIXME: useCapture was marked as optional upstream, however native 224 # FIXME: useCapture was marked as optional upstream, however native
206 # implementation still requires all three parameters. JavaScript bindings 225 # implementation still requires all three parameters. JavaScript bindings
207 # have custom generation for addEventListener and removeEventListener. 226 # have custom generation for addEventListener and removeEventListener.
208 return 0 if $function->signature->name eq "addEventListener" || $function->s ignature->name eq "removeEventListener"; 227 return 0 if $function->signature->name eq "addEventListener" || $function->s ignature->name eq "removeEventListener";
209 228
210 foreach my $parameter (@{$function->parameters}) { 229 foreach my $parameter (@{$function->parameters}) {
211 return 1 if IsParameterOptionalInWebKit($parameter); 230 return 1 if IsParameterOptionalInWebKit($parameter);
212 } 231 }
213 } 232 }
214 233
234 sub CanBeConstructed
235 {
236 my ($dataNode) = @_;
237
238 return
239 $dataNode->extendedAttributes->{CanBeConstructed} || HasCustomConstructo r($dataNode);
240 }
241
215 sub HasCustomConstructor 242 sub HasCustomConstructor
216 { 243 {
217 my ($dataNode) = @_; 244 my ($dataNode) = @_;
218 245
219 # FIXME: switch to using CanBeConstructed attribute. 246 return $dataNode->extendedAttributes->{CustomConstructor} && not ($dataNode- >name =~ "Event");
220 return 1 if $dataNode->name eq "FileReader";
221 return 1 if $dataNode->name eq "XMLHttpRequest";
222 return 1 if $dataNode->name eq "WebKitCSSMatrix";
223 return 1 if $dataNode->name eq "WebKitPoint";
224
225 return 0;
226 } 247 }
227 248
228 sub IsParameterOptionalInWebKit 249 sub IsParameterOptionalInWebKit
229 { 250 {
230 my ($parameter) = @_; 251 my ($parameter) = @_;
231 252
232 # Optional callbacks are not optional parameters in native implementations, they always have a default value (0). 253 # Optional callbacks are not optional parameters in native implementations, they always have a default value (0).
233 my $optional = $parameter->extendedAttributes->{Optional}; 254 my $optional = $parameter->extendedAttributes->{Optional};
234 return $optional && $optional ne "CallWithDefaultValue" && !$parameter->exte ndedAttributes->{Callback}; 255 return $optional && $optional ne "CallWithDefaultValue" && !$parameter->exte ndedAttributes->{Callback};
235 } 256 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 391
371 sub IDLTypeToW3C 392 sub IDLTypeToW3C
372 { 393 {
373 my ($idlType,) = @_; 394 my ($idlType,) = @_;
374 return $idlTypeToW3C{$idlType} if exists $idlTypeToW3C{$idlType}; 395 return $idlTypeToW3C{$idlType} if exists $idlTypeToW3C{$idlType};
375 return $idlType; 396 return $idlType;
376 } 397 }
377 398
378 my %idlTypeToDart = ( 399 my %idlTypeToDart = (
379 "any" => "Object", 400 "any" => "Object",
401 "any[]" => "List",
380 "boolean" => "bool", 402 "boolean" => "bool",
381 "custom" => "Object", 403 "custom" => "Object",
382 "object" => "Object", 404 "object" => "Object",
383 "Array" => "List", 405 "Array" => "List",
384 "DOMObject" => "Object", 406 "DOMObject" => "Object",
385 "DOMString" => "String", 407 "DOMString" => "String",
386 "DOMString[]" => "DOMStringList", 408 "DOMString[]" => "DOMStringList",
387 "DOMTimeStamp" => "int", 409 "DOMTimeStamp" => "int",
388 "ObjectArray" => "List", 410 "ObjectArray" => "List",
389 "SerializedScriptValue" => "Object", 411 "SerializedScriptValue" => "Object",
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 "SVGFitToViewBox" => 1, 1365 "SVGFitToViewBox" => 1,
1344 "SVGLangSpace" => 1, 1366 "SVGLangSpace" => 1,
1345 "SVGLocatable" => 1, 1367 "SVGLocatable" => 1,
1346 "SVGStylable" => 1, 1368 "SVGStylable" => 1,
1347 "SVGTests" => 1, 1369 "SVGTests" => 1,
1348 "SVGTransformable" => 1, 1370 "SVGTransformable" => 1,
1349 "SVGViewSpec" => 1, 1371 "SVGViewSpec" => 1,
1350 "SVGZoomAndPan" => 1, 1372 "SVGZoomAndPan" => 1,
1351 ); 1373 );
1352 1374
1353 sub ListLike 1375 sub ListLikeWithBase
1354 { 1376 {
1355 my ($elementType, $needsAuxiliaryAccessors) = @_; 1377 my ($elementType, $baseClass, $needsAuxiliaryAccessors) = @_;
1356 1378
1357 my @auxiliaryMethods = (); 1379 my @auxiliaryMethods = ();
1358 if ($needsAuxiliaryAccessors) { 1380 if ($needsAuxiliaryAccessors) {
1359 push(@auxiliaryMethods, ["$elementType operator [] (int index)", "numeri cIndexGetter", 2]); 1381 push(@auxiliaryMethods, ["$elementType operator [] (int index)", "numeri cIndexGetter", 2]);
1360 push(@auxiliaryMethods, ["void operator []= (int index, $elementType val ue)", "numericIndexSetter", 3]); 1382 push(@auxiliaryMethods, ["void operator []= (int index, $elementType val ue)", "numericIndexSetter", 3]);
1361 } 1383 }
1362 1384
1363 return IDLTypeInfoStruct->new( 1385 return IDLTypeInfoStruct->new(
1364 additionalInterfaces => ["List<$elementType>"], 1386 additionalInterfaces => ["List<$elementType>"],
1365 superClass => "ListBase<$elementType>", 1387 superClass => "$baseClass",
1366 auxilaryMethods => \@auxiliaryMethods 1388 auxilaryMethods => \@auxiliaryMethods
1367 ); 1389 );
1368 } 1390 }
1369 1391
1392 sub ListLike
1393 {
1394 my ($elementType, $needsAuxiliaryAccessors) = @_;
1395
1396 return ListLikeWithBase($elementType, "ListBase<$elementType>", $needsAuxili aryAccessors);
1397 }
1398
1399 sub ArrayBufferLike
1400 {
1401 my ($elementType, $needsAuxiliaryAccessors) = @_;
1402
1403 return ListLikeWithBase($elementType, "ArrayBufferViewImplementation", $need sAuxiliaryAccessors);
1404 }
1405
1370 sub MapLike 1406 sub MapLike
1371 { 1407 {
1372 # FIXME: most probably we need to deduce more types using hints like 1408 # FIXME: most probably we need to deduce more types using hints like
1373 # HasNameGetter, CustomDeleteProperty, CustomGetPropertyNames, DelegatingPut Function 1409 # HasNameGetter, CustomDeleteProperty, CustomGetPropertyNames, DelegatingPut Function
1374 # attributes. 1410 # attributes.
1375 # FIXME: technically at least DOMStringMap.setItem and DOMStringMap.item cou ld be automatically 1411 # FIXME: technically at least DOMStringMap.setItem and DOMStringMap.item cou ld be automatically
1376 # generated and then used from [] and []=. I don't do it for now not to mes s up with IDLs too 1412 # generated and then used from [] and []=. I don't do it for now not to mes s up with IDLs too
1377 # much. 1413 # much.
1378 # FIXME: support removal of elements if allowed (it is at least for DOMStrin gMap.) 1414 # FIXME: support removal of elements if allowed (it is at least for DOMStrin gMap.)
1379 my ($interfaceName, $keyType, $elementType) = @_; 1415 my ($interfaceName, $keyType, $elementType) = @_;
1380 return IDLTypeInfoStruct->new( 1416 return IDLTypeInfoStruct->new(
1381 additionalInterfaces => ["Map<$keyType, $elementType>"], 1417 additionalInterfaces => ["Map<$keyType, $elementType>"],
1382 superClass => "MapBase<$keyType, $elementType>", 1418 superClass => "MapBase<$keyType, $elementType>",
1383 auxilaryMethods => [ 1419 auxilaryMethods => [
1384 ["Collection<$keyType> getKeys()", "getKeys", 1], 1420 ["Collection<$keyType> getKeys()", "getKeys", 1],
1385 ["$elementType operator [] ($keyType k)", "item", 2], 1421 ["$elementType operator [] ($keyType k)", "item", 2],
1386 ["operator []= ($keyType k, $elementType v)", "setItem", 3], 1422 ["operator []= ($keyType k, $elementType v)", "setItem", 3],
1387 ["$elementType remove($keyType k)", "deleteItem", 2], 1423 ["$elementType remove($keyType k)", "deleteItem", 2],
1388 ], 1424 ],
1389 ); 1425 );
1390 } 1426 }
1391 1427
1392 my %idlTypeInfoOverrides = ( 1428 my %idlTypeInfoOverrides = (
1393 "CanvasPixelArray" => ListLike("int", 1), 1429 "CanvasPixelArray" => ListLike("int", 1),
1394 "DOMStringMap" => MapLike("DOMStringMap", "String", "String"), 1430 "DOMStringMap" => MapLike("DOMStringMap", "String", "String"),
1395 "HTMLCollection" => ListLike("Node"), 1431 "HTMLCollection" => ListLike("Node"),
1396 "NodeList" => ListLike("Node"), 1432 "NodeList" => ListLike("Node"),
1397 "StyleSheetList" => ListLike("StyleSheet"), 1433 "StyleSheetList" => ListLike("StyleSheet"),
1434 "ArrayBufferView" => ListLikeWithBase("num", "ListBase<num>"),
1435 "Float32Array" => ArrayBufferLike("double", 1),
1436 "Float64Array" => ArrayBufferLike("double", 1),
1437 "Int8Array" => ArrayBufferLike("int", 1),
1438 "Int16Array" => ArrayBufferLike("int", 1),
1439 "Int32Array" => ArrayBufferLike("int", 1),
1440 "Uint8Array" => ArrayBufferLike("int", 1),
1441 "Uint16Array" => ArrayBufferLike("int", 1),
1442 "Uint32Array" => ArrayBufferLike("int", 1),
1398 ); 1443 );
1399 1444
1400 # FIXME: turn into the single IDL type info registry. 1445 # FIXME: turn into the single IDL type info registry.
1401 sub IDLTypeInfo 1446 sub IDLTypeInfo
1402 { 1447 {
1403 my ($dataNode,) = @_; 1448 my ($dataNode,) = @_;
1404 my $override = $idlTypeInfoOverrides{$dataNode->name}; 1449 my $override = $idlTypeInfoOverrides{$dataNode->name};
1405 return $override if $override; 1450 return $override if $override;
1406 1451
1407 my $parentInterface = ParentInterface($dataNode); 1452 my $parentInterface = ParentInterface($dataNode);
(...skipping 21 matching lines...) Expand all
1429 1474
1430 push(@implementedInterfaces, @{IDLTypeInfo($dataNode)->additionalInterfaces} ); 1475 push(@implementedInterfaces, @{IDLTypeInfo($dataNode)->additionalInterfaces} );
1431 push(@implementedInterfaces, @allParents); 1476 push(@implementedInterfaces, @allParents);
1432 1477
1433 if (@implementedInterfaces) { 1478 if (@implementedInterfaces) {
1434 $extendsClause = " extends " . join(", ", @implementedInterfaces); 1479 $extendsClause = " extends " . join(", ", @implementedInterfaces);
1435 } 1480 }
1436 1481
1437 # Build default clause if any. 1482 # Build default clause if any.
1438 my $defaultClause = ""; 1483 my $defaultClause = "";
1439 if (HasCustomConstructor($dataNode)) { 1484 if (CanBeConstructed($dataNode)) {
1440 $defaultClause = " default ${w3cInterfaceName}Implementation"; 1485 $defaultClause = " default ${w3cInterfaceName}Implementation";
1441 push(@customCallbackDeclarations, GenerateCustomCallbackDeclaration("con structorCallback")); 1486 push(@customCallbackDeclarations, GenerateCustomCallbackDeclaration("con structorCallback"));
1442 } 1487 }
1443 1488
1444 push(@dartInterfaceContent, "\ninterface ${w3cInterfaceName}${extendsClause} ${defaultClause} {\n"); 1489 push(@dartInterfaceContent, "\ninterface ${w3cInterfaceName}${extendsClause} ${defaultClause} {\n");
1445 push(@dartInterfaceContent, "\n // Constants.\n"); 1490 push(@dartInterfaceContent, "\n // Constants.\n");
1446 foreach my $constant (@{$dataNode->constants}) { 1491 foreach my $constant (@{$dataNode->constants}) {
1447 my $name = $constant->name; 1492 my $name = $constant->name;
1448 my $value = $constant->value; 1493 my $value = $constant->value;
1449 1494
(...skipping 30 matching lines...) Expand all
1480 1525
1481 foreach my $auxilaryMethod (@{IDLTypeInfo($dataNode)->auxilaryMethods}) { 1526 foreach my $auxilaryMethod (@{IDLTypeInfo($dataNode)->auxilaryMethods}) {
1482 my $dartDeclaration = $auxilaryMethod->[0]; 1527 my $dartDeclaration = $auxilaryMethod->[0];
1483 my $descriptor = CreateFunctionNativeDescriptor($interfaceName, $auxilar yMethod->[1], $auxilaryMethod->[2]); 1528 my $descriptor = CreateFunctionNativeDescriptor($interfaceName, $auxilar yMethod->[1], $auxilaryMethod->[2]);
1484 my $nativeId = $descriptor->nativeId; 1529 my $nativeId = $descriptor->nativeId;
1485 push(@dartImplContent, " $dartDeclaration native \"$nativeId\";\n"); 1530 push(@dartImplContent, " $dartDeclaration native \"$nativeId\";\n");
1486 push(@customCallbackDeclarations, GenerateCustomCallbackDeclaration($des criptor->cppCallbackName)); 1531 push(@customCallbackDeclarations, GenerateCustomCallbackDeclaration($des criptor->cppCallbackName));
1487 } 1532 }
1488 1533
1489 if (HasCustomConstructor($dataNode)) { 1534 if (HasCustomConstructor($dataNode)) {
1490 my $parameterCount = $dataNode->extendedAttributes->{"ConstructorParamet ers"} || 0; 1535 my $parameterCount = ConstructorParameterCount($dataNode);
1491 my $descriptor = CreateFunctionNativeDescriptor($interfaceName, "constru ctor", 1 + $parameterCount); 1536 my $descriptor = CreateFunctionNativeDescriptor($interfaceName, "constru ctor", 1 + $parameterCount);
1492 my $nativeId = $descriptor->nativeId; 1537 my $nativeId = $descriptor->nativeId;
1493 my $parameters = DartAnonymousNamedOptionalParameters($parameterCount); 1538 my $parameters = DartAnonymousNamedOptionalParameters($parameterCount);
1494 my $arguments = DartAnonymousArguments($parameterCount); 1539 my $arguments = DartAnonymousArguments($parameterCount);
1495 push(@dartInterfaceContent, " $w3cInterfaceName($parameters);\n"); 1540 push(@dartInterfaceContent, " $w3cInterfaceName($parameters);\n");
1496 push(@dartImplContent, <<END); 1541 push(@dartImplContent, <<END);
1497 $implementationClassName($parameters) { 1542 $implementationClassName($parameters) {
1498 this._bind($arguments); 1543 this._bind($arguments);
1499 } 1544 }
1500 END 1545 END
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 1732
1688 if (defined($DART_IMPL)) { 1733 if (defined($DART_IMPL)) {
1689 # Write content of Dart file. 1734 # Write content of Dart file.
1690 print $DART_IMPL @dartImplContent; 1735 print $DART_IMPL @dartImplContent;
1691 close($DART_IMPL); 1736 close($DART_IMPL);
1692 undef($DART_IMPL); 1737 undef($DART_IMPL);
1693 1738
1694 @dartImplContent = (); 1739 @dartImplContent = ();
1695 } 1740 }
1696 } 1741 }
OLDNEW
« no previous file with comments | « Source/WebCore/bindings/dart/gyp/overrides.gypi ('k') | Source/WebCore/html/canvas/Float32Array.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698