2 # Copyright (C) 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
4 # Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org>
5 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
6 # Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
18 # You should have received a copy of the GNU Library General Public License
19 # aint with this library; see the file COPYING.LIB. If not, write to
20 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 # Boston, MA 02110-1301, USA.
23 package CodeGeneratorJS;
30 my @headerContent = ();
31 my @implContentHeader = ();
33 my %implIncludes = ();
36 my $headerTemplate = << "EOF";
38 This file is part of the WebKit open source project.
39 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
41 This library is free software; you can redistribute it and/or
42 modify it under the terms of the GNU Library General Public
43 License as published by the Free Software Foundation; either
44 version 2 of the License, or (at your option) any later version.
46 This library is distributed in the hope that it will be useful,
47 but WITHOUT ANY WARRANTY; without even the implied warranty of
48 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
49 Library General Public License for more details.
51 You should have received a copy of the GNU Library General Public License
52 along with this library; see the file COPYING.LIB. If not, write to
53 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
54 Boston, MA 02110-1301, USA.
64 $codeGenerator = shift;
67 bless($reference, $object);
80 my ($value, $distance) = @_;
81 return (($value << $distance) & 0xFFFFFFFF);
84 # Params: 'domClass' struct
91 # Start actual generation
92 $object->GenerateHeader($dataNode);
93 $object->GenerateImplementation($dataNode);
95 my $name = $dataNode->name;
97 # Open files for writing
98 my $headerFileName = "$outputDir/JS$name.h";
99 my $implFileName = "$outputDir/JS$name.cpp";
101 open($IMPL, ">$implFileName") || die "Couldn't open file $implFileName";
102 open($HEADER, ">$headerFileName") || die "Couldn't open file $headerFileName";
105 # Params: 'idlDocument' struct
109 my $dataNode = shift;
111 $module = $dataNode->module;
114 sub GetParentClassName
116 my $dataNode = shift;
118 return $dataNode->extendedAttributes->{"LegacyParent"} if $dataNode->extendedAttributes->{"LegacyParent"};
119 return "DOMObject" if @{$dataNode->parents} eq 0;
120 return "JS" . $codeGenerator->StripModule($dataNode->parents(0));
123 sub GetLegacyHeaderIncludes
125 my $legacyParent = shift;
127 return "#include \"JSHTMLInputElementBase.h\"\n\n" if $legacyParent eq "JSHTMLInputElementBase";
128 return "#include \"kjs_window.h\"\n\n" if $legacyParent eq "KJS::Window";
129 return "#include \"kjs_events.h\"\n\n" if $module eq "events";
130 return "#include \"kjs_css.h\"\n\n" if $module eq "css";
131 return "#include \"kjs_html.h\"\n\n" if $module eq "html";
133 die "Don't know what headers to include for module $module";
136 sub GetVisibleClassName
138 my $className = shift;
140 return "DOMException" if $className eq "DOMCoreException";
144 sub AvoidInclusionOfType
148 # Special case: SVGRect.h / SVGPoint.h / SVGNumber.h / SVGMatrix.h do not exist.
149 return 1 if $type eq "SVGRect" or $type eq "SVGPoint" or $type eq "SVGNumber" or $type eq "SVGMatrix";
153 sub UsesManualToJSImplementation
157 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 "CanvasPixelArray";
161 sub IndexGetterReturnsStrings
165 return 1 if $type eq "CSSStyleDeclaration" or $type eq "MediaList";
169 sub CreateSVGContextInterfaceName
173 return $type if $codeGenerator->IsSVGAnimatedType($type);
174 return "SVGPathSeg" if $type =~ /^SVGPathSeg/ and $type ne "SVGPathSegList";
179 sub AddIncludesForType
181 my $type = $codeGenerator->StripModule(shift);
183 # When we're finished with the one-file-per-class
184 # reorganization, we won't need these special cases.
185 if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)
186 or $type eq "DOMString" or $type eq "DOMObject" or $type eq "RGBColor") {
187 } elsif ($type =~ /SVGPathSeg/) {
189 $joinedName =~ s/Abs|Rel//;
190 $implIncludes{"${joinedName}.h"} = 1;
191 } elsif ($type eq "XPathNSResolver") {
192 $implIncludes{"JSXPathNSResolver.h"} = 1;
193 $implIncludes{"JSCustomXPathNSResolver.h"} = 1;
195 # default, include the same named file
196 $implIncludes{"${type}.h"} = 1;
199 # additional includes (things needed to compile the bindings but not the header)
201 if ($type eq "CanvasRenderingContext2D") {
202 $implIncludes{"CanvasGradient.h"} = 1;
203 $implIncludes{"CanvasPattern.h"} = 1;
204 $implIncludes{"CanvasStyle.h"} = 1;
207 if ($type eq "CanvasGradient" or $type eq "XPathNSResolver") {
208 $implIncludes{"PlatformString.h"} = 1;
211 if ($type eq "Document") {
212 $implIncludes{"NodeFilter.h"} = 1;
216 sub AddIncludesForSVGAnimatedType
219 $type =~ s/SVGAnimated//;
221 if ($type eq "Point" or $type eq "Rect") {
222 $implIncludes{"Float$type.h"} = 1;
223 } elsif ($type eq "String") {
224 $implIncludes{"PlatformString.h"} = 1;
228 sub AddClassForwardIfNeeded
230 my $implClassName = shift;
232 # SVGAnimatedLength/Number/etc.. are typedefs to SVGAnimtatedTemplate, so don't use class forwards for them!
233 push(@headerContent, "class $implClassName;\n\n") unless $codeGenerator->IsSVGAnimatedType($implClassName);
236 sub IsSVGTypeNeedingContextParameter
238 my $implClassName = shift;
240 if ($implClassName =~ /SVG/ and not $implClassName =~ /Element/) {
241 return 1 unless $implClassName =~ /SVGPaint/ or $implClassName =~ /SVGColor/ or $implClassName =~ /SVGDocument/;
247 sub HashValueForClassAndName
252 # SVG Filter enums live in WebCore namespace (platform/graphics/)
253 if ($class =~ /^SVGFE*/ or $class =~ /^SVGComponentTransferFunctionElement$/) {
254 return "WebCore::$name";
257 return "${class}::$name";
263 my $dataNode = shift;
265 my $interfaceName = $dataNode->name;
266 my $className = "JS$interfaceName";
267 my $implClassName = $interfaceName;
269 # We only support multiple parents with SVG (for now).
270 if (@{$dataNode->parents} > 1) {
271 die "A class can't have more than one parent" unless $interfaceName =~ /SVG/;
272 $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode);
275 my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"};
276 my $hasRealParent = @{$dataNode->parents} > 0;
277 my $hasParent = $hasLegacyParent || $hasRealParent;
278 my $parentClassName = GetParentClassName($dataNode);
279 my $conditional = $dataNode->extendedAttributes->{"Conditional"};
281 # - Add default header template
282 @headerContent = split("\r", $headerTemplate);
284 # - Add header protection
285 push(@headerContent, "\n#ifndef $className" . "_H");
286 push(@headerContent, "\n#define $className" . "_H\n\n");
288 my $conditionalString;
290 $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")";
291 push(@headerContent, "\n#if ${conditionalString}\n\n");
294 if (exists $dataNode->extendedAttributes->{"LegacyParent"}) {
295 push(@headerContent, GetLegacyHeaderIncludes($dataNode->extendedAttributes->{"LegacyParent"}));
298 push(@headerContent, "#include \"$parentClassName.h\"\n");
300 push(@headerContent, "#include \"kjs_binding.h\"\n");
301 push(@headerContent, "#include <kjs/JSGlobalObject.h>\n");
302 push(@headerContent, "#include <kjs/object_object.h>\n");
306 # Get correct pass/store types respecting PODType flag
307 my $podType = $dataNode->extendedAttributes->{"PODType"};
308 my $passType = $podType ? "JSSVGPODTypeWrapper<$podType>*" : "$implClassName*";
309 push(@headerContent, "#include \"$podType.h\"\n") if $podType and $podType ne "float";
311 push(@headerContent, "#include \"JSSVGPODTypeWrapper.h\"\n") if $podType;
313 my $numConstants = @{$dataNode->constants};
314 my $numAttributes = @{$dataNode->attributes};
315 my $numFunctions = @{$dataNode->functions};
317 push(@headerContent, "\nnamespace WebCore {\n\n");
319 # Implementation class forward declaration
320 AddClassForwardIfNeeded($implClassName) unless $podType;
323 push(@headerContent, "class $className : public $parentClassName {\n");
324 push(@headerContent, " typedef $parentClassName Base;\n");
325 push(@headerContent, "public:\n");
328 if ($dataNode->extendedAttributes->{"DoNotCache"}) {
329 push(@headerContent, " $className($passType);\n");
331 push(@headerContent, " $className(KJS::JSObject* prototype, $passType" . (IsSVGTypeNeedingContextParameter($implClassName) ? ", SVGElement* context" : "") .");\n");
335 push(@headerContent, " virtual ~$className();\n") if (!$hasParent or $interfaceName eq "Document");
337 my $hasGetter = $numAttributes > 0
338 || $dataNode->extendedAttributes->{"GenerateConstructor"}
339 || $dataNode->extendedAttributes->{"HasIndexGetter"}
340 || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}
341 || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}
342 || $dataNode->extendedAttributes->{"HasNameGetter"}
343 || $dataNode->extendedAttributes->{"HasOverridingNameGetter"};
347 push(@headerContent, " virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier& propertyName, KJS::PropertySlot&);\n");
348 push(@headerContent, " virtual bool getOwnPropertySlot(KJS::ExecState*, unsigned propertyName, KJS::PropertySlot&);\n") if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) && !$dataNode->extendedAttributes->{"HasOverridingNameGetter"};
349 push(@headerContent, " KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;\n") if $numAttributes > 0 || $dataNode->extendedAttributes->{"GenerateConstructor"};
350 push(@headerContent, " bool customGetOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n") if $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"};
353 # Check if we have any writable properties
354 my $hasReadWriteProperties = 0;
355 foreach (@{$dataNode->attributes}) {
356 if ($_->type !~ /^readonly\ attribute$/) {
357 $hasReadWriteProperties = 1;
361 my $hasSetter = $hasReadWriteProperties
362 || $dataNode->extendedAttributes->{"CustomPutFunction"}
363 || $dataNode->extendedAttributes->{"HasCustomIndexSetter"};
367 push(@headerContent, " virtual void put(KJS::ExecState*, const KJS::Identifier& propertyName, KJS::JSValue*, int attr = KJS::None);\n");
368 push(@headerContent, " virtual void put(KJS::ExecState*, unsigned propertyName, KJS::JSValue*, int attr = KJS::None);\n") if $dataNode->extendedAttributes->{"HasCustomIndexSetter"};
369 push(@headerContent, " void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);\n") if $hasReadWriteProperties;
370 push(@headerContent, " bool customPut(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr);\n") if $dataNode->extendedAttributes->{"CustomPutFunction"};
374 push(@headerContent, " virtual const KJS::ClassInfo* classInfo() const { return &info; }\n");
375 push(@headerContent, " static const KJS::ClassInfo info;\n\n");
377 # Custom mark function
378 push(@headerContent, " virtual void mark();\n\n") if $dataNode->extendedAttributes->{"CustomMarkFunction"};
380 # Custom pushEventHandlerScope function
381 push(@headerContent, " virtual void pushEventHandlerScope(KJS::ExecState*, KJS::ScopeChain&) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
383 # Custom call functions
384 if ($dataNode->extendedAttributes->{"CustomCall"}) {
385 push(@headerContent, " virtual KJS::JSValue* callAsFunction(KJS::ExecState*, KJS::JSObject*, const KJS::List&);\n");
386 push(@headerContent, " virtual bool implementsCall() const;\n\n");
389 # Custom deleteProperty function
390 push(@headerContent, " virtual bool deleteProperty(KJS::ExecState*, const KJS::Identifier&);\n") if $dataNode->extendedAttributes->{"CustomDeleteProperty"};
392 # Custom getPropertyNames function
393 push(@headerContent, " virtual void getPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);\n") if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"});
394 push(@headerContent, " bool customGetPropertyNames(KJS::ExecState*, KJS::PropertyNameArray&);\n") if $dataNode->extendedAttributes->{"CustomGetPropertyNames"};
396 # Constructor object getter
397 push(@headerContent, " static KJS::JSValue* getConstructor(KJS::ExecState*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"};
399 my $numCustomFunctions = 0;
400 my $numCustomAttributes = 0;
402 # Attribute and function enums
403 my $hasAttrEnum = ($numAttributes > 0) || $dataNode->extendedAttributes->{"GenerateConstructor"};
404 push(@headerContent, " enum {\n") if ($hasAttrEnum);
406 if ($numAttributes > 0) {
407 push(@headerContent, " // Attributes\n ");
410 foreach (@{$dataNode->attributes}) {
413 $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"Custom"};
414 $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"CustomGetter"};
415 $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"CustomSetter"};
418 if ((($i % 4) eq 0) and ($i ne 0)) {
419 push(@headerContent, "\n ");
422 my $value = $codeGenerator->WK_ucfirst($attribute->signature->name)
423 . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "")
425 $value .= ", " if (($i < $numAttributes - 1) or (($i eq $numAttributes - 1) and (($numFunctions ne 0) or $dataNode->extendedAttributes->{"GenerateConstructor"})));
426 push(@headerContent, $value);
430 if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
431 push(@headerContent, "\n\n") if $numAttributes > 0;
432 push(@headerContent, " // The Constructor Attribute\n");
433 push(@headerContent, " ConstructorAttrNum");
436 push(@headerContent, "\n };\n") if ($hasAttrEnum);
438 if ($numCustomAttributes > 0) {
439 push(@headerContent, "\n // Custom attributes\n");
441 foreach my $attribute (@{$dataNode->attributes}) {
442 if ($attribute->signature->extendedAttributes->{"Custom"}) {
443 push(@headerContent, " KJS::JSValue* " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(KJS::ExecState*) const;\n");
444 if ($attribute->type !~ /^readonly/) {
445 push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(KJS::ExecState*, KJS::JSValue*);\n");
447 } elsif ($attribute->signature->extendedAttributes->{"CustomGetter"}) {
448 push(@headerContent, " KJS::JSValue* " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(KJS::ExecState*) const;\n");
449 } elsif ($attribute->signature->extendedAttributes->{"CustomSetter"}) {
450 if ($attribute->type !~ /^readonly/) {
451 push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(KJS::ExecState*, KJS::JSValue*);\n");
457 foreach my $function (@{$dataNode->functions}) {
458 $numCustomFunctions++ if $function->signature->extendedAttributes->{"Custom"};
461 if ($numCustomFunctions > 0) {
462 push(@headerContent, "\n // Custom functions\n");
463 foreach my $function (@{$dataNode->functions}) {
464 if ($function->signature->extendedAttributes->{"Custom"}) {
465 push(@headerContent, " KJS::JSValue* " . $codeGenerator->WK_lcfirst($function->signature->name) . "(KJS::ExecState*, const KJS::List&);\n");
473 push(@headerContent, " JSSVGPODTypeWrapper<$podType>* impl() const { return m_impl.get(); }\n");
474 push(@headerContent, " SVGElement* context() const { return m_context.get(); }\n\n");
475 push(@headerContent, "private:\n");
476 push(@headerContent, " RefPtr<SVGElement> m_context;\n");
477 push(@headerContent, " RefPtr<JSSVGPODTypeWrapper<$podType> > m_impl;\n");
478 } elsif (IsSVGTypeNeedingContextParameter($implClassName)) {
479 push(@headerContent, " $implClassName* impl() const { return m_impl.get(); }\n");
480 push(@headerContent, " SVGElement* context() const { return m_context.get(); }\n\n");
481 push(@headerContent, "private:\n");
482 push(@headerContent, " RefPtr<SVGElement> m_context;\n");
483 push(@headerContent, " RefPtr<$implClassName > m_impl;\n");
485 push(@headerContent, " $implClassName* impl() const { return m_impl.get(); }\n\n");
486 push(@headerContent, "private:\n");
487 push(@headerContent, " RefPtr<$implClassName> m_impl;\n");
489 } elsif ($dataNode->extendedAttributes->{"GenerateNativeConverter"}) {
490 push(@headerContent, " $implClassName* impl() const;\n");
494 if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) {
495 push(@headerContent, " static KJS::JSValue* indexGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);\n");
499 if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) {
500 push(@headerContent, " void indexSetter(KJS::ExecState*, unsigned index, KJS::JSValue*, int attr);\n");
503 if ($dataNode->extendedAttributes->{"HasNameGetter"} || $dataNode->extendedAttributes->{"HasOverridingNameGetter"}) {
504 push(@headerContent, "private:\n");
505 push(@headerContent, " static bool canGetItemsForName(KJS::ExecState*, $implClassName*, const KJS::Identifier&);\n");
506 push(@headerContent, " static KJS::JSValue* nameGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);\n");
509 push(@headerContent, "};\n\n");
511 if (!$hasParent || $dataNode->extendedAttributes->{"GenerateToJS"}) {
513 push(@headerContent, "KJS::JSValue* toJS(KJS::ExecState*, JSSVGPODTypeWrapper<$podType>*, SVGElement* context);\n");
514 } elsif (IsSVGTypeNeedingContextParameter($implClassName)) {
515 push(@headerContent, "KJS::JSValue* toJS(KJS::ExecState*, $passType, SVGElement* context);\n");
516 } elsif ($interfaceName eq "Node") {
517 push(@headerContent, "KJS::JSValue* toJS(KJS::ExecState*, PassRefPtr<Node>);\n");
519 push(@headerContent, "KJS::JSValue* toJS(KJS::ExecState*, $passType);\n");
522 if (!$hasParent || $dataNode->extendedAttributes->{"GenerateNativeConverter"}) {
524 push(@headerContent, "$podType to${interfaceName}(KJS::JSValue*);\n");
526 push(@headerContent, "$implClassName* to${interfaceName}(KJS::JSValue*);\n");
529 push(@headerContent, "\n");
531 # Add prototype declaration -- code adopted from the KJS_DEFINE_PROTOTYPE and KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE macros
532 push(@headerContent, "class ${className}Prototype : public KJS::JSObject {\n");
533 push(@headerContent, "public:\n");
534 if ($dataNode->extendedAttributes->{"DoNotCache"}) {
535 push(@headerContent, " static KJS::JSObject* self();\n");
537 push(@headerContent, " static KJS::JSObject* self(KJS::ExecState* exec);\n");
539 push(@headerContent, " virtual const KJS::ClassInfo* classInfo() const { return &info; }\n");
540 push(@headerContent, " static const KJS::ClassInfo info;\n");
541 if ($numFunctions > 0 || $numConstants > 0) {
542 push(@headerContent, " bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);\n");
544 if ($numConstants ne 0) {
545 push(@headerContent, " KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;\n");
547 if ($dataNode->extendedAttributes->{"DoNotCache"}) {
548 push(@headerContent, " ${className}Prototype() { }\n");
550 push(@headerContent, " ${className}Prototype(KJS::ExecState* exec)\n");
551 if ($hasParent && $parentClassName ne "KJS::DOMNodeFilter") {
552 push(@headerContent, " : KJS::JSObject(${parentClassName}Prototype::self(exec)) { }\n");
554 push(@headerContent, " : KJS::JSObject(exec->lexicalGlobalObject()->objectPrototype()) { }\n");
558 push(@headerContent, "};\n\n");
560 if ($numFunctions > 0) {
561 push(@headerContent,"// Functions\n\n");
562 foreach my $function (@{$dataNode->functions}) {
563 my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name);
564 push(@headerContent, "KJS::JSValue* ${functionName}(KJS::ExecState*, KJS::JSObject*, const KJS::List&);\n");
568 push(@headerContent, "} // namespace WebCore\n\n");
569 push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional;
570 push(@headerContent, "#endif\n");
573 sub GenerateImplementation
575 my ($object, $dataNode) = @_;
577 my $interfaceName = $dataNode->name;
578 my $className = "JS$interfaceName";
579 my $implClassName = $interfaceName;
581 my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"};
582 my $hasRealParent = @{$dataNode->parents} > 0;
583 my $hasParent = $hasLegacyParent || $hasRealParent;
584 my $parentClassName = GetParentClassName($dataNode);
585 my $conditional = $dataNode->extendedAttributes->{"Conditional"};
586 my $visibleClassName = GetVisibleClassName($interfaceName);
588 # - Add default header template
589 @implContentHeader = split("\r", $headerTemplate);
590 push(@implContentHeader, "\n#include \"config.h\"\n\n");
591 my $conditionalString;
593 $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")";
594 push(@implContentHeader, "\n#if ${conditionalString}\n\n");
597 if ($className =~ /^JSSVG/) {
598 push(@implContentHeader, "#include \"Document.h\"\n");
599 push(@implContentHeader, "#include \"Frame.h\"\n");
600 push(@implContentHeader, "#include \"SVGDocumentExtensions.h\"\n");
601 push(@implContentHeader, "#include \"SVGElement.h\"\n");
602 push(@implContentHeader, "#include \"SVGAnimatedTemplate.h\"\n");
604 if ($className =~ /^JSSVGAnimated/) {
605 AddIncludesForSVGAnimatedType($interfaceName);
609 push(@implContentHeader, "#include \"$className.h\"\n\n");
610 push(@implContentHeader, "#include <wtf/GetPtr.h>\n\n");
612 push(@implContentHeader, "#include <kjs/PropertyNameArray.h>\n") if $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"};
614 AddIncludesForType($interfaceName);
618 push(@implContent, "\nusing namespace KJS;\n\n");
619 push(@implContent, "namespace WebCore {\n\n");
621 # - Add all attributes in a hashtable definition
622 my $numAttributes = @{$dataNode->attributes};
623 $numAttributes++ if $dataNode->extendedAttributes->{"GenerateConstructor"};
625 if ($numAttributes > 0) {
626 my $hashSize = $numAttributes;
627 my $hashName = $className . "Table";
629 my @hashKeys = (); # ie. 'insertBefore'
630 my @hashValues = (); # ie. 'JSNode::InsertBefore'
631 my @hashSpecials = (); # ie. 'DontDelete|Function'
632 my @hashParameters = (); # ie. '2'
634 foreach my $attribute (@{$dataNode->attributes}) {
635 my $name = $attribute->signature->name;
636 push(@hashKeys, $name);
638 my $value = $className . "::" . $codeGenerator->WK_ucfirst($attribute->signature->name)
639 . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "")
641 push(@hashValues, $value);
644 push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"};
645 push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"};
646 push(@specials, "ReadOnly") if $attribute->type =~ /readonly/;
647 my $special = (@specials > 0) ? join("|", @specials) : "0";
648 push(@hashSpecials, $special);
650 my $numParameters = "0";
651 push(@hashParameters, $numParameters);
654 if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
655 push(@hashKeys, "constructor");
656 push(@hashValues, $className . "::ConstructorAttrNum");
657 push(@hashSpecials, "DontEnum");
658 push(@hashParameters, "0");
661 $object->GenerateHashTable($hashName, $hashSize,
662 \@hashKeys, \@hashValues,
663 \@hashSpecials, \@hashParameters);
666 my $numConstants = @{$dataNode->constants};
667 my $numFunctions = @{$dataNode->functions};
669 # - Add all constants
670 if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
671 $hashSize = $numConstants;
672 $hashName = $className . "ConstructorTable";
677 @hashParameters = ();
679 foreach my $constant (@{$dataNode->constants}) {
680 my $name = $constant->name;
681 push(@hashKeys, $name);
683 my $value = $constant->value;
684 push(@hashValues, $value);
686 my $special = "DontDelete|ReadOnly";
687 push(@hashSpecials, $special);
689 my $numParameters = 0;
690 push(@hashParameters, $numParameters);
693 $object->GenerateHashTable($hashName, $hashSize,
694 \@hashKeys, \@hashValues,
695 \@hashSpecials, \@hashParameters);
698 $protoClassName = "${className}Prototype";
700 push(@implContent, constructorFor($className, $protoClassName, $interfaceName, $visibleClassName, $dataNode->extendedAttributes->{"CanBeConstructed"}));
703 # - Add functions and constants to a hashtable definition
704 $hashSize = $numFunctions + $numConstants;
705 $hashName = $className . "PrototypeTable";
710 @hashParameters = ();
712 foreach my $constant (@{$dataNode->constants}) {
713 my $name = $constant->name;
714 push(@hashKeys, $name);
716 my $value = $constant->value;
717 push(@hashValues, $value);
719 my $special = "DontDelete|ReadOnly";
720 push(@hashSpecials, $special);
722 my $numParameters = 0;
723 push(@hashParameters, $numParameters);
726 foreach my $function (@{$dataNode->functions}) {
727 my $name = $function->signature->name;
728 push(@hashKeys, $name);
730 my $value = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($name);
731 push(@hashValues, $value);
734 push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"};
735 push(@specials, "DontEnum") if $function->signature->extendedAttributes->{"DontEnum"};
736 push(@specials, "Function");
737 my $special = (@specials > 0) ? join("|", @specials) : "0";
738 push(@hashSpecials, $special);
740 my $numParameters = @{$function->parameters};
741 push(@hashParameters, $numParameters);
744 $object->GenerateHashTable($hashName, $hashSize,
745 \@hashKeys, \@hashValues,
746 \@hashSpecials, \@hashParameters);
748 push(@implContent, "const ClassInfo ${className}Prototype::info = { \"${visibleClassName}Prototype\", 0, &${className}PrototypeTable };\n\n");
749 if ($dataNode->extendedAttributes->{"DoNotCache"}) {
750 push(@implContent, "JSObject* ${className}Prototype::self()\n");
751 push(@implContent, "{\n");
752 push(@implContent, " return new ${className}Prototype();\n");
753 push(@implContent, "}\n\n");
755 push(@implContent, "JSObject* ${className}Prototype::self(ExecState* exec)\n");
756 push(@implContent, "{\n");
757 push(@implContent, " return KJS::cacheGlobalObject<${className}Prototype>(exec, \"[[${className}.prototype]]\");\n");
758 push(@implContent, "}\n\n");
760 if ($numConstants > 0 || $numFunctions > 0) {
761 push(@implContent, "bool ${className}Prototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n");
762 push(@implContent, "{\n");
763 if ($numConstants eq 0) {
764 push(@implContent, " return getStaticFunctionSlot<JSObject>(exec, &${className}PrototypeTable, this, propertyName, slot);\n");
765 } elsif ($numFunctions eq 0) {
766 push(@implContent, " return getStaticValueSlot<${className}Prototype, JSObject>(exec, &${className}PrototypeTable, this, propertyName, slot);\n");
768 push(@implContent, " return getStaticPropertySlot<${className}Prototype, JSObject>(exec, &${className}PrototypeTable, this, propertyName, slot);\n");
770 push(@implContent, "}\n\n");
772 if ($numConstants ne 0) {
773 push(@implContent, "JSValue* ${className}Prototype::getValueProperty(ExecState*, int token) const\n{\n");
774 push(@implContent, " // The token is the numeric value of its associated constant\n");
775 push(@implContent, " return jsNumber(token);\n}\n\n");
778 # - Initialize static ClassInfo object
779 push(@implContent, "const ClassInfo $className" . "::info = { \"${visibleClassName}\", ");
781 push(@implContent, "&" . $parentClassName . "::info, ");
783 push(@implContent, "0, ");
786 if ($numAttributes > 0) {
787 push(@implContent, "&${className}Table ");
789 push(@implContent, "0 ")
791 push(@implContent, "};\n\n");
793 # Get correct pass/store types respecting PODType flag
794 my $podType = $dataNode->extendedAttributes->{"PODType"};
795 my $passType = $podType ? "JSSVGPODTypeWrapper<$podType>*" : "$implClassName*";
797 my $needsSVGContext = IsSVGTypeNeedingContextParameter($implClassName);
798 my $parentNeedsSVGContext = ($needsSVGContext and $parentClassName =~ /SVG/);
801 if ($dataNode->extendedAttributes->{"DoNotCache"}) {
802 push(@implContent, "${className}::$className($passType impl)\n");
803 push(@implContent, " : $parentClassName(${className}Prototype::self(), impl)\n");
805 push(@implContent, "${className}::$className(JSObject* prototype, $passType impl" . ($needsSVGContext ? ", SVGElement* context" : "") . ")\n");
807 push(@implContent, " : $parentClassName(prototype, impl" . ($parentNeedsSVGContext ? ", context" : "") . ")\n");
809 push(@implContent, " : $parentClassName(prototype)\n");
810 push(@implContent, " , m_context(context)\n") if $needsSVGContext;
811 push(@implContent, " , m_impl(impl)\n");
815 push(@implContent, "{\n");
816 push(@implContent, "}\n\n");
820 push(@implContent, "${className}::~$className()\n");
821 push(@implContent, "{\n");
823 if ($interfaceName eq "Node") {
824 push(@implContent, " ScriptInterpreter::forgetDOMNodeForDocument(m_impl->document(), m_impl.get());\n");
827 my $animatedType = $implClassName;
828 $animatedType =~ s/SVG/SVGAnimated/;
830 # Special case for JSSVGNumber
831 if ($codeGenerator->IsSVGAnimatedType($animatedType) and $podType ne "float") {
832 push(@implContent, " JSSVGPODTypeWrapperCache<$podType, $animatedType>::forgetWrapper(m_impl.get());\n");
835 push(@implContent, " ScriptInterpreter::forgetDOMObject(m_impl.get());\n");
838 push(@implContent, "\n}\n\n");
841 # Document needs a special destructor because it's a special case for caching. It needs
842 # its own special handling rather than relying on the caching that Node normally does.
843 if ($interfaceName eq "Document") {
844 push(@implContent, "${className}::~$className()\n");
845 push(@implContent, "{\n ScriptInterpreter::forgetDOMObject(static_cast<${implClassName}*>(impl()));\n}\n\n");
848 my $hasGetter = $numAttributes > 0
849 || $dataNode->extendedAttributes->{"GenerateConstructor"}
850 || $dataNode->extendedAttributes->{"HasIndexGetter"}
851 || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}
852 || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}
853 || $dataNode->extendedAttributes->{"HasNameGetter"}
854 || $dataNode->extendedAttributes->{"HasOverridingNameGetter"};
858 push(@implContent, "bool ${className}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n");
859 push(@implContent, "{\n");
861 if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection") {
862 push(@implContent, " JSValue* proto = prototype();\n");
863 push(@implContent, " if (proto->isObject() && static_cast<JSObject*>(proto)->hasProperty(exec, propertyName))\n");
864 push(@implContent, " return false;\n\n");
867 my $hasNameGetterGeneration = sub {
868 push(@implContent, " if (canGetItemsForName(exec, static_cast<$implClassName*>(impl()), propertyName)) {\n");
869 push(@implContent, " slot.setCustom(this, nameGetter);\n");
870 push(@implContent, " return true;\n");
871 push(@implContent, " }\n");
872 $implIncludes{"AtomicString.h"} = 1;
875 if ($dataNode->extendedAttributes->{"HasOverridingNameGetter"}) {
876 &$hasNameGetterGeneration();
879 my $requiresManualLookup = $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasNameGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"};
880 if ($requiresManualLookup) {
881 push(@implContent, " const HashEntry* entry = Lookup::findEntry(&${className}Table, propertyName);\n");
882 push(@implContent, " if (entry) {\n");
883 push(@implContent, " slot.setStaticEntry(this, entry, staticValueGetter<$className>);\n");
884 push(@implContent, " return true;\n");
885 push(@implContent, " }\n");
888 if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) {
889 push(@implContent, " bool ok;\n");
890 push(@implContent, " unsigned index = propertyName.toUInt32(&ok, false);\n");
891 push(@implContent, " if (ok && index < static_cast<$implClassName*>(impl())->length()) {\n");
892 push(@implContent, " slot.setCustomIndex(this, index, indexGetter);\n");
893 push(@implContent, " return true;\n");
894 push(@implContent, " }\n");
897 if ($dataNode->extendedAttributes->{"HasNameGetter"}) {
898 &$hasNameGetterGeneration();
901 if ($dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"}) {
902 push(@implContent, " if (customGetOwnPropertySlot(exec, propertyName, slot))\n");
903 push(@implContent, " return true;\n");
906 if ($numAttributes > 0) {
907 push(@implContent, " return getStaticValueSlot<$className, Base>(exec, &${className}Table, this, propertyName, slot);\n");
909 push(@implContent, " return Base::getOwnPropertySlot(exec, propertyName, slot);\n");
911 push(@implContent, "}\n\n");
913 if (($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"})
914 && !$dataNode->extendedAttributes->{"HasOverridingNameGetter"}) {
915 push(@implContent, "bool ${className}::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)\n");
916 push(@implContent, "{\n");
917 push(@implContent, " if (propertyName < static_cast<$implClassName*>(impl())->length()) {\n");
918 push(@implContent, " slot.setCustomIndex(this, propertyName, indexGetter);\n");
919 push(@implContent, " return true;\n");
920 push(@implContent, " }\n");
921 push(@implContent, " return getOwnPropertySlot(exec, Identifier::from(propertyName), slot);\n");
922 push(@implContent, "}\n\n");
925 if ($numAttributes > 0) {
926 push(@implContent, "JSValue* ${className}::getValueProperty(ExecState* exec, int token) const\n");
927 push(@implContent, "{\n");
929 push(@implContent, " switch (token) {\n");
931 foreach my $attribute (@{$dataNode->attributes}) {
932 my $getterFunctionName = $codeGenerator->WK_lcfirst($attribute->signature->name);
934 my $implClassNameForValueConversion = "";
935 if (!$podType and ($codeGenerator->IsSVGAnimatedType($implClassName) or $attribute->type !~ /^readonly/)) {
936 $implClassNameForValueConversion = $implClassName;
939 push(@implContent, " case " . $codeGenerator->WK_ucfirst($attribute->signature->name)
940 . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "")
943 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} &&
944 !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"} &&
945 !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurityOnGet"}) {
946 push(@implContent, " if (!allowsAccessFrom(exec))\n");
947 push(@implContent, " return jsUndefined();\n");
950 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"CustomGetter"}) {
951 push(@implContent, " return $getterFunctionName(exec);\n");
952 } elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) {
953 $implIncludes{"kjs_dom.h"} = 1;
954 push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(impl());\n");
955 push(@implContent, " return checkNodeSecurity(exec, imp->$getterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$getterFunctionName()") . " : jsUndefined();\n");
956 } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) {
957 $implIncludes{"Document.h"} = 1;
958 $implIncludes{"kjs_dom.h"} = 1;
959 push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(impl());\n");
960 push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$getterFunctionName()") . " : jsUndefined();\n");
961 } elsif ($attribute->signature->type =~ /Constructor$/) {
962 my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
963 $constructorType =~ s/Constructor$//;
964 push(@implContent, " return JS" . $constructorType . "::getConstructor(exec);\n");
965 } elsif (!@{$attribute->getterExceptions}) {
967 push(@implContent, " $podType imp(*impl());\n");
968 if ($podType eq "float") { # Special case for JSSVGNumber
969 push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp") . ";\n");
971 push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$getterFunctionName()") . ";\n");
974 push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(impl());\n");
975 my $type = $codeGenerator->StripModule($attribute->signature->type);
976 my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$getterFunctionName()");
977 if ($codeGenerator->IsSVGAnimatedType($type)) {
978 push(@implContent, " RefPtr<$type> obj = $jsType;\n");
979 push(@implContent, " return toJS(exec, obj.get(), imp);\n");
981 push(@implContent, " return $jsType;\n");
985 push(@implContent, " ExceptionCode ec = 0;\n");
988 push(@implContent, " $podType imp(*impl());\n");
989 push(@implContent, " KJS::JSValue* result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$getterFunctionName(ec)") . ";\n");
991 push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(impl());\n");
992 push(@implContent, " KJS::JSValue* result = " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$getterFunctionName(ec)") . ";\n");
995 push(@implContent, " setDOMException(exec, ec);\n");
996 push(@implContent, " return result;\n");
998 push(@implContent, " }\n");
1001 if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
1002 push(@implContent, " case ConstructorAttrNum:\n");
1003 push(@implContent, " return getConstructor(exec);\n");
1006 push(@implContent, " }\n");
1007 push(@implContent, " return 0;\n");
1008 push(@implContent, "}\n\n");
1011 # Check if we have any writable attributes
1012 my $hasReadWriteProperties = 0;
1013 foreach my $attribute (@{$dataNode->attributes}) {
1014 $hasReadWriteProperties = 1 if $attribute->type !~ /^readonly/;
1017 my $hasSetter = $hasReadWriteProperties
1018 || $dataNode->extendedAttributes->{"CustomPutFunction"}
1019 || $dataNode->extendedAttributes->{"HasCustomIndexSetter"};
1022 push(@implContent, "void ${className}::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)\n");
1023 push(@implContent, "{\n");
1024 if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) {
1025 push(@implContent, " bool ok;\n");
1026 push(@implContent, " unsigned index = propertyName.toUInt32(&ok, false);\n");
1027 push(@implContent, " if (ok) {\n");
1028 push(@implContent, " indexSetter(exec, index, value, attr);\n");
1029 push(@implContent, " return;\n");
1030 push(@implContent, " }\n");
1032 if ($dataNode->extendedAttributes->{"CustomPutFunction"}) {
1033 push(@implContent, " if (customPut(exec, propertyName, value, attr))\n");
1034 push(@implContent, " return;\n");
1037 if ($hasReadWriteProperties) {
1038 push(@implContent, " lookupPut<$className, Base>(exec, propertyName, value, attr, &${className}Table, this);\n");
1040 push(@implContent, " Base::put(exec, propertyName, value, attr);\n");
1042 push(@implContent, "}\n\n");
1044 if ($dataNode->extendedAttributes->{"HasCustomIndexSetter"}) {
1045 push(@implContent, "void ${className}::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr)\n");
1046 push(@implContent, "{\n");
1047 push(@implContent, " indexSetter(exec, propertyName, value, attr);\n");
1048 push(@implContent, " return;\n");
1049 push(@implContent, "}\n\n");
1052 if ($hasReadWriteProperties) {
1053 push(@implContent, "void ${className}::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)\n");
1054 push(@implContent, "{\n");
1056 push(@implContent, " switch (token) {\n");
1058 foreach my $attribute (@{$dataNode->attributes}) {
1059 if ($attribute->type !~ /^readonly/) {
1060 my $name = $attribute->signature->name;
1061 my $setterFunctionName = $codeGenerator->WK_ucfirst($name);
1063 push(@implContent, " case " . $codeGenerator->WK_ucfirst($attribute->signature->name)
1064 . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "")
1067 if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {
1068 if ($interfaceName eq "DOMWindow") {
1069 push(@implContent, " if (!allowsAccessFrom(exec))\n");
1071 push(@implContent, " if (!allowsAccessFromFrame(exec, impl()->frame()))\n");
1073 push(@implContent, " return;\n");
1076 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"CustomSetter"}) {
1077 push(@implContent, " set$setterFunctionName(exec, value);\n");
1078 } elsif ($attribute->signature->type =~ /Constructor$/) {
1079 my $constructorType = $attribute->signature->type;
1080 $constructorType =~ s/Constructor$//;
1081 $implIncludes{"JS" . $constructorType . ".h"} = 1;
1082 push(@implContent, " // Shadowing a built-in constructor\n");
1083 push(@implContent, " putDirect(\"$name\", value);\n");
1084 } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) {
1085 push(@implContent, " putDirect(\"$name\", value);\n");
1088 push(@implContent, " $podType imp(*impl());\n");
1089 if ($podType eq "float") { # Special case for JSSVGNumber
1090 push(@implContent, " imp = " . JSValueToNative($attribute->signature, "value") . ";\n");
1092 push(@implContent, " imp.set$setterFunctionName(" . JSValueToNative($attribute->signature, "value") . ");\n");
1094 push(@implContent, " m_impl->commitChange(imp, context());\n");
1096 push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(impl());\n");
1097 push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
1098 push(@implContent, " imp->set$setterFunctionName(" . JSValueToNative($attribute->signature, "value"));
1099 push(@implContent, ", ec") if @{$attribute->setterExceptions};
1100 push(@implContent, ");\n");
1101 push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
1103 if (IsSVGTypeNeedingContextParameter($implClassName)) {
1104 push(@implContent, " if (context())\n");
1105 push(@implContent, " context()->svgAttributeChanged(impl()->associatedAttributeName());\n");
1109 push(@implContent, " break;\n");
1110 push(@implContent, " }\n");
1113 push(@implContent, " }\n"); # end switch
1114 push(@implContent, "}\n\n"); # end function
1119 if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) {
1120 push(@implContent, "void ${className}::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)\n");
1121 push(@implContent, "{\n");
1122 if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"}) {
1123 push(@implContent, " if (customGetPropertyNames(exec, propertyNames))\n");
1124 push(@implContent, " return;\n");
1126 if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"}) {
1127 push(@implContent, " for (unsigned i = 0; i < static_cast<${implClassName}*>(impl())->length(); ++i)\n");
1128 push(@implContent, " propertyNames.add(Identifier::from(i));\n");
1130 push(@implContent, " Base::getPropertyNames(exec, propertyNames);\n");
1131 push(@implContent, "}\n\n");
1134 if ($dataNode->extendedAttributes->{"GenerateConstructor"}) {
1135 push(@implContent, "JSValue* ${className}::getConstructor(ExecState* exec)\n{\n");
1136 push(@implContent, " return KJS::cacheGlobalObject<${className}Constructor>(exec, \"[[${interfaceName}.constructor]]\");\n");
1137 push(@implContent, "}\n\n");
1141 if ($numFunctions > 0) {
1142 foreach my $function (@{$dataNode->functions}) {
1143 my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name);
1144 push(@implContent, "JSValue* ${functionName}(ExecState* exec, JSObject* thisObj, const List& args)\n");
1145 push(@implContent, "{\n");
1146 push(@implContent, " if (!thisObj->inherits(&${className}::info))\n");
1147 push(@implContent, " return throwError(exec, TypeError);\n");
1149 AddIncludesForType($function->signature->type);
1151 push(@implContent, " $className* castedThisObj = static_cast<$className*>(thisObj);\n");
1153 if ($function->signature->extendedAttributes->{"Custom"}) {
1154 push(@implContent, " return castedThisObj->" . $codeGenerator->WK_lcfirst($function->signature->name) . "(exec, args);\n");
1157 push(@implContent, " JSSVGPODTypeWrapper<$podType>* wrapper = castedThisObj->impl();\n");
1158 push(@implContent, " $podType imp(*wrapper);\n");
1160 push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThisObj->impl());\n");
1163 my $numParameters = @{$function->parameters};
1165 if ($function->signature->extendedAttributes->{"RequiresAllArguments"}) {
1166 push(@implContent, " if (args.size() < $numParameters)\n");
1167 push(@implContent, " return jsUndefined();\n");
1170 if (@{$function->raisesExceptions}) {
1171 push(@implContent, " ExceptionCode ec = 0;\n");
1174 if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) {
1175 push(@implContent, " if (!checkNodeSecurity(exec, imp->getSVGDocument(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
1176 push(@implContent, " return jsUndefined();\n");
1177 $implIncludes{"kjs_dom.h"} = 1;
1181 my $functionString = "imp" . ($podType ? "." : "->") . $codeGenerator->WK_lcfirst($function->signature->name) . "(";
1183 my $hasOptionalArguments = 0;
1185 foreach my $parameter (@{$function->parameters}) {
1186 if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) {
1187 push(@implContent, "\n int argsCount = args.size();\n");
1188 $hasOptionalArguments = 1;
1191 if ($hasOptionalArguments) {
1192 push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n");
1193 GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName);
1194 push(@implContent, " }\n\n");
1197 my $name = $parameter->name;
1199 if ($parameter->type eq "XPathNSResolver") {
1200 push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n");
1201 push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(args[$paramIndex]);\n");
1202 push(@implContent, " if (!resolver) {\n");
1203 push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, args[$paramIndex]);\n");
1204 push(@implContent, " if (exec->hadException())\n");
1205 push(@implContent, " return jsUndefined();\n");
1206 push(@implContent, " resolver = customResolver.get();\n");
1207 push(@implContent, " }\n");
1209 push(@implContent, " bool ${name}Ok;\n") if TypeCanFailConversion($parameter);
1210 push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args[$paramIndex]", TypeCanFailConversion($parameter) ? "${name}Ok" : undef) . ";\n");
1211 if (TypeCanFailConversion($parameter)) {
1212 push(@implContent, " if (!${name}Ok) {\n");
1213 push(@implContent, " setDOMException(exec, TYPE_MISMATCH_ERR);\n");
1214 push(@implContent, " return jsUndefined();\n");
1215 push(@implContent, " }\n");
1218 # If a parameter is "an index", it should throw an INDEX_SIZE_ERR
1220 if ($parameter->extendedAttributes->{"IsIndex"}) {
1221 $implIncludes{"ExceptionCode.h"} = 1;
1222 push(@implContent, " if ($name < 0) {\n");
1223 push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n");
1224 push(@implContent, " return jsUndefined();\n");
1225 push(@implContent, " }\n");
1229 $functionString .= ", " if $paramIndex;
1230 $functionString .= $name;
1235 push(@implContent, "\n");
1236 GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $podType, $implClassName);
1238 push(@implContent, "}\n\n");
1242 if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
1243 push(@implContent, "\nJSValue* ${className}::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)\n");
1244 push(@implContent, "{\n");
1245 push(@implContent, " ${className}* thisObj = static_cast<$className*>(slot.slotBase());\n");
1246 if (IndexGetterReturnsStrings($implClassName)) {
1247 $implIncludes{"KURL.h"} = 1;
1248 push(@implContent, " return jsStringOrNull(thisObj->impl()->item(slot.index()));\n");
1250 push(@implContent, " return toJS(exec, static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n");
1252 push(@implContent, "}\n");
1253 if ($interfaceName eq "HTMLCollection") {
1254 $implIncludes{"JSNode.h"} = 1;
1255 $implIncludes{"Node.h"} = 1;
1259 if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateToJS"}) and !UsesManualToJSImplementation($implClassName)) {
1261 push(@implContent, "KJS::JSValue* toJS(KJS::ExecState* exec, JSSVGPODTypeWrapper<$podType>* obj, SVGElement* context)\n");
1262 } elsif (IsSVGTypeNeedingContextParameter($implClassName)) {
1263 push(@implContent, "KJS::JSValue* toJS(KJS::ExecState* exec, $passType obj, SVGElement* context)\n");
1265 push(@implContent, "KJS::JSValue* toJS(KJS::ExecState* exec, $passType obj)\n");
1268 push(@implContent, "{\n");
1270 push(@implContent, " return cacheSVGDOMObject<JSSVGPODTypeWrapper<$podType>, $className, ${className}Prototype>(exec, obj, context);\n");
1271 } elsif (IsSVGTypeNeedingContextParameter($implClassName)) {
1272 push(@implContent, " return cacheSVGDOMObject<$implClassName, $className, ${className}Prototype>(exec, obj, context);\n");
1274 push(@implContent, " return cacheDOMObject<$implClassName, $className, ${className}Prototype>(exec, obj);\n");
1276 push(@implContent, "}\n");
1279 if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateNativeConverter"}) and !$dataNode->extendedAttributes->{"CustomNativeConverter"}) {
1281 push(@implContent, "$podType to${interfaceName}(KJS::JSValue* val)\n");
1283 push(@implContent, "$implClassName* to${interfaceName}(KJS::JSValue* val)\n");
1286 push(@implContent, "{\n");
1288 push(@implContent, " return val->isObject(&${className}::info) ? " . ($podType ? "($podType) *" : "") . "static_cast<$className*>(val)->impl() : ");
1289 if ($podType and $podType ne "float") {
1290 push(@implContent, "$podType();\n}\n");
1292 push(@implContent, "0;\n}\n");
1296 if ($dataNode->extendedAttributes->{"GenerateNativeConverter"} && $hasParent) {
1297 push(@implContent, "\n$implClassName* ${className}::impl() const\n");
1298 push(@implContent, "{\n");
1299 push(@implContent, " return static_cast<$implClassName*>(Base::impl());\n");
1300 push(@implContent, "}\n");
1303 push(@implContent, "\n}\n");
1305 push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional;
1308 sub GenerateImplementationFunctionCall()
1310 my $function = shift;
1311 my $functionString = shift;
1312 my $paramIndex = shift;
1314 my $podType = shift;
1315 my $implClassName = shift;
1317 if (@{$function->raisesExceptions}) {
1318 $functionString .= ", " if $paramIndex;
1319 $functionString .= "ec";
1321 $functionString .= ")";
1323 if ($function->signature->type eq "void") {
1324 push(@implContent, $indent . "$functionString;\n");
1325 push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
1328 push(@implContent, $indent . "wrapper->commitChange(imp, castedThisObj->context());\n");
1331 push(@implContent, $indent . "return jsUndefined();\n");
1333 push(@implContent, "\n" . $indent . "KJS::JSValue* result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString) . ";\n");
1334 push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
1337 push(@implContent, $indent . "wrapper->commitChange(imp, castedThisObj->context());\n");
1340 push(@implContent, $indent . "return result;\n");
1344 sub GetNativeTypeFromSignature
1346 my $signature = shift;
1347 my $type = $codeGenerator->StripModule($signature->type);
1349 if ($type eq "unsigned long" and $signature->extendedAttributes->{"IsIndex"}) {
1350 # Special-case index arguments because we need to check that they aren't < 0.
1354 return GetNativeType($type);
1358 "AtomicString" => "AtomicString",
1359 "CompareHow" => "Range::CompareHow",
1360 "DOMString" => "String",
1361 "EventTarget" => "EventTargetNode*",
1362 "SVGLength" => "SVGLength",
1363 "SVGMatrix" => "AffineTransform",
1364 "SVGNumber" => "float",
1365 "SVGPaintType" => "SVGPaint::SVGPaintType",
1366 "SVGPoint" => "FloatPoint",
1367 "SVGRect" => "FloatRect",
1368 "SVGTransform" => "SVGTransform",
1369 "boolean" => "bool",
1370 "double" => "double",
1373 "unsigned long" => "unsigned",
1374 "unsigned short" => "unsigned short",
1381 return $nativeType{$type} if exists $nativeType{$type};
1383 # For all other types, the native type is a pointer with same type name as the IDL type.
1387 my %typeCanFailConversion = (
1388 "AtomicString" => 0,
1393 "DocumentType" => 0,
1396 "EventListener" => 0,
1399 "HTMLOptionElement" => 0,
1403 "SQLResultSet" => 0,
1409 "SVGPaintType" => 0,
1413 "SVGTransform" => 0,
1414 "VoidCallback" => 1,
1415 "XPathEvaluator" => 0,
1416 "XPathNSResolver" => 0,
1422 "unsigned long" => 0,
1423 "unsigned short" => 0,
1426 sub TypeCanFailConversion
1428 my $signature = shift;
1430 my $type = $codeGenerator->StripModule($signature->type);
1432 $implIncludes{"ExceptionCode.h"} = 1 if $type eq "Attr";
1434 return $typeCanFailConversion{$type} if exists $typeCanFailConversion{$type};
1436 die "Don't know whether a JS value can fail conversion to type $type.";
1441 my $signature = shift;
1443 my $okParam = shift;
1444 my $maybeOkParam = $okParam ? ", ${okParam}" : "";
1446 my $type = $codeGenerator->StripModule($signature->type);
1448 return "$value->toBoolean(exec)" if $type eq "boolean";
1449 return "$value->toNumber(exec)" if $type eq "double";
1450 return "$value->toFloat(exec)" if $type eq "float" or $type eq "SVGNumber";
1451 return "$value->toInt32(exec${maybeOkParam})" if $type eq "unsigned long" or $type eq "long" or $type eq "unsigned short";
1453 return "static_cast<Range::CompareHow>($value->toInt32(exec))" if $type eq "CompareHow";
1454 return "static_cast<SVGPaint::SVGPaintType>($value->toInt32(exec))" if $type eq "SVGPaintType";
1456 return "$value->toString(exec)" if $type eq "AtomicString";
1457 if ($type eq "DOMString") {
1458 return "valueToStringWithNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertNullToNullString"};
1459 return "valueToStringWithUndefinedOrNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertUndefinedOrNullToNullString"};
1460 return "$value->toString(exec)";
1463 if ($type eq "EventTarget") {
1464 $implIncludes{"JSEventTargetNode.h"} = 1;
1465 return "toEventTargetNode($value)";
1468 if ($type eq "Attr") {
1469 $implIncludes{"kjs_dom.h"} = 1;
1470 return "toAttr($value${maybeOkParam})";
1473 if ($type eq "VoidCallback") {
1474 $implIncludes{"JSCustomVoidCallback.h"} = 1;
1475 return "toVoidCallback(exec, $value${maybeOkParam})";
1478 $implIncludes{"FloatPoint.h"} = 1 if $type eq "SVGPoint";
1479 $implIncludes{"FloatRect.h"} = 1 if $type eq "SVGRect";
1480 $implIncludes{"HTMLOptionElement.h"} = 1 if $type eq "HTMLOptionElement";
1482 # Default, assume autogenerated type conversion routines
1483 $implIncludes{"JS$type.h"} = 1;
1484 return "to$type($value)";
1489 my $signature = shift;
1490 my $inFunctionCall = shift;
1491 my $implClassName = shift;
1492 my $implClassNameForValueConversion = shift;
1495 my $type = $codeGenerator->StripModule($signature->type);
1497 return "jsBoolean($value)" if $type eq "boolean";
1498 return "jsNumber($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType" or $type eq "DOMTimeStamp";
1500 if ($codeGenerator->IsStringType($type)) {
1501 $implIncludes{"KURL.h"} = 1;
1502 my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"};
1503 if (defined $conv) {
1504 return "jsStringOrNull($value)" if $conv eq "Null";
1505 return "jsStringOrUndefined($value)" if $conv eq "Undefined";
1506 return "jsStringOrFalse($value)" if $conv eq "False";
1508 die "Unknown value for ConvertNullStringTo extended attribute";
1510 return "jsString($value)";
1513 if ($type eq "RGBColor") {
1514 $implIncludes{"kjs_css.h"} = 1;
1515 return "getJSRGBColor(exec, $value)";
1518 if ($codeGenerator->IsPodType($type)) {
1519 $implIncludes{"JS$type.h"} = 1;
1521 my $nativeType = GetNativeType($type);
1523 my $getter = $value;
1524 $getter =~ s/imp->//;
1525 $getter =~ s/\(\)//;
1527 my $setter = "set" . $codeGenerator->WK_ucfirst($getter);
1529 if ($implClassNameForValueConversion eq "") {
1530 if (IsSVGTypeNeedingContextParameter($implClassName)) {
1531 return "toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<$nativeType>($value), castedThisObj->context())" if $inFunctionCall eq 1;
1533 # Special case: SVGZoomEvent - it doesn't have a context, but it's no problem, as there are no readwrite props
1534 return "toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<$nativeType>($value), 0)" if $implClassName eq "SVGZoomEvent";
1535 return "toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<$nativeType>($value), context())";
1537 return "toJS(exec, new JSSVGPODTypeWrapperCreatorReadOnly<$nativeType>($value), imp)";
1539 } else { # These classes, always have a m_context pointer!
1540 return "toJS(exec, JSSVGPODTypeWrapperCache<$nativeType, $implClassNameForValueConversion>::lookupOrCreateWrapper(imp, &${implClassNameForValueConversion}::$getter, &${implClassNameForValueConversion}::$setter), context())";
1544 if ($codeGenerator->IsSVGAnimatedType($type)) {
1546 $value .= "Animated()";
1549 if ($type eq "CSSStyleDeclaration") {
1550 $implIncludes{"CSSMutableStyleDeclaration.h"} = 1;
1553 if ($type eq "NamedNodeMap") {
1554 $implIncludes{"NamedAttrMap.h"} = 1;
1557 if ($type eq "NodeList") {
1558 $implIncludes{"NameNodeList.h"} = 1;
1561 if ($type eq "EventTarget") {
1562 $implIncludes{"EventTargetNode.h"} = 1;
1563 $implIncludes{"JSEventTargetNode.h"} = 1;
1564 $implIncludes{"kjs_dom.h"} = 1;
1565 } elsif ($type eq "DOMWindow") {
1566 $implIncludes{"kjs_window.h"} = 1;
1567 } elsif ($type eq "DOMObject") {
1568 $implIncludes{"JSCanvasRenderingContext2D.h"} = 1;
1569 } elsif ($type eq "Clipboard") {
1570 $implIncludes{"kjs_events.h"} = 1;
1571 $implIncludes{"Clipboard.h"} = 1;
1572 } elsif ($type =~ /SVGPathSeg/) {
1573 $implIncludes{"JS$type.h"} = 1;
1574 $joinedName = $type;
1575 $joinedName =~ s/Abs|Rel//;
1576 $implIncludes{"$joinedName.h"} = 1;
1578 # Default, include header with same name.
1579 $implIncludes{"JS$type.h"} = 1;
1580 $implIncludes{"$type.h"} = 1;
1583 return $value if $codeGenerator->IsSVGAnimatedType($type);
1585 if (IsSVGTypeNeedingContextParameter($type)) {
1586 if (IsSVGTypeNeedingContextParameter($implClassName)) {
1587 if ($inFunctionCall eq 1) {
1588 return "toJS(exec, WTF::getPtr($value), castedThisObj->context())";
1590 return "toJS(exec, WTF::getPtr($value), context())";
1593 return "toJS(exec, WTF::getPtr($value), imp)";
1597 return "toJS(exec, WTF::getPtr($value))";
1600 sub ceilingToPowerOf2
1605 while ($size > $powerOf2) {
1613 sub GenerateHashTable
1621 my $specials = shift;
1622 my $parameters = shift;
1628 $size = ceilingToPowerOf2($size * 2);
1632 my $numEntries = $size;
1634 # Collect hashtable information
1636 foreach (@{$keys}) {
1638 my $h = $object->GenerateHashValue($_) % $numEntries;
1640 while (defined($table[$h])) {
1641 if (defined($links[$h])) {
1655 $maxDepth = $depth if ($depth > $maxDepth);
1658 # Ensure table is big enough (in case of undef entries at the end)
1659 if ($#table + 1 < $size) {
1660 $#table = $size - 1;
1663 # Start outputing the hashtables
1664 my $nameEntries = "${name}Entries";
1665 $nameEntries =~ s/:/_/g;
1667 if (($name =~ /Prototype/) or ($name =~ /Constructor/)) {
1671 if ($name =~ /Prototype/) {
1672 $type =~ s/Prototype.*//;
1673 $implClass = $type; $implClass =~ s/Wrapper$//;
1674 push(@implContent, "/* Hash table for prototype */\n");
1676 $type =~ s/Constructor.*//;
1677 $implClass = $type; $implClass =~ s/Constructor$//;
1678 push(@implContent, "/* Hash table for constructor */\n");
1681 push(@implContent, "/* Hash table */\n");
1684 # Dump the hash table
1685 push(@implContent, "\nstatic const HashEntry $nameEntries\[\] =\n\{\n");
1688 foreach $entry (@table) {
1689 if (defined($entry)) {
1690 my $key = @$keys[$entry];
1692 push(@implContent, " \{ \"" . $key . "\"");
1693 push(@implContent, ", \{ (intptr_t)" . @$values[$entry] . " \}");
1694 push(@implContent, ", " . @$specials[$entry]);
1695 push(@implContent, ", " . @$parameters[$entry]);
1696 push(@implContent, ", ");
1698 if (defined($links[$i])) {
1699 push(@implContent, "&" . $nameEntries . "[$links[$i]]" . " \}");
1701 push(@implContent, "0 \}");
1704 push(@implContent, " { 0, { 0 }, 0, 0, 0 }");
1707 push(@implContent, ",") unless($i eq $size - 1);
1708 push(@implContent, "\n");
1713 my $sizeMask = $numEntries - 1;
1715 push(@implContent, "};\n\n");
1716 push(@implContent, "static const HashTable $name = \n");
1717 push(@implContent, "{\n 3, $size, $nameEntries, $sizeMask\n};\n\n");
1721 sub GenerateHashValue
1725 @chars = split(/ */, $_[0]);
1727 # This hash is designed to work on 16-bit chunks at a time. But since the normal case
1728 # (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they
1729 # were 16-bit chunks, which should give matching results
1731 my $EXP2_32 = 4294967296;
1733 my $hash = 0x9e3779b9;
1734 my $l = scalar @chars; #I wish this was in Ruby --- Maks
1741 for (; $l > 0; $l--) {
1742 $hash += ord($chars[$s]);
1743 my $tmp = leftShift(ord($chars[$s+1]), 11) ^ $hash;
1744 $hash = (leftShift($hash, 16)% $EXP2_32) ^ $tmp;
1746 $hash += $hash >> 11;
1752 $hash += ord($chars[$s]);
1753 $hash ^= (leftShift($hash, 11)% $EXP2_32);
1754 $hash += $hash >> 17;
1757 # Force "avalanching" of final 127 bits
1758 $hash ^= leftShift($hash, 3);
1759 $hash += ($hash >> 5);
1760 $hash = ($hash% $EXP2_32);
1761 $hash ^= (leftShift($hash, 2)% $EXP2_32);
1762 $hash += ($hash >> 15);
1763 $hash = $hash% $EXP2_32;
1764 $hash ^= (leftShift($hash, 10)% $EXP2_32);
1766 # this avoids ever returning a hash code of 0, since that is used to
1767 # signal "hash not computed yet", using a value that is likely to be
1768 # effectively the same as 0 when the low bits are masked
1769 $hash = 0x80000000 if ($hash == 0);
1777 if (defined($IMPL)) {
1778 # Write content to file.
1779 print $IMPL @implContentHeader;
1781 foreach my $implInclude (sort keys(%implIncludes)) {
1782 my $checkType = $implInclude;
1783 $checkType =~ s/\.h//;
1785 print $IMPL "#include \"$implInclude\"\n" unless $codeGenerator->IsSVGAnimatedType($checkType);
1788 print $IMPL @implContent;
1792 @implContentHeader = ();
1797 if (defined($HEADER)) {
1798 # Write content to file.
1799 print $HEADER @headerContent;
1803 @headerContent = ();
1809 my $className = shift;
1810 my $protoClassName = shift;
1811 my $interfaceName = shift;
1812 my $visibleClassName = shift;
1813 my $canConstruct = shift;
1815 my $implContent = << "EOF";
1816 class ${className}Constructor : public DOMObject {
1818 ${className}Constructor(ExecState* exec)
1819 : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
1821 putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec), None);
1823 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
1824 JSValue* getValueProperty(ExecState*, int token) const;
1825 virtual const ClassInfo* classInfo() const { return &info; }
1826 static const ClassInfo info;
1828 virtual bool implementsHasInstance() const { return true; }
1831 if ($canConstruct) {
1832 $implContent .= << "EOF";
1833 virtual bool implementsConstruct() const { return true; }
1834 virtual JSObject* construct(ExecState* exec, const List& args) { return static_cast<JSObject*>(toJS(exec, ${interfaceName}::create())); }
1838 $implContent .= << "EOF";
1841 const ClassInfo ${className}Constructor::info = { "${visibleClassName}Constructor", 0, &${className}ConstructorTable };
1843 bool ${className}Constructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
1845 return getStaticValueSlot<${className}Constructor, DOMObject>(exec, &${className}ConstructorTable, this, propertyName, slot);
1848 JSValue* ${className}Constructor::getValueProperty(ExecState*, int token) const
1850 // The token is the numeric value of its associated constant
1851 return jsNumber(token);
1856 return $implContent;