/*
 * Copyright (C) 2005 Robert Shearman
 *
 * 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 ident
#pragma makedep typelib

#include "tmarshal_dispids.h"
import "ocidl.idl";

[
  uuid(d96d8a3e-78b6-4c8d-8f27-059db959be8a),
  version(2.5),
  helpstring("Test Typelib")
]
library TestTypelib
{
    importlib("stdole2.tlb");

    typedef enum tagSTATE
    {
        STATE_UNWIDGETIFIED = 1,
        STATE_WIDGETIFIED
    } STATE;

    typedef struct tagMYSTRUCT
    {
        INT field1;
        ULONGLONG field2;
        UINT uarr[8];
    } MYSTRUCT;

    coclass ApplicationObject2;

    [
        odl,
        uuid(12345678-1234-4321-1234-121212121212)
    ]
    interface ISomethingFromDispatch : IDispatch
    {
        HRESULT anotherfn(void);
    }

    [
        odl,
        oleautomation,
        dual,
        uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c7967)
    ]
    interface ItestDual : IDispatch
    {
        HRESULT test();
    }

    [
        odl,
        uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c7968)
    ]
    interface ITestSecondIface : IUnknown
    {
        HRESULT test();
    }

    [
        odl,
        oleautomation,
        dual,
        uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c7969)
    ]
    interface ITestSecondDisp : IDispatch
    {
        HRESULT test();
    }

    [
        odl,
        uuid(a1f8cae3-c947-4c5f-b57d-c87b9b5f3586),
        oleautomation,
        dual
    ]
    interface IWidget : IDispatch
    {
        [propput, id(DISPID_TM_NAME)]
        HRESULT Name([in] BSTR name);
        [propget, id(DISPID_TM_NAME)]
        HRESULT Name([out, retval] BSTR *name);

        [id(DISPID_TM_DOSOMETHING)]
        HRESULT DoSomething([in] double number, [out] BSTR *str1, [in, defaultvalue("")] BSTR str2, [in, optional] VARIANT *opt);

        [propget, id(DISPID_TM_STATE)]
        HRESULT State([out, retval] STATE *state);
        [propput, id(DISPID_TM_STATE)]
        HRESULT State([in] STATE state);

        [id(DISPID_TM_MAP)]
        HRESULT Map([in] BSTR bstrId, [out, retval] BSTR *sValue);

        [id(DISPID_TM_SETOLECOLOR)]
        HRESULT SetOleColor([in] OLE_COLOR val);

        [id(DISPID_TM_GETOLECOLOR)]
        HRESULT GetOleColor([out, retval] OLE_COLOR *pVal);

        [propget, id(DISPID_TM_CLONE)]
        HRESULT Clone([out, retval] IWidget **ppVal);

        [propget, id(DISPID_TM_CLONEDISPATCH)]
        HRESULT CloneDispatch([out, retval] IDispatch **ppVal);

        [propget, id(DISPID_TM_CLONECOCLASS)]
        HRESULT CloneCoclass([out, retval] ApplicationObject2 **ppVal);

        [propget, id(DISPID_VALUE)]
        HRESULT Value([in] VARIANT *value, [out, retval] VARIANT *retval);

        [id(DISPID_TM_ARRAY)]
        HRESULT Array([in] SAFEARRAY(BSTR) values);

        [id(DISPID_TM_VARARRAYPTR)]
        HRESULT VariantArrayPtr([in] SAFEARRAY(VARIANT) *values);

        [id(DISPID_TM_VARCARRAY)]
        HRESULT VariantCArray([in] ULONG count, [in, out] VARIANT values[2]);

        [id(DISPID_TM_VARIANT)]
        HRESULT Variant([in] VARIANT var);

        [vararg, id(DISPID_TM_VARARG)]
        HRESULT VarArg([in] int numexpect, [in] SAFEARRAY(VARIANT) values);

        [id(DISPID_TM_STRUCTARGS)]
        HRESULT StructArgs([in] MYSTRUCT byval, [in] MYSTRUCT *byptr, [in] MYSTRUCT arr[5]);

        [id(DISPID_TM_ERROR)]
        HRESULT Error();

        [propget, id(DISPID_TM_CLONEINTERFACE)]
        HRESULT CloneInterface([out, retval] ISomethingFromDispatch **ppVal);

        [id(DISPID_TM_PROP_WITH_LCID), propput]
        HRESULT prop_with_lcid([in,lcid] long lcid, [in] INT i);

        [id(DISPID_TM_PROP_WITH_LCID), propget]
        HRESULT prop_with_lcid([in,lcid] long lcid, [out,retval] INT *i);

        [id(DISPID_TM_PROP_INT), propget]
        HRESULT prop_int([out,retval] INT *i);

        [id(DISPID_TM_PROP_UINT), propget]
        HRESULT prop_uint([out,retval] UINT *i);

        [id(DISPID_TM_BYREF_UINT)]
        HRESULT ByRefUInt([in, out] UINT *i);

        [id(DISPID_TM_PROP_OPT_ARG), propput]
        HRESULT prop_opt_arg([in,optional] INT opt, [in] INT i);

        [id(DISPID_TM_PROP_REQ_ARG), propput]
        HRESULT prop_req_arg([in] INT req, [in] INT i);

        [id(DISPID_TM_RESTRICTED), restricted]
        HRESULT pos_restrict([out, retval] INT *i);

        [id(DISPID_TM_NEG_RESTRICTED), restricted]
        HRESULT neg_restrict([out, retval] INT *i);

        [id(DISPID_TM_VARARG_RUN), vararg]
        HRESULT VarArg_Run([in] BSTR name, [in] SAFEARRAY(VARIANT) params, [out, retval] VARIANT *result);

        [id(DISPID_TM_VARARG_REF_RUN), vararg]
        HRESULT VarArg_Ref_Run([in] BSTR name, [in] SAFEARRAY(VARIANT) *params, [out, retval] VARIANT *result);

        [id(DISPID_TM_COCLASS)]
        HRESULT Coclass([in] ApplicationObject2 *param);
    }

    [
        odl,
        uuid(a1f8cae3-c947-3c5f-a57c-c88b9b6f3586),
        oleautomation,
        dual
    ]
    interface IStaticWidget : IDispatch
    {
        [id(DISPID_TM_TESTDUAL)]
        HRESULT TestDual([in] ItestDual *p);

        [id(DISPID_TM_TESTSECONDIFACE)]
        HRESULT TestSecondIface([in] ITestSecondIface *p);
    }

    [
        odl,
        uuid(a028db05-30f0-4b93-b17a-41c72f831d84),
#if 0 /* FIXME: commented out as causes widl to generate incorrect typelib */
        dual,
