IT翻訳 Nobuyuki の仕事部屋

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

Mozilla DOM Hacking Guide: Introduction to XPCOM19

2006-01-28 21:33:00 | InDraft
今日車がパンクした。いつものように家内を乗せてスーバーまで買い物に行こうと車と発進させたが、どうも様子がおかしい。車台の下で何か音がする。静かに走らせると特に問題がないようである。しかし、速度を上げると車の下でなにか引きずっているような音がする。家内が家に戻ろうかと言ったが、交通の多い道でUターンするのもままならない。停車するスペースもない。そのまま、ドラッグストアの駐車場まで走らせた。停車して車を点検してみると、一見してパンクと分かった。左前輪のタイヤが潰れていた。

ジャッキをトランクルームから取り出してタイヤの交換作業に入る。車体をジャッキアップするのに苦労したものの、なんとか応急用のタイヤと交換できた。所要時間10分とかかっていない。家内の買い物時間のほうがはるかに長かった。これも、自分でタイヤのローテーションを5千キロごとに行っていたお陰である。手馴れたものさ。(^_^ゞ

買い物を済ませて帰宅した後、近所のガソリンスタンドまでパンクの修理に行った。ところが、タイヤのダメージが大きいので、交換を勧められた。ホイールからタイヤを外して、その内側の状態をチェックしてもらうと、損傷が大きくタイヤの機密性が完全に確保できないと言う。最悪、高速走行時にバーストの可能性があるという。そういわれて、パンク修理で済ませてくれと言うのはかなり勇気の要ることだったろう。結局1万円強の臨時出費となった。(/_・、)
----------------------------------------------------------------------------
原文:  青色表示
訳文:  黒色表示
注記/訂正: 赤色表示

Theory

Now that we know what interface inheritance means, we can look at more generic cases. We will first see this in a very theoretical way, and then we will use the nsHTMLAnchorElement example to illustrate the discussion.


理論

インターフェイスの継承がどういうことであるか分かったので、もっと一般的なケースを調べてみましょう。最初にごく理論的に見て、次に nsHTMLAnchorElement のサンプルを使って議論を解説します。


Let's assume we have a DOM object Foo, implemented by the real class nsFoo. We also have another real class, nsBar, as well as three interfaces, nsIFoo1, nsIFoo2, and nsIFoo3. The situation is the following:

nsBar <- nsIFoo1
|
V
nsFoo <- nsIFoo2 <- nsIFoo3


実際のクラス nsFoo によって実装されている DOM オブジェクト Foo があると仮定しましょう。nsIFoo1、nsIFoo2、nsIFoo3 の 3 つのインターフェイス に加えて別の実際のクラス nsBar もあるとしましょう。この状況は以下のようになります:

nsBar <- nsIFoo1
|
V
nsFoo <- nsIFoo2 <- nsIFoo3


In this situation, the nsIFoo2 interface inherits from the nsIFoo3 interface, as described above. nsFoo implements nsIFoo2, and thus also nsIFoo3, and nsBar implements nsIFoo1. The real class nsFoo inherits from the other real class nsBar. The rules describing inheritance are the following:

この状況で上記に記されているように nsIFoo2 インターフェイスは nsIFoo3 インターフェイスを継承します。 nsFoo は nsIFoo2 を実装しその結果 nsIFoo3 も実装します。nsBar は nsIFoo1 を実装します。実際のクラス nsFoo は別の実際のクラス nsBar を継承します。継承を説明する規則は以下のようになっています:

* nsFoo implements nsIFoo1 automatically, because it inherits from a class that already implements nsIFoo1.
* nsBar has to implement nsIFoo1.
* nsFoo has to implement nsIFoo2 and nsIFoo3, unless they are forwarded to nsBar. Interface forwarding is described in Section 1.E.d.


* nsFoo は自動的に nsIFoo1 を実装します。というのは、すでに nsIFoo1 を実装しているクラスを継承しているからです。
* nsBar は nsIFoo1 を実装しなければ なりません。
* nsFoo は、nsIFoo2 と nsIFoo3 が nsBar へ転送 されない限りは、nsIFoo2 と nsIFoo3 を実装しなければなりません。インターフェイスの転送については 1.E.d の節で解説されています。


These rules are pretty simple, and are widely used in the DOM code. It gets trickier with a lot of classes and interfaces, but you can always reduce the problem to the above situation.

これらの規則はとても簡単であり DOM のコードで広く使われています。クラスやインターフェイスが増えるにつれてコードはより複雑になりますが、上記の方法を使えば必ず問題を低減することが出来ます。

さて、未熟な翻訳を衆目に晒して早19日、もう1、2日で草稿アップの状態までもって行けそうだ。See you! (^-^)/~~~~