/*
 * 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

import "ocidl.idl";

enum IWidget_dispids
{
    DISPID_TM_NAME = 1,
    DISPID_TM_DOSOMETHING,
    DISPID_TM_STATE,
    DISPID_TM_MAP,
    DISPID_TM_SETOLECOLOR,
    DISPID_TM_GETOLECOLOR,
    DISPID_TM_CLONE,
    DISPID_TM_CLONEDISPATCH,
    DISPID_TM_CLONECOCLASS,
    DISPID_TM_VALUE,
    DISPID_TM_VARARRAYPTR,
    DISPID_TM_VARARG,
    DISPID_TM_ERROR,
    DISPID_TM_CLONEINTERFACE,
    DISPID_TM_TESTDUAL,
    DISPID_TM_PROP_WITH_LCID,
    DISPID_TM_PROP_INT,
    DISPID_TM_PROP_UINT,
    DISPID_TM_BYREF_UINT,
    DISPID_TM_PROP_OPT_ARG,
    DISPID_TM_PROP_REQ_ARG,
    DISPID_TM_RESTRICTED,
    DISPID_TM_TESTSECONDIFACE,
    DISPID_TM_VARARG_RUN,
    DISPID_TM_VARARG_REF_RUN,

    DISPID_TM_BASETYPES_IN,
    DISPID_TM_BASETYPES_OUT,
    DISPID_TM_FLOAT_ABI,
    DISPID_TM_INT_PTR,
    DISPID_TM_INT_PTR_PTR,
    DISPID_TM_IFACE_IN,
    DISPID_TM_IFACE_OUT,
    DISPID_TM_IFACE_PTR,
    DISPID_TM_IFACE_NOPTR,
    DISPID_TM_BSTR,
    DISPID_TM_VARIANT,
    DISPID_TM_SAFEARRAY,
    DISPID_TM_STRUCT,
    DISPID_TM_STRUCT_PTR_PTR,
    DISPID_TM_THIN_STRUCT,
    DISPID_TM_RECT,
    DISPID_TM_COMPLEX_STRUCT,
    DISPID_TM_ARRAY,
    DISPID_TM_VARIANT_ARRAY,
    DISPID_TM_STRUCT_ARRAY,
    DISPID_TM_TYPEDEF,
    DISPID_TM_COCLASS,
    DISPID_TM_COCLASS_PTR,
    DISPID_TM_COCLASS_NOPTR,
    DISPID_TM_NOINOUT
};

static const int DISPID_TM_NEG_RESTRICTED = -26;

enum INonOleAutomation_dispids
{
    DISPID_NOA_BSTRRET = 1,
    DISPID_NOA_ERROR
};

[
  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;

    typedef [public] int myint_t;

    typedef int array_t[4];

    coclass ApplicationObject2;

    [
        odl,
        oleautomation,
        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();
    }

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

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

cpp_quote("struct Coclass1 { ICoclass1 *iface; };")
cpp_quote("struct Coclass2 { ICoclass2 *iface; };")
cpp_quote("struct Coclass3 { ICoclass1 *iface; };")

    [
        uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796c)
    ]
    coclass Coclass1
    {
        [default] interface ICoclass1;
        interface ICoclass2;
    }

    [
        uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796d)
    ]
    coclass Coclass2
    {
        interface ICoclass1;
        [default] interface ICoclass2;
    }

    [
        uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796e)
    ]
    coclass Coclass3
    {
        interface ICoclass1;
        interface ICoclass2;
    }

    [
        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_VARARRAYPTR)]
        HRESULT VariantArrayPtr([in] SAFEARRAY(VARIANT) *values);

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

        [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_BASETYPES_IN)]
        HRESULT basetypes_in([in] signed char c, [in] short s, [in] int i, [in] hyper h,
                [in] unsigned char uc, [in] unsigned short us, [in] unsigned int ui,
                [in] unsigned hyper uh, [in] float f, [in] double d, [in] STATE st);

        [id(DISPID_TM_BASETYPES_OUT)]
        HRESULT basetypes_out([out] signed char *c, [out] short *s, [out] int *i, [out] hyper *h,
                [out] unsigned char *uc, [out] unsigned short *us, [out] unsigned int *ui,
                [out] unsigned hyper *uh, [out] float *f, [out] double *d, [out] STATE *st);

        [id(DISPID_TM_FLOAT_ABI)]
        HRESULT float_abi([in] float f, [in] double d, [in] int i, [in] float f2, [in] double d2);

        [id(DISPID_TM_INT_PTR)]
        HRESULT int_ptr([in] int *in, [out] int *out, [in, out] int *in_out);

        [id(DISPID_TM_INT_PTR_PTR)]
        HRESULT int_ptr_ptr([in] int **in, [out] int **out, [in, out] int **in_out);

        [id(DISPID_TM_IFACE_IN)]
        HRESULT iface_in([in] IUnknown *unk, [in] IDispatch *disp, [in] ISomethingFromDispatch *sfd);

        [id(DISPID_TM_IFACE_OUT)]
        HRESULT iface_out([out] IUnknown **unk, [out] IDispatch **disp, [out] ISomethingFromDispatch **sfd);

        [id(DISPID_TM_IFACE_PTR)]
        HRESULT iface_ptr([in] ISomethingFromDispatch **in, [out] ISomethingFromDispatch **out, [in, out] ISomethingFromDispatch **in_out);

        [id(DISPID_TM_IFACE_NOPTR)]
        HRESULT iface_noptr([in] IUnknown unk, [in] IDispatch disp, [in] ISomethingFromDispatch sfd);

        [id(DISPID_TM_BSTR)]
        HRESULT bstr([in] BSTR in, [out] BSTR *out, [in] BSTR *in_ptr, [in, out] BSTR *in_out);

        [id(DISPID_TM_VARIANT)]
        HRESULT variant([in] VARIANT in, [out] VARIANT *out, [in] VARIANT *in_ptr, [in, out] VARIANT *in_out);

        [id(DISPID_TM_SAFEARRAY)]
        HRESULT safearray([in] SAFEARRAY(int) in, [out] SAFEARRAY(int) *out, [in] SAFEARRAY(int) *in_ptr, [in, out] SAFEARRAY(int) *in_out);

        [id(DISPID_TM_STRUCT)]
        HRESULT mystruct([in] MYSTRUCT in, [out] MYSTRUCT *out, [in] MYSTRUCT *in_ptr, [in, out] MYSTRUCT *in_out);

        [id(DISPID_TM_STRUCT_PTR_PTR)]
        HRESULT mystruct_ptr_ptr([in] MYSTRUCT **in);

        struct thin
        {
            short a;
            char b;
        };

        [id(DISPID_TM_THIN_STRUCT)]
        HRESULT thin_struct([in] struct thin in);

        [id(DISPID_TM_RECT)]
        HRESULT rect([in] RECT in, [out] RECT *out, [in] RECT *in_ptr, [in, out] RECT *in_out);

        struct complex
        {
            char c;
            int i;
            int *pi;
            int **ppi;
            ISomethingFromDispatch *iface;
            ISomethingFromDispatch **iface_ptr;
            BSTR bstr;
            VARIANT var;
            MYSTRUCT mystruct;
            array_t arr;
            myint_t myint;
        };

        [id(DISPID_TM_COMPLEX_STRUCT)]
        HRESULT complex_struct([in] struct complex in);

        [id(DISPID_TM_ARRAY)]
        HRESULT array([in] array_t in, [out] array_t out, [in, out] array_t in_out);

        [id(DISPID_TM_VARIANT_ARRAY)]
        HRESULT variant_array([in] VARIANT in[2], [out] VARIANT out[2], [in, out] VARIANT in_out[2]);

        [id(DISPID_TM_STRUCT_ARRAY)]
        HRESULT mystruct_array([in] MYSTRUCT in[2]);

        [id(DISPID_TM_TYPEDEF)]
        HRESULT myint([in] myint_t val, [in] myint_t *ptr, [in] myint_t **ptr_ptr);

        [id(DISPID_TM_COCLASS)]
        HRESULT Coclass([in] Coclass1 *class1, [in] Coclass2 *class2, [in] Coclass3 *class3);

        [id(DISPID_TM_COCLASS_PTR)]
        HRESULT Coclass_ptr([in] Coclass1 **in, [out] Coclass1 **out, [in, out] Coclass1 **in_out);

        [id(DISPID_TM_COCLASS_NOPTR)]
        HRESULT Coclass_noptr([in] Coclass1 class1, [in] Coclass2 class2, [in] Coclass3 class3);

        [id(DISPID_TM_NOINOUT)]
        HRESULT no_in_out(BSTR str, int i);
    }

    [
        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),
        dual,
        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;
    }

    [
        object,
        uuid(ec236d8e-2cc7-44f2-b394-46c86ff3da74),
        dual,
        oleautomation
    ]
    interface ItestIF12 : IDispatch
    {
        [id(0x1234)] HRESULT fn4([in] int a);
        [id(0x1235)] HRESULT fn5([in] int a);
    }

    [
        object,
        uuid(f711b105-554d-4751-818c-56fcc5d7c0d5),
        dual,
        oleautomation
    ]
    interface ItestIF13 : ItestIF12
    {
        [id(0x1236)] HRESULT fn6([in] GUID a);
    }

};
