Main Page   Compound List   File List   Compound Members   File Members  

tclxpcom.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 __TCLXPCOM_H__
00036 #define __TCLXPCOM_H__
00037 
00038 #include "tcl.h"
00039 #include "nsISupports.h"
00040 #include "nsIInterfaceInfo.h"
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 /*
00047  * if the BUILD_TCLXPCOM macro is defined, the assumption is that we are
00048  * building the dynamic library.
00049  */
00050 #ifdef BUILD_TCLXPCOM
00051 #  undef TCL_STORAGE_CLASS
00052 #  define TCL_STORAGE_CLASS DLLEXPORT
00053 #endif
00054 
00055 #define TCLXPCOM_MOZHOMEVARNAME    "::xpcom::mozilla_home"
00056 #define TCLXPCOM_LASTRESULTVARNAME "::xpcom::lastResult"
00057 #define TCLXPCOM_ERRORMSGPROC      "::xpcom::errormsg"
00058 #define TCLXPCOM_BGERRORPROC       "::xpcom::bgerror"
00059 
00060 EXTERN int Tclxpcom_Init _ANSI_ARGS_((Tcl_Interp *interp));
00061 EXTERN int Tclxpcom_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
00062 
00063 
00064 // custom tcl object types
00065 #define TCLXPCOM_ISUPPORTSTYPENAME  "TclXPCOM_Interface_Reference"
00066 #define TCLXPCOM_NSIDTYPENAME       "TclXPCOM_Unique_ID"
00067 #define TCLXPCOM_POINTERTYPENAME    "TclXPCOM_Void_Pointer"
00068 #define TCLXPCOM_IDENTIFIERTYPENAME "TclXPCOM_Identifier"
00069 
00070 EXTERN Tcl_Obj *TclXPCOM_NewISupportsObj  (nsISupports *isupports, nsIInterfaceInfo *interfaceinfo);
00071 EXTERN Tcl_Obj *TclXPCOM_NewNsIDObj       (nsID *id);
00072 EXTERN Tcl_Obj *TclXPCOM_NewPointerObj    (void *ptr);
00073 EXTERN Tcl_Obj *TclXPCOM_NewIdentifierObj (nsIInterfaceInfo *interfaceinfo, char *identifier);
00074 
00075 EXTERN int TclXPCOM_GetISupportsFromObj  (Tcl_Interp *interp, Tcl_Obj *objPtr, nsISupports **ref, nsIInterfaceInfo **info);
00076 EXTERN int TclXPCOM_QueryISupportsObj    (Tcl_Interp *interp, Tcl_Obj *objPtr, nsIInterfaceInfo *info, nsISupports **ref);
00077 EXTERN int TclXPCOM_GetNsIDFromObj       (Tcl_Interp *interp, Tcl_Obj *objPtr, nsID **id);
00078 EXTERN int TclXPCOM_GetPointerFromObj    (Tcl_Interp *interp, Tcl_Obj *objPtr, void **ptr);
00079 EXTERN int TclXPCOM_GetIdentifierFromObj (Tcl_Interp *interp, Tcl_Obj *objPtr, nsIInterfaceInfo **interfaceinfo, char **identifier);
00080 
00081 EXTERN int TclXPCOM_IsNULL (Tcl_Obj *objPtr);
00082 
00083 
00084 // flags for invoke and stubs facility
00085 #define FORCE_HIDDEN         0x01
00086 #define FORCE_NOTXPCOM       0x02
00087 #define FORCE_NOTSCRIPTABLE  0x04
00088 
00089 
00090 EXTERN void TclXPCOM_RegisterCommands (Tcl_Interp *interp);
00091 
00092 EXTERN Tcl_ObjCmdProc TclXPCOM_InvokeObjCmd;
00093 EXTERN Tcl_ObjCmdProc TclXPCOM_WrapObjCmd;
00094 EXTERN Tcl_ObjCmdProc TclXPCOM_ThisObjCmd;
00095 EXTERN Tcl_ObjCmdProc TclXPCOM_ConstantObjCmd;
00096 EXTERN Tcl_ObjCmdProc TclXPCOM_InfoObjCmd;
00097 EXTERN Tcl_ObjCmdProc TclXPCOM_NullObjCmd;
00098 EXTERN Tcl_ObjCmdProc TclXPCOM_IsNullObjCmd;
00099 EXTERN Tcl_ObjCmdProc TclXPCOM_PointerObjCmd;
00100 EXTERN Tcl_ObjCmdProc TclXPCOM_AddressObjCmd;
00101 EXTERN Tcl_ObjCmdProc TclXPCOM_FromStringObjCmd;
00102 EXTERN Tcl_ObjCmdProc TclXPCOM_SetReturnCodeObjCmd;
00103 EXTERN Tcl_ObjCmdProc TclXPCOM_IdObjCmd;
00104 
00105 // invoke facility
00106 EXTERN int TclXPCOM_Invoke (Tcl_Interp *interp, Tcl_Obj *CONST objv[], nsISupports *isupports, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex);
00107 // int TclXPCOM_Invoke (Tcl_Interp *interp, Tcl_Obj *CONST objv[], nsISupports *isupports, TclXPCOM_MethodInfo methodinfo);
00108 
00109 // stubs facility
00110 EXTERN void     TclXPCOM_GetCurrentComponentContext (nsIInterfaceInfo **interfaceinfo, nsISupports **isupports);
00111 EXTERN int      TclXPCOM_SetReturnCode              (nsresult res);
00112 
00113 EXTERN int TclXPCOM_CheckInterfaceIsReflectable (Tcl_Interp *interp, nsIInterfaceInfo *interfaceinfo, int flags);
00114 EXTERN int TclXPCOM_CheckMethodIsReflectable    (Tcl_Interp *interp, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, int flags);
00115 
00116 
00117 typedef struct IdentifierInfo_ IdentifierInfo;
00118 typedef struct ClassInfo_      ClassInfo;
00119 
00120 // interfaceinfo
00121 #define INTERFACEINFO_METHOD  0x01
00122 #define INTERFACEINFO_GETTER  0x02
00123 #define INTERFACEINFO_SETTER  0x04
00124 
00125 EXTERN int        TclXPCOM_GetIdentifierInfoFromInterface (Tcl_Interp *interp, nsIInterfaceInfo *info, Tcl_Obj *identifier, int type, IdentifierInfo **idinfo);
00126 EXTERN int        TclXPCOM_GetIdentifierInfoFromClass     (Tcl_Interp *interp, ClassInfo *cinfo, Tcl_Obj *identifier, int type, nsIInterfaceInfo **info, IdentifierInfo **idinfo);
00127 EXTERN int        TclXPCOM_GetMethodIndex                 (Tcl_Interp *interp, IdentifierInfo *idinfo, int type, PRUint16 *methodindex);
00128 EXTERN int        TclXPCOM_GetConstant                    (Tcl_Interp *interp, nsIInterfaceInfo *interfaceinfo, Tcl_Obj *constantname, Tcl_Obj **result);
00129 EXTERN ClassInfo *TclXPCOM_GetClassInfo                   (int iidcount, nsIID **iids);
00130 
00131 
00132 
00133 //EXTERN TclXPCOMInterface TclXPCOM_GetInterface      (nsIInterfaceInfo *interfaceinfo);
00134 //EXTERN TclXPCOMClass     TclXPCOM_GetClass          (int iidcount, nsIID **iids);
00135 //EXTERN TclXPCOMMethod    TclXPCOM_GetMethod         (nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex);
00136 
00137 //EXTERN Tcl_Obj          *TclXPCOM_GetInterfaceConstantValue  (TclXPCOMInterface interface, int constantindex);
00138 
00139 //EXTERN int               TclXPCOM_GetMethodFromInterface (Tcl_Interp *interp, TclXPCOMInterface interface, Tcl_Obj *identifier, int type, TclXPCOMMethod *method);
00140 //EXTERN int               TclXPCOM_GetMethodFromClass     (Tcl_Interp *interp, TclXPCOMClass class, Tcl_Obj *identifier, int type, nsIInterfaceInfo **info, MethodInfo **minfo);
00141 //EXTERN int               TclXPCOM_GetMethod              (Tcl_Interp *interp, TclXPCOMInterface interface, MethodInfo *minfo, int type, TclXPCOMMethod *method);
00142 //EXTERN int               TclXPCOM_GetConstant            (Tcl_Interp *interp, TclXPCOMInterface interface, Tcl_Obj *constantname, Tcl_Obj **result);
00143 
00144 
00145 EXTERN void TclXPCOM_SetErrorCode    (Tcl_Interp *interp, nsresult res);
00146 //returns 1 if successful,  0 if failure
00147 EXTERN int  TclXPCOM_GetErrorCode    (Tcl_Interp *interp, nsresult *res);
00148 EXTERN void TclXPCOM_BackgroundError (Tcl_Interp *interp);
00149 
00150 EXTERN void TclXPCOM_SetErrorMessage (Tcl_Interp *interp, nsresult res);
00151 EXTERN void TclXPCOM_SetError        (Tcl_Interp *interp, nsresult res);
00152 
00153 
00154 // utility functions
00155 EXTERN Tcl_Obj *TclXPCOM_ListInterfaceMethods    (nsIInterfaceInfo *interfaceinfo);
00156 EXTERN Tcl_Obj *TclXPCOM_ListInterfaceAttributes (nsIInterfaceInfo *interfaceinfo);
00157 EXTERN Tcl_Obj *TclXPCOM_ListInterfaceConstants  (nsIInterfaceInfo *interfaceinfo);
00158 EXTERN Tcl_Obj *TclXPCOM_ListClassMethods        (ClassInfo *cinfo);
00159 EXTERN Tcl_Obj *TclXPCOM_ListClassAttributes     (ClassInfo *cinfo);
00160 
00161 EXTERN Tcl_Obj *TclXPCOM_ListMethodArguments     (nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex);
00162 EXTERN Tcl_Obj *TclXPCOM_GetAttributeType        (nsIInterfaceInfo *interfaceinfo, IdentifierInfo *idinfo);
00163 EXTERN Tcl_Obj *TclXPCOM_GetReturnValueType      (nsIInterfaceInfo *interfaceinfo, IdentifierInfo *idinfo);
00164 
00165 
00166 # undef TCL_STORAGE_CLASS
00167 # define TCL_STORAGE_CLASS DLLIMPORT
00168     
00169 #ifdef __cplusplus
00170 }
00171 #endif
00172 
00173 #endif /* __TCLXPCOM_H__ */

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