Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 XPCOM 开发的菜鸟。在用 C++ 编写 XPCOM 代码的过程中,我需要创建额外的类以在我的 XPCOM 组件中使用。我需要为这些类创建另一个 XPCOM 组件吗?我不能只在头文件中添加新类吗?
一点都不。XPCOM 描述了外部接口。“内部”类由您的 C++ 编译器编译。那个编译器不会向你告发,所以 XPCOM 永远不会知道它们的存在。
为了您自己的理智,将这些内部类保留在自己的标题中确实很有意义。
您只需为希望从外部源(例如 JavaScript)可发现和可控制的类创建接口。如果某个类仅用于实现某个其他接口的功能,那么您不需要(也不应该)为该类定义 XPCOM 接口。