VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/doc/architecture.html@ 95970

Last change on this file since 95970 was 11746, checked in by vboxsync, 16 years ago

export python lib to OSE

  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
1<html>
2<!-- ***** BEGIN LICENSE BLOCK *****
3 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 -
5 - The contents of this file are subject to the Mozilla Public License Version
6 - 1.1 (the "License"); you may not use this file except in compliance with
7 - the License. You may obtain a copy of the License at
8 - http://www.mozilla.org/MPL/
9 -
10 - Software distributed under the License is distributed on an "AS IS" basis,
11 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 - for the specific language governing rights and limitations under the
13 - License.
14 -
15 - The Original Code is PyXPCOM.
16 -
17 - The Initial Developer of the Original Code is
18 - ActiveState Tool Corporation.
19 - Portions created by the Initial Developer are Copyright (C) 2000-2001
20 - the Initial Developer. All Rights Reserved.
21 -
22 - Contributor(s):
23 -
24 - Alternatively, the contents of this file may be used under the terms of
25 - either the GNU General Public License Version 2 or later (the "GPL"), or
26 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 - in which case the provisions of the GPL or the LGPL are applicable instead
28 - of those above. If you wish to allow use of your version of this file only
29 - under the terms of either the GPL or the LGPL, and not to allow others to
30 - use your version of this file under the terms of the MPL, indicate your
31 - decision by deleting the provisions above and replace them with the notice
32 - and other provisions required by the LGPL or the GPL. If you do not delete
33 - the provisions above, a recipient may use your version of this file under
34 - the terms of any one of the MPL, the GPL or the LGPL.
35 -
36 - ***** END LICENSE BLOCK ***** -->
37
38<head>
39<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
40<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
41<meta name="ProgId" content="FrontPage.Editor.Document">
42<title>Architecture</title>
43</head>
44
45<body>
46
47<h1>Python XPCOM Package Architecture</h1>
48<h2><a name="Architecture">Architecture</a></h2>
49<p>Much of the design for the Python XPCOM Package has been borrowed from the Python MS-COM
50extensions in <i>win32com</i>. Most of the major limitations and drawbacks in the <i>win32com</i>
51design have been addressed, mainly &quot;auto-wrapping&quot; of
52interface objects, which is not supported by <i>win32com</i>.</p>
53<p>Like <i>win32com</i>, this architecture includes the concept of <i>client COM</i> and <i>server
54COM.</i> </p>
55<p>Client COM:</p>
56<ul>
57 <li>calls other interfaces</li>
58 <li>is supported by <i>PyInterfaces</i> implemented in C++, which assists
59in making the COM calls</li>
60 <li>is supported by <i>PyGateways</i>, which assists in receiving
61external COM calls and dispatching them to the correct Python object</li>
62 <li> is supported in the <i>xpcom/client</i> package</li>
63</ul>
64<p>Server COM:</p>
65<ul>
66 <li>implements interfaces for use by other XPCOM applications or components</li>
67 <li> is
68supported in the <i>xpcom/server</i> package</li>
69</ul>
70<p>The XPConnect framework is very powerful, and far exceeds what COM's <i>
71IDispatch</i> can offer.&nbsp; Thus, we are able to get by with far fewer interfaces
72supported in the C++ level, and defer most things to the Python code that uses
73XPConnect.&nbsp; As a result, the requirement for a huge number of interfaces to
74exist in the <i>.pyd</i> does not exist.&nbsp; There are, however, a number of
75interfaces that do require native C++ support: these are interfaces
76required to &quot;boot&quot; the XPConnect support (i.e., the interfaces that are
77used to get information about interfaces), and also two gateways that need to
78work without interface information available. This last requirement is
79due to the XPCOM shutdown-ordering - it may be a bug, but is not an unreasonable
80amount of code anyway.</p>
81<p><b>Auto-wrapping</b> of COM objects is supported by both client COM and
82server COM.&nbsp;For client COM, auto-wrapping means that the
83Python programmer always sees Python &quot;component&quot; objects, rather than
84raw C++ interface objects; to the user, it all appears to &quot;just
85work&quot;.&nbsp; This is a major source of frustration in the <i>win32com</i>
86framework.</p>
87<p>For server COM, auto-wrapping means that you can
88pass Python instances wherever a COM object is expected. If the Python
89instance supports COM interfaces, by virtue of having a <i>_com_interfaces_</i>
90attribute that lists the interface requested, it will be automatically wrapped
91in the correct COM object.&nbsp;</p>
92<p><b>Error Handling:</b> The C++ framework has good error handling support,
93and uses the XPCOM console service to log debug messages, Python exceptions and
94tracebacks.&nbsp; <i>win32com</i> does not have good exception/traceback support
95at the C++ level, mainly because COM does not define a service like
96the console where debug messages can go.&nbsp; This does mean that in Mozilla
97release builds, these debug messages are likely to be lost, but the <i>--console</i>
98command line option to a release Mozilla will get them back.&nbsp; Therefore,
99the other error-support utilities, such as the error callbacks made on the
100policy object, may be used.</p>
101<p><b>Component Loader, Modules and Factories:</b>&nbsp; XPCOM has the concept
102of a component loader - a module used to load all components of a
103particular type.&nbsp; For example, the <i>moz.jsloader.1</i> component loads all
104the JavaScript components.&nbsp;Similarly, the <i>moz.pyloader.1</i>
105component loads all Python components.&nbsp; However, unlike
106JavaScript, the Python component loader is actually implemented in Python
107itself!&nbsp;Since the Python component loader can not be used to load
108itself, this component has some special code, <i>pyloader.dll,</i> to boot-strap itself.</p>
109<p>This means is that all XPCOM components, including the Python loader itself and all
110XPCOM module and factory interfaces, are implemented in
111Python.&nbsp;<b>There are no components or interfaces implemented purely in C++
112in this entire package!</b></p>
113
114</body>
115
116</html>
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette