IT翻訳 Nobuyuki の仕事部屋

ボランティアでソフトウエアーローカライズのために翻訳をしている。

Mozilla DOM Hacking Guide: Introduction to XPCOM20

2006-01-29 21:13:41 | InDraft
昨日より続く。

原文:  青色表示
訳文:  黒色表示
注記/訂正: 赤色表示

Example

Let's take a look at a simple example, the HTML Anchor Element. First, let's illustrate the interface inheritance rules. If we look at nsIDOMHTMLAnchorElement (which contains the methods and properties defined by the W3C for this element), we can see that it inherits from another interface, nsIDOMHTMLElement:

interface nsIDOMHTMLAnchorElement : nsIDOMHTMLElement


サンプル

簡単なサンプルである HTML Anchor Element を見てみましょう。 最初に、インターフェイスの継承規則を解説しましょう。nsIDOMHTMLAnchorElement(HTML Anchor Element のために W3C によって定義されたメソッドやプロパティを備えていますが)を見れば、それが別のインターフェイスである nsIDOMHTMLElement を継承してるのが分かります:

interface nsIDOMHTMLAnchorElement : nsIDOMHTMLElement


This means that whatever class implements the nsIDOMHTMLAnchorElement interface will also have to implement the nsIDOMHTMLElement interface. If we look at nsIDOMHTMLElement, we can see that it inherits from nsIDOMElement, which inherits from nsIDOMNode, which inherits from nsISupports. Any class implementing nsIDOMHTMLAnchorElement will have to implement all the mentioned interfaces, because of inheritance. How the interfaces are implemented is described in paragraph 1.E.d.

すなわち、nsIDOMHTMLAnchorElement インターフェイスを実装するクラスはすべて nsIDOMHTMLElement インターフェイスも実装しなければならないということです。 nsIDOMHTMLElement を見ると、それが nsIDOMElement を継承しており、後者は nsIDOMNode を継承しており、さらに nsIDOMNode が、nsISupports を継承しているのが分かります。 nsIDOMHTMLAnchorElement は継承のために今述べたすべてのインターフェイスを実装しなければなりません。インターフェイスの実装方法は 1.E.d.の段落を参照してください。

The interface inheritance shows that the top-level interface is nsISupports. All interfaces have to inherit from nsISupports, directly or indirectly. It defines three methods, AddRef(), Release(), and QueryInterface(), which is explained in Section 1.B. nsISupports rests peacefully in xpcom/base/, unmodified since 1999. For more information about XPCOM interfaces and nsISupports, please read the Modularization techniques guide.

インターフェイスの継承によってトップレベルのインターフェイスが nsISupports であることが分かります。すべてのインターフェイスは直接的にまた間接的に nsISupports を継承しなければなりません。このインターフェイスは 1.B. の節で説明された AddRef()、 Release()、QueryInterface() という3 つのメソッドを定義します。 nsISupports は xpcom/base/ で 1999 年以降変更されることなく平和に息づいています。 XPCOM インターフェイスと nsISupports については、モジュール化の方法をご参照ください。


この長いチュートリアルもいよいよ明日草稿として完成します。本当に長かったなもし。(・_・、