/*
 * Copyright 2015 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#pragma makedep regtypelib

import "oaidl.idl";

[
    helpstring("Microsoft Script Control 1.0"),
    uuid(0e59f1d2-1fbe-11d0-8ff2-00a0d10038bc),
    version(1.0)
]
library MSScriptControl
{
    importlib("stdole2.tlb");

    typedef enum {
        Initialized = 0,
        Connected = 1
    } ScriptControlStates;

    [
        dual,
        uuid(70841c73-067d-11d0-95d8-00a02463ab28),
        odl,
        hidden,
        nonextensible,
        oleautomation
    ]
    interface IScriptProcedure : IDispatch {
        [id(DISPID_VALUE), propget]
        HRESULT Name([out, retval] BSTR *pbstrName);

        [id(0x0064), propget]
        HRESULT NumArgs([out, retval] long *pcArgs);

        [id(0x0065), propget]
        HRESULT HasReturnValue([out, retval] VARIANT_BOOL *pfHasReturnValue);
    }

    [
        dual,
        uuid(70841c71-067d-11d0-95d8-00a02463ab28),
        odl,
        hidden,
        nonextensible,
        oleautomation
    ]
    interface IScriptProcedureCollection : IDispatch {
        [id(DISPID_NEWENUM), propget]
        HRESULT _NewEnum([out, retval] IUnknown *ppenumProcedures);

        [id(DISPID_VALUE), propget]
        HRESULT Item(
                [in] VARIANT Index,
                [out, retval] IScriptProcedure **ppdispProcedure);

        [id(1), propget]
        HRESULT Count([out, retval] long *plCount);
    }

    [
        dual,
        uuid(70841c70-067d-11d0-95d8-00a02463ab28),
        odl,
        hidden,
        nonextensible,
        oleautomation
    ]
    interface IScriptModule : IDispatch {
        [id(DISPID_VALUE), propget]
        HRESULT Name([out, retval] BSTR *pbstrName);

        [id(0x03e8), propget]
        HRESULT CodeObject([out, retval] IDispatch *ppdispObject);

        [id(0x03e9), propget]
        HRESULT Procedures([out, retval] IScriptProcedureCollection **ppdispProcedures);

        [id(0x07d0)]
        HRESULT AddCode([in] BSTR Code);

        [id(0x07d1)]
        HRESULT Eval(
                [in] BSTR Expression,
                [out, retval] VARIANT *pvarResult);

        [id(0x07d2)]
        HRESULT ExecuteStatement([in] BSTR Statement);

        [id(0x07d3), vararg]
        HRESULT Run(
                [in] BSTR ProcedureName,
                [in] SAFEARRAY(VARIANT) *Parameters,
                [out, retval] VARIANT *pvarResult);
    }

    [
        dual,
        uuid(70841c6f-067d-11d0-95d8-00a02463ab28),
        odl,
        hidden,
        nonextensible,
        oleautomation
    ]
    interface IScriptModuleCollection : IDispatch {
        [id(DISPID_NEWENUM), propget]
        HRESULT _NewEnum([out, retval] IUnknown *ppenumContexts);

        [id(DISPID_VALUE), propget]
        HRESULT Item(
                [in] VARIANT Index,
                [out, retval] IScriptModule **ppmod);

        [id(1), propget]
        HRESULT Count([out, retval] long *plCount);

        [id(2)]
        HRESULT Add(
                [in] BSTR Name,
                [in, optional] VARIANT *Object,
                [out, retval] IScriptModule **ppmod);
    }

    [
        dual,
        uuid(70841c78-067d-11d0-95d8-00a02463ab28),
        odl,
        helpstring("Provides access to scripting error information"),
        helpcontext(0x00113eb6),
        hidden,
        nonextensible,
        oleautomation
    ]
    interface IScriptError : IDispatch {
        [id(0x00c9), propget]
        HRESULT Number([out, retval] long *plNumber);

        [id(0x00ca), propget]
        HRESULT Source([out, retval] BSTR *pbstrSource);

        [id(0x00cb), propget]
        HRESULT Description([out, retval] BSTR *pbstrDescription);

        [id(0x00cc), propget]
        HRESULT HelpFile([out, retval] BSTR *pbstrHelpFile);

        [id(0x00cd), propget]
        HRESULT HelpContext([out, retval] long *plHelpContext);

        [id(0xfffffdfb), propget]
        HRESULT Text([out, retval] BSTR *pbstrText);

        [id(0x00ce), propget]
        HRESULT Line([out, retval] long *plLine);

        [id(0xfffffdef), propget]
        HRESULT Column([out, retval] long *plColumn);

        [id(0x00d0)]
        HRESULT Clear();
    }

     [
        dual,
        uuid(0e59f1d3-1fbe-11d0-8ff2-00a0d10038bc),
        odl,
        hidden,
        nonextensible,
        oleautomation
    ]
    interface IScriptControl : IDispatch {
        [id(0x05dc), propget] HRESULT Language([out, retval] BSTR *pbstrLanguage);
        [id(0x05dc), propput] HRESULT Language([in] BSTR pbstrLanguage);

        [id(0x05dd), propget] HRESULT State([out, retval] ScriptControlStates *pssState);
        [id(0x05dd), propput] HRESULT State([in] ScriptControlStates pssState);

        [id(0x05de), propput] HRESULT SitehWnd([in] long rhs);
        [id(0x05de), propget] HRESULT SitehWnd([out, retval] long *rhs);

        [id(0x05df), propget] HRESULT Timeout([out, retval] long *plMilleseconds);
        [id(0x05df), propput] HRESULT Timeout([in] long plMilleseconds);

        [id(0x05e0), propget] HRESULT AllowUI([out, retval] VARIANT_BOOL *pfAllowUI);
        [id(0x05e0), propput] HRESULT AllowUI([in] VARIANT_BOOL pfAllowUI);

        [id(0x05e1), propget] HRESULT UseSafeSubset([out, retval] VARIANT_BOOL *pfUseSafeSubset);
        [id(0x05e1), propput] HRESULT UseSafeSubset([in] VARIANT_BOOL pfUseSafeSubset);

        [id(0x05e2), propget] HRESULT Modules([out, retval] IScriptModuleCollection **ppmods);

        [id(0x05e3), propget] HRESULT Error([out, retval] IScriptError **ppse);

        [id(0x03e8), propget] HRESULT CodeObject([out, retval] IDispatch **ppdispObject);

        [id(0x03e9), propget] HRESULT Procedures([out, retval] IScriptProcedureCollection **ppdispProcedures);

        [id(0xfffffdd8)]
        HRESULT _AboutBox();

        [id(0x09c4)]
        HRESULT AddObject(
                [in] BSTR Name,
                [in] IDispatch *Object,
                [in, optional, defaultvalue(0)] VARIANT_BOOL AddMembers);

        [id(0x09c5)]
        HRESULT Reset();

        [id(0x07d0)]
        HRESULT AddCode([in] BSTR Code);

        [id(0x07d1)]
        HRESULT Eval(
                [in] BSTR Expression,
                [out, retval] VARIANT *pvarResult);

        [id(0x07d2)]
        HRESULT ExecuteStatement([in] BSTR Statement);

        [id(0x07d3), vararg]
        HRESULT Run(
                [in] BSTR ProcedureName,
                [in] SAFEARRAY(VARIANT) *Parameters,
                [out, retval] VARIANT *pvarResult);
    }

    [
        uuid(8b167d60-8605-11d0-abcb-00a0c90fffc0),
        hidden
    ]
    dispinterface DScriptControlSource {
    properties:
    methods:
        [id(0x0bb8)] void Error();
        [id(0x0bb9)] void Timeout();
    }

    [
        uuid(0e59f1da-1fbe-11d0-8ff2-00a0d10038bc),
        noncreatable
    ]
    coclass Procedure {
        [default] interface IScriptProcedure;
    }

    [
        uuid(0e59f1db-1fbe-11d0-8ff2-00a0d10038bc),
        noncreatable
    ]
    coclass Procedures {
        [default] interface IScriptProcedureCollection;
    }

    [
        uuid(0e59f1dc-1fbe-11d0-8ff2-00a0d10038bc),
        noncreatable
    ]
    coclass Module {
        [default] interface IScriptModule;
    }

    [
        uuid(0e59f1dd-1fbe-11d0-8ff2-00a0d10038bc),
        noncreatable
    ]
    coclass Modules {
        [default] interface IScriptModuleCollection;
    }

    [
        uuid(0e59f1de-1fbe-11d0-8ff2-00a0d10038bc),
        noncreatable
    ]
    coclass Error {
        [default] interface IScriptError;
    }

    [
        helpstring("ScriptControl Object"),
        uuid(0e59f1d5-1fbe-11d0-8ff2-00a0d10038bc),
        threading(apartment),
        progid("MSScriptControl.ScriptControl.1"),
        vi_progid("MSScriptControl.ScriptControl")
    ]
    coclass ScriptControl {
        [default] interface  IScriptControl;
        [default, source] dispinterface DScriptControlSource;
    }
}
