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

Unified Diff: Source/bindings/scripts/CodeGeneratorV8.pm

Issue 17572008: WIP IDL compiler rewrite (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: non-callback headers working Created 7 years, 6 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 | « no previous file | Source/bindings/scripts/callbackHeader.template » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/CodeGeneratorV8.pm
diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
index 1a5429d29c03c3db7d1d3329d406c56cba0398fb..fa7dca7eb7a05084fda6756031e2074d857b6da1 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -278,19 +278,26 @@ sub IDLFileForInterface
my $interfaceName = shift;
unless ($idlFiles) {
+# use Data::Dumper;
+# print "[direc]", Dumper($idlDirectories), "\n";
my @directories = map { $_ = "$sourceRoot/$_" if -d "$sourceRoot/$_"; $_ } @$idlDirectories;
push(@directories, ".");
+# print "[directories]", Dumper(@directories), "\n";
$idlFiles = { };
foreach my $idlFile (@$dependentIdlFiles) {
$idlFiles->{fileparse(basename($idlFile), ".idl")} = $idlFile;
}
+# use Data::Dumper;
+# print "[idlFiles]", Dumper($idlFiles), "\n";
my $wanted = sub {
+# print "<find> ", $File::Find::name, "\n";
$idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/;
$File::Find::prune = 1 if /^\../;
};
find($wanted, @directories);
+# print "[idlFiles]", scalar(keys($idlFiles)), "\n";
}
return $idlFiles->{$interfaceName};
@@ -329,6 +336,11 @@ sub GenerateInterface
my $object = shift;
my $interface = shift;
+ print "[Parents of] ", $interface->name, "\n";
+# ForAllParents($interface, sub {
+# my $parent = shift;
+# print " - ", $parent->name, "\n"
+# });
%callbackFunctionTypeHash = map { $_->name => $_ } @{$idlDocument->callbackFunctions};
%enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations};
my $v8ClassName = GetV8ClassName($interface);
@@ -456,6 +468,7 @@ sub HeaderFilesForInterface
my $interfaceName = shift;
my $implClassName = shift;
+ use Data::Dumper;
my @includes = ();
if (IsTypedArrayType($interfaceName)) {
push(@includes, "wtf/${interfaceName}.h");
@@ -467,6 +480,7 @@ sub HeaderFilesForInterface
my $idlRelPath= "bindings/" . File::Spec->abs2rel($idlFilename, $sourceRoot);
push(@includes, dirname($idlRelPath) . "/" . $implClassName . ".h");
}
+# print "[HeaderFilesForInterface]", Dumper(@includes);
return @includes;
}
@@ -618,17 +632,24 @@ sub GenerateHeader
my $v8ClassName = GetV8ClassName($interface);
# Copy contents of parent interfaces except the first parent.
- my @parents;
- AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents);
+ AddMethodsConstantsAndAttributesFromParentInterfaces($interface); # needed for SVG* only
LinkOverloadedFunctions($interface);
# Ensure the IsDOMNodeType function is in sync.
- die("IsDOMNodeType is out of date with respect to $interfaceName") if IsDOMNodeType($interfaceName) != InheritsInterface($interface, "Node");
+ my $_dom = IsDOMNodeType($interfaceName) ? "DOM" : "";
+ my $_inh = InheritsInterface($interface, "Node") ? "INH" : "";
+ if(IsDOMNodeType($interfaceName) != InheritsInterface($interface, "Node")) {
+# print "[DOMDOM] $_dom $_inh ", $interface->name, "\n";
+ die("IsDOMNodeType is out of date with respect to $interfaceName")
+ }
my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interfaceName);
if ($v8ClassName !~ /SVG/) {
+ use Data::Dumper;
+ print "Parents", Dumper($interface->parents);
for my $parent (@{$interface->parents}) {
+ print "ADD H $parent\n";
AddToHeaderIncludes("V8${parent}.h");
}
}
@@ -703,7 +724,8 @@ END
next if $name eq "";
my $attrExt = $function->extendedAttributes;
- if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $function->{overloadIndex} == 1) {
+# if (HasCustomMethod($attrExt) && !$attrExt->{"ImplementedBy"} && $function->{overloadIndex} == 1) {
+ if (HasCustomMethod($attrExt) && $function->{overloadIndex} == 1) {
my $conditionalString = GenerateConditionalString($function);
$header{classPublic}->add("#if ${conditionalString}\n") if $conditionalString;
$header{classPublic}->add(<<END);
@@ -729,14 +751,16 @@ END
my $name = $attribute->name;
my $attrExt = $attribute->extendedAttributes;
my $conditionalString = GenerateConditionalString($attribute);
- if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
+# if (HasCustomGetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
+ if (HasCustomGetter($attrExt)) {
$header{classPublic}->add("#if ${conditionalString}\n") if $conditionalString;
$header{classPublic}->add(<<END);
static void ${name}AttrGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>&);
END
$header{classPublic}->add("#endif // ${conditionalString}\n") if $conditionalString;
}
- if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
+# if (HasCustomSetter($attrExt) && !$attrExt->{"ImplementedBy"}) {
+ if (HasCustomSetter($attrExt)) {
$header{classPublic}->add("#if ${conditionalString}\n") if $conditionalString;
$header{classPublic}->add(<<END);
static void ${name}AttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
@@ -823,7 +847,12 @@ END
my $customWrap = $interface->extendedAttributes->{"CustomToV8"};
if ($noToV8) {
- die "Can't suppress toV8 for subclass\n" if @parents;
+ my $hasParent = 0;
+ ForAllParents($interface, sub {
+ my $parent = shift;
+ $hasParent = 1;
+ });
+ die "Can't suppress toV8 for subclass\n" if $hasParent;
} elsif ($noWrap) {
die "Must have custom toV8\n" if !$customWrap;
$header{nameSpaceWebCore}->add(<<END);
@@ -3837,6 +3866,7 @@ sub GenerateImplementationMasqueradesAsUndefined
return $code;
}
+# __IMPL__
sub GenerateImplementation
{
my $object = shift;
@@ -4205,6 +4235,20 @@ END
else
END
}
+=memo
+static v8::Local<v8::Signature> configureTemplate(
+ v8::Handle<v8::FunctionTemplate>,
+ const char* interfaceName,
+ v8::Handle<v8::FunctionTemplate> parentClass,
+ size_t fieldCount,
+
+ const BatchedAttribute*,
+ size_t attributeCount,
+ const BatchedMethod*,
+ size_t callbackCount,
+ v8::Isolate*,
+ WrapperWorldType);
+=cut
$code .= <<END;
defaultSignature = V8DOMConfiguration::configureTemplate(desc, \"${interfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount,
END
@@ -4554,6 +4598,8 @@ sub GenerateCallbackHeader
END
+#print "[CallbackHeader]", $interface->name, "\n";
+
# Functions
my $numFunctions = @{$interface->functions};
if ($numFunctions > 0) {
@@ -4613,6 +4659,8 @@ ${v8ClassName}::~${v8ClassName}()
END
+#print "[CallbackImp]", $interface->name, "\n";
+
# Functions
my $numFunctions = @{$interface->functions};
if ($numFunctions > 0) {
@@ -4997,6 +5045,8 @@ sub GetNativeType
{
my $type = shift;
my $isParameter = shift;
+ my $isw = IsWrapperType($type) ? "WT":"";
+print "[GetNativeType] $type, $isParameter $isw\n" if $type eq "ObjectArray";
my $svgNativeType = GetSVGTypeNeedingTearOff($type);
if ($svgNativeType) {
@@ -5032,6 +5082,7 @@ sub GetNativeType
die "UnionType is not supported" if IsUnionType($type);
+print "[GetNativeType] here\n" if $type eq "ObjectArray";
# We need to check [ImplementedAs] extended attribute for wrapper types.
if (IsWrapperType($type)) {
my $interface = ParseInterface($type);
@@ -5055,6 +5106,9 @@ sub GetNativeType
sub GetNativeTypeForCallbacks
{
my $type = shift;
+# print "#####\n[Callback] DOMString\n" if $type eq "DOMString";
+# print "#####\n[Callback] SerializedScriptValue\n" if $type eq "SerializedScriptValue";
+
return "const String&" if $type eq "DOMString";
return "PassRefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue";
@@ -5554,7 +5608,6 @@ sub ForAllParents
{
my $interface = shift;
my $beforeRecursion = shift;
- my $afterRecursion = shift;
my $recurse;
$recurse = sub {
@@ -5568,7 +5621,6 @@ sub ForAllParents
&$beforeRecursion($parentInterface) eq 'prune' and next;
}
&$recurse($parentInterface);
- &$afterRecursion($parentInterface) if $afterRecursion;
}
};
@@ -5584,7 +5636,6 @@ sub AddMethodsConstantsAndAttributesFromParentInterfaces
# and its ancestors will also be appended to $parents.
my $interface = shift;
- my $parents = shift;
my $first = 1;
ForAllParents($interface, sub {
@@ -5594,19 +5645,11 @@ sub AddMethodsConstantsAndAttributesFromParentInterfaces
# Ignore first parent class, already handled by the generation itself.
$first = 0;
- # Just collect the names of the direct ancestor interfaces,
- # if necessary.
- push(@$parents, $currentInterface->name);
- ForAllParents($currentInterface, sub {
- my $currentInterface = shift;
- push(@$parents, $currentInterface->name);
- });
return 'prune';
}
- # Collect the name of this additional parent.
- push(@$parents, $currentInterface->name) if $parents;
-
+ # SVG* only!
+# print $interface->name, "[Came here with]", $currentInterface->name, "\n";
# Add this parent's members to $interface.
push(@{$interface->constants}, @{$currentInterface->constants});
push(@{$interface->functions}, @{$currentInterface->functions});
@@ -5618,7 +5661,7 @@ sub FindSuperMethod
{
my ($interface, $functionName) = @_;
my $indexer;
- ForAllParents($interface, undef, sub {
+ ForAllParents($interface, sub {
my $currentInterface = shift;
foreach my $function (@{$currentInterface->functions}) {
if ($function->name eq $functionName) {
« no previous file with comments | « no previous file | Source/bindings/scripts/callbackHeader.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698