IT翻訳 Nobuyuki の仕事部屋

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

Mozilla DOM Hacking Guide: Introduction to XPCOM 2

2006-01-10 21:51:58 | InDraft
さて、タイトルの文書の草稿作成のため和訳をすすめています。
まだ粗稿の段階何なので、文章がこなれていませんが。(・_・;

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


Introduction to XPCOM for the DOM
A. Introduction to the introduction
The DOM makes extensive use of XPCOM. In fact, to do anything with the DOM implementation you need XPCOM. You do not, however, need to know all the hairy details, if you just intend to read the code or to work with the existing framework. The numerous macros and facilities brought by the DOM, as well as nsCOMPtr's, make our life much easier. In this chapter I will attempt to cover the most widespread use of XPCOM in the DOM, avoiding the details as much as possible. I will introduce nsCOMPtr's, interfaces, reference counting, and the nsISupports interface. A tutorial about how to add a new interface is also provided, and eventually, a more detailed discussion of class inheritance in C++.



DOM のための XPCOM 入門
A. 入門への手引き
DOM は XPCOM を広く使います。事実、 DOM を実装して使用するには XPCOM が必要になります。しかし、コードを読んだり既存のフレームワークに何かするだけならば、詳細まで知る必要はありません。nsCOMPtr も含めて DOM が提供する数多くのマクロや機能は私たちの活動をとても楽にしてくれます。この章では、できるだで枝葉末節の解説を避けて DOM でごく共通に使われている XPCOM の範囲をカバーしたいと思います。そして nsCOMPtr のインターフェイス、参照カウント、 nsISupports インターフェイスを解説します。新インターフェイスの追加方法のチュートリアルや、最後に C++ におけるクラスの継承についての詳細の議論についても解説します。


B Interfaces

Object-oriented programming is based on the used of inheritance between classes. Furthermore, a class can be de declared to be "abstract" if it declares some methods but does not implement them entirely. Pushing this concept to its maximum, a class can be "purely virtual" if it declares methods without implementing any of them. Such a class is called an interface. The goal of interfaces is to have a single ... interface to a set of methods that manipulate an object (often represented by a class), without worrying about the details of the implementation. If you know a class implements an interface, just use the methods in the interface, and you don't have to care if the implementation of the interface (the concrete class) changes. XPCOM pushes this concept to the extreme. Pure virtual methods are declared with the following syntax:

virtual nsresult FunctionFoo() = 0;


B インターフェイス

オブジェクト指向のプログラミングは クラス間の継承の使用を基本にしています。さらに、メソッドを宣言して完全には実装しない限り、クラスは”抽象クラス”として宣言することができます。この考えを最大限に発揮することでクラスは、メソッドを実装せずに宣言するだけで、”完全に抽象的//→”完全な抽象クラス”のほうがいい?”になります。そのようなクラスはインターフェイスと呼ばれます。インターフェイスの目的は、ひとつのインターフェイスに・・・実装の詳細内容を心配することなく、(普通クラスとして表される)オブジェクトを操作する一セットのメソッドを持たせることです。もしクラスがインターフェイスを実装することをご存知ならば、その時インターフェイスにメソッドを使ってください。すると、インターフェイスの実装(具体的なクラス)が変わるかどうか気にする必要はありません。XPCOM はこの考えを究極まで推進しています。純粋な抽象メソッドが以下の構文で宣言されます:

virtual nsresult FunctionFoo() = 0;


(^-^)/~~~~