#endif
        oleautomation
    ]
    interface IKindaEnumWidget : IUnknown
    {
        HRESULT Next(
                     [out] IWidget **widget);

        HRESULT Count(
                      [out] unsigned long *count);

        HRESULT Reset();

        HRESULT Clone(
                      [out] IKindaEnumWidget **ppenum);
    }

    [
        odl,
        uuid(a028db06-30f0-4b93-b17a-41c72f831d84),
    ]
    interface INonOleAutomation : IUnknown
    {
        [id(DISPID_NOA_BSTRRET)]
        BSTR BstrRet();

        [id(DISPID_NOA_ERROR)]
        HRESULT Error();
    }


    [
        dllname("comm.drv"),
        uuid(d377f60b-8639-4261-8ee7-75c8340d2cc9),
    ]
    module BadModule
    {
        [
            entry("Foo"),
        ]
        HRESULT BadModuleFoo();
    };

    [
        dllname("oleaut32.dll"),
        uuid(d377f60c-8639-4261-8ee7-75c8340d2cc9),
    ]
    module BadEntry
    {
        [
            entry("Foo"),
        ]
        HRESULT BadEntryFoo();
    };

    [
        uuid(bb171948-10ec-407a-9a57-2f85f797ff1a),
        appobject,
    ]
    coclass ApplicationObject2
    {
        interface IWidget;
        [source] interface IWidget;
    };

    [
        odl,
        uuid(375f8a9d-33d0-44f3-b972-61f8407899e0)
    ]
        interface ItestIF1 : IUnknown
    {
        HRESULT fn1([in] int x);
        HRESULT fn2([out,retval] int *x);
    }

    [
        odl,
        uuid(094056a3-666f-4956-be12-1859668310b8)
    ]
    interface ItestIF2 : ItestIF1
    {
        HRESULT fn3([in] int y);
    }

    [
        odl,
        uuid(33baba09-2e68-43ab-81fe-d84b403df2e5)
    ]
    dispinterface ItestIF3
    {
        interface ItestIF2;
    }

    [
        odl,
        uuid(a01005c7-7491-42eb-94f3-668e37ce60a6)
    ]
    dispinterface ItestIF4
    {
        properties:
        methods:
        [id(0x1c)] HRESULT fn([in] int z);
    }

    [
        odl,
        uuid(4ab61e25-c09f-4239-8f7f-7a018ea0199f),
        dual
    ]
    interface ItestIF5 : ItestIF2
    {
        [id(0x1234)] HRESULT fn4([in] int a);
        [id(0x1235)] HRESULT fn5([in] int a);
    }

    [
        odl,
        uuid(ec236d8e-2cc7-44f2-b394-36c86ff3da74)
    ]
    interface ItestIF6 : IDispatch
    {
        [id(0x1234)] HRESULT fn4([in] int a);
        [id(0x1235)] HRESULT fn5([in] int a);
    }

    [
        odl,
        uuid(f711b105-554d-4751-818c-46fcc5d7c0d5),
        dual
    ]
    interface ItestIF7 : ItestIF6
    {
        [id(0x1236)] HRESULT fn6([in] GUID a);
    }

    [
        odl,
        uuid(bdfa260b-ef40-43d3-b071-cddec919f132)
    ]
        interface ItestIF8
    {
        HRESULT fn1([in] int x);
        HRESULT fn2([out,retval] int *x);
    }

    [
        odl,
        uuid(51033a23-dc37-4f19-aa34-4d8a670458a0)

    ]
    interface ItestIF9 : ItestIF8
    {
        HRESULT fn3([in] int y);
    }

    [
        odl,
        uuid(2e8f14fe-0bce-42f0-8b7d-3af8393c7967)
    ]
    dispinterface ItestIF10
    {
        interface ItestIF9;
    }

    [
        odl,
        uuid(7d9e9371-482e-4944-9b19-511fc705236f)
    ]
    dispinterface ItestIF11
    {
        interface ItestIF7;
    }

};
