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

Unified Diff: Source/bindings/scripts/generate-bindings.pl

Issue 15984007: Refactor IDL value checking into SemanticAnalyzer.pm (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add dependency Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/scripts/SemanticAnalyzer.pm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/generate-bindings.pl
diff --git a/Source/bindings/scripts/generate-bindings.pl b/Source/bindings/scripts/generate-bindings.pl
index b3f3d43298ac01f3e561873f5119d564763adf41..583ad4456a28725fdd54f783454213224b36b272 100755
--- a/Source/bindings/scripts/generate-bindings.pl
+++ b/Source/bindings/scripts/generate-bindings.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -w -I../../core/scripts
#
# Copyright (C) 2005 Apple Computer, Inc.
# Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
@@ -38,6 +38,7 @@ use Cwd;
use IDLParser;
use CodeGeneratorV8;
+use SemanticAnalyzer;
my @idlDirectories;
my $outputDirectory;
@@ -121,8 +122,8 @@ my $targetParser = IDLParser->new(!$verbose);
my $targetDocument = $targetParser->Parse($targetIdlFile, $defines, $preprocessor);
if ($idlAttributesFile) {
- my $idlAttributes = loadIDLAttributes($idlAttributesFile);
- checkIDLAttributes($idlAttributes, $targetDocument, basename($targetIdlFile));
+ my $semanticAnalyzer = SemanticAnalyzer->new($idlAttributesFile);
+ $semanticAnalyzer->checkIDLAttributes($targetDocument, basename($targetIdlFile));
}
foreach my $idlFile (@supplementedIdlFiles) {
@@ -215,86 +216,3 @@ sub generateEmptyHeaderAndCpp
print FH $contents;
close FH;
}
-
-sub loadIDLAttributes
-{
- my $idlAttributesFile = shift;
-
- my %idlAttributes;
- open FH, "<", $idlAttributesFile or die "Couldn't open $idlAttributesFile: $!";
- while (my $line = <FH>) {
- chomp $line;
- next if $line =~ /^\s*#/;
- next if $line =~ /^\s*$/;
-
- if ($line =~ /^\s*([^=\s]*)\s*=?\s*(.*)/) {
- my $name = $1;
- $idlAttributes{$name} = {};
- if ($2) {
- foreach my $rightValue (split /\|/, $2) {
- $rightValue =~ s/^\s*|\s*$//g;
- $rightValue = "VALUE_IS_MISSING" unless $rightValue;
- $idlAttributes{$name}{$rightValue} = 1;
- }
- } else {
- $idlAttributes{$name}{"VALUE_IS_MISSING"} = 1;
- }
- } else {
- die "The format of " . basename($idlAttributesFile) . " is wrong: line $.\n";
- }
- }
- close FH;
-
- return \%idlAttributes;
-}
-
-sub checkIDLAttributes
-{
- my $idlAttributes = shift;
- my $document = shift;
- my $idlFile = shift;
-
- foreach my $interface (@{$document->interfaces}) {
- checkIfIDLAttributesExists($idlAttributes, $interface->extendedAttributes, $idlFile);
-
- foreach my $attribute (@{$interface->attributes}) {
- checkIfIDLAttributesExists($idlAttributes, $attribute->signature->extendedAttributes, $idlFile);
- }
-
- foreach my $function (@{$interface->functions}) {
- checkIfIDLAttributesExists($idlAttributes, $function->signature->extendedAttributes, $idlFile);
- foreach my $parameter (@{$function->parameters}) {
- checkIfIDLAttributesExists($idlAttributes, $parameter->extendedAttributes, $idlFile);
- }
- }
- }
-}
-
-sub checkIfIDLAttributesExists
-{
- my $idlAttributes = shift;
- my $extendedAttributes = shift;
- my $idlFile = shift;
-
- my $error;
- OUTER: for my $name (keys %$extendedAttributes) {
- if (!exists $idlAttributes->{$name}) {
- $error = "Unknown IDL attribute [$name] is found at $idlFile.";
- last OUTER;
- }
- if ($idlAttributes->{$name}{"*"}) {
- next;
- }
- for my $rightValue (split /\s*\|\s*/, $extendedAttributes->{$name}) {
- if (!exists $idlAttributes->{$name}{$rightValue}) {
- $error = "Unknown IDL attribute [$name=" . $extendedAttributes->{$name} . "] is found at $idlFile.";
- last OUTER;
- }
- }
- }
- if ($error) {
- die "IDL ATTRIBUTE CHECKER ERROR: $error
-If you want to add a new IDL attribute, you need to add it to bindings/scripts/IDLAttributes.txt and add explanations to the Blink IDL document (http://chromium.org/blink/webidl).
-";
- }
-}
« no previous file with comments | « Source/bindings/scripts/SemanticAnalyzer.pm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698