What is XPCOM? XPCOM vs COM?

喜欢而已 提交于 2019-12-05 01:10:15

问题


I have trouble understanding XPCOM. How is it different from COM? What makes it cross platform?

Is it a framework with a set of libraries that you can use to do some jobs?

Also, does Component Object Model means every functionality is implemented in component so we can use it without knowing the detail implementation?

Can you someone help me understand this please? Thanks, Chan.


回答1:


I have trouble understanding XPCOM. How is it different from COM?

XPCOM is Mozilla's own, cross-platform (hence the XP bit) version of COM.

What makes it cross platform?

It is implemented in a library that has been ported to many platforms by contributors to the Mozilla open-source project. You can build it or download a binary for any platform that you wish and, in the extremely remote possibility that you want to use it on a platform that is not already supported, it should be straightforward to port it yourself.

Also, does Component Object Model means every functionality is implemented in component so we can use it without knowing the detail implementation?

Yes, spot on. The idea is for a language-independent framework that enables different components to communicate and interact, without requiring any special knowledge of the language that any particular component is implemented in. So javascript code can call C++ code, for instance.

This is achieved by components publishing well-defined interfaces, using a language called IDL (or, in XPCOM's case, XPIDL). These interfaces make use of well-defined types with mappings in each of the supporting languages. Every interface inherits from a common base interface, which provides standard methods for reference-counting and type-inference (called IUnknown in COM and nsISupports in XPCOM).

Can you someone help me understand this please?

In terms of online resources, there are dedicated areas on both the MSDN (for COM) and the MDC (for XPCOM). If you want to really understand the motivation for COM and why it is the way it is, I recommend picking up Don Box's Essential COM. And of course, if you have any specific questions that need answering, you can always come here to ask them. :)



来源:https://stackoverflow.com/questions/3957049/what-is-xpcom-xpcom-vs-com

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!