⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codegeneratorjs.pm

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 PM
📖 第 1 页 / 共 5 页
字号:
## Copyright (C) 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org># Copyright (C) 2006 Anders Carlsson <andersca@mac.com># Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org># Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org># Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.# # This library is free software; you can redistribute it and/or# modify it under the terms of the GNU Library General Public# License as published by the Free Software Foundation; either# version 2 of the License, or (at your option) any later version.## This library is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU# Library General Public License for more details.## You should have received a copy of the GNU Library General Public License# aint with this library; see the file COPYING.LIB.  If not, write to# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,# Boston, MA 02110-1301, USA.package CodeGeneratorJS;use File::stat;my $module = "";my $outputDir = "";my @headerContentHeader = ();my @headerContent = ();my %headerIncludes = ();my @implContentHeader = ();my @implContent = ();my %implIncludes = ();my %implKJSIncludes = ();# Default .h templatemy $headerTemplate = << "EOF";/*    This file is part of the WebKit open source project.    This file has been generated by generate-bindings.pl. DO NOT MODIFY!    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Library General Public License for more details.    You should have received a copy of the GNU Library General Public License    along with this library; see the file COPYING.LIB.  If not, write to    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,    Boston, MA 02110-1301, USA.*/EOF# Default constructorsub new{    my $object = shift;    my $reference = { };    $codeGenerator = shift;    $outputDir = shift;    bless($reference, $object);    return $reference;}sub finish{    my $object = shift;    # Commit changes!    $object->WriteData();}sub leftShift($$) {    my ($value, $distance) = @_;    return (($value << $distance) & 0xFFFFFFFF);}# Params: 'domClass' structsub GenerateInterface{    my $object = shift;    my $dataNode = shift;    my $defines = shift;    # Start actual generation    $object->GenerateHeader($dataNode);    $object->GenerateImplementation($dataNode);    my $name = $dataNode->name;    # Open files for writing    my $headerFileName = "$outputDir/JS$name.h";    my $implFileName = "$outputDir/JS$name.cpp";    open($IMPL, ">$implFileName") || die "Couldn't open file $implFileName";    open($HEADER, ">$headerFileName") || die "Couldn't open file $headerFileName";}# Params: 'idlDocument' structsub GenerateModule{    my $object = shift;    my $dataNode = shift;    $module = $dataNode->module;}sub GetParentClassName{    my $dataNode = shift;    return $dataNode->extendedAttributes->{"LegacyParent"} if $dataNode->extendedAttributes->{"LegacyParent"};    return "DOMObject" if @{$dataNode->parents} eq 0;    return "JS" . $codeGenerator->StripModule($dataNode->parents(0));}sub GetVisibleClassName{    my $className = shift;    return "DOMException" if $className eq "DOMCoreException";    return $className;}sub AvoidInclusionOfType{    my $type = shift;    # Special case: SVGRect.h / SVGPoint.h / SVGNumber.h / SVGMatrix.h do not exist.    return 1 if $type eq "SVGRect" or $type eq "SVGPoint" or $type eq "SVGNumber" or $type eq "SVGMatrix";    return 0;}sub UsesManualToJSImplementation{    my $type = shift;    return 1 if $type eq "Node" or $type eq "Document" or $type eq "HTMLCollection" or $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue" or $type eq "Event" or $type eq "ImageData" or $type eq "Element" or $type eq "Text";    return 0;}sub IndexGetterReturnsStrings{    my $type = shift;    return 1 if $type eq "CSSStyleDeclaration" or $type eq "MediaList" or $type eq "CSSVariablesDeclaration";    return 0;}sub CreateSVGContextInterfaceName{    my $type = shift;    return $type if $codeGenerator->IsSVGAnimatedType($type);    return "SVGPathSeg" if $type =~ /^SVGPathSeg/ and $type ne "SVGPathSegList";    return "";}sub AddIncludesForType{    my $type = $codeGenerator->StripModule(shift);    # When we're finished with the one-file-per-class    # reorganization, we won't need these special cases.    if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)        or $type eq "DOMString" or $type eq "DOMObject" or $type eq "RGBColor" or $type eq "Array") {    } elsif ($type =~ /SVGPathSeg/) {        $joinedName = $type;        $joinedName =~ s/Abs|Rel//;        $implIncludes{"${joinedName}.h"} = 1;    } elsif ($type eq "XPathNSResolver") {        $implIncludes{"JSXPathNSResolver.h"} = 1;        $implIncludes{"JSCustomXPathNSResolver.h"} = 1;    } else {        # default, include the same named file        $implIncludes{"${type}.h"} = 1;    }    # additional includes (things needed to compile the bindings but not the header)    if ($type eq "CanvasRenderingContext2D") {        $implIncludes{"CanvasGradient.h"} = 1;        $implIncludes{"CanvasPattern.h"} = 1;        $implIncludes{"CanvasStyle.h"} = 1;    }    if ($type eq "CanvasGradient" or $type eq "XPathNSResolver" or $type eq "MessagePort") {        $implIncludes{"PlatformString.h"} = 1;    }    if ($type eq "Document") {        $implIncludes{"NodeFilter.h"} = 1;    }}sub AddIncludesForSVGAnimatedType{    my $type = shift;    $type =~ s/SVGAnimated//;    if ($type eq "Point" or $type eq "Rect") {        $implIncludes{"Float$type.h"} = 1;    } elsif ($type eq "String") {        $implIncludes{"PlatformString.h"} = 1;    }}sub AddClassForwardIfNeeded{    my $implClassName = shift;    # SVGAnimatedLength/Number/etc.. are typedefs to SVGAnimtatedTemplate, so don't use class forwards for them!    push(@headerContent, "class $implClassName;\n\n") unless $codeGenerator->IsSVGAnimatedType($implClassName);}sub IsSVGTypeNeedingContextParameter{    my $implClassName = shift;    if ($implClassName =~ /SVG/ and not $implClassName =~ /Element/) {        return 1 unless $implClassName =~ /SVGPaint/ or $implClassName =~ /SVGColor/ or $implClassName =~ /SVGDocument/;    }    return 0;}sub HashValueForClassAndName{    my $class = shift;    my $name = shift;    # SVG Filter enums live in WebCore namespace (platform/graphics/)    if ($class =~ /^SVGFE*/ or $class =~ /^SVGComponentTransferFunctionElement$/) {        return "WebCore::$name";    }    return "${class}::$name";}sub hashTableAccessor{    my $noStaticTables = shift;    my $className = shift;    if ($noStaticTables) {        return "get${className}Table(exec)";    } else {        return "&${className}Table";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -