/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla 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/MPL/
 *
 * 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 the Initial Developer are Copyright (C) 2001
 * the Initial Developer. 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
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

/* 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 successfully 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"
%}
