/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * The contents of this file are subject to the Netscape Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/NPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code is Mozilla Communicator client code, released
 * March 31, 1998.
 *
 * The Initial Developer of the Original Code is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 2001 Netscape Communications Corporation. All
 * Rights Reserved.
 *
 * Contributor(s):
 *   John Bandhauer <jband@netscape.com> (original author)
 *
 * Alternatively, the contents of this file may be used under the
 * terms of the GNU Public License (the "GPL"), in which case the
 * provisions of the GPL are applicable instead of those above.
 * If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use your
 * version of this file under the NPL, indicate your decision by
 * deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this
 * file under either the NPL or the GPL.
 */

/* Scriptable version of the information exposed by nsIInterfaceInfo */

#include "nsISupports.idl"
#include "nsIInterfaceInfo.idl"
#include "nsIVariant.idl"

[scriptable, uuid(312e3b94-dc98-4ccc-b2fb-e3406f905cc6)]
interface nsIScriptableDataType : nsISupports
{
    readonly attribute PRBool isPointer;
    readonly attribute PRBool isUniquePointer;
    readonly attribute PRBool isReference;
    readonly attribute PRBool isArithmetic;
    readonly attribute PRBool isInterfacePointer;
    readonly attribute PRBool isArray;
    readonly attribute PRBool isDependent;

    /**
    * This is one of the constants declared in nsIDataType
    */
    readonly attribute PRUint16 dataType;
};

[scriptable, uuid(2309482b-4631-455f-833f-5e4e9ce38589)]
interface nsIScriptableParamInfo : nsISupports
{
    readonly attribute PRBool isIn;
    readonly attribute PRBool isOut;
    readonly attribute PRBool isRetval;
    readonly attribute PRBool isShared;
    readonly attribute PRBool isDipper;

    readonly attribute nsIScriptableDataType type;

    [noscript] void getParamInfo([shared, const, retval] out nsXPTParamInfoPtr aInfo);
};

[scriptable, uuid(0f6c5b09-88b0-43ca-b55c-578f24f3d810)]
interface nsIScriptableConstant : nsISupports
{
    readonly attribute string                name;
    readonly attribute nsIScriptableDataType type;
    readonly attribute nsIVariant            value;
};

[scriptable, uuid(9228afa2-187c-4feb-9228-5108e640ca33)]
interface nsIScriptableMethodInfo : nsISupports
{
    readonly attribute PRBool isGetter;
    readonly attribute PRBool isSetter;
    readonly attribute PRBool isNotXPCOM;
    readonly attribute PRBool isConstructor;
    readonly attribute PRBool isHidden;

    readonly attribute string name;
    readonly attribute PRUint8  paramCount;

    nsIScriptableParamInfo getParam(in PRUint8 idx);

    readonly attribute nsIScriptableParamInfo result;
};

[scriptable, uuid(f902d5ba-2ef6-444e-8a17-52cb70715c10)]
interface nsIScriptableInterfaceInfo : nsISupports
{
    [noscript] attribute nsIInterfaceInfo info;
    
    void init(in nsIIDPtr aIID);
    void initWithName(in string name);

    readonly attribute string   name;
    
    readonly attribute nsIIDPtr interfaceID;

     /** 
     * True if this object has been sucessfully set to wrap an interface info.
     */
    readonly attribute PRBool isValid;

    readonly attribute PRBool isScriptable;

    readonly attribute nsIScriptableInterfaceInfo parent;

    /**
    * These include counts for parent (and all ancestors).
    */
    readonly attribute PRUint16 methodCount;
    readonly attribute PRUint16 constantCount;

    /**
    * These include methods and constants for parent (and all ancestors).
    */
    
    nsIScriptableMethodInfo getMethodInfo(in PRUint16 index);

    nsIScriptableMethodInfo getMethodInfoForName(in string methodName, 
                                                 out PRUint16 index);


    nsIScriptableConstant getConstant(in PRUint16 index);

    /**
    * Get the interface information or iid associated with a param of some
    * method in this interface.
    */

    nsIScriptableInterfaceInfo getInfoForParam(in PRUint16 methodIndex, 
                                               in nsIScriptableParamInfo param);

    nsIIDPtr getIIDForParam(in PRUint16 methodIndex, 
                            in nsIScriptableParamInfo param);


    nsIScriptableDataType getTypeForParam(in PRUint16 methodIndex, 
                                          in nsIScriptableParamInfo param,
                                          in PRUint16 dimension);

    PRUint8 getSizeIsArgNumberForParam(in PRUint16 methodIndex, 
                                       in nsIScriptableParamInfo param,
                                       in PRUint16 dimension);

    PRUint8 getLengthIsArgNumberForParam(in PRUint16 methodIndex, 
                                         in nsIScriptableParamInfo param,
                                         in PRUint16 dimension);

    PRUint8 getInterfaceIsArgNumberForParam(in PRUint16 methodIndex, 
                                            in nsIScriptableParamInfo param);

    PRBool isIID(in nsIIDPtr IID);

    readonly attribute PRBool isFunction;

    PRBool hasAncestor(in nsIIDPtr iid);
};

%{C++
// The contractID for the implementation built in to xpconnect.
#define NS_SCRIPTABLE_INTERFACE_INFO_CONTRACTID "@mozilla.org/scriptableInterfaceInfo;1"
%}
