Back to index

lightning-sunbird  0.9+nobinonly
XPCIDispatchClassInfo.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  * ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the IDispatch implementation for XPConnect.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * David Bradley.
00019  * Portions created by the Initial Developer are Copyright (C) 2002
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "xpcprivate.h"
00039 #include "nsCRT.h"
00040 
00041 NS_IMPL_ISUPPORTS1(XPCIDispatchClassInfo, nsIClassInfo)
00042 
00043 XPCIDispatchClassInfo* XPCIDispatchClassInfo::sInstance = nsnull;
00044 
00045 XPCIDispatchClassInfo* XPCIDispatchClassInfo::GetSingleton()
00046 {
00047     if(!sInstance)
00048     {
00049         sInstance = new XPCIDispatchClassInfo;
00050         NS_IF_ADDREF(sInstance);
00051     }
00052     NS_IF_ADDREF(sInstance);
00053     return sInstance;
00054 }
00055 
00056 void XPCIDispatchClassInfo::FreeSingleton()
00057 {
00058     NS_IF_RELEASE(sInstance);
00059     sInstance = nsnull;
00060 }
00061 
00062 /* void getInterfaces (out PRUint32 count, [array, size_is (count), retval] 
00063                        out nsIIDPtr array); */
00064 NS_IMETHODIMP 
00065 XPCIDispatchClassInfo::GetInterfaces(PRUint32 *count, nsIID * **array)
00066 {
00067     *count = 0;
00068     *array = NS_STATIC_CAST(nsIID**, nsMemory::Alloc(sizeof(nsIID*)));
00069     NS_ENSURE_TRUE(*array, NS_ERROR_OUT_OF_MEMORY);
00070 
00071     **array = NS_STATIC_CAST(nsIID *, nsMemory::Clone(&NSID_IDISPATCH,
00072                                                       sizeof(NSID_IDISPATCH)));
00073     if(!**array)
00074     {
00075         nsMemory::Free(*array);
00076         *array = nsnull;
00077         return NS_ERROR_OUT_OF_MEMORY;
00078     }
00079 
00080     *count = 1;
00081     return NS_OK;
00082 }
00083 
00084 /* nsISupports getHelperForLanguage (in PRUint32 language); */
00085 NS_IMETHODIMP 
00086 XPCIDispatchClassInfo::GetHelperForLanguage(PRUint32 language, 
00087                                             nsISupports **retval)
00088 {
00089     *retval = nsnull;
00090     return NS_OK;
00091 }
00092 
00093 /* readonly attribute string contractID; */
00094 NS_IMETHODIMP 
00095 XPCIDispatchClassInfo::GetContractID(char * *aContractID)
00096 {
00097     *aContractID = nsnull;
00098     return NS_OK;
00099 }
00100 
00101 /* readonly attribute string classDescription; */
00102 NS_IMETHODIMP 
00103 XPCIDispatchClassInfo::GetClassDescription(char * *aClassDescription)
00104 {
00105     *aClassDescription = nsCRT::strdup("IDispatch");
00106     return *aClassDescription ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
00107 }
00108 
00109 /* readonly attribute nsCIDPtr classID; */
00110 NS_IMETHODIMP 
00111 XPCIDispatchClassInfo::GetClassID(nsCID * *aClassID)
00112 {
00113     *aClassID = nsnull;
00114     return NS_OK;
00115 }
00116 
00117 /* readonly attribute PRUint32 implementationLanguage; */
00118 NS_IMETHODIMP 
00119 XPCIDispatchClassInfo::GetImplementationLanguage(
00120     PRUint32 *aImplementationLanguage)
00121 {
00122     *aImplementationLanguage = nsIProgrammingLanguage::UNKNOWN;
00123     return NS_OK;
00124 }
00125 
00126 /* readonly attribute PRUint32 flags; */
00127 NS_IMETHODIMP 
00128 XPCIDispatchClassInfo::GetFlags(PRUint32 *aFlags)
00129 {
00130     *aFlags = nsIClassInfo::DOM_OBJECT;
00131     return NS_OK;
00132 }
00133 
00134 /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */
00135 NS_IMETHODIMP 
00136 XPCIDispatchClassInfo::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
00137 {
00138     return NS_ERROR_NOT_AVAILABLE;
00139 }