%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/virtualbox/sdk/bindings/xpcom/python/xpcom/
Upload File :
Create Path :
Current File : //lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyc

�
�SK\c@s@dZddlZddlZddlZddlZddlTdd7d��YZdd8d��YZd	d9d
��YZdd:d��YZ	d
d;d��YZ
dd<d��YZd�Zdd=d��YZ
id>e6d?e6d@e6dAe6dBe6dCe6dDe6dEe6dFe6dGe6dHe6dIe6dJe6dKe6dLe6dMe6dNe6dOe6dPe 6dQe!6dRe"6dSe#6dTe$6Z%d,�Z&e'd-kr<e(ej)�dkr�d.GHd/GHd0GHej)j*d1�ej)j*d2�ej)j*d3�ej)j*d1�nd4Z+xBej)dD]0Z,e,d5d6kr(e,dZ+qe&e,e+�qWndS(Us,
Program: xpt.py

Task: describe interfaces etc using XPCOM reflection.

Subtasks:
     output (nearly) exactly the same stuff as xpt_dump, for verification
     output Python source code that can be used as a template for an interface

Status: Works pretty well if you ask me :-)

Author:
   David Ascher did an original version that parsed XPT files
   directly.  Mark Hammond changed it to use the reflection interfaces,
   but kept most of the printing logic.


Revision:

  0.1: March 6, 2000
  0.2: April 2000 - Mark removed lots of Davids lovely parsing code in favour
                    of the new xpcom interfaces that provide this info.

  May 2000 - Moved into Perforce - track the log there!
  Early 2001 - Moved into the Mozilla CVS tree - track the log there!  

Todo:
  Fill out this todo list.

