Commit ac93628e authored by weinig's avatar weinig

Reviewed by Tim H.

        Patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=11082
        Simplify Internal methods for the auto-generated Objective-C DOM code

        - Auto-generate the internal methods for more Objective-C classes.

        * WebCore.xcodeproj/project.pbxproj:
        * bindings/objc/DOM.mm:
        * bindings/objc/DOMCSS.mm:
        (-[DOMStyleSheet WebCore::]):
        (+[DOMStyleSheet _styleSheetWith:WebCore::]):
        (-[DOMCSSRule WebCore::]):
        (-[DOMCSSRule _initWithCSSRule:WebCore::]):
        (+[DOMCSSRule _CSSRuleWith:WebCore::]):
        (-[DOMCSSValue WebCore::]):
        (-[DOMCSSValue _initWithCSSValue:WebCore::]):
        (+[DOMCSSValue _CSSValueWith:WebCore::]):
        * bindings/objc/DOMHTMLAppletElement.mm:
        (-[DOMHTMLAppletElement WebCore::]):
        (+[DOMHTMLAppletElement _HTMLOptionElementWith:WebCore::]):
        * bindings/objc/DOMHTMLEmbedElement.mm:
        (-[DOMHTMLEmbedElement WebCore::]):
        (+[DOMHTMLEmbedElement _HTMLEmbedElementWith:WebCore::]):
        * bindings/objc/DOMInternal.h:
        * bindings/objc/DOMInternal.mm:
        * bindings/scripts/CodeGeneratorObjC.pm:
        * css/CSSCharsetRule.idl:
        * css/CSSFontFaceRule.idl:
        * css/CSSImportRule.idl:
        * css/CSSMediaRule.idl:
        * css/CSSPageRule.idl:
        * css/CSSPrimitiveValue.idl:
        * css/CSSStyleRule.idl:
        * css/CSSStyleSheet.idl:
        * css/CSSUnknownRule.idl:
        * css/CSSValueList.idl:
        * dom/KeyboardEvent.idl:
        * dom/MouseEvent.idl:
        * dom/MutationEvent.idl:
        * dom/NodeIterator.idl:
        * dom/OverflowEvent.idl:
        * dom/UIEvent.idl:
        * dom/WheelEvent.idl:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16645 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 43f6c9d0
2006-09-29 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Tim H.
Patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=11082
Simplify Internal methods for the auto-generated Objective-C DOM code
- Auto-generate the internal methods for more Objective-C classes.
* WebCore.xcodeproj/project.pbxproj:
* bindings/objc/DOM.mm:
* bindings/objc/DOMCSS.mm:
(-[DOMStyleSheet WebCore::]):
(+[DOMStyleSheet _styleSheetWith:WebCore::]):
(-[DOMCSSRule WebCore::]):
(-[DOMCSSRule _initWithCSSRule:WebCore::]):
(+[DOMCSSRule _CSSRuleWith:WebCore::]):
(-[DOMCSSValue WebCore::]):
(-[DOMCSSValue _initWithCSSValue:WebCore::]):
(+[DOMCSSValue _CSSValueWith:WebCore::]):
* bindings/objc/DOMHTMLAppletElement.mm:
(-[DOMHTMLAppletElement WebCore::]):
(+[DOMHTMLAppletElement _HTMLOptionElementWith:WebCore::]):
* bindings/objc/DOMHTMLEmbedElement.mm:
(-[DOMHTMLEmbedElement WebCore::]):
(+[DOMHTMLEmbedElement _HTMLEmbedElementWith:WebCore::]):
* bindings/objc/DOMInternal.h:
* bindings/objc/DOMInternal.mm:
* bindings/scripts/CodeGeneratorObjC.pm:
* css/CSSCharsetRule.idl:
* css/CSSFontFaceRule.idl:
* css/CSSImportRule.idl:
* css/CSSMediaRule.idl:
* css/CSSPageRule.idl:
* css/CSSPrimitiveValue.idl:
* css/CSSStyleRule.idl:
* css/CSSStyleSheet.idl:
* css/CSSUnknownRule.idl:
* css/CSSValueList.idl:
* dom/KeyboardEvent.idl:
* dom/MouseEvent.idl:
* dom/MutationEvent.idl:
* dom/NodeIterator.idl:
* dom/OverflowEvent.idl:
* dom/UIEvent.idl:
* dom/WheelEvent.idl:
2006-09-29 David Harrison <harrison@apple.com>
Reviewed by John Sullivan.
This diff is collapsed.
......@@ -31,7 +31,6 @@
#import "CDATASection.h"
#import "CSSStyleSheet.h"
#import "Comment.h"
#import "DOMHTML.h"
#import "DOMImplementationFront.h"
#import "DOMInternal.h"
#import "DOMPrivate.h"
......@@ -61,91 +60,8 @@
#import "TreeWalker.h"
#import "WebScriptObjectPrivate.h"
#import "csshelper.h"
// From old DOMCore.h
#import "DOMObject.h"
#import "DOMException.h"
// Generated Objective-C Bindings
#import "DOMAttr.h"
#import "DOMCDATASection.h"
#import "DOMCharacterData.h"
#import "DOMComment.h"
#import "DOMDOMImplementation.h"
#import "DOMDocument.h"
#import "DOMDocumentFragment.h"
#import "DOMDocumentType.h"
#import "DOMElement.h"
#import "DOMEntity.h"
#import "DOMEntityReference.h"
#import "DOMNamedNodeMap.h"
#import "DOMNode.h"
#import "DOMNodeList.h"
#import "DOMNotation.h"
#import "DOMProcessingInstruction.h"
#import "DOMText.h"
// From old DOMHTML.h
#import "DOMHTMLAppletElement.h"
#import "DOMHTMLOptionElement.h"
// Generated Objective-C Bindings
#import "DOMHTMLAnchorElement.h"
#import "DOMHTMLAreaElement.h"
#import "DOMHTMLBRElement.h"
#import "DOMHTMLBaseElement.h"
#import "DOMHTMLBaseFontElement.h"
#import "DOMHTMLBodyElement.h"
#import "DOMHTMLButtonElement.h"
#import "DOMHTMLCollection.h"
#import "DOMHTMLDListElement.h"
#import "DOMHTMLDirectoryElement.h"
#import "DOMHTMLDivElement.h"
#import "DOMHTMLDocument.h"
#import "DOMHTMLElement.h"
#import "DOMHTMLFieldSetElement.h"
#import "DOMHTMLFontElement.h"
#import "DOMHTMLFormElement.h"
#import "DOMHTMLFrameElement.h"
#import "DOMHTMLFrameSetElement.h"
#import "DOMHTMLHRElement.h"
#import "DOMHTMLHeadElement.h"
#import "DOMHTMLHeadingElement.h"
#import "DOMHTMLHtmlElement.h"
#import "DOMHTMLIFrameElement.h"
#import "DOMHTMLImageElement.h"
#import "DOMHTMLInputElement.h"
#import "DOMHTMLIsIndexElement.h"
#import "DOMHTMLLIElement.h"
#import "DOMHTMLLabelElement.h"
#import "DOMHTMLLegendElement.h"
#import "DOMHTMLLinkElement.h"
#import "DOMHTMLMapElement.h"
#import "DOMHTMLMenuElement.h"
#import "DOMHTMLMetaElement.h"
#import "DOMHTMLModElement.h"
#import "DOMHTMLOListElement.h"
#import "DOMHTMLObjectElement.h"
#import "DOMHTMLOptGroupElement.h"
#import "DOMHTMLOptionsCollection.h"
#import "DOMHTMLParagraphElement.h"
#import "DOMHTMLParamElement.h"
#import "DOMHTMLPreElement.h"
#import "DOMHTMLQuoteElement.h"
#import "DOMHTMLScriptElement.h"
#import "DOMHTMLSelectElement.h"
#import "DOMHTMLStyleElement.h"
#import "DOMHTMLTableCaptionElement.h"
#import "DOMHTMLTableCellElement.h"
#import "DOMHTMLTableColElement.h"
#import "DOMHTMLTableElement.h"
#import "DOMHTMLTableRowElement.h"
#import "DOMHTMLTableSectionElement.h"
#import "DOMHTMLTextAreaElement.h"
#import "DOMHTMLTitleElement.h"
#import "DOMHTMLUListElement.h"
#import <objc/objc-class.h>
#import <wtf/HashMap.h>
using namespace WebCore::HTMLNames;
......
......@@ -58,6 +58,11 @@ namespace WebCore {
@implementation DOMStyleSheet (WebCoreInternal)
- (WebCore::StyleSheet *)_styleSheet
{
return reinterpret_cast<WebCore::StyleSheet*>(_internal);
}
- (id)_initWithStyleSheet:(WebCore::StyleSheet *)impl
{
[super _init];
......@@ -71,7 +76,7 @@ namespace WebCore {
{
if (!impl)
return nil;
id cachedInstance;
cachedInstance = getDOMWrapper(impl);
if (cachedInstance)
......@@ -87,26 +92,17 @@ namespace WebCore {
@end
//------------------------------------------------------------------------------------------
// DOMCSSStyleSheet
// DOMCSSRule
@implementation DOMCSSStyleSheet (WebCoreInternal)
@implementation DOMCSSRule (WebCoreInternal)
+ (DOMCSSStyleSheet *)_CSSStyleSheetWith:(WebCore::CSSStyleSheet *)impl
- (WebCore::CSSRule *)_CSSRule
{
return static_cast<DOMCSSStyleSheet*>([DOMStyleSheet _styleSheetWith:impl]);
return reinterpret_cast<WebCore::CSSRule*>(_internal);
}
@end
//------------------------------------------------------------------------------------------
// DOMCSSRule
@implementation DOMCSSRule (WebCoreInternal)
- (id)_initWithRule:(WebCore::CSSRule *)impl
- (id)_initWithCSSRule:(WebCore::CSSRule *)impl
{
[super _init];
_internal = reinterpret_cast<DOMObjectInternal*>(impl);
......@@ -119,7 +115,7 @@ namespace WebCore {
{
if (!impl)
return nil;
id cachedInstance;
cachedInstance = getDOMWrapper(impl);
if (cachedInstance)
......@@ -149,7 +145,7 @@ namespace WebCore {
wrapperClass = [DOMCSSPageRule class];
break;
}
return [[[wrapperClass alloc] _initWithRule:impl] autorelease];
return [[[wrapperClass alloc] _initWithCSSRule:impl] autorelease];
}
@end
......@@ -160,7 +156,12 @@ namespace WebCore {
@implementation DOMCSSValue (WebCoreInternal)
- (id)_initWithValue:(WebCore::CSSValue *)impl
- (WebCore::CSSValue *)_CSSValue
{
return reinterpret_cast<WebCore::CSSValue*>(_internal);
}
- (id)_initWithCSSValue:(WebCore::CSSValue *)impl
{
[super _init];
_internal = reinterpret_cast<DOMObjectInternal*>(impl);
......@@ -173,12 +174,12 @@ namespace WebCore {
{
if (!impl)
return nil;
id cachedInstance;
cachedInstance = getDOMWrapper(impl);
if (cachedInstance)
return [[cachedInstance retain] autorelease];
Class wrapperClass = nil;
switch (impl->cssValueType()) {
case DOM_CSS_INHERIT:
......@@ -194,31 +195,14 @@ namespace WebCore {
wrapperClass = [DOMCSSValue class];
break;
}
return [[[wrapperClass alloc] _initWithValue:impl] autorelease];
}
@end
//------------------------------------------------------------------------------------------
// DOMCSSPrimitiveValue
@implementation DOMCSSPrimitiveValue (WebCoreInternal)
- (WebCore::CSSPrimitiveValue *)_CSSPrimitiveValue
{
return static_cast<WebCore::CSSPrimitiveValue*>(reinterpret_cast<WebCore::CSSValue*>(_internal));
}
+ (DOMCSSPrimitiveValue *)_CSSPrimitiveValueWith:(WebCore::CSSValue *)impl
{
return static_cast<DOMCSSPrimitiveValue*>([DOMCSSValue _CSSValueWith:impl]);
return [[[wrapperClass alloc] _initWithCSSValue:impl] autorelease];
}
@end
//------------------------------------------------------------------------------------------
// DOMCSSStyleDeclaration CSS2 Properties
@implementation DOMCSSStyleDeclaration (DOMCSS2Properties)
......
......@@ -148,3 +148,17 @@
}
@end
@implementation DOMHTMLAppletElement (WebCoreInternal)
- (WebCore::HTMLAppletElement *)_HTMLAppletElement
{
return IMPL;
}
+ (DOMHTMLAppletElement *)_HTMLOptionElementWith:(WebCore::HTMLAppletElement *)impl
{
return static_cast<DOMHTMLAppletElement*>([DOMNode _nodeWith:impl]);
}
@end
......@@ -97,4 +97,19 @@
IMPL->setWidth(WebCore::String::number(newWidth));
}
@end
@implementation DOMHTMLEmbedElement (WebCoreInternal)
- (WebCore::HTMLEmbedElement *)_HTMLEmbedElement
{
return IMPL;
}
+ (DOMHTMLEmbedElement *)_HTMLEmbedElementWith:(WebCore::HTMLEmbedElement *)impl
{
return static_cast<DOMHTMLEmbedElement*>([DOMNode _nodeWith:impl]);
}
@end
......@@ -29,9 +29,7 @@
#import "Color.h"
#import "DOMAbstractView.h"
#import "DOMCSSPrimitiveValue.h"
#import "DOMCSSRule.h"
#import "DOMCSSStyleSheet.h"
#import "DOMCSSValue.h"
#import "DOMEvents.h"
#import "DOMHTMLOptionElement.h"
......@@ -47,8 +45,18 @@
// Auto-generated internal interfaces
#import "DOMAttrInternal.h"
#import "DOMCDATASectionInternal.h"
#import "DOMCSSCharsetRuleInternal.h"
#import "DOMCSSFontFaceRuleInternal.h"
#import "DOMCSSImportRuleInternal.h"
#import "DOMCSSMediaRuleInternal.h"
#import "DOMCSSPageRuleInternal.h"
#import "DOMCSSPrimitiveValueInternal.h"
#import "DOMCSSRuleListInternal.h"
#import "DOMCSSStyleDeclarationInternal.h"
#import "DOMCSSStyleRuleInternal.h"
#import "DOMCSSStyleSheetInternal.h"
#import "DOMCSSUnknownRuleInternal.h"
#import "DOMCSSValueListInternal.h"
#import "DOMCharacterDataInternal.h"
#import "DOMCommentInternal.h"
#import "DOMCounterInternal.h"
......@@ -113,14 +121,20 @@
#import "DOMHTMLTextAreaElementInternal.h"
#import "DOMHTMLTitleElementInternal.h"
#import "DOMHTMLUListElementInternal.h"
#import "DOMKeyboardEventInternal.h"
#import "DOMMediaListInternal.h"
#import "DOMMouseEventInternal.h"
#import "DOMMutationEventInternal.h"
#import "DOMNamedNodeMapInternal.h"
#import "DOMNodeListInternal.h"
#import "DOMNotationInternal.h"
#import "DOMOverflowEventInternal.h"
#import "DOMProcessingInstructionInternal.h"
#import "DOMRectInternal.h"
#import "DOMStyleSheetListInternal.h"
#import "DOMTextInternal.h"
#import "DOMUIEventInternal.h"
#import "DOMWheelEventInternal.h"
#ifdef SVG_SUPPORT
#import "DOMSVGAngleInternal.h"
......@@ -153,9 +167,7 @@
#endif // XPATH_SUPPORT
namespace WebCore {
class CSSPrimitiveValue;
class CSSRule;
class CSSStyleSheet;
class CSSValue;
class DOMWindow;
class Event;
......@@ -197,29 +209,23 @@ namespace WebCore {
@interface DOMCSSRule (WebCoreInternal)
+ (DOMCSSRule *)_CSSRuleWith:(WebCore::CSSRule *)impl;
- (WebCore::CSSRule *)_CSSRule;
@end
@interface DOMCSSValue (WebCoreInternal)
+ (DOMCSSValue *)_CSSValueWith:(WebCore::CSSValue *)impl;
@end
@interface DOMCSSPrimitiveValue (WebCoreInternal)
- (WebCore::CSSPrimitiveValue *)_CSSPrimitiveValue;
+ (DOMCSSPrimitiveValue *)_CSSPrimitiveValueWith:(WebCore::CSSValue *)impl;
- (WebCore::CSSValue *)_CSSValue;
@end
@interface DOMRGBColor (WebCoreInternal)
+ (DOMRGBColor *)_RGBColorWithRGB:(WebCore::RGBA32)value;
@end
@interface DOMCSSStyleSheet (WebCoreInternal)
+ (DOMCSSStyleSheet *)_CSSStyleSheetWith:(WebCore::CSSStyleSheet *)impl;
@end
// StyleSheets Internal Interfaces
@interface DOMStyleSheet (WebCoreInternal)
+ (DOMStyleSheet *)_styleSheetWith:(WebCore::StyleSheet *)impl;
- (WebCore::StyleSheet *)_styleSheet;
@end
// Events Internal Interfaces
......
......@@ -42,11 +42,10 @@ using namespace WebCore;
using KJS::ExecState;
using KJS::Interpreter;
using KJS::JSObject;
using KJS::Bindings::RootObject;
//------------------------------------------------------------------------------------------
// Wrapping khtml implementation objects
// Wrapping WebCore implementation objects
static HashMap<DOMObjectInternal*, NSObject*>* wrapperCache;
......
......@@ -312,6 +312,15 @@ sub GetParentAndProtocols
return ($parent, @protocols);
}
sub GetBaseClass
{
$parent = shift;
return $parent if $parent eq "Object" or $parent eq "CSSValue" or $parent eq "CSSRule" or $parent eq "StyleSheet";
return "Event" if $parent eq "Event" or $parent eq "UIEvent";
return "Node";
}
sub IsProtocolType
{
$type = shift;
......@@ -735,6 +744,7 @@ sub GenerateImplementation
my $implClassName = GetImplClassName($interfaceName);
my $parentImplClassName = GetParentImplClassName($dataNode);
my $implClassNameWithNamespace = "WebCore::" . $implClassName;
my $baseClass = GetBaseClass($parentImplClassName);
my $classHeaderName = GetClassHeaderName($className);
my $conditional = $dataNode->extendedAttributes->{"Conditional"};
......@@ -761,20 +771,11 @@ sub GenerateImplementation
@implContent = ();
# add implementation accessor
# FIXME: CSSStyleSheet should not need special casing like this.
if ($parentImplClassName eq "Object" or $interfaceName eq "CSSStyleSheet") {
if ($parentImplClassName eq "Object") {
push(@implContent, "#define IMPL reinterpret_cast<$implClassNameWithNamespace*>(_internal)\n\n");
} else {
my $internalBaseType = "WebCore::";
if ($parentImplClassName eq "CSSValue" or $parentImplClassName eq "CSSRule") {
$internalBaseType .= $parentImplClassName;
} elsif ($parentImplClassName eq "Event" or $parentImplClassName eq "UIEvent") {
$internalBaseType .= "Event";
} else {
$internalBaseType .= "Node";
}
push(@implContent, "#define IMPL static_cast<$implClassNameWithNamespace*>(reinterpret_cast<$internalBaseType*>(_internal))\n\n");
my $baseClassWithNamespace = "WebCore::$baseClass";
push(@implContent, "#define IMPL static_cast<$implClassNameWithNamespace*>(reinterpret_cast<$baseClassWithNamespace*>(_internal))\n\n");
}
# START implementation
......@@ -1168,10 +1169,13 @@ sub GenerateImplementation
push(@implContent, " return [[[self alloc] $initWithImplName:impl] autorelease];\n");
push(@implContent, "}\n\n");
} else {
my $internalBaseType = "DOM$baseClass";
my $internalBaseTypeMaker = GetObjCTypeMaker($baseClass);
# - (DOMFooBar)_FooBarWith:(WebCore::FooBar *)impl for implementation class FooBar
push(@implContent, "$typeMakerSig\n");
push(@implContent, "{\n");
push(@implContent, " return static_cast<$className*>([DOMNode _nodeWith:impl]);\n");
push(@implContent, " return static_cast<$className*>([$internalBaseType $internalBaseTypeMaker:impl]);\n");
push(@implContent, "}\n\n");
}
......
......@@ -21,7 +21,7 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSCharsetRule : CSSRule {
interface CSSCharsetRule : CSSRule {
// FIXME: the DOM spec says that this attribute
// should not be readonly. The correct declaration
......
......@@ -21,7 +21,7 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSFontFaceRule : CSSRule {
interface CSSFontFaceRule : CSSRule {
readonly attribute CSSStyleDeclaration style;
};
......
......@@ -21,7 +21,7 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSImportRule : CSSRule {
interface CSSImportRule : CSSRule {
readonly attribute DOMString href;
readonly attribute stylesheets::MediaList media;
readonly attribute CSSStyleSheet styleSheet;
......
......@@ -21,7 +21,7 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSMediaRule : CSSRule {
interface CSSMediaRule : CSSRule {
readonly attribute stylesheets::MediaList media;
readonly attribute CSSRuleList cssRules;
......
......@@ -21,7 +21,7 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSPageRule : CSSRule {
interface CSSPageRule : CSSRule {
// FIXME: DOM spec says that this can raise an
// exception on setting.
......
......@@ -19,7 +19,7 @@
module css {
interface [GenerateConstructor, ObjCNoInternal] CSSPrimitiveValue : CSSValue {
interface [GenerateConstructor] CSSPrimitiveValue : CSSValue {
// UnitTypes
const unsigned short CSS_UNKNOWN = 0;
......@@ -52,12 +52,12 @@ module css {
readonly attribute unsigned short primitiveType;
[OldStyleObjC] void setFloatValue(in unsigned short unitType,
in float floatValue)
raises(dom::DOMException);
in float floatValue)
raises(DOMException);
float getFloatValue(in unsigned short unitType);
[OldStyleObjC] void setStringValue(in unsigned short stringType,
in DOMString stringValue)
raises(dom::DOMException);
in DOMString stringValue)
raises(DOMException);
DOMString getStringValue();
Counter getCounterValue();
Rect getRectValue();
......
......@@ -21,7 +21,7 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSStyleRule : CSSRule {
interface CSSStyleRule : CSSRule {
// FIXME: DOM spec says that this can raise an
// exception on setting.
......
......@@ -21,16 +21,15 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSStyleSheet : stylesheets::StyleSheet {
interface CSSStyleSheet : stylesheets::StyleSheet {
readonly attribute CSSRule ownerRule;
readonly attribute CSSRuleList cssRules;
[OldStyleObjC] unsigned long insertRule(in DOMString rule,
in unsigned long index)
in unsigned long index)
raises(DOMException);
void deleteRule(in unsigned long index)
raises(DOMException);
};
}
......@@ -21,7 +21,7 @@
module css {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] CSSUnknownRule : CSSRule {
interface CSSUnknownRule : CSSRule {
};
}
......@@ -26,8 +26,9 @@
module css {
// Introduced in DOM Level 2:
interface [HasIndexGetter, ObjCNoInternal] CSSValueList : CSSValue {
interface [HasIndexGetter] CSSValueList : CSSValue {
readonly attribute unsigned long length;
CSSValue item(in unsigned long index);
};
}
......@@ -21,7 +21,7 @@
module events {
// Introduced in DOM Level 3:
interface [ObjCNoInternal] KeyboardEvent : UIEvent {
interface KeyboardEvent : UIEvent {
#if !defined(LANGUAGE_JAVASCRIPT)
// KeyLocationCode
......
......@@ -20,7 +20,7 @@
module events {
// Introduced in DOM Level 2:
interface [ObjCNoInternal] MouseEvent : UIEvent {
interface MouseEvent : UIEvent {
readonly attribute long screenX;
readonly attribute long screenY;
readonly attribute long clientX;
......