Back to index

lightning-sunbird  0.9+nobinonly
nsScriptableInterfaceInfo.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; 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 mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   John Bandhauer <jband@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 /* nsIScriptableInteraceInfo family implementations. */
00040 
00041 #include "iixprivate.h"
00042 
00043 /***************************************************************************/
00044 static inline
00045 nsresult CloneString(const char* inStr, char** outStr)
00046 {
00047     *outStr = (char*) nsMemory::Clone(inStr, strlen(inStr)+1);
00048     return *outStr ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
00049 }
00050 
00051 /***************************************************************************/
00052 
00053 /* Header file */
00054 class nsScriptableDataType : public nsIScriptableDataType
00055 {
00056 public:
00057     NS_DECL_ISUPPORTS
00058     NS_DECL_NSISCRIPTABLEDATATYPE
00059 
00060     static nsresult Create(const nsXPTType& aType,
00061                            nsIScriptableDataType** aResult);
00062 
00063     nsScriptableDataType(const nsXPTType& aType)
00064         : mType(aType)
00065     {
00066     }
00067 
00068     virtual ~nsScriptableDataType()
00069     {
00070     }
00071 
00072 private:
00073     nsScriptableDataType(); // not implemented
00074 
00075     nsXPTType mType;
00076 };
00077 
00078 // static
00079 nsresult
00080 nsScriptableDataType::Create(const nsXPTType& aType,
00081                              nsIScriptableDataType** aResult)
00082 {
00083     nsScriptableDataType* obj = new nsScriptableDataType(aType);
00084     if(!obj)
00085         return NS_ERROR_OUT_OF_MEMORY;
00086     *aResult = NS_STATIC_CAST(nsIScriptableDataType*, obj);
00087     NS_ADDREF(*aResult);
00088     return NS_OK;
00089 }
00090 
00091 NS_IMPL_ISUPPORTS1(nsScriptableDataType, nsIScriptableDataType)
00092 
00093 /* readonly attribute PRBool isPointer; */
00094 NS_IMETHODIMP
00095 nsScriptableDataType::GetIsPointer(PRBool *aIsPointer)
00096 {
00097     *aIsPointer = mType.IsPointer();
00098     return NS_OK;
00099 }
00100 
00101 /* readonly attribute PRBool isUniquePointer; */
00102 NS_IMETHODIMP
00103 nsScriptableDataType::GetIsUniquePointer(PRBool *aIsUniquePointer)
00104 {
00105     *aIsUniquePointer = mType.IsUniquePointer();
00106     return NS_OK;
00107 }
00108 
00109 /* readonly attribute PRBool isReference; */
00110 NS_IMETHODIMP
00111 nsScriptableDataType::GetIsReference(PRBool *aIsReference)
00112 {
00113     *aIsReference = mType.IsReference();
00114     return NS_OK;
00115 }
00116 
00117 /* readonly attribute PRBool isArithmetic; */
00118 NS_IMETHODIMP
00119 nsScriptableDataType::GetIsArithmetic(PRBool *aIsArithmetic)
00120 {
00121     *aIsArithmetic = mType.IsArithmetic();
00122     return NS_OK;
00123 }
00124 
00125 /* readonly attribute PRBool isInterfacePointer; */
00126 NS_IMETHODIMP
00127 nsScriptableDataType::GetIsInterfacePointer(PRBool *aIsInterfacePointer)
00128 {
00129     *aIsInterfacePointer = mType.IsInterfacePointer();
00130     return NS_OK;
00131 }
00132 
00133 /* readonly attribute PRBool isArray; */
00134 NS_IMETHODIMP
00135 nsScriptableDataType::GetIsArray(PRBool *aIsArray)
00136 {
00137     *aIsArray = mType.IsArray();
00138     return NS_OK;
00139 }
00140 
00141 /* readonly attribute PRBool isDependent; */
00142 NS_IMETHODIMP
00143 nsScriptableDataType::GetIsDependent(PRBool *aIsDependent)
00144 {
00145     *aIsDependent = mType.IsDependent();
00146     return NS_OK;
00147 }
00148 
00149 /* readonly attribute PRUint16 dataType; */
00150 NS_IMETHODIMP
00151 nsScriptableDataType::GetDataType(PRUint16 *aDataType)
00152 {
00153     *aDataType = mType.TagPart();
00154     return NS_OK;
00155 }
00156 
00157 /***************************************************************************/
00158 
00159 class nsScriptableParamInfo : public nsIScriptableParamInfo
00160 {
00161 public:
00162     NS_DECL_ISUPPORTS
00163     NS_DECL_NSISCRIPTABLEPARAMINFO
00164 
00165     static nsresult Create(nsIInterfaceInfo* aInfo,
00166                            const nsXPTParamInfo& aParam,
00167                            nsIScriptableParamInfo** aResult);
00168 
00169     nsScriptableParamInfo(nsIInterfaceInfo* aInfo,
00170                            const nsXPTParamInfo& aParam)
00171         : mInfo(aInfo), mParam(aParam)
00172     {
00173     }
00174     virtual ~nsScriptableParamInfo()
00175     {
00176     }
00177 
00178 private:
00179     nsScriptableParamInfo(); // not implemented
00180 
00181     // Holding onto the interface info keeps the underlying param alive.
00182     nsCOMPtr<nsIInterfaceInfo> mInfo;
00183     nsXPTParamInfo             mParam;
00184 };
00185 
00186 
00187 // static
00188 nsresult
00189 nsScriptableParamInfo::Create(nsIInterfaceInfo* aInfo,
00190                               const nsXPTParamInfo& aParam,
00191                               nsIScriptableParamInfo** aResult)
00192 {
00193     nsScriptableParamInfo* obj = new nsScriptableParamInfo(aInfo, aParam);
00194     if(!obj)
00195         return NS_ERROR_OUT_OF_MEMORY;
00196     *aResult = NS_STATIC_CAST(nsIScriptableParamInfo*, obj);
00197     NS_ADDREF(*aResult);
00198     return NS_OK;
00199 }
00200 
00201 NS_IMPL_ISUPPORTS1(nsScriptableParamInfo, nsIScriptableParamInfo)
00202 
00203 /* readonly attribute PRBool isIn; */
00204 NS_IMETHODIMP
00205 nsScriptableParamInfo::GetIsIn(PRBool *aIsIn)
00206 {
00207     *aIsIn = mParam.IsIn();
00208     return NS_OK;
00209 }
00210 
00211 /* readonly attribute PRBool isOut; */
00212 NS_IMETHODIMP
00213 nsScriptableParamInfo::GetIsOut(PRBool *aIsOut)
00214 {
00215     *aIsOut = mParam.IsOut();
00216     return NS_OK;
00217 }
00218 
00219 /* readonly attribute PRBool isRetval; */
00220 NS_IMETHODIMP
00221 nsScriptableParamInfo::GetIsRetval(PRBool *aIsRetval)
00222 {
00223     *aIsRetval = mParam.IsRetval();
00224     return NS_OK;
00225 }
00226 
00227 /* readonly attribute PRBool isShared; */
00228 NS_IMETHODIMP
00229 nsScriptableParamInfo::GetIsShared(PRBool *aIsShared)
00230 {
00231     *aIsShared = mParam.IsShared();
00232     return NS_OK;
00233 }
00234 
00235 /* readonly attribute PRBool isDipper; */
00236 NS_IMETHODIMP
00237 nsScriptableParamInfo::GetIsDipper(PRBool *aIsDipper)
00238 {
00239     *aIsDipper = mParam.IsDipper();
00240     return NS_OK;
00241 }
00242 
00243 /* readonly attribute nsIScriptableDataType type; */
00244 NS_IMETHODIMP
00245 nsScriptableParamInfo::GetType(nsIScriptableDataType * *aType)
00246 {
00247     return nsScriptableDataType::Create(mParam.GetType(), aType);
00248 }
00249 
00250 /* [noscript] void getParamInfo ([shared, const, retval] out
00251    nsXPTParamInfoPtr aInfo); */
00252 NS_IMETHODIMP
00253 nsScriptableParamInfo::GetParamInfo(const nsXPTParamInfo * *aInfo)
00254 {
00255     *aInfo = &mParam;
00256     return NS_OK;
00257 }
00258 
00259 /***************************************************************************/
00260 class nsScriptableConstant : public nsIScriptableConstant
00261 {
00262 public:
00263     NS_DECL_ISUPPORTS
00264     NS_DECL_NSISCRIPTABLECONSTANT
00265 
00266     static nsresult Create(nsIInterfaceInfo* aInfo,
00267                            const nsXPTConstant& aConst,
00268                            nsIScriptableConstant** aResult);
00269 
00270     nsScriptableConstant(); // not implemented
00271     nsScriptableConstant(nsIInterfaceInfo* aInfo,
00272                          const nsXPTConstant& aConst)
00273         : mInfo(aInfo), mConst(aConst)
00274     {
00275     }
00276     virtual ~nsScriptableConstant()
00277     {
00278     }
00279 private:
00280     // Holding onto the interface info keeps the underlying const alive.
00281     nsCOMPtr<nsIInterfaceInfo> mInfo;
00282     nsXPTConstant              mConst;
00283 };
00284 
00285 // static
00286 nsresult
00287 nsScriptableConstant::Create(nsIInterfaceInfo* aInfo,
00288                              const nsXPTConstant& aConst,
00289                              nsIScriptableConstant** aResult)
00290 {
00291     nsScriptableConstant* obj = new nsScriptableConstant(aInfo, aConst);
00292     if(!obj)
00293         return NS_ERROR_OUT_OF_MEMORY;
00294     *aResult = NS_STATIC_CAST(nsIScriptableConstant*, obj);
00295     NS_ADDREF(*aResult);
00296     return NS_OK;
00297 }
00298 
00299 NS_IMPL_ISUPPORTS1(nsScriptableConstant, nsIScriptableConstant)
00300 
00301 /* readonly attribute string name; */
00302 NS_IMETHODIMP
00303 nsScriptableConstant::GetName(char * *aName)
00304 {
00305     return CloneString(mConst.GetName(), aName);
00306 }
00307 
00308 /* readonly attribute nsIScriptableDataType type; */
00309 NS_IMETHODIMP
00310 nsScriptableConstant::GetType(nsIScriptableDataType * *aType)
00311 {
00312     return nsScriptableDataType::Create(mConst.GetType(), aType);
00313 }
00314 
00315 /* readonly attribute nsIVariant value; */
00316 NS_IMETHODIMP
00317 nsScriptableConstant::GetValue(nsIVariant * *aValue)
00318 {
00319     nsVariant* variant = new nsVariant();
00320     if(!variant)
00321     {
00322         *aValue = nsnull;
00323         return NS_ERROR_OUT_OF_MEMORY;
00324     }
00325     *aValue = NS_STATIC_CAST(nsIVariant*, variant);
00326     NS_ADDREF(*aValue);
00327 
00328     const nsXPTCMiniVariant* varval = mConst.GetValue();
00329     nsresult rv;
00330 
00331     switch(mConst.GetType())
00332     {
00333         case nsXPTType::T_I16:
00334             rv = variant->SetAsInt16(varval->val.i16);
00335             break;
00336         case nsXPTType::T_I32:
00337             rv = variant->SetAsInt32(varval->val.i32);
00338             break;
00339         case nsXPTType::T_U16:
00340             rv = variant->SetAsUint16(varval->val.u16);
00341             break;
00342         case nsXPTType::T_U32:
00343             rv = variant->SetAsUint32(varval->val.u32);
00344             break;
00345         default:
00346             NS_ERROR("invalid const type");
00347             rv = NS_ERROR_UNEXPECTED;
00348             break;
00349     }
00350 
00351     if(NS_FAILED(rv))
00352     {
00353         NS_RELEASE(*aValue);
00354         return rv;
00355     }
00356 
00357     return NS_OK;
00358 }
00359 
00360 /***************************************************************************/
00361 
00362 class nsScriptableMethodInfo : public nsIScriptableMethodInfo
00363 {
00364 public:
00365     NS_DECL_ISUPPORTS
00366     NS_DECL_NSISCRIPTABLEMETHODINFO
00367 
00368     static nsresult Create(nsIInterfaceInfo* aInfo,
00369                            const nsXPTMethodInfo& aMethod,
00370                            nsIScriptableMethodInfo** aResult);
00371 
00372     nsScriptableMethodInfo(nsIInterfaceInfo* aInfo,
00373                             const nsXPTMethodInfo& aMethod)
00374         : mInfo(aInfo), mMethod(aMethod)
00375     {
00376     }
00377     virtual ~nsScriptableMethodInfo()
00378     {
00379     }
00380 private:
00381     nsScriptableMethodInfo(); // not implemented
00382 
00383     // Holding onto the interface info keeps the underlying method
00384     // alive.
00385     nsCOMPtr<nsIInterfaceInfo> mInfo;
00386     const nsXPTMethodInfo&     mMethod;
00387 };
00388 
00389 // static
00390 nsresult
00391 nsScriptableMethodInfo::Create(nsIInterfaceInfo* aInfo,
00392                                const nsXPTMethodInfo& aMethod,
00393                                nsIScriptableMethodInfo** aResult)
00394 {
00395     nsScriptableMethodInfo* obj = new nsScriptableMethodInfo(aInfo, aMethod);
00396     if(!obj)
00397         return NS_ERROR_OUT_OF_MEMORY;
00398     *aResult = NS_STATIC_CAST(nsIScriptableMethodInfo*, obj);
00399     NS_ADDREF(*aResult);
00400     return NS_OK;
00401 }
00402 
00403 NS_IMPL_ISUPPORTS1(nsScriptableMethodInfo, nsIScriptableMethodInfo)
00404 
00405 /* readonly attribute PRBool isGetter; */
00406 NS_IMETHODIMP
00407 nsScriptableMethodInfo::GetIsGetter(PRBool *aIsGetter)
00408 {
00409     *aIsGetter = mMethod.IsGetter();
00410     return NS_OK;
00411 }
00412 
00413 /* readonly attribute PRBool isSetter; */
00414 NS_IMETHODIMP
00415 nsScriptableMethodInfo::GetIsSetter(PRBool *aIsSetter)
00416 {
00417     *aIsSetter = mMethod.IsSetter();
00418     return NS_OK;
00419 }
00420 
00421 /* readonly attribute PRBool isNotXPCOM; */
00422 NS_IMETHODIMP
00423 nsScriptableMethodInfo::GetIsNotXPCOM(PRBool *aIsNotXPCOM)
00424 {
00425     *aIsNotXPCOM = mMethod.IsNotXPCOM();
00426     return NS_OK;
00427 }
00428 
00429 /* readonly attribute PRBool isConstructor; */
00430 NS_IMETHODIMP
00431 nsScriptableMethodInfo::GetIsConstructor(PRBool *aIsConstructor)
00432 {
00433     *aIsConstructor = mMethod.IsConstructor();
00434     return NS_OK;
00435 }
00436 
00437 /* readonly attribute PRBool isHidden; */
00438 NS_IMETHODIMP
00439 nsScriptableMethodInfo::GetIsHidden(PRBool *aIsHidden)
00440 {
00441     *aIsHidden = mMethod.IsHidden();
00442     return NS_OK;
00443 }
00444 
00445 /* readonly attribute string name; */
00446 NS_IMETHODIMP
00447 nsScriptableMethodInfo::GetName(char * *aName)
00448 {
00449     return CloneString(mMethod.GetName(), aName);
00450 }
00451 
00452 /* readonly attribute PRUint8 paramCount; */
00453 NS_IMETHODIMP
00454 nsScriptableMethodInfo::GetParamCount(PRUint8 *aParamCount)
00455 {
00456     *aParamCount = mMethod.GetParamCount();
00457     return NS_OK;
00458 }
00459 
00460 /* nsIScriptableParamInfo getParam (in PRUint8 idx); */
00461 NS_IMETHODIMP
00462 nsScriptableMethodInfo::GetParam(PRUint8 idx, nsIScriptableParamInfo **_retval)
00463 {
00464     if(idx >= mMethod.GetParamCount())
00465         return NS_ERROR_INVALID_ARG;
00466     return nsScriptableParamInfo::Create(mInfo, mMethod.GetParam(idx),
00467                                          _retval);
00468 }
00469 
00470 /* readonly attribute nsIScriptableParamInfo result; */
00471 NS_IMETHODIMP
00472 nsScriptableMethodInfo::GetResult(nsIScriptableParamInfo * *aResult)
00473 {
00474     return nsScriptableParamInfo::Create(mInfo, mMethod.GetResult(), aResult);
00475 }
00476 
00477 /***************************************************************************/
00478 
00479 // static
00480 nsresult
00481 nsScriptableInterfaceInfo::Create(nsIInterfaceInfo* aInfo,
00482                                   nsIScriptableInterfaceInfo** aResult)
00483 {
00484     nsScriptableInterfaceInfo* obj = new nsScriptableInterfaceInfo(aInfo);
00485     if(!obj)
00486         return NS_ERROR_OUT_OF_MEMORY;
00487     *aResult = NS_STATIC_CAST(nsIScriptableInterfaceInfo*, obj);
00488     NS_ADDREF(*aResult);
00489     return NS_OK;
00490 }
00491 
00492 NS_IMPL_ISUPPORTS1(nsScriptableInterfaceInfo, nsIScriptableInterfaceInfo)
00493 
00494 nsScriptableInterfaceInfo::nsScriptableInterfaceInfo()
00495 {
00496 }
00497 
00498 nsScriptableInterfaceInfo::nsScriptableInterfaceInfo(nsIInterfaceInfo* aInfo)
00499     : mInfo(aInfo)
00500 {
00501 }
00502 
00503 nsScriptableInterfaceInfo::~nsScriptableInterfaceInfo()
00504 {
00505     // empty;
00506 }
00507 
00508 /* [noscript] attribute nsIInterfaceInfo info; */
00509 NS_IMETHODIMP
00510 nsScriptableInterfaceInfo::GetInfo(nsIInterfaceInfo * *aInfo)
00511 {
00512     if(mInfo)
00513         NS_ADDREF(*aInfo = mInfo);
00514     else
00515         *aInfo = nsnull;
00516     return NS_OK;
00517 }
00518 
00519 NS_IMETHODIMP
00520 nsScriptableInterfaceInfo::SetInfo(nsIInterfaceInfo * aInfo)
00521 {
00522     if(mInfo)
00523         return NS_ERROR_ALREADY_INITIALIZED;
00524     mInfo = aInfo;
00525     return NS_OK;
00526 }
00527 
00528 /***************************************************************************/
00529 
00530 typedef PRBool (*InfoTester)(nsIInterfaceInfoManager* manager,
00531                              const void* data, nsIInterfaceInfo** info);
00532 
00533 static PRBool
00534 IIDTester(nsIInterfaceInfoManager* manager, const void* data,
00535           nsIInterfaceInfo** info)
00536 {
00537     return NS_SUCCEEDED(manager->GetInfoForIID((const nsIID *) data, info)) &&
00538            *info;
00539 }
00540 
00541 static PRBool
00542 NameTester(nsIInterfaceInfoManager* manager, const void* data,
00543            nsIInterfaceInfo** info)
00544 {
00545     return NS_SUCCEEDED(manager->GetInfoForName((const char *) data, info)) &&
00546            *info;
00547 }
00548 
00549 static nsresult
00550 FindInfo(InfoTester tester, const void* data, nsIInterfaceInfo** info)
00551 {
00552     nsCOMPtr<nsIInterfaceInfoManager> iim = 
00553         dont_AddRef(XPTI_GetInterfaceInfoManager());
00554     
00555     if(!iim)
00556         return NS_ERROR_UNEXPECTED;
00557 
00558     if(tester(iim, data, info))
00559         return NS_OK;
00560     
00561     // If not found, then let's ask additional managers.
00562 
00563     PRBool yes;
00564     nsCOMPtr<nsISimpleEnumerator> list;
00565     nsCOMPtr<nsIInterfaceInfoSuperManager> iism;
00566 
00567     if((nsnull != (iism = do_QueryInterface(iim))) &&
00568        NS_SUCCEEDED(iism->HasAdditionalManagers(&yes)) && yes &&
00569        NS_SUCCEEDED(iism->EnumerateAdditionalManagers(getter_AddRefs(list))) &&
00570        list)
00571     {
00572         PRBool more;
00573         nsCOMPtr<nsIInterfaceInfoManager> current;
00574 
00575         while(NS_SUCCEEDED(list->HasMoreElements(&more)) && more &&
00576               NS_SUCCEEDED(list->GetNext(getter_AddRefs(current))) && current)
00577         {
00578             if(tester(current, data, info))
00579                 return NS_OK;
00580         }
00581     }
00582     
00583     return NS_ERROR_NO_INTERFACE;
00584 }    
00585 
00586 /***************************************************************************/
00587 
00588 
00589 /* void Init (in nsIIDPtr aIID); */
00590 NS_IMETHODIMP 
00591 nsScriptableInterfaceInfo::Init(const nsIID * aIID)
00592 {
00593     if(mInfo)
00594         return NS_ERROR_ALREADY_INITIALIZED;
00595 
00596     if(!aIID)
00597         return NS_ERROR_NULL_POINTER;
00598 
00599     return FindInfo(IIDTester, aIID, getter_AddRefs(mInfo));
00600 }
00601 
00602 /* void initWithName (in string name); */
00603 NS_IMETHODIMP 
00604 nsScriptableInterfaceInfo::InitWithName(const char *name)
00605 {
00606     if(mInfo)
00607         return NS_ERROR_ALREADY_INITIALIZED;
00608 
00609     if(!name)
00610         return NS_ERROR_NULL_POINTER;
00611 
00612     return FindInfo(NameTester, name, getter_AddRefs(mInfo));
00613 }
00614 
00615 /* readonly attribute string name; */
00616 NS_IMETHODIMP
00617 nsScriptableInterfaceInfo::GetName(char * *aName)
00618 {
00619     if(!mInfo)
00620         return NS_ERROR_NOT_INITIALIZED;
00621 
00622     return mInfo->GetName(aName);
00623 }
00624 
00625 /* readonly attribute nsIIDPtr interfaceID; */
00626 NS_IMETHODIMP 
00627 nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
00628 {
00629     if(!mInfo)
00630         return NS_ERROR_NOT_INITIALIZED;
00631 
00632     return mInfo->GetInterfaceIID(aInterfaceID);
00633 }
00634 
00635 /* readonly attribute PRBool isValid; */
00636 NS_IMETHODIMP
00637 nsScriptableInterfaceInfo::GetIsValid(PRBool *aIsValid)
00638 {
00639     *aIsValid = !!mInfo;
00640     return NS_OK;
00641 }
00642 
00643 /* readonly attribute PRBool isScriptable; */
00644 NS_IMETHODIMP
00645 nsScriptableInterfaceInfo::GetIsScriptable(PRBool *aIsScriptable)
00646 {
00647     if(!mInfo)
00648         return NS_ERROR_NOT_INITIALIZED;
00649 
00650     return mInfo->IsScriptable(aIsScriptable);
00651 }
00652 
00653 /* readonly attribute nsIScriptableInterfaceInfo parent; */
00654 NS_IMETHODIMP
00655 nsScriptableInterfaceInfo::GetParent(nsIScriptableInterfaceInfo * *aParent)
00656 {
00657     if(!mInfo)
00658         return NS_ERROR_NOT_INITIALIZED;
00659 
00660     nsCOMPtr<nsIInterfaceInfo> parentInfo;
00661     nsresult rv = mInfo->GetParent(getter_AddRefs(parentInfo));
00662     if(NS_FAILED(rv))
00663         return rv;
00664 
00665     if(parentInfo)
00666         return Create(parentInfo, aParent);
00667 
00668     *aParent = nsnull;
00669     return NS_OK;
00670 }
00671 
00672 /* readonly attribute PRUint16 methodCount; */
00673 NS_IMETHODIMP
00674 nsScriptableInterfaceInfo::GetMethodCount(PRUint16 *aMethodCount)
00675 {
00676     if(!mInfo)
00677         return NS_ERROR_NOT_INITIALIZED;
00678 
00679     return mInfo->GetMethodCount(aMethodCount);
00680 }
00681 
00682 /* readonly attribute PRUint16 constantCount; */
00683 NS_IMETHODIMP
00684 nsScriptableInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
00685 {
00686     if(!mInfo)
00687         return NS_ERROR_NOT_INITIALIZED;
00688 
00689     return mInfo->GetConstantCount(aConstantCount);
00690 }
00691 
00692 /* nsIScriptableMethodInfo getMethodInfo (in PRUint16 index); */
00693 NS_IMETHODIMP
00694 nsScriptableInterfaceInfo::GetMethodInfo(PRUint16 index,
00695                                          nsIScriptableMethodInfo **_retval)
00696 {
00697     if(!mInfo)
00698         return NS_ERROR_NOT_INITIALIZED;
00699 
00700     const nsXPTMethodInfo* methodInfo;
00701     nsresult rv = mInfo->GetMethodInfo(index, &methodInfo);
00702     if(NS_FAILED(rv))
00703         return rv;
00704 
00705     return nsScriptableMethodInfo::Create(mInfo, *methodInfo, _retval);
00706 }
00707 
00708 /* nsIScriptableMethodInfo getMethodInfoForName (in string methodName,
00709    out PRUint16 index); */
00710 NS_IMETHODIMP
00711 nsScriptableInterfaceInfo::GetMethodInfoForName(const char *methodName,
00712                                                 PRUint16 *index,
00713                                                 nsIScriptableMethodInfo **_retval)
00714 {
00715     if(!mInfo)
00716         return NS_ERROR_NOT_INITIALIZED;
00717 
00718     const nsXPTMethodInfo* methodInfo;
00719     nsresult rv = mInfo->GetMethodInfoForName(methodName, index, &methodInfo);
00720     if(NS_FAILED(rv))
00721         return rv;
00722 
00723     return nsScriptableMethodInfo::Create(mInfo, *methodInfo, _retval);
00724 }
00725 
00726 /* nsIScriptableConstant getConstant (in PRUint16 index); */
00727 NS_IMETHODIMP
00728 nsScriptableInterfaceInfo::GetConstant(PRUint16 index,
00729                                        nsIScriptableConstant **_retval)
00730 {
00731     if(!mInfo)
00732         return NS_ERROR_NOT_INITIALIZED;
00733 
00734     const nsXPTConstant* constant;
00735     nsresult rv = mInfo->GetConstant(index, &constant);
00736     if(NS_FAILED(rv))
00737         return rv;
00738 
00739     return nsScriptableConstant::Create(mInfo, *constant, _retval);
00740 }
00741 
00742 /* nsIScriptableInterfaceInfo getInfoForParam (in PRUint16
00743    methodIndex, in nsIScriptableParamInfo param); */
00744 NS_IMETHODIMP
00745 nsScriptableInterfaceInfo::GetInfoForParam(PRUint16 methodIndex,
00746                                            nsIScriptableParamInfo *param,
00747                                            nsIScriptableInterfaceInfo **_retval)
00748 {
00749     if(!mInfo)
00750         return NS_ERROR_NOT_INITIALIZED;
00751 
00752     const nsXPTParamInfo* paramInfo;
00753     nsresult rv = param->GetParamInfo(&paramInfo);
00754     if(NS_FAILED(rv))
00755         return rv;
00756 
00757     nsCOMPtr<nsIInterfaceInfo> info;
00758     rv = mInfo->GetInfoForParam(methodIndex, paramInfo, getter_AddRefs(info));
00759     if(NS_FAILED(rv))
00760         return rv;
00761 
00762     if(info)
00763         return Create(info, _retval);
00764 
00765     *_retval = nsnull;
00766     return NS_OK;
00767 }
00768 
00769 /* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, in
00770    nsIScriptableParamInfo param); */
00771 NS_IMETHODIMP
00772 nsScriptableInterfaceInfo::GetIIDForParam(PRUint16 methodIndex,
00773                                           nsIScriptableParamInfo *param,
00774                                           nsIID * *_retval)
00775 {
00776     if(!mInfo)
00777         return NS_ERROR_NOT_INITIALIZED;
00778 
00779     const nsXPTParamInfo* paramInfo;
00780     nsresult rv = param->GetParamInfo(&paramInfo);
00781     if(NS_FAILED(rv))
00782         return rv;
00783 
00784     return mInfo->GetIIDForParam(methodIndex, paramInfo, _retval);
00785 }
00786 
00787 /* nsIScriptableDataType getTypeForParam (in PRUint16 methodIndex, in
00788    nsIScriptableParamInfo param, in PRUint16 dimension); */
00789 NS_IMETHODIMP
00790 nsScriptableInterfaceInfo::GetTypeForParam(PRUint16 methodIndex,
00791                                            nsIScriptableParamInfo *param,
00792                                            PRUint16 dimension,
00793                                            nsIScriptableDataType **_retval)
00794 {
00795     if(!mInfo)
00796         return NS_ERROR_NOT_INITIALIZED;
00797 
00798     const nsXPTParamInfo* paramInfo;
00799     nsresult rv = param->GetParamInfo(&paramInfo);
00800     if(NS_FAILED(rv))
00801         return rv;
00802 
00803     nsXPTType type;
00804 
00805     rv = mInfo->GetTypeForParam(methodIndex, paramInfo, dimension, &type);
00806     if(NS_FAILED(rv))
00807         return rv;
00808 
00809     return nsScriptableDataType::Create(type, _retval);
00810 }
00811 
00812 /* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, in
00813    nsIScriptableParamInfo param, in PRUint16 dimension); */
00814 NS_IMETHODIMP
00815 nsScriptableInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex,
00816                                                       nsIScriptableParamInfo *param,
00817                                                       PRUint16 dimension,
00818                                                       PRUint8 *_retval)
00819 {
00820     if(!mInfo)
00821         return NS_ERROR_NOT_INITIALIZED;
00822 
00823     const nsXPTParamInfo* paramInfo;
00824     nsresult rv = param->GetParamInfo(&paramInfo);
00825     if(NS_FAILED(rv))
00826         return rv;
00827 
00828     return mInfo->GetSizeIsArgNumberForParam(methodIndex, paramInfo, dimension,
00829                                              _retval);
00830 }
00831 
00832 /* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, in
00833    nsIScriptableParamInfo param, in PRUint16 dimension); */
00834 NS_IMETHODIMP
00835 nsScriptableInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex,
00836                                                         nsIScriptableParamInfo *param,
00837                                                         PRUint16 dimension,
00838                                                         PRUint8 *_retval)
00839 {
00840     if(!mInfo)
00841         return NS_ERROR_NOT_INITIALIZED;
00842 
00843     const nsXPTParamInfo* paramInfo;
00844     nsresult rv = param->GetParamInfo(&paramInfo);
00845     if(NS_FAILED(rv))
00846         return rv;
00847 
00848     return mInfo->GetLengthIsArgNumberForParam(methodIndex, paramInfo,
00849                                                dimension, _retval);
00850 }
00851 
00852 /* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex,
00853    in nsIScriptableParamInfo param); */
00854 NS_IMETHODIMP
00855 nsScriptableInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex,
00856                                                            nsIScriptableParamInfo *param,
00857                                                            PRUint8 *_retval)
00858 {
00859     if(!mInfo)
00860         return NS_ERROR_NOT_INITIALIZED;
00861 
00862     const nsXPTParamInfo* paramInfo;
00863     nsresult rv = param->GetParamInfo(&paramInfo);
00864     if(NS_FAILED(rv))
00865         return rv;
00866 
00867     return mInfo->GetInterfaceIsArgNumberForParam(methodIndex, paramInfo,
00868                                                   _retval);
00869 }
00870 
00871 /* PRBool isIID (in nsIIDPtr IID); */
00872 NS_IMETHODIMP
00873 nsScriptableInterfaceInfo::IsIID(const nsIID * IID, PRBool *_retval)
00874 {
00875     if(!mInfo)
00876         return NS_ERROR_NOT_INITIALIZED;
00877 
00878     return mInfo->IsIID(IID, _retval);
00879 }
00880 
00881 /* readonly attribute PRBool isFunction; */
00882 NS_IMETHODIMP
00883 nsScriptableInterfaceInfo::GetIsFunction(PRBool *aIsFunction)
00884 {
00885     if(!mInfo)
00886         return NS_ERROR_NOT_INITIALIZED;
00887 
00888     return mInfo->IsFunction(aIsFunction);
00889 }
00890 
00891 /* PRBool hasAncestor (in nsIIDPtr iid); */
00892 NS_IMETHODIMP
00893 nsScriptableInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_retval)
00894 {
00895     if(!mInfo)
00896         return NS_ERROR_NOT_INITIALIZED;
00897 
00898     return mInfo->HasAncestor(iid, _retval);
00899 }