Commit bd62eba1 authored by darin's avatar darin

Reviewed by Anders.

        - http://bugzilla.opendarwin.org/show_bug.cgi?id=7875
          autogenerate bindings for Range

        * dom/Range.idl: Added.
        * khtml/ecma/kjs_range.cpp: Removed.
        * khtml/ecma/kjs_range.h: Removed.

        * WebCore.vcproj/WebCore/build-generated-files.sh: Removed code to generate
        kjs_range.lut.h.

        * WebCore.xcodeproj/project.pbxproj: Added Range.idl source file.
        Removed kjs_range.h and kjs_range.cpp source files. Sorted the "dom" group.
        Removed rule to generate kjs_range.lut.h.

        * bindings/js/JSDOMCore.cpp: Added include of JSRange.cpp.

        * bindings/scripts/CodeGeneratorJS.pm: Added DocumentFragment, Range, CompareHow,
        and short to the types this script can handle. Added code to generate toRange
        functions and the like. Added separate code to handle exceptions for getters
        vs. setters for attributes. Changed return values for the "bad ID" case to 0
        -- there's no need to generate the extra code to return jsUndefined() in such
        cases, which should be unreachable. Changed exception handling to use setDOMException
        directly instead of DOMExceptionTranslator; DOMExceptionTranslator was a trick
        to make it easier to convert existing bindings and shouldn't be used going
        forward. Fixed names of constructors to use the JavaScript class name (the
        interface name), not the name of the C++ implementation class. Fixed generation
        of code for functions that have no parameters but do raise exceptions.

        * bindings/scripts/IDLParser.pm: Added parsing for separate getter and setter
        exceptions in attributes. The syntax is not real IDL, but real IDL doesn't support
        declaring exceptions on attributes at all. We'll probably want to revisit our
        syntax for this some day.

        * bindings/scripts/IDLStructure.pm: Removed unused exceptionName field from
        domAttribute, and replaced raisesExceptions field with getterExceptions and
        setterExceptions. Added regular expressions for parsing getter/setter syntax.
        We'll probably have to redo this whole thing parse in a better way at some
        point -- the regular expressions allow any invalid syntax in between them.

        * dom/Attr.idl: Change exception declaration for setting the value attribute
        to use setter-specific exception syntax.
        * dom/CharacterData.idl: Change exception declaration for setting the data
        attribute to use setter-specific exception syntax.
        * dom/ProcessingInstruction.idl: Change exception declaration for setting the
        data attribute to use setter-specific exception syntax.

        * khtml/ecma/kjs_dom.cpp: Include JSRange.h instead of kjs_range.h.
        * khtml/ecma/kjs_window.cpp: Include JSRange.h instead of kjs_range.h.
        (KJS::Window::getValueProperty): Use JSRange::getConstructor instead of
        getRangeConstructor.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@13400 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 79d19e14
2006-03-20 Darin Adler <darin@apple.com>
Reviewed by Anders.
- http://bugzilla.opendarwin.org/show_bug.cgi?id=7875
autogenerate bindings for Range
* dom/Range.idl: Added.
* khtml/ecma/kjs_range.cpp: Removed.
* khtml/ecma/kjs_range.h: Removed.
* WebCore.vcproj/WebCore/build-generated-files.sh: Removed code to generate
kjs_range.lut.h.
* WebCore.xcodeproj/project.pbxproj: Added Range.idl source file.
Removed kjs_range.h and kjs_range.cpp source files. Sorted the "dom" group.
Removed rule to generate kjs_range.lut.h.
* bindings/js/JSDOMCore.cpp: Added include of JSRange.cpp.
* bindings/scripts/CodeGeneratorJS.pm: Added DocumentFragment, Range, CompareHow,
and short to the types this script can handle. Added code to generate toRange
functions and the like. Added separate code to handle exceptions for getters
vs. setters for attributes. Changed return values for the "bad ID" case to 0
-- there's no need to generate the extra code to return jsUndefined() in such
cases, which should be unreachable. Changed exception handling to use setDOMException
directly instead of DOMExceptionTranslator; DOMExceptionTranslator was a trick
to make it easier to convert existing bindings and shouldn't be used going
forward. Fixed names of constructors to use the JavaScript class name (the
interface name), not the name of the C++ implementation class. Fixed generation
of code for functions that have no parameters but do raise exceptions.
* bindings/scripts/IDLParser.pm: Added parsing for separate getter and setter
exceptions in attributes. The syntax is not real IDL, but real IDL doesn't support
declaring exceptions on attributes at all. We'll probably want to revisit our
syntax for this some day.
* bindings/scripts/IDLStructure.pm: Removed unused exceptionName field from
domAttribute, and replaced raisesExceptions field with getterExceptions and
setterExceptions. Added regular expressions for parsing getter/setter syntax.
We'll probably have to redo this whole thing parse in a better way at some
point -- the regular expressions allow any invalid syntax in between them.
* dom/Attr.idl: Change exception declaration for setting the value attribute
to use setter-specific exception syntax.
* dom/CharacterData.idl: Change exception declaration for setting the data
attribute to use setter-specific exception syntax.
* dom/ProcessingInstruction.idl: Change exception declaration for setting the
data attribute to use setter-specific exception syntax.
* khtml/ecma/kjs_dom.cpp: Include JSRange.h instead of kjs_range.h.
* khtml/ecma/kjs_window.cpp: Include JSRange.h instead of kjs_range.h.
(KJS::Window::getValueProperty): Use JSRange::getConstructor instead of
getRangeConstructor.
2006-03-20 Eric Seidel <eseidel@apple.com>
Reviewed by hyatt.
......@@ -94,10 +94,6 @@ if [ ../JavaScriptCore/kjs/create_hash_table -nt "$DerivedSourcesDir/kjs_navigat
../JavaScriptCore/kjs/create_hash_table khtml/ecma/kjs_navigator.cpp > "$DerivedSourcesDir/kjs_navigator.lut.h"
fi
if [ ../JavaScriptCore/kjs/create_hash_table -nt "$DerivedSourcesDir/kjs_range.lut.h" -o khtml/ecma/kjs_range.cpp -nt "$DerivedSourcesDir/kjs_range.lut.h" ]; then
../JavaScriptCore/kjs/create_hash_table khtml/ecma/kjs_range.cpp > "$DerivedSourcesDir/kjs_range.lut.h"
fi
if [ ../JavaScriptCore/kjs/create_hash_table -nt "$DerivedSourcesDir/kjs_traversal.lut.h" -o khtml/ecma/kjs_traversal.cpp -nt "$DerivedSourcesDir/kjs_traversal.lut.h" ]; then
../JavaScriptCore/kjs/create_hash_table khtml/ecma/kjs_traversal.cpp > "$DerivedSourcesDir/kjs_traversal.lut.h"
fi
......
......@@ -209,6 +209,7 @@
935FBC4509BA00B900E230B1 /* EventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 935FBC4409BA00B900E230B1 /* EventListener.h */; };
935FBCF209BA143B00E230B1 /* ExceptionCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 935FBCF109BA143B00E230B1 /* ExceptionCode.h */; };
936B424E09A436CD00BAA820 /* SVGCSSParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F6F6089701F100BA5114 /* SVGCSSParser.cpp */; };
936DD03B09CEAC270056AE8C /* Range.idl in Resources */ = {isa = PBXBuildFile; fileRef = 936DD03A09CEAC270056AE8C /* Range.idl */; };
937A36A7097E2E3200E4EE2F /* UserAgentStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 937A36A6097E2E3200E4EE2F /* UserAgentStyleSheets.cpp */; };
9380F47309A11AB4001FDB34 /* Widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9380F47109A11AB4001FDB34 /* Widget.cpp */; };
9380F47409A11AB4001FDB34 /* Widget.h in Headers */ = {isa = PBXBuildFile; fileRef = 9380F47209A11AB4001FDB34 /* Widget.h */; };
......@@ -256,7 +257,6 @@
93F198D508245E59001E9ABC /* kjs_html.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D20002DE4369018635CA /* kjs_html.h */; };
93F198D708245E59001E9ABC /* kjs_navigator.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D20302DE4369018635CA /* kjs_navigator.h */; };
93F198D908245E59001E9ABC /* kjs_proxy.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D20602DE4369018635CA /* kjs_proxy.h */; };
93F198DA08245E59001E9ABC /* kjs_range.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D20802DE4369018635CA /* kjs_range.h */; };
93F198DC08245E59001E9ABC /* kjs_traversal.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D20B02DE4369018635CA /* kjs_traversal.h */; };
93F198DE08245E59001E9ABC /* kjs_views.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D20E02DE4369018635CA /* kjs_views.h */; };
93F198E008245E59001E9ABC /* kjs_window.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D21102DE4369018635CA /* kjs_window.h */; };
......@@ -383,7 +383,6 @@
93F19A8708245E59001E9ABC /* kjs_html.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D1FF02DE4369018635CA /* kjs_html.cpp */; };
93F19A8808245E59001E9ABC /* kjs_navigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D20202DE4369018635CA /* kjs_navigator.cpp */; };
93F19A8908245E59001E9ABC /* kjs_proxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D20502DE4369018635CA /* kjs_proxy.cpp */; };
93F19A8A08245E59001E9ABC /* kjs_range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D20702DE4369018635CA /* kjs_range.cpp */; };
93F19A8B08245E59001E9ABC /* kjs_traversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D20A02DE4369018635CA /* kjs_traversal.cpp */; };
93F19A8C08245E59001E9ABC /* kjs_views.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D20D02DE4369018635CA /* kjs_views.cpp */; };
93F19A8D08245E59001E9ABC /* kjs_window.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F523D21002DE4369018635CA /* kjs_window.cpp */; };
......@@ -1361,6 +1360,7 @@
935C477409AC4D8D00A6AAB4 /* GapRects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GapRects.h; sourceTree = "<group>"; };
935FBC4409BA00B900E230B1 /* EventListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventListener.h; sourceTree = "<group>"; };
935FBCF109BA143B00E230B1 /* ExceptionCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCode.h; sourceTree = "<group>"; };
936DD03A09CEAC270056AE8C /* Range.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Range.idl; sourceTree = "<group>"; };
937A36A6097E2E3200E4EE2F /* UserAgentStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserAgentStyleSheets.cpp; sourceTree = "<group>"; };
9380F47109A11AB4001FDB34 /* Widget.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Widget.cpp; path = platform/Widget.cpp; sourceTree = "<group>"; };
9380F47209A11AB4001FDB34 /* Widget.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Widget.h; path = platform/Widget.h; sourceTree = "<group>"; };
......@@ -2208,8 +2208,6 @@
F523D20302DE4369018635CA /* kjs_navigator.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = kjs_navigator.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D20502DE4369018635CA /* kjs_proxy.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_proxy.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D20602DE4369018635CA /* kjs_proxy.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = kjs_proxy.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D20702DE4369018635CA /* kjs_range.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_range.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D20802DE4369018635CA /* kjs_range.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = kjs_range.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D20A02DE4369018635CA /* kjs_traversal.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_traversal.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D20B02DE4369018635CA /* kjs_traversal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = kjs_traversal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D20D02DE4369018635CA /* kjs_views.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_views.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -3673,8 +3671,6 @@
F523D20302DE4369018635CA /* kjs_navigator.h */,
F523D20502DE4369018635CA /* kjs_proxy.cpp */,
F523D20602DE4369018635CA /* kjs_proxy.h */,
F523D20702DE4369018635CA /* kjs_range.cpp */,
F523D20802DE4369018635CA /* kjs_range.h */,
F523D20A02DE4369018635CA /* kjs_traversal.cpp */,
F523D20B02DE4369018635CA /* kjs_traversal.h */,
F523D20D02DE4369018635CA /* kjs_views.cpp */,
......@@ -3782,15 +3778,17 @@
F523D32402DE4478018635CA /* dom */ = {
isa = PBXGroup;
children = (
F523D30702DE4476018635CA /* AbstractView.cpp */,
F523D30802DE4476018635CA /* AbstractView.h */,
BC3B364705C9D5E200E42902 /* AtomicStringList.h */,
93EEC1E509C2877700C515D1 /* Attr.idl */,
AB23A32509BBA7D00067CC53 /* BeforeTextInsertedEvent.cpp */,
AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEvent.h */,
6550B693099DF0270090D781 /* CDATASection.cpp */,
6550B694099DF0270090D781 /* CDATASection.h */,
93EEC1E609C2877700C515D1 /* CharacterData.idl */,
6550B695099DF0270090D781 /* CharacterData.cpp */,
6550B696099DF0270090D781 /* CharacterData.h */,
93EEC1E609C2877700C515D1 /* CharacterData.idl */,
A818721A0977D3C0005826D9 /* ChildNodeList.cpp */,
A81872150977D3C0005826D9 /* ChildNodeList.h */,
6550B697099DF0270090D781 /* Comment.cpp */,
......@@ -3798,31 +3796,25 @@
A81872140977D3C0005826D9 /* ContainerNode.cpp */,
A81872110977D3C0005826D9 /* ContainerNode.h */,
93EEC1E709C2877700C515D1 /* DocPtr.h */,
A8185F3709765765005826D9 /* DocumentFragment.cpp */,
A8185F3509765765005826D9 /* DocumentFragment.h */,
A8185F3409765765005826D9 /* Document.cpp */,
A8185F3809765765005826D9 /* Document.h */,
A8185F3709765765005826D9 /* DocumentFragment.cpp */,
A8185F3509765765005826D9 /* DocumentFragment.h */,
ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */,
93EEC1E809C2877700C515D1 /* DocumentType.idl */,
A8185F3209765765005826D9 /* DocumentType.cpp */,
A8185F3109765765005826D9 /* DocumentType.h */,
93EEC1E809C2877700C515D1 /* DocumentType.idl */,
F523D30102DE4476018635CA /* dom2_eventsimpl.cpp */,
F523D30202DE4476018635CA /* dom2_eventsimpl.h */,
F523D30302DE4476018635CA /* Range.cpp */,
F523D30402DE4476018635CA /* Range.h */,
F523D30502DE4476018635CA /* dom2_traversalimpl.cpp */,
F523D30602DE4476018635CA /* dom2_traversalimpl.h */,
F523D30702DE4476018635CA /* AbstractView.cpp */,
F523D30802DE4476018635CA /* AbstractView.h */,
F523D2F702DE4476018635CA /* dom_elementimpl.cpp */,
F523D2F802DE4476018635CA /* dom_elementimpl.h */,
BE91FC8C06133666005E3790 /* Position.cpp */,
BE91FC8B06133666005E3790 /* Position.h */,
F523D2FF02DE4476018635CA /* dom_xmlimpl.cpp */,
F523D30002DE4476018635CA /* dom_xmlimpl.h */,
93EEC1E909C2877700C515D1 /* DOMImplementation.idl */,
A8185F3609765765005826D9 /* DOMImplementation.cpp */,
A8185F3309765765005826D9 /* DOMImplementation.h */,
93EEC1E909C2877700C515D1 /* DOMImplementation.idl */,
6550B699099DF0270090D781 /* EditingText.cpp */,
6550B69A099DF0270090D781 /* EditingText.h */,
93EEC1EA09C2877700C515D1 /* Element.idl */,
......@@ -3830,6 +3822,8 @@
935FBC4409BA00B900E230B1 /* EventListener.h */,
939885C108B7E3D100E707C4 /* EventNames.cpp */,
939885C208B7E3D100E707C4 /* EventNames.h */,
14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */,
14EC267D09CA07E000E1EEEC /* EventTargetNode.h */,
935FBCF109BA143B00E230B1 /* ExceptionCode.h */,
93EEC1F309C2877700C515D1 /* MutationEvent.idl */,
A81872180977D3C0005826D9 /* NamedNodeMap.h */,
......@@ -3840,17 +3834,20 @@
A81872160977D3C0005826D9 /* NodeList.cpp */,
A81872100977D3C0005826D9 /* NodeList.h */,
93EEC1F409C2877700C515D1 /* Notation.idl */,
93EEC1F709C2877700C515D1 /* PlatformWheelEvent.idl */,
BE91FC8C06133666005E3790 /* Position.cpp */,
BE91FC8B06133666005E3790 /* Position.h */,
93EEC1F509C2877700C515D1 /* ProcessingInstruction.idl */,
550A0BC7085F6039007353D6 /* QualifiedName.cpp */,
550A0BC8085F6039007353D6 /* QualifiedName.h */,
93EEC1F609C2877700C515D1 /* Text.idl */,
F523D30302DE4476018635CA /* Range.cpp */,
F523D30402DE4476018635CA /* Range.h */,
936DD03A09CEAC270056AE8C /* Range.idl */,
6550B69B099DF0270090D781 /* Text.cpp */,
6550B69C099DF0270090D781 /* Text.h */,
93EEC1F709C2877700C515D1 /* PlatformWheelEvent.idl */,
93EEC1F609C2877700C515D1 /* Text.idl */,
F523D30902DE4476018635CA /* xml_tokenizer.cpp */,
F523D30A02DE4476018635CA /* xml_tokenizer.h */,
14EC267D09CA07E000E1EEEC /* EventTargetNode.h */,
14EC267E09CA07E000E1EEEC /* EventTargetNode.cpp */,
);
path = dom;
sourceTree = "<group>";
......@@ -3942,7 +3939,6 @@
93F198D508245E59001E9ABC /* kjs_html.h in Headers */,
93F198D708245E59001E9ABC /* kjs_navigator.h in Headers */,
93F198D908245E59001E9ABC /* kjs_proxy.h in Headers */,
93F198DA08245E59001E9ABC /* kjs_range.h in Headers */,
93F198DC08245E59001E9ABC /* kjs_traversal.h in Headers */,
93F198DE08245E59001E9ABC /* kjs_views.h in Headers */,
93F198E008245E59001E9ABC /* kjs_window.h in Headers */,
......@@ -4479,7 +4475,6 @@
932FC1650824A8EE005B3C75 /* kjs_events.lut.h */,
932FC1630824A8E9005B3C75 /* kjs_html.lut.h */,
932FC1670824A8F6005B3C75 /* kjs_navigator.lut.h */,
932FC1690824A8FC005B3C75 /* kjs_range.lut.h */,
932FC16B0824A901005B3C75 /* kjs_traversal.lut.h */,
932FC16D0824A906005B3C75 /* kjs_views.lut.h */,
932FC16F0824A90D005B3C75 /* kjs_window.lut.h */,
......@@ -4645,6 +4640,7 @@
930CAB8909C49EFA00229C04 /* CanvasGradient.idl in Resources */,
930CAB9009C49F1B00229C04 /* CanvasPattern.idl in Resources */,
930CAB9709C49FAA00229C04 /* CodeGeneratorJS.pm in Resources */,
936DD03B09CEAC270056AE8C /* Range.idl in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -4834,23 +4830,6 @@
shellPath = /bin/sh;
shellScript = "\"$CREATE_HASH_TABLE\" khtml/ecma/kjs_navigator.cpp > \"$DERIVED_FILE_DIR/kjs_navigator.lut.h\"";
};
932FC1690824A8FC005B3C75 /* kjs_range.lut.h */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"$(CREATE_HASH_TABLE)",
khtml/ecma/kjs_range.cpp,
);
name = kjs_range.lut.h;
outputPaths = (
"$(DERIVED_FILE_DIR)/kjs_range.lut.h",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$CREATE_HASH_TABLE\" khtml/ecma/kjs_range.cpp > \"$DERIVED_FILE_DIR/kjs_range.lut.h\"";
};
932FC16B0824A901005B3C75 /* kjs_traversal.lut.h */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
......@@ -5154,7 +5133,6 @@
93F19A8708245E59001E9ABC /* kjs_html.cpp in Sources */,
93F19A8808245E59001E9ABC /* kjs_navigator.cpp in Sources */,
93F19A8908245E59001E9ABC /* kjs_proxy.cpp in Sources */,
93F19A8A08245E59001E9ABC /* kjs_range.cpp in Sources */,
93F19A8B08245E59001E9ABC /* kjs_traversal.cpp in Sources */,
93F19A8C08245E59001E9ABC /* kjs_views.cpp in Sources */,
93F19A8D08245E59001E9ABC /* kjs_window.cpp in Sources */,
......
#include "config.h"
// The files below are generated by a script.
// The files below are all generated by a script.
#include "JSAttr.cpp"
#include "JSCharacterData.cpp"
......@@ -10,4 +10,5 @@
#include "JSEntity.cpp"
#include "JSNotation.cpp"
#include "JSProcessingInstruction.cpp"
#include "JSRange.cpp"
#include "JSText.cpp"
#include "config.h"
// The files below are generated by a script.
// The files below are all generated by a script.
#include "JSMutationEvent.cpp"
#include "JSWheelEvent.cpp"
#include "config.h"
// The files below are generated by a script.
// The files below are all generated by a script.
#include "JSCanvasGradient.cpp"
#include "JSCanvasPattern.cpp"
......
......@@ -185,7 +185,10 @@ sub AddIncludesForType
$type eq "DOMImplementation" or
$type eq "NodeList" or
$type eq "Text" or
$type eq "CharacterData") {
$type eq "CharacterData" or
$type eq "CanvasPattern" or
$type eq "Range" or
$type eq "DocumentFragment") {
$implIncludes{"${type}.h"} = 1;
} elsif ($type eq "Attr" or
$type eq "Element") {
......@@ -209,8 +212,6 @@ sub AddIncludesForType
} elsif ($type eq "CanvasGradient") {
$implIncludes{"CanvasGradient.h"} = 1;
$implIncludes{"PlatformString.h"} = 1;
} elsif ($type eq "CanvasPattern") {
$implIncludes{"$type.h"} = 1;
} elsif ($codeGenerator->IsPrimitiveType($type) or
$type eq "DOMString") {
# Do nothing
......@@ -240,8 +241,6 @@ sub GenerateHeader
my $interfaceName = $dataNode->name;
my $className = "JS$interfaceName";
my $implClassName = $interfaceName;
# Canvas classes don't have Impl suffix (remove this when removing the Impl suffix elsewhere).
$implClassName = $interfaceName if $interfaceName =~ /^Canvas/;
# FIXME: If we're sure that an interface can't have more than
# one parent we can do the check in the parser instead
......@@ -378,7 +377,8 @@ sub GenerateHeader
push(@headerContent, "};\n\n");
if (!$hasParent) {
push(@headerContent, "KJS::JSValue* toJS(KJS::ExecState*, $implClassName*);\n\n");
push(@headerContent, "KJS::JSValue* toJS(KJS::ExecState*, $implClassName*);\n");
push(@headerContent, "$implClassName* to${interfaceName}(KJS::JSValue*);\n\n");
}
# Add prototype declaration
......@@ -401,8 +401,6 @@ sub GenerateImplementation
my $interfaceName = $dataNode->name;
my $className = "JS$interfaceName";
my $implClassName = $interfaceName;
# Canvas classes don't have Impl suffix (remove this when removing the Impl suffix elsewhere).
$implClassName = $interfaceName if $interfaceName =~ /^Canvas/;
my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"};
my $hasRealParent = @{$dataNode->parents} > 0;
......@@ -586,25 +584,26 @@ sub GenerateImplementation
foreach my $attribute (@{$dataNode->attributes}) {
my $name = $attribute->signature->name;
push(@implContent, " case " . ucfirst($name) . ":\n");
push(@implContent, " return " . NativeToJSValue($attribute->signature, "impl->$name()") . ";\n");
if (!@{$attribute->getterExceptions}) {
push(@implContent, " case " . ucfirst($name) . ":\n");
push(@implContent, " return " . NativeToJSValue($attribute->signature, "impl->$name()") . ";\n");
} else {
push(@implContent, " case " . ucfirst($name) .": {\n");
push(@implContent, " ExceptionCode ec = 0;\n");
push(@implContent, " KJS::JSValue* result = " . NativeToJSValue($attribute->signature, "impl->$name(ec)") . ";\n");
push(@implContent, " setDOMException(exec, ec);\n");
push(@implContent, " return result;\n");
push(@implContent, " }\n");
}
}
push(@implContent, " }\n return jsUndefined();\n}\n\n");
push(@implContent, " }\n return 0;\n}\n\n");
# Check if we have any writable attributes and if they raise exceptions
# Check if we have any writable attributes
my $hasReadWriteProperties = 0;
my $raisesExceptions = 0;
foreach my $attribute (@{$dataNode->attributes}) {
if($attribute->type !~ /^readonly\ attribute$/) {
$hasReadWriteProperties = 1;
if (@{$attribute->raisesExceptions}) {
$raisesExceptions = 1;
}
}
$hasReadWriteProperties = 1 if $attribute->type !~ /^readonly/;
}
if ($hasReadWriteProperties) {
push(@implContent, "void ${className}::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)\n");
push(@implContent, "{\n lookupPut<$className, $parentClassName>" .
......@@ -612,51 +611,38 @@ sub GenerateImplementation
push(@implContent, "void ${className}::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)\n");
push(@implContent, "{\n");
if ($raisesExceptions) {
push(@implContent, " DOMExceptionTranslator exception(exec);\n");
}
push(@implContent, " $implClassName* impl = static_cast<$implClassName*>(${className}::impl());\n\n");
push(@implContent, " switch (token) {\n");
foreach my $attribute (@{$dataNode->attributes}) {
if($attribute->type !~ /^readonly\ attribute$/) {
if ($attribute->type !~ /^readonly/) {
my $name = $attribute->signature->name;
push(@implContent, " case " . ucfirst($name) .":\n");
push(@implContent, " case " . ucfirst($name) .": {\n");
push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions};
push(@implContent, " impl->set" . ucfirst($name) . "(" . JSValueToNative($attribute->signature, "value"));
if (@{$attribute->raisesExceptions}) {
push(@implContent, ", exception")
}
push(@implContent, ");\n break;\n");
push(@implContent, ", ec") if @{$attribute->setterExceptions};
push(@implContent, ");\n");
push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions};
push(@implContent, " }\n");
push(@implContent, " break;\n");
}
}
push(@implContent, " }\n}\n\n");
}
}
if ($numConstants ne 0) {
push(@implContent, "JSValue* ${className}::getConstructor(ExecState* exec)\n{\n");
push(@implContent, " return cacheGlobalObject<${className}Constructor>(exec, \"[[${className}.constructor]]\");\n");
push(@implContent, " return cacheGlobalObject<${className}Constructor>(exec, \"[[${interfaceName}.constructor]]\");\n");
push(@implContent, "}\n");
}
# Functions
if($numFunctions ne 0) {
my $raisesExceptions = 0;
# Check if any of the functions throw exceptions
foreach my $function (@{$dataNode->functions}) {
if (@{$function->raisesExceptions}) {
$raisesExceptions = 1;
}
}
push(@implContent, "JSValue* ${className}ProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)\n{\n");
push(@implContent, " if (!thisObj->inherits(&${className}::info))\n");
push(@implContent, " return throwError(exec, TypeError);\n\n");
if ($raisesExceptions) {
push(@implContent, " DOMExceptionTranslator exception(exec);\n");
}
push(@implContent, " $implClassName* impl = static_cast<$implClassName*>(static_cast<$className*>(thisObj)->impl());\n\n");
......@@ -680,33 +666,36 @@ sub GenerateImplementation
$implIncludes{"ExceptionCode.h"} = 1;
push(@implContent, " if ($name < 0) {\n");
push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n");
push(@implContent, " break;\n }\n");
push(@implContent, " return jsUndefined();\n }\n");
}
$paramIndex++;
if ($paramIndex < $numParameters) {
$functionString .= "$name, ";
} else {
$functionString .= "$name";
}
$functionString .= ", " if $paramIndex;
$functionString .= $name;
$paramIndex++;
}
if (@{$function->raisesExceptions}) {
$functionString .= ", exception)";
} else {
$functionString .= ")";
$functionString .= ", " if $paramIndex;
$functionString .= "ec";
push(@implContent, " ExceptionCode ec = 0;\n");
}
$functionString .= ")";
if ($function->signature->type eq "void") {
push(@implContent, "\n $functionString;\n return jsUndefined();\n");
push(@implContent, "\n $functionString;\n");
push(@implContent, " setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
push(@implContent, " return jsUndefined();\n");
} else {
push(@implContent, "\n return " . NativeToJSValue($function->signature, $functionString) . ";\n");
push(@implContent, "\n KJS::JSValue* result = " . NativeToJSValue($function->signature, $functionString) . ";\n");
push(@implContent, " setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
push(@implContent, " return result;\n");
}
push(@implContent, " }\n");
}
push(@implContent, " }\n");
push(@implContent, " return jsUndefined();\n");
push(@implContent, " return 0;\n");
push(@implContent, "}\n")
}
......@@ -715,6 +704,10 @@ sub GenerateImplementation
push(@implContent, "{\n");
push(@implContent, " return KJS::cacheDOMObject<$implClassName, $className>(exec, obj);\n");
push(@implContent, "}\n");
push(@implContent, "$implClassName* to${interfaceName}(KJS::JSValue* val)\n");
push(@implContent, "{\n");
push(@implContent, " return val->isObject(&${className}::info) ? static_cast<$className*>(val)->impl() : 0;\n");
push(@implContent, "}\n");
}
push(@implContent, "\n}\n");
......@@ -748,9 +741,13 @@ sub GetNativeType
return "String";
} elsif ($type eq "views::AbstractView") {
return "AbstractView*";
} elsif ($type eq "Node" or $type eq "Attr" or
$type eq "DocumentType") {
} elsif ($type eq "Node" or
$type eq "Attr" or
$type eq "DocumentType" or
$type eq "Range") {
return "${type}*";
} elsif ($type eq "CompareHow") {
return "Range::CompareHow";
} else {
die "Don't know how the native type of $type";
}
......@@ -769,6 +766,8 @@ sub JSValueToNative
return "$value->toInt32(exec)";
} elsif ($type eq "unsigned short") {
return "$value->toInt32(exec)";
} elsif ($type eq "CompareHow") {
return "static_cast<Range::CompareHow>($value->toInt32(exec))";
} elsif ($type eq "float") {
return "$value->toNumber(exec)";
} elsif ($type eq "AtomicString") {
......@@ -791,6 +790,9 @@ sub JSValueToNative
} elsif ($type eq "DocumentType") {
$implIncludes{"kjs_dom.h"} = 1;
return "toDocumentType($value)";
} elsif ($type eq "Range") {
$implIncludes{"JSRange.h"} = 1;
return "toRange($value)";
} else {
die "Don't know how to convert a JS value of type $type."
}
......@@ -805,8 +807,11 @@ sub NativeToJSValue
if ($type eq "boolean") {
return "jsBoolean($value)";
} elsif ($type eq "long" or $type eq "unsigned long" or
$type eq "unsigned short" or $type eq "float") {
} elsif ($type eq "long" or
$type eq "unsigned long" or
$type eq "short" or
$type eq "unsigned short" or
$type eq "float") {
return "jsNumber($value)";
} elsif ($type eq "DOMString") {
my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"};
......@@ -819,10 +824,14 @@ sub NativeToJSValue
} else {
return "jsString($value)";
}
} elsif ($type eq "Node" or $type eq "Text" or
$type eq "DocumentType" or $type eq "Document" or
$type eq "HTMLDocument" or $type eq "Element" or
$type eq "Attr") {
} elsif ($type eq "Node" or
$type eq "Text" or
$type eq "DocumentType" or
$type eq "Document" or
$type eq "HTMLDocument" or
$type eq "Element" or
$type eq "Attr" or
$type eq "DocumentFragment") {
# Add necessary includes
$implIncludes{"kjs_dom.h"} = 1;
$implIncludes{"Node.h"} = 1;
......@@ -848,6 +857,9 @@ sub NativeToJSValue
} elsif ($type eq "CanvasGradient") {
$implIncludes{"kjs_html.h"} = 1;
return "toJS(exec, $value)";
} elsif ($type eq "Range") {
$implIncludes{"JSRange.h"} = 1;
return "toJS(exec, $value)";
} else {
die "Don't know how to convert a value of type $type to a JS Value";
}
......
......@@ -249,8 +249,11 @@ sub ParseInterface
('' =~ /^/); # Reset variables needed for regexp matching
$line =~ /$IDLStructure::raisesSelector/;
my $attributeException = (defined($1) ? $1 : "");
$line =~ /$IDLStructure::getterRaisesSelector/;
my $getterException = (defined($1) ? $1 : "");
$line =~ /$IDLStructure::setterRaisesSelector/;
my $setterException = (defined($1) ? $1 : "");
my $newDataNode = new domAttribute();
$newDataNode->type($attributeType);
......@@ -263,11 +266,13 @@ sub ParseInterface
my $arrayRef = $dataNode->attributes;
push(@$arrayRef, $newDataNode);
print " | |> Attribute; TYPE \"$attributeType\" DATA NAME \"$attributeDataName\" DATA TYPE \"$attributeDataType\" EXCEPTION? \"$attributeException\"" .
print " | |> Attribute; TYPE \"$attributeType\" DATA NAME \"$attributeDataName\" DATA TYPE \"$attributeDataType\" GET EXCEPTION? \"$getterException\" SET EXCEPTION? \"$setterException\"" .
dumpExtendedAttributes("\n | ", $newDataNode->signature->extendedAttributes) . "\n" if(!$beQuiet);
$attributeException =~ s/\s+//g;
@{$newDataNode->raisesExceptions} = split(/,/, $attributeException);
$getterException =~ s/\s+//g;
$setterException =~ s/\s+//g;
@{$newDataNode->getterExceptions} = split(/,/, $getterException);
@{$newDataNode->setterExceptions} = split(/,/, $setterException);
} elsif(($line !~ s/^\s*$//g) and ($line !~ /^\s+const/)) {
$line =~ /$IDLStructure::interfaceMethodSelector/ or die "Parsing error!\nSource:\n$line\n)";
......
......@@ -49,12 +49,12 @@ struct( domFunction => {
raisesExceptions => '@', # Possibly raised exceptions.
});
# Used to represent domClass contents (name of method, signature)
# Used to represent domClass contents (name of attribute, signature)
struct( domAttribute => {
type => '$', # Attribute type (including namespace)
signature => '$', # Attribute signature
exceptionName => '$', # Name of exception
raisesExceptions => '@', # Possibly raised exceptions.
signature => '$', # Attribute signature
getterExceptions => '@', # Possibly raised exceptions.
setterExceptions => '@', # Possibly raised exceptions.
});
# Used to represent a map of 'variable name' <-> 'variable type'
......@@ -90,6 +90,8 @@ $moduleSelector = 'module\s*(' . $idlId . '*)\s*{';