i����Ni(t*t	InterfacecBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCsstjj�}t|d�r0|j|�}n|j|�}||_d|_t|�|_	t
|�|_dS(Ntuppert(txpcomt_xpcomtXPTI_GetInterfaceInfoManagerthasattrtGetInfoForNamet
GetInfoForIIDtinterface_infot	namespacetMethodstmethodst	Constantst	constants(tselftiidtiimtitem((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt__init__Ms		cCst|j|�S(N(tgetattrR
(Rtattr((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt__getattr__YscCsly3|jj�}|dkr"dSt|j��SWn2tjk
rgtjrWdGHnttjj	�SXdS(NsJThe parent interface of IID '%s' can not be located - assuming nsISupports(
R
t	GetParenttNoneRtGetIIDRt	ExceptiontverboseRtIID_nsISupports(Rt
raw_parent((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR\s	cCs�g}g|jD]}|j�s|^q}x!|D]}|j|j��q5Wd}|j|�}d|j�|j�j|fS(Ns
s�class %s:
    _com_interfaces_ = xpcom.components.interfaces.%s
    # If this object needs to be registered, the following 2 are also needed.
    # _reg_clsid_ = "{a new clsid generated for this object}"
    # _reg_contractid_ = "The.Object.Name"
%s(R
t
IsNotXPCOMtappendtDescribe_PythontjointGetNameRtname(Rtmethod_reprstmR
t
method_joinertmethods_repr((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR!is(
cCs�dt|j��dd!d}d|jd|j�d|d}|j�}|dk	r�|d	|jd|j�d
}n|d}|j�r�d}nd
}|d|d
}|d}g|jD]}|j�s�|^q�}t	|�r'x3|D]}|d|j
�d
}qWn
|d}|d}|jrsx6|jD]}|d|j
�d
}qNWn
|d}|S(Nt(ii����t)s   - s::t s:
s      Parent: s
s
      Flags:
tTRUEtFALSEs         Scriptable: s      Methods:
s   s         No Methods
s      Constants:
s	         s         No Constants
(tstrRRR#RRtIsScriptableR
RtlentDescribeR(Rtiid_usetstparenttwordR&R
tc((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR1ws,!'&
	
(


	
(t__name__t
__module__RRRR!R1(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRLs
			
	RcBs#eZd�Zd�Zd�ZRS(cCsX||_ydg|j�|_Wn.tjk
rStjrGdGHng|_nXdS(Ns0** GetMethodCount failed?? - assuming no methods(R
RtGetMethodCounttitemsRRR(RR
((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR�s		cCs
t|j�S(N(R0R:(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt__len__�scCsR|j|}|dkrN|jj|�}t|||j�}|j|<n|S(N(R:RR
t
GetMethodInfotMethod(Rtindextrettmi((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt__getitem__�s

#(R7R8RR;RA(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR�s		R=cBsSeZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	c
Cs||_||_|\|_|_}|_g|_d}x7|D]/}|jjt||||��|d}qCWx�|jD]�}|j}t	|d�}	|	t
kr�|j�r�d|j|d_q�|	t
tgkr�|j�r�d|j|d_q�q�WdS(Niii(R
tmethod_indextflagsR$tresult_desctparamsR t	Parametert	type_desctXPT_TDP_TAGtT_ARRAYtIsInthidden_indicatortT_PSTRING_SIZE_IStT_PWSTRING_SIZE_IS(
Rtmethod_infoRBR
tparam_descstpitpdtpttdttag((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR�s			
	cCs|jt@S(N(RCt
XPT_MD_GETTER(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsGetter�scCs|jt@S(N(RCt
XPT_MD_SETTER(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsSetter�scCs|jt@S(N(RCtXPT_MD_NOTXPCOM(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR�scCs|jt@S(N(RCtXPT_MD_CTOR(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt
IsConstructor�scCs|jt@S(N(RCt
XPT_MD_HIDDEN(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsHidden�scCsr|jdkrdS|j}|j�r8d|f}n"|j�rTd|f}n|}dg}g}g}d}x�|jD]�}|j�\}}	}
}|dk	r�|j|�n|	dk	r�|j|	�n|
dk	r�|j|
�n|dk	r|}qqWd}d}
}
|r6||j|�}
n|rR||j|�}
nd|d	j|�||
|
fS(
NiRsget_%ssset_%sRsResult: void - Nones
        # s/    def %s( %s ):
        # %s%s%s
        passs, (	RBR$RVRXRER!RR R"(Rt	base_nameR$tparam_declstin_commentst	out_descstresult_commentRRtin_desctin_desc_commentstout_desctthis_result_commenttjoinert
in_comment((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR!�s:		

cCsLd}|j�rd}nd}|j�r6d}nd}|j�rQd}nd}|j�rld}nd}|j�r�d}nd}d�}tjtt||j	��d	�}t
|jd
d�}	|	j
�}
tj|
d�}|dkr|
| |
|td�}
n|||||d|
d|jd
|dS(NRtGR+tStHtNtCcSs
|j�S(N(R1(ta((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytdesc�ss, isretval i����R)s);(RVRXR]RR[tstringR"tlisttmapREt
TypeDescriberRDRR1tfindR0R$(RR3RiRjRkRlRmRotmethod_desctresult_typetreturn_descti((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR1�s0						$N(R7R8RRRVRXRR[R]R!R1(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR=�s						!RFcBseeZd
d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�ZRS(cCs:|\|_|_d|_||_||_||_dS(Ni(tparam_flagsRGRKtparam_indexRBR
(Rt
param_descRzRBR
((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRs
			cCsd|jS(Nsc<param %(param_index)d (method %(method_index)d) - flags = 0x%(param_flags)x, type = %(type_desc)s>(t__dict__(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt__repr__
scCs
t|j�S(N(tXPT_PD_IS_INRy(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRJscCs
t|j�S(N(t
XPT_PD_IS_OUTRy(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsOutscCs|j�o|j�S(N(RJR�(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsInOutscCs
t|j�S(N(tXPT_PD_IS_RETVALRy(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsRetvalscCs
t|j�S(N(tXPT_PD_IS_SHAREDRy(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsSharedscCs
t|j�S(N(tXPT_PD_IS_DIPPERRy(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsDippersc	Csd|jf}|jr0dd|fddfSt|jd|�}d}}}}|j�}|j�r�|j�r�|}d}|j�r�d}nd|||f}nD|j�s�|j�r�|j	�r�d|f}q�d|f}n||||fS(	Nsparam%ds%s is a hidden parameteriRtOutsIn%s: %s: %ss
Result: %ssOut: %s(
RzRKRRsRGR1RJR�R�R�(	RR$tttdeclRhtout_commentRbRGtextra((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR!s"		cCs�g}|j�r"|jd�n8|j�r>|jd�n|j�rZ|jd�n|j�rv|jd�n|j�r�|jd�n|j�r�|jd�nt|jd|�}|j	�}|j|�t
j|�S(Ntinouttintouttdippertretvaltsharedi(R�R RJR�R�R�R�RsRGR1RpR"(RtpartsR�ttype_str((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR12s"
N(
R7R8RRR}RJR�R�R�R�R�R!R1(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRFs								RcBs#eZd�Zd�Zd�ZRS(cCsX||_ydg|j�|_Wn.tjk
rStjrGdGHng|_nXdS(Ns4** GetConstantCount failed?? - assuming no constants(R
RtGetConstantCountR:RRR(RR
((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyREs		cCs
t|j�S(N(R0R:(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR;MscCsI|j|}|dkrE|jj|�}t|�}|j|<n|S(N(R:RR
tGetConstanttConstant(RR>R?tci((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRAOs

(R7R8RR;RA(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRDs		R�cBs eZd�Zd�ZeZRS(cCs|\|_|_|_dS(N(R$ttypetvalue(RR�((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRWscCs6t|jd�j�d|jdt|j�dS(NR+s = t;(RsR�RR1R$R.R�(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR1Zs(R7R8RR1t__str__(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR�Vs		cCs�|jdt@}|tkr�|j}y|j|j|j�}Wn tjk
rdtj	j
}nX|jdddt|�fS|tkr�|j}|j
|j|jd�}|jd |d S|jS(Niii����(RGtXPT_TDP_TAGMASKtT_INTERFACER
tGetIIDForParamRBRzRRRRR.RItGetTypeForParam(tparamRTti_infoRt
array_desc((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytMakeReprForInvoke_s		RscBsGeZd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs(||_t|j�|_||_dS(N(t
type_flagsRHRTR�(RR�R�((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRqs	cCs
t|j�S(N(tXPT_TDP_IS_POINTERR�(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt	IsPointeruscCs
t|j�S(N(tXPT_TDP_IS_UNIQUE_POINTERR�(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsUniquePointerwscCs
t|j�S(N(tXPT_TDP_IS_REFERENCER�(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytIsReferenceyscCs
|jfS(N(R�(R((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytrepr_for_invoke{scCs�|j�}tj|j�}|dkr3d}n|j�ret|�dkrY|dS|ddS|j�r�t|�dkr�|dS|ddS|dS(Ntunknowniis &is *(sunknown(R�t
type_info_maptgetRTRR�R0(Rtis_ptrtdata((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR#}s	cCs/|jtkr�|jdks0|jjdkr9d}nF|jj}|j|jj|jjd�}t|dd�j	�}|j
�d|dS|jtkr%|jdks�|jjdkr�dS|jj}|jj}|jj}y|j||�}|j
SWq%tjk
r!dSXn|j
�S(NRiit[t]tnsISomething(RTRIR�RR
R�RBRzRsR1R#R�R�R$RR(RRGR�t	type_codetm_indextp_indexR((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyR1�s&!	!!(	R7R8RR�R�R�R�R#R1(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyRsps						tint8tint16tint32tint64tuint8tuint16tuint32tuint64tfloattdoubletbooleantchartwchar_ttwstringtvoidtreservedsnsIID *snsIID &t	DOMStringRps
InterfaceIs *tArraytstring_st	wstring_scCset|�}d}|dkr'd}n|dk	rJ|d|j�}nt||�}|�GHdS(NR1txptinfot_(RRt
capitalizeR(Rtmodet	interfacetdescriber_namet	describer((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pytdump_interface�s	t__main__s,Usage: xpt.py [-xptinfo] interface_name, ...s4  -info: Dump in a style similar to the xptdump tools(Dumping nsISupports and nsIInterfaceInfotnsIInterfaceInfos-xptinfotnsISupportstPythonit-((((((((R�(R�(R�(R�(R�(R�(R�(R�(sfloat(R�(R�(schar(R�R�(svoid(R�snsIID *snsIID &(R�(R�sstring(R�R�(R�R(R�s
InterfaceIs *(R�R�(R�R�(R�R�(-t__doc__RptsysRtxpcom._xpcomtxpcom_constsRRR=RFRR�R�RstT_I8tT_I16tT_I32tT_I64tT_U8tT_U16tT_U32tT_U64tT_FLOATtT_DOUBLEtT_BOOLtT_CHARtT_WCHARtT_VOIDtT_IIDtT_DOMSTRINGt
T_CHAR_STRtT_WCHAR_STRR�tT_INTERFACE_ISRIRLRMR�R�R7R0targvR R�Rx(((s:/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/xpt.pyt<module>Dsf
H`>		5
		


Zerion Mini Shell 1.0