Main Page   Compound List   File List   Compound Members   File Members  

TclXPCOMPrivate.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * The contents of this file are subject to the Mozilla Public License Version
00004  * 1.1 (the "License"); you may not use this file except in compliance with
00005  * the License. You may obtain a copy of the License at
00006  * http://www.mozilla.org/MPL/
00007  *
00008  * Software distributed under the License is distributed on an "AS IS" basis,
00009  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00010  * for the specific language governing rights and limitations under the
00011  * License.
00012  *
00013  * The Original Code is TclXPCOM.
00014  * 
00015  * The Initial Developer of the Original Code is Mark Follett.
00016  * Portions created by Mark Follett are Copyright (C) 2001-2002
00017  * Mark Follett.  All Rights Reserved.
00018  * 
00019  * Contributor(s):
00020  *     Mark Follett <mef123@myrealbox.com> (Original Author)
00021  *
00022  * Alternatively, the contents of this file may be used under the terms of
00023  * either the GNU General Public License Version 2 or later (the "GPL"), or
00024  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00025  * in which case the provisions of the GPL or the LGPL are applicable instead
00026  * of those above. If you wish to allow use of your version of this file only
00027  * under the terms of either the GPL or the LGPL, and not to allow others to
00028  * use your version of this file under the terms of the MPL, indicate your
00029  * decision by deleting the provisions above and replace them with the notice
00030  * and other provisions required by the GPL or the LGPL. If you do not delete
00031  * the provisions above, a recipient may use your version of this file under
00032  * the terms of any one of the MPL, the GPL or the LGPL.
00033  */
00034 
00035 #ifndef __TCLXPCOMPRIVATE_H__
00036 #define __TCLXPCOMPRIVATE_H__
00037 
00038 #ifndef MOZILLA_STRICT_API
00039 #define MOZILLA_STRICT_API
00040 #endif
00041 
00042 // Tcl_GetIndexFromObj requires no const in 8.3 and const in 8.4
00043 #define USE_NON_CONST
00044 
00045 #include "tclxpcom.h"
00046 #include "xptcall.h"
00047 #include "nsISupports.h"
00048 #include "nsISupportsUtils.h"
00049 #include "nsIClassInfo.h"
00050 #include "nsIInterfaceInfo.h"
00051 #include "nsIServiceManager.h"
00052 #include "nsIInterfaceInfoManager.h"
00053 #include "nsIComponentRegistrar.h"
00054 #include "nsIMemory.h"
00055 #include "nsWeakReference.h"
00056 
00057 extern Tcl_Encoding ascii_enc;
00058 
00059 
00060 #ifdef TCL_WIDE_INT_TYPE
00061 #   define USE_TCL_WIDEINT
00062 #endif
00063 
00064 
00065 #ifdef USE_TCL_WIDEINT
00066 
00067 typedef Tcl_WideInt TclXPCOM_WideInt;
00068 #define TclXPCOM_NewWideIntObj     Tcl_NewWideIntObj
00069 #define TclXPCOM_GetWideIntFromObj Tcl_GetWideIntFromObj
00070 
00071 #else /* !defined(USE_TCL_WIDEINT) */
00072 
00073 typedef PRInt64 TclXPCOM_WideInt;
00074 Tcl_Obj *TclXPCOM_NewWideIntObj     (TclXPCOM_WideInt wideint);
00075 int      TclXPCOM_GetWideIntFromObj (Tcl_Interp *interp, Tcl_Obj *objPtr, TclXPCOM_WideInt *wideint);
00076 
00077 #endif
00078 
00079 
00080 extern nsIServiceManager       *servmanager;
00081 extern nsIInterfaceInfoManager *manager;
00082 extern nsIComponentRegistrar   *registrar;
00083 extern nsIMemory               *memmgr;
00084 
00085 extern nsIID nsisupports_iid;
00086 extern nsIID nsiclassinfo_iid;
00087 extern nsIID nsiservicemanager_iid;
00088 
00089 extern nsIInterfaceInfo *nsisupports_info;
00090 extern nsIInterfaceInfo *nsiservicemanager_info;
00091 extern nsIInterfaceInfo *nsiclassinfo_info;
00092 
00093 extern Tcl_ObjType ISupportsType;
00094 
00098 #define PARAM_IS_SKIPPED         0x0100
00099 #define PARAM_IS_RETVAL          0x0200
00100 #define PARAM_IS_SKIPPED_IN      0x0400
00101 #define PARAM_IS_SKIPPED_OUT     0x0800
00102 #define PARAM_IS_SHARED_IN       0x1000
00103 #define PARAM_IS_SHARED_OUT      0x2000
00104 #define PARAM_INDEX_MASK         0x00ff
00105 
00106 
00110 typedef struct MethodInfo
00111 {
00112     PRUint8  paramcount;             
00113     PRUint8  tclparamcount;          
00114     PRUint16 *tclparams;             
00115     nsXPTParamInfo *paraminfos;      
00116 } MethodInfo;
00117 
00118 
00122 typedef struct IdentifierInfo_
00123 {
00124     char *name;
00125     PRUint8 type;
00126     union
00127     {
00128         PRUint16 methodindex;
00129         struct
00130         {
00131             PRUint16 getterindex;
00132             PRUint16 setterindex;
00133         } attributeindices;
00134     } indices;
00135 } IdentifierInfo;
00136 
00137 
00141 typedef struct InterfaceInfo
00142 {
00143 //  int timestamp;                  ///< time of last access
00144     nsIInterfaceInfo *info;
00145     nsIInterfaceInfo *parentinfo;
00146 //  const nsIID *iid;
00147 
00148     PRUint16 imethodcount;
00149     PRUint16 methodcount;           
00150     PRUint16 attributecount;        
00151     PRUint16 constantcount;         
00152 
00153     PRUint16 baseimethodindex;
00154     PRUint16 basemethodindex;
00155     PRUint16 baseattributeindex;
00156     PRUint16 baseconstantindex;
00157 
00158     MethodInfo     *imethods;       
00159     IdentifierInfo *methods;        
00160     IdentifierInfo *attributes;     
00161     char          **constantnames;  
00162     Tcl_Obj       **constantvalues; 
00163 } InterfaceInfo;
00164 
00165 
00169 typedef struct ClassInfoSignature
00170 {
00171     int                infocount;   
00172     nsIInterfaceInfo **infolist;    
00173 } ClassInfoSignature;
00174 
00175 
00179 typedef struct ClassIdentifierInfo
00180 {
00181     IdentifierInfo idinfo;
00182     nsIInterfaceInfo *info;         
00183     PRUint8 qualified;              
00184 } ClassIdentifierInfo;
00185 
00186 
00190 typedef struct ClassInfo_
00191 {
00192 //  int timestamp;                  ///< time of last access
00193     ClassInfoSignature  signature;  
00194     PRUint16            methodcount;
00195     PRUint16         attributecount;
00196     ClassIdentifierInfo *methods;   
00197     ClassIdentifierInfo *attributes;
00198 } ClassInfo;
00199 
00200 
00204 typedef struct InterfaceRef
00205 {
00206     int refcount;                
00207     Tcl_HashTable    refhash;    
00208     nsIClassInfo     *cinforef;  
00209     ClassInfo        *cinfo;     
00210     int              cisupported;
00211 } InterfaceRef;
00212 
00213 
00217 class TclXPCOMStub : public nsXPTCStubBase,
00218                      public nsSupportsWeakReference
00219 {
00220     public:
00221 
00222     nsIInterfaceInfo         *info;     
00223     struct TclXPCOMComponent *component;
00224     Tcl_Obj                 **bindings; 
00225 
00226     TclXPCOMStub  (nsIInterfaceInfo *interfaceinfo);
00227     ~TclXPCOMStub (void);
00228 
00229     NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
00230     NS_IMETHOD_(nsrefcnt) AddRef(void);
00231     NS_IMETHOD_(nsrefcnt) Release(void);
00232     NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
00233     NS_IMETHOD CallMethod(PRUint16 methodIndex, const nsXPTMethodInfo *info, nsXPTCMiniVariant *params);
00234 
00235     void     SetBinding   (PRUint16 methodindex, Tcl_Obj *script);
00236     void     UnsetBinding (PRUint16 methodindex);
00237     Tcl_Obj *GetBinding   (PRUint16 methodindex);
00238 };
00239 
00240 
00244 typedef struct TclXPCOMComponent
00245 {
00246     nsrefcnt       refcount;  
00247     Tcl_Interp    *interp;    
00248     Tcl_ThreadId   thread;    
00249     ClassInfo     *cinfo;     
00250     TclXPCOMStub **stubs;     
00251     Tcl_Obj       *destructor;
00252     int            nesting;   
00253     int            nestlevel; 
00254 } TclXPCOMComponent;
00255 
00256 
00257 void TclXPCOM_InitInterfaceRef  (void);
00258 void TclXPCOM_InitClassInfo     (void);
00259 void TclXPCOM_InitInterfaceInfo (void);
00260 void TclXPCOM_RegisterObjTypes  (void);
00261 
00262 int           AddRefInterface    (nsISupports *isupports, nsIInterfaceInfo *interfaceinfo, Tcl_HashEntry **entry);
00263 int           ReleaseInterface   (nsISupports *isupports);
00264 int           QueryInterfaceIRef (Tcl_Interp *interp, InterfaceRef *iref, nsIInterfaceInfo *queryinfo, nsISupports **result);
00265 int           GetMethodFromIRef  (Tcl_Interp *interp, nsISupports *isupports, nsIInterfaceInfo *info, Tcl_Obj *identifier, int type, nsIInterfaceInfo **interfaceinfo, PRUint16 *methodindex);
00266 InterfaceRef *GetInterfaceRef    (nsISupports *isupports);
00267 
00268 TclXPCOMComponent *NewTclXPCOMComponent  (Tcl_Interp *interp, Tcl_ThreadId thread, ClassInfo *cinfo);
00269 void               FreeTclXPCOMComponent (TclXPCOMComponent *component);
00270 int                BindScript            (Tcl_Interp *interp, TclXPCOMComponent *component, Tcl_Obj *identifier, Tcl_Obj *script, int flags);
00271 
00272 InterfaceInfo *GetInterfaceInfo (nsIInterfaceInfo *interfaceinfo);
00273 MethodInfo    *GetMethodInfo    (nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex);
00274 
00275 int IsInInterface (nsIInterfaceInfo *infoa, nsIInterfaceInfo *infob);
00276 int isInInterface (nsIInterfaceInfo *interfaceinfo, nsIID *iid);
00277 
00278 int      Tcl2Native   (Tcl_Interp *interp, Tcl_Obj *value, void **params, void *param, nsXPTType *type, int shared, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, nsXPTParamInfo *paraminfo);
00279 nsresult Native2Tcl   (void **params, void *param, nsXPTType *type, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, nsXPTParamInfo *paraminfo, Tcl_Obj **result);
00280 void     CleanupParam (void **params, void *param, nsXPTType *type, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, nsXPTParamInfo *paraminfo);
00281 
00282 nsresult TclXPCOM_CallMethod (Tcl_Interp *interp, nsXPTCMiniVariant *variants, nsISupports *isupports, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, Tcl_Obj *script);
00283 
00284 void *CloneMemory (void *ptr, size_t size);
00285 
00286 #endif /* __TCLXPCOMPRIVATE_H__ */

Generated on Fri Jun 14 23:25:51 2002 for TclXPCOM by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002