From 936851e20d7e5882a7ac202c2161b633fa261ea6 Mon Sep 17 00:00:00 2001 From: "KJK::Hyperion" Date: Thu, 15 Jan 2009 17:52:35 +0000 Subject: [PATCH] Sync widl, comcat, ole32, oleaut32 and rpcrt4 to wine 1.1.12 widl can now automatically generate boilerplate code for DLLs hosting RPC proxies (and ole32 and oleaut32 now use this feature): invoke the generation automatically from rbuild rules for rpcproxy modules svn path=/trunk/; revision=38774 --- reactos/base/services/rpcss/rpcss.rbuild | 4 +- reactos/dll/win32/comcat/comcat.rbuild | 5 - reactos/dll/win32/comcat/comcat.spec | 2 +- reactos/dll/win32/comcat/comcat_main.c | 49 +- reactos/dll/win32/comcat/comcat_private.h | 73 - reactos/dll/win32/comcat/factory.c | 149 - reactos/dll/win32/comcat/information.c | 968 ----- reactos/dll/win32/comcat/manager.c | 120 - reactos/dll/win32/comcat/register.c | 342 -- reactos/dll/win32/comcat/regsvr.c | 418 -- reactos/dll/win32/ole32/classmoniker.c | 4 +- reactos/dll/win32/ole32/clipboard.c | 18 +- reactos/dll/win32/ole32/comcat.c | 4 +- reactos/dll/win32/ole32/compobj.c | 107 +- reactos/dll/win32/ole32/compobj_private.h | 10 +- reactos/dll/win32/ole32/defaulthandler.c | 52 +- reactos/dll/win32/ole32/errorinfo.c | 4 +- reactos/dll/win32/ole32/filemoniker.c | 9 +- reactos/dll/win32/ole32/itemmoniker.c | 8 +- reactos/dll/win32/ole32/memlockbytes16.c | 2 +- reactos/dll/win32/ole32/moniker.c | 6 +- reactos/dll/win32/ole32/ole16.c | 2 +- reactos/dll/win32/ole32/ole2.c | 32 +- reactos/dll/win32/ole32/ole2_16.c | 2 +- reactos/dll/win32/ole32/ole32.rbuild | 6 + reactos/dll/win32/ole32/ole32.spec | 2 + reactos/dll/win32/ole32/ole32_ros.diff | 12 - reactos/dll/win32/ole32/oleproxy.c | 25 +- reactos/dll/win32/ole32/regsvr.c | 48 +- reactos/dll/win32/ole32/stg_bigblockfile.c | 4 +- reactos/dll/win32/ole32/storage.c | 43 +- reactos/dll/win32/ole32/storage.spec | 9 +- reactos/dll/win32/ole32/storage32.c | 2 +- reactos/dll/win32/ole32/stubmanager.c | 2 +- reactos/dll/win32/ole32/usrmarshal.c | 23 +- reactos/dll/win32/oleaut32/dispatch.c | 4 +- reactos/dll/win32/oleaut32/oleaut.c | 21 +- reactos/dll/win32/oleaut32/oleaut32.rbuild | 12 + reactos/dll/win32/oleaut32/oleaut32_Ko.rc | 2 +- reactos/dll/win32/oleaut32/oleaut32_ocidl.idl | 1 - reactos/dll/win32/oleaut32/olefont.c | 6 +- reactos/dll/win32/oleaut32/olepicture.c | 98 +- reactos/dll/win32/oleaut32/recinfo.c | 10 +- reactos/dll/win32/oleaut32/regsvr.c | 404 +- reactos/dll/win32/oleaut32/safearray.c | 8 +- reactos/dll/win32/oleaut32/tmarshal.c | 6 +- reactos/dll/win32/oleaut32/typelib.c | 332 +- reactos/dll/win32/oleaut32/typelib2.c | 4 +- reactos/dll/win32/oleaut32/ungif.c | 12 +- reactos/dll/win32/oleaut32/usrmarshal.c | 36 +- reactos/dll/win32/oleaut32/varformat.c | 5 +- reactos/dll/win32/oleaut32/variant.c | 16 +- reactos/dll/win32/oleaut32/vartype.c | 8 +- reactos/dll/win32/rpcrt4/cproxy.c | 2 +- reactos/dll/win32/rpcrt4/cpsf.c | 111 +- reactos/dll/win32/rpcrt4/ndr_fullpointer.c | 6 +- reactos/dll/win32/rpcrt4/ndr_marshall.c | 2 +- reactos/dll/win32/rpcrt4/ndr_stubless.c | 4 +- reactos/dll/win32/rpcrt4/rpc_server.c | 2 + reactos/dll/win32/rpcrt4/rpc_transport.c | 19 +- reactos/dll/win32/rpcrt4/rpcrt4.rbuild | 1 + reactos/dll/win32/rpcrt4/rpcrt4_main.c | 2 +- reactos/include/psdk/rpcndr.h | 21 +- reactos/include/psdk/rpcproxy.h | 25 +- reactos/include/psdk/stdole2.idl | 6 - reactos/include/reactos/wine/irot.idl | 105 +- .../rbuild/backend/mingw/modulehandler.cpp | 42 + .../rbuild/backend/mingw/modulehandler.h | 1 + reactos/tools/rbuild/backend/mingw/rule.cpp | 1 + reactos/tools/widl/client.c | 198 +- reactos/tools/widl/expr.c | 62 +- reactos/tools/widl/expr.h | 3 +- reactos/tools/widl/header.c | 358 +- reactos/tools/widl/header.h | 28 +- reactos/tools/widl/parser.h | 3 + reactos/tools/widl/parser.l | 21 +- reactos/tools/widl/parser.tab.c | 3868 ++++++++--------- reactos/tools/widl/parser.tab.h | 3 +- reactos/tools/widl/parser.y | 807 ++-- reactos/tools/widl/parser.yy.c | 97 +- reactos/tools/widl/proxy.c | 371 +- reactos/tools/widl/server.c | 161 +- reactos/tools/widl/typegen.c | 627 ++- reactos/tools/widl/typegen.h | 11 +- reactos/tools/widl/typelib.c | 19 +- reactos/tools/widl/typelib.h | 2 - reactos/tools/widl/typetree.c | 98 + reactos/tools/widl/typetree.h | 107 + reactos/tools/widl/widl.c | 155 +- reactos/tools/widl/widl.h | 14 +- reactos/tools/widl/widl.rbuild | 1 + reactos/tools/widl/widltypes.h | 35 +- reactos/tools/widl/write_msft.c | 90 +- 93 files changed, 4780 insertions(+), 6260 deletions(-) delete mode 100644 reactos/dll/win32/comcat/comcat_private.h delete mode 100644 reactos/dll/win32/comcat/factory.c delete mode 100644 reactos/dll/win32/comcat/information.c delete mode 100644 reactos/dll/win32/comcat/manager.c delete mode 100644 reactos/dll/win32/comcat/register.c delete mode 100644 reactos/dll/win32/comcat/regsvr.c delete mode 100644 reactos/dll/win32/ole32/ole32_ros.diff create mode 100644 reactos/tools/widl/typetree.c create mode 100644 reactos/tools/widl/typetree.h diff --git a/reactos/base/services/rpcss/rpcss.rbuild b/reactos/base/services/rpcss/rpcss.rbuild index 30311f3011d..1bb6ff3b670 100644 --- a/reactos/base/services/rpcss/rpcss.rbuild +++ b/reactos/base/services/rpcss/rpcss.rbuild @@ -18,9 +18,9 @@ irot.idl rpcss.rc - + epm.idl - + irot.idl diff --git a/reactos/dll/win32/comcat/comcat.rbuild b/reactos/dll/win32/comcat/comcat.rbuild index f686d1bb8d7..1d936cb2e95 100644 --- a/reactos/dll/win32/comcat/comcat.rbuild +++ b/reactos/dll/win32/comcat/comcat.rbuild @@ -15,10 +15,5 @@ uuid ntdll comcat_main.c - factory.c - information.c - manager.c - register.c - regsvr.c version.rc diff --git a/reactos/dll/win32/comcat/comcat.spec b/reactos/dll/win32/comcat/comcat.spec index b16365d0c9f..5b5f7b06cb1 100644 --- a/reactos/dll/win32/comcat/comcat.spec +++ b/reactos/dll/win32/comcat/comcat.spec @@ -1,4 +1,4 @@ @ stdcall -private DllCanUnloadNow() -@ stdcall -private DllGetClassObject(ptr ptr ptr) +@ stdcall -private DllGetClassObject(ptr ptr ptr) ole32.DllGetClassObject @ stdcall -private DllRegisterServer() @ stdcall -private DllUnregisterServer() diff --git a/reactos/dll/win32/comcat/comcat_main.c b/reactos/dll/win32/comcat/comcat_main.c index 258f57598f1..83fc0eefe22 100644 --- a/reactos/dll/win32/comcat/comcat_main.c +++ b/reactos/dll/win32/comcat/comcat_main.c @@ -18,38 +18,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "comcat_private.h" +#include -#include "wine/debug.h" +#define COBJMACROS -WINE_DEFAULT_DEBUG_CHANNEL(ole); - -LONG dll_ref = 0; - -/*********************************************************************** - * Global string constant definitions - */ -const WCHAR clsid_keyname[6] = { 'C', 'L', 'S', 'I', 'D', 0 }; - -/*********************************************************************** - * DllGetClassObject (COMCAT.@) - */ -HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) -{ - *ppv = NULL; - if (IsEqualGUID(rclsid, &CLSID_StdComponentCategoriesMgr)) { - return IClassFactory_QueryInterface((LPCLASSFACTORY)&COMCAT_ClassFactory, iid, ppv); - } - FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid)); - return CLASS_E_CLASSNOTAVAILABLE; -} +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winreg.h" +#include "winerror.h" +#include "ole2.h" /*********************************************************************** * DllCanUnloadNow (COMCAT.@) */ HRESULT WINAPI DllCanUnloadNow(void) { - return dll_ref != 0 ? S_FALSE : S_OK; + return S_FALSE; } -/* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */ +/*********************************************************************** + * DllRegisterServer (COMCAT.@) + */ +HRESULT WINAPI DllRegisterServer(void) +{ + return S_OK; +} + +/*********************************************************************** + * DllUnregisterServer (COMCAT.@) + */ +HRESULT WINAPI DllUnregisterServer(void) +{ + return S_OK; +} diff --git a/reactos/dll/win32/comcat/comcat_private.h b/reactos/dll/win32/comcat/comcat_private.h deleted file mode 100644 index 4002dfd0c96..00000000000 --- a/reactos/dll/win32/comcat/comcat_private.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * includes for comcat.dll - * - * Copyright (C) 2002 John K. Hohm - * - * 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 - */ - -#include - -#define COBJMACROS - -#include "windef.h" -#include "winbase.h" -#include "winuser.h" -#include "winreg.h" -#include "winerror.h" - -#include "ole2.h" -#include "comcat.h" -#include "wine/unicode.h" - -#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field)) - -/********************************************************************** - * Dll lifetime tracking declaration for comcat.dll - */ -extern LONG dll_ref; - -/********************************************************************** - * ClassFactory declaration for comcat.dll - */ -typedef struct -{ - /* IUnknown fields */ - const IClassFactoryVtbl *lpVtbl; - LONG ref; -} ClassFactoryImpl; - -extern ClassFactoryImpl COMCAT_ClassFactory; - -/********************************************************************** - * StdComponentCategoriesMgr declaration for comcat.dll - */ -typedef struct -{ - /* IUnknown fields */ - const IUnknownVtbl *unkVtbl; - const ICatRegisterVtbl *regVtbl; - const ICatInformationVtbl *infVtbl; - LONG ref; -} ComCatMgrImpl; - -extern ComCatMgrImpl COMCAT_ComCatMgr; -extern const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl; -extern const ICatInformationVtbl COMCAT_ICatInformation_Vtbl; - -/********************************************************************** - * Global string constant declarations - */ -extern const WCHAR clsid_keyname[6]; diff --git a/reactos/dll/win32/comcat/factory.c b/reactos/dll/win32/comcat/factory.c deleted file mode 100644 index 575c9675fc0..00000000000 --- a/reactos/dll/win32/comcat/factory.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * ClassFactory implementation for comcat.dll - * - * Copyright (C) 2002 John K. Hohm - * - * 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 - */ - -#include "comcat_private.h" - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ole); - -static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface); - -/********************************************************************** - * COMCAT_IClassFactory_QueryInterface (also IUnknown) - */ -static HRESULT WINAPI COMCAT_IClassFactory_QueryInterface( - LPCLASSFACTORY iface, - REFIID riid, - LPVOID *ppvObj) -{ - ClassFactoryImpl *This = (ClassFactoryImpl *)iface; - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IClassFactory)) - { - *ppvObj = (LPVOID)iface; - COMCAT_IClassFactory_AddRef(iface); - return S_OK; - } - - return E_NOINTERFACE; -} - -/********************************************************************** - * COMCAT_IClassFactory_AddRef (also IUnknown) - */ -static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface) -{ - ClassFactoryImpl *This = (ClassFactoryImpl *)iface; - ULONG ref; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - ref = InterlockedIncrement(&This->ref); - if (ref == 1) { - InterlockedIncrement(&dll_ref); - } - return ref; -} - -/********************************************************************** - * COMCAT_IClassFactory_Release (also IUnknown) - */ -static ULONG WINAPI COMCAT_IClassFactory_Release(LPCLASSFACTORY iface) -{ - ClassFactoryImpl *This = (ClassFactoryImpl *)iface; - ULONG ref; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - InterlockedDecrement(&dll_ref); - } - return ref; -} - -/********************************************************************** - * COMCAT_IClassFactory_CreateInstance - */ -static HRESULT WINAPI COMCAT_IClassFactory_CreateInstance( - LPCLASSFACTORY iface, - LPUNKNOWN pUnkOuter, - REFIID riid, - LPVOID *ppvObj) -{ - ClassFactoryImpl *This = (ClassFactoryImpl *)iface; - HRESULT res; - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - /* Don't support aggregation (Windows doesn't) */ - if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION; - - res = IUnknown_QueryInterface((LPUNKNOWN)&COMCAT_ComCatMgr, riid, ppvObj); - if (SUCCEEDED(res)) { - return res; - } - - return CLASS_E_CLASSNOTAVAILABLE; -} - -/********************************************************************** - * COMCAT_IClassFactory_LockServer - */ -static HRESULT WINAPI COMCAT_IClassFactory_LockServer( - LPCLASSFACTORY iface, - BOOL fLock) -{ - TRACE("\n"); - - if (fLock != FALSE) { - IClassFactory_AddRef(iface); - } else { - IClassFactory_Release(iface); - } - return S_OK; -} - -/********************************************************************** - * IClassFactory_Vtbl - */ -static const IClassFactoryVtbl IClassFactory_Vtbl = -{ - COMCAT_IClassFactory_QueryInterface, - COMCAT_IClassFactory_AddRef, - COMCAT_IClassFactory_Release, - COMCAT_IClassFactory_CreateInstance, - COMCAT_IClassFactory_LockServer -}; - -/********************************************************************** - * static ClassFactory instance - */ -ClassFactoryImpl COMCAT_ClassFactory = { &IClassFactory_Vtbl, 0 }; diff --git a/reactos/dll/win32/comcat/information.c b/reactos/dll/win32/comcat/information.c deleted file mode 100644 index cd5a9ea9dd9..00000000000 --- a/reactos/dll/win32/comcat/information.c +++ /dev/null @@ -1,968 +0,0 @@ -/* - * ComCatMgr ICatInformation implementation for comcat.dll - * - * Copyright (C) 2002 John K. Hohm - * - * 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 - */ - -#include -#include "comcat_private.h" - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ole); - -static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid); -static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc, - ULONG buf_wchars); - -struct class_categories { - LPCWSTR impl_strings; - LPCWSTR req_strings; -}; - -static struct class_categories *COMCAT_PrepareClassCategories( - ULONG impl_count, const CATID *impl_catids, ULONG req_count, const CATID *req_catids); -static HRESULT COMCAT_IsClassOfCategories( - HKEY key, struct class_categories const* class_categories); -static LPENUMGUID COMCAT_CLSID_IEnumGUID_Construct( - struct class_categories *class_categories); -static LPENUMGUID COMCAT_CATID_IEnumGUID_Construct( - REFCLSID rclsid, LPCWSTR impl_req); - -/********************************************************************** - * COMCAT_ICatInformation_QueryInterface - */ -static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface( - LPCATINFORMATION iface, - REFIID riid, - LPVOID *ppvObj) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - return IUnknown_QueryInterface((LPUNKNOWN)&This->unkVtbl, riid, ppvObj); -} - -/********************************************************************** - * COMCAT_ICatInformation_AddRef - */ -static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - return IUnknown_AddRef((LPUNKNOWN)&This->unkVtbl); -} - -/********************************************************************** - * COMCAT_ICatInformation_Release - */ -static ULONG WINAPI COMCAT_ICatInformation_Release(LPCATINFORMATION iface) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - return IUnknown_Release((LPUNKNOWN)&This->unkVtbl); -} - -/********************************************************************** - * COMCAT_ICatInformation_EnumCategories - */ -static HRESULT WINAPI COMCAT_ICatInformation_EnumCategories( - LPCATINFORMATION iface, - LCID lcid, - LPENUMCATEGORYINFO *ppenumCatInfo) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - TRACE("\n"); - - if (iface == NULL || ppenumCatInfo == NULL) return E_POINTER; - - *ppenumCatInfo = COMCAT_IEnumCATEGORYINFO_Construct(lcid); - if (*ppenumCatInfo == NULL) return E_OUTOFMEMORY; - IEnumCATEGORYINFO_AddRef(*ppenumCatInfo); - return S_OK; -} - -/********************************************************************** - * COMCAT_ICatInformation_GetCategoryDesc - */ -static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc( - LPCATINFORMATION iface, - REFCATID rcatid, - LCID lcid, - PWCHAR *ppszDesc) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - WCHAR keyname[60] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n', - 't', ' ', 'C', 'a', 't', 'e', 'g', 'o', - 'r', 'i', 'e', 's', '\\', 0 }; - HKEY key; - HRESULT res; - - TRACE("\n\tCATID:\t%s\n\tLCID:\t%X\n",debugstr_guid(rcatid), lcid); - - if (rcatid == NULL || ppszDesc == NULL) return E_INVALIDARG; - - /* Open the key for this category. */ - if (!StringFromGUID2(rcatid, keyname + 21, 39)) return E_FAIL; - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &key); - if (res != ERROR_SUCCESS) return CAT_E_CATIDNOEXIST; - - /* Allocate a sensible amount of memory for the description. */ - *ppszDesc = (PWCHAR) CoTaskMemAlloc(128 * sizeof(WCHAR)); - if (*ppszDesc == NULL) { - RegCloseKey(key); - return E_OUTOFMEMORY; - } - - /* Get the description, and make sure it's null terminated. */ - res = COMCAT_GetCategoryDesc(key, lcid, *ppszDesc, 128); - RegCloseKey(key); - if (FAILED(res)) { - CoTaskMemFree(*ppszDesc); - return res; - } - - return S_OK; -} - -/********************************************************************** - * COMCAT_ICatInformation_EnumClassesOfCategories - */ -static HRESULT WINAPI COMCAT_ICatInformation_EnumClassesOfCategories( - LPCATINFORMATION iface, - ULONG cImplemented, - CATID *rgcatidImpl, - ULONG cRequired, - CATID *rgcatidReq, - LPENUMCLSID *ppenumCLSID) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - struct class_categories *categories; - - TRACE("\n"); - - if (cImplemented == (ULONG)-1) - cImplemented = 0; - if (cRequired == (ULONG)-1) - cRequired = 0; - - if (iface == NULL || ppenumCLSID == NULL || - (cImplemented && rgcatidImpl == NULL) || - (cRequired && rgcatidReq == NULL)) return E_POINTER; - - categories = COMCAT_PrepareClassCategories(cImplemented, rgcatidImpl, - cRequired, rgcatidReq); - if (categories == NULL) return E_OUTOFMEMORY; - *ppenumCLSID = COMCAT_CLSID_IEnumGUID_Construct(categories); - if (*ppenumCLSID == NULL) { - HeapFree(GetProcessHeap(), 0, categories); - return E_OUTOFMEMORY; - } - IEnumGUID_AddRef(*ppenumCLSID); - return S_OK; -} - -/********************************************************************** - * COMCAT_ICatInformation_IsClassOfCategories - */ -static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories( - LPCATINFORMATION iface, - REFCLSID rclsid, - ULONG cImplemented, - CATID *rgcatidImpl, - ULONG cRequired, - CATID *rgcatidReq) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - WCHAR keyname[45] = { 'C', 'L', 'S', 'I', 'D', '\\', 0 }; - HRESULT res; - struct class_categories *categories; - HKEY key; - - if (WINE_TRACE_ON(ole)) { - ULONG count; - TRACE("\n\tCLSID:\t%s\n\tImplemented %u\n",debugstr_guid(rclsid),cImplemented); - for (count = 0; count < cImplemented; ++count) - TRACE("\t\t%s\n",debugstr_guid(&rgcatidImpl[count])); - TRACE("\tRequired %u\n",cRequired); - for (count = 0; count < cRequired; ++count) - TRACE("\t\t%s\n",debugstr_guid(&rgcatidReq[count])); - } - - if ((cImplemented && rgcatidImpl == NULL) || - (cRequired && rgcatidReq == NULL)) return E_POINTER; - - res = StringFromGUID2(rclsid, keyname + 6, 39); - if (FAILED(res)) return res; - - categories = COMCAT_PrepareClassCategories(cImplemented, rgcatidImpl, - cRequired, rgcatidReq); - if (categories == NULL) return E_OUTOFMEMORY; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &key); - if (res == ERROR_SUCCESS) { - res = COMCAT_IsClassOfCategories(key, categories); - RegCloseKey(key); - } else res = S_FALSE; - - HeapFree(GetProcessHeap(), 0, categories); - - return res; -} - -/********************************************************************** - * COMCAT_ICatInformation_EnumImplCategoriesOfClass - */ -static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass( - LPCATINFORMATION iface, - REFCLSID rclsid, - LPENUMCATID *ppenumCATID) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - static const WCHAR postfix[24] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e', - 'n', 't', 'e', 'd', ' ', 'C', 'a', 't', - 'e', 'g', 'o', 'r', 'i', 'e', 's', 0 }; - - TRACE("\n\tCLSID:\t%s\n",debugstr_guid(rclsid)); - - if (iface == NULL || rclsid == NULL || ppenumCATID == NULL) - return E_POINTER; - - *ppenumCATID = COMCAT_CATID_IEnumGUID_Construct(rclsid, postfix); - if (*ppenumCATID == NULL) return E_OUTOFMEMORY; - return S_OK; -} - -/********************************************************************** - * COMCAT_ICatInformation_EnumReqCategoriesOfClass - */ -static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass( - LPCATINFORMATION iface, - REFCLSID rclsid, - LPENUMCATID *ppenumCATID) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - static const WCHAR postfix[21] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e', - 'd', ' ', 'C', 'a', 't', 'e', 'g', 'o', - 'r', 'i', 'e', 's', 0 }; - - TRACE("\n\tCLSID:\t%s\n",debugstr_guid(rclsid)); - - if (iface == NULL || rclsid == NULL || ppenumCATID == NULL) - return E_POINTER; - - *ppenumCATID = COMCAT_CATID_IEnumGUID_Construct(rclsid, postfix); - if (*ppenumCATID == NULL) return E_OUTOFMEMORY; - return S_OK; -} - -/********************************************************************** - * COMCAT_ICatInformation_Vtbl - */ -const ICatInformationVtbl COMCAT_ICatInformation_Vtbl = -{ - COMCAT_ICatInformation_QueryInterface, - COMCAT_ICatInformation_AddRef, - COMCAT_ICatInformation_Release, - COMCAT_ICatInformation_EnumCategories, - COMCAT_ICatInformation_GetCategoryDesc, - COMCAT_ICatInformation_EnumClassesOfCategories, - COMCAT_ICatInformation_IsClassOfCategories, - COMCAT_ICatInformation_EnumImplCategoriesOfClass, - COMCAT_ICatInformation_EnumReqCategoriesOfClass -}; - -/********************************************************************** - * IEnumCATEGORYINFO implementation - * - * This implementation is not thread-safe. The manager itself is, but - * I can't imagine a valid use of an enumerator in several threads. - */ -typedef struct -{ - const IEnumCATEGORYINFOVtbl *lpVtbl; - LONG ref; - LCID lcid; - HKEY key; - DWORD next_index; -} IEnumCATEGORYINFOImpl; - -static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_AddRef(LPENUMCATEGORYINFO iface) -{ - IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - return InterlockedIncrement(&This->ref); -} - -static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_QueryInterface( - LPENUMCATEGORYINFO iface, - REFIID riid, - LPVOID *ppvObj) -{ - IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface; - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IEnumCATEGORYINFO)) - { - *ppvObj = (LPVOID)iface; - COMCAT_IEnumCATEGORYINFO_AddRef(iface); - return S_OK; - } - - return E_NOINTERFACE; -} - -static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_Release(LPENUMCATEGORYINFO iface) -{ - IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface; - ULONG ref; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - if (This->key) RegCloseKey(This->key); - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return ref; -} - -static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Next( - LPENUMCATEGORYINFO iface, - ULONG celt, - CATEGORYINFO *rgelt, - ULONG *pceltFetched) -{ - IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface; - ULONG fetched = 0; - - TRACE("\n"); - - if (This == NULL || rgelt == NULL) return E_POINTER; - - if (This->key) while (fetched < celt) { - HRESULT res; - WCHAR catid[39]; - DWORD cName = 39; - HKEY subkey; - - res = RegEnumKeyExW(This->key, This->next_index, catid, &cName, - NULL, NULL, NULL, NULL); - if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break; - ++(This->next_index); - - res = CLSIDFromString(catid, &rgelt->catid); - if (FAILED(res)) continue; - - res = RegOpenKeyExW(This->key, catid, 0, KEY_READ, &subkey); - if (res != ERROR_SUCCESS) continue; - - res = COMCAT_GetCategoryDesc(subkey, This->lcid, - rgelt->szDescription, 128); - RegCloseKey(subkey); - if (FAILED(res)) continue; - - rgelt->lcid = This->lcid; - ++fetched; - ++rgelt; - } - - if (pceltFetched) *pceltFetched = fetched; - return fetched == celt ? S_OK : S_FALSE; -} - -static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Skip( - LPENUMCATEGORYINFO iface, - ULONG celt) -{ - IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - This->next_index += celt; - /* This should return S_FALSE when there aren't celt elems to skip. */ - return S_OK; -} - -static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Reset(LPENUMCATEGORYINFO iface) -{ - IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - This->next_index = 0; - return S_OK; -} - -static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone( - LPENUMCATEGORYINFO iface, - IEnumCATEGORYINFO **ppenum) -{ - IEnumCATEGORYINFOImpl *This = (IEnumCATEGORYINFOImpl *)iface; - static const WCHAR keyname[] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n', - 't', ' ', 'C', 'a', 't', 'e', 'g', 'o', - 'r', 'i', 'e', 's', 0 }; - IEnumCATEGORYINFOImpl *new_this; - - TRACE("\n"); - - if (This == NULL || ppenum == NULL) return E_POINTER; - - new_this = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumCATEGORYINFOImpl)); - if (new_this == NULL) return E_OUTOFMEMORY; - - new_this->lpVtbl = This->lpVtbl; - new_this->ref = 1; - new_this->lcid = This->lcid; - /* FIXME: could we more efficiently use DuplicateHandle? */ - RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &new_this->key); - new_this->next_index = This->next_index; - - *ppenum = (LPENUMCATEGORYINFO)new_this; - return S_OK; -} - -static const IEnumCATEGORYINFOVtbl COMCAT_IEnumCATEGORYINFO_Vtbl = -{ - COMCAT_IEnumCATEGORYINFO_QueryInterface, - COMCAT_IEnumCATEGORYINFO_AddRef, - COMCAT_IEnumCATEGORYINFO_Release, - COMCAT_IEnumCATEGORYINFO_Next, - COMCAT_IEnumCATEGORYINFO_Skip, - COMCAT_IEnumCATEGORYINFO_Reset, - COMCAT_IEnumCATEGORYINFO_Clone -}; - -static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid) -{ - IEnumCATEGORYINFOImpl *This; - - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumCATEGORYINFOImpl)); - if (This) { - static const WCHAR keyname[] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n', - 't', ' ', 'C', 'a', 't', 'e', 'g', 'o', - 'r', 'i', 'e', 's', 0 }; - - This->lpVtbl = &COMCAT_IEnumCATEGORYINFO_Vtbl; - This->lcid = lcid; - RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &This->key); - } - return (LPENUMCATEGORYINFO)This; -} - -/********************************************************************** - * COMCAT_GetCategoryDesc - */ -static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc, - ULONG buf_wchars) -{ - static const WCHAR fmt[] = { '%', 'l', 'X', 0 }; - WCHAR valname[5]; - HRESULT res; - DWORD type, size = (buf_wchars - 1) * sizeof(WCHAR); - - if (pszDesc == NULL) return E_INVALIDARG; - - /* FIXME: lcid comparisons are more complex than this! */ - wsprintfW(valname, fmt, lcid); - res = RegQueryValueExW(key, valname, 0, &type, (LPBYTE)pszDesc, &size); - if (res != ERROR_SUCCESS || type != REG_SZ) { - FIXME("Simplified lcid comparison\n"); - return CAT_E_NODESCRIPTION; - } - pszDesc[size / sizeof(WCHAR)] = (WCHAR)0; - - return S_OK; -} - -/********************************************************************** - * COMCAT_PrepareClassCategories - */ -static struct class_categories *COMCAT_PrepareClassCategories( - ULONG impl_count, const CATID *impl_catids, ULONG req_count, const CATID *req_catids) -{ - struct class_categories *categories; - WCHAR *strings; - - categories = HeapAlloc( - GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(struct class_categories) + - ((impl_count + req_count) * 39 + 2) * sizeof(WCHAR)); - if (categories == NULL) return categories; - - strings = (WCHAR *)(categories + 1); - categories->impl_strings = strings; - while (impl_count--) { - StringFromGUID2(impl_catids++, strings, 39); - strings += 39; - } - *strings++ = 0; - - categories->req_strings = strings; - while (req_count--) { - StringFromGUID2(req_catids++, strings, 39); - strings += 39; - } - *strings++ = 0; - - return categories; -} - -/********************************************************************** - * COMCAT_IsClassOfCategories - */ -static HRESULT COMCAT_IsClassOfCategories( - HKEY key, - struct class_categories const* categories) -{ - static const WCHAR impl_keyname[] = { 'I', 'm', 'p', 'l', 'e', 'm', 'e', 'n', - 't', 'e', 'd', ' ', 'C', 'a', 't', 'e', - 'g', 'o', 'r', 'i', 'e', 's', 0 }; - static const WCHAR req_keyname[] = { 'R', 'e', 'q', 'u', 'i', 'r', 'e', 'd', - ' ', 'C', 'a', 't', 'e', 'g', 'o', 'r', - 'i', 'e', 's', 0 }; - HKEY subkey; - HRESULT res; - DWORD index; - LPCWSTR string; - - /* Check that every given category is implemented by class. */ - res = RegOpenKeyExW(key, impl_keyname, 0, KEY_READ, &subkey); - if (res != ERROR_SUCCESS) return S_FALSE; - for (string = categories->impl_strings; *string; string += 39) { - HKEY catkey; - res = RegOpenKeyExW(subkey, string, 0, 0, &catkey); - if (res != ERROR_SUCCESS) { - RegCloseKey(subkey); - return S_FALSE; - } - RegCloseKey(catkey); - } - RegCloseKey(subkey); - - /* Check that all categories required by class are given. */ - res = RegOpenKeyExW(key, req_keyname, 0, KEY_READ, &subkey); - if (res == ERROR_SUCCESS) { - for (index = 0; ; ++index) { - WCHAR keyname[39]; - DWORD size = 39; - - res = RegEnumKeyExW(subkey, index, keyname, &size, - NULL, NULL, NULL, NULL); - if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break; - if (size != 38) continue; /* bogus catid in registry */ - for (string = categories->req_strings; *string; string += 39) - if (!strcmpiW(string, keyname)) break; - if (!*string) { - RegCloseKey(subkey); - return S_FALSE; - } - } - RegCloseKey(subkey); - } - - return S_OK; -} - -/********************************************************************** - * ClassesOfCategories IEnumCLSID (IEnumGUID) implementation - * - * This implementation is not thread-safe. The manager itself is, but - * I can't imagine a valid use of an enumerator in several threads. - */ -typedef struct -{ - const IEnumGUIDVtbl *lpVtbl; - LONG ref; - struct class_categories *categories; - HKEY key; - DWORD next_index; -} CLSID_IEnumGUIDImpl; - -static ULONG WINAPI COMCAT_CLSID_IEnumGUID_AddRef(LPENUMGUID iface) -{ - CLSID_IEnumGUIDImpl *This = (CLSID_IEnumGUIDImpl *)iface; - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - return InterlockedIncrement(&This->ref); -} - -static HRESULT WINAPI COMCAT_CLSID_IEnumGUID_QueryInterface( - LPENUMGUID iface, - REFIID riid, - LPVOID *ppvObj) -{ - CLSID_IEnumGUIDImpl *This = (CLSID_IEnumGUIDImpl *)iface; - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IEnumGUID)) - { - *ppvObj = (LPVOID)iface; - COMCAT_CLSID_IEnumGUID_AddRef(iface); - return S_OK; - } - - return E_NOINTERFACE; -} - -static ULONG WINAPI COMCAT_CLSID_IEnumGUID_Release(LPENUMGUID iface) -{ - CLSID_IEnumGUIDImpl *This = (CLSID_IEnumGUIDImpl *)iface; - ULONG ref; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - if (This->key) RegCloseKey(This->key); - HeapFree(GetProcessHeap(), 0, (LPVOID)This->categories); - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return ref; -} - -static HRESULT WINAPI COMCAT_CLSID_IEnumGUID_Next( - LPENUMGUID iface, - ULONG celt, - GUID *rgelt, - ULONG *pceltFetched) -{ - CLSID_IEnumGUIDImpl *This = (CLSID_IEnumGUIDImpl *)iface; - ULONG fetched = 0; - - TRACE("\n"); - - if (This == NULL || rgelt == NULL) return E_POINTER; - - if (This->key) while (fetched < celt) { - HRESULT res; - WCHAR clsid[39]; - DWORD cName = 39; - HKEY subkey; - - res = RegEnumKeyExW(This->key, This->next_index, clsid, &cName, - NULL, NULL, NULL, NULL); - if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break; - ++(This->next_index); - - res = CLSIDFromString(clsid, rgelt); - if (FAILED(res)) continue; - - res = RegOpenKeyExW(This->key, clsid, 0, KEY_READ, &subkey); - if (res != ERROR_SUCCESS) continue; - - res = COMCAT_IsClassOfCategories(subkey, This->categories); - RegCloseKey(subkey); - if (res != S_OK) continue; - - ++fetched; - ++rgelt; - } - - if (pceltFetched) *pceltFetched = fetched; - return fetched == celt ? S_OK : S_FALSE; -} - -static HRESULT WINAPI COMCAT_CLSID_IEnumGUID_Skip( - LPENUMGUID iface, - ULONG celt) -{ - CLSID_IEnumGUIDImpl *This = (CLSID_IEnumGUIDImpl *)iface; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - This->next_index += celt; - FIXME("Never returns S_FALSE\n"); - return S_OK; -} - -static HRESULT WINAPI COMCAT_CLSID_IEnumGUID_Reset(LPENUMGUID iface) -{ - CLSID_IEnumGUIDImpl *This = (CLSID_IEnumGUIDImpl *)iface; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - This->next_index = 0; - return S_OK; -} - -static HRESULT WINAPI COMCAT_CLSID_IEnumGUID_Clone( - LPENUMGUID iface, - IEnumGUID **ppenum) -{ - CLSID_IEnumGUIDImpl *This = (CLSID_IEnumGUIDImpl *)iface; - static const WCHAR keyname[] = { 'C', 'L', 'S', 'I', 'D', 0 }; - CLSID_IEnumGUIDImpl *new_this; - DWORD size; - - TRACE("\n"); - - if (This == NULL || ppenum == NULL) return E_POINTER; - - new_this = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLSID_IEnumGUIDImpl)); - if (new_this == NULL) return E_OUTOFMEMORY; - - new_this->lpVtbl = This->lpVtbl; - new_this->ref = 1; - size = HeapSize(GetProcessHeap(), 0, (LPVOID)This->categories); - new_this->categories = - HeapAlloc(GetProcessHeap(), 0, size); - if (new_this->categories == NULL) { - HeapFree(GetProcessHeap(), 0, new_this); - return E_OUTOFMEMORY; - } - memcpy((LPVOID)new_this->categories, This->categories, size); - /* FIXME: could we more efficiently use DuplicateHandle? */ - RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &new_this->key); - new_this->next_index = This->next_index; - - *ppenum = (LPENUMGUID)new_this; - return S_OK; -} - -static const IEnumGUIDVtbl COMCAT_CLSID_IEnumGUID_Vtbl = -{ - COMCAT_CLSID_IEnumGUID_QueryInterface, - COMCAT_CLSID_IEnumGUID_AddRef, - COMCAT_CLSID_IEnumGUID_Release, - COMCAT_CLSID_IEnumGUID_Next, - COMCAT_CLSID_IEnumGUID_Skip, - COMCAT_CLSID_IEnumGUID_Reset, - COMCAT_CLSID_IEnumGUID_Clone -}; - -static LPENUMGUID COMCAT_CLSID_IEnumGUID_Construct(struct class_categories *categories) -{ - CLSID_IEnumGUIDImpl *This; - - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLSID_IEnumGUIDImpl)); - if (This) { - static const WCHAR keyname[] = { 'C', 'L', 'S', 'I', 'D', 0 }; - - This->lpVtbl = &COMCAT_CLSID_IEnumGUID_Vtbl; - This->categories = categories; - RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &This->key); - } - return (LPENUMGUID)This; -} - -/********************************************************************** - * CategoriesOfClass IEnumCATID (IEnumGUID) implementation - * - * This implementation is not thread-safe. The manager itself is, but - * I can't imagine a valid use of an enumerator in several threads. - */ -typedef struct -{ - const IEnumGUIDVtbl *lpVtbl; - LONG ref; - WCHAR keyname[68]; - HKEY key; - DWORD next_index; -} CATID_IEnumGUIDImpl; - -static ULONG WINAPI COMCAT_CATID_IEnumGUID_AddRef(LPENUMGUID iface) -{ - CATID_IEnumGUIDImpl *This = (CATID_IEnumGUIDImpl *)iface; - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - return InterlockedIncrement(&This->ref); -} - -static HRESULT WINAPI COMCAT_CATID_IEnumGUID_QueryInterface( - LPENUMGUID iface, - REFIID riid, - LPVOID *ppvObj) -{ - CATID_IEnumGUIDImpl *This = (CATID_IEnumGUIDImpl *)iface; - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IEnumGUID)) - { - *ppvObj = (LPVOID)iface; - COMCAT_CATID_IEnumGUID_AddRef(iface); - return S_OK; - } - - return E_NOINTERFACE; -} - -static ULONG WINAPI COMCAT_CATID_IEnumGUID_Release(LPENUMGUID iface) -{ - CATID_IEnumGUIDImpl *This = (CATID_IEnumGUIDImpl *)iface; - ULONG ref; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - if (This->key) RegCloseKey(This->key); - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return ref; -} - -static HRESULT WINAPI COMCAT_CATID_IEnumGUID_Next( - LPENUMGUID iface, - ULONG celt, - GUID *rgelt, - ULONG *pceltFetched) -{ - CATID_IEnumGUIDImpl *This = (CATID_IEnumGUIDImpl *)iface; - ULONG fetched = 0; - - TRACE("\n"); - - if (This == NULL || rgelt == NULL) return E_POINTER; - - if (This->key) while (fetched < celt) { - HRESULT res; - WCHAR catid[39]; - DWORD cName = 39; - - res = RegEnumKeyExW(This->key, This->next_index, catid, &cName, - NULL, NULL, NULL, NULL); - if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break; - ++(This->next_index); - - res = CLSIDFromString(catid, rgelt); - if (FAILED(res)) continue; - - ++fetched; - ++rgelt; - } - - if (pceltFetched) *pceltFetched = fetched; - return fetched == celt ? S_OK : S_FALSE; -} - -static HRESULT WINAPI COMCAT_CATID_IEnumGUID_Skip( - LPENUMGUID iface, - ULONG celt) -{ - CATID_IEnumGUIDImpl *This = (CATID_IEnumGUIDImpl *)iface; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - This->next_index += celt; - FIXME("Never returns S_FALSE\n"); - return S_OK; -} - -static HRESULT WINAPI COMCAT_CATID_IEnumGUID_Reset(LPENUMGUID iface) -{ - CATID_IEnumGUIDImpl *This = (CATID_IEnumGUIDImpl *)iface; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - This->next_index = 0; - return S_OK; -} - -static HRESULT WINAPI COMCAT_CATID_IEnumGUID_Clone( - LPENUMGUID iface, - IEnumGUID **ppenum) -{ - CATID_IEnumGUIDImpl *This = (CATID_IEnumGUIDImpl *)iface; - CATID_IEnumGUIDImpl *new_this; - - TRACE("\n"); - - if (This == NULL || ppenum == NULL) return E_POINTER; - - new_this = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CATID_IEnumGUIDImpl)); - if (new_this == NULL) return E_OUTOFMEMORY; - - new_this->lpVtbl = This->lpVtbl; - new_this->ref = 1; - lstrcpyW(new_this->keyname, This->keyname); - /* FIXME: could we more efficiently use DuplicateHandle? */ - RegOpenKeyExW(HKEY_CLASSES_ROOT, new_this->keyname, 0, KEY_READ, &new_this->key); - new_this->next_index = This->next_index; - - *ppenum = (LPENUMGUID)new_this; - return S_OK; -} - -static const IEnumGUIDVtbl COMCAT_CATID_IEnumGUID_Vtbl = -{ - COMCAT_CATID_IEnumGUID_QueryInterface, - COMCAT_CATID_IEnumGUID_AddRef, - COMCAT_CATID_IEnumGUID_Release, - COMCAT_CATID_IEnumGUID_Next, - COMCAT_CATID_IEnumGUID_Skip, - COMCAT_CATID_IEnumGUID_Reset, - COMCAT_CATID_IEnumGUID_Clone -}; - -static LPENUMGUID COMCAT_CATID_IEnumGUID_Construct( - REFCLSID rclsid, LPCWSTR postfix) -{ - CATID_IEnumGUIDImpl *This; - - This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CATID_IEnumGUIDImpl)); - if (This) { - WCHAR prefix[6] = { 'C', 'L', 'S', 'I', 'D', '\\' }; - - This->lpVtbl = &COMCAT_CATID_IEnumGUID_Vtbl; - memcpy(This->keyname, prefix, sizeof(prefix)); - StringFromGUID2(rclsid, This->keyname + 6, 39); - lstrcpyW(This->keyname + 44, postfix); - RegOpenKeyExW(HKEY_CLASSES_ROOT, This->keyname, 0, KEY_READ, &This->key); - } - return (LPENUMGUID)This; -} diff --git a/reactos/dll/win32/comcat/manager.c b/reactos/dll/win32/comcat/manager.c deleted file mode 100644 index 0b80cbe75dc..00000000000 --- a/reactos/dll/win32/comcat/manager.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * ComCatMgr IUnknown implementation for comcat.dll - * - * Copyright (C) 2002 John K. Hohm - * - * 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 - */ - -#include "comcat_private.h" - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ole); - -static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface); - -/********************************************************************** - * COMCAT_IUnknown_QueryInterface - */ -static HRESULT WINAPI COMCAT_IUnknown_QueryInterface( - LPUNKNOWN iface, - REFIID riid, - LPVOID *ppvObj) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface); - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - if (IsEqualGUID(riid, &IID_IUnknown)) { - *ppvObj = &This->unkVtbl; - COMCAT_IUnknown_AddRef(iface); - return S_OK; - } - - if (IsEqualGUID(riid, &IID_ICatRegister)) { - *ppvObj = &This->regVtbl; - COMCAT_IUnknown_AddRef(iface); - return S_OK; - } - - if (IsEqualGUID(riid, &IID_ICatInformation)) { - *ppvObj = &This->infVtbl; - COMCAT_IUnknown_AddRef(iface); - return S_OK; - } - - return E_NOINTERFACE; -} - -/********************************************************************** - * COMCAT_IUnknown_AddRef - */ -static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface); - ULONG ref; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - ref = InterlockedIncrement(&This->ref); - if (ref == 1) { - InterlockedIncrement(&dll_ref); - } - return ref; -} - -/********************************************************************** - * COMCAT_IUnknown_Release - */ -static ULONG WINAPI COMCAT_IUnknown_Release(LPUNKNOWN iface) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface); - ULONG ref; - - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - InterlockedDecrement(&dll_ref); - } - return ref; -} - -/********************************************************************** - * COMCAT_IUnknown_Vtbl - */ -static const IUnknownVtbl COMCAT_IUnknown_Vtbl = -{ - COMCAT_IUnknown_QueryInterface, - COMCAT_IUnknown_AddRef, - COMCAT_IUnknown_Release -}; - -/********************************************************************** - * static ComCatMgr instance - */ -ComCatMgrImpl COMCAT_ComCatMgr = -{ - &COMCAT_IUnknown_Vtbl, - &COMCAT_ICatRegister_Vtbl, - &COMCAT_ICatInformation_Vtbl, - 0 -}; diff --git a/reactos/dll/win32/comcat/register.c b/reactos/dll/win32/comcat/register.c deleted file mode 100644 index 9a46e65cc8c..00000000000 --- a/reactos/dll/win32/comcat/register.c +++ /dev/null @@ -1,342 +0,0 @@ -/* - * ComCatMgr ICatRegister implementation for comcat.dll - * - * Copyright (C) 2002 John K. Hohm - * - * 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 - */ - -#include "comcat_private.h" - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ole); - -/********************************************************************** - * File-scope string constants - */ -static const WCHAR comcat_keyname[21] = { - 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n', 't', ' ', 'C', 'a', - 't', 'e', 'g', 'o', 'r', 'i', 'e', 's', 0 }; -static const WCHAR impl_keyname[23] = { - 'I', 'm', 'p', 'l', 'e', 'm', 'e', 'n', - 't', 'e', 'd', ' ', 'C', 'a', 't', 'e', - 'g', 'o', 'r', 'i', 'e', 's', 0 }; -static const WCHAR req_keyname[20] = { - 'R', 'e', 'q', 'u', 'i', 'r', 'e', 'd', - ' ', 'C', 'a', 't', 'e', 'g', 'o', 'r', - 'i', 'e', 's', 0 }; - -static HRESULT COMCAT_RegisterClassCategories( - REFCLSID rclsid, LPCWSTR type, - ULONG cCategories, const CATID *rgcatid); -static HRESULT COMCAT_UnRegisterClassCategories( - REFCLSID rclsid, LPCWSTR type, - ULONG cCategories, const CATID *rgcatid); - -/********************************************************************** - * COMCAT_ICatRegister_QueryInterface - */ -static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface( - LPCATREGISTER iface, - REFIID riid, - LPVOID *ppvObj) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); - TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); - - if (This == NULL || ppvObj == NULL) return E_POINTER; - - return IUnknown_QueryInterface((LPUNKNOWN)&This->unkVtbl, riid, ppvObj); -} - -/********************************************************************** - * COMCAT_ICatRegister_AddRef - */ -static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - return IUnknown_AddRef((LPUNKNOWN)&This->unkVtbl); -} - -/********************************************************************** - * COMCAT_ICatRegister_Release - */ -static ULONG WINAPI COMCAT_ICatRegister_Release(LPCATREGISTER iface) -{ - ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); - TRACE("\n"); - - if (This == NULL) return E_POINTER; - - return IUnknown_Release((LPUNKNOWN)&This->unkVtbl); -} - -/********************************************************************** - * COMCAT_ICatRegister_RegisterCategories - */ -static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories( - LPCATREGISTER iface, - ULONG cCategories, - CATEGORYINFO *rgci) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */ - HKEY comcat_key; - HRESULT res; - - TRACE("\n"); - - if (iface == NULL || (cCategories && rgci == NULL)) - return E_POINTER; - - /* Create (or open) the component categories key. */ - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, comcat_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &comcat_key, NULL); - if (res != ERROR_SUCCESS) return E_FAIL; - - for (; cCategories; --cCategories, ++rgci) { - static const WCHAR fmt[] = { '%', 'l', 'X', 0 }; - WCHAR keyname[39]; - WCHAR valname[9]; - HKEY cat_key; - - /* Create (or open) the key for this category. */ - if (!StringFromGUID2(&rgci->catid, keyname, 39)) continue; - res = RegCreateKeyExW(comcat_key, keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &cat_key, NULL); - if (res != ERROR_SUCCESS) continue; - - /* Set the value for this locale's description. */ - wsprintfW(valname, fmt, rgci->lcid); - RegSetValueExW(cat_key, valname, 0, REG_SZ, - (CONST BYTE*)(rgci->szDescription), - (lstrlenW(rgci->szDescription) + 1) * sizeof(WCHAR)); - - RegCloseKey(cat_key); - } - - RegCloseKey(comcat_key); - return S_OK; -} - -/********************************************************************** - * COMCAT_ICatRegister_UnRegisterCategories - */ -static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories( - LPCATREGISTER iface, - ULONG cCategories, - CATID *rgcatid) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */ - HKEY comcat_key; - HRESULT res; - - TRACE("\n"); - - if (iface == NULL || (cCategories && rgcatid == NULL)) - return E_POINTER; - - /* Open the component categories key. */ - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, comcat_keyname, 0, - KEY_READ | KEY_WRITE, &comcat_key); - if (res != ERROR_SUCCESS) return E_FAIL; - - for (; cCategories; --cCategories, ++rgcatid) { - WCHAR keyname[39]; - - /* Delete the key for this category. */ - if (!StringFromGUID2(rgcatid, keyname, 39)) continue; - RegDeleteKeyW(comcat_key, keyname); - } - - RegCloseKey(comcat_key); - return S_OK; -} - -/********************************************************************** - * COMCAT_ICatRegister_RegisterClassImplCategories - */ -static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassImplCategories( - LPCATREGISTER iface, - REFCLSID rclsid, - ULONG cCategories, - CATID *rgcatid) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */ - TRACE("\n"); - - return COMCAT_RegisterClassCategories( - rclsid, impl_keyname, cCategories, rgcatid); -} - -/********************************************************************** - * COMCAT_ICatRegister_UnRegisterClassImplCategories - */ -static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassImplCategories( - LPCATREGISTER iface, - REFCLSID rclsid, - ULONG cCategories, - CATID *rgcatid) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */ - TRACE("\n"); - - return COMCAT_UnRegisterClassCategories( - rclsid, impl_keyname, cCategories, rgcatid); -} - -/********************************************************************** - * COMCAT_ICatRegister_RegisterClassReqCategories - */ -static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassReqCategories( - LPCATREGISTER iface, - REFCLSID rclsid, - ULONG cCategories, - CATID *rgcatid) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */ - TRACE("\n"); - - return COMCAT_RegisterClassCategories( - rclsid, req_keyname, cCategories, rgcatid); -} - -/********************************************************************** - * COMCAT_ICatRegister_UnRegisterClassReqCategories - */ -static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories( - LPCATREGISTER iface, - REFCLSID rclsid, - ULONG cCategories, - CATID *rgcatid) -{ -/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */ - TRACE("\n"); - - return COMCAT_UnRegisterClassCategories( - rclsid, req_keyname, cCategories, rgcatid); -} - -/********************************************************************** - * COMCAT_ICatRegister_Vtbl - */ -const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl = -{ - COMCAT_ICatRegister_QueryInterface, - COMCAT_ICatRegister_AddRef, - COMCAT_ICatRegister_Release, - COMCAT_ICatRegister_RegisterCategories, - COMCAT_ICatRegister_UnRegisterCategories, - COMCAT_ICatRegister_RegisterClassImplCategories, - COMCAT_ICatRegister_UnRegisterClassImplCategories, - COMCAT_ICatRegister_RegisterClassReqCategories, - COMCAT_ICatRegister_UnRegisterClassReqCategories -}; - -/********************************************************************** - * COMCAT_RegisterClassCategories - */ -static HRESULT COMCAT_RegisterClassCategories( - REFCLSID rclsid, - LPCWSTR type, - ULONG cCategories, - const CATID *rgcatid) -{ - WCHAR keyname[39]; - HRESULT res; - HKEY clsid_key, class_key, type_key; - - if (cCategories && rgcatid == NULL) return E_POINTER; - - /* Format the class key name. */ - res = StringFromGUID2(rclsid, keyname, 39); - if (FAILED(res)) return res; - - /* Create (or open) the CLSID key. */ - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL); - if (res != ERROR_SUCCESS) return E_FAIL; - - /* Create (or open) the class key. */ - res = RegCreateKeyExW(clsid_key, keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &class_key, NULL); - if (res == ERROR_SUCCESS) { - /* Create (or open) the category type key. */ - res = RegCreateKeyExW(class_key, type, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &type_key, NULL); - if (res == ERROR_SUCCESS) { - for (; cCategories; --cCategories, ++rgcatid) { - HKEY key; - - /* Format the category key name. */ - res = StringFromGUID2(rgcatid, keyname, 39); - if (FAILED(res)) continue; - - /* Do the register. */ - res = RegCreateKeyExW(type_key, keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res == ERROR_SUCCESS) RegCloseKey(key); - } - res = S_OK; - } else res = E_FAIL; - RegCloseKey(class_key); - } else res = E_FAIL; - RegCloseKey(clsid_key); - - return res; -} - -/********************************************************************** - * COMCAT_UnRegisterClassCategories - */ -static HRESULT COMCAT_UnRegisterClassCategories( - REFCLSID rclsid, - LPCWSTR type, - ULONG cCategories, - const CATID *rgcatid) -{ - WCHAR keyname[68] = { 'C', 'L', 'S', 'I', 'D', '\\' }; - HRESULT res; - HKEY type_key; - - if (cCategories && rgcatid == NULL) return E_POINTER; - - /* Format the class category type key name. */ - res = StringFromGUID2(rclsid, keyname + 6, 39); - if (FAILED(res)) return res; - keyname[44] = '\\'; - lstrcpyW(keyname + 45, type); - - /* Open the class category type key. */ - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, - KEY_READ | KEY_WRITE, &type_key); - if (res != ERROR_SUCCESS) return E_FAIL; - - for (; cCategories; --cCategories, ++rgcatid) { - /* Format the category key name. */ - res = StringFromGUID2(rgcatid, keyname, 39); - if (FAILED(res)) continue; - - /* Do the unregister. */ - RegDeleteKeyW(type_key, keyname); - } - RegCloseKey(type_key); - - return S_OK; -} diff --git a/reactos/dll/win32/comcat/regsvr.c b/reactos/dll/win32/comcat/regsvr.c deleted file mode 100644 index 21a7597c73a..00000000000 --- a/reactos/dll/win32/comcat/regsvr.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - * self-registerable dll functions for comcat.dll - * - * Copyright (C) 2002-2003 John K. Hohm - * - * 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 - */ - -#include -#include - -#include "windef.h" -#include "winbase.h" -#include "winuser.h" -#include "winreg.h" -#include "winerror.h" - -#include "ole2.h" -#include "comcat.h" - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ole); - -/* - * Near the bottom of this file are the exported DllRegisterServer and - * DllUnregisterServer, which make all this worthwhile. - */ - -/*********************************************************************** - * interface for self-registering - */ -struct regsvr_interface -{ - IID const *iid; /* NULL for end of list */ - LPCSTR name; /* can be NULL to omit */ - IID const *base_iid; /* can be NULL to omit */ - int num_methods; /* can be <0 to omit */ - CLSID const *ps_clsid; /* can be NULL to omit */ - CLSID const *ps_clsid32; /* can be NULL to omit */ -}; - -static HRESULT register_interfaces(struct regsvr_interface const *list); -static HRESULT unregister_interfaces(struct regsvr_interface const *list); - -struct regsvr_coclass -{ - CLSID const *clsid; /* NULL for end of list */ - LPCSTR name; /* can be NULL to omit */ - LPCSTR ips; /* can be NULL to omit */ - LPCSTR ips32; /* can be NULL to omit */ - LPCSTR ips32_tmodel; /* can be NULL to omit */ -}; - -static HRESULT register_coclasses(struct regsvr_coclass const *list); -static HRESULT unregister_coclasses(struct regsvr_coclass const *list); - -/*********************************************************************** - * static string constants - */ -static WCHAR const interface_keyname[10] = { - 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 }; -static WCHAR const base_ifa_keyname[14] = { - 'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', - 'e', 0 }; -static WCHAR const num_methods_keyname[11] = { - 'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 }; -static WCHAR const ps_clsid_keyname[15] = { - 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's', - 'i', 'd', 0 }; -static WCHAR const ps_clsid32_keyname[17] = { - 'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's', - 'i', 'd', '3', '2', 0 }; -static WCHAR const clsid_keyname[6] = { - 'C', 'L', 'S', 'I', 'D', 0 }; -static WCHAR const ips_keyname[13] = { - 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r', - 0 }; -static WCHAR const ips32_keyname[15] = { - 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r', - '3', '2', 0 }; -static char const tmodel_valuename[] = "ThreadingModel"; - -/*********************************************************************** - * static helper functions - */ -static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid); -static LONG register_key_defvalueW(HKEY base, WCHAR const *name, - WCHAR const *value); -static LONG register_key_defvalueA(HKEY base, WCHAR const *name, - char const *value); - -/*********************************************************************** - * register_interfaces - */ -static HRESULT register_interfaces(struct regsvr_interface const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY interface_key; - - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &interface_key, NULL); - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->iid; ++list) { - WCHAR buf[39]; - HKEY iid_key; - - StringFromGUID2(list->iid, buf, 39); - res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &iid_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_interface_key; - - if (list->name) { - res = RegSetValueExA(iid_key, NULL, 0, REG_SZ, - (CONST BYTE*)(list->name), - strlen(list->name) + 1); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (list->base_iid) { - res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (0 <= list->num_methods) { - static WCHAR const fmt[3] = { '%', 'd', 0 }; - HKEY key; - - res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - - wsprintfW(buf, fmt, list->num_methods); - res = RegSetValueExW(key, NULL, 0, REG_SZ, - (CONST BYTE*)buf, - (lstrlenW(buf) + 1) * sizeof(WCHAR)); - RegCloseKey(key); - - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (list->ps_clsid) { - res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - if (list->ps_clsid32) { - res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32); - if (res != ERROR_SUCCESS) goto error_close_iid_key; - } - - error_close_iid_key: - RegCloseKey(iid_key); - } - -error_close_interface_key: - RegCloseKey(interface_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * unregister_interfaces - */ -static HRESULT unregister_interfaces(struct regsvr_interface const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY interface_key; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, - KEY_READ | KEY_WRITE, &interface_key); - if (res == ERROR_FILE_NOT_FOUND) return S_OK; - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->iid; ++list) { - WCHAR buf[39]; - - StringFromGUID2(list->iid, buf, 39); - res = RegDeleteTreeW(interface_key, buf); - if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS; - } - - RegCloseKey(interface_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * register_coclasses - */ -static HRESULT register_coclasses(struct regsvr_coclass const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY coclass_key; - - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL); - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->clsid; ++list) { - WCHAR buf[39]; - HKEY clsid_key; - - StringFromGUID2(list->clsid, buf, 39); - res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - - if (list->name) { - res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ, - (CONST BYTE*)(list->name), - strlen(list->name) + 1); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->ips) { - res = register_key_defvalueA(clsid_key, ips_keyname, list->ips); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->ips32) { - HKEY ips32_key; - - res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, - &ips32_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - - res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ, - (CONST BYTE*)list->ips32, - lstrlenA(list->ips32) + 1); - if (res == ERROR_SUCCESS && list->ips32_tmodel) - res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ, - (CONST BYTE*)list->ips32_tmodel, - strlen(list->ips32_tmodel) + 1); - RegCloseKey(ips32_key); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - error_close_clsid_key: - RegCloseKey(clsid_key); - } - -error_close_coclass_key: - RegCloseKey(coclass_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * unregister_coclasses - */ -static HRESULT unregister_coclasses(struct regsvr_coclass const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY coclass_key; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, - KEY_READ | KEY_WRITE, &coclass_key); - if (res == ERROR_FILE_NOT_FOUND) return S_OK; - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->clsid; ++list) { - WCHAR buf[39]; - - StringFromGUID2(list->clsid, buf, 39); - res = RegDeleteTreeW(coclass_key, buf); - if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS; - } - -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * regsvr_key_guid - */ -static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid) -{ - WCHAR buf[39]; - - StringFromGUID2(guid, buf, 39); - return register_key_defvalueW(base, name, buf); -} - -/*********************************************************************** - * regsvr_key_defvalueW - */ -static LONG register_key_defvalueW( - HKEY base, - WCHAR const *name, - WCHAR const *value) -{ - LONG res; - HKEY key; - - res = RegCreateKeyExW(base, name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) return res; - res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value, - (lstrlenW(value) + 1) * sizeof(WCHAR)); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * regsvr_key_defvalueA - */ -static LONG register_key_defvalueA( - HKEY base, - WCHAR const *name, - char const *value) -{ - LONG res; - HKEY key; - - res = RegCreateKeyExW(base, name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) return res; - res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value, - lstrlenA(value) + 1); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * coclass list - */ -static struct regsvr_coclass const coclass_list[] = { - { &CLSID_StdComponentCategoriesMgr, - "Component Categories Manager", - NULL, - "comcat.dll", - "Both" - }, - { NULL } /* list terminator */ -}; - -/*********************************************************************** - * interface list - */ -static GUID const CLSID_PSFactoryBuffer_actxprxy = { - 0xB8DA6310, 0xE19B, 0x11D0, {0x93,0x3C,0x00,0xA0,0xC9,0x0D,0xCA,0xA9} }; - -static struct regsvr_interface const interface_list[] = { - { &IID_IEnumGUID, - "IEnumGUID", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer_actxprxy - }, - { &IID_IEnumCATEGORYINFO, - "IEnumCATEGORYINFO", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer_actxprxy - }, - { &IID_ICatRegister, - "ICatRegister", - NULL, - 9, - NULL, - &CLSID_PSFactoryBuffer_actxprxy - }, - { &IID_ICatInformation, - "ICatInformation", - NULL, - 9, - NULL, - &CLSID_PSFactoryBuffer_actxprxy - }, - { NULL } /* list terminator */ -}; - -/*********************************************************************** - * DllRegisterServer (COMCAT.@) - */ -HRESULT WINAPI DllRegisterServer(void) -{ - HRESULT hr; - - TRACE("\n"); - - hr = register_coclasses(coclass_list); - if (SUCCEEDED(hr)) - hr = register_interfaces(interface_list); - return hr; -} - -/*********************************************************************** - * DllUnregisterServer (COMCAT.@) - */ -HRESULT WINAPI DllUnregisterServer(void) -{ - HRESULT hr; - - TRACE("\n"); - - hr = unregister_coclasses(coclass_list); - if (SUCCEEDED(hr)) - hr = unregister_interfaces(interface_list); - return hr; -} diff --git a/reactos/dll/win32/ole32/classmoniker.c b/reactos/dll/win32/ole32/classmoniker.c index 5c95b0a1532..5629c5ae908 100644 --- a/reactos/dll/win32/ole32/classmoniker.c +++ b/reactos/dll/win32/ole32/classmoniker.c @@ -116,7 +116,7 @@ static ULONG WINAPI ClassMoniker_AddRef(IMoniker* iface) /****************************************************************************** * ClassMoniker_Destroy (local function) *******************************************************************************/ -static HRESULT WINAPI ClassMoniker_Destroy(ClassMoniker* This) +static HRESULT ClassMoniker_Destroy(ClassMoniker* This) { TRACE("(%p)\n",This); @@ -693,7 +693,7 @@ static const IROTDataVtbl ROTDataVtbl = /****************************************************************************** * ClassMoniker_Construct (local function) *******************************************************************************/ -static HRESULT WINAPI ClassMoniker_Construct(ClassMoniker* This, REFCLSID rclsid) +static HRESULT ClassMoniker_Construct(ClassMoniker* This, REFCLSID rclsid) { TRACE("(%p,%s)\n",This,debugstr_guid(rclsid)); diff --git a/reactos/dll/win32/ole32/clipboard.c b/reactos/dll/win32/ole32/clipboard.c index 0e9d55c4eca..a3586542d09 100644 --- a/reactos/dll/win32/ole32/clipboard.c +++ b/reactos/dll/win32/ole32/clipboard.c @@ -78,7 +78,9 @@ #include "storage32.h" -#define HANDLE_ERROR(err) { hr = err; TRACE("(HRESULT=%x)\n", (HRESULT)err); goto CLEANUP; } +#include "compobj_private.h" + +#define HANDLE_ERROR(err) do { hr = err; TRACE("(HRESULT=%x)\n", (HRESULT)err); goto CLEANUP; } while (0) WINE_DEFAULT_DEBUG_CHANNEL(ole); @@ -313,6 +315,7 @@ HRESULT WINAPI OleSetClipboard(IDataObject* pDataObj) IEnumFORMATETC* penumFormatetc = NULL; FORMATETC rgelt; BOOL bClipboardOpen = FALSE; + struct oletls *info = COM_CurrentInfo(); /* HGLOBAL hDataObject = 0; OLEClipbrd **ppDataObject; @@ -320,6 +323,12 @@ HRESULT WINAPI OleSetClipboard(IDataObject* pDataObj) TRACE("(%p)\n", pDataObj); + if(!info) + WARN("Could not allocate tls\n"); + else + if(!info->ole_inits) + return CO_E_NOTINITIALIZED; + /* * Make sure we have a clipboard object */ @@ -414,7 +423,7 @@ HRESULT WINAPI OleSetClipboard(IDataObject* pDataObj) if (hDataObject==0) HANDLE_ERROR( E_OUTOFMEMORY ); - ppDataObject = (OLEClipbrd**)GlobalLock(hDataObject); + ppDataObject = GlobalLock(hDataObject); *ppDataObject = theOleClipboard; GlobalUnlock(hDataObject); @@ -958,7 +967,7 @@ static HRESULT OLEClipbrd_RenderFormat(IDataObject *pIDataObject, LPFORMATETC pF if (SUCCEEDED(hr = IDataObject_GetData(theOleClipboard->pIDataObjectSrc, &fmt2, &std2))) { - mfp = (METAFILEPICT *)GlobalLock(std2.u.hGlobal); + mfp = GlobalLock(std2.u.hGlobal); } if (mfp) @@ -1237,7 +1246,8 @@ static HRESULT WINAPI OLEClipbrd_IDataObject_GetData( } if ( pformatetcIn->lindex != -1 ) - return DV_E_LINDEX; + return DV_E_FORMATETC; + if ( (pformatetcIn->tymed & TYMED_HGLOBAL) != TYMED_HGLOBAL ) return DV_E_TYMED; /* diff --git a/reactos/dll/win32/ole32/comcat.c b/reactos/dll/win32/ole32/comcat.c index 9120df09126..f757cf9cc07 100644 --- a/reactos/dll/win32/ole32/comcat.c +++ b/reactos/dll/win32/ole32/comcat.c @@ -181,7 +181,7 @@ static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc, FIXME("Simplified lcid comparison\n"); return CAT_E_NODESCRIPTION; } - pszDesc[size / sizeof(WCHAR)] = (WCHAR)0; + pszDesc[size / sizeof(WCHAR)] = 0; return S_OK; } @@ -531,7 +531,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc( if (res != ERROR_SUCCESS) return CAT_E_CATIDNOEXIST; /* Allocate a sensible amount of memory for the description. */ - *ppszDesc = (PWCHAR) CoTaskMemAlloc(128 * sizeof(WCHAR)); + *ppszDesc = CoTaskMemAlloc(128 * sizeof(WCHAR)); if (*ppszDesc == NULL) { RegCloseKey(key); return E_OUTOFMEMORY; diff --git a/reactos/dll/win32/ole32/compobj.c b/reactos/dll/win32/ole32/compobj.c index 37907eccca1..d77847853f5 100644 --- a/reactos/dll/win32/ole32/compobj.c +++ b/reactos/dll/win32/ole32/compobj.c @@ -63,8 +63,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); -HINSTANCE OLE32_hInstance = 0; - #define ARRAYSIZE(array) (sizeof(array)/sizeof((array)[0])) /**************************************************************************** @@ -209,14 +207,14 @@ static void COMPOBJ_InitProcess( void ) */ memset(&wclass, 0, sizeof(wclass)); wclass.lpfnWndProc = apartment_wndproc; - wclass.hInstance = OLE32_hInstance; + wclass.hInstance = hProxyDll; wclass.lpszClassName = wszAptWinClass; RegisterClassW(&wclass); } static void COMPOBJ_UninitProcess( void ) { - UnregisterClassW(wszAptWinClass, OLE32_hInstance); + UnregisterClassW(wszAptWinClass, hProxyDll); } static void COM_TlsDestroy(void) @@ -227,6 +225,7 @@ static void COM_TlsDestroy(void) if (info->apt) apartment_release(info->apt); if (info->errorinfo) IErrorInfo_Release(info->errorinfo); if (info->state) IUnknown_Release(info->state); + if (info->spy) IUnknown_Release(info->spy); HeapFree(GetProcessHeap(), 0, info); NtCurrentTeb()->ReservedForOle = NULL; } @@ -728,7 +727,7 @@ HRESULT apartment_createwindowifneeded(struct apartment *apt) { HWND hwnd = CreateWindowW(wszAptWinClass, NULL, 0, 0, 0, 0, 0, - HWND_MESSAGE, 0, OLE32_hInstance, NULL); + HWND_MESSAGE, 0, hProxyDll, NULL); if (!hwnd) { ERR("CreateWindow failed with error %d\n", GetLastError()); @@ -1013,6 +1012,80 @@ DWORD WINAPI CoBuildVersion(void) return (rmm<<16)+rup; } +/****************************************************************************** + * CoRegisterInitializeSpy [OLE32.@] + * + * Add a Spy that watches CoInitializeEx calls + * + * PARAMS + * spy [I] Pointer to IUnknown interface that will be QueryInterface'd. + * cookie [II] cookie receiver + * + * RETURNS + * Success: S_OK if not already initialized, S_FALSE otherwise. + * Failure: HRESULT code. + * + * SEE ALSO + * CoInitializeEx + */ +HRESULT WINAPI CoRegisterInitializeSpy(IInitializeSpy *spy, ULARGE_INTEGER *cookie) +{ + struct oletls *info = COM_CurrentInfo(); + HRESULT hr; + + TRACE("(%p, %p)\n", spy, cookie); + + if (!spy || !cookie || !info) + { + if (!info) + WARN("Could not allocate tls\n"); + return E_INVALIDARG; + } + + if (info->spy) + { + FIXME("Already registered?\n"); + return E_UNEXPECTED; + } + + hr = IUnknown_QueryInterface(spy, &IID_IInitializeSpy, (void **) &info->spy); + if (SUCCEEDED(hr)) + { + cookie->QuadPart = (DWORD_PTR)spy; + return S_OK; + } + return hr; +} + +/****************************************************************************** + * CoRevokeInitializeSpy [OLE32.@] + * + * Remove a spy that previously watched CoInitializeEx calls + * + * PARAMS + * cookie [I] The cookie obtained from a previous CoRegisterInitializeSpy call + * + * RETURNS + * Success: S_OK if a spy is removed + * Failure: E_INVALIDARG + * + * SEE ALSO + * CoInitializeEx + */ +HRESULT WINAPI CoRevokeInitializeSpy(ULARGE_INTEGER cookie) +{ + struct oletls *info = COM_CurrentInfo(); + TRACE("(%s)\n", wine_dbgstr_longlong(cookie.QuadPart)); + + if (!info || !info->spy || cookie.QuadPart != (DWORD_PTR)info->spy) + return E_INVALIDARG; + + IUnknown_Release(info->spy); + info->spy = NULL; + return S_OK; +} + + /****************************************************************************** * CoInitialize [OLE32.@] * @@ -1069,6 +1142,7 @@ HRESULT WINAPI CoInitialize(LPVOID lpReserved) */ HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit) { + struct oletls *info = COM_CurrentInfo(); HRESULT hr = S_OK; APARTMENT *apt; @@ -1096,7 +1170,10 @@ HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit) RunningObjectTableImpl_Initialize(); } - if (!(apt = COM_CurrentInfo()->apt)) + if (info->spy) + IInitializeSpy_PreInitialize(info->spy, dwCoInit, info->inits); + + if (!(apt = info->apt)) { apt = apartment_get_or_create(dwCoInit); if (!apt) return E_OUTOFMEMORY; @@ -1113,7 +1190,10 @@ HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit) else hr = S_FALSE; - COM_CurrentInfo()->inits++; + info->inits++; + + if (info->spy) + IInitializeSpy_PostInitialize(info->spy, hr, dwCoInit, info->inits); return hr; } @@ -1144,10 +1224,16 @@ void WINAPI CoUninitialize(void) /* will only happen on OOM */ if (!info) return; + if (info->spy) + IInitializeSpy_PreUninitialize(info->spy, info->inits); + /* sanity check */ if (!info->inits) { ERR("Mismatched CoUninitialize\n"); + + if (info->spy) + IInitializeSpy_PostUninitialize(info->spy, info->inits); return; } @@ -1173,6 +1259,8 @@ void WINAPI CoUninitialize(void) ERR( "CoUninitialize() - not CoInitialized.\n" ); InterlockedExchangeAdd(&s_COMLockCount,1); /* restore the lock count. */ } + if (info->spy) + IInitializeSpy_PostUninitialize(info->spy, info->inits); } /****************************************************************************** @@ -1267,7 +1355,7 @@ HRESULT WINAPI CoCreateGuid(GUID *pguid) * SEE ALSO * StringFromCLSID */ -static HRESULT WINAPI __CLSIDFromString(LPCWSTR s, CLSID *id) +static HRESULT __CLSIDFromString(LPCWSTR s, CLSID *id) { int i; BYTE table[256]; @@ -3771,7 +3859,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) switch(fdwReason) { case DLL_PROCESS_ATTACH: - OLE32_hInstance = hinstDLL; + hProxyDll = hinstDLL; COMPOBJ_InitProcess(); if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1); break; @@ -3782,7 +3870,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) COMPOBJ_UninitProcess(); RPC_UnregisterAllChannelHooks(); COMPOBJ_DllList_Free(); - OLE32_hInstance = 0; break; case DLL_THREAD_DETACH: diff --git a/reactos/dll/win32/ole32/compobj_private.h b/reactos/dll/win32/ole32/compobj_private.h index 81d591ea3fb..3c3e96d94e9 100644 --- a/reactos/dll/win32/ole32/compobj_private.h +++ b/reactos/dll/win32/ole32/compobj_private.h @@ -175,6 +175,7 @@ struct oletls struct apartment *apt; IErrorInfo *errorinfo; /* see errorinfo.c */ IUnknown *state; /* see CoSetState */ + IInitializeSpy *spy; /* The "SPY" from CoInitializeSpy */ DWORD inits; /* number of times CoInitializeEx called */ DWORD ole_inits; /* number of times OleInitialize called */ GUID causality_id; /* unique identifier for each COM call */ @@ -211,7 +212,6 @@ struct stub_manager *get_stub_manager_from_object(APARTMENT *apt, void *object); BOOL stub_manager_notify_unmarshal(struct stub_manager *m, const IPID *ipid); BOOL stub_manager_is_table_marshaled(struct stub_manager *m, const IPID *ipid); void stub_manager_release_marshal_data(struct stub_manager *m, ULONG refs, const IPID *ipid, BOOL tableweak); -HRESULT ipid_to_stub_manager(const IPID *ipid, APARTMENT **stub_apt, struct stub_manager **stubmgr_ret); HRESULT ipid_get_dispatch_params(const IPID *ipid, APARTMENT **stub_apt, IRpcStubBuffer **stub, IRpcChannelBuffer **chan, IID *iid, IUnknown **iface); HRESULT start_apartment_remote_unknown(void); @@ -302,12 +302,16 @@ static inline GUID COM_CurrentCausalityId(void) # define DEBUG_SET_CRITSEC_NAME(cs, name) (cs)->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": " name) # define DEBUG_CLEAR_CRITSEC_NAME(cs) (cs)->DebugInfo->Spare[0] = 0 -extern HINSTANCE OLE32_hInstance; /* FIXME: make static */ - #define CHARS_IN_GUID 39 /* including NULL */ #define WINE_CLSCTX_DONT_HOST 0x80000000 +/* from dlldata.c */ +extern HINSTANCE hProxyDll DECLSPEC_HIDDEN; +extern HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN; +extern HRESULT WINAPI OLE32_DllRegisterServer(void) DECLSPEC_HIDDEN; +extern HRESULT WINAPI OLE32_DllUnregisterServer(void) DECLSPEC_HIDDEN; + /* Exported non-interface Data Advise Holder functions */ HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate); void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface); diff --git a/reactos/dll/win32/ole32/defaulthandler.c b/reactos/dll/win32/ole32/defaulthandler.c index 6844ee86b3a..5c6f9b2d72f 100644 --- a/reactos/dll/win32/ole32/defaulthandler.c +++ b/reactos/dll/win32/ole32/defaulthandler.c @@ -71,6 +71,12 @@ enum storage_state storage_state_loaded }; +enum object_state +{ + object_state_not_running, + object_state_running +}; + /**************************************************************************** * DefaultHandler * @@ -123,6 +129,7 @@ struct DefaultHandler IPersistStorage *pPSDelegate; /* IDataObject delegate */ IDataObject *pDataDelegate; + enum object_state object_state; /* connection cookie for the advise on the delegate OLE object */ DWORD dwAdvConn; @@ -420,6 +427,25 @@ static HRESULT WINAPI DefaultHandler_SetHostNames( return S_OK; } +static void release_delegates(DefaultHandler *This) +{ + if (This->pDataDelegate) + { + IDataObject_Release(This->pDataDelegate); + This->pDataDelegate = NULL; + } + if (This->pPSDelegate) + { + IPersistStorage_Release(This->pPSDelegate); + This->pPSDelegate = NULL; + } + if (This->pOleDelegate) + { + IOleObject_Release(This->pOleDelegate); + This->pOleDelegate = NULL; + } +} + /* undoes the work done by DefaultHandler_Run */ static void DefaultHandler_Stop(DefaultHandler *This) { @@ -432,18 +458,8 @@ static void DefaultHandler_Stop(DefaultHandler *This) if (This->dataAdviseHolder) DataAdviseHolder_OnDisconnect(This->dataAdviseHolder); - if (This->pDataDelegate) - { - IDataObject_Release(This->pDataDelegate); - This->pDataDelegate = NULL; - } - if (This->pPSDelegate) - { - IPersistStorage_Release(This->pPSDelegate); - This->pPSDelegate = NULL; - } - IOleObject_Release(This->pOleDelegate); - This->pOleDelegate = NULL; + + This->object_state = object_state_not_running; } /************************************************************************ @@ -469,6 +485,7 @@ static HRESULT WINAPI DefaultHandler_Close( hr = IOleObject_Close(This->pOleDelegate, dwSaveOption); DefaultHandler_Stop(This); + release_delegates(This); return hr; } @@ -1296,11 +1313,15 @@ static HRESULT WINAPI DefaultHandler_Run( if (object_is_running(This)) return S_OK; + release_delegates(This); + hr = CoCreateInstance(&This->clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_IOleObject, (void **)&This->pOleDelegate); if (FAILED(hr)) return hr; + This->object_state = object_state_running; + hr = IOleObject_Advise(This->pOleDelegate, (IAdviseSink *)&This->lpvtblIAdviseSink, &This->dwAdvConn); @@ -1339,7 +1360,10 @@ static HRESULT WINAPI DefaultHandler_Run( hr = DataAdviseHolder_OnConnect(This->dataAdviseHolder, This->pDataDelegate); if (FAILED(hr)) + { DefaultHandler_Stop(This); + release_delegates(This); + } return hr; } @@ -1356,7 +1380,7 @@ static BOOL WINAPI DefaultHandler_IsRunning( TRACE("()\n"); - if (This->pOleDelegate) + if (This->object_state == object_state_running) return TRUE; else return FALSE; @@ -1934,6 +1958,7 @@ static DefaultHandler* DefaultHandler_Construct( This->pOleDelegate = NULL; This->pPSDelegate = NULL; This->pDataDelegate = NULL; + This->object_state = object_state_not_running; This->dwAdvConn = 0; This->storage = NULL; @@ -1947,6 +1972,7 @@ static void DefaultHandler_Destroy( { /* release delegates */ DefaultHandler_Stop(This); + release_delegates(This); HeapFree( GetProcessHeap(), 0, This->containerApp ); This->containerApp = NULL; diff --git a/reactos/dll/win32/ole32/errorinfo.c b/reactos/dll/win32/ole32/errorinfo.c index e4a1c47ac53..0009ebee357 100644 --- a/reactos/dll/win32/ole32/errorinfo.c +++ b/reactos/dll/win32/ole32/errorinfo.c @@ -42,7 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); /* this code is from SysAllocStringLen (ole2disp.c in oleaut32) */ -static BSTR WINAPI ERRORINFO_SysAllocString(const OLECHAR* in) +static BSTR ERRORINFO_SysAllocString(const OLECHAR* in) { DWORD bufferSize; DWORD* newBuffer; @@ -99,7 +99,7 @@ static BSTR WINAPI ERRORINFO_SysAllocString(const OLECHAR* in) } /* this code is from SysFreeString (ole2disp.c in oleaut32)*/ -static VOID WINAPI ERRORINFO_SysFreeString(BSTR in) +static VOID ERRORINFO_SysFreeString(BSTR in) { DWORD* bufferPointer; diff --git a/reactos/dll/win32/ole32/filemoniker.c b/reactos/dll/win32/ole32/filemoniker.c index 3dae13970aa..0da643fb4ff 100644 --- a/reactos/dll/win32/ole32/filemoniker.c +++ b/reactos/dll/win32/ole32/filemoniker.c @@ -63,8 +63,8 @@ static inline IMoniker *impl_from_IROTData( IROTData *iface ) } /* Local function used by filemoniker implementation */ -static HRESULT WINAPI FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName); -static HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* iface); +static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName); +static HRESULT FileMonikerImpl_Destroy(FileMonikerImpl* iface); /******************************************************************************* * FileMoniker_QueryInterface @@ -456,7 +456,7 @@ FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize) /****************************************************************************** * FileMoniker_Destroy (local function) *******************************************************************************/ -HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* This) +HRESULT FileMonikerImpl_Destroy(FileMonikerImpl* This) { TRACE("(%p)\n",This); @@ -1333,8 +1333,7 @@ static const IROTDataVtbl VT_ROTDataImpl = /****************************************************************************** * FileMoniker_Construct (local function) */ -static HRESULT WINAPI -FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPathName) +static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPathName) { int nb=0,i; int sizeStr=lstrlenW(lpszPathName); diff --git a/reactos/dll/win32/ole32/itemmoniker.c b/reactos/dll/win32/ole32/itemmoniker.c index 1a8822a596c..08b1fe48a91 100644 --- a/reactos/dll/win32/ole32/itemmoniker.c +++ b/reactos/dll/win32/ole32/itemmoniker.c @@ -97,8 +97,8 @@ static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* static HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys); /* Local function used by ItemMoniker implementation */ -static HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* iface, LPCOLESTR lpszDelim,LPCOLESTR lpszPathName); -static HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* iface); +static HRESULT ItemMonikerImpl_Construct(ItemMonikerImpl* iface, LPCOLESTR lpszDelim,LPCOLESTR lpszPathName); +static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* iface); /********************************************************************************/ /* IROTData prototype functions */ @@ -391,7 +391,7 @@ HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, /****************************************************************************** * ItemMoniker_Construct (local function) *******************************************************************************/ -static HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem) +static HRESULT ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem) { int sizeStr1=lstrlenW(lpszItem), sizeStr2; @@ -429,7 +429,7 @@ static HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR /****************************************************************************** * ItemMoniker_Destroy (local function) *******************************************************************************/ -static HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* This) +static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* This) { TRACE("(%p)\n",This); diff --git a/reactos/dll/win32/ole32/memlockbytes16.c b/reactos/dll/win32/ole32/memlockbytes16.c index bccb953c735..bca7aa103ab 100644 --- a/reactos/dll/win32/ole32/memlockbytes16.c +++ b/reactos/dll/win32/ole32/memlockbytes16.c @@ -193,7 +193,7 @@ HRESULT CDECL HGLOBALLockBytesImpl16_QueryInterface( REFIID riid, /* [in] */ void** ppvObject) /* [out][iid_is] (ptr to SEGPTR!) */ { - HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)MapSL((SEGPTR)iface); + HGLOBALLockBytesImpl16* const This = MapSL((SEGPTR)iface); TRACE("(%p,%s,%p)\n",iface,debugstr_guid(riid),ppvObject); /* diff --git a/reactos/dll/win32/ole32/moniker.c b/reactos/dll/win32/ole32/moniker.c index 4e5646279b2..c5b5c2f5845 100644 --- a/reactos/dll/win32/ole32/moniker.c +++ b/reactos/dll/win32/ole32/moniker.c @@ -93,7 +93,7 @@ typedef struct EnumMonikerImpl /* IEnumMoniker Local functions*/ -static HRESULT WINAPI EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list, +static HRESULT EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list, ULONG pos, IEnumMoniker **ppenumMoniker); static IrotHandle get_irot_handle(void) @@ -342,7 +342,7 @@ RunningObjectTableImpl_AddRef(IRunningObjectTable* iface) /*********************************************************************** * RunningObjectTable_Initialize */ -static HRESULT WINAPI +static HRESULT RunningObjectTableImpl_Destroy(void) { struct list *cursor, *cursor2; @@ -1463,7 +1463,7 @@ static const IEnumMonikerVtbl VT_EnumMonikerImpl = * Used by EnumRunning to create the structure and EnumClone * to copy the structure */ -static HRESULT WINAPI EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list, +static HRESULT EnumMonikerImpl_CreateEnumROTMoniker(InterfaceList *moniker_list, ULONG current_pos, IEnumMoniker **ppenumMoniker) { diff --git a/reactos/dll/win32/ole32/ole16.c b/reactos/dll/win32/ole32/ole16.c index d19a817851c..a8fa59bceb7 100644 --- a/reactos/dll/win32/ole32/ole16.c +++ b/reactos/dll/win32/ole32/ole16.c @@ -572,7 +572,7 @@ SEGPTR WINAPI CoMemAlloc(DWORD size, DWORD dwMemContext, DWORD x) { TRACE("(%d, 0x%08x, 0x%08x)\n", size, dwMemContext, x); hres = _xmalloc16(size, &segptr); if (hres != S_OK) - return (SEGPTR)0; + return 0; return segptr; } diff --git a/reactos/dll/win32/ole32/ole2.c b/reactos/dll/win32/ole32/ole2.c index bdbf6da7861..a2ff9b791ba 100644 --- a/reactos/dll/win32/ole32/ole2.c +++ b/reactos/dll/win32/ole32/ole2.c @@ -1405,7 +1405,7 @@ static LRESULT CALLBACK OLEMenu_CallWndProc(INT code, WPARAM wParam, LPARAM lPar goto NEXTHOOK; /* Get the menu descriptor */ - pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu ); + pOleMenuDescriptor = GlobalLock( hOleMenu ); if ( !pOleMenuDescriptor ) /* Bad descriptor! */ goto NEXTHOOK; @@ -1524,7 +1524,7 @@ static LRESULT CALLBACK OLEMenu_GetMsgProc(INT code, WPARAM wParam, LPARAM lPara } /* Get the menu descriptor */ - pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu ); + pOleMenuDescriptor = GlobalLock( hOleMenu ); if ( !pOleMenuDescriptor ) /* Bad descriptor! */ goto NEXTHOOK; @@ -1579,7 +1579,7 @@ HOLEMENU WINAPI OleCreateMenuDescriptor( sizeof(OleMenuDescriptor) ) ) ) return 0; - pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu ); + pOleMenuDescriptor = GlobalLock( hOleMenu ); if ( !pOleMenuDescriptor ) return 0; @@ -1664,7 +1664,7 @@ HRESULT WINAPI OleSetMenuDescriptor( return E_FAIL; /* Get the menu descriptor */ - pOleMenuDescriptor = (OleMenuDescriptor *) GlobalLock( hOleMenu ); + pOleMenuDescriptor = GlobalLock( hOleMenu ); if ( !pOleMenuDescriptor ) return E_UNEXPECTED; @@ -2119,19 +2119,19 @@ static void OLEDD_TrackMouseMove(TrackerWindowInfo* trackerInfo) { if (*trackerInfo->pdwEffect & DROPEFFECT_MOVE) { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(1))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(1))); } else if (*trackerInfo->pdwEffect & DROPEFFECT_COPY) { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(2))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(2))); } else if (*trackerInfo->pdwEffect & DROPEFFECT_LINK) { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(3))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(3))); } else { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(0))); } } } @@ -2815,6 +2815,22 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, /* [out] */ switch(pvarSrc->vt) { + case VT_EMPTY: + case VT_NULL: + case VT_I1: + case VT_UI1: + case VT_I2: + case VT_UI2: + case VT_BOOL: + case VT_I4: + case VT_UI4: + case VT_R4: + case VT_ERROR: + case VT_I8: + case VT_UI8: + case VT_R8: + case VT_CY: + case VT_DATE: case VT_FILETIME: break; case VT_STREAM: diff --git a/reactos/dll/win32/ole32/ole2_16.c b/reactos/dll/win32/ole32/ole2_16.c index 90a1ed20237..fc88d8ae688 100644 --- a/reactos/dll/win32/ole32/ole2_16.c +++ b/reactos/dll/win32/ole32/ole2_16.c @@ -113,7 +113,7 @@ HGLOBAL16 WINAPI OleMetaFilePictFromIconAndLabel16( hmf = CloseMetaFile(hdc); hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16)); - mf16 = (METAFILEPICT16 *)GlobalLock16(hmf16); + mf16 = GlobalLock16(hmf16); mf16->mm = MM_ANISOTROPIC; mf16->xExt = 20; /* FIXME: bogus */ mf16->yExt = 20; /* ditto */ diff --git a/reactos/dll/win32/ole32/ole32.rbuild b/reactos/dll/win32/ole32/ole32.rbuild index 514e4bea110..66221ec1525 100644 --- a/reactos/dll/win32/ole32/ole32.rbuild +++ b/reactos/dll/win32/ole32/ole32.rbuild @@ -9,6 +9,9 @@ 0x600 + OLE32_ + CLSID_PSFactoryBuffer + wine advapi32 @@ -74,6 +77,9 @@ + OLE32_ + CLSID_PSFactoryBuffer + dcom.idl ole32_unknwn.idl ole32_objidl.idl diff --git a/reactos/dll/win32/ole32/ole32.spec b/reactos/dll/win32/ole32/ole32.spec index e5e90b3e15c..79376acb8c0 100644 --- a/reactos/dll/win32/ole32/ole32.spec +++ b/reactos/dll/win32/ole32/ole32.spec @@ -57,6 +57,7 @@ @ stub CoQueryReleaseObject @ stdcall CoRegisterChannelHook(ptr ptr) @ stdcall CoRegisterClassObject(ptr ptr long long ptr) +@ stdcall CoRegisterInitializeSpy(ptr ptr) @ stdcall CoRegisterMallocSpy (ptr) @ stdcall CoRegisterMessageFilter(ptr ptr) @ stdcall CoRegisterPSClsid(ptr ptr) @@ -67,6 +68,7 @@ @ stdcall CoResumeClassObjects() @ stdcall CoRevertToSelf() @ stdcall CoRevokeClassObject(long) +@ stdcall CoRevokeInitializeSpy(double) @ stdcall CoRevokeMallocSpy() @ stdcall CoSetProxyBlanket(ptr long long wstr long long ptr long) @ stdcall CoSetState(ptr) diff --git a/reactos/dll/win32/ole32/ole32_ros.diff b/reactos/dll/win32/ole32/ole32_ros.diff deleted file mode 100644 index f26156b7084..00000000000 --- a/reactos/dll/win32/ole32/ole32_ros.diff +++ /dev/null @@ -1,12 +0,0 @@ -Index: ole32.rbuild -=================================================================== ---- ole32.rbuild (revision 31639) -+++ ole32.rbuild (working copy) -@@ -13,6 +13,7 @@ - advapi32 - user32 - gdi32 -+ ole32_irot_client - rpcrt4 - kernel32 - ntdll diff --git a/reactos/dll/win32/ole32/oleproxy.c b/reactos/dll/win32/ole32/oleproxy.c index 99a86f009e3..11a3ad12d8b 100644 --- a/reactos/dll/win32/ole32/oleproxy.c +++ b/reactos/dll/win32/ole32/oleproxy.c @@ -36,33 +36,11 @@ #include "objbase.h" #include "ole2.h" #include "rpc.h" -#include "rpcproxy.h" #include "compobj_private.h" #include "moniker.h" #include "comcat.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ole); - -static CStdPSFactoryBuffer PSFactoryBuffer; - -CSTDSTUBBUFFERRELEASE(&PSFactoryBuffer) - -extern const ExtendedProxyFileInfo dcom_ProxyFileInfo; -extern const ExtendedProxyFileInfo ole32_objidl_ProxyFileInfo; -extern const ExtendedProxyFileInfo ole32_oleidl_ProxyFileInfo; -extern const ExtendedProxyFileInfo ole32_unknwn_ProxyFileInfo; - -static const ProxyFileInfo *OLE32_ProxyFileList[] = { - &dcom_ProxyFileInfo, - &ole32_objidl_ProxyFileInfo, - &ole32_oleidl_ProxyFileInfo, - &ole32_unknwn_ProxyFileInfo, - NULL -}; - /*********************************************************************** * DllGetClassObject [OLE32.@] */ @@ -92,6 +70,5 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) if (IsEqualGUID(rclsid, &CLSID_StdComponentCategoriesMgr)) return ComCatCF_Create(iid, ppv); - return NdrDllGetClassObject(rclsid, iid, ppv, OLE32_ProxyFileList, - &CLSID_PSFactoryBuffer, &PSFactoryBuffer); + return OLE32_DllGetClassObject(rclsid, iid, ppv); } diff --git a/reactos/dll/win32/ole32/regsvr.c b/reactos/dll/win32/ole32/regsvr.c index 07ddde01661..17e78eff0fe 100644 --- a/reactos/dll/win32/ole32/regsvr.c +++ b/reactos/dll/win32/ole32/regsvr.c @@ -38,6 +38,7 @@ #include "moniker.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); @@ -155,7 +156,7 @@ static HRESULT register_interfaces(struct regsvr_interface const *list) KEY_READ | KEY_WRITE, NULL, &key, NULL); if (res != ERROR_SUCCESS) goto error_close_iid_key; - wsprintfW(buf, fmt, list->num_methods); + sprintfW(buf, fmt, list->num_methods); res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)buf, (lstrlenW(buf) + 1) * sizeof(WCHAR)); @@ -509,69 +510,38 @@ static struct regsvr_coclass const coclass_list[] = { * interface list */ -#define INTERFACE_ENTRY(interface, base, clsid32, clsid16) { &IID_##interface, #interface, base, sizeof(interface##Vtbl)/sizeof(void*), clsid16, clsid32 } -#define BAS_INTERFACE_ENTRY(interface, base) INTERFACE_ENTRY(interface, &IID_##base, &CLSID_PSFactoryBuffer, NULL) -#define STD_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer, NULL) -#define ACTX_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer_actxprxy, NULL) -#define LCL_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, NULL, NULL) +#define INTERFACE_ENTRY(interface, base, clsid32) { &IID_##interface, #interface, base, sizeof(interface##Vtbl)/sizeof(void*), NULL, clsid32 } +#define BAS_INTERFACE_ENTRY(interface, base) INTERFACE_ENTRY(interface, &IID_##base, NULL) +#define ACTX_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer_actxprxy) +#define LCL_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, NULL) static const struct regsvr_interface interface_list[] = { LCL_INTERFACE_ENTRY(IUnknown), - STD_INTERFACE_ENTRY(IClassFactory), LCL_INTERFACE_ENTRY(IMalloc), LCL_INTERFACE_ENTRY(IMarshal), - STD_INTERFACE_ENTRY(ILockBytes), - STD_INTERFACE_ENTRY(IStorage), - STD_INTERFACE_ENTRY(IStream), - STD_INTERFACE_ENTRY(IEnumSTATSTG), - STD_INTERFACE_ENTRY(IBindCtx), BAS_INTERFACE_ENTRY(IMoniker, IPersistStream), - STD_INTERFACE_ENTRY(IRunningObjectTable), - STD_INTERFACE_ENTRY(IRootStorage), LCL_INTERFACE_ENTRY(IMessageFilter), LCL_INTERFACE_ENTRY(IStdMarshalInfo), LCL_INTERFACE_ENTRY(IExternalConnection), LCL_INTERFACE_ENTRY(IMallocSpy), LCL_INTERFACE_ENTRY(IMultiQI), - STD_INTERFACE_ENTRY(IEnumUnknown), - STD_INTERFACE_ENTRY(IEnumString), - STD_INTERFACE_ENTRY(IEnumMoniker), - STD_INTERFACE_ENTRY(IEnumFORMATETC), - STD_INTERFACE_ENTRY(IEnumOLEVERB), - STD_INTERFACE_ENTRY(IEnumSTATDATA), BAS_INTERFACE_ENTRY(IPersistStream, IPersist), BAS_INTERFACE_ENTRY(IPersistStorage, IPersist), BAS_INTERFACE_ENTRY(IPersistFile, IPersist), - STD_INTERFACE_ENTRY(IPersist), - STD_INTERFACE_ENTRY(IViewObject), - STD_INTERFACE_ENTRY(IDataObject), - STD_INTERFACE_ENTRY(IAdviseSink), LCL_INTERFACE_ENTRY(IDataAdviseHolder), LCL_INTERFACE_ENTRY(IOleAdviseHolder), - STD_INTERFACE_ENTRY(IOleObject), BAS_INTERFACE_ENTRY(IOleInPlaceObject, IOleWindow), - STD_INTERFACE_ENTRY(IOleWindow), BAS_INTERFACE_ENTRY(IOleInPlaceUIWindow, IOleWindow), - STD_INTERFACE_ENTRY(IOleInPlaceFrame), BAS_INTERFACE_ENTRY(IOleInPlaceActiveObject, IOleWindow), - STD_INTERFACE_ENTRY(IOleClientSite), BAS_INTERFACE_ENTRY(IOleInPlaceSite, IOleWindow), - STD_INTERFACE_ENTRY(IParseDisplayName), BAS_INTERFACE_ENTRY(IOleContainer, IParseDisplayName), BAS_INTERFACE_ENTRY(IOleItemContainer, IOleContainer), - STD_INTERFACE_ENTRY(IOleLink), - STD_INTERFACE_ENTRY(IOleCache), LCL_INTERFACE_ENTRY(IDropSource), - STD_INTERFACE_ENTRY(IDropTarget), BAS_INTERFACE_ENTRY(IAdviseSink2, IAdviseSink), - STD_INTERFACE_ENTRY(IRunnableObject), BAS_INTERFACE_ENTRY(IViewObject2, IViewObject), BAS_INTERFACE_ENTRY(IOleCache2, IOleCache), - STD_INTERFACE_ENTRY(IOleCacheControl), - STD_INTERFACE_ENTRY(IRemUnknown), LCL_INTERFACE_ENTRY(IClientSecurity), LCL_INTERFACE_ENTRY(IServerSecurity), - STD_INTERFACE_ENTRY(ISequentialStream), ACTX_INTERFACE_ENTRY(IEnumGUID), ACTX_INTERFACE_ENTRY(IEnumCATEGORYINFO), ACTX_INTERFACE_ENTRY(ICatRegister), @@ -588,7 +558,9 @@ HRESULT WINAPI DllRegisterServer(void) TRACE("\n"); - hr = register_coclasses(coclass_list); + hr = OLE32_DllRegisterServer(); + if (SUCCEEDED(hr)) + hr = register_coclasses(coclass_list); if (SUCCEEDED(hr)) hr = register_interfaces(interface_list); return hr; @@ -606,5 +578,7 @@ HRESULT WINAPI DllUnregisterServer(void) hr = unregister_coclasses(coclass_list); if (SUCCEEDED(hr)) hr = unregister_interfaces(interface_list); + if (SUCCEEDED(hr)) + hr = OLE32_DllUnregisterServer(); return hr; } diff --git a/reactos/dll/win32/ole32/stg_bigblockfile.c b/reactos/dll/win32/ole32/stg_bigblockfile.c index b0e54e5ef52..a2ee1deca2a 100644 --- a/reactos/dll/win32/ole32/stg_bigblockfile.c +++ b/reactos/dll/win32/ole32/stg_bigblockfile.c @@ -725,7 +725,7 @@ static DWORD BIGBLOCKFILE_GetProtectMode(DWORD openFlags) * * See the documentation of ILockBytes for more info. */ -static HRESULT WINAPI ImplBIGBLOCKFILE_ReadAt( +static HRESULT ImplBIGBLOCKFILE_ReadAt( BigBlockFile* const This, ULARGE_INTEGER ulOffset, /* [in] */ void* pv, /* [length_is][size_is][out] */ @@ -812,7 +812,7 @@ static HRESULT WINAPI ImplBIGBLOCKFILE_ReadAt( * * See the documentation of ILockBytes for more info. */ -static HRESULT WINAPI ImplBIGBLOCKFILE_WriteAt( +static HRESULT ImplBIGBLOCKFILE_WriteAt( BigBlockFile* const This, ULARGE_INTEGER ulOffset, /* [in] */ const void* pv, /* [size_is][in] */ diff --git a/reactos/dll/win32/ole32/storage.c b/reactos/dll/win32/ole32/storage.c index d356c676220..7e345dc71dc 100644 --- a/reactos/dll/win32/ole32/storage.c +++ b/reactos/dll/win32/ole32/storage.c @@ -706,8 +706,7 @@ STORAGE_look_for_named_pps(stream_access16*str,int n,LPOLESTR name) { /****************************************************************************** * STORAGE_dump_pps_entry [Internal] * - * FIXME - * Function is unused + * This function is there to simplify debugging. It is otherwise unused. */ void STORAGE_dump_pps_entry(struct storage_pps_entry *stde) { @@ -1623,46 +1622,6 @@ typedef struct ULARGE_INTEGER offset; } IStream32Impl; -/***************************************************************************** - * IStream32_QueryInterface [VTABLE] - */ -HRESULT WINAPI IStream_fnQueryInterface( - IStream* iface,REFIID refiid,LPVOID *obj -) { - IStream32Impl *This = (IStream32Impl *)iface; - - TRACE_(relay)("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj); - if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) { - *obj = This; - return 0; - } - return OLE_E_ENUM_NOMORE; - -} - -/****************************************************************************** - * IStream32_AddRef [VTABLE] - */ -ULONG WINAPI IStream_fnAddRef(IStream* iface) { - IStream32Impl *This = (IStream32Impl *)iface; - return InterlockedIncrement(&This->ref); -} - -/****************************************************************************** - * IStream32_Release [VTABLE] - */ -ULONG WINAPI IStream_fnRelease(IStream* iface) { - IStream32Impl *This = (IStream32Impl *)iface; - ULONG ref; - FlushFileBuffers(This->hf); - ref = InterlockedDecrement(&This->ref); - if (!ref) { - CloseHandle(This->hf); - HeapFree( GetProcessHeap(), 0, This ); - } - return ref; -} - /****************************************************************************** * IStorage16_QueryInterface [STORAGE.500] */ diff --git a/reactos/dll/win32/ole32/storage.spec b/reactos/dll/win32/ole32/storage.spec index 58273caa449..d4933a7f947 100644 --- a/reactos/dll/win32/ole32/storage.spec +++ b/reactos/dll/win32/ole32/storage.spec @@ -22,12 +22,10 @@ 500 cdecl IStorage16_QueryInterface(ptr ptr ptr) IStorage16_fnQueryInterface 501 cdecl IStorage16_AddRef(ptr) IStorage16_fnAddRef 502 cdecl IStorage16_Release(ptr) IStorage16_fnRelease -#503 cdecl IStorage16_CreateStream(ptr str long long long ptr) IStorage16_fnCreateStream -503 stub IStorage16_CreateStream +503 cdecl IStorage16_CreateStream(ptr str long long long ptr) IStorage16_fnCreateStream 504 cdecl IStorage16_OpenStream(ptr str ptr long long ptr) IStorage16_fnOpenStream -#505 cdecl IStorage16_CreateStorage(ptr str long long long ptr) IStorage16_fnCreateStorage -505 stub IStorage16_CreateStorage +505 cdecl IStorage16_CreateStorage(ptr str long long long ptr) IStorage16_fnCreateStorage 506 cdecl IStorage16_OpenStorage(ptr str ptr long ptr long ptr) IStorage16_fnOpenStorage 507 cdecl IStorage16_CopyTo(ptr long ptr ptr ptr) IStorage16_fnCopyTo 508 stub IStorage16_MoveElementTo @@ -46,8 +44,7 @@ 519 cdecl IStream16_AddRef(ptr) IStream16_fnAddRef 520 cdecl IStream16_Release(ptr) IStream16_fnRelease 521 cdecl IStream16_Read(ptr ptr long ptr) IStream16_fnRead -#522 cdecl IStream16_Write(ptr ptr long ptr) IStream16_fnWrite -522 stub IStream16_Write +522 cdecl IStream16_Write(ptr ptr long ptr) IStream16_fnWrite 523 cdecl IStream16_Seek(ptr double long ptr) IStream16_fnSeek 524 stub IStream16_SetSize 525 stub IStream16_CopyTo diff --git a/reactos/dll/win32/ole32/storage32.c b/reactos/dll/win32/ole32/storage32.c index 3c88a36f766..fe848046861 100644 --- a/reactos/dll/win32/ole32/storage32.c +++ b/reactos/dll/win32/ole32/storage32.c @@ -6606,7 +6606,7 @@ static HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM if(hRes == S_OK) { - /* Get the TypeID...more info needed for this field */ + /* Get the TypeID... more info needed for this field */ dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID)); if(dwSize != sizeof(pData->dwTypeID)) { diff --git a/reactos/dll/win32/ole32/stubmanager.c b/reactos/dll/win32/ole32/stubmanager.c index 9918fbc94bd..61bb0cfee06 100644 --- a/reactos/dll/win32/ole32/stubmanager.c +++ b/reactos/dll/win32/ole32/stubmanager.c @@ -367,7 +367,7 @@ static struct stub_manager *get_stub_manager_from_ipid(APARTMENT *apt, const IPI return result; } -HRESULT ipid_to_stub_manager(const IPID *ipid, APARTMENT **stub_apt, struct stub_manager **stubmgr_ret) +static HRESULT ipid_to_stub_manager(const IPID *ipid, APARTMENT **stub_apt, struct stub_manager **stubmgr_ret) { /* FIXME: hack for IRemUnknown */ if (ipid->Data2 == 0xffff) diff --git a/reactos/dll/win32/ole32/usrmarshal.c b/reactos/dll/win32/ole32/usrmarshal.c index e504485cb08..8aed5d695e5 100644 --- a/reactos/dll/win32/ole32/usrmarshal.c +++ b/reactos/dll/win32/ole32/usrmarshal.c @@ -260,7 +260,7 @@ void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF) * so nothing to do */ } -static ULONG __RPC_USER handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle) +static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle) { if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE) { @@ -271,7 +271,7 @@ static ULONG __RPC_USER handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDL return StartingSize + sizeof(RemotableHandle); } -static unsigned char * __RPC_USER handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle) +static unsigned char * handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle) { RemotableHandle *remhandle = (RemotableHandle *)pBuffer; if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE) @@ -285,7 +285,7 @@ static unsigned char * __RPC_USER handle_UserMarshal(ULONG *pFlags, unsigned cha return pBuffer + sizeof(RemotableHandle); } -static unsigned char * __RPC_USER handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle) +static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle) { RemotableHandle *remhandle = (RemotableHandle *)pBuffer; if (remhandle->fContext != WDT_INPROC_CALL) @@ -294,7 +294,7 @@ static unsigned char * __RPC_USER handle_UserUnmarshal(ULONG *pFlags, unsigned c return pBuffer + sizeof(RemotableHandle); } -static void __RPC_USER handle_UserFree(ULONG *pFlags, HANDLE *phMenu) +static void handle_UserFree(ULONG *pFlags, HANDLE *phMenu) { /* nothing to do */ } @@ -1891,25 +1891,26 @@ void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium) ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium) { - FIXME(":stub\n"); - return StartingSize; + TRACE("\n"); + return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium); } unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium) { - FIXME(":stub\n"); - return pBuffer; + TRACE("\n"); + return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium); } unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium) { - FIXME(":stub\n"); - return pBuffer; + TRACE("\n"); + return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium); } void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium) { - FIXME(":stub\n"); + TRACE("\n"); + STGMEDIUM_UserFree(pFlags, pStgMedium); } ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium) diff --git a/reactos/dll/win32/oleaut32/dispatch.c b/reactos/dll/win32/oleaut32/dispatch.c index 057e39a46a4..4dfc47074ae 100644 --- a/reactos/dll/win32/oleaut32/dispatch.c +++ b/reactos/dll/win32/oleaut32/dispatch.c @@ -39,7 +39,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); -static IDispatch * WINAPI StdDispatch_Construct(IUnknown * punkOuter, void * pvThis, ITypeInfo * pTypeInfo); +static IDispatch * StdDispatch_Construct(IUnknown * punkOuter, void * pvThis, ITypeInfo * pTypeInfo); /****************************************************************************** * DispInvoke (OLEAUT32.30) @@ -425,7 +425,7 @@ static const IDispatchVtbl StdDispatch_VTable = StdDispatch_Invoke }; -static IDispatch * WINAPI StdDispatch_Construct( +static IDispatch * StdDispatch_Construct( IUnknown * punkOuter, void * pvThis, ITypeInfo * pTypeInfo) diff --git a/reactos/dll/win32/oleaut32/oleaut.c b/reactos/dll/win32/oleaut32/oleaut.c index aa97b31a550..40cfae36d2a 100644 --- a/reactos/dll/win32/oleaut32/oleaut.c +++ b/reactos/dll/win32/oleaut32/oleaut.c @@ -41,8 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); static BOOL BSTR_bCache = TRUE; /* Cache allocations to minimise alloc calls? */ -HMODULE OLEAUT32_hModule = NULL; - /****************************************************************************** * BSTR {OLEAUT32} * @@ -419,8 +417,7 @@ INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR str) /* * Make sure we free the old string. */ - if (*old!=NULL) - SysFreeString(*old); + SysFreeString(*old); /* * Allocate the new string @@ -697,7 +694,8 @@ HRESULT WINAPI OleTranslateColor( return S_OK; } -extern HRESULT OLEAUTPS_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv); +extern HRESULT WINAPI OLEAUTPS_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN; +extern BOOL WINAPI OLEAUTPS_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN; extern void _get_STDFONT_CF(LPVOID *); extern void _get_STDPIC_CF(LPVOID *); @@ -831,18 +829,7 @@ HRESULT WINAPI DllCanUnloadNow(void) */ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved) { - TRACE("(%p,%d,%p)\n", hInstDll, fdwReason, lpvReserved); - - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - DisableThreadLibraryCalls(hInstDll); - OLEAUT32_hModule = hInstDll; - break; - case DLL_PROCESS_DETACH: - break; - }; - - return TRUE; + return OLEAUTPS_DllMain( hInstDll, fdwReason, lpvReserved ); } /*********************************************************************** diff --git a/reactos/dll/win32/oleaut32/oleaut32.rbuild b/reactos/dll/win32/oleaut32/oleaut32.rbuild index fe1a201b5c1..00f7a294c28 100644 --- a/reactos/dll/win32/oleaut32/oleaut32.rbuild +++ b/reactos/dll/win32/oleaut32/oleaut32.rbuild @@ -8,6 +8,12 @@ include/reactos/wine 0x600 + CLSID_PSDispatch + + + + + OLEAUTPS_ connpt.c dispatch.c hash.c @@ -44,6 +50,12 @@ pseh + + CLSID_PSDispatch + + + + OLEAUTPS_ oleaut32_oaidl.idl oleaut32_ocidl.idl diff --git a/reactos/dll/win32/oleaut32/oleaut32_Ko.rc b/reactos/dll/win32/oleaut32/oleaut32_Ko.rc index b3b5296df7f..0134c7a54b9 100644 --- a/reactos/dll/win32/oleaut32/oleaut32_Ko.rc +++ b/reactos/dll/win32/oleaut32/oleaut32_Ko.rc @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -LANGUAGE LANG_KOREAN, SUBLANG_NEUTRAL +LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { diff --git a/reactos/dll/win32/oleaut32/oleaut32_ocidl.idl b/reactos/dll/win32/oleaut32/oleaut32_ocidl.idl index 379df5bbfee..dcd3ea458da 100644 --- a/reactos/dll/win32/oleaut32/oleaut32_ocidl.idl +++ b/reactos/dll/win32/oleaut32/oleaut32_ocidl.idl @@ -16,5 +16,4 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -cpp_quote("#include ") #include "ocidl.idl" diff --git a/reactos/dll/win32/oleaut32/olefont.c b/reactos/dll/win32/oleaut32/olefont.c index 1a30621714e..da622a10818 100644 --- a/reactos/dll/win32/oleaut32/olefont.c +++ b/reactos/dll/win32/oleaut32/olefont.c @@ -328,7 +328,7 @@ static void OLEFont_SendNotify(OLEFontImpl* this, DISPID dispID) * * See Windows documentation for more details on IUnknown methods. */ -HRESULT WINAPI OLEFontImpl_QueryInterface( +static HRESULT WINAPI OLEFontImpl_QueryInterface( IFont* iface, REFIID riid, void** ppvObject) @@ -384,7 +384,7 @@ HRESULT WINAPI OLEFontImpl_QueryInterface( * * See Windows documentation for more details on IUnknown methods. */ -ULONG WINAPI OLEFontImpl_AddRef( +static ULONG WINAPI OLEFontImpl_AddRef( IFont* iface) { OLEFontImpl *this = (OLEFontImpl *)iface; @@ -397,7 +397,7 @@ ULONG WINAPI OLEFontImpl_AddRef( * * See Windows documentation for more details on IUnknown methods. */ -ULONG WINAPI OLEFontImpl_Release( +static ULONG WINAPI OLEFontImpl_Release( IFont* iface) { OLEFontImpl *this = (OLEFontImpl *)iface; diff --git a/reactos/dll/win32/oleaut32/olepicture.c b/reactos/dll/win32/oleaut32/olepicture.c index 8dc10edf5a4..bdce729639f 100644 --- a/reactos/dll/win32/oleaut32/olepicture.c +++ b/reactos/dll/win32/oleaut32/olepicture.c @@ -5,6 +5,7 @@ * * Copyright 2000 Huw D M Davies for CodeWeavers. * Copyright 2001 Marcus Meissner + * Copyright 2008 Kirill K. Smirnov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -508,7 +509,6 @@ static void OLEPicture_SendNotify(OLEPictureImpl* this, DISPID dispID) IUnknown_Release(CD.pUnk); } IEnumConnections_Release(pEnum); - return; } /************************************************************************ @@ -637,6 +637,10 @@ static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc, TRACE("prcWBounds (%d,%d) - (%d,%d)\n", prcWBounds->left, prcWBounds->top, prcWBounds->right, prcWBounds->bottom); + if(cx == 0 || cy == 0 || cxSrc == 0 || cySrc == 0){ + return CTL_E_INVALIDPROPERTYVALUE; + } + /* * While the documentation suggests this to be here (or after rendering?) * it does cause an endless recursion in my sample app. -MM 20010804 @@ -644,6 +648,10 @@ static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc, */ switch(This->desc.picType) { + case PICTYPE_UNINITIALIZED: + case PICTYPE_NONE: + /* nothing to do */ + return S_OK; case PICTYPE_BITMAP: { HBITMAP hbmpOld; @@ -1035,7 +1043,7 @@ static int _gif_inputfunc(GifFileType *gif, GifByteType *data, int len) { struct gifdata *gd = (struct gifdata*)gif->UserData; if (len+gd->curoff > gd->len) { - FIXME("Trying to read %d bytes, but only %d available.\n",len, gd->len-gd->curoff); + ERR("Trying to read %d bytes, but only %d available.\n",len, gd->len-gd->curoff); len = gd->len - gd->curoff; } memcpy(data, gd->data+gd->curoff, len); @@ -1065,14 +1073,14 @@ static HRESULT OLEPictureImpl_LoadGif(OLEPictureImpl *This, BYTE *xbuf, ULONG xr gif = DGifOpen((void*)&gd, _gif_inputfunc); ret = DGifSlurp(gif); if (ret == GIF_ERROR) { - FIXME("Failed reading GIF using libgif.\n"); + ERR("Failed reading GIF using libgif.\n"); return E_FAIL; } TRACE("screen height %d, width %d\n", gif->SWidth, gif->SHeight); TRACE("color res %d, backgcolor %d\n", gif->SColorResolution, gif->SBackGroundColor); TRACE("imgcnt %d\n", gif->ImageCount); if (gif->ImageCount<1) { - FIXME("GIF stream does not have images inside?\n"); + ERR("GIF stream does not have images inside?\n"); return E_FAIL; } TRACE("curimage: %d x %d, on %dx%d, interlace %d\n", @@ -1258,7 +1266,7 @@ static HRESULT OLEPictureImpl_LoadJpeg(OLEPictureImpl *This, BYTE *xbuf, ULONG x if(!libjpeg_handle) { if(!load_libjpeg()) { - FIXME("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG); + ERR("Failed reading JPEG because unable to find %s\n", SONAME_LIBJPEG); return E_FAIL; } } @@ -1297,7 +1305,7 @@ static HRESULT OLEPictureImpl_LoadJpeg(OLEPictureImpl *This, BYTE *xbuf, ULONG x while ( jd.output_scanlinedesc.picType = PICTYPE_ICON; @@ -1686,39 +1692,24 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x } } -static HRESULT OLEPictureImpl_LoadMetafile(OLEPictureImpl *This, - const BYTE *data, ULONG size) +static HRESULT OLEPictureImpl_LoadEnhMetafile(OLEPictureImpl *This, + const BYTE *data, ULONG size) { - HMETAFILE hmf; HENHMETAFILE hemf; - - /* SetMetaFileBitsEx performs data check on its own */ - hmf = SetMetaFileBitsEx(size, data); - if (hmf) - { - This->desc.picType = PICTYPE_METAFILE; - This->desc.u.wmf.hmeta = hmf; - This->desc.u.wmf.xExt = 0; - This->desc.u.wmf.yExt = 0; - - This->origWidth = 0; - This->origHeight = 0; - This->himetricWidth = 0; - This->himetricHeight = 0; - - return S_OK; - } + ENHMETAHEADER hdr; hemf = SetEnhMetaFileBits(size, data); if (!hemf) return E_FAIL; + GetEnhMetaFileHeader(hemf, sizeof(hdr), &hdr); + This->desc.picType = PICTYPE_ENHMETAFILE; This->desc.u.emf.hemf = hemf; This->origWidth = 0; This->origHeight = 0; - This->himetricWidth = 0; - This->himetricHeight = 0; + This->himetricWidth = hdr.rclFrame.right - hdr.rclFrame.left; + This->himetricHeight = hdr.rclFrame.bottom - hdr.rclFrame.top; return S_OK; } @@ -1727,16 +1718,24 @@ static HRESULT OLEPictureImpl_LoadAPM(OLEPictureImpl *This, const BYTE *data, ULONG size) { APM_HEADER *header = (APM_HEADER *)data; - HRESULT hr; + HMETAFILE hmf; if (size < sizeof(APM_HEADER)) return E_FAIL; if (header->key != 0x9ac6cdd7) return E_FAIL; - if ((hr = OLEPictureImpl_LoadMetafile(This, data + sizeof(APM_HEADER), size - sizeof(*header))) != S_OK) - return hr; + /* SetMetaFileBitsEx performs data check on its own */ + hmf = SetMetaFileBitsEx(size - sizeof(*header), data + sizeof(*header)); + if (!hmf) return E_FAIL; + This->desc.picType = PICTYPE_METAFILE; + This->desc.u.wmf.hmeta = hmf; + This->desc.u.wmf.xExt = 0; + This->desc.u.wmf.yExt = 0; + + This->origWidth = 0; + This->origHeight = 0; This->himetricWidth = MulDiv((INT)header->right - header->left, 2540, header->inch); This->himetricHeight = MulDiv((INT)header->bottom - header->top, 2540, header->inch); return S_OK; @@ -1807,8 +1806,8 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) { do { hr=IStream_Read(pStm,header,8,&xread); if (hr || xread!=8) { - FIXME("Failure while reading picture header (hr is %x, nread is %d).\n",hr,xread); - return hr; + ERR("Failure while reading picture header (hr is %x, nread is %d).\n",hr,xread); + return (hr?hr:E_FAIL); } headerread += xread; xread = 0; @@ -1885,7 +1884,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) { break; } if (xread != This->datalen) - FIXME("Could only read %d of %d bytes out of stream?\n",xread,This->datalen); + ERR("Could only read %d of %d bytes out of stream?\n",xread,This->datalen); } if (This->datalen == 0) { /* Marks the "NONE" picture */ This->desc.picType = PICTYPE_NONE; @@ -1924,8 +1923,8 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) { { unsigned int i; - /* let's see if it's a metafile */ - hr = OLEPictureImpl_LoadMetafile(This, xbuf, xread); + /* let's see if it's a EMF */ + hr = OLEPictureImpl_LoadEnhMetafile(This, xbuf, xread); if (hr == S_OK) break; FIXME("Unknown magic %04x, %d read bytes:\n",magic,xread); @@ -2643,7 +2642,7 @@ HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode, return hr; hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps); if (hr) { - FIXME("Could not get IPersistStream iface from Ole Picture?\n"); + ERR("Could not get IPersistStream iface from Ole Picture?\n"); IPicture_Release(newpic); *ppvObj = NULL; return hr; @@ -2659,7 +2658,7 @@ HRESULT WINAPI OleLoadPicture( LPSTREAM lpstream, LONG lSize, BOOL fRunmode, } hr = IPicture_QueryInterface(newpic,riid,ppvObj); if (hr) - FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); + ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); IPicture_Release(newpic); return hr; } @@ -2682,16 +2681,23 @@ HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode, return hr; hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps); if (hr) { - FIXME("Could not get IPersistStream iface from Ole Picture?\n"); + ERR("Could not get IPersistStream iface from Ole Picture?\n"); IPicture_Release(newpic); *ppvObj = NULL; return hr; } - IPersistStream_Load(ps,lpstream); + hr = IPersistStream_Load(ps,lpstream); IPersistStream_Release(ps); + if (FAILED(hr)) + { + ERR("IPersistStream_Load failed\n"); + IPicture_Release(newpic); + *ppvObj = NULL; + return hr; + } hr = IPicture_QueryInterface(newpic,riid,ppvObj); if (hr) - FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); + ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); IPicture_Release(newpic); return hr; } @@ -2797,7 +2803,7 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller, hRes = IPicture_QueryInterface(ipicture,riid,ppvRet); if (hRes) - FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); + ERR("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); IPicture_Release(ipicture); return hRes; diff --git a/reactos/dll/win32/oleaut32/recinfo.c b/reactos/dll/win32/oleaut32/recinfo.c index 61f65543975..19ae217cb94 100644 --- a/reactos/dll/win32/oleaut32/recinfo.c +++ b/reactos/dll/win32/oleaut32/recinfo.c @@ -59,7 +59,7 @@ static HRESULT copy_to_variant(void *src, VARIANT *pvar, enum VARENUM vt) #define CASE_COPY(x) \ case VT_ ## x: \ - V_ ## x(pvar) = *(typeof(V_ ## x(pvar))*)src; \ + memcpy(&V_ ## x(pvar), src, sizeof(V_ ## x(pvar))); \ break switch(vt) { @@ -106,7 +106,7 @@ static HRESULT copy_from_variant(VARIANT *src, void *dest, enum VARENUM vt) #define CASE_COPY(x) \ case VT_ ## x: \ - *(typeof(V_ ## x(&var))*)dest = V_ ## x(&var); \ + memcpy(dest, &V_ ## x(&var), sizeof(V_ ## x(&var))); \ break switch(vt) { @@ -236,6 +236,9 @@ static HRESULT WINAPI IRecordInfoImpl_RecordClear(IRecordInfo *iface, PVOID pvEx case VT_UINT_PTR: *(void**)var = NULL; break; + case VT_SAFEARRAY: + SafeArrayDestroy((SAFEARRAY*)var); + break; default: FIXME("Not supported vt = %d\n", This->fields[i].vt); break; @@ -412,8 +415,7 @@ static HRESULT WINAPI IRecordInfoImpl_GetFieldNames(IRecordInfo *iface, ULONG *p BSTR *rgBstrNames) { IRecordInfoImpl *This = (IRecordInfoImpl*)iface; - ULONG n = This->n_vars; - int i; + ULONG n = This->n_vars, i; TRACE("(%p)->(%p %p)\n", This, pcNames, rgBstrNames); diff --git a/reactos/dll/win32/oleaut32/regsvr.c b/reactos/dll/win32/oleaut32/regsvr.c index a65c1091236..9ee36b53ef0 100644 --- a/reactos/dll/win32/oleaut32/regsvr.c +++ b/reactos/dll/win32/oleaut32/regsvr.c @@ -34,6 +34,7 @@ #include "typelib.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); @@ -150,7 +151,7 @@ static HRESULT register_interfaces(struct regsvr_interface const *list) KEY_READ | KEY_WRITE, NULL, &key, NULL); if (res != ERROR_SUCCESS) goto error_close_iid_key; - wsprintfW(buf, fmt, list->num_methods); + sprintfW(buf, fmt, list->num_methods); res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)buf, (lstrlenW(buf) + 1) * sizeof(WCHAR)); @@ -466,353 +467,62 @@ static struct regsvr_coclass const coclass_list[] = { /*********************************************************************** * interface list */ +#define INTERFACE_ENTRY(interface, clsid16, clsid32) { &IID_##interface, #interface, NULL, sizeof(interface##Vtbl)/sizeof(void*), clsid16, clsid32 } +#define LCL_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, NULL) +#define PSFAC_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer) +#define CLSID_INTERFACE_ENTRY(interface,clsid) INTERFACE_ENTRY(interface, clsid, clsid) + static struct regsvr_interface const interface_list[] = { - { &IID_IDispatch, - "IDispatch", - NULL, - 7, - &CLSID_PSDispatch, - &CLSID_PSDispatch - }, - { &IID_ITypeInfo, - "ITypeInfo", - NULL, - 22, - &CLSID_PSTypeInfo, - &CLSID_PSTypeInfo - }, - { &IID_ITypeLib, - "ITypeLib", - NULL, - 13, - &CLSID_PSTypeLib, - &CLSID_PSTypeLib - }, - { &IID_ITypeComp, - "ITypeComp", - NULL, - 5, - &CLSID_PSTypeComp, - &CLSID_PSTypeComp - }, - { &IID_IEnumVARIANT, - "IEnumVARIANT", - NULL, - 15, - &CLSID_PSEnumVariant, - &CLSID_PSEnumVariant - }, - { &IID_ICreateTypeInfo, - "ICreateTypeInfo", - NULL, - 26, - NULL, - NULL - }, - { &IID_ICreateTypeLib, - "ICreateTypeLib", - NULL, - 13, - NULL, - NULL - }, - { &IID_ITypeInfo2, - "ITypeInfo2", - NULL, - 32, - NULL, - &CLSID_PSDispatch - }, - { &IID_ITypeLib2, - "ITypeLib2", - NULL, - 16, - NULL, - &CLSID_PSDispatch - }, - { &IID_IPropertyPage2, - "IPropertyPage2", - NULL, - 15, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IErrorInfo, - "IErrorInfo", - NULL, - 8, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_ICreateErrorInfo, - "ICreateErrorInfo", - NULL, - 8, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPersistPropertyBag2, - "IPersistPropertyBag2", - NULL, - 8, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPropertyBag2, - "IPropertyBag2", - NULL, - 8, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IErrorLog, - "IErrorLog", - NULL, - 4, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPerPropertyBrowsing, - "IPerPropertyBrowsing", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPersistPropertyBag, - "IPersistPropertyBag", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IAdviseSinkEx, - "IAdviseSinkEx", - NULL, - 9, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IFontEventsDisp, - "IFontEventsDisp", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPropertyBag, - "IPropertyBag", - NULL, - 5, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPointerInactive, - "IPointerInactive", - NULL, - 6, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_ISimpleFrameSite, - "ISimpleFrameSite", - NULL, - 5, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPicture, - "IPicture", - NULL, - 17, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPictureDisp, - "IPictureDisp", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPersistStreamInit, - "IPersistStreamInit", - NULL, - 9, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IOleUndoUnit, - "IOleUndoUnit", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPropertyNotifySink, - "IPropertyNotifySink", - NULL, - 5, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IOleInPlaceSiteEx, - "IOleInPlaceSiteEx", - NULL, - 18, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IOleParentUndoUnit, - "IOleParentUndoUnit", - NULL, - 12, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IProvideClassInfo2, - "IProvideClassInfo2", - NULL, - 5, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IProvideMultipleClassInfo, - "IProvideMultipleClassInfo", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IProvideClassInfo, - "IProvideClassInfo", - NULL, - 4, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IConnectionPointContainer, - "IConnectionPointContainer", - NULL, - 5, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IEnumConnectionPoints, - "IEnumConnectionPoints", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IConnectionPoint, - "IConnectionPoint", - NULL, - 8, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IEnumConnections, - "IEnumConnections", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IOleControl, - "IOleControl", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IOleControlSite, - "IOleControlSite", - NULL, - 10, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_ISpecifyPropertyPages, - "ISpecifyPropertyPages", - NULL, - 4, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPropertyPageSite, - "IPropertyPageSite", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPropertyPage, - "IPropertyPage", - NULL, - 14, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IClassFactory2, - "IClassFactory2", - NULL, - 8, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IEnumOleUndoUnits, - "IEnumOleUndoUnits", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IPersistMemory, - "IPersistMemory", - NULL, - 9, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IFont, - "IFont", - NULL, - 27, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IFontDisp, - "IFontDisp", - NULL, - 7, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IQuickActivate, - "IQuickActivate", - NULL, - 6, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IOleUndoManager, - "IOleUndoManager", - NULL, - 15, - NULL, - &CLSID_PSFactoryBuffer - }, - { &IID_IObjectWithSite, - "IObjectWithSite", - NULL, - 5, - NULL, - &CLSID_PSFactoryBuffer - }, + LCL_INTERFACE_ENTRY(ICreateTypeInfo), + LCL_INTERFACE_ENTRY(ICreateTypeLib), + CLSID_INTERFACE_ENTRY(IDispatch,&CLSID_PSDispatch), + CLSID_INTERFACE_ENTRY(IEnumVARIANT,&CLSID_PSEnumVariant), + CLSID_INTERFACE_ENTRY(ITypeComp,&CLSID_PSTypeComp), + CLSID_INTERFACE_ENTRY(ITypeInfo,&CLSID_PSTypeInfo), + CLSID_INTERFACE_ENTRY(ITypeLib,&CLSID_PSTypeLib), + PSFAC_INTERFACE_ENTRY(IAdviseSinkEx), + PSFAC_INTERFACE_ENTRY(IClassFactory2), + PSFAC_INTERFACE_ENTRY(IConnectionPoint), + PSFAC_INTERFACE_ENTRY(IConnectionPointContainer), + PSFAC_INTERFACE_ENTRY(ICreateErrorInfo), + PSFAC_INTERFACE_ENTRY(IEnumConnectionPoints), + PSFAC_INTERFACE_ENTRY(IEnumConnections), + PSFAC_INTERFACE_ENTRY(IEnumOleUndoUnits), + PSFAC_INTERFACE_ENTRY(IErrorInfo), + PSFAC_INTERFACE_ENTRY(IErrorLog), + PSFAC_INTERFACE_ENTRY(IFont), + PSFAC_INTERFACE_ENTRY(IObjectWithSite), + PSFAC_INTERFACE_ENTRY(IOleControl), + PSFAC_INTERFACE_ENTRY(IOleControlSite), + PSFAC_INTERFACE_ENTRY(IOleInPlaceSiteEx), + PSFAC_INTERFACE_ENTRY(IOleParentUndoUnit), + PSFAC_INTERFACE_ENTRY(IOleUndoManager), + PSFAC_INTERFACE_ENTRY(IOleUndoUnit), + PSFAC_INTERFACE_ENTRY(IPerPropertyBrowsing), + PSFAC_INTERFACE_ENTRY(IPersistMemory), + PSFAC_INTERFACE_ENTRY(IPersistPropertyBag), + PSFAC_INTERFACE_ENTRY(IPersistPropertyBag2), + PSFAC_INTERFACE_ENTRY(IPersistStreamInit), + PSFAC_INTERFACE_ENTRY(IPicture), + PSFAC_INTERFACE_ENTRY(IPointerInactive), + PSFAC_INTERFACE_ENTRY(IPropertyBag), + PSFAC_INTERFACE_ENTRY(IPropertyBag2), + PSFAC_INTERFACE_ENTRY(IPropertyNotifySink), + PSFAC_INTERFACE_ENTRY(IPropertyPage), + PSFAC_INTERFACE_ENTRY(IPropertyPage2), + PSFAC_INTERFACE_ENTRY(IPropertyPageSite), + PSFAC_INTERFACE_ENTRY(IProvideClassInfo), + PSFAC_INTERFACE_ENTRY(IProvideClassInfo2), + PSFAC_INTERFACE_ENTRY(IProvideMultipleClassInfo), + PSFAC_INTERFACE_ENTRY(IQuickActivate), + PSFAC_INTERFACE_ENTRY(ISimpleFrameSite), + PSFAC_INTERFACE_ENTRY(ISpecifyPropertyPages), { NULL } /* list terminator */ }; +extern HRESULT WINAPI OLEAUTPS_DllRegisterServer(void) DECLSPEC_HIDDEN; +extern HRESULT WINAPI OLEAUTPS_DllUnregisterServer(void) DECLSPEC_HIDDEN; + /*********************************************************************** * DllRegisterServer (OLEAUT32.@) */ @@ -822,7 +532,9 @@ HRESULT WINAPI DllRegisterServer(void) TRACE("\n"); - hr = register_coclasses(coclass_list); + hr = OLEAUTPS_DllRegisterServer(); + if (SUCCEEDED(hr)) + hr = register_coclasses(coclass_list); if (SUCCEEDED(hr)) hr = register_interfaces(interface_list); return hr; @@ -840,5 +552,7 @@ HRESULT WINAPI DllUnregisterServer(void) hr = unregister_coclasses(coclass_list); if (SUCCEEDED(hr)) hr = unregister_interfaces(interface_list); + if (SUCCEEDED(hr)) + hr = OLEAUTPS_DllUnregisterServer(); return hr; } diff --git a/reactos/dll/win32/oleaut32/safearray.c b/reactos/dll/win32/oleaut32/safearray.c index a19d599c527..c717ac6608a 100644 --- a/reactos/dll/win32/oleaut32/safearray.c +++ b/reactos/dll/win32/oleaut32/safearray.c @@ -207,7 +207,7 @@ static void SAFEARRAY_SetFeatures(VARTYPE vt, SAFEARRAY *psa) static SAFEARRAY* SAFEARRAY_Create(VARTYPE vt, UINT cDims, const SAFEARRAYBOUND *rgsabound, ULONG ulSize) { SAFEARRAY *psa = NULL; - int i; + unsigned int i; if (!rgsabound) return NULL; @@ -314,8 +314,7 @@ static HRESULT SAFEARRAY_DestroyData(SAFEARRAY *psa, ULONG ulStartCell) while(ulCellCount--) { - if (*lpBstr) - SysFreeString(*lpBstr); + SysFreeString(*lpBstr); lpBstr++; } } @@ -865,8 +864,7 @@ HRESULT WINAPI SafeArrayPutElement(SAFEARRAY *psa, LONG *rgIndices, void *pvData BSTR lpBstr = (BSTR)pvData; BSTR* lpDest = (BSTR*)lpvDest; - if (*lpDest) - SysFreeString(*lpDest); + SysFreeString(*lpDest); *lpDest = SysAllocStringByteLen((char*)lpBstr, SysStringByteLen(lpBstr)); if (!*lpDest) diff --git a/reactos/dll/win32/oleaut32/tmarshal.c b/reactos/dll/win32/oleaut32/tmarshal.c index fdfe07ce7c9..a7b40092a2f 100644 --- a/reactos/dll/win32/oleaut32/tmarshal.c +++ b/reactos/dll/win32/oleaut32/tmarshal.c @@ -1420,8 +1420,8 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */) TRACE_(olerelay)("("); } - if (iname) SysFreeString(iname); - if (fname) SysFreeString(fname); + SysFreeString(iname); + SysFreeString(fname); memset(&buf,0,sizeof(buf)); @@ -2080,7 +2080,7 @@ TMStubImpl_Invoke( goto exit; } - if (iname) SysFreeString (iname); + SysFreeString (iname); /* Need them for hack below */ memset(names,0,sizeof(names)); diff --git a/reactos/dll/win32/oleaut32/typelib.c b/reactos/dll/win32/oleaut32/typelib.c index ceb229528b1..9bc601ec42f 100644 --- a/reactos/dll/win32/oleaut32/typelib.c +++ b/reactos/dll/win32/oleaut32/typelib.c @@ -64,7 +64,9 @@ #include "winnls.h" #include "winreg.h" #include "winuser.h" +#include "lzexpand.h" +#include "wine/winbase16.h" #include "wine/unicode.h" #include "objbase.h" #include "typelib.h" @@ -394,7 +396,7 @@ HRESULT WINAPI LoadTypeLibEx( /* else fall-through */ case REGKIND_REGISTER: - if (!SUCCEEDED(res = RegisterTypeLib(*pptLib, (LPOLESTR)szPath, NULL))) + if (FAILED(res = RegisterTypeLib(*pptLib, (LPOLESTR)szPath, NULL))) { IUnknown_Release(*pptLib); *pptLib = 0; @@ -491,7 +493,7 @@ HRESULT WINAPI RegisterTypeLib( if (ptlib == NULL || szFullPath == NULL) return E_INVALIDARG; - if (!SUCCEEDED(ITypeLib_GetLibAttr(ptlib, &attr))) + if (FAILED(ITypeLib_GetLibAttr(ptlib, &attr))) return E_FAIL; get_typelib_key( &attr->guid, attr->wMajorVerNum, attr->wMinorVerNum, keyName ); @@ -838,7 +840,7 @@ enddeleteloop: } end: - if (tlibPath) SysFreeString(tlibPath); + SysFreeString(tlibPath); if (typeLib) ITypeLib_Release(typeLib); if (subKey) RegCloseKey(subKey); if (key) RegCloseKey(key); @@ -1034,7 +1036,7 @@ static inline ITypeInfoImpl *info_impl_from_ITypeComp( ITypeComp *iface ) static const ITypeInfo2Vtbl tinfvt; static const ITypeCompVtbl tcompvt; -static ITypeInfo2 * WINAPI ITypeInfo_Constructor(void); +static ITypeInfo2 * ITypeInfo_Constructor(void); typedef struct tagTLBContext { @@ -1294,7 +1296,7 @@ static void dump_Variant(const VARIANT * pvar) static void dump_DispParms(const DISPPARAMS * pdp) { - int index; + unsigned int index; TRACE("args=%u named args=%u\n", pdp->cArgs, pdp->cNamedArgs); @@ -2326,6 +2328,220 @@ static HRESULT TLB_PEFile_Open(LPCWSTR path, INT index, LPVOID *ppBase, DWORD *p return TYPE_E_CANTLOADLIBRARY; } +typedef struct TLB_NEFile +{ + const IUnknownVtbl *lpvtbl; + LONG refs; + LPVOID typelib_base; +} TLB_NEFile; + +static HRESULT WINAPI TLB_NEFile_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) +{ + if (IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = iface; + IUnknown_AddRef(iface); + return S_OK; + } + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI TLB_NEFile_AddRef(IUnknown *iface) +{ + TLB_NEFile *This = (TLB_NEFile *)iface; + return InterlockedIncrement(&This->refs); +} + +static ULONG WINAPI TLB_NEFile_Release(IUnknown *iface) +{ + TLB_NEFile *This = (TLB_NEFile *)iface; + ULONG refs = InterlockedDecrement(&This->refs); + if (!refs) + { + HeapFree(GetProcessHeap(), 0, This->typelib_base); + HeapFree(GetProcessHeap(), 0, This); + } + return refs; +} + +static const IUnknownVtbl TLB_NEFile_Vtable = +{ + TLB_NEFile_QueryInterface, + TLB_NEFile_AddRef, + TLB_NEFile_Release +}; + +/*********************************************************************** + * read_xx_header [internal] + */ +static int read_xx_header( HFILE lzfd ) +{ + IMAGE_DOS_HEADER mzh; + char magic[3]; + + LZSeek( lzfd, 0, SEEK_SET ); + if ( sizeof(mzh) != LZRead( lzfd, (LPSTR)&mzh, sizeof(mzh) ) ) + return 0; + if ( mzh.e_magic != IMAGE_DOS_SIGNATURE ) + return 0; + + LZSeek( lzfd, mzh.e_lfanew, SEEK_SET ); + if ( 2 != LZRead( lzfd, magic, 2 ) ) + return 0; + + LZSeek( lzfd, mzh.e_lfanew, SEEK_SET ); + + if ( magic[0] == 'N' && magic[1] == 'E' ) + return IMAGE_OS2_SIGNATURE; + if ( magic[0] == 'P' && magic[1] == 'E' ) + return IMAGE_NT_SIGNATURE; + + magic[2] = '\0'; + WARN("Can't handle %s files.\n", magic ); + return 0; +} + + +/*********************************************************************** + * find_ne_resource [internal] + */ +static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid, + DWORD *resLen, DWORD *resOff ) +{ + IMAGE_OS2_HEADER nehd; + NE_TYPEINFO *typeInfo; + NE_NAMEINFO *nameInfo; + DWORD nehdoffset; + LPBYTE resTab; + DWORD resTabSize; + int count; + + /* Read in NE header */ + nehdoffset = LZSeek( lzfd, 0, SEEK_CUR ); + if ( sizeof(nehd) != LZRead( lzfd, (LPSTR)&nehd, sizeof(nehd) ) ) return 0; + + resTabSize = nehd.ne_restab - nehd.ne_rsrctab; + if ( !resTabSize ) + { + TRACE("No resources in NE dll\n" ); + return FALSE; + } + + /* Read in resource table */ + resTab = HeapAlloc( GetProcessHeap(), 0, resTabSize ); + if ( !resTab ) return FALSE; + + LZSeek( lzfd, nehd.ne_rsrctab + nehdoffset, SEEK_SET ); + if ( resTabSize != LZRead( lzfd, (char*)resTab, resTabSize ) ) + { + HeapFree( GetProcessHeap(), 0, resTab ); + return FALSE; + } + + /* Find resource */ + typeInfo = (NE_TYPEINFO *)(resTab + 2); + + if (HIWORD(typeid) != 0) /* named type */ + { + BYTE len = strlen( typeid ); + while (typeInfo->type_id) + { + if (!(typeInfo->type_id & 0x8000)) + { + BYTE *p = resTab + typeInfo->type_id; + if ((*p == len) && !strncasecmp( (char*)p+1, typeid, len )) goto found_type; + } + typeInfo = (NE_TYPEINFO *)((char *)(typeInfo + 1) + + typeInfo->count * sizeof(NE_NAMEINFO)); + } + } + else /* numeric type id */ + { + WORD id = LOWORD(typeid) | 0x8000; + while (typeInfo->type_id) + { + if (typeInfo->type_id == id) goto found_type; + typeInfo = (NE_TYPEINFO *)((char *)(typeInfo + 1) + + typeInfo->count * sizeof(NE_NAMEINFO)); + } + } + TRACE("No typeid entry found for %p\n", typeid ); + HeapFree( GetProcessHeap(), 0, resTab ); + return FALSE; + + found_type: + nameInfo = (NE_NAMEINFO *)(typeInfo + 1); + + if (HIWORD(resid) != 0) /* named resource */ + { + BYTE len = strlen( resid ); + for (count = typeInfo->count; count > 0; count--, nameInfo++) + { + BYTE *p = resTab + nameInfo->id; + if (nameInfo->id & 0x8000) continue; + if ((*p == len) && !strncasecmp( (char*)p+1, resid, len )) goto found_name; + } + } + else /* numeric resource id */ + { + WORD id = LOWORD(resid) | 0x8000; + for (count = typeInfo->count; count > 0; count--, nameInfo++) + if (nameInfo->id == id) goto found_name; + } + TRACE("No resid entry found for %p\n", typeid ); + HeapFree( GetProcessHeap(), 0, resTab ); + return FALSE; + + found_name: + /* Return resource data */ + if ( resLen ) *resLen = nameInfo->length << *(WORD *)resTab; + if ( resOff ) *resOff = nameInfo->offset << *(WORD *)resTab; + + HeapFree( GetProcessHeap(), 0, resTab ); + return TRUE; +} + +static HRESULT TLB_NEFile_Open(LPCWSTR path, INT index, LPVOID *ppBase, DWORD *pdwTLBLength, IUnknown **ppFile){ + + HFILE lzfd = -1; + OFSTRUCT ofs; + HRESULT hr = TYPE_E_CANTLOADLIBRARY; + TLB_NEFile *This = NULL; + + This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); + if (!This) return E_OUTOFMEMORY; + + This->lpvtbl = &TLB_NEFile_Vtable; + This->refs = 1; + This->typelib_base = NULL; + + lzfd = LZOpenFileW( (LPWSTR)path, &ofs, OF_READ ); + if ( lzfd >= 0 && read_xx_header( lzfd ) == IMAGE_OS2_SIGNATURE ) + { + DWORD reslen, offset; + if( find_ne_resource( lzfd, "TYPELIB", MAKEINTRESOURCEA(index), &reslen, &offset ) ) + { + This->typelib_base = HeapAlloc(GetProcessHeap(), 0, reslen); + if( !This->typelib_base ) + hr = E_OUTOFMEMORY; + else + { + LZSeek( lzfd, offset, SEEK_SET ); + reslen = LZRead( lzfd, This->typelib_base, reslen ); + LZClose( lzfd ); + *ppBase = This->typelib_base; + *pdwTLBLength = reslen; + *ppFile = (IUnknown *)&This->lpvtbl; + return S_OK; + } + } + } + + if( lzfd >= 0) LZClose( lzfd ); + TLB_NEFile_Release((IUnknown *)&This->lpvtbl); + return hr; +} typedef struct TLB_Mapping { @@ -2485,6 +2701,8 @@ static HRESULT TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath /* now actually load and parse the typelib */ ret = TLB_PEFile_Open(pszPath, index, &pBase, &dwTLBLength, &pFile); + if (ret == TYPE_E_CANTLOADLIBRARY) + ret = TLB_NEFile_Open(pszPath, index, &pBase, &dwTLBLength, &pFile); if (ret == TYPE_E_CANTLOADLIBRARY) ret = TLB_Mapping_Open(pszPath, &pBase, &dwTLBLength, &pFile); if (SUCCEEDED(ret)) @@ -2973,7 +3191,7 @@ static WORD *SLTG_DoElem(WORD *pType, char *pBlk, static sltg_ref_lookup_t *SLTG_DoRefs(SLTG_RefInfo *pRef, ITypeLibImpl *pTL, char *pNameTable) { - int ref; + unsigned int ref; char *name; TLBRefType *ref_type; sltg_ref_lookup_t *table; @@ -3833,29 +4051,17 @@ static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface) } TRACE(" destroying ITypeLib(%p)\n",This); - if (This->Name) - { - SysFreeString(This->Name); - This->Name = NULL; - } + SysFreeString(This->Name); + This->Name = NULL; - if (This->DocString) - { - SysFreeString(This->DocString); - This->DocString = NULL; - } + SysFreeString(This->DocString); + This->DocString = NULL; - if (This->HelpFile) - { - SysFreeString(This->HelpFile); - This->HelpFile = NULL; - } + SysFreeString(This->HelpFile); + This->HelpFile = NULL; - if (This->HelpStringDll) - { - SysFreeString(This->HelpStringDll); - This->HelpStringDll = NULL; - } + SysFreeString(This->HelpStringDll); + This->HelpStringDll = NULL; for (pCustData = This->pCustData; pCustData; pCustData = pCustDataNext) { @@ -3916,7 +4122,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfo( UINT index, ITypeInfo **ppTInfo) { - int i; + UINT i; ITypeLibImpl *This = (ITypeLibImpl *)iface; ITypeInfoImpl *pTypeInfo = This->pTypeInfo; @@ -3954,9 +4160,9 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoType( TYPEKIND *pTKind) { ITypeLibImpl *This = (ITypeLibImpl *)iface; - int i; + UINT i; ITypeInfoImpl *pTInfo = This->pTypeInfo; - + if (ITypeLib2_fnGetTypeInfoCount(iface) < index + 1) return TYPE_E_ELEMENTNOTFOUND; @@ -4599,7 +4805,7 @@ static const ITypeCompVtbl tlbtcvt = }; /*================== ITypeInfo(2) Methods ===================================*/ -static ITypeInfo2 * WINAPI ITypeInfo_Constructor(void) +static ITypeInfo2 * ITypeInfo_Constructor(void) { ITypeInfoImpl * pTypeInfoImpl; @@ -4679,27 +4885,18 @@ static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface) if (This->no_free_data) goto finish_free; - if (This->Name) - { - SysFreeString(This->Name); - This->Name = 0; - } + SysFreeString(This->Name); + This->Name = NULL; - if (This->DocString) - { - SysFreeString(This->DocString); - This->DocString = 0; - } + SysFreeString(This->DocString); + This->DocString = NULL; - if (This->DllName) - { - SysFreeString(This->DllName); - This->DllName = 0; - } + SysFreeString(This->DllName); + This->DllName = NULL; for (pFInfo = This->funclist; pFInfo; pFInfo = pFInfoNext) { - UINT i; + INT i; for(i = 0;i < pFInfo->funcdesc.cParams; i++) { ELEMDESC *elemdesc = &pFInfo->funcdesc.lprgelemdescParam[i]; @@ -4934,7 +5131,7 @@ HRESULT ITypeInfoImpl_GetInternalFuncDesc( ITypeInfo *iface, UINT index, const F { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; const TLBFuncDesc *pFDesc; - int i; + UINT i; for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next) ; @@ -5127,7 +5324,7 @@ static HRESULT WINAPI ITypeInfo_fnGetVarDesc( ITypeInfo2 *iface, UINT index, LPVARDESC *ppVarDesc) { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; - int i; + UINT i; const TLBVarDesc *pVDesc; TRACE("(%p) index %d\n", This, index); @@ -5219,7 +5416,7 @@ static HRESULT WINAPI ITypeInfo_fnGetRefTypeOfImplType( HREFTYPE *pRefType) { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; - int i; + UINT i; HRESULT hr = S_OK; const TLBImplType *pImpl = This->impltypelist; @@ -5282,7 +5479,7 @@ static HRESULT WINAPI ITypeInfo_fnGetImplTypeFlags( ITypeInfo2 *iface, UINT index, INT *pImplTypeFlags) { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; - int i; + UINT i; TLBImplType *pImpl; TRACE("(%p) index %d\n", This, index); @@ -5308,7 +5505,7 @@ static HRESULT WINAPI ITypeInfo_fnGetIDsOfNames( ITypeInfo2 *iface, const TLBFuncDesc *pFDesc; const TLBVarDesc *pVDesc; HRESULT ret=S_OK; - int i; + UINT i; TRACE("(%p) Name %s cNames %d\n", This, debugstr_w(*rgszNames), cNames); @@ -5488,7 +5685,7 @@ _invoke(FARPROC func,CALLCONV callconv, int nrargs, DWORD *args) { /* The size of the argument on the stack in DWORD units (in all x86 call * convetions the arguments on the stack are DWORD-aligned) */ -int _dispargsize(VARTYPE vt) +static int _dispargsize(VARTYPE vt) { switch (vt) { case VT_I8: @@ -5684,7 +5881,8 @@ DispCallFunc( void* pvInstance, ULONG_PTR oVft, CALLCONV cc, VARTYPE vtReturn, UINT cActuals, VARTYPE* prgvt, VARIANTARG** prgpvarg, VARIANT* pvargResult) { - int i, argsize, argspos; + int argsize, argspos; + UINT i; DWORD *args; HRESULT hres; @@ -5698,7 +5896,7 @@ DispCallFunc( for (i=0;ipImpTLInfo->lcid, &pTLib); - if(!SUCCEEDED(result)) { + if(FAILED(result)) { BSTR libnam=SysAllocString(ref_type->pImpTLInfo->name); result=LoadTypeLib(libnam, &pTLib); SysFreeString(libnam); @@ -6526,7 +6724,7 @@ static HRESULT WINAPI ITypeInfo_fnAddressOfMember( ITypeInfo2 *iface, { ERR("couldn't load %s\n", debugstr_w(dll)); SysFreeString(dll); - if (entry) SysFreeString(entry); + SysFreeString(entry); return STG_E_FILENOTFOUND; } /* FIXME: store library somewhere where we can free it */ @@ -6552,7 +6750,7 @@ static HRESULT WINAPI ITypeInfo_fnAddressOfMember( ITypeInfo2 *iface, } SysFreeString(dll); - if (entry) SysFreeString(entry); + SysFreeString(entry); if (!*ppv) return TYPE_E_DLLFUNCTIONNOTFOUND; @@ -6823,7 +7021,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetFuncCustData( ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData=NULL; TLBFuncDesc * pFDesc; - int i; + UINT i; for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next); @@ -6855,7 +7053,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetParamCustData( ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData=NULL; TLBFuncDesc * pFDesc; - int i; + UINT i; for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++,pFDesc=pFDesc->next); @@ -6888,7 +7086,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetVarCustData( ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData=NULL; TLBVarDesc * pVDesc; - int i; + UINT i; for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, pVDesc=pVDesc->next); @@ -6924,7 +7122,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetImplTypeCustData( ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData=NULL; TLBImplType * pRDesc; - int i; + UINT i; for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++, pRDesc=pRDesc->next); @@ -7051,7 +7249,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetAllFuncCustData( ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData; TLBFuncDesc * pFDesc; - int i; + UINT i; TRACE("(%p) index %d\n", This, index); for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next) @@ -7087,7 +7285,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetAllParamCustData( ITypeInfo2 * iface, ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData=NULL; TLBFuncDesc * pFDesc; - int i; + UINT i; TRACE("(%p) index %d\n", This, indexFunc); for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++, pFDesc=pFDesc->next) @@ -7124,7 +7322,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetAllVarCustData( ITypeInfo2 * iface, ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData; TLBVarDesc * pVDesc; - int i; + UINT i; TRACE("(%p) index %d\n", This, index); for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, pVDesc=pVDesc->next) @@ -7162,7 +7360,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetAllImplTypeCustData( ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TLBCustData *pCData; TLBImplType * pRDesc; - int i; + UINT i; TRACE("(%p) index %d\n", This, index); for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++, pRDesc=pRDesc->next) @@ -7252,7 +7450,7 @@ HRESULT WINAPI CreateDispTypeInfo( { ITypeInfoImpl *pTIClass, *pTIIface; ITypeLibImpl *pTypeLibImpl; - int param, func; + unsigned int param, func; TLBFuncDesc **ppFuncDesc; TLBRefType *ref; diff --git a/reactos/dll/win32/oleaut32/typelib2.c b/reactos/dll/win32/oleaut32/typelib2.c index cbcd7f02332..3d092e50d89 100644 --- a/reactos/dll/win32/oleaut32/typelib2.c +++ b/reactos/dll/win32/oleaut32/typelib2.c @@ -1349,7 +1349,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo( * implementation of ITypeInfo. So we need to do the following... */ res = ITypeInfo_GetContainingTypeLib(pTInfo, &container, &index); - if (!SUCCEEDED(res)) { + if (FAILED(res)) { TRACE("failed to find containing typelib.\n"); return res; } @@ -1708,7 +1708,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncAndParamNames( { ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface; - int i; + UINT i; int offset; char *namedata; diff --git a/reactos/dll/win32/oleaut32/ungif.c b/reactos/dll/win32/oleaut32/ungif.c index 9cb56932bca..79bad60102f 100644 --- a/reactos/dll/win32/oleaut32/ungif.c +++ b/reactos/dll/win32/oleaut32/ungif.c @@ -148,16 +148,16 @@ MakeMapObject(int ColorCount, /*** FIXME: Our ColorCount has to be a power of two. Is it necessary to * make the user know that or should we automatically round up instead? */ if (ColorCount != (1 << BitSize(ColorCount))) { - return ((ColorMapObject *) NULL); + return NULL; } Object = ungif_alloc(sizeof(ColorMapObject)); - if (Object == (ColorMapObject *) NULL) { - return ((ColorMapObject *) NULL); + if (Object == NULL) { + return NULL; } Object->Colors = ungif_calloc(ColorCount, sizeof(GifColorType)); - if (Object->Colors == (GifColorType *) NULL) { + if (Object->Colors == NULL) { return NULL; } @@ -413,9 +413,9 @@ DGifGetImageDesc(GifFileType * GifFile) { return GIF_ERROR; } } - sp->RasterBits = (unsigned char *)NULL; + sp->RasterBits = NULL; sp->ExtensionBlockCount = 0; - sp->ExtensionBlocks = (ExtensionBlock *) NULL; + sp->ExtensionBlocks = NULL; GifFile->ImageCount++; diff --git a/reactos/dll/win32/oleaut32/usrmarshal.c b/reactos/dll/win32/oleaut32/usrmarshal.c index ea5f49e0b2f..85faac46460 100644 --- a/reactos/dll/win32/oleaut32/usrmarshal.c +++ b/reactos/dll/win32/oleaut32/usrmarshal.c @@ -34,7 +34,6 @@ #include "ole2.h" #include "oleauto.h" -#include "rpcproxy.h" #include "typelib.h" #include "ocidl.h" #include "wine/debug.h" @@ -46,25 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align) #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align) -static CStdPSFactoryBuffer PSFactoryBuffer; - -CSTDSTUBBUFFERRELEASE(&PSFactoryBuffer) - -extern const ExtendedProxyFileInfo oleaut32_oaidl_ProxyFileInfo; -extern const ExtendedProxyFileInfo oleaut32_ocidl_ProxyFileInfo; - -static const ProxyFileInfo *OLEAUT32_ProxyFileList[] = { - &oleaut32_oaidl_ProxyFileInfo, - &oleaut32_ocidl_ProxyFileInfo, - NULL -}; - -HRESULT OLEAUTPS_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) -{ - return NdrDllGetClassObject(rclsid, riid, ppv, OLEAUT32_ProxyFileList, - &CLSID_PSDispatch, &PSFactoryBuffer); -} - static void dump_user_flags(const ULONG *pFlags) { if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION) @@ -186,12 +166,9 @@ unsigned char * WINAPI BSTR_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, header = (bstr_wire_t*)Buffer; if(header->len != header->len2) FIXME("len %08x != len2 %08x\n", header->len, header->len2); - - if(*pstr) - { - SysFreeString(*pstr); - *pstr = NULL; - } + + SysFreeString(*pstr); + *pstr = NULL; if(header->byte_len != 0xffffffff) *pstr = SysAllocStringByteLen((char*)(header + 1), header->byte_len); @@ -203,11 +180,8 @@ unsigned char * WINAPI BSTR_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, void WINAPI BSTR_UserFree(ULONG *pFlags, BSTR *pstr) { TRACE("(%x,%p) => %p\n", *pFlags, pstr, *pstr); - if (*pstr) - { - SysFreeString(*pstr); - *pstr = NULL; - } + SysFreeString(*pstr); + *pstr = NULL; } /* VARIANT */ diff --git a/reactos/dll/win32/oleaut32/varformat.c b/reactos/dll/win32/oleaut32/varformat.c index 217fb10c374..d76ceb5e08e 100644 --- a/reactos/dll/win32/oleaut32/varformat.c +++ b/reactos/dll/win32/oleaut32/varformat.c @@ -1391,7 +1391,7 @@ VARIANT_FormatNumber_Bool: break; case FMT_NUM_DECIMAL: - if ((np.dwOutFlags & NUMPRS_NEG) && !(dwState & NUM_WROTE_SIGN)) + if ((np.dwOutFlags & NUMPRS_NEG) && !(dwState & NUM_WROTE_SIGN) && !header->starts[1]) { /* last chance for a negative sign in the .# case */ TRACE("write negative sign\n"); @@ -1476,7 +1476,7 @@ VARIANT_FormatNumber_Bool: { int count, count_max, position; - if ((np.dwOutFlags & NUMPRS_NEG) && !(dwState & NUM_WROTE_SIGN)) + if ((np.dwOutFlags & NUMPRS_NEG) && !(dwState & NUM_WROTE_SIGN) && !header->starts[1]) { TRACE("write negative sign\n"); localeValue = LOCALE_SNEGATIVESIGN; @@ -1532,7 +1532,6 @@ VARIANT_FormatNumber_Bool: } } count = min(count_max, pad); - count_max -= count; pad -= count; TRACE("write %d whole trailing 0's\n", count); while (count--) diff --git a/reactos/dll/win32/oleaut32/variant.c b/reactos/dll/win32/oleaut32/variant.c index 5c094e10278..26a19bbbe85 100644 --- a/reactos/dll/win32/oleaut32/variant.c +++ b/reactos/dll/win32/oleaut32/variant.c @@ -608,8 +608,7 @@ HRESULT WINAPI VariantClear(VARIANTARG* pVarg) } else if (V_VT(pVarg) == VT_BSTR) { - if (V_BSTR(pVarg)) - SysFreeString(V_BSTR(pVarg)); + SysFreeString(V_BSTR(pVarg)); } else if (V_VT(pVarg) == VT_RECORD) { @@ -2323,7 +2322,7 @@ HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig, whole = whole * dblMultipliers[10]; multiplier10 -= 10; } - if (multiplier10) + if (multiplier10 && !bOverflow) { if (whole > dblMaximums[multiplier10]) { @@ -2334,9 +2333,10 @@ HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig, whole = whole * dblMultipliers[multiplier10]; } - TRACE("Scaled double value is %16.16g\n", whole); + if (!bOverflow) + TRACE("Scaled double value is %16.16g\n", whole); - while (divisor10 > 10) + while (divisor10 > 10 && !bOverflow) { if (whole < dblMinimums[10] && whole != 0) { @@ -2347,7 +2347,7 @@ HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig, whole = whole / dblMultipliers[10]; divisor10 -= 10; } - if (divisor10) + if (divisor10 && !bOverflow) { if (whole < dblMinimums[divisor10] && whole != 0) { @@ -5673,14 +5673,14 @@ HRESULT WINAPI VarPow(LPVARIANT left, LPVARIANT right, LPVARIANT result) } hr = VariantChangeType(&dl,left,0,resvt); - if (!SUCCEEDED(hr)) { + if (FAILED(hr)) { ERR("Could not change passed left argument to VT_R8, handle it differently.\n"); hr = E_FAIL; goto end; } hr = VariantChangeType(&dr,right,0,resvt); - if (!SUCCEEDED(hr)) { + if (FAILED(hr)) { ERR("Could not change passed right argument to VT_R8, handle it differently.\n"); hr = E_FAIL; goto end; diff --git a/reactos/dll/win32/oleaut32/vartype.c b/reactos/dll/win32/oleaut32/vartype.c index 52d939e511d..2ef1510506e 100644 --- a/reactos/dll/win32/oleaut32/vartype.c +++ b/reactos/dll/win32/oleaut32/vartype.c @@ -32,7 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(variant); -extern HMODULE OLEAUT32_hModule; +extern HMODULE hProxyDll DECLSPEC_HIDDEN; #define CY_MULTIPLIER 10000 /* 4 dp of precision */ #define CY_MULTIPLIER_F 10000.0 @@ -153,7 +153,7 @@ static HRESULT VARIANT_FromDisp(IDispatch* pdispIn, LCID lcid, void* pOut, /* Compiler cast where input cannot be negative */ #define NEGTST(dest, src, func) RETTYP _##func(src in, dest* out) { \ - if (in < (src)0) return DISP_E_OVERFLOW; *out = in; return S_OK; } + if (in < 0) return DISP_E_OVERFLOW; *out = in; return S_OK; } /* Compiler cast where input cannot be > some number */ #define POSTST(dest, src, func, tst) RETTYP _##func(src in, dest* out) { \ @@ -5949,11 +5949,11 @@ static BOOL VARIANT_GetLocalisedText(LANGID langId, DWORD dwId, WCHAR *lpszDest) { HRSRC hrsrc; - hrsrc = FindResourceExW( OLEAUT32_hModule, (LPWSTR)RT_STRING, + hrsrc = FindResourceExW( hProxyDll, (LPWSTR)RT_STRING, MAKEINTRESOURCEW((dwId >> 4) + 1), langId ); if (hrsrc) { - HGLOBAL hmem = LoadResource( OLEAUT32_hModule, hrsrc ); + HGLOBAL hmem = LoadResource( hProxyDll, hrsrc ); if (hmem) { diff --git a/reactos/dll/win32/rpcrt4/cproxy.c b/reactos/dll/win32/rpcrt4/cproxy.c index 7979c0ecb31..6c26d181978 100644 --- a/reactos/dll/win32/rpcrt4/cproxy.c +++ b/reactos/dll/win32/rpcrt4/cproxy.c @@ -193,7 +193,7 @@ HRESULT WINAPI StdProxy_Construct(REFIID riid, return S_OK; } -static void WINAPI StdProxy_Destruct(LPRPCPROXYBUFFER iface) +static void StdProxy_Destruct(LPRPCPROXYBUFFER iface) { ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface); diff --git a/reactos/dll/win32/rpcrt4/cpsf.c b/reactos/dll/win32/rpcrt4/cpsf.c index 94496956333..bece899d964 100644 --- a/reactos/dll/win32/rpcrt4/cpsf.c +++ b/reactos/dll/win32/rpcrt4/cpsf.c @@ -36,12 +36,25 @@ #include "rpcproxy.h" +#include "wine/unicode.h" #include "wine/debug.h" #include "cpsf.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); +static void format_clsid( WCHAR *buffer, const CLSID *clsid ) +{ + static const WCHAR clsid_formatW[] = {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X','-', + '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X', + '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','}',0}; + + sprintfW( buffer, clsid_formatW, clsid->Data1, clsid->Data2, clsid->Data3, + clsid->Data4[0], clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], + clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7] ); + +} + static BOOL FindProxyInfo(const ProxyFileInfo **pProxyFileList, REFIID riid, const ProxyFileInfo **pProxyInfo, int *pIndex) { while (*pProxyFileList) { @@ -147,7 +160,7 @@ HRESULT WINAPI NdrDllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv, *ppv = NULL; if (!pPSFactoryBuffer->lpVtbl) { const ProxyFileInfo **pProxyFileList2; - int max_delegating_vtbl_size = 0; + DWORD max_delegating_vtbl_size = 0; pPSFactoryBuffer->lpVtbl = &CStdPSFactory_Vtbl; pPSFactoryBuffer->RefCount = 0; pPSFactoryBuffer->pProxyFileList = pProxyFileList; @@ -158,7 +171,7 @@ HRESULT WINAPI NdrDllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv, * async interfaces */ void * const *pSrcRpcStubVtbl = (void * const *)&CStdStubBuffer_Vtbl; void **pRpcStubVtbl = (void **)&(*pProxyFileList2)->pStubVtblList[i]->Vtbl; - int j; + unsigned int j; if ((*pProxyFileList2)->pDelegatedIIDs && (*pProxyFileList2)->pDelegatedIIDs[i]) { pSrcRpcStubVtbl = (void * const *)&CStdStubBuffer_Delegating_Vtbl; @@ -197,6 +210,7 @@ HRESULT WINAPI NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer) return !(pPSFactoryBuffer->RefCount); } + /*********************************************************************** * NdrDllRegisterProxy [RPCRT4.@] */ @@ -204,13 +218,21 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid) { - LPSTR clsid; - char keyname[120], module[MAX_PATH]; + static const WCHAR bothW[] = {'B','o','t','h',0}; + static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0}; + static const WCHAR clsid32W[] = {'P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0}; + static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0}; + static const WCHAR psfactoryW[] = {'P','S','F','a','c','t','o','r','y','B','u','f','f','e','r',0}; + static const WCHAR numformatW[] = {'%','u',0}; + static const WCHAR nummethodsW[] = {'N','u','m','M','e','t','h','o','d','s',0}; + static const WCHAR inprocserverW[] = {'I','n','P','r','o','c','S','e','r','v','e','r','3','2',0}; + static const WCHAR threadingmodelW[] = {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0}; + WCHAR clsid[39], keyname[50], module[MAX_PATH]; HKEY key, subkey; DWORD len; TRACE("(%p,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid)); - UuidToStringA((UUID*)pclsid, (unsigned char**)&clsid); + format_clsid( clsid, pclsid ); /* register interfaces to point to clsid */ while (*pProxyFileList) { @@ -218,23 +240,19 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll, for (u=0; u<(*pProxyFileList)->TableSize; u++) { CInterfaceStubVtbl *proxy = (*pProxyFileList)->pStubVtblList[u]; PCInterfaceName name = (*pProxyFileList)->pNamesArray[u]; - LPSTR iid; - TRACE("registering %s %s => %s\n", name, debugstr_guid(proxy->header.piid), clsid); + TRACE("registering %s %s => %s\n", + debugstr_a(name), debugstr_guid(proxy->header.piid), debugstr_w(clsid)); - UuidToStringA((UUID*)proxy->header.piid, (unsigned char**)&iid); - snprintf(keyname, sizeof(keyname), "Interface\\{%s}", iid); - RpcStringFreeA((unsigned char**)&iid); - if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyname, 0, NULL, 0, - KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) { + strcpyW( keyname, interfaceW ); + format_clsid( keyname + strlenW(keyname), proxy->header.piid ); + if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) { + WCHAR num[10]; if (name) - RegSetValueExA(key, NULL, 0, REG_SZ, (const BYTE *)name, strlen(name)); - if (RegCreateKeyExA(key, "ProxyStubClsid32", 0, NULL, 0, - KEY_WRITE, NULL, &subkey, NULL) == ERROR_SUCCESS) { - snprintf(module, sizeof(module), "{%s}", clsid); - RegSetValueExA(subkey, NULL, 0, REG_SZ, (LPBYTE)module, strlen(module)); - RegCloseKey(subkey); - } + RegSetValueExA(key, NULL, 0, REG_SZ, (const BYTE *)name, strlen(name)+1); + RegSetValueW( key, clsid32W, REG_SZ, clsid, 0 ); + sprintfW(num, numformatW, proxy->header.DispatchTableCount); + RegSetValueW( key, nummethodsW, REG_SZ, num, 0 ); RegCloseKey(key); } } @@ -242,25 +260,22 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll, } /* register clsid to point to module */ - snprintf(keyname, sizeof(keyname), "CLSID\\{%s}", clsid); - len = GetModuleFileNameA(hDll, module, sizeof(module)); + strcpyW( keyname, clsidW ); + strcatW( keyname, clsid ); + len = GetModuleFileNameW(hDll, module, sizeof(module)/sizeof(WCHAR)); if (len && len < sizeof(module)) { - TRACE("registering CLSID %s => %s\n", clsid, module); - if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyname, 0, NULL, 0, - KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) { - RegSetValueExA(subkey, NULL, 0, REG_SZ, (const BYTE *)"PSFactoryBuffer", strlen("PSFactoryBuffer")); - if (RegCreateKeyExA(key, "InProcServer32", 0, NULL, 0, - KEY_WRITE, NULL, &subkey, NULL) == ERROR_SUCCESS) { - RegSetValueExA(subkey, NULL, 0, REG_SZ, (LPBYTE)module, strlen(module)); - RegSetValueExA(subkey, "ThreadingModel", 0, REG_SZ, (const BYTE *)"Both", strlen("Both")); - RegCloseKey(subkey); + TRACE("registering CLSID %s => %s\n", debugstr_w(clsid), debugstr_w(module)); + if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) { + RegSetValueExW(subkey, NULL, 0, REG_SZ, (const BYTE *)psfactoryW, sizeof(psfactoryW)); + if (RegCreateKeyW(key, inprocserverW, &subkey) == ERROR_SUCCESS) { + RegSetValueExW(subkey, NULL, 0, REG_SZ, (LPBYTE)module, (strlenW(module)+1)*sizeof(WCHAR)); + RegSetValueExW(subkey, threadingmodelW, 0, REG_SZ, (const BYTE *)bothW, sizeof(bothW)); + RegCloseKey(subkey); + } + RegCloseKey(key); } - RegCloseKey(key); - } } - /* done */ - RpcStringFreeA((unsigned char**)&clsid); return S_OK; } @@ -271,12 +286,11 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid) { - LPSTR clsid; - char keyname[120], module[MAX_PATH]; - DWORD len; + static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0}; + static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0}; + WCHAR keyname[50]; TRACE("(%p,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid)); - UuidToStringA((UUID*)pclsid, (unsigned char**)&clsid); /* unregister interfaces */ while (*pProxyFileList) { @@ -284,27 +298,20 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll, for (u=0; u<(*pProxyFileList)->TableSize; u++) { CInterfaceStubVtbl *proxy = (*pProxyFileList)->pStubVtblList[u]; PCInterfaceName name = (*pProxyFileList)->pNamesArray[u]; - LPSTR iid; - TRACE("unregistering %s %s <= %s\n", name, debugstr_guid(proxy->header.piid), clsid); + TRACE("unregistering %s %s\n", debugstr_a(name), debugstr_guid(proxy->header.piid)); - UuidToStringA((UUID*)proxy->header.piid, (unsigned char**)&iid); - snprintf(keyname, sizeof(keyname), "Interface\\{%s}", iid); - RpcStringFreeA((unsigned char**)&iid); - RegDeleteKeyA(HKEY_CLASSES_ROOT, keyname); + strcpyW( keyname, interfaceW ); + format_clsid( keyname + strlenW(keyname), proxy->header.piid ); + RegDeleteTreeW(HKEY_CLASSES_ROOT, keyname); } pProxyFileList++; } /* unregister clsid */ - snprintf(keyname, sizeof(keyname), "CLSID\\{%s}", clsid); - len = GetModuleFileNameA(hDll, module, sizeof(module)); - if (len && len < sizeof(module)) { - TRACE("unregistering CLSID %s <= %s\n", clsid, module); - RegDeleteKeyA(HKEY_CLASSES_ROOT, keyname); - } + strcpyW( keyname, clsidW ); + format_clsid( keyname + strlenW(keyname), pclsid ); + RegDeleteTreeW(HKEY_CLASSES_ROOT, keyname); - /* done */ - RpcStringFreeA((unsigned char**)&clsid); return S_OK; } diff --git a/reactos/dll/win32/rpcrt4/ndr_fullpointer.c b/reactos/dll/win32/rpcrt4/ndr_fullpointer.c index 307e54540d0..b686683f6f4 100644 --- a/reactos/dll/win32/rpcrt4/ndr_fullpointer.c +++ b/reactos/dll/win32/rpcrt4/ndr_fullpointer.c @@ -111,7 +111,7 @@ int WINAPI NdrFullPointerQueryPointer(PFULL_PTR_XLAT_TABLES pXlatTables, ULONG *pRefId ) { ULONG Hash = 0; - int i; + unsigned int i; PFULL_PTR_TO_REFID_ELEMENT XlatTableEntry; TRACE("(%p, %p, %d, %p)\n", pXlatTables, pPointer, QueryType, pRefId); @@ -186,7 +186,7 @@ void WINAPI NdrFullPointerInsertRefId(PFULL_PTR_XLAT_TABLES pXlatTables, ULONG RefId, void *pPointer) { ULONG Hash = 0; - int i; + unsigned int i; PFULL_PTR_TO_REFID_ELEMENT XlatTableEntry; TRACE("(%p, 0x%x, %p)\n", pXlatTables, RefId, pPointer); @@ -211,7 +211,7 @@ void WINAPI NdrFullPointerInsertRefId(PFULL_PTR_XLAT_TABLES pXlatTables, int WINAPI NdrFullPointerFree(PFULL_PTR_XLAT_TABLES pXlatTables, void *Pointer) { ULONG Hash = 0; - int i; + unsigned int i; PFULL_PTR_TO_REFID_ELEMENT XlatTableEntry; ULONG RefId = 0; diff --git a/reactos/dll/win32/rpcrt4/ndr_marshall.c b/reactos/dll/win32/rpcrt4/ndr_marshall.c index 3be736d1edc..9608f1e56c6 100644 --- a/reactos/dll/win32/rpcrt4/ndr_marshall.c +++ b/reactos/dll/win32/rpcrt4/ndr_marshall.c @@ -391,7 +391,7 @@ void * WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, SIZE_T len) return p; } -static void WINAPI NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer) +static void NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer) { TRACE("(%p, %p)\n", pStubMsg, Pointer); diff --git a/reactos/dll/win32/rpcrt4/ndr_stubless.c b/reactos/dll/win32/rpcrt4/ndr_stubless.c index 0daf22e9364..98334832e3c 100644 --- a/reactos/dll/win32/rpcrt4/ndr_stubless.c +++ b/reactos/dll/win32/rpcrt4/ndr_stubless.c @@ -107,7 +107,7 @@ void WINAPI NdrRpcSmSetClientToOsf(PMIDL_STUB_MESSAGE pMessage) #endif } -static void WINAPI dump_RPC_FC_PROC_PF(PARAM_ATTRIBUTES param_attributes) +static void dump_RPC_FC_PROC_PF(PARAM_ATTRIBUTES param_attributes) { if (param_attributes.MustSize) TRACE(" MustSize"); if (param_attributes.MustFree) TRACE(" MustFree"); @@ -123,7 +123,7 @@ static void WINAPI dump_RPC_FC_PROC_PF(PARAM_ATTRIBUTES param_attributes) if (param_attributes.ServerAllocSize) TRACE(" ServerAllocSize = %d", param_attributes.ServerAllocSize * 8); } -static void WINAPI dump_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags) +static void dump_INTERPRETER_OPT_FLAGS(INTERPRETER_OPT_FLAGS Oi2Flags) { if (Oi2Flags.ServerMustSize) TRACE(" ServerMustSize"); if (Oi2Flags.ClientMustSize) TRACE(" ClientMustSize"); diff --git a/reactos/dll/win32/rpcrt4/rpc_server.c b/reactos/dll/win32/rpcrt4/rpc_server.c index 6201166a750..fc66d7fe859 100644 --- a/reactos/dll/win32/rpcrt4/rpc_server.c +++ b/reactos/dll/win32/rpcrt4/rpc_server.c @@ -1061,6 +1061,8 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListen( void ) LeaveCriticalSection(&listen_cs); + FIXME("not waiting for server calls to finish\n"); + return RPC_S_OK; } diff --git a/reactos/dll/win32/rpcrt4/rpc_transport.c b/reactos/dll/win32/rpcrt4/rpc_transport.c index 14aa908929e..50520aea13a 100644 --- a/reactos/dll/win32/rpcrt4/rpc_transport.c +++ b/reactos/dll/win32/rpcrt4/rpc_transport.c @@ -501,7 +501,6 @@ static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data, memcpy(tower_data, networkaddr, networkaddr_size); else tower_data[0] = 0; - tower_data += networkaddr_size; return size; } @@ -714,7 +713,6 @@ static size_t rpcrt4_ncalrpc_get_top_of_tower(unsigned char *tower_data, pipe_floor->count_rhs = endpoint_size; memcpy(tower_data, endpoint, endpoint_size); - tower_data += endpoint_size; return size; } @@ -756,6 +754,8 @@ static RPC_STATUS rpcrt4_ncalrpc_parse_top_of_tower(const unsigned char *tower_d /**** ncacn_ip_tcp support ****/ +#ifdef HAVE_SOCKETPAIR + typedef struct _RpcConnection_tcp { RpcConnection common; @@ -1348,7 +1348,8 @@ static void rpcrt4_protseq_sock_free_wait_array(RpcServerProtseq *protseq, void static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array) { struct pollfd *poll_info = wait_array; - int ret, i; + int ret; + unsigned int i; RpcConnection *cconn; RpcConnection_tcp *conn; @@ -1395,6 +1396,8 @@ static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq return 1; } +#endif /* HAVE_SOCKETPAIR */ + static const struct connection_ops conn_protseq_list[] = { { "ncacn_np", { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB }, @@ -1422,6 +1425,7 @@ static const struct connection_ops conn_protseq_list[] = { rpcrt4_ncalrpc_get_top_of_tower, rpcrt4_ncalrpc_parse_top_of_tower, }, +#ifdef HAVE_SOCKETPAIR { "ncacn_ip_tcp", { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP }, rpcrt4_conn_tcp_alloc, @@ -1435,6 +1439,7 @@ static const struct connection_ops conn_protseq_list[] = { rpcrt4_ncacn_ip_tcp_get_top_of_tower, rpcrt4_ncacn_ip_tcp_parse_top_of_tower, } +#endif }; @@ -1458,6 +1463,7 @@ static const struct protseq_ops protseq_list[] = rpcrt4_protseq_np_wait_for_new_connection, rpcrt4_protseq_ncalrpc_open_endpoint, }, +#ifdef HAVE_SOCKETPAIR { "ncacn_ip_tcp", rpcrt4_protseq_sock_alloc, @@ -1467,13 +1473,14 @@ static const struct protseq_ops protseq_list[] = rpcrt4_protseq_sock_wait_for_new_connection, rpcrt4_protseq_ncacn_ip_tcp_open_endpoint, }, +#endif }; #define ARRAYSIZE(a) (sizeof((a)) / sizeof((a)[0])) const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq) { - int i; + unsigned int i; for(i=0; i . include/reactos/wine + 0x600 diff --git a/reactos/dll/win32/rpcrt4/rpcrt4_main.c b/reactos/dll/win32/rpcrt4/rpcrt4_main.c index 1f0b1bbd615..177c82caadb 100644 --- a/reactos/dll/win32/rpcrt4/rpcrt4_main.c +++ b/reactos/dll/win32/rpcrt4/rpcrt4_main.c @@ -78,7 +78,7 @@ static CRITICAL_SECTION_DEBUG threaddata_cs_debug = }; static CRITICAL_SECTION threaddata_cs = { &threaddata_cs_debug, -1, 0, 0, 0, 0 }; -struct list threaddata_list = LIST_INIT(threaddata_list); +static struct list threaddata_list = LIST_INIT(threaddata_list); struct context_handle_list { diff --git a/reactos/include/psdk/rpcndr.h b/reactos/include/psdk/rpcndr.h index 97638de773e..15f1cb2a21d 100644 --- a/reactos/include/psdk/rpcndr.h +++ b/reactos/include/psdk/rpcndr.h @@ -111,7 +111,7 @@ typedef unsigned char boolean; #define midl_user_free MIDL_user_free #define midl_user_allocate MIDL_user_allocate -#define NdrFcShort(s) (unsigned char)(s & 0xff), (unsigned char)((s & 0xff00) >> 8) +#define NdrFcShort(s) (unsigned char)(s & 0xff), (unsigned char)(s >> 8) #define NdrFcLong(s) (unsigned char)(s & 0xff), (unsigned char)((s & 0x0000ff00) >> 8), \ (unsigned char)((s & 0x00ff0000) >> 16), (unsigned char)(s >> 24) @@ -220,7 +220,7 @@ typedef struct _MIDL_STUB_MESSAGE int fNeedMCCP:1; int fUnused:3; int fUnused2:16; - unsigned long dwDestContext; + DWORD dwDestContext; void *pvDestContext; NDR_SCONTEXT *SavedContextHandles; LONG ParamNumber; @@ -230,7 +230,7 @@ typedef struct _MIDL_STUB_MESSAGE ULONG *SizePtrOffsetArray; ULONG *SizePtrLengthArray; void *pArgQueue; - unsigned long dwStubPhase; + DWORD dwStubPhase; void *LowStackMark; PNDR_ASYNC_MESSAGE pAsyncMsg; PNDR_CORRELATION_INFO pCorrInfo; @@ -291,8 +291,8 @@ typedef struct _USER_MARSHAL_ROUTINE_QUADRUPLE /* 'USRC' */ #define USER_MARSHAL_CB_SIGNATURE \ - ( ( (unsigned long)'U' << 24 ) | ( (unsigned long)'S' << 16 ) | \ - ( (unsigned long)'R' << 8 ) | ( (unsigned long)'C' ) ) + ( ( (DWORD)'U' << 24 ) | ( (DWORD)'S' << 16 ) | \ + ( (DWORD)'R' << 8 ) | ( (DWORD)'C' ) ) typedef enum { @@ -462,8 +462,7 @@ typedef struct _FULL_PTR_XLAT_TABLES { struct IRpcStubBuffer; -typedef unsigned long error_status_t; - +typedef ULONG error_status_t; typedef void * NDR_CCONTEXT; typedef struct _SCONTEXT_QUEUE { @@ -650,13 +649,13 @@ RPCRTAPI void RPC_ENTRY NdrAsyncServerCall( PRPC_MESSAGE pRpcMsg ); RPCRTAPI LONG RPC_ENTRY - NdrStubCall2( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, unsigned long * pdwStubPhase ); + NdrStubCall2( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, DWORD * pdwStubPhase ); RPCRTAPI LONG RPC_ENTRY - NdrStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, unsigned long * pdwStubPhase ); + NdrStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, DWORD * pdwStubPhase ); RPCRTAPI LONG RPC_ENTRY - NdrAsyncStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, unsigned long * pdwStubPhase ); + NdrAsyncStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, DWORD * pdwStubPhase ); RPCRTAPI LONG RPC_ENTRY - NdrDcomAsyncStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, unsigned long * pdwStubPhase ); + NdrDcomAsyncStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, DWORD * pdwStubPhase ); RPCRTAPI void* RPC_ENTRY NdrAllocate( PMIDL_STUB_MESSAGE pStubMsg, SIZE_T Len ) __WINE_ALLOC_SIZE(2); diff --git a/reactos/include/psdk/rpcproxy.h b/reactos/include/psdk/rpcproxy.h index acddc729b36..76a88128d83 100644 --- a/reactos/include/psdk/rpcproxy.h +++ b/reactos/include/psdk/rpcproxy.h @@ -125,7 +125,7 @@ typedef struct tagCStdPSFactoryBuffer #define STUB_FORWARDING_FUNCTION NdrStubForwardingFunction -ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This); +ULONG STDMETHODCALLTYPE CStdStubBuffer2_Release(IRpcStubBuffer *This) DECLSPEC_HIDDEN; ULONG STDMETHODCALLTYPE NdrCStdStubBuffer2_Release(IRpcStubBuffer *This, IPSFactoryBuffer *pPSF); #define CStdStubBuffer_DELEGATING_METHODS 0, 0, CStdStubBuffer2_Release, 0, 0, 0, 0, 0, 0, 0 @@ -136,7 +136,7 @@ HRESULT WINAPI ULONG WINAPI CStdStubBuffer_AddRef( IRpcStubBuffer *This ); ULONG WINAPI - CStdStubBuffer_Release( IRpcStubBuffer *This ); + CStdStubBuffer_Release( IRpcStubBuffer *This ) DECLSPEC_HIDDEN; ULONG WINAPI NdrCStdStubBuffer_Release( IRpcStubBuffer *This, IPSFactoryBuffer *pPSF ); HRESULT WINAPI @@ -233,10 +233,10 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ /* macros used in dlldata.c files */ #define EXTERN_PROXY_FILE(proxy) \ - EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo; + EXTERN_C const ProxyFileInfo proxy##_ProxyFileInfo DECLSPEC_HIDDEN; #define PROXYFILE_LIST_START \ - const ProxyFileInfo *aProxyFileList[] = \ + const ProxyFileInfo * aProxyFileList[] DECLSPEC_HIDDEN = \ { #define REFERENCE_PROXY_FILE(proxy) \ @@ -251,11 +251,11 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ /* define PROXY_CLSID_IS to specify the CLSID data of the PSFactoryBuffer */ /* define neither to use the GUID of the first interface */ #ifdef PROXY_CLSID -# define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID; +# define CLSID_PSFACTORYBUFFER extern CLSID PROXY_CLSID DECLSPEC_HIDDEN; #else # ifdef PROXY_CLSID_IS -# define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer = \ - PROXY_CLSID_IS; +# define CLSID_PSFACTORYBUFFER const CLSID CLSID_PSFactoryBuffer DECLSPEC_HIDDEN; \ + const CLSID CLSID_PSFactoryBuffer = PROXY_CLSID_IS; # define PROXY_CLSID CLSID_PSFactoryBuffer # else # define CLSID_PSFACTORYBUFFER @@ -286,6 +286,8 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ #endif #define DLLDATA_GETPROXYDLLINFO(pfl, rclsid) \ + void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \ + const CLSID **ppClsid) DECLSPEC_HIDDEN; \ void RPC_ENTRY GetProxyDllInfo(const ProxyFileInfo ***ppProxyFileInfo, \ const CLSID **ppClsid) \ { \ @@ -294,6 +296,7 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ } #define DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, factory) \ + HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN; \ HRESULT WINAPI DLLGETCLASSOBJECT_ENTRY(REFCLSID rclsid, REFIID riid, \ void **ppv) \ { \ @@ -302,14 +305,16 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ } #define DLLCANUNLOADNOW(factory) \ + HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) DECLSPEC_HIDDEN; \ HRESULT WINAPI DLLCANUNLOADNOW_ENTRY(void) \ { \ return NdrDllCanUnloadNow((factory)); \ } #define REGISTER_PROXY_DLL_ROUTINES(pfl, factory_clsid) \ - HINSTANCE hProxyDll = NULL; \ + HINSTANCE hProxyDll DECLSPEC_HIDDEN = NULL; \ \ + BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DECLSPEC_HIDDEN; \ BOOL WINAPI DLLMAIN_ENTRY(HINSTANCE hinstDLL, DWORD fdwReason, \ LPVOID lpvReserved) \ { \ @@ -321,11 +326,13 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ return TRUE; \ } \ \ + HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \ HRESULT WINAPI DLLREGISTERSERVER_ENTRY(void) \ { \ return NdrDllRegisterProxy(hProxyDll, (pfl), (factory_clsid)); \ } \ \ + HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) DECLSPEC_HIDDEN; \ HRESULT WINAPI DLLUNREGISTERSERVER_ENTRY(void) \ { \ return NdrDllUnregisterProxy(hProxyDll, (pfl), (factory_clsid)); \ @@ -340,7 +347,7 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \ #define DLLDATA_ROUTINES(pfl, factory_clsid) \ CLSID_PSFACTORYBUFFER \ - CStdPSFactoryBuffer gPFactory = { NULL, 0, NULL, 0 }; \ + CStdPSFactoryBuffer DECLSPEC_HIDDEN gPFactory = { NULL, 0, NULL, 0 }; \ DLLDATA_GETPROXYDLLINFO(pfl, factory_clsid) \ DLLGETCLASSOBJECTROUTINE(pfl, factory_clsid, &gPFactory) \ DLLCANUNLOADNOW(&gPFactory) \ diff --git a/reactos/include/psdk/stdole2.idl b/reactos/include/psdk/stdole2.idl index 072743f3153..0aa52c8be34 100644 --- a/reactos/include/psdk/stdole2.idl +++ b/reactos/include/psdk/stdole2.idl @@ -191,12 +191,9 @@ library stdole typedef [uuid(BF030645-9069-101B-AE2D-08002B2EC713), public] VARIANT_BOOL OLE_ENABLEDEFAULTBOOL; - /* FIXME: widl can't cope with enum attributes yet */ - /* [ uuid(6650430A-BE0F-101A-8BBB-00AA00300CAB) ] - */ enum OLE_TRISTATE { Unchecked = 0, Checked = 1, @@ -380,12 +377,9 @@ library stdole interface IPicture; }; - /* FIXME: widl can't cope with enum attributes yet */ - /* [ uuid(E6C8FA08-BD9F-11D0-985E-00C04FC29993) ] - */ enum LoadPictureConstants { Default = 0, Monochrome = 1, diff --git a/reactos/include/reactos/wine/irot.idl b/reactos/include/reactos/wine/irot.idl index e1a62398327..54d86531ef1 100644 --- a/reactos/include/reactos/wine/irot.idl +++ b/reactos/include/reactos/wine/irot.idl @@ -22,75 +22,76 @@ cpp_quote("#define IROT_PROTSEQ {'n','c','a','l','r','p','c',0}") cpp_quote("#define IROT_ENDPOINT {'i','r','o','t',0}") typedef struct tagMonikerComparisonData { - ULONG ulCntData; - [size_is(ulCntData)] BYTE abData[]; + ULONG ulCntData; + [size_is(ulCntData)] BYTE abData[]; } MonikerComparisonData; [ uuid(7a98c254-6808-11cf-b73b-00aa00b677a8), - version(0.2) + version(0.2), + strict_context_handle ] interface Irot { - typedef struct tagInterfaceData - { - ULONG ulCntData; - [size_is(ulCntData)] BYTE abData[]; - } InterfaceData; + typedef struct tagInterfaceData + { + ULONG ulCntData; + [size_is(ulCntData)] BYTE abData[]; + } InterfaceData; - typedef [unique] InterfaceData *PInterfaceData; + typedef [unique] InterfaceData *PInterfaceData; - typedef struct tagInterfaceList - { - ULONG size; - [size_is(size)] PInterfaceData interfaces[]; - } InterfaceList; + typedef struct tagInterfaceList + { + ULONG size; + [size_is(size)] PInterfaceData interfaces[]; + } InterfaceList; - typedef [unique] InterfaceList *PInterfaceList; + typedef [unique] InterfaceList *PInterfaceList; - typedef DWORD IrotCookie; + typedef DWORD IrotCookie; - typedef handle_t IrotHandle; - typedef [context_handle] void *IrotContextHandle; + typedef handle_t IrotHandle; + typedef [context_handle] void *IrotContextHandle; - HRESULT IrotRegister( - [in] IrotHandle h, - [in] const MonikerComparisonData *moniker_data, - [in] const InterfaceData *object, - [in] const InterfaceData *moniker, - [in] const FILETIME *time, - [in] DWORD grfFlags, - [out] IrotCookie *cookie, - [out] IrotContextHandle *ctxt_handle); + HRESULT IrotRegister( + [in] IrotHandle h, + [in] const MonikerComparisonData *moniker_data, + [in] const InterfaceData *object, + [in] const InterfaceData *moniker, + [in] const FILETIME *time, + [in] DWORD grfFlags, + [out] IrotCookie *cookie, + [out] IrotContextHandle *ctxt_handle); - HRESULT IrotRevoke( - [in] IrotHandle h, - [in] IrotCookie cookie, - [in, out] IrotContextHandle *ctxt_handle, - [out] PInterfaceData *object, - [out] PInterfaceData *moniker); + HRESULT IrotRevoke( + [in] IrotHandle h, + [in] IrotCookie cookie, + [in, out] IrotContextHandle *ctxt_handle, + [out] PInterfaceData *object, + [out] PInterfaceData *moniker); - HRESULT IrotIsRunning( - [in] IrotHandle h, - [in] const MonikerComparisonData *moniker_data); + HRESULT IrotIsRunning( + [in] IrotHandle h, + [in] const MonikerComparisonData *moniker_data); - HRESULT IrotGetObject( - [in] IrotHandle h, - [in] const MonikerComparisonData *moniker_data, - [out] PInterfaceData *obj, - [out] IrotCookie *cookie); + HRESULT IrotGetObject( + [in] IrotHandle h, + [in] const MonikerComparisonData *moniker_data, + [out] PInterfaceData *obj, + [out] IrotCookie *cookie); - HRESULT IrotNoteChangeTime( - [in] IrotHandle h, - [in] IrotCookie cookie, - [in] const FILETIME *time); + HRESULT IrotNoteChangeTime( + [in] IrotHandle h, + [in] IrotCookie cookie, + [in] const FILETIME *time); - HRESULT IrotGetTimeOfLastChange( - [in] IrotHandle h, - [in] const MonikerComparisonData *moniker_data, - [out] FILETIME *time); + HRESULT IrotGetTimeOfLastChange( + [in] IrotHandle h, + [in] const MonikerComparisonData *moniker_data, + [out] FILETIME *time); - HRESULT IrotEnumRunning( - [in] IrotHandle h, - [out] PInterfaceList *list); + HRESULT IrotEnumRunning( + [in] IrotHandle h, + [out] PInterfaceList *list); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index c8c14dd2eb7..c3c43f9d2c7 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -1011,6 +1011,31 @@ MingwModuleHandler::GenerateObjectMacros ( delete stubs_file; } + + if ( module.type == RpcProxy ) + { + const FileLocation *dlldata_file = GetDlldataFilename(); + + fprintf ( + fMakefile, + "%s += %s\n", + objectsMacro.c_str(), + ReplaceExtension ( backend->GetFullName ( *dlldata_file ), ".o" ).c_str() ); + + delete dlldata_file; + } +} + +const FileLocation* +MingwModuleHandler::GetDlldataFilename() const +{ + std::string dlldata_path = ""; + size_t dlldata_path_len = module.xmlbuildFile.find_last_of(cSep); + + if ( dlldata_path_len != std::string::npos && dlldata_path_len != 0 ) + dlldata_path = module.xmlbuildFile.substr(0, dlldata_path_len); + + return new FileLocation( IntermediateDirectory, dlldata_path, module.name + ".dlldata.c" ); } /* caller needs to delete the returned object */ @@ -1139,6 +1164,13 @@ Rule widlProxyRule ( "$(source): ${$(module_name)_precondition}\n" "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.c", "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_p.o", "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL ); +Rule widlDlldataRule ( "$(source): $(dependencies) ${$(module_name)_precondition} $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n" + "\t$(ECHO_WIDL)\n" + "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) --dlldata-only --dlldata=$(source) $(bare_dependencies)\n" + "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).o: $(source) $(dependencies) | $(INTERMEDIATE)$(SEP)$(source_dir)\n" + "\t$(ECHO_CC)\n" + "\t${gcc} -o $@ $($(module_name)_CFLAGS)$(compiler_flags) -c $<\n", + "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).o", NULL ); Rule widlTlbRule ( "$(source): ${$(module_name)_precondition}\n" "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(module_name).tlb: $(source)$(dependencies) $(WIDL_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n" "\t$(ECHO_WIDL)\n" @@ -1642,6 +1674,16 @@ MingwModuleHandler::GenerateObjectFileTargets ( const IfableData& data ) defRule->Execute ( fMakefile, backend, module, module.importLibrary->source, clean_files ); } + + if ( module.type == RpcProxy ) + { + widlDlldataRule.Execute ( fMakefile, + backend, + module, + GetDlldataFilename(), + clean_files, + ssprintf ( "$(%s_SOURCES)", module.name.c_str ()) ); + } } void diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 83210bcdc26..a06205616e4 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -136,6 +136,7 @@ private: void GenerateSourceMacros ( const IfableData& data ); void GenerateObjectMacros ( const IfableData& data ); const FileLocation* GetPrecompiledHeaderFilename () const; + const FileLocation* GetDlldataFilename () const; void GenerateGccCommand ( const FileLocation* sourceFile, const Rule *rule, const std::string& extraDependencies ); diff --git a/reactos/tools/rbuild/backend/mingw/rule.cpp b/reactos/tools/rbuild/backend/mingw/rule.cpp index e177ca84b58..6c1c3b00c6a 100644 --- a/reactos/tools/rbuild/backend/mingw/rule.cpp +++ b/reactos/tools/rbuild/backend/mingw/rule.cpp @@ -54,6 +54,7 @@ FixString ( const string& str, Backend *backend, const Module& module, const Fil ReplaceVariable ( ret, "$(source_path)", backend->GetFullPath ( *source ) ); } ReplaceVariable ( ret, "$(dependencies)", dep ); + ReplaceVariable ( ret, "$(bare_dependencies)", additional_dependencies ); ReplaceVariable ( ret, "$(module_name)", module.name ); ReplaceVariable ( ret, "$(module_dllname)", module.GetDllName() ); ReplaceVariable ( ret, "$(module_output)", GetTargetMacro ( module, true ) ); diff --git a/reactos/tools/widl/client.c b/reactos/tools/widl/client.c index 191ae188636..673b9188357 100644 --- a/reactos/tools/widl/client.c +++ b/reactos/tools/widl/client.c @@ -99,6 +99,50 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) context_handle_var = get_context_handle_var(func); } + print_client( "struct __frame_%s%s\n{\n", prefix_client, get_name(def) ); + indent++; + print_client( "__DECL_EXCEPTION_FRAME\n" ); + print_client("MIDL_STUB_MESSAGE _StubMsg;\n"); + if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var) + { + if (!implicit_handle && explicit_generic_handle_var) + print_client("%s %s;\n", + get_explicit_generic_handle_type(explicit_generic_handle_var)->name, + explicit_generic_handle_var->name ); + print_client("RPC_BINDING_HANDLE _Handle;\n"); + } + + if (!is_void(get_func_return_type(func)) && decl_indirect(get_func_return_type(func))) + { + print_client("void *_p_%s;\n", "_RetVal" ); + } + indent--; + print_client( "};\n\n" ); + + print_client( "static void __finally_%s%s(", prefix_client, get_name(def) ); + print_client( " struct __frame_%s%s *__frame )\n{\n", prefix_client, get_name(def) ); + indent++; + + /* FIXME: emit client finally code */ + + if (has_full_pointer) + write_full_pointer_free(client, indent, func); + + print_client("NdrFreeBuffer(&__frame->_StubMsg);\n"); + + if (!implicit_handle && explicit_generic_handle_var) + { + fprintf(client, "\n"); + print_client("if (__frame->_Handle)\n"); + indent++; + print_client("%s_unbind(__frame->%s, __frame->_Handle);\n", + get_explicit_generic_handle_type(explicit_generic_handle_var)->name, + explicit_generic_handle_var->name); + indent--; + } + indent--; + print_client( "}\n\n" ); + write_type_decl_left(client, get_func_return_type(func)); if (needs_space_after(get_func_return_type(func))) fprintf(client, " "); @@ -115,6 +159,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) /* write the functions body */ fprintf(client, "{\n"); indent++; + print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(def) ); /* declare return value '_RetVal' */ if (!is_void(get_func_return_type(func))) @@ -123,19 +168,24 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) write_type_decl_left(client, get_func_return_type(func)); fprintf(client, " _RetVal;\n"); } + print_client("RPC_MESSAGE _RpcMessage;\n"); if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var) - print_client("RPC_BINDING_HANDLE _Handle = 0;\n"); - - print_client("RPC_MESSAGE _RpcMessage;\n"); - print_client("MIDL_STUB_MESSAGE _StubMsg;\n"); + { + print_client( "__frame->_Handle = 0;\n" ); + if (!implicit_handle && explicit_generic_handle_var) + print_client("__frame->%s = %s;\n", + explicit_generic_handle_var->name, explicit_generic_handle_var->name ); + } if (!is_void(get_func_return_type(func)) && decl_indirect(get_func_return_type(func))) { - print_client("void *_p_%s = &%s;\n", + print_client("__frame->_p_%s = &%s;\n", "_RetVal", "_RetVal"); } fprintf(client, "\n"); + print_client( "RpcExceptionInit( 0, __finally_%s%s );\n", prefix_client, get_name(def) ); + if (has_full_pointer) write_full_pointer_init(client, indent, func, FALSE); @@ -146,14 +196,8 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("{\n"); indent++; - print_client("NdrClientInitializeNew(\n"); - indent++; - print_client("(PRPC_MESSAGE)&_RpcMessage,\n"); - print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); - print_client("(PMIDL_STUB_DESC)&%s_StubDesc,\n", iface->name); - print_client("%d);\n", method_count); - indent--; - fprintf(client, "\n"); + print_client("NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, &%s_StubDesc, %d);\n", + iface->name, method_count); if (is_attr(def->attrs, ATTR_IDEMPOTENT) || is_attr(def->attrs, ATTR_BROADCAST)) { @@ -167,12 +211,12 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) if (explicit_handle_var) { - print_client("_Handle = %s;\n", explicit_handle_var->name); + print_client("__frame->_Handle = %s;\n", explicit_handle_var->name); fprintf(client, "\n"); } else if (explicit_generic_handle_var) { - print_client("_Handle = %s_bind(%s);\n", + print_client("__frame->_Handle = %s_bind(%s);\n", get_explicit_generic_handle_type(explicit_generic_handle_var)->name, explicit_generic_handle_var->name); fprintf(client, "\n"); @@ -185,7 +229,8 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) int is_ch_ptr = is_aliaschain_attr(context_handle_var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE; print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", context_handle_var->name); indent++; - print_client("_Handle = NDRCContextBinding(%s%s);\n", is_ch_ptr ? "*" : "", context_handle_var->name); + print_client("__frame->_Handle = NDRCContextBinding(%s%s);\n", + is_ch_ptr ? "*" : "", context_handle_var->name); indent--; if (is_attr(context_handle_var->attrs, ATTR_IN) && !is_attr(context_handle_var->attrs, ATTR_OUT)) @@ -199,38 +244,29 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) } else if (implicit_handle) { - print_client("_Handle = %s;\n", implicit_handle); + print_client("__frame->_Handle = %s;\n", implicit_handle); fprintf(client, "\n"); } - write_remoting_arguments(client, indent, func, PASS_IN, PHASE_BUFFERSIZE); + write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_BUFFERSIZE); - print_client("NdrGetBuffer(\n"); - indent++; - print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); - print_client("_StubMsg.BufferLength,\n"); + print_client("NdrGetBuffer(&__frame->_StubMsg, __frame->_StubMsg.BufferLength, "); if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var) - print_client("_Handle);\n"); + fprintf(client, "__frame->_Handle);\n\n"); else - print_client("%s__MIDL_AutoBindHandle);\n", iface->name); - indent--; - fprintf(client, "\n"); + fprintf(client,"%s__MIDL_AutoBindHandle);\n\n", iface->name); /* marshal arguments */ - write_remoting_arguments(client, indent, func, PASS_IN, PHASE_MARSHAL); + write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_MARSHAL); /* send/receive message */ /* print_client("NdrNsSendReceive(\n"); */ - /* print_client("(unsigned char *)_StubMsg.Buffer,\n"); */ + /* print_client("(unsigned char *)__frame->_StubMsg.Buffer,\n"); */ /* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */ - print_client("NdrSendReceive(\n"); - indent++; - print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); - print_client("(unsigned char *)_StubMsg.Buffer);\n\n"); - indent--; + print_client("NdrSendReceive(&__frame->_StubMsg, __frame->_StubMsg.Buffer);\n\n"); - print_client("_StubMsg.BufferStart = (unsigned char *)_RpcMessage.Buffer;\n"); - print_client("_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n"); + print_client("__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n"); + print_client("__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n"); if (has_out_arg_or_return(func)) { @@ -238,16 +274,14 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; - print_client("NdrConvert(\n"); - indent++; - print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); - print_client("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset); - indent -= 2; + print_client("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", + *proc_offset); + indent--; } /* unmarshall arguments */ fprintf(client, "\n"); - write_remoting_arguments(client, indent, func, PASS_OUT, PHASE_UNMARSHAL); + write_remoting_arguments(client, indent, func, "", PASS_OUT, PHASE_UNMARSHAL); /* unmarshal return value */ if (!is_void(get_func_return_type(func))) @@ -256,7 +290,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal"); else if (is_ptr(get_func_return_type(func)) || is_array(get_func_return_type(func))) print_client("%s = 0;\n", "_RetVal"); - write_remoting_arguments(client, indent, func, PASS_RETURN, PHASE_UNMARSHAL); + write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL); } /* update proc_offset */ @@ -275,26 +309,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("RpcFinally\n"); print_client("{\n"); indent++; - - - /* FIXME: emit client finally code */ - - if (has_full_pointer) - write_full_pointer_free(client, indent, func); - - print_client("NdrFreeBuffer((PMIDL_STUB_MESSAGE)&_StubMsg);\n"); - - if (!implicit_handle && explicit_generic_handle_var) - { - fprintf(client, "\n"); - print_client("if (_Handle)\n"); - indent++; - print_client("%s_unbind(%s, _Handle);\n", - get_explicit_generic_handle_type(explicit_generic_handle_var)->name, - explicit_generic_handle_var->name); - indent--; - } - + print_client( "__finally_%s%s( __frame );\n", prefix_client, get_name(def) ); indent--; print_client("}\n"); print_client("RpcEndFinally\n"); @@ -400,10 +415,10 @@ static void write_clientinterfacedecl(type_t *iface) indent--; print_client("};\n"); if (old_names) - print_client("RPC_IF_HANDLE %s_ClientIfHandle = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n", + print_client("RPC_IF_HANDLE %s_ClientIfHandle DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n", iface->name, iface->name); else - print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n", + print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n", prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name); fprintf(client, "\n"); } @@ -434,9 +449,16 @@ static void init_client(void) print_client("#endif\n"); fprintf(client, "\n"); print_client("#include \"%s\"\n", header_name); - fprintf(client, "\n"); + print_client( "\n"); + print_client( "#ifndef DECLSPEC_HIDDEN\n"); + print_client( "#define DECLSPEC_HIDDEN\n"); + print_client( "#endif\n"); + print_client( "\n"); + write_exceptions( client ); + print_client( "\n"); } + static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_routines, unsigned int *proc_offset) { const statement_t *stmt; @@ -461,7 +483,7 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou write_stubdescdecl(iface); write_function_stubs(iface, proc_offset); - print_client("#if !defined(__RPC_WIN32__)\n"); + print_client("#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32); print_client("#error Invalid build platform for this stub.\n"); print_client("#endif\n"); @@ -474,20 +496,11 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou } } -void write_client(const statement_list_t *stmts) +static void write_client_routines(const statement_list_t *stmts) { unsigned int proc_offset = 0; int expr_eval_routines; - if (!do_client) - return; - if (do_everything && !need_stub_files(stmts)) - return; - - init_client(); - if (!client) - return; - write_formatstringsdecl(client, indent, stmts, need_stub); expr_eval_routines = write_expr_eval_routines(client, client_token); if (expr_eval_routines) @@ -500,6 +513,39 @@ void write_client(const statement_list_t *stmts) write_procformatstring(client, stmts, need_stub); write_typeformatstring(client, stmts, need_stub); +} + +void write_client(const statement_list_t *stmts) +{ + if (!do_client) + return; + if (do_everything && !need_stub_files(stmts)) + return; + + init_client(); + if (!client) + return; + + if (do_win32 && do_win64) + { + fprintf(client, "\n#ifndef _WIN64\n\n"); + pointer_size = 4; + write_client_routines( stmts ); + fprintf(client, "\n#else /* _WIN64 */\n\n"); + pointer_size = 8; + write_client_routines( stmts ); + fprintf(client, "\n#endif /* _WIN64 */\n"); + } + else if (do_win32) + { + pointer_size = 4; + write_client_routines( stmts ); + } + else if (do_win64) + { + pointer_size = 8; + write_client_routines( stmts ); + } fclose(client); } diff --git a/reactos/tools/widl/expr.c b/reactos/tools/widl/expr.c index 1adf82fbaf7..efe1769e7b1 100644 --- a/reactos/tools/widl/expr.c +++ b/reactos/tools/widl/expr.c @@ -32,6 +32,7 @@ #include "utils.h" #include "expr.h" #include "header.h" +#include "typetree.h" expr_t *make_expr(enum expr_type type) { @@ -362,17 +363,14 @@ static type_t *find_identifier(const char *identifier, const type_t *cont_type, *found_in_cont_type = 0; - if (cont_type && (cont_type->type == RPC_FC_FUNCTION || is_struct(cont_type->type))) - fields = cont_type->fields_or_args; - else if (cont_type && is_union(cont_type->type)) + if (cont_type) { - if (cont_type->type == RPC_FC_ENCAPSULATED_UNION) - { - const var_t *uv = LIST_ENTRY(list_tail(cont_type->fields_or_args), const var_t, entry); - fields = uv->type->fields_or_args; - } - else - fields = cont_type->fields_or_args; + if (cont_type->type == RPC_FC_FUNCTION) + fields = type_function_get_args(cont_type); + else if (is_struct(cont_type->type)) + fields = type_struct_get_fields(cont_type); + else if (is_union(cont_type->type)) + fields = type_union_get_cases(cont_type); } if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) @@ -576,7 +574,7 @@ const type_t *expr_resolve_type(const struct expr_loc *expr_loc, const type_t *c void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix, - const type_t *cont_type) + const type_t *cont_type, const char *local_var_prefix) { switch (e->type) { @@ -602,9 +600,13 @@ void write_expr(FILE *h, const expr_t *e, int brackets, { int found_in_cont_type; find_identifier(e->u.sval, cont_type, &found_in_cont_type); - if (found_in_cont_type) fprintf(h, "%s", toplevel_prefix); + if (found_in_cont_type) + { + fprintf(h, "%s%s", toplevel_prefix, e->u.sval); + break; + } } - fprintf(h, "%s", e->u.sval); + fprintf(h, "%s%s", local_var_prefix, e->u.sval); break; case EXPR_STRLIT: fprintf(h, "\"%s\"", e->u.sval); @@ -614,33 +616,33 @@ void write_expr(FILE *h, const expr_t *e, int brackets, break; case EXPR_LOGNOT: fprintf(h, "!"); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_NOT: fprintf(h, "~"); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_POS: fprintf(h, "+"); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_NEG: fprintf(h, "-"); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_ADDRESSOF: fprintf(h, "&"); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_PPTR: fprintf(h, "*"); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_CAST: fprintf(h, "("); write_type_decl(h, e->u.tref, NULL); fprintf(h, ")"); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_SIZEOF: fprintf(h, "sizeof("); @@ -666,7 +668,7 @@ void write_expr(FILE *h, const expr_t *e, int brackets, case EXPR_GTREQL: case EXPR_LESSEQL: if (brackets) fprintf(h, "("); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); switch (e->type) { case EXPR_SHL: fprintf(h, " << "); break; @@ -689,38 +691,38 @@ void write_expr(FILE *h, const expr_t *e, int brackets, case EXPR_LESSEQL: fprintf(h, " <= "); break; default: break; } - write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); if (brackets) fprintf(h, ")"); break; case EXPR_MEMBER: if (brackets) fprintf(h, "("); if (e->ref->type == EXPR_PPTR) { - write_expr(h, e->ref->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); fprintf(h, "->"); } else { - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); fprintf(h, "."); } - write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->u.ext, 1, 0, toplevel_prefix, cont_type, ""); if (brackets) fprintf(h, ")"); break; case EXPR_COND: if (brackets) fprintf(h, "("); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); fprintf(h, " ? "); - write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); fprintf(h, " : "); - write_expr(h, e->ext2, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ext2, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); if (brackets) fprintf(h, ")"); break; case EXPR_ARRAY: if (brackets) fprintf(h, "("); - write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); fprintf(h, "["); - write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type); + write_expr(h, e->u.ext, 1, 1, toplevel_prefix, cont_type, local_var_prefix); fprintf(h, "]"); if (brackets) fprintf(h, ")"); break; diff --git a/reactos/tools/widl/expr.h b/reactos/tools/widl/expr.h index 1b773e0a33d..31ce31d3e9e 100644 --- a/reactos/tools/widl/expr.h +++ b/reactos/tools/widl/expr.h @@ -37,4 +37,5 @@ extern expr_t *make_expr3(enum expr_type type, expr_t *expr1, expr_t *expr2, exp extern const type_t *expr_resolve_type(const struct expr_loc *expr_loc, const type_t *cont_type, const expr_t *expr); extern int compare_expr(const expr_t *a, const expr_t *b); -extern void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix, const type_t *cont_type); +extern void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix, + const type_t *cont_type, const char *local_var_prefix); diff --git a/reactos/tools/widl/header.c b/reactos/tools/widl/header.c index 5d1b1a6b8d8..b7df77bb171 100644 --- a/reactos/tools/widl/header.c +++ b/reactos/tools/widl/header.c @@ -34,6 +34,7 @@ #include "parser.h" #include "header.h" #include "expr.h" +#include "typetree.h" typedef struct _user_type_t generic_handle_t; @@ -174,7 +175,7 @@ static void write_enums(FILE *h, var_list_t *enums) fprintf(h, "%s", get_name(v)); if (v->eval) { fprintf(h, " = "); - write_expr(h, v->eval, 0, 1, NULL, NULL); + write_expr(h, v->eval, 0, 1, NULL, NULL, ""); } } if (list_next( enums, &v->entry )) fprintf(h, ",\n"); @@ -204,12 +205,12 @@ void write_type_left(FILE *h, type_t *t, int declonly) switch (t->type) { case RPC_FC_ENUM16: case RPC_FC_ENUM32: - if (!declonly && t->defined && !t->written && !t->ignore) { + if (!declonly && t->defined && !t->written) { if (t->name) fprintf(h, "enum %s {\n", t->name); else fprintf(h, "enum {\n"); t->written = TRUE; indentation++; - write_enums(h, t->fields_or_args); + write_enums(h, type_enum_get_values(t)); indent(h, -1); fprintf(h, "}"); } @@ -222,24 +223,27 @@ void write_type_left(FILE *h, type_t *t, int declonly) case RPC_FC_PSTRUCT: case RPC_FC_BOGUS_STRUCT: case RPC_FC_ENCAPSULATED_UNION: - if (!declonly && t->defined && !t->written && !t->ignore) { + if (!declonly && t->defined && !t->written) { if (t->name) fprintf(h, "struct %s {\n", t->name); else fprintf(h, "struct {\n"); t->written = TRUE; indentation++; - write_fields(h, t->fields_or_args); + if (t->type == RPC_FC_ENCAPSULATED_UNION) + write_fields(h, type_encapsulated_union_get_fields(t)); + else + write_fields(h, type_struct_get_fields(t)); indent(h, -1); fprintf(h, "}"); } else fprintf(h, "struct %s", t->name ? t->name : ""); break; case RPC_FC_NON_ENCAPSULATED_UNION: - if (!declonly && t->defined && !t->written && !t->ignore) { + if (!declonly && t->defined && !t->written) { if (t->name) fprintf(h, "union %s {\n", t->name); else fprintf(h, "union {\n"); t->written = TRUE; indentation++; - write_fields(h, t->fields_or_args); + write_fields(h, type_union_get_cases(t)); indent(h, -1); fprintf(h, "}"); } @@ -308,7 +312,7 @@ void write_type_v(FILE *h, type_t *t, int is_field, int declonly, if (pt->type == RPC_FC_FUNCTION) { if (ptr_level) fputc(')', h); fputc('(', h); - write_args(h, pt->fields_or_args, NULL, 0, FALSE); + write_args(h, type_function_get_args(pt), NULL, 0, FALSE); fputc(')', h); } else write_type_right(h, t, is_field); @@ -407,15 +411,22 @@ void check_for_additional_prototype_types(const var_list_t *list) * using a wire marshaled type */ break; } - else + else if (type_is_complete(type)) { - check_for_additional_prototype_types(type->fields_or_args); + var_list_t *vars = NULL; + if (type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32) + vars = type_enum_get_values(type); + else if (is_struct(type->type)) + vars = type_struct_get_fields(type); + else if (is_union(type->type)) + vars = type_union_get_cases(type); + check_for_additional_prototype_types(vars); } } } } -void write_user_types(void) +static void write_user_types(FILE *header) { user_type_t *ut; LIST_FOR_EACH_ENTRY(ut, &user_type_list, user_type_t, entry) @@ -428,7 +439,7 @@ void write_user_types(void) } } -void write_context_handle_rundowns(void) +static void write_context_handle_rundowns(FILE *header) { context_handle_t *ch; LIST_FOR_EACH_ENTRY(ch, &context_handle_list, context_handle_t, entry) @@ -438,7 +449,7 @@ void write_context_handle_rundowns(void) } } -void write_generic_handle_routines(void) +static void write_generic_handle_routines(FILE *header) { generic_handle_t *gh; LIST_FOR_EACH_ENTRY(gh, &generic_handle_list, generic_handle_t, entry) @@ -449,7 +460,7 @@ void write_generic_handle_routines(void) } } -void write_typedef(type_t *type) +static void write_typedef(FILE *header, type_t *type) { fprintf(header, "typedef "); write_type_def_or_decl(header, type->orig, FALSE, "%s", type->name); @@ -474,15 +485,15 @@ int is_const_decl(const var_t *var) return FALSE; } -void write_declaration(const var_t *v, int is_in_interface) +static void write_declaration(FILE *header, const var_t *v) { if (is_const_decl(v) && v->eval) { fprintf(header, "#define %s (", v->name); - write_expr(header, v->eval, 0, 1, NULL, NULL); + write_expr(header, v->eval, 0, 1, NULL, NULL, ""); fprintf(header, ")\n\n"); } - else if (v->type->type != RPC_FC_FUNCTION || !is_in_interface) + else { switch (v->stgclass) { @@ -501,7 +512,7 @@ void write_declaration(const var_t *v, int is_in_interface) } } -void write_library(const typelib_t *typelib) +static void write_library(FILE *header, const typelib_t *typelib) { const UUID *uuid = get_attrp(typelib->attrs, ATTR_UUID); fprintf(header, "\n"); @@ -526,18 +537,10 @@ const var_t* get_explicit_handle_var(const func_t* func) const type_t* get_explicit_generic_handle_type(const var_t* var) { - const type_t *t = var->type; - - if (t->type == RPC_FC_BIND_PRIMITIVE) - return NULL; - - if (!is_ptr(t) && is_attr(t->attrs, ATTR_HANDLE)) - return t; - else - for (; is_ptr(t); t = t->ref) - if (t->type != RPC_FC_BIND_PRIMITIVE && is_attr(t->attrs, ATTR_HANDLE)) - return t; - + const type_t *t; + for (t = var->type; is_ptr(t); t = t->ref) + if (t->type != RPC_FC_BIND_PRIMITIVE && is_attr(t->attrs, ATTR_HANDLE)) + return t; return NULL; } @@ -751,7 +754,7 @@ static void write_method_proto(FILE *header, const type_t *iface) } } -void write_locals(FILE *fp, const type_t *iface, int body) +static void write_locals(FILE *fp, const type_t *iface, int body) { static const char comment[] = "/* WIDL-generated stub. You must provide an implementation for this. */"; @@ -811,55 +814,60 @@ void write_locals(FILE *fp, const type_t *iface, int body) } } -static void write_function_proto(FILE *header, const type_t *iface, const func_t *fun, const char *prefix) +static void write_local_stubs_stmts(FILE *local_stubs, const statement_list_t *stmts) { - var_t *def = fun->def; - const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV); + const statement_t *stmt; + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) + write_locals(local_stubs, stmt->u.type, TRUE); + else if (stmt->type == STMT_LIBRARY) + write_local_stubs_stmts(local_stubs, stmt->u.lib->stmts); + } +} + +void write_local_stubs(const statement_list_t *stmts) +{ + FILE *local_stubs; + + if (!local_stubs_name) return; + + local_stubs = fopen(local_stubs_name, "w"); + if (!local_stubs) { + error("Could not open %s for output\n", local_stubs_name); + return; + } + fprintf(local_stubs, "/* call_as/local stubs for %s */\n\n", input_name); + fprintf(local_stubs, "#include \n"); + fprintf(local_stubs, "#include \"%s\"\n\n", header_name); + + write_local_stubs_stmts(local_stubs, stmts); + + fclose(local_stubs); +} + +static void write_function_proto(FILE *header, const type_t *iface, const var_t *fun, const char *prefix) +{ + const char *callconv = get_attrp(fun->type->attrs, ATTR_CALLCONV); /* FIXME: do we need to handle call_as? */ - write_type_decl_left(header, get_func_return_type(fun)); + write_type_decl_left(header, fun->type->ref); fprintf(header, " "); if (callconv) fprintf(header, "%s ", callconv); - fprintf(header, "%s%s(\n", prefix, get_name(def)); - if (fun->args) - write_args(header, fun->args, iface->name, 0, TRUE); + fprintf(header, "%s%s(\n", prefix, get_name(fun)); + if (fun->type->details.function->args) + write_args(header, fun->type->details.function->args, iface->name, 0, TRUE); else fprintf(header, " void"); fprintf(header, ");\n\n"); } -static void write_function_protos(FILE *header, const type_t *iface) +static void write_forward(FILE *header, type_t *iface) { - const func_t *cur; - int prefixes_differ = strcmp(prefix_client, prefix_server); - - if (!iface->funcs) return; - LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) - { - if (prefixes_differ) { - fprintf(header, "/* client prototype */\n"); - write_function_proto(header, iface, cur, prefix_client); - fprintf(header, "/* server prototype */\n"); - } - write_function_proto(header, iface, cur, prefix_server); - } -} - -void write_forward(type_t *iface) -{ - /* C/C++ forwards should only be written for object interfaces, so if we - * have a full definition we only write one if we find [object] among the - * attributes - however, if we don't have a full definition at this point - * (i.e. this is an IDL forward), then we also assume that it is an object - * interface, since non-object interfaces shouldn't need forwards */ - if ((!iface->defined || is_object(iface->attrs) || is_attr(iface->attrs, ATTR_DISPINTERFACE)) - && !iface->written) { - fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", iface->name); - fprintf(header, "#define __%s_FWD_DEFINED__\n", iface->name); - fprintf(header, "typedef interface %s %s;\n", iface->name, iface->name); - fprintf(header, "#endif\n\n" ); - iface->written = TRUE; - } + fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", iface->name); + fprintf(header, "#define __%s_FWD_DEFINED__\n", iface->name); + fprintf(header, "typedef interface %s %s;\n", iface->name, iface->name); + fprintf(header, "#endif\n\n" ); } static void write_iface_guid(FILE *header, const type_t *iface) @@ -996,22 +1004,7 @@ static void write_rpc_interface_end(FILE *header, const type_t *iface) fprintf(header,"\n#endif /* __%s_INTERFACE_DEFINED__ */\n\n", iface->name); } -void write_interface(type_t *iface) -{ - if (is_attr(iface->attrs, ATTR_DISPINTERFACE) || is_object(iface->attrs)) - { - write_com_interface_start(header, iface); - write_com_interface_end(header, iface); - } - else - { - write_rpc_interface_start(header, iface); - write_function_protos(header, iface); - write_rpc_interface_end(header, iface); - } -} - -void write_coclass(type_t *cocl) +static void write_coclass(FILE *header, type_t *cocl) { fprintf(header, "/*****************************************************************************\n"); fprintf(header, " * %s coclass\n", cocl->name); @@ -1020,7 +1013,7 @@ void write_coclass(type_t *cocl) fprintf(header, "\n"); } -void write_coclass_forward(type_t *cocl) +static void write_coclass_forward(FILE *header, type_t *cocl) { fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", cocl->name); fprintf(header, "#define __%s_FWD_DEFINED__\n", cocl->name); @@ -1028,7 +1021,7 @@ void write_coclass_forward(type_t *cocl) fprintf(header, "#endif /* defined __%s_FWD_DEFINED__ */\n\n", cocl->name ); } -void write_import(const char *fname) +static void write_import(FILE *header, const char *fname) { char *hname, *p; @@ -1039,3 +1032,194 @@ void write_import(const char *fname) fprintf(header, "#include <%s>\n", hname); free(hname); } + +static void write_imports(FILE *header, const statement_list_t *stmts) +{ + const statement_t *stmt; + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + switch (stmt->type) + { + case STMT_TYPE: + if (stmt->u.type->type == RPC_FC_IP) + write_imports(header, stmt->u.type->stmts); + break; + case STMT_TYPEREF: + case STMT_IMPORTLIB: + /* not included in header */ + break; + case STMT_IMPORT: + write_import(header, stmt->u.str); + break; + case STMT_TYPEDEF: + case STMT_MODULE: + case STMT_CPPQUOTE: + case STMT_DECLARATION: + /* not processed here */ + break; + case STMT_LIBRARY: + write_imports(header, stmt->u.lib->stmts); + break; + } + } +} + +static void write_forward_decls(FILE *header, const statement_list_t *stmts) +{ + const statement_t *stmt; + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + switch (stmt->type) + { + case STMT_TYPE: + if (stmt->u.type->type == RPC_FC_IP) + { + if (is_object(stmt->u.type->attrs) || is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE)) + write_forward(header, stmt->u.type); + } + else if (stmt->u.type->type == RPC_FC_COCLASS) + write_coclass_forward(header, stmt->u.type); + break; + case STMT_TYPEREF: + case STMT_IMPORTLIB: + /* not included in header */ + break; + case STMT_IMPORT: + case STMT_TYPEDEF: + case STMT_MODULE: + case STMT_CPPQUOTE: + case STMT_DECLARATION: + /* not processed here */ + break; + case STMT_LIBRARY: + write_forward_decls(header, stmt->u.lib->stmts); + break; + } + } +} + +static void write_header_stmts(FILE *header, const statement_list_t *stmts, const type_t *iface, int ignore_funcs) +{ + const statement_t *stmt; + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + switch (stmt->type) + { + case STMT_TYPE: + if (stmt->u.type->type == RPC_FC_IP) + { + type_t *iface = stmt->u.type; + if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type->attrs)) + { + write_com_interface_start(header, iface); + write_header_stmts(header, iface->stmts, stmt->u.type, TRUE); + write_com_interface_end(header, iface); + } + else + { + write_rpc_interface_start(header, iface); + write_header_stmts(header, iface->stmts, iface, FALSE); + write_rpc_interface_end(header, iface); + } + } + else if (stmt->u.type->type == RPC_FC_COCLASS) + write_coclass(header, stmt->u.type); + else + { + write_type_def_or_decl(header, stmt->u.type, FALSE, NULL); + fprintf(header, ";\n\n"); + } + break; + case STMT_TYPEREF: + /* FIXME: shouldn't write out forward declarations for undefined + * interfaces but a number of our IDL files depend on this */ + if (stmt->u.type->type == RPC_FC_IP && !stmt->u.type->written) + write_forward(header, stmt->u.type); + break; + case STMT_IMPORTLIB: + case STMT_MODULE: + /* not included in header */ + break; + case STMT_IMPORT: + /* not processed here */ + break; + case STMT_TYPEDEF: + { + const type_list_t *type_entry = stmt->u.type_list; + for (; type_entry; type_entry = type_entry->next) + write_typedef(header, type_entry->type); + break; + } + case STMT_LIBRARY: + write_library(header, stmt->u.lib); + write_header_stmts(header, stmt->u.lib->stmts, NULL, FALSE); + break; + case STMT_CPPQUOTE: + fprintf(header, "%s\n", stmt->u.str); + break; + case STMT_DECLARATION: + if (iface && stmt->u.var->type->type == RPC_FC_FUNCTION) + { + if (!ignore_funcs) + { + int prefixes_differ = strcmp(prefix_client, prefix_server); + + if (prefixes_differ) + { + fprintf(header, "/* client prototype */\n"); + write_function_proto(header, iface, stmt->u.var, prefix_client); + fprintf(header, "/* server prototype */\n"); + } + write_function_proto(header, iface, stmt->u.var, prefix_server); + } + } + else + write_declaration(header, stmt->u.var); + break; + } + } +} + +void write_header(const statement_list_t *stmts) +{ + FILE *header; + + if (!do_header) return; + + if(!(header = fopen(header_name, "w"))) { + error("Could not open %s for output\n", header_name); + return; + } + fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n\n", PACKAGE_VERSION, input_name); + fprintf(header, "#include \n" ); + fprintf(header, "#include \n\n" ); + + fprintf(header, "#ifndef __WIDL_%s\n", header_token); + fprintf(header, "#define __WIDL_%s\n\n", header_token); + start_cplusplus_guard(header); + + fprintf(header, "/* Headers for imported files */\n\n"); + write_imports(header, stmts); + fprintf(header, "\n"); + + /* FIXME: should be before imported file includes */ + fprintf(header, "/* Forward declarations */\n\n"); + write_forward_decls(header, stmts); + fprintf(header, "\n"); + + write_header_stmts(header, stmts, NULL, FALSE); + + fprintf(header, "/* Begin additional prototypes for all interfaces */\n"); + fprintf(header, "\n"); + write_user_types(header); + write_generic_handle_routines(header); + write_context_handle_rundowns(header); + fprintf(header, "\n"); + fprintf(header, "/* End additional prototypes */\n"); + fprintf(header, "\n"); + + end_cplusplus_guard(header); + fprintf(header, "#endif /* __WIDL_%s */\n", header_token); + + fclose(header); +} diff --git a/reactos/tools/widl/header.h b/reactos/tools/widl/header.h index 777beeeae5e..23561ce37e6 100644 --- a/reactos/tools/widl/header.h +++ b/reactos/tools/widl/header.h @@ -47,18 +47,6 @@ extern int need_proxy_file(const statement_list_t *stmts); extern const var_t *is_callas(const attr_list_t *list); extern void write_args(FILE *h, const var_list_t *arg, const char *name, int obj, int do_indent); extern void write_array(FILE *h, array_dims_t *v, int field); -extern void write_import(const char *fname); -extern void write_forward(type_t *iface); -extern void write_interface(type_t *iface); -extern void write_locals(FILE *fp, const type_t *iface, int body); -extern void write_coclass(type_t *cocl); -extern void write_coclass_forward(type_t *cocl); -extern void write_typedef(type_t *type); -extern void write_declaration(const var_t *v, int is_in_interface); -extern void write_library(const typelib_t *typelib); -extern void write_user_types(void); -extern void write_context_handle_rundowns(void); -extern void write_generic_handle_routines(void); extern const var_t* get_explicit_handle_var(const func_t* func); extern const type_t* get_explicit_generic_handle_type(const var_t* var); extern const var_t* get_explicit_generic_handle_var(const func_t* func); @@ -86,19 +74,11 @@ static inline int is_string_type(const attr_list_t *attrs, const type_t *type) static inline int is_context_handle(const type_t *type) { - if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) - return 1; - - for (;;) - { - if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) + const type_t *t; + for (t = type; is_ptr(t); t = t->ref) + if (is_attr(t->attrs, ATTR_CONTEXTHANDLE)) return 1; - else if (type->kind == TKIND_ALIAS) - type = type->orig; - else if (is_ptr(type)) - type = type->ref; - else return 0; - } + return 0; } #endif diff --git a/reactos/tools/widl/parser.h b/reactos/tools/widl/parser.h index 71f08dc994a..85171f74b9f 100644 --- a/reactos/tools/widl/parser.h +++ b/reactos/tools/widl/parser.h @@ -45,4 +45,7 @@ void pop_import(void); int is_type(const char *name); +void check_functions(const type_t *iface); +func_list_t *gen_function_list(const statement_list_t *stmts); + #endif diff --git a/reactos/tools/widl/parser.l b/reactos/tools/widl/parser.l index 1953a270da9..dba27ea7387 100644 --- a/reactos/tools/widl/parser.l +++ b/reactos/tools/widl/parser.l @@ -47,6 +47,8 @@ double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)* #include #include #include +#include +#include #ifdef HAVE_UNISTD_H #include @@ -82,6 +84,19 @@ struct { } import_stack[MAX_IMPORT_DEPTH]; int import_stack_ptr = 0; +/* converts an integer in string form to an unsigned long and prints an error + * on overflow */ +static unsigned long xstrtoul(const char *nptr, char **endptr, int base) +{ + unsigned long l; + + errno = 0; + l = strtoul(nptr, endptr, base); + if (l == ULONG_MAX && errno == ERANGE) + error_loc("integer constant %s is too large\n", nptr); + return l; +} + UUID *parse_uuid(const char *u) { UUID* uuid = xmalloc(sizeof(UUID)); @@ -154,11 +169,11 @@ UUID *parse_uuid(const char *u) return aUUID; } {hex} { - parser_lval.num = strtoul(yytext, NULL, 0); + parser_lval.num = xstrtoul(yytext, NULL, 0); return aHEXNUM; } {int} { - parser_lval.num = strtoul(yytext, NULL, 0); + parser_lval.num = xstrtoul(yytext, NULL, 0); return aNUM; } {double} { @@ -244,7 +259,7 @@ static const struct keyword keywords[] = { {"short", tSHORT}, {"signed", tSIGNED}, {"sizeof", tSIZEOF}, - {"small", tSMALL}, + {"small", tSMALL}, {"static", tSTATIC}, {"stdcall", tSTDCALL}, {"struct", tSTRUCT}, diff --git a/reactos/tools/widl/parser.tab.c b/reactos/tools/widl/parser.tab.c index 25a3f18895b..3c7bda42afc 100644 --- a/reactos/tools/widl/parser.tab.c +++ b/reactos/tools/widl/parser.tab.c @@ -412,6 +412,7 @@ #include "typelib.h" #include "typegen.h" #include "expr.h" +#include "typetree.h" #if defined(YYBYACC) /* Berkeley yacc (byacc) doesn't seem to know about these */ @@ -441,7 +442,6 @@ #define YYERROR_VERBOSE unsigned char pointer_default = RPC_FC_UP; -static int is_in_interface = FALSE; static int is_object_interface = FALSE; /* are we inside a library block? */ static int is_inside_library = FALSE; @@ -469,6 +469,7 @@ typelist_t incomplete_types = LIST_INIT(incomplete_types); static void add_incomplete(type_t *t); static void fix_incomplete(void); +static void fix_incomplete_types(type_t *complete_type); static str_list_t *append_str(str_list_t *list, char *str); static attr_list_t *append_attr(attr_list_t *list, attr_t *attr); @@ -495,34 +496,30 @@ static type_t *make_safearray(type_t *type); static type_t *make_builtin(char *name); static type_t *make_int(int sign); static typelib_t *make_library(const char *name, const attr_list_t *attrs); -static type_t *make_func_type(var_list_t *args); -static type_t *make_pointer_type(type_t *ref, attr_list_t *attrs); static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type); +static type_t *type_new_enum(char *name, var_list_t *enums); +static type_t *type_new_struct(char *name, int defined, var_list_t *fields); +static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields); +static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases); + static type_t *reg_type(type_t *type, const char *name, int t); static type_t *reg_typedefs(decl_spec_t *decl_spec, var_list_t *names, attr_list_t *attrs); static type_t *find_type_or_error(const char *name, int t); static type_t *find_type_or_error2(char *name, int t); static type_t *get_type(unsigned char type, char *name, int t); -static type_t *get_typev(unsigned char type, var_t *name, int t); -static int get_struct_type(var_list_t *fields); static var_t *reg_const(var_t *var); -static void write_libid(const typelib_t *typelib); -static void write_clsid(type_t *cls); -static void write_diid(type_t *iface); -static void write_iid(type_t *iface); - -static int compute_method_indexes(type_t *iface); static char *gen_name(void); -static statement_t *process_typedefs(var_list_t *names); static void check_arg(var_t *arg); -static void check_functions(const type_t *iface); static void check_all_user_types(const statement_list_t *stmts); static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_typedef_attrs(attr_list_t *attrs); +static attr_list_t *check_enum_attrs(attr_list_t *attrs); +static attr_list_t *check_struct_attrs(attr_list_t *attrs); +static attr_list_t *check_union_attrs(attr_list_t *attrs); static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_library_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs); @@ -540,9 +537,10 @@ static statement_t *make_statement_library(typelib_t *typelib); static statement_t *make_statement_cppquote(const char *str); static statement_t *make_statement_importlib(const char *str); static statement_t *make_statement_module(type_t *type); +static statement_t *make_statement_typedef(var_list_t *names); static statement_t *make_statement_import(const char *str); +static statement_t *make_statement_typedef(var_list_t *names); static statement_list_t *append_statement(statement_list_t *list, statement_t *stmt); -static func_list_t *append_func_from_statement(func_list_t *list, statement_t *stmt); #define tsENUM 1 #define tsSTRUCT 2 @@ -569,7 +567,7 @@ static func_list_t *append_func_from_statement(func_list_t *list, statement_t *s #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 179 "parser.y" +#line 177 "parser.y" typedef union YYSTYPE { attr_t *attr; attr_list_t *attr_list; @@ -599,7 +597,7 @@ typedef union YYSTYPE { enum storage_class stgclass; } YYSTYPE; /* Line 196 of yacc.c. */ -#line 603 "parser.tab.c" +#line 601 "parser.tab.c" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -611,7 +609,7 @@ typedef union YYSTYPE { /* Line 219 of yacc.c. */ -#line 615 "parser.tab.c" +#line 613 "parser.tab.c" #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ @@ -762,16 +760,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 2092 +#define YYLAST 2034 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 176 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 88 /* YYNRULES -- Number of rules. */ -#define YYNRULES 309 +#define YYNRULES 312 /* YYNRULES -- Number of states. */ -#define YYNSTATES 545 +#define YYNSTATES 548 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -834,34 +832,35 @@ static const unsigned short int yyprhs[] = 0, 0, 3, 5, 6, 9, 12, 16, 19, 22, 25, 28, 29, 32, 35, 39, 42, 45, 48, 51, 54, 55, 58, 59, 61, 63, 66, 69, 71, 74, - 76, 78, 80, 85, 89, 93, 99, 102, 106, 111, - 112, 114, 116, 118, 122, 124, 128, 131, 135, 139, - 140, 142, 146, 148, 152, 157, 159, 163, 164, 166, - 168, 170, 172, 174, 176, 181, 186, 188, 190, 192, - 194, 196, 198, 203, 205, 207, 212, 214, 219, 224, - 226, 228, 233, 238, 243, 248, 253, 255, 260, 262, - 267, 269, 275, 277, 279, 284, 289, 291, 293, 295, - 297, 299, 301, 303, 305, 307, 312, 314, 316, 318, - 320, 327, 329, 331, 333, 335, 340, 342, 344, 346, - 351, 356, 361, 366, 368, 370, 375, 380, 382, 384, - 386, 388, 390, 392, 394, 395, 398, 403, 407, 408, - 411, 413, 415, 419, 423, 425, 431, 433, 437, 438, - 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, - 464, 468, 472, 476, 480, 484, 488, 492, 496, 500, - 504, 508, 512, 516, 520, 524, 528, 532, 536, 539, - 542, 545, 548, 551, 554, 558, 562, 567, 572, 577, - 581, 583, 587, 589, 591, 592, 595, 600, 604, 607, - 610, 611, 614, 617, 619, 623, 627, 631, 634, 635, - 637, 638, 640, 642, 644, 646, 648, 650, 652, 655, - 658, 660, 662, 664, 666, 668, 670, 672, 673, 675, - 677, 680, 682, 685, 688, 690, 692, 695, 698, 701, - 707, 708, 711, 714, 717, 720, 723, 726, 730, 733, - 737, 743, 749, 750, 753, 756, 759, 762, 769, 778, - 781, 784, 787, 790, 793, 796, 802, 804, 806, 808, - 810, 812, 813, 816, 819, 823, 824, 826, 829, 832, - 835, 839, 842, 844, 846, 850, 853, 858, 860, 864, - 866, 870, 872, 874, 876, 882, 884, 886, 888, 890, - 893, 895, 898, 900, 903, 908, 913, 919, 930, 932 + 76, 78, 80, 83, 86, 89, 94, 98, 102, 108, + 111, 115, 120, 121, 123, 125, 127, 131, 133, 137, + 140, 144, 148, 149, 151, 155, 157, 161, 166, 168, + 172, 173, 175, 177, 179, 181, 183, 185, 190, 195, + 197, 199, 201, 203, 205, 207, 212, 214, 216, 221, + 223, 228, 233, 235, 237, 242, 247, 252, 257, 262, + 264, 269, 271, 276, 278, 284, 286, 288, 293, 298, + 300, 302, 304, 306, 308, 310, 312, 314, 316, 321, + 323, 325, 327, 329, 336, 338, 340, 342, 344, 349, + 351, 353, 355, 360, 365, 370, 375, 377, 379, 384, + 389, 391, 393, 395, 397, 399, 401, 403, 404, 407, + 412, 416, 417, 420, 422, 424, 428, 432, 434, 440, + 442, 446, 447, 449, 451, 453, 455, 457, 459, 461, + 463, 465, 467, 473, 477, 481, 485, 489, 493, 497, + 501, 505, 509, 513, 517, 521, 525, 529, 533, 537, + 541, 545, 548, 551, 554, 557, 560, 563, 567, 571, + 576, 581, 586, 590, 592, 596, 598, 600, 601, 604, + 609, 613, 616, 619, 620, 623, 626, 628, 632, 636, + 640, 643, 644, 646, 647, 649, 651, 653, 655, 657, + 659, 661, 664, 667, 669, 671, 673, 675, 677, 679, + 681, 682, 684, 686, 689, 691, 694, 697, 699, 701, + 704, 707, 710, 716, 717, 720, 723, 726, 729, 732, + 735, 739, 742, 746, 752, 758, 759, 762, 765, 768, + 771, 778, 787, 790, 793, 796, 799, 802, 805, 811, + 813, 815, 817, 819, 821, 822, 825, 828, 832, 833, + 835, 838, 841, 844, 848, 851, 853, 855, 859, 862, + 867, 869, 873, 875, 879, 881, 883, 885, 891, 893, + 895, 897, 899, 902, 904, 907, 909, 912, 917, 922, + 928, 939, 941 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -875,128 +874,130 @@ static const short int yyrhs[] = -1, 179, 190, -1, -1, 180, 182, -1, -1, 170, -1, 184, -1, 183, 170, -1, 222, 170, -1, 186, -1, 261, 170, -1, 208, -1, 259, -1, 262, -1, - 45, 171, 8, 172, -1, 78, 8, 170, -1, 185, - 179, 11, -1, 79, 171, 8, 172, 181, -1, 89, - 3, -1, 197, 188, 173, -1, 189, 179, 174, 181, - -1, -1, 193, -1, 144, -1, 194, -1, 193, 147, - 194, -1, 192, -1, 197, 251, 254, -1, 251, 254, - -1, 168, 210, 169, -1, 168, 157, 169, -1, -1, - 197, -1, 168, 198, 169, -1, 200, -1, 198, 147, - 200, -1, 198, 169, 168, 200, -1, 8, -1, 199, - 147, 8, -1, -1, 21, -1, 23, -1, 24, -1, - 26, -1, 27, -1, 29, -1, 32, 171, 225, 172, - -1, 34, 171, 212, 172, -1, 41, -1, 42, -1, - 43, -1, 44, -1, 46, -1, 47, -1, 48, 171, - 214, 172, -1, 49, -1, 50, -1, 52, 171, 8, - 172, -1, 54, -1, 55, 171, 199, 172, -1, 56, - 171, 214, 172, -1, 59, -1, 64, -1, 66, 171, - 213, 172, -1, 67, 171, 8, 172, -1, 68, 171, - 8, 172, -1, 69, 171, 213, 172, -1, 70, 171, - 8, 172, -1, 71, -1, 73, 171, 213, 172, -1, - 74, -1, 75, 171, 211, 172, -1, 76, -1, 77, - 171, 65, 3, 172, -1, 80, -1, 83, -1, 88, - 171, 209, 172, -1, 87, 171, 213, 172, -1, 90, - -1, 94, -1, 95, -1, 96, -1, 98, -1, 99, - -1, 100, -1, 101, -1, 102, -1, 104, 171, 258, - 172, -1, 106, -1, 107, -1, 108, -1, 110, -1, - 111, 171, 213, 147, 213, 172, -1, 112, -1, 115, - -1, 116, -1, 117, -1, 122, 171, 209, 172, -1, - 125, -1, 128, -1, 129, -1, 132, 171, 211, 172, - -1, 133, 171, 260, 172, -1, 134, 171, 260, 172, - -1, 140, 171, 201, 172, -1, 141, -1, 142, -1, - 143, 171, 263, 172, -1, 146, 171, 260, 172, -1, - 258, -1, 10, -1, 8, -1, 35, -1, 62, -1, - 103, -1, 127, -1, -1, 203, 204, -1, 34, 213, - 149, 219, -1, 46, 149, 219, -1, -1, 206, 147, - -1, 206, -1, 207, -1, 206, 147, 207, -1, 225, - 175, 213, -1, 225, -1, 57, 224, 173, 205, 174, - -1, 210, -1, 209, 147, 210, -1, -1, 211, -1, - 5, -1, 6, -1, 7, -1, 61, -1, 97, -1, - 135, -1, 8, -1, 9, -1, 3, -1, 211, 148, - 211, 149, 211, -1, 211, 19, 211, -1, 211, 20, - 211, -1, 211, 150, 211, -1, 211, 151, 211, -1, - 211, 152, 211, -1, 211, 15, 211, -1, 211, 16, - 211, -1, 211, 154, 211, -1, 211, 153, 211, -1, - 211, 17, 211, -1, 211, 18, 211, -1, 211, 12, - 211, -1, 211, 13, 211, -1, 211, 156, 211, -1, - 211, 155, 211, -1, 211, 159, 211, -1, 211, 157, - 211, -1, 211, 158, 211, -1, 160, 211, -1, 161, - 211, -1, 156, 211, -1, 155, 211, -1, 152, 211, - -1, 157, 211, -1, 211, 14, 3, -1, 211, 167, - 3, -1, 171, 260, 172, 211, -1, 123, 171, 260, - 172, -1, 211, 168, 211, 169, -1, 171, 211, 172, - -1, 213, -1, 212, 147, 213, -1, 211, -1, 211, - -1, -1, 215, 216, -1, 196, 251, 256, 170, -1, - 196, 262, 170, -1, 220, 170, -1, 197, 170, -1, - -1, 218, 217, -1, 220, 170, -1, 170, -1, 196, - 251, 254, -1, 196, 251, 254, -1, 197, 251, 257, - -1, 251, 257, -1, -1, 225, -1, -1, 3, -1, - 4, -1, 3, -1, 4, -1, 30, -1, 145, -1, - 228, -1, 120, 228, -1, 139, 228, -1, 139, -1, - 63, -1, 121, -1, 53, -1, 28, -1, 58, -1, - 65, -1, -1, 84, -1, 84, -1, 119, 227, -1, - 124, -1, 91, 227, -1, 72, 227, -1, 85, -1, - 36, -1, 37, 3, -1, 37, 4, -1, 197, 229, - -1, 230, 173, 232, 174, 181, -1, -1, 232, 233, - -1, 196, 243, -1, 51, 3, -1, 51, 4, -1, - 197, 234, -1, 105, 149, -1, 236, 220, 170, -1, - 92, 149, -1, 237, 221, 170, -1, 235, 173, 236, - 237, 174, -1, 235, 173, 240, 170, 174, -1, -1, - 149, 4, -1, 86, 3, -1, 86, 4, -1, 197, - 240, -1, 241, 239, 173, 180, 174, 181, -1, 241, - 149, 3, 173, 186, 180, 174, 181, -1, 238, 181, - -1, 240, 170, -1, 234, 170, -1, 93, 3, -1, - 93, 4, -1, 197, 244, -1, 245, 173, 180, 174, - 181, -1, 60, -1, 126, -1, 114, -1, 82, -1, - 40, -1, -1, 250, 249, -1, 260, 252, -1, 253, - 260, 252, -1, -1, 253, -1, 249, 252, -1, 248, - 252, -1, 247, 252, -1, 157, 250, 254, -1, 202, - 254, -1, 255, -1, 225, -1, 171, 254, 172, -1, - 255, 195, -1, 255, 171, 191, 172, -1, 254, -1, - 256, 147, 254, -1, 254, -1, 254, 175, 214, -1, - 113, -1, 138, -1, 109, -1, 130, 224, 173, 215, - 174, -1, 144, -1, 4, -1, 226, -1, 208, -1, - 57, 3, -1, 259, -1, 130, 3, -1, 262, -1, - 137, 3, -1, 118, 171, 260, 172, -1, 136, 196, - 251, 256, -1, 137, 224, 173, 218, 174, -1, 137, - 224, 131, 171, 220, 172, 223, 173, 203, 174, -1, - 5, -1, 5, 167, 5, -1 + 197, 208, -1, 197, 259, -1, 197, 262, -1, 45, + 171, 8, 172, -1, 78, 8, 170, -1, 185, 179, + 11, -1, 79, 171, 8, 172, 181, -1, 89, 3, + -1, 197, 188, 173, -1, 189, 179, 174, 181, -1, + -1, 193, -1, 144, -1, 194, -1, 193, 147, 194, + -1, 192, -1, 197, 251, 254, -1, 251, 254, -1, + 168, 210, 169, -1, 168, 157, 169, -1, -1, 197, + -1, 168, 198, 169, -1, 200, -1, 198, 147, 200, + -1, 198, 169, 168, 200, -1, 8, -1, 199, 147, + 8, -1, -1, 21, -1, 23, -1, 24, -1, 26, + -1, 27, -1, 29, -1, 32, 171, 225, 172, -1, + 34, 171, 212, 172, -1, 41, -1, 42, -1, 43, + -1, 44, -1, 46, -1, 47, -1, 48, 171, 214, + 172, -1, 49, -1, 50, -1, 52, 171, 8, 172, + -1, 54, -1, 55, 171, 199, 172, -1, 56, 171, + 214, 172, -1, 59, -1, 64, -1, 66, 171, 213, + 172, -1, 67, 171, 8, 172, -1, 68, 171, 8, + 172, -1, 69, 171, 213, 172, -1, 70, 171, 8, + 172, -1, 71, -1, 73, 171, 213, 172, -1, 74, + -1, 75, 171, 211, 172, -1, 76, -1, 77, 171, + 65, 3, 172, -1, 80, -1, 83, -1, 88, 171, + 209, 172, -1, 87, 171, 213, 172, -1, 90, -1, + 94, -1, 95, -1, 96, -1, 98, -1, 99, -1, + 100, -1, 101, -1, 102, -1, 104, 171, 258, 172, + -1, 106, -1, 107, -1, 108, -1, 110, -1, 111, + 171, 213, 147, 213, 172, -1, 112, -1, 115, -1, + 116, -1, 117, -1, 122, 171, 209, 172, -1, 125, + -1, 128, -1, 129, -1, 132, 171, 211, 172, -1, + 133, 171, 260, 172, -1, 134, 171, 260, 172, -1, + 140, 171, 201, 172, -1, 141, -1, 142, -1, 143, + 171, 263, 172, -1, 146, 171, 260, 172, -1, 258, + -1, 10, -1, 8, -1, 35, -1, 62, -1, 103, + -1, 127, -1, -1, 203, 204, -1, 34, 213, 149, + 219, -1, 46, 149, 219, -1, -1, 206, 147, -1, + 206, -1, 207, -1, 206, 147, 207, -1, 225, 175, + 213, -1, 225, -1, 57, 224, 173, 205, 174, -1, + 210, -1, 209, 147, 210, -1, -1, 211, -1, 5, + -1, 6, -1, 7, -1, 61, -1, 97, -1, 135, + -1, 8, -1, 9, -1, 3, -1, 211, 148, 211, + 149, 211, -1, 211, 19, 211, -1, 211, 20, 211, + -1, 211, 150, 211, -1, 211, 151, 211, -1, 211, + 152, 211, -1, 211, 15, 211, -1, 211, 16, 211, + -1, 211, 154, 211, -1, 211, 153, 211, -1, 211, + 17, 211, -1, 211, 18, 211, -1, 211, 12, 211, + -1, 211, 13, 211, -1, 211, 156, 211, -1, 211, + 155, 211, -1, 211, 159, 211, -1, 211, 157, 211, + -1, 211, 158, 211, -1, 160, 211, -1, 161, 211, + -1, 156, 211, -1, 155, 211, -1, 152, 211, -1, + 157, 211, -1, 211, 14, 3, -1, 211, 167, 3, + -1, 171, 260, 172, 211, -1, 123, 171, 260, 172, + -1, 211, 168, 211, 169, -1, 171, 211, 172, -1, + 213, -1, 212, 147, 213, -1, 211, -1, 211, -1, + -1, 215, 216, -1, 196, 251, 256, 170, -1, 196, + 262, 170, -1, 220, 170, -1, 197, 170, -1, -1, + 218, 217, -1, 220, 170, -1, 170, -1, 196, 251, + 254, -1, 196, 251, 254, -1, 197, 251, 257, -1, + 251, 257, -1, -1, 225, -1, -1, 3, -1, 4, + -1, 3, -1, 4, -1, 30, -1, 145, -1, 228, + -1, 120, 228, -1, 139, 228, -1, 139, -1, 63, + -1, 121, -1, 53, -1, 28, -1, 58, -1, 65, + -1, -1, 84, -1, 84, -1, 119, 227, -1, 124, + -1, 91, 227, -1, 72, 227, -1, 85, -1, 36, + -1, 37, 3, -1, 37, 4, -1, 197, 229, -1, + 230, 173, 232, 174, 181, -1, -1, 232, 233, -1, + 196, 243, -1, 51, 3, -1, 51, 4, -1, 197, + 234, -1, 105, 149, -1, 236, 220, 170, -1, 92, + 149, -1, 237, 221, 170, -1, 235, 173, 236, 237, + 174, -1, 235, 173, 240, 170, 174, -1, -1, 149, + 4, -1, 86, 3, -1, 86, 4, -1, 197, 240, + -1, 241, 239, 173, 180, 174, 181, -1, 241, 149, + 3, 173, 186, 180, 174, 181, -1, 238, 181, -1, + 240, 170, -1, 234, 170, -1, 93, 3, -1, 93, + 4, -1, 197, 244, -1, 245, 173, 180, 174, 181, + -1, 60, -1, 126, -1, 114, -1, 82, -1, 40, + -1, -1, 250, 249, -1, 260, 252, -1, 253, 260, + 252, -1, -1, 253, -1, 249, 252, -1, 248, 252, + -1, 247, 252, -1, 157, 250, 254, -1, 202, 254, + -1, 255, -1, 225, -1, 171, 254, 172, -1, 255, + 195, -1, 255, 171, 191, 172, -1, 254, -1, 256, + 147, 254, -1, 254, -1, 254, 175, 214, -1, 113, + -1, 138, -1, 109, -1, 130, 224, 173, 215, 174, + -1, 144, -1, 4, -1, 226, -1, 208, -1, 57, + 3, -1, 259, -1, 130, 3, -1, 262, -1, 137, + 3, -1, 118, 171, 260, 172, -1, 136, 196, 251, + 256, -1, 137, 224, 173, 218, 174, -1, 137, 224, + 131, 171, 220, 172, 223, 173, 203, 174, -1, 5, + -1, 5, 167, 5, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short int yyrline[] = { - 0, 351, 351, 360, 361, 362, 363, 367, 372, 375, - 376, 379, 380, 381, 382, 383, 388, 389, 390, 391, - 394, 395, 398, 399, 403, 404, 410, 413, 414, 418, - 419, 420, 423, 425, 433, 440, 444, 446, 453, 461, - 462, 465, 468, 469, 470, 474, 481, 489, 490, 493, - 494, 498, 504, 505, 506, 509, 510, 513, 514, 515, + 0, 348, 348, 360, 361, 362, 363, 366, 369, 370, + 371, 374, 375, 376, 377, 378, 381, 382, 383, 384, + 387, 388, 391, 392, 396, 397, 398, 399, 400, 404, + 405, 406, 407, 408, 409, 412, 414, 422, 428, 432, + 434, 439, 447, 448, 451, 454, 455, 456, 460, 467, + 475, 476, 479, 480, 484, 487, 488, 489, 492, 493, + 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, + 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, - 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, - 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, - 566, 570, 571, 572, 573, 574, 575, 576, 577, 578, - 579, 580, 581, 582, 583, 584, 585, 586, 590, 591, - 596, 597, 598, 599, 602, 603, 606, 610, 616, 617, - 618, 621, 625, 634, 638, 643, 652, 653, 666, 667, - 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, - 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, - 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, - 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, - 712, 713, 716, 722, 728, 729, 732, 737, 744, 745, - 748, 749, 753, 754, 757, 765, 774, 780, 786, 787, - 790, 791, 792, 795, 797, 800, 801, 802, 803, 804, - 820, 821, 822, 823, 824, 825, 826, 829, 830, 833, - 834, 835, 836, 837, 838, 839, 842, 843, 851, 861, - 868, 869, 873, 876, 877, 880, 894, 895, 898, 899, - 902, 912, 922, 923, 926, 927, 930, 943, 957, 970, - 974, 975, 978, 979, 982, 987, 995, 996, 997, 1001, - 1005, 1008, 1009, 1012, 1013, 1017, 1018, 1022, 1023, 1024, - 1028, 1030, 1031, 1035, 1036, 1037, 1038, 1045, 1046, 1050, - 1051, 1055, 1056, 1057, 1060, 1072, 1073, 1074, 1075, 1076, - 1077, 1078, 1079, 1080, 1081, 1084, 1090, 1097, 1115, 1116 + 546, 547, 548, 549, 553, 554, 555, 556, 557, 558, + 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, + 569, 573, 574, 579, 580, 581, 582, 585, 586, 589, + 593, 599, 600, 601, 604, 608, 617, 621, 626, 629, + 630, 643, 644, 647, 648, 649, 650, 651, 652, 653, + 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, + 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, + 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, + 684, 685, 686, 689, 690, 693, 699, 705, 706, 709, + 714, 721, 722, 725, 726, 730, 731, 734, 742, 751, + 757, 763, 764, 767, 768, 769, 772, 774, 777, 778, + 779, 780, 781, 797, 798, 799, 800, 801, 802, 803, + 806, 807, 810, 811, 812, 813, 814, 815, 816, 819, + 820, 828, 834, 841, 842, 846, 849, 850, 853, 863, + 864, 867, 868, 871, 877, 883, 884, 887, 888, 891, + 902, 909, 915, 919, 920, 923, 924, 927, 932, 940, + 941, 942, 946, 950, 953, 954, 957, 958, 962, 963, + 967, 968, 969, 973, 975, 976, 980, 981, 982, 983, + 990, 991, 995, 996, 1000, 1001, 1002, 1005, 1008, 1009, + 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1020, 1026, + 1028, 1034, 1035 }; #endif @@ -1089,34 +1090,35 @@ static const unsigned short int yyr1[] = 0, 176, 177, 178, 178, 178, 178, 178, 178, 178, 178, 179, 179, 179, 179, 179, 179, 179, 179, 179, 180, 180, 181, 181, 182, 182, 182, 182, 182, 183, - 183, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 191, 192, 193, 193, 193, 194, 194, 195, 195, 196, - 196, 197, 198, 198, 198, 199, 199, 200, 200, 200, + 183, 183, 183, 183, 183, 184, 185, 186, 187, 188, + 189, 190, 191, 191, 192, 193, 193, 193, 194, 194, + 195, 195, 196, 196, 197, 198, 198, 198, 199, 199, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - 200, 200, 200, 200, 200, 200, 200, 200, 201, 201, - 202, 202, 202, 202, 203, 203, 204, 204, 205, 205, - 205, 206, 206, 207, 207, 208, 209, 209, 210, 210, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 201, 201, 202, 202, 202, 202, 203, 203, 204, + 204, 205, 205, 205, 206, 206, 207, 207, 208, 209, + 209, 210, 210, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 212, 212, 213, 214, 215, 215, 216, 216, 217, 217, - 218, 218, 219, 219, 220, 221, 222, 222, 223, 223, - 224, 224, 224, 225, 225, 226, 226, 226, 226, 226, - 226, 226, 226, 226, 226, 226, 226, 227, 227, 228, - 228, 228, 228, 228, 228, 228, 229, 229, 230, 231, - 232, 232, 233, 234, 234, 235, 236, 236, 237, 237, - 238, 238, 239, 239, 240, 240, 241, 242, 242, 242, - 243, 243, 244, 244, 245, 246, 247, 247, 247, 248, - 249, 250, 250, 251, 251, 252, 252, 253, 253, 253, - 254, 254, 254, 255, 255, 255, 255, 256, 256, 257, - 257, 258, 258, 258, 259, 260, 260, 260, 260, 260, - 260, 260, 260, 260, 260, 261, 262, 262, 263, 263 + 211, 211, 211, 212, 212, 213, 214, 215, 215, 216, + 216, 217, 217, 218, 218, 219, 219, 220, 221, 222, + 222, 223, 223, 224, 224, 224, 225, 225, 226, 226, + 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, + 227, 227, 228, 228, 228, 228, 228, 228, 228, 229, + 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, + 236, 237, 237, 238, 238, 239, 239, 240, 240, 241, + 242, 242, 242, 243, 243, 244, 244, 245, 246, 247, + 247, 247, 248, 249, 250, 250, 251, 251, 252, 252, + 253, 253, 253, 254, 254, 254, 255, 255, 255, 255, + 256, 256, 257, 257, 258, 258, 258, 259, 260, 260, + 260, 260, 260, 260, 260, 260, 260, 260, 261, 262, + 262, 263, 263 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1125,34 +1127,35 @@ static const unsigned char yyr2[] = 0, 2, 1, 0, 2, 2, 3, 2, 2, 2, 2, 0, 2, 2, 3, 2, 2, 2, 2, 2, 0, 2, 0, 1, 1, 2, 2, 1, 2, 1, - 1, 1, 4, 3, 3, 5, 2, 3, 4, 0, - 1, 1, 1, 3, 1, 3, 2, 3, 3, 0, - 1, 3, 1, 3, 4, 1, 3, 0, 1, 1, - 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, - 1, 1, 4, 1, 1, 4, 1, 4, 4, 1, - 1, 4, 4, 4, 4, 4, 1, 4, 1, 4, - 1, 5, 1, 1, 4, 4, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, - 6, 1, 1, 1, 1, 4, 1, 1, 1, 4, - 4, 4, 4, 1, 1, 4, 4, 1, 1, 1, - 1, 1, 1, 1, 0, 2, 4, 3, 0, 2, - 1, 1, 3, 3, 1, 5, 1, 3, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, + 1, 1, 2, 2, 2, 4, 3, 3, 5, 2, + 3, 4, 0, 1, 1, 1, 3, 1, 3, 2, + 3, 3, 0, 1, 3, 1, 3, 4, 1, 3, + 0, 1, 1, 1, 1, 1, 1, 4, 4, 1, + 1, 1, 1, 1, 1, 4, 1, 1, 4, 1, + 4, 4, 1, 1, 4, 4, 4, 4, 4, 1, + 4, 1, 4, 1, 5, 1, 1, 4, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, + 1, 1, 1, 6, 1, 1, 1, 1, 4, 1, + 1, 1, 4, 4, 4, 4, 1, 1, 4, 4, + 1, 1, 1, 1, 1, 1, 1, 0, 2, 4, + 3, 0, 2, 1, 1, 3, 3, 1, 5, 1, + 3, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, - 2, 2, 2, 2, 3, 3, 4, 4, 4, 3, - 1, 3, 1, 1, 0, 2, 4, 3, 2, 2, - 0, 2, 2, 1, 3, 3, 3, 2, 0, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, - 2, 1, 2, 2, 1, 1, 2, 2, 2, 5, - 0, 2, 2, 2, 2, 2, 2, 3, 2, 3, - 5, 5, 0, 2, 2, 2, 2, 6, 8, 2, - 2, 2, 2, 2, 2, 5, 1, 1, 1, 1, - 1, 0, 2, 2, 3, 0, 1, 2, 2, 2, - 3, 2, 1, 1, 3, 2, 4, 1, 3, 1, - 3, 1, 1, 1, 5, 1, 1, 1, 1, 2, - 1, 2, 1, 2, 4, 4, 5, 10, 1, 3 + 3, 2, 2, 2, 2, 2, 2, 3, 3, 4, + 4, 4, 3, 1, 3, 1, 1, 0, 2, 4, + 3, 2, 2, 0, 2, 2, 1, 3, 3, 3, + 2, 0, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 2, 1, 2, 2, 1, 1, 2, + 2, 2, 5, 0, 2, 2, 2, 2, 2, 2, + 3, 2, 3, 5, 5, 0, 2, 2, 2, 2, + 6, 8, 2, 2, 2, 2, 2, 2, 5, 1, + 1, 1, 1, 1, 0, 2, 2, 3, 0, 1, + 2, 2, 2, 3, 2, 1, 1, 3, 2, 4, + 1, 3, 1, 3, 1, 1, 1, 5, 1, 1, + 1, 1, 2, 1, 2, 1, 2, 4, 4, 5, + 10, 1, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -1160,584 +1163,572 @@ static const unsigned char yyr2[] = means the default is an error. */ static const unsigned short int yydefact[] = { - 3, 0, 2, 1, 296, 224, 215, 235, 0, 270, - 0, 0, 223, 210, 225, 266, 221, 226, 227, 0, - 269, 229, 234, 0, 227, 268, 0, 227, 0, 222, - 231, 267, 210, 49, 210, 220, 295, 216, 57, 10, - 0, 24, 11, 27, 11, 9, 0, 298, 0, 297, - 217, 0, 0, 7, 0, 0, 22, 0, 252, 5, - 4, 0, 8, 275, 275, 275, 0, 0, 300, 275, - 0, 302, 236, 237, 0, 243, 244, 299, 212, 0, - 228, 233, 0, 254, 255, 232, 0, 230, 218, 301, - 0, 0, 50, 303, 0, 219, 58, 59, 60, 61, - 62, 63, 0, 0, 66, 67, 68, 69, 70, 71, - 0, 73, 74, 0, 76, 0, 0, 79, 80, 0, - 0, 0, 0, 0, 86, 0, 88, 0, 90, 0, - 92, 93, 0, 0, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 0, 106, 107, 108, 293, 109, 0, - 111, 291, 112, 113, 114, 0, 116, 117, 118, 0, - 0, 0, 292, 0, 123, 124, 0, 0, 0, 52, - 127, 25, 0, 0, 0, 0, 0, 298, 238, 245, - 256, 264, 0, 300, 302, 26, 6, 240, 261, 0, - 23, 259, 260, 0, 0, 20, 279, 276, 278, 277, - 213, 214, 130, 131, 132, 133, 271, 0, 0, 283, - 289, 282, 207, 275, 273, 28, 0, 138, 33, 0, - 194, 0, 0, 200, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, - 0, 0, 148, 0, 0, 0, 0, 0, 0, 57, - 51, 34, 0, 17, 18, 19, 0, 15, 13, 12, - 16, 22, 36, 262, 263, 37, 206, 49, 0, 49, - 0, 0, 253, 20, 0, 0, 0, 281, 0, 148, - 39, 285, 274, 32, 0, 140, 141, 144, 304, 49, - 287, 305, 49, 49, 0, 158, 150, 151, 152, 156, - 157, 153, 154, 0, 155, 0, 0, 0, 0, 0, - 0, 0, 192, 0, 190, 193, 0, 0, 55, 0, + 3, 0, 2, 1, 299, 227, 218, 238, 0, 273, + 0, 0, 226, 213, 228, 269, 224, 229, 230, 0, + 272, 232, 237, 0, 230, 271, 0, 230, 0, 225, + 234, 270, 213, 52, 213, 223, 298, 219, 60, 10, + 0, 24, 11, 27, 11, 9, 0, 301, 0, 300, + 220, 0, 0, 7, 0, 0, 22, 0, 255, 5, + 4, 0, 8, 278, 278, 278, 0, 0, 303, 278, + 0, 305, 239, 240, 0, 246, 247, 302, 215, 0, + 231, 236, 0, 257, 258, 235, 0, 233, 221, 304, + 0, 0, 53, 306, 0, 222, 61, 62, 63, 64, + 65, 66, 0, 0, 69, 70, 71, 72, 73, 74, + 0, 76, 77, 0, 79, 0, 0, 82, 83, 0, + 0, 0, 0, 0, 89, 0, 91, 0, 93, 0, + 95, 96, 0, 0, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 0, 109, 110, 111, 296, 112, 0, + 114, 294, 115, 116, 117, 0, 119, 120, 121, 0, + 0, 0, 295, 0, 126, 127, 0, 0, 0, 55, + 130, 25, 0, 0, 0, 0, 0, 301, 241, 248, + 259, 267, 0, 303, 305, 26, 6, 243, 264, 0, + 23, 262, 263, 0, 0, 20, 282, 279, 281, 280, + 216, 217, 133, 134, 135, 136, 274, 0, 0, 286, + 292, 285, 210, 301, 303, 278, 305, 276, 28, 0, + 141, 36, 0, 197, 0, 0, 203, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 146, 149, 0, 0, 0, 0, 0, 0, 129, - 128, 0, 308, 0, 0, 53, 57, 0, 14, 38, - 22, 0, 241, 246, 0, 0, 0, 49, 0, 0, - 0, 22, 21, 0, 272, 280, 284, 290, 0, 0, - 295, 0, 44, 40, 42, 0, 0, 145, 139, 0, - 294, 0, 195, 0, 0, 306, 50, 201, 0, 64, - 0, 182, 181, 180, 183, 178, 179, 0, 0, 0, + 0, 0, 151, 0, 0, 151, 0, 0, 0, 0, + 0, 0, 60, 54, 37, 0, 17, 18, 19, 0, + 15, 13, 12, 16, 22, 39, 265, 266, 40, 209, + 52, 0, 52, 0, 0, 256, 20, 0, 0, 0, + 284, 0, 151, 42, 288, 277, 35, 0, 143, 144, + 147, 307, 52, 290, 308, 52, 52, 0, 161, 153, + 154, 155, 159, 160, 156, 157, 0, 158, 0, 0, + 0, 0, 0, 0, 0, 195, 0, 193, 196, 0, + 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 149, 152, 0, 0, 0, 0, + 0, 0, 132, 131, 0, 311, 0, 0, 56, 60, + 0, 14, 41, 22, 0, 244, 249, 0, 0, 0, + 52, 0, 0, 0, 22, 21, 0, 275, 283, 287, + 293, 0, 0, 298, 0, 47, 43, 45, 0, 0, + 148, 142, 0, 297, 0, 198, 0, 0, 309, 53, + 204, 0, 67, 0, 185, 184, 183, 186, 181, 182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 65, 72, 75, 0, 77, 78, 81, 82, - 83, 84, 85, 87, 89, 0, 95, 148, 94, 105, - 0, 115, 119, 120, 121, 122, 0, 125, 126, 54, - 0, 239, 242, 248, 0, 247, 250, 0, 0, 251, - 20, 22, 265, 48, 47, 286, 0, 0, 46, 142, - 143, 0, 302, 288, 208, 199, 198, 0, 189, 0, - 171, 172, 184, 165, 166, 169, 170, 160, 161, 0, - 162, 163, 164, 168, 167, 174, 173, 176, 177, 175, - 185, 0, 191, 56, 91, 147, 0, 309, 22, 204, - 0, 249, 0, 257, 43, 45, 0, 197, 0, 209, - 187, 186, 0, 188, 110, 35, 205, 22, 196, 134, - 159, 258, 0, 0, 0, 307, 135, 0, 49, 49, - 203, 137, 0, 136, 202 + 0, 0, 0, 0, 0, 68, 75, 78, 0, 80, + 81, 84, 85, 86, 87, 88, 90, 92, 0, 98, + 151, 97, 108, 0, 118, 122, 123, 124, 125, 0, + 128, 129, 57, 0, 242, 245, 251, 0, 250, 253, + 0, 0, 254, 20, 22, 268, 51, 50, 289, 0, + 0, 49, 145, 146, 0, 305, 291, 211, 202, 201, + 0, 192, 0, 174, 175, 187, 168, 169, 172, 173, + 163, 164, 0, 165, 166, 167, 171, 170, 177, 176, + 179, 180, 178, 188, 0, 194, 59, 94, 150, 0, + 312, 22, 207, 0, 252, 0, 260, 46, 48, 0, + 200, 0, 212, 190, 189, 0, 191, 113, 38, 208, + 22, 199, 137, 162, 261, 0, 0, 0, 310, 138, + 0, 52, 52, 206, 140, 0, 139, 205 }; /* YYDEFGOTO[NTERM-NUM]. */ static const short int yydefgoto[] = { - -1, 1, 2, 172, 274, 191, 362, 40, 41, 42, - 43, 254, 176, 44, 255, 371, 372, 373, 374, 281, - 355, 92, 168, 319, 169, 341, 208, 532, 536, 284, - 285, 286, 177, 330, 331, 312, 313, 314, 316, 289, - 382, 387, 293, 541, 542, 458, 48, 518, 79, 209, - 49, 81, 50, 256, 52, 257, 267, 352, 54, 55, - 269, 357, 56, 194, 57, 58, 258, 259, 181, 61, - 260, 63, 64, 65, 275, 66, 196, 67, 210, 211, - 291, 212, 170, 183, 69, 70, 184, 343 + -1, 1, 2, 172, 277, 191, 365, 40, 41, 42, + 43, 257, 176, 44, 258, 374, 375, 376, 377, 284, + 358, 92, 168, 322, 169, 344, 208, 535, 539, 287, + 288, 289, 213, 333, 334, 315, 316, 317, 319, 292, + 385, 390, 296, 544, 545, 461, 48, 521, 79, 209, + 49, 81, 50, 259, 52, 260, 270, 355, 54, 55, + 272, 360, 56, 194, 57, 58, 261, 262, 181, 61, + 263, 63, 64, 65, 278, 66, 196, 67, 210, 211, + 294, 212, 170, 214, 69, 70, 216, 346 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -271 +#define YYPACT_NINF -265 static const short int yypact[] = { - -271, 69, 1074, -271, -271, -271, -271, -271, 58, -271, - -62, 123, -271, 126, -271, -271, -271, -271, 53, 107, - -271, -271, -271, 128, 53, -271, -26, 53, -17, -271, - -271, -271, 130, -22, 132, -17, -271, -271, 1946, -271, - -21, -271, -271, -271, -271, -271, 1708, -19, -10, -271, - -271, -9, -25, -271, -4, -23, -1, 6, 4, -271, - -271, -18, -271, -6, -6, -6, 35, 1821, 32, -6, - 37, 40, -271, -271, 156, -271, -271, -5, -271, 15, - -271, -271, 41, -271, -271, -271, 1821, -271, -271, -5, - 39, 1751, -271, -96, -87, -271, -271, -271, -271, -271, - -271, -271, 34, 43, -271, -271, -271, -271, -271, -271, - 44, -271, -271, 47, -271, 48, 51, -271, -271, 54, - 56, 57, 60, 61, -271, 62, -271, 63, -271, 65, - -271, -271, 66, 73, -271, -271, -271, -271, -271, -271, - -271, -271, -271, 74, -271, -271, -271, -271, -271, 77, - -271, -271, -271, -271, -271, 78, -271, -271, -271, 79, - 80, 82, -271, 83, -271, -271, 85, 88, -105, -271, - -271, -271, 979, 402, 205, 136, 67, -271, -271, -271, - -271, -271, 35, -271, -271, -271, -271, -271, -271, -15, - -271, -271, -271, 138, 89, -271, -271, -271, -271, -271, - -271, -271, -271, -271, -271, -271, -271, 35, 35, -271, - 49, -70, -271, -6, -271, -271, 95, 140, -271, 96, - -271, 35, 92, -271, 140, 443, 443, 252, 261, 443, - 443, 262, 265, 443, 269, 443, 443, 216, 443, 443, - -57, 443, 443, 443, 1821, 1821, 111, 277, 1821, 1946, - 116, -271, 114, -271, -271, -271, 117, -271, -271, -271, - -271, -1, -271, -271, -271, -271, -271, -123, 137, -68, - 118, 142, -271, -271, 497, 25, 147, -271, 443, 843, - 1149, -271, -271, -271, 115, 143, -271, 134, -271, -69, - -271, 173, -22, -58, 153, -271, -271, -271, -271, -271, - -271, -271, -271, 150, -271, 443, 443, 443, 443, 443, - 443, 782, 1444, -100, -271, 1444, 154, 155, -271, -97, - 162, 163, 166, 174, 175, 176, 177, 1283, 325, 178, - -90, -271, 1444, 179, 190, -89, 1326, 184, 185, -271, - -271, 187, 194, 191, 192, -271, 1946, 358, -271, -271, - -1, -8, -271, -271, 218, 1751, 198, -56, 195, 292, - 592, -1, -271, 1751, -271, -271, -271, -271, 86, 202, - -84, 200, -271, 226, -271, 1751, 35, -271, 140, 443, - -271, 1751, -271, 35, 203, -271, 204, -271, 206, -271, - 1821, 27, 27, 27, 27, 27, 27, 1349, 207, 443, - 443, 374, 443, 443, 443, 443, 443, 443, 443, 443, - 443, 443, 443, 443, 443, 443, 443, 443, 443, 375, - 443, 443, -271, -271, -271, 372, -271, -271, -271, -271, - -271, -271, -271, -271, -271, 210, -271, 443, -271, -271, - 443, -271, -271, -271, -271, -271, 378, -271, -271, -271, - 212, -271, -271, -271, 35, -271, -271, 1751, 215, -271, - -271, -1, -271, -271, -271, -271, 1192, 35, -271, -271, - -271, 35, 238, -271, 140, -271, -271, 237, -271, 443, - 149, 149, -271, 186, 186, 144, 144, 1551, 1474, 1394, - 1497, 1520, 1567, 144, 144, 165, 165, 27, 27, 27, - -271, 1372, -271, -271, -271, -271, 239, -271, -1, -271, - 35, -271, 687, -271, -271, -271, -74, -271, 240, -271, - -271, 27, 443, -271, -271, -271, -271, -1, -271, -271, - 1444, -271, -20, 443, 266, -271, -271, 267, -46, -46, - -271, -271, 244, -271, -271 + -265, 38, 1016, -265, -265, -265, -265, -265, 133, -265, + -118, 135, -265, 138, -265, -265, -265, -265, -26, 63, + -265, -265, -265, 140, -26, -265, -44, -26, -3, -265, + -265, -265, 142, -57, 144, -3, -265, -265, 1888, -265, + -8, -265, -265, -265, -265, -265, 1650, 21, 23, -265, + -265, 26, -23, -265, 28, -14, 30, 31, 55, -265, + -265, 32, -265, -4, -4, -4, 114, 1763, 33, -4, + 42, 43, -265, -265, 212, -265, -265, 49, -265, 51, + -265, -265, 57, -265, -265, -265, 1763, -265, -265, 49, + 58, 1693, -265, -94, -89, -265, -265, -265, -265, -265, + -265, -265, 66, 67, -265, -265, -265, -265, -265, -265, + 68, -265, -265, 72, -265, 75, 86, -265, -265, 87, + 89, 90, 92, 93, -265, 94, -265, 96, -265, 99, + -265, -265, 103, 109, -265, -265, -265, -265, -265, -265, + -265, -265, -265, 111, -265, -265, -265, -265, -265, 113, + -265, -265, -265, -265, -265, 115, -265, -265, -265, 116, + 117, 118, -265, 119, -265, -265, 120, 121, -72, -265, + -265, -265, 921, 405, 225, 149, 76, 123, -265, -265, + -265, -265, 114, 132, 134, -265, -265, -265, -265, 19, + -265, -265, -265, 151, 130, -265, -265, -265, -265, -265, + -265, -265, -265, -265, -265, -265, -265, 114, 114, -265, + 73, -85, -265, -265, -265, -4, -265, -265, -265, 141, + 154, -265, 146, -265, 114, 136, -265, 154, 95, 95, + 297, 298, 95, 95, 308, 311, 95, 314, 95, 95, + 258, 95, 95, -62, 95, 95, 95, 1763, 1763, 122, + 319, 1763, 1888, 158, -265, 156, -265, -265, -265, 159, + -265, -265, -265, -265, 30, -265, -265, -265, -265, -265, + -48, 179, -60, 161, 160, -265, -265, 500, 37, 162, + -265, 95, 446, 1091, -265, -265, -265, 170, 188, -265, + 171, -265, -45, -265, 189, -57, -43, 173, -265, -265, + -265, -265, -265, -265, -265, -265, 176, -265, 95, 95, + 95, 95, 95, 95, 785, 1386, -82, -265, 1386, 177, + 180, -265, -80, 182, 184, 185, 187, 190, 192, 195, + 1225, 345, 198, -79, -265, 1386, 199, 208, -77, 1268, + 201, 202, -265, -265, 203, 193, 204, 205, -265, 1888, + 370, -265, -265, 30, -12, -265, -265, 230, 1693, 210, + -40, 207, 304, 595, 30, -265, 1693, -265, -265, -265, + -265, 54, 214, -53, 213, -265, 239, -265, 1693, 114, + -265, 154, 95, -265, 1693, -265, 114, 215, -265, 218, + -265, 221, -265, 1763, 1, 1, 1, 1, 1, 1, + 1291, 240, 95, 95, 408, 95, 95, 95, 95, 95, + 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, + 95, 95, 410, 95, 95, -265, -265, -265, 406, -265, + -265, -265, -265, -265, -265, -265, -265, -265, 243, -265, + 95, -265, -265, 95, -265, -265, -265, -265, -265, 411, + -265, -265, -265, 245, -265, -265, -265, 114, -265, -265, + 1693, 248, -265, -265, 30, -265, -265, -265, -265, 1134, + 114, -265, -265, -265, 114, 250, -265, 154, -265, -265, + 249, -265, 95, 183, 183, -265, 534, 534, 153, 153, + 1493, 1416, 1336, 1439, 1462, 1509, 153, 153, 77, 77, + 1, 1, 1, -265, 1314, -265, -265, -265, -265, 251, + -265, 30, -265, 114, -265, 690, -265, -265, -265, -81, + -265, 252, -265, -265, 1, 95, -265, -265, -265, -265, + 30, -265, -265, 1386, -265, -11, 95, 273, -265, -265, + 275, -83, -83, -265, -265, 256, -265, -265 }; /* YYPGOTO[NTERM-NUM]. */ static const short int yypgoto[] = { - -271, -271, -271, 344, -267, -244, 18, -271, -271, -271, - 59, -271, -271, -271, 408, -271, -271, -271, -49, -271, - -28, -2, -271, -271, -233, -271, -271, -271, -271, -271, - -271, 42, 2, 180, -270, -13, -271, -220, -193, -271, - -271, -271, -271, -120, -189, -271, -271, -271, 91, -194, - -271, 87, 31, 38, -271, 421, -271, -271, 379, -271, - -271, -271, -271, -271, -24, -271, 424, 1, -271, -271, - 425, -271, -271, 158, -271, -45, -16, -32, -196, -271, - -43, 247, 196, 5, -59, -271, 0, -271 + -265, -265, -265, 385, -264, -257, 11, -265, -265, -265, + 69, -265, -265, -265, 428, -265, -265, -265, -37, -265, + -30, -2, -265, -265, -235, -265, -265, -265, -265, -265, + -265, 53, 2, 191, -255, -13, -265, -222, -208, -265, + -265, -265, -265, -105, -241, -265, -265, -265, 101, -199, + -265, 85, 78, 18, -265, 436, -265, -265, 393, -265, + -265, -265, -265, -265, -28, -265, 438, -1, -265, -265, + 441, -265, -265, 166, -265, -41, -35, -20, -198, -265, + -27, 264, 216, 6, -61, -265, 0, -265 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -212 +#define YYTABLE_NINF -215 static const short int yytable[] = { - 46, 182, 71, 60, 47, 91, 360, 68, 213, 369, - 321, 276, 277, 324, 533, 326, 345, 349, 329, 7, - 39, 334, 180, 287, 354, 290, 534, 219, 200, 201, - 294, 197, 197, 197, 9, -211, 320, 197, 200, 201, - 51, 401, 249, 11, 222, 38, 221, 421, 198, 199, - 425, 350, 147, 214, 15, 18, 151, 437, 437, 88, - 202, 72, 73, -41, 250, 9, 95, 21, 22, 3, - 202, 23, 422, 383, 24, 426, 20, -211, 23, 365, - 356, 162, 438, 441, 178, 367, 223, 203, -41, 295, - 268, 296, 297, 298, 299, 300, 528, 203, 279, 38, - 38, 280, 27, 384, 388, 380, 451, 30, 25, 74, - 38, 85, 38, 449, 87, 82, 385, 462, 456, 339, - 31, 340, 38, 90, 540, 94, 75, 76, 204, 77, - 78, 83, 84, 89, 78, 93, 78, 80, 204, 263, - 264, 271, 272, 200, 201, 86, 38, 301, 187, 171, - 189, -29, 205, 193, 535, 195, 399, 400, 401, 470, - 185, 186, 205, 401, 216, 270, 188, 505, -211, 190, - 46, 46, 71, 71, 47, 47, 192, 68, 68, 401, - 468, 197, 206, 302, 287, 337, 338, 473, 217, 344, - 253, 253, 206, 512, 419, 420, 207, 282, 399, 400, - 401, 502, -30, 404, 405, 224, 207, 215, 262, 303, - -31, 218, 220, 315, 225, 226, 315, 513, 227, 228, - 506, 304, 229, 327, 278, 230, 332, 231, 232, 332, - 336, 233, 234, 235, 236, 376, 237, 238, 305, 351, - 265, 306, 307, 308, 239, 240, 309, 310, 241, 242, - 243, 244, 398, 245, 246, 463, 247, 311, 509, 248, - 317, 381, 273, 292, 525, 315, 332, 283, 288, 318, - 322, 515, 363, 323, 71, 290, 47, 325, 375, 68, - 519, 328, 342, 531, 346, 347, 353, 348, 358, 377, - 378, 386, 391, 392, 393, 394, 395, 396, 397, 414, - 415, 416, 417, 418, 414, 415, 416, 417, 418, 379, - 454, 419, 420, 537, 526, 359, 419, 420, 182, 366, - 383, 390, 416, 417, 418, 389, 423, 424, 435, 457, - 467, 477, 419, 420, 427, 428, 471, 440, 429, 412, - 413, 414, 415, 416, 417, 418, 430, 431, 432, 433, - 436, 439, 452, 419, 420, 394, 443, 444, 363, 445, - 71, 446, 47, 447, 448, 68, 450, 453, 455, 459, - 19, 464, 465, 466, 475, 474, 476, 482, 500, 479, - 503, 472, 504, 507, 508, 511, 480, 481, 173, 483, - 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, - 494, 495, 496, 497, 498, 499, 4, 501, 517, 520, - 45, 524, 510, 529, 544, 538, 539, 514, 460, 543, - 469, 376, 335, 53, 332, 179, 59, 62, 516, 266, - 5, 0, 6, 364, 0, 0, 333, 0, 7, 8, - 0, 0, 9, 0, 0, 0, 295, 10, 296, 297, - 298, 299, 300, 11, 0, 12, 0, 0, 0, 13, - 14, 0, 15, 0, 375, 16, 521, 17, 0, 0, - 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, - 19, 252, 0, 0, 20, 0, 21, 22, 23, 0, - 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, - 0, 4, 0, 0, 301, 0, 0, 0, 0, 530, - 363, 0, 71, 0, 47, 0, 25, 68, 0, 0, - 26, 27, 28, 29, 0, 5, 30, 6, 31, 0, - 0, 0, 32, 7, 0, 0, 0, 9, 33, 34, - 302, 35, 10, 0, 0, 0, 36, 37, 0, 0, - 12, 0, 0, 0, 13, 14, 0, 15, 0, 0, - 16, 0, 17, 0, 0, 0, 303, 0, 0, 18, - 38, 0, 0, 0, 0, 19, 261, 0, 304, 20, - 0, 21, 22, 0, 0, 0, 0, 0, 24, 0, - 0, 0, 0, 0, 0, 305, 4, 0, 306, 307, - 308, 0, 0, 309, 310, 0, 0, 0, 0, 0, - 0, 25, 0, 0, 311, 26, 27, 28, 29, 0, - 5, 30, 6, 31, 0, 0, 0, 32, 7, 0, - 0, 0, 9, 33, 34, 0, 35, 10, 0, 0, - 0, 36, 37, 0, 0, 12, 0, 0, 0, 13, - 14, 0, 15, 0, 0, 16, 0, 17, 0, 0, - 0, 0, 0, 0, 18, 38, 0, 0, 0, 0, - 19, 361, 0, 0, 20, 0, 21, 22, 0, 0, - 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, - 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, - 26, 27, 28, 29, 0, 5, 30, 6, 31, 0, - 0, 0, 32, 7, 0, 0, 0, 9, 33, 34, - 0, 35, 10, 0, 0, 0, 36, 37, 0, 0, - 12, 0, 0, 0, 13, 14, 0, 15, 0, 0, - 16, 0, 17, 0, 0, 0, 0, 0, 0, 18, - 38, 0, 0, 0, 0, 19, 461, 0, 0, 20, - 0, 21, 22, 0, 0, 0, 0, 0, 24, 0, - 0, 0, 0, 0, 0, 295, 4, 296, 297, 298, - 299, 300, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 25, 0, 0, 0, 26, 27, 28, 29, 0, - 5, 30, 6, 31, 0, 0, 0, 32, 7, 0, - 0, 0, 0, 33, 34, 0, 35, 0, 0, 0, - 0, 36, 37, 0, 0, 12, 0, 0, 0, 13, - 14, 0, 0, 301, 0, 16, 295, 17, 296, 297, - 298, 299, 300, 0, 18, 38, 0, 0, 0, 0, - 0, 527, 0, 0, 0, 0, 21, 22, 0, 0, - 0, 0, 0, 24, 0, 0, 0, 0, 0, 302, + 46, 60, 71, 91, 47, 182, 215, 352, 68, 279, + 280, 324, 363, 39, 327, 404, 329, 348, 180, 332, + 51, 290, 337, 536, 323, 222, 293, 372, 297, 198, + 199, 359, 357, 7, 217, 537, 9, -214, 3, 11, + 200, 201, 225, 197, 197, 197, 184, 147, 177, 197, + 224, 151, 183, 74, 387, 391, 15, 298, 80, 299, + 300, 301, 302, 303, 178, 424, 386, 428, 440, 18, + 440, 82, 202, 370, 23, 252, 162, 9, 20, -214, + 368, 21, 22, 282, 226, 38, 283, 543, 24, 531, + 425, 404, 429, 441, -44, 444, 454, 253, 298, 203, + 299, 300, 301, 302, 303, 23, 88, 465, 38, 85, + 25, 38, 87, 95, 452, 304, 27, 200, 201, -44, + 38, 30, 31, 38, 271, 38, 353, 86, 38, 383, + 342, 388, 343, 90, 459, 94, 72, 73, 75, 76, + 204, 77, 78, 83, 84, 89, 78, 93, 78, 202, + 187, 305, 266, 267, 274, 275, 304, 200, 201, 189, + 473, 273, 171, 538, 205, 402, 403, 404, 422, 423, + 46, 46, 71, 71, 47, 47, 203, 306, 68, 68, + 285, 471, 290, 256, 256, 508, 340, 341, 476, 307, + 347, -29, 305, 185, 206, 197, 186, 404, 188, 515, + 190, 192, 505, -30, 193, 195, 308, 516, 207, 309, + 310, 311, 218, -31, 312, 313, 318, 204, 306, 318, + 219, 509, -214, 466, 220, 314, 330, 221, 265, 335, + 307, 223, 335, 339, 419, 420, 421, 227, 228, 229, + 354, 205, 379, 230, 422, 423, 231, 308, 281, 268, + 309, 310, 311, 401, 528, 312, 313, 232, 233, 512, + 234, 235, 384, 236, 237, 238, 314, 239, 318, 335, + 240, 206, 518, 534, 241, 366, 293, 71, 522, 47, + 242, 378, 243, 68, 244, 207, 245, 246, 247, 248, + 249, 250, 251, -32, 389, 394, 395, 396, 397, 398, + 399, 400, -33, 276, -34, 320, 321, 295, 417, 418, + 419, 420, 421, 286, 540, 529, 325, 457, 291, 326, + 422, 423, 328, 331, 345, 182, 349, 350, 356, 351, + 460, 361, 480, 362, 369, 381, 386, 470, 417, 418, + 419, 420, 421, 474, 380, 392, 382, 393, 438, 426, + 422, 423, 427, 455, 430, 443, 431, 432, 397, 433, + 449, 366, 434, 71, 435, 47, 184, 436, 177, 68, + 439, 442, 183, 446, 447, 448, 450, 451, 453, 456, + 458, 462, 19, 467, 475, 468, 469, 477, 478, 483, + 484, 479, 486, 487, 488, 489, 490, 491, 492, 493, + 494, 495, 496, 497, 498, 499, 500, 501, 502, 4, + 504, 485, 482, 503, 506, 507, 510, 511, 514, 513, + 520, 523, 541, 527, 542, 532, 547, 335, 379, 173, + 45, 463, 517, 5, 472, 6, 338, 546, 53, 179, + 59, 7, 8, 62, 367, 9, 269, 519, 0, 298, + 10, 299, 300, 301, 302, 303, 11, 0, 12, 336, + 0, 0, 13, 14, 0, 15, 0, 378, 16, 524, + 17, 0, 0, 0, 0, 0, 0, 18, 0, 0, + 0, 0, 0, 19, 255, 0, 0, 20, 0, 21, + 22, 23, 0, 0, 0, 0, 24, 0, 0, 0, + 0, 0, 0, 0, 4, 0, 0, 304, 0, 0, + 0, 0, 533, 366, 0, 71, 0, 47, 0, 25, + 0, 68, 0, 26, 27, 28, 29, 0, 5, 30, + 6, 31, 0, 0, 0, 32, 7, 0, 0, 0, + 9, 33, 34, 305, 35, 10, 402, 403, 404, 36, + 37, 407, 408, 12, 0, 0, 0, 13, 14, 0, + 15, 0, 0, 16, 0, 17, 0, 0, 0, 306, + 0, 0, 18, 38, 0, 0, 0, 0, 19, 264, + 0, 307, 20, 0, 21, 22, 0, 0, 0, 0, + 0, 24, 0, 0, 0, 0, 0, 0, 308, 4, + 0, 309, 310, 371, 0, 0, 312, 313, 0, 0, + 0, 0, 0, 0, 25, 0, 0, 314, 26, 27, + 28, 29, 0, 5, 30, 6, 31, 0, 0, 0, + 32, 7, 0, 0, 0, 9, 33, 34, 0, 35, + 10, 0, 0, 0, 36, 37, 0, 0, 12, 0, + 0, 0, 13, 14, 0, 15, 0, 0, 16, 0, + 17, 0, 0, 0, 0, 0, 0, 18, 38, 0, + 0, 0, 0, 19, 364, 0, 0, 20, 0, 21, + 22, 0, 0, 0, 0, 0, 24, 415, 416, 417, + 418, 419, 420, 421, 4, 0, 0, 0, 0, 0, + 0, 422, 423, 0, 0, 0, 0, 0, 0, 25, + 0, 0, 0, 26, 27, 28, 29, 0, 5, 30, + 6, 31, 0, 0, 0, 32, 7, 0, 0, 0, + 9, 33, 34, 0, 35, 10, 0, 0, 0, 36, + 37, 0, 0, 12, 0, 0, 0, 13, 14, 0, + 15, 0, 0, 16, 0, 17, 0, 0, 0, 0, + 0, 0, 18, 38, 0, 0, 0, 0, 19, 464, + 0, 0, 20, 0, 21, 22, 0, 0, 0, 0, + 0, 24, 0, 0, 0, 0, 0, 0, 298, 4, + 299, 300, 301, 302, 303, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 25, 0, 0, 0, 26, 27, + 28, 29, 0, 5, 30, 6, 31, 0, 0, 0, + 32, 7, 0, 0, 0, 0, 33, 34, 0, 35, + 0, 0, 0, 0, 36, 37, 0, 0, 12, 0, + 0, 0, 13, 14, 0, 0, 304, 0, 16, 0, + 17, 0, 0, 0, 0, 0, 0, 18, 38, 0, + 0, 0, 0, 0, 530, 0, 0, 0, 0, 21, + 22, 0, 0, 0, 0, 0, 24, 0, 0, 0, + 0, 0, 305, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 26, 27, 28, 29, 301, 303, 30, 0, 0, 0, - 0, 0, 32, 0, 0, 0, 0, 304, 0, 34, - 0, 35, 0, 0, 0, 0, 36, 37, 0, 0, - 0, 0, 0, 0, 305, 0, 0, 306, 307, 308, - 302, 0, 309, 310, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 311, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 303, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 304, 0, - 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, - 251, 0, 0, 0, 0, 305, 0, 0, 306, 307, - 368, 0, 0, 309, 310, 0, 0, 5, 0, 6, - 0, 0, 0, 0, 311, 7, 8, 0, 0, 9, - 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, - 11, 0, 12, 0, 0, 0, 13, 14, 0, 15, - 0, 0, 16, 0, 17, 0, 0, 0, 0, 0, - 0, 18, 0, 0, 0, 0, 0, 19, 252, 0, - 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, - 24, 0, 0, 0, 0, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 25, 0, 0, 0, 26, 27, 28, - 29, 0, 5, 30, 6, 31, 0, 0, 0, 32, - 7, 8, 0, 0, 9, 33, 34, 0, 35, 10, - 0, 0, 0, 36, 37, 11, 0, 12, 0, 0, - 0, 13, 14, 0, 15, 0, 0, 16, 0, 17, - 0, 0, 0, 0, 0, 0, 18, 38, 0, 0, - 0, 0, 19, 4, 0, 0, 20, 0, 21, 22, - 23, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 5, 0, 6, - 0, 0, 0, 0, 0, 7, 0, 0, 25, 9, - 0, 0, 26, 27, 28, 29, 4, 0, 30, 0, - 31, 0, 12, 0, 32, 0, 13, 14, 0, 15, - 33, 34, 16, 35, 17, 0, 0, 0, 36, 37, - 5, 18, 6, 0, 0, 0, 0, 0, 7, 0, - 0, 20, 9, 21, 22, 0, 0, 0, 0, 0, - 24, 0, 38, 0, 0, 12, 0, 0, 0, 13, - 14, 0, 15, 0, 0, 16, 0, 17, 0, 0, - 0, 0, 0, 25, 18, 0, 0, 26, 27, 28, - 29, 0, 0, 30, 20, 31, 21, 22, 0, 32, - 0, 0, 0, 24, 0, 0, 34, 0, 35, 0, - 0, 0, 0, 370, 37, 399, 400, 401, 402, 403, - 404, 405, 406, 407, 0, 0, 25, 0, 0, 0, - 26, 27, 28, 29, 0, 0, 30, 38, 31, 0, - 0, 0, 32, 0, 0, 0, 0, 0, 0, 34, - 0, 35, 0, 0, 0, 0, 36, 37, 399, 400, - 401, 402, 403, 404, 405, 406, 407, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 38, 399, 400, 401, 402, 403, 404, 405, 406, 407, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 399, 400, 401, 402, 403, 404, - 405, 406, 407, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 399, 400, 401, 402, - 403, 404, 405, 406, 407, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 408, 0, 409, 410, 411, 412, 413, 414, 415, - 416, 417, 418, 0, 0, 0, 0, 0, 0, 0, - 419, 420, 0, 0, 0, 434, 399, 400, 401, 402, - 403, 404, 405, 406, 407, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 408, 0, 409, 410, 411, 412, - 413, 414, 415, 416, 417, 418, 399, 400, 401, 402, - 403, 404, 405, 419, 420, 0, 0, 408, 442, 409, - 410, 411, 412, 413, 414, 415, 416, 417, 418, 399, - 400, 401, 402, 403, 404, 405, 419, 420, 0, 0, - 408, 478, 409, 410, 411, 412, 413, 414, 415, 416, - 417, 418, 399, 400, 401, 402, 403, 404, 405, 419, - 420, 523, 408, 522, 409, 410, 411, 412, 413, 414, - 415, 416, 417, 418, 0, 0, 0, 0, 0, 0, - 0, 419, 420, 399, 400, 401, 402, 403, 404, 405, - 0, 407, 0, 0, 0, 0, 0, 0, 0, 399, - 400, 401, 402, 403, 404, 405, 0, 0, 0, 0, - 0, 0, 408, 0, 409, 410, 411, 412, 413, 414, - 415, 416, 417, 418, 0, 0, 0, 0, 0, 0, - 0, 419, 420, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 409, 410, 411, 412, 413, 414, - 415, 416, 417, 418, 0, 0, 0, 0, 0, 0, - 0, 419, 420, 0, 0, 0, 0, 0, 410, 411, - 412, 413, 414, 415, 416, 417, 418, 0, 0, 0, - 0, 0, 0, 0, 419, 420, 0, 0, 0, 0, - 0, 0, 411, 412, 413, 414, 415, 416, 417, 418, - 0, 0, 0, 0, 0, 0, 0, 419, 420, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 409, 410, 411, 412, 413, 414, 415, 416, 417, - 418, 0, 4, 0, 0, 0, 0, 0, 419, 420, - 412, 413, 414, 415, 416, 417, 418, 0, 0, 0, - 0, 0, 0, 0, 419, 420, 5, 0, 6, 0, - 0, 0, 0, 0, 7, 8, 0, 0, 9, 0, - 0, 0, 0, 0, 0, 4, 0, 0, 0, 11, - 0, 12, 0, 0, 0, 13, 14, 0, 15, 0, - 0, 16, 0, 17, 0, 0, 0, 0, 0, 5, - 18, 6, 0, 0, 0, 0, 0, 7, 0, 0, - 20, 9, 21, 22, 23, 0, 0, 174, 0, 24, - 0, 175, 0, 0, 12, 0, 0, 0, 13, 14, + 0, 0, 0, 26, 27, 28, 29, 0, 306, 30, + 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, + 307, 0, 34, 0, 35, 4, 0, 0, 0, 36, + 37, 0, 254, 0, 0, 0, 0, 308, 0, 0, + 309, 310, 311, 0, 0, 312, 313, 0, 0, 5, + 0, 6, 0, 0, 0, 0, 314, 7, 8, 0, + 0, 9, 0, 0, 0, 0, 10, 0, 0, 0, + 0, 0, 11, 0, 12, 0, 0, 0, 13, 14, 0, 15, 0, 0, 16, 0, 17, 0, 0, 0, - 0, 0, 25, 18, 0, 4, 26, 27, 28, 29, - 0, 0, 30, 20, 31, 21, 22, 0, 32, 0, - 0, 0, 24, 0, 0, 34, 0, 35, 0, 5, - 0, 6, 36, 37, 0, 0, 0, 7, 0, 0, - 0, 0, 0, 0, 0, 25, 0, 0, 0, 26, - 27, 28, 29, 0, 12, 30, 0, 31, 13, 14, - 0, 32, 0, 0, 16, 0, 17, 0, 34, 0, - 35, 0, 0, 18, 0, 36, 37, 0, 0, 0, - 0, 0, 0, 0, 0, 21, 22, 0, 0, 0, + 0, 0, 0, 18, 0, 0, 0, 0, 0, 19, + 255, 0, 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 25, 0, 0, 0, 26, + 27, 28, 29, 0, 5, 30, 6, 31, 0, 0, + 0, 32, 7, 8, 0, 0, 9, 33, 34, 0, + 35, 10, 0, 0, 0, 36, 37, 11, 0, 12, + 0, 0, 0, 13, 14, 0, 15, 0, 0, 16, + 0, 17, 0, 0, 0, 0, 0, 0, 18, 38, + 0, 0, 0, 0, 19, 4, 0, 0, 20, 0, + 21, 22, 23, 0, 0, 0, 0, 24, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, + 0, 6, 0, 0, 0, 0, 0, 7, 0, 0, + 25, 9, 0, 0, 26, 27, 28, 29, 4, 0, + 30, 0, 31, 0, 12, 0, 32, 0, 13, 14, + 0, 15, 33, 34, 16, 35, 17, 0, 0, 0, + 36, 37, 5, 18, 6, 0, 0, 0, 0, 0, + 7, 0, 0, 20, 9, 21, 22, 0, 0, 0, + 0, 0, 24, 0, 38, 0, 0, 12, 0, 0, + 0, 13, 14, 0, 15, 0, 0, 16, 0, 17, + 0, 0, 0, 0, 0, 25, 18, 0, 0, 26, + 27, 28, 29, 0, 0, 30, 20, 31, 21, 22, + 0, 32, 0, 0, 0, 24, 0, 0, 34, 0, + 35, 0, 0, 0, 0, 373, 37, 402, 403, 404, + 405, 406, 407, 408, 409, 410, 0, 0, 25, 0, + 0, 0, 26, 27, 28, 29, 0, 0, 30, 38, + 31, 0, 0, 0, 32, 0, 0, 0, 0, 0, + 0, 34, 0, 35, 0, 0, 0, 0, 36, 37, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, - 27, 28, 29, 0, 0, 30, 0, 0, 0, 0, - 0, 32, 0, 0, 0, 0, 0, 0, 34, 0, - 35, 0, 0, 0, 0, 36, 37, 96, 0, 97, - 98, 0, 99, 100, 0, 101, 0, 0, 102, 0, - 103, 0, 0, 0, 0, 0, 0, 104, 105, 106, - 107, 0, 108, 109, 110, 111, 112, 0, 113, 0, - 114, 115, 116, 0, 0, 117, 0, 0, 0, 0, - 118, 0, 119, 120, 121, 122, 123, 124, 0, 125, - 126, 127, 128, 129, 0, 0, 130, 0, 0, 131, - 0, 0, 0, 132, 133, 0, 134, 0, 0, 0, - 135, 136, 137, 0, 138, 139, 140, 141, 142, 0, - 143, 0, 144, 145, 146, 147, 148, 149, 150, 151, - 0, 152, 153, 154, 0, 0, 0, 0, 155, 0, - 0, 156, 0, 0, 157, 158, 0, 0, 159, 160, - 161, 0, 0, 0, 162, 0, 163, 164, 165, 166, - 0, 0, 167 + 0, 0, 38, 402, 403, 404, 405, 406, 407, 408, + 409, 410, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 402, 403, 404, 405, + 406, 407, 408, 409, 410, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 402, 403, + 404, 405, 406, 407, 408, 409, 410, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 411, 0, 412, 413, 414, 415, 416, + 417, 418, 419, 420, 421, 0, 0, 0, 0, 0, + 0, 0, 422, 423, 0, 0, 0, 437, 402, 403, + 404, 405, 406, 407, 408, 409, 410, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 411, 0, 412, 413, + 414, 415, 416, 417, 418, 419, 420, 421, 402, 403, + 404, 405, 406, 407, 408, 422, 423, 0, 0, 411, + 445, 412, 413, 414, 415, 416, 417, 418, 419, 420, + 421, 402, 403, 404, 405, 406, 407, 408, 422, 423, + 0, 0, 411, 481, 412, 413, 414, 415, 416, 417, + 418, 419, 420, 421, 402, 403, 404, 405, 406, 407, + 408, 422, 423, 526, 411, 525, 412, 413, 414, 415, + 416, 417, 418, 419, 420, 421, 0, 0, 0, 0, + 0, 0, 0, 422, 423, 402, 403, 404, 405, 406, + 407, 408, 0, 410, 0, 0, 0, 0, 0, 0, + 0, 402, 403, 404, 405, 406, 407, 408, 0, 0, + 0, 0, 0, 0, 411, 0, 412, 413, 414, 415, + 416, 417, 418, 419, 420, 421, 0, 0, 0, 0, + 0, 0, 0, 422, 423, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 412, 413, 414, 415, + 416, 417, 418, 419, 420, 421, 0, 0, 0, 0, + 0, 0, 0, 422, 423, 0, 0, 0, 0, 0, + 413, 414, 415, 416, 417, 418, 419, 420, 421, 0, + 0, 0, 0, 0, 0, 0, 422, 423, 0, 0, + 0, 0, 0, 0, 414, 415, 416, 417, 418, 419, + 420, 421, 0, 0, 0, 0, 0, 0, 0, 422, + 423, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 412, 413, 414, 415, 416, 417, 418, + 419, 420, 421, 0, 4, 0, 0, 0, 0, 0, + 422, 423, 415, 416, 417, 418, 419, 420, 421, 0, + 0, 0, 0, 0, 0, 0, 422, 423, 5, 0, + 6, 0, 0, 0, 0, 0, 7, 8, 0, 0, + 9, 0, 0, 0, 0, 0, 0, 4, 0, 0, + 0, 11, 0, 12, 0, 0, 0, 13, 14, 0, + 15, 0, 0, 16, 0, 17, 0, 0, 0, 0, + 0, 5, 18, 6, 0, 0, 0, 0, 0, 7, + 0, 0, 20, 9, 21, 22, 23, 0, 0, 174, + 0, 24, 0, 175, 0, 0, 12, 0, 0, 0, + 13, 14, 0, 15, 0, 0, 16, 0, 17, 0, + 0, 0, 0, 0, 25, 18, 0, 4, 26, 27, + 28, 29, 0, 0, 30, 20, 31, 21, 22, 0, + 32, 0, 0, 0, 24, 0, 0, 34, 0, 35, + 0, 5, 0, 6, 36, 37, 0, 0, 0, 7, + 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, + 0, 26, 27, 28, 29, 0, 12, 30, 0, 31, + 13, 14, 0, 32, 0, 0, 16, 0, 17, 0, + 34, 0, 35, 0, 0, 18, 0, 36, 37, 0, + 0, 0, 0, 0, 0, 0, 0, 21, 22, 0, + 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 26, 27, 28, 29, 0, 0, 30, 0, 0, + 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, + 34, 0, 35, 0, 0, 0, 0, 36, 37, 96, + 0, 97, 98, 0, 99, 100, 0, 101, 0, 0, + 102, 0, 103, 0, 0, 0, 0, 0, 0, 104, + 105, 106, 107, 0, 108, 109, 110, 111, 112, 0, + 113, 0, 114, 115, 116, 0, 0, 117, 0, 0, + 0, 0, 118, 0, 119, 120, 121, 122, 123, 124, + 0, 125, 126, 127, 128, 129, 0, 0, 130, 0, + 0, 131, 0, 0, 0, 132, 133, 0, 134, 0, + 0, 0, 135, 136, 137, 0, 138, 139, 140, 141, + 142, 0, 143, 0, 144, 145, 146, 147, 148, 149, + 150, 151, 0, 152, 153, 154, 0, 0, 0, 0, + 155, 0, 0, 156, 0, 0, 157, 158, 0, 0, + 159, 160, 161, 0, 0, 0, 162, 0, 163, 164, + 165, 166, 0, 0, 167 }; static const short int yycheck[] = { - 2, 46, 2, 2, 2, 33, 273, 2, 67, 279, - 230, 207, 208, 233, 34, 235, 249, 261, 238, 36, - 2, 241, 46, 217, 92, 221, 46, 86, 3, 4, - 224, 63, 64, 65, 40, 131, 229, 69, 3, 4, - 2, 14, 147, 51, 131, 168, 91, 147, 64, 65, - 147, 174, 109, 69, 60, 72, 113, 147, 147, 28, - 35, 3, 4, 147, 169, 40, 35, 84, 85, 0, - 35, 86, 172, 147, 91, 172, 82, 173, 86, 275, - 269, 138, 172, 172, 46, 278, 173, 62, 172, 3, - 105, 5, 6, 7, 8, 9, 170, 62, 168, 168, - 168, 171, 119, 292, 293, 174, 350, 124, 114, 171, - 168, 24, 168, 346, 27, 8, 174, 361, 174, 8, - 126, 10, 168, 32, 170, 34, 3, 4, 103, 3, - 4, 3, 4, 3, 4, 3, 4, 84, 103, 3, - 4, 3, 4, 3, 4, 171, 168, 61, 173, 170, - 173, 170, 127, 149, 174, 173, 12, 13, 14, 379, - 170, 170, 127, 14, 8, 189, 170, 437, 173, 170, - 172, 173, 172, 173, 172, 173, 170, 172, 173, 14, - 376, 213, 157, 97, 378, 244, 245, 383, 173, 248, - 172, 173, 157, 460, 167, 168, 171, 213, 12, 13, - 14, 421, 170, 17, 18, 171, 171, 170, 3, 123, - 170, 170, 173, 226, 171, 171, 229, 461, 171, 171, - 440, 135, 171, 236, 175, 171, 239, 171, 171, 242, - 243, 171, 171, 171, 171, 280, 171, 171, 152, 267, - 173, 155, 156, 157, 171, 171, 160, 161, 171, 171, - 171, 171, 311, 171, 171, 169, 171, 171, 454, 171, - 8, 289, 173, 171, 508, 278, 279, 172, 172, 8, - 8, 467, 274, 8, 274, 471, 274, 8, 280, 274, - 474, 65, 5, 527, 168, 171, 149, 170, 170, 174, - 147, 293, 305, 306, 307, 308, 309, 310, 311, 155, - 156, 157, 158, 159, 155, 156, 157, 158, 159, 175, - 355, 167, 168, 533, 510, 173, 167, 168, 363, 172, - 147, 171, 157, 158, 159, 172, 172, 172, 3, 357, - 375, 390, 167, 168, 172, 172, 381, 147, 172, 153, - 154, 155, 156, 157, 158, 159, 172, 172, 172, 172, - 172, 172, 351, 167, 168, 368, 172, 172, 360, 172, - 360, 167, 360, 172, 172, 360, 8, 149, 170, 174, - 78, 169, 172, 147, 170, 172, 170, 3, 3, 172, - 8, 381, 172, 5, 172, 170, 399, 400, 44, 402, - 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, - 413, 414, 415, 416, 417, 418, 4, 420, 170, 172, - 2, 172, 457, 173, 170, 149, 149, 466, 359, 539, - 378, 466, 242, 2, 437, 46, 2, 2, 471, 182, - 28, -1, 30, 275, -1, -1, 240, -1, 36, 37, - -1, -1, 40, -1, -1, -1, 3, 45, 5, 6, - 7, 8, 9, 51, -1, 53, -1, -1, -1, 57, - 58, -1, 60, -1, 466, 63, 479, 65, -1, -1, - -1, -1, -1, -1, 72, -1, -1, -1, -1, -1, - 78, 79, -1, -1, 82, -1, 84, 85, 86, -1, - -1, -1, -1, 91, -1, -1, -1, -1, -1, -1, - -1, 4, -1, -1, 61, -1, -1, -1, -1, 522, - 512, -1, 512, -1, 512, -1, 114, 512, -1, -1, - 118, 119, 120, 121, -1, 28, 124, 30, 126, -1, - -1, -1, 130, 36, -1, -1, -1, 40, 136, 137, - 97, 139, 45, -1, -1, -1, 144, 145, -1, -1, - 53, -1, -1, -1, 57, 58, -1, 60, -1, -1, - 63, -1, 65, -1, -1, -1, 123, -1, -1, 72, - 168, -1, -1, -1, -1, 78, 174, -1, 135, 82, - -1, 84, 85, -1, -1, -1, -1, -1, 91, -1, - -1, -1, -1, -1, -1, 152, 4, -1, 155, 156, - 157, -1, -1, 160, 161, -1, -1, -1, -1, -1, - -1, 114, -1, -1, 171, 118, 119, 120, 121, -1, - 28, 124, 30, 126, -1, -1, -1, 130, 36, -1, - -1, -1, 40, 136, 137, -1, 139, 45, -1, -1, - -1, 144, 145, -1, -1, 53, -1, -1, -1, 57, - 58, -1, 60, -1, -1, 63, -1, 65, -1, -1, - -1, -1, -1, -1, 72, 168, -1, -1, -1, -1, - 78, 174, -1, -1, 82, -1, 84, 85, -1, -1, - -1, -1, -1, 91, -1, -1, -1, -1, -1, -1, - -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 114, -1, -1, -1, - 118, 119, 120, 121, -1, 28, 124, 30, 126, -1, - -1, -1, 130, 36, -1, -1, -1, 40, 136, 137, - -1, 139, 45, -1, -1, -1, 144, 145, -1, -1, - 53, -1, -1, -1, 57, 58, -1, 60, -1, -1, - 63, -1, 65, -1, -1, -1, -1, -1, -1, 72, - 168, -1, -1, -1, -1, 78, 174, -1, -1, 82, - -1, 84, 85, -1, -1, -1, -1, -1, 91, -1, - -1, -1, -1, -1, -1, 3, 4, 5, 6, 7, - 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 114, -1, -1, -1, 118, 119, 120, 121, -1, - 28, 124, 30, 126, -1, -1, -1, 130, 36, -1, - -1, -1, -1, 136, 137, -1, 139, -1, -1, -1, - -1, 144, 145, -1, -1, 53, -1, -1, -1, 57, - 58, -1, -1, 61, -1, 63, 3, 65, 5, 6, - 7, 8, 9, -1, 72, 168, -1, -1, -1, -1, - -1, 174, -1, -1, -1, -1, 84, 85, -1, -1, - -1, -1, -1, 91, -1, -1, -1, -1, -1, 97, + 2, 2, 2, 33, 2, 46, 67, 264, 2, 207, + 208, 233, 276, 2, 236, 14, 238, 252, 46, 241, + 2, 220, 244, 34, 232, 86, 224, 282, 227, 64, + 65, 272, 92, 36, 69, 46, 40, 131, 0, 51, + 3, 4, 131, 63, 64, 65, 46, 109, 46, 69, + 91, 113, 46, 171, 295, 296, 60, 3, 84, 5, + 6, 7, 8, 9, 46, 147, 147, 147, 147, 72, + 147, 8, 35, 281, 86, 147, 138, 40, 82, 173, + 278, 84, 85, 168, 173, 168, 171, 170, 91, 170, + 172, 14, 172, 172, 147, 172, 353, 169, 3, 62, + 5, 6, 7, 8, 9, 86, 28, 364, 168, 24, + 114, 168, 27, 35, 349, 61, 119, 3, 4, 172, + 168, 124, 126, 168, 105, 168, 174, 171, 168, 174, + 8, 174, 10, 32, 174, 34, 3, 4, 3, 4, + 103, 3, 4, 3, 4, 3, 4, 3, 4, 35, + 173, 97, 3, 4, 3, 4, 61, 3, 4, 173, + 382, 189, 170, 174, 127, 12, 13, 14, 167, 168, + 172, 173, 172, 173, 172, 173, 62, 123, 172, 173, + 215, 379, 381, 172, 173, 440, 247, 248, 386, 135, + 251, 170, 97, 170, 157, 215, 170, 14, 170, 463, + 170, 170, 424, 170, 149, 173, 152, 464, 171, 155, + 156, 157, 170, 170, 160, 161, 229, 103, 123, 232, + 8, 443, 173, 169, 173, 171, 239, 170, 3, 242, + 135, 173, 245, 246, 157, 158, 159, 171, 171, 171, + 270, 127, 283, 171, 167, 168, 171, 152, 175, 173, + 155, 156, 157, 314, 511, 160, 161, 171, 171, 457, + 171, 171, 292, 171, 171, 171, 171, 171, 281, 282, + 171, 157, 470, 530, 171, 277, 474, 277, 477, 277, + 171, 283, 171, 277, 171, 171, 171, 171, 171, 171, + 171, 171, 171, 170, 296, 308, 309, 310, 311, 312, + 313, 314, 170, 173, 170, 8, 8, 171, 155, 156, + 157, 158, 159, 172, 536, 513, 8, 358, 172, 8, + 167, 168, 8, 65, 5, 366, 168, 171, 149, 170, + 360, 170, 393, 173, 172, 147, 147, 378, 155, 156, + 157, 158, 159, 384, 174, 172, 175, 171, 3, 172, + 167, 168, 172, 354, 172, 147, 172, 172, 371, 172, + 167, 363, 172, 363, 172, 363, 366, 172, 366, 363, + 172, 172, 366, 172, 172, 172, 172, 172, 8, 149, + 170, 174, 78, 169, 384, 172, 147, 172, 170, 402, + 403, 170, 405, 406, 407, 408, 409, 410, 411, 412, + 413, 414, 415, 416, 417, 418, 419, 420, 421, 4, + 423, 3, 172, 3, 8, 172, 5, 172, 170, 460, + 170, 172, 149, 172, 149, 173, 170, 440, 469, 44, + 2, 362, 469, 28, 381, 30, 245, 542, 2, 46, + 2, 36, 37, 2, 278, 40, 182, 474, -1, 3, + 45, 5, 6, 7, 8, 9, 51, -1, 53, 243, + -1, -1, 57, 58, -1, 60, -1, 469, 63, 482, + 65, -1, -1, -1, -1, -1, -1, 72, -1, -1, + -1, -1, -1, 78, 79, -1, -1, 82, -1, 84, + 85, 86, -1, -1, -1, -1, 91, -1, -1, -1, + -1, -1, -1, -1, 4, -1, -1, 61, -1, -1, + -1, -1, 525, 515, -1, 515, -1, 515, -1, 114, + -1, 515, -1, 118, 119, 120, 121, -1, 28, 124, + 30, 126, -1, -1, -1, 130, 36, -1, -1, -1, + 40, 136, 137, 97, 139, 45, 12, 13, 14, 144, + 145, 17, 18, 53, -1, -1, -1, 57, 58, -1, + 60, -1, -1, 63, -1, 65, -1, -1, -1, 123, + -1, -1, 72, 168, -1, -1, -1, -1, 78, 174, + -1, 135, 82, -1, 84, 85, -1, -1, -1, -1, + -1, 91, -1, -1, -1, -1, -1, -1, 152, 4, + -1, 155, 156, 157, -1, -1, 160, 161, -1, -1, + -1, -1, -1, -1, 114, -1, -1, 171, 118, 119, + 120, 121, -1, 28, 124, 30, 126, -1, -1, -1, + 130, 36, -1, -1, -1, 40, 136, 137, -1, 139, + 45, -1, -1, -1, 144, 145, -1, -1, 53, -1, + -1, -1, 57, 58, -1, 60, -1, -1, 63, -1, + 65, -1, -1, -1, -1, -1, -1, 72, 168, -1, + -1, -1, -1, 78, 174, -1, -1, 82, -1, 84, + 85, -1, -1, -1, -1, -1, 91, 153, 154, 155, + 156, 157, 158, 159, 4, -1, -1, -1, -1, -1, + -1, 167, 168, -1, -1, -1, -1, -1, -1, 114, + -1, -1, -1, 118, 119, 120, 121, -1, 28, 124, + 30, 126, -1, -1, -1, 130, 36, -1, -1, -1, + 40, 136, 137, -1, 139, 45, -1, -1, -1, 144, + 145, -1, -1, 53, -1, -1, -1, 57, 58, -1, + 60, -1, -1, 63, -1, 65, -1, -1, -1, -1, + -1, -1, 72, 168, -1, -1, -1, -1, 78, 174, + -1, -1, 82, -1, 84, 85, -1, -1, -1, -1, + -1, 91, -1, -1, -1, -1, -1, -1, 3, 4, + 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 114, -1, -1, -1, 118, 119, + 120, 121, -1, 28, 124, 30, 126, -1, -1, -1, + 130, 36, -1, -1, -1, -1, 136, 137, -1, 139, + -1, -1, -1, -1, 144, 145, -1, -1, 53, -1, + -1, -1, 57, 58, -1, -1, 61, -1, 63, -1, + 65, -1, -1, -1, -1, -1, -1, 72, 168, -1, + -1, -1, -1, -1, 174, -1, -1, -1, -1, 84, + 85, -1, -1, -1, -1, -1, 91, -1, -1, -1, + -1, -1, 97, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 118, 119, 120, 121, 61, 123, 124, -1, -1, -1, - -1, -1, 130, -1, -1, -1, -1, 135, -1, 137, - -1, 139, -1, -1, -1, -1, 144, 145, -1, -1, - -1, -1, -1, -1, 152, -1, -1, 155, 156, 157, - 97, -1, 160, 161, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 171, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 123, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 135, -1, - -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, - 11, -1, -1, -1, -1, 152, -1, -1, 155, 156, - 157, -1, -1, 160, 161, -1, -1, 28, -1, 30, - -1, -1, -1, -1, 171, 36, 37, -1, -1, 40, - -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, - 51, -1, 53, -1, -1, -1, 57, 58, -1, 60, - -1, -1, 63, -1, 65, -1, -1, -1, -1, -1, - -1, 72, -1, -1, -1, -1, -1, 78, 79, -1, - -1, 82, -1, 84, 85, 86, -1, -1, -1, -1, - 91, -1, -1, -1, -1, -1, -1, -1, 4, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 114, -1, -1, -1, 118, 119, 120, - 121, -1, 28, 124, 30, 126, -1, -1, -1, 130, - 36, 37, -1, -1, 40, 136, 137, -1, 139, 45, - -1, -1, -1, 144, 145, 51, -1, 53, -1, -1, + -1, -1, -1, 118, 119, 120, 121, -1, 123, 124, + -1, -1, -1, -1, -1, 130, -1, -1, -1, -1, + 135, -1, 137, -1, 139, 4, -1, -1, -1, 144, + 145, -1, 11, -1, -1, -1, -1, 152, -1, -1, + 155, 156, 157, -1, -1, 160, 161, -1, -1, 28, + -1, 30, -1, -1, -1, -1, 171, 36, 37, -1, + -1, 40, -1, -1, -1, -1, 45, -1, -1, -1, + -1, -1, 51, -1, 53, -1, -1, -1, 57, 58, + -1, 60, -1, -1, 63, -1, 65, -1, -1, -1, + -1, -1, -1, 72, -1, -1, -1, -1, -1, 78, + 79, -1, -1, 82, -1, 84, 85, 86, -1, -1, + -1, -1, 91, -1, -1, -1, -1, -1, -1, -1, + 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 114, -1, -1, -1, 118, + 119, 120, 121, -1, 28, 124, 30, 126, -1, -1, + -1, 130, 36, 37, -1, -1, 40, 136, 137, -1, + 139, 45, -1, -1, -1, 144, 145, 51, -1, 53, + -1, -1, -1, 57, 58, -1, 60, -1, -1, 63, + -1, 65, -1, -1, -1, -1, -1, -1, 72, 168, + -1, -1, -1, -1, 78, 4, -1, -1, 82, -1, + 84, 85, 86, -1, -1, -1, -1, 91, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, + -1, 30, -1, -1, -1, -1, -1, 36, -1, -1, + 114, 40, -1, -1, 118, 119, 120, 121, 4, -1, + 124, -1, 126, -1, 53, -1, 130, -1, 57, 58, + -1, 60, 136, 137, 63, 139, 65, -1, -1, -1, + 144, 145, 28, 72, 30, -1, -1, -1, -1, -1, + 36, -1, -1, 82, 40, 84, 85, -1, -1, -1, + -1, -1, 91, -1, 168, -1, -1, 53, -1, -1, -1, 57, 58, -1, 60, -1, -1, 63, -1, 65, - -1, -1, -1, -1, -1, -1, 72, 168, -1, -1, - -1, -1, 78, 4, -1, -1, 82, -1, 84, 85, - 86, -1, -1, -1, -1, 91, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 28, -1, 30, - -1, -1, -1, -1, -1, 36, -1, -1, 114, 40, - -1, -1, 118, 119, 120, 121, 4, -1, 124, -1, - 126, -1, 53, -1, 130, -1, 57, 58, -1, 60, - 136, 137, 63, 139, 65, -1, -1, -1, 144, 145, - 28, 72, 30, -1, -1, -1, -1, -1, 36, -1, - -1, 82, 40, 84, 85, -1, -1, -1, -1, -1, - 91, -1, 168, -1, -1, 53, -1, -1, -1, 57, - 58, -1, 60, -1, -1, 63, -1, 65, -1, -1, - -1, -1, -1, 114, 72, -1, -1, 118, 119, 120, - 121, -1, -1, 124, 82, 126, 84, 85, -1, 130, - -1, -1, -1, 91, -1, -1, 137, -1, 139, -1, - -1, -1, -1, 144, 145, 12, 13, 14, 15, 16, - 17, 18, 19, 20, -1, -1, 114, -1, -1, -1, - 118, 119, 120, 121, -1, -1, 124, 168, 126, -1, - -1, -1, 130, -1, -1, -1, -1, -1, -1, 137, - -1, 139, -1, -1, -1, -1, 144, 145, 12, 13, - 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, + -1, -1, -1, -1, -1, 114, 72, -1, -1, 118, + 119, 120, 121, -1, -1, 124, 82, 126, 84, 85, + -1, 130, -1, -1, -1, 91, -1, -1, 137, -1, + 139, -1, -1, -1, -1, 144, 145, 12, 13, 14, + 15, 16, 17, 18, 19, 20, -1, -1, 114, -1, + -1, -1, 118, 119, 120, 121, -1, -1, 124, 168, + 126, -1, -1, -1, 130, -1, -1, -1, -1, -1, + -1, 137, -1, 139, -1, -1, -1, -1, 144, 145, + 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 168, 12, 13, 14, 15, 16, 17, 18, 19, 20, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 12, 13, 14, 15, 16, 17, - 18, 19, 20, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 168, 12, 13, 14, 15, 16, 17, 18, + 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 12, 13, + 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 148, -1, 150, 151, 152, 153, 154, 155, 156, - 157, 158, 159, -1, -1, -1, -1, -1, -1, -1, - 167, 168, -1, -1, -1, 172, 12, 13, 14, 15, - 16, 17, 18, 19, 20, -1, -1, -1, -1, -1, + -1, -1, -1, 148, -1, 150, 151, 152, 153, 154, + 155, 156, 157, 158, 159, -1, -1, -1, -1, -1, + -1, -1, 167, 168, -1, -1, -1, 172, 12, 13, + 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 148, -1, 150, 151, + 152, 153, 154, 155, 156, 157, 158, 159, 12, 13, + 14, 15, 16, 17, 18, 167, 168, -1, -1, 148, + 172, 150, 151, 152, 153, 154, 155, 156, 157, 158, + 159, 12, 13, 14, 15, 16, 17, 18, 167, 168, + -1, -1, 148, 172, 150, 151, 152, 153, 154, 155, + 156, 157, 158, 159, 12, 13, 14, 15, 16, 17, + 18, 167, 168, 169, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, -1, -1, -1, -1, + -1, -1, -1, 167, 168, 12, 13, 14, 15, 16, + 17, 18, -1, 20, -1, -1, -1, -1, -1, -1, + -1, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1, 148, -1, 150, 151, 152, 153, - 154, 155, 156, 157, 158, 159, 12, 13, 14, 15, - 16, 17, 18, 167, 168, -1, -1, 148, 172, 150, - 151, 152, 153, 154, 155, 156, 157, 158, 159, 12, - 13, 14, 15, 16, 17, 18, 167, 168, -1, -1, - 148, 172, 150, 151, 152, 153, 154, 155, 156, 157, - 158, 159, 12, 13, 14, 15, 16, 17, 18, 167, - 168, 169, 148, 149, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 159, -1, -1, -1, -1, -1, -1, - -1, 167, 168, 12, 13, 14, 15, 16, 17, 18, - -1, 20, -1, -1, -1, -1, -1, -1, -1, 12, - 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, - -1, -1, 148, -1, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 159, -1, -1, -1, -1, -1, -1, - -1, 167, 168, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 159, -1, -1, -1, -1, -1, -1, - -1, 167, 168, -1, -1, -1, -1, -1, 151, 152, - 153, 154, 155, 156, 157, 158, 159, -1, -1, -1, - -1, -1, -1, -1, 167, 168, -1, -1, -1, -1, - -1, -1, 152, 153, 154, 155, 156, 157, 158, 159, - -1, -1, -1, -1, -1, -1, -1, 167, 168, -1, + 154, 155, 156, 157, 158, 159, -1, -1, -1, -1, + -1, -1, -1, 167, 168, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, -1, -1, -1, -1, + -1, -1, -1, 167, 168, -1, -1, -1, -1, -1, + 151, 152, 153, 154, 155, 156, 157, 158, 159, -1, + -1, -1, -1, -1, -1, -1, 167, 168, -1, -1, + -1, -1, -1, -1, 152, 153, 154, 155, 156, 157, + 158, 159, -1, -1, -1, -1, -1, -1, -1, 167, + 168, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 150, 151, 152, 153, 154, 155, 156, + 157, 158, 159, -1, 4, -1, -1, -1, -1, -1, + 167, 168, 153, 154, 155, 156, 157, 158, 159, -1, + -1, -1, -1, -1, -1, -1, 167, 168, 28, -1, + 30, -1, -1, -1, -1, -1, 36, 37, -1, -1, + 40, -1, -1, -1, -1, -1, -1, 4, -1, -1, + -1, 51, -1, 53, -1, -1, -1, 57, 58, -1, + 60, -1, -1, 63, -1, 65, -1, -1, -1, -1, + -1, 28, 72, 30, -1, -1, -1, -1, -1, 36, + -1, -1, 82, 40, 84, 85, 86, -1, -1, 89, + -1, 91, -1, 93, -1, -1, 53, -1, -1, -1, + 57, 58, -1, 60, -1, -1, 63, -1, 65, -1, + -1, -1, -1, -1, 114, 72, -1, 4, 118, 119, + 120, 121, -1, -1, 124, 82, 126, 84, 85, -1, + 130, -1, -1, -1, 91, -1, -1, 137, -1, 139, + -1, 28, -1, 30, 144, 145, -1, -1, -1, 36, + -1, -1, -1, -1, -1, -1, -1, 114, -1, -1, + -1, 118, 119, 120, 121, -1, 53, 124, -1, 126, + 57, 58, -1, 130, -1, -1, 63, -1, 65, -1, + 137, -1, 139, -1, -1, 72, -1, 144, 145, -1, + -1, -1, -1, -1, -1, -1, -1, 84, 85, -1, + -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 150, 151, 152, 153, 154, 155, 156, 157, 158, - 159, -1, 4, -1, -1, -1, -1, -1, 167, 168, - 153, 154, 155, 156, 157, 158, 159, -1, -1, -1, - -1, -1, -1, -1, 167, 168, 28, -1, 30, -1, - -1, -1, -1, -1, 36, 37, -1, -1, 40, -1, - -1, -1, -1, -1, -1, 4, -1, -1, -1, 51, - -1, 53, -1, -1, -1, 57, 58, -1, 60, -1, - -1, 63, -1, 65, -1, -1, -1, -1, -1, 28, - 72, 30, -1, -1, -1, -1, -1, 36, -1, -1, - 82, 40, 84, 85, 86, -1, -1, 89, -1, 91, - -1, 93, -1, -1, 53, -1, -1, -1, 57, 58, - -1, 60, -1, -1, 63, -1, 65, -1, -1, -1, - -1, -1, 114, 72, -1, 4, 118, 119, 120, 121, - -1, -1, 124, 82, 126, 84, 85, -1, 130, -1, - -1, -1, 91, -1, -1, 137, -1, 139, -1, 28, - -1, 30, 144, 145, -1, -1, -1, 36, -1, -1, - -1, -1, -1, -1, -1, 114, -1, -1, -1, 118, - 119, 120, 121, -1, 53, 124, -1, 126, 57, 58, - -1, 130, -1, -1, 63, -1, 65, -1, 137, -1, - 139, -1, -1, 72, -1, 144, 145, -1, -1, -1, - -1, -1, -1, -1, -1, 84, 85, -1, -1, -1, - -1, -1, 91, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 118, - 119, 120, 121, -1, -1, 124, -1, -1, -1, -1, - -1, 130, -1, -1, -1, -1, -1, -1, 137, -1, - 139, -1, -1, -1, -1, 144, 145, 21, -1, 23, - 24, -1, 26, 27, -1, 29, -1, -1, 32, -1, - 34, -1, -1, -1, -1, -1, -1, 41, 42, 43, - 44, -1, 46, 47, 48, 49, 50, -1, 52, -1, - 54, 55, 56, -1, -1, 59, -1, -1, -1, -1, - 64, -1, 66, 67, 68, 69, 70, 71, -1, 73, - 74, 75, 76, 77, -1, -1, 80, -1, -1, 83, - -1, -1, -1, 87, 88, -1, 90, -1, -1, -1, - 94, 95, 96, -1, 98, 99, 100, 101, 102, -1, - 104, -1, 106, 107, 108, 109, 110, 111, 112, 113, - -1, 115, 116, 117, -1, -1, -1, -1, 122, -1, - -1, 125, -1, -1, 128, 129, -1, -1, 132, 133, - 134, -1, -1, -1, 138, -1, 140, 141, 142, 143, - -1, -1, 146 + -1, 118, 119, 120, 121, -1, -1, 124, -1, -1, + -1, -1, -1, 130, -1, -1, -1, -1, -1, -1, + 137, -1, 139, -1, -1, -1, -1, 144, 145, 21, + -1, 23, 24, -1, 26, 27, -1, 29, -1, -1, + 32, -1, 34, -1, -1, -1, -1, -1, -1, 41, + 42, 43, 44, -1, 46, 47, 48, 49, 50, -1, + 52, -1, 54, 55, 56, -1, -1, 59, -1, -1, + -1, -1, 64, -1, 66, 67, 68, 69, 70, 71, + -1, 73, 74, 75, 76, 77, -1, -1, 80, -1, + -1, 83, -1, -1, -1, 87, 88, -1, 90, -1, + -1, -1, 94, 95, 96, -1, 98, 99, 100, 101, + 102, -1, 104, -1, 106, 107, 108, 109, 110, 111, + 112, 113, -1, 115, 116, 117, -1, -1, -1, -1, + 122, -1, -1, 125, -1, -1, 128, 129, -1, -1, + 132, 133, 134, -1, -1, -1, 138, -1, 140, 141, + 142, 143, -1, -1, 146 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -1765,40 +1756,40 @@ static const unsigned short int yystos[] = 240, 244, 251, 259, 262, 170, 170, 173, 170, 173, 170, 181, 170, 149, 239, 173, 252, 253, 252, 252, 3, 4, 35, 62, 103, 127, 157, 171, 202, 225, - 254, 255, 257, 260, 252, 170, 8, 173, 170, 260, - 173, 251, 131, 173, 171, 171, 171, 171, 171, 171, + 254, 255, 257, 208, 259, 260, 262, 252, 170, 8, + 173, 170, 260, 173, 251, 131, 173, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 147, - 169, 11, 79, 182, 187, 190, 229, 231, 242, 243, - 246, 174, 3, 3, 4, 173, 257, 232, 105, 236, - 240, 3, 4, 173, 180, 250, 254, 254, 175, 168, - 171, 195, 252, 172, 205, 206, 207, 225, 172, 215, - 254, 256, 171, 218, 225, 3, 5, 6, 7, 8, - 9, 61, 97, 123, 135, 152, 155, 156, 157, 160, - 161, 171, 211, 212, 213, 211, 214, 8, 8, 199, - 214, 213, 8, 8, 213, 8, 213, 211, 65, 213, - 209, 210, 211, 258, 213, 209, 211, 260, 260, 8, - 10, 201, 5, 263, 260, 200, 168, 171, 170, 181, - 174, 196, 233, 149, 92, 196, 220, 237, 170, 173, - 180, 174, 182, 197, 249, 254, 172, 214, 157, 210, - 144, 191, 192, 193, 194, 197, 251, 174, 147, 175, - 174, 196, 216, 147, 220, 174, 197, 217, 220, 172, - 171, 211, 211, 211, 211, 211, 211, 211, 260, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 148, 150, - 151, 152, 153, 154, 155, 156, 157, 158, 159, 167, - 168, 147, 172, 172, 172, 147, 172, 172, 172, 172, - 172, 172, 172, 172, 172, 3, 172, 147, 172, 172, - 147, 172, 172, 172, 172, 172, 167, 172, 172, 200, - 8, 181, 243, 149, 251, 170, 174, 196, 221, 174, - 186, 174, 181, 169, 169, 172, 147, 251, 254, 207, - 213, 251, 262, 254, 172, 170, 170, 260, 172, 172, - 211, 211, 3, 211, 211, 211, 211, 211, 211, 211, + 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, + 171, 171, 147, 169, 11, 79, 182, 187, 190, 229, + 231, 242, 243, 246, 174, 3, 3, 4, 173, 257, + 232, 105, 236, 240, 3, 4, 173, 180, 250, 254, + 254, 175, 168, 171, 195, 252, 172, 205, 206, 207, + 225, 172, 215, 254, 256, 171, 218, 225, 3, 5, + 6, 7, 8, 9, 61, 97, 123, 135, 152, 155, + 156, 157, 160, 161, 171, 211, 212, 213, 211, 214, + 8, 8, 199, 214, 213, 8, 8, 213, 8, 213, + 211, 65, 213, 209, 210, 211, 258, 213, 209, 211, + 260, 260, 8, 10, 201, 5, 263, 260, 200, 168, + 171, 170, 181, 174, 196, 233, 149, 92, 196, 220, + 237, 170, 173, 180, 174, 182, 197, 249, 254, 172, + 214, 157, 210, 144, 191, 192, 193, 194, 197, 251, + 174, 147, 175, 174, 196, 216, 147, 220, 174, 197, + 217, 220, 172, 171, 211, 211, 211, 211, 211, 211, + 211, 260, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 148, 150, 151, 152, 153, 154, 155, 156, 157, + 158, 159, 167, 168, 147, 172, 172, 172, 147, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 3, 172, + 147, 172, 172, 147, 172, 172, 172, 172, 172, 167, + 172, 172, 200, 8, 181, 243, 149, 251, 170, 174, + 196, 221, 174, 186, 174, 181, 169, 169, 172, 147, + 251, 254, 207, 213, 251, 262, 254, 172, 170, 170, + 260, 172, 172, 211, 211, 3, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, - 3, 211, 213, 8, 172, 210, 213, 5, 172, 254, - 251, 170, 180, 181, 194, 254, 256, 170, 223, 225, - 172, 211, 149, 169, 172, 181, 254, 174, 170, 173, - 211, 181, 203, 34, 46, 174, 204, 213, 149, 149, - 170, 219, 220, 219, 170 + 211, 211, 211, 3, 211, 213, 8, 172, 210, 213, + 5, 172, 254, 251, 170, 180, 181, 194, 254, 256, + 170, 223, 225, 172, 211, 149, 169, 172, 181, 254, + 174, 170, 173, 211, 181, 203, 34, 46, 174, 204, + 213, 149, 149, 170, 219, 220, 219, 170 }; #define yyerrok (yyerrstatus = 0) @@ -2468,13 +2459,16 @@ yyreduce: switch (yyn) { case 2: -#line 351 "parser.y" +#line 348 "parser.y" { fix_incomplete(); check_all_user_types((yyvsp[0].stmt_list)); + write_header((yyvsp[0].stmt_list)); + write_id_data((yyvsp[0].stmt_list)); write_proxies((yyvsp[0].stmt_list)); write_client((yyvsp[0].stmt_list)); write_server((yyvsp[0].stmt_list)); write_dlldata((yyvsp[0].stmt_list)); + write_local_stubs((yyvsp[0].stmt_list)); ;} break; @@ -2485,7 +2479,7 @@ yyreduce: case 4: #line 361 "parser.y" - { (yyval.stmt_list) = (yyvsp[-1].stmt_list); ;} + { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_reference((yyvsp[0].type))); ;} break; case 5: @@ -2497,134 +2491,135 @@ yyreduce: #line 363 "parser.y" { (yyval.stmt_list) = (yyvsp[-2].stmt_list); reg_type((yyvsp[-1].type), (yyvsp[-1].type)->name, 0); - if (!parse_only && do_header) write_coclass_forward((yyvsp[-1].type)); ;} break; case 7: -#line 367 "parser.y" +#line 366 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_type_decl((yyvsp[0].type))); - add_typelib_entry((yyvsp[0].type)); reg_type((yyvsp[0].type), (yyvsp[0].type)->name, 0); - if (!parse_only && do_header) write_coclass_forward((yyvsp[0].type)); ;} break; case 8: -#line 372 "parser.y" - { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_module((yyvsp[0].type))); - add_typelib_entry((yyvsp[0].type)); - ;} +#line 369 "parser.y" + { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_module((yyvsp[0].type))); ;} break; case 9: -#line 375 "parser.y" +#line 370 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_library((yyvsp[0].typelib))); ;} break; case 10: -#line 376 "parser.y" +#line 371 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), (yyvsp[0].statement)); ;} break; case 11: -#line 379 "parser.y" +#line 374 "parser.y" { (yyval.stmt_list) = NULL; ;} break; case 12: -#line 380 "parser.y" - { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_reference((yyvsp[0].type))); if (!parse_only) add_typelib_entry((yyvsp[0].type)); ;} +#line 375 "parser.y" + { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_reference((yyvsp[0].type))); ;} break; case 13: -#line 381 "parser.y" - { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_type_decl((yyvsp[0].type))); if (!parse_only) add_typelib_entry((yyvsp[0].type)); ;} +#line 376 "parser.y" + { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_type_decl((yyvsp[0].type))); ;} break; case 14: -#line 382 "parser.y" - { (yyval.stmt_list) = (yyvsp[-2].stmt_list); reg_type((yyvsp[-1].type), (yyvsp[-1].type)->name, 0); if (!parse_only && do_header) write_coclass_forward((yyvsp[-1].type)); ;} +#line 377 "parser.y" + { (yyval.stmt_list) = (yyvsp[-2].stmt_list); reg_type((yyvsp[-1].type), (yyvsp[-1].type)->name, 0); ;} break; case 15: -#line 383 "parser.y" +#line 378 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_type_decl((yyvsp[0].type))); - if (!parse_only) add_typelib_entry((yyvsp[0].type)); reg_type((yyvsp[0].type), (yyvsp[0].type)->name, 0); - if (!parse_only && do_header) write_coclass_forward((yyvsp[0].type)); ;} break; case 16: -#line 388 "parser.y" - { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_module((yyvsp[0].type))); if (!parse_only) add_typelib_entry((yyvsp[0].type)); ;} +#line 381 "parser.y" + { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_module((yyvsp[0].type))); ;} break; case 17: -#line 389 "parser.y" +#line 382 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), (yyvsp[0].statement)); ;} break; case 18: -#line 390 "parser.y" +#line 383 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_importlib((yyvsp[0].str))); ;} break; case 19: -#line 391 "parser.y" +#line 384 "parser.y" { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), make_statement_library((yyvsp[0].typelib))); ;} break; case 20: -#line 394 "parser.y" - { (yyval.func_list) = NULL; ;} +#line 387 "parser.y" + { (yyval.stmt_list) = NULL; ;} break; case 21: -#line 395 "parser.y" - { (yyval.func_list) = append_func_from_statement( (yyvsp[-1].func_list), (yyvsp[0].statement) ); ;} +#line 388 "parser.y" + { (yyval.stmt_list) = append_statement((yyvsp[-1].stmt_list), (yyvsp[0].statement)); ;} break; case 24: -#line 403 "parser.y" +#line 396 "parser.y" { (yyval.statement) = make_statement_cppquote((yyvsp[0].str)); ;} break; case 25: -#line 404 "parser.y" - { (yyval.statement) = make_statement_type_decl((yyvsp[-1].type)); - if (!parse_only && do_header) { - write_type_def_or_decl(header, (yyvsp[-1].type), FALSE, NULL); - fprintf(header, ";\n\n"); - } - ;} +#line 397 "parser.y" + { (yyval.statement) = make_statement_type_decl((yyvsp[-1].type)); ;} break; case 26: -#line 410 "parser.y" - { (yyval.statement) = make_statement_declaration((yyvsp[-1].var)); - if (!parse_only && do_header) write_declaration((yyvsp[-1].var), is_in_interface); - ;} +#line 398 "parser.y" + { (yyval.statement) = make_statement_declaration((yyvsp[-1].var)); ;} break; case 27: -#line 413 "parser.y" +#line 399 "parser.y" { (yyval.statement) = make_statement_import((yyvsp[0].str)); ;} break; case 28: -#line 414 "parser.y" +#line 400 "parser.y" { (yyval.statement) = (yyvsp[-1].statement); ;} break; case 32: -#line 423 "parser.y" - { (yyval.str) = (yyvsp[-1].str); if (!parse_only && do_header) fprintf(header, "%s\n", (yyvsp[-1].str)); ;} +#line 407 "parser.y" + { (yyval.type) = (yyvsp[0].type); (yyval.type)->attrs = check_enum_attrs((yyvsp[-1].attr_list)); ;} break; case 33: -#line 425 "parser.y" +#line 408 "parser.y" + { (yyval.type) = (yyvsp[0].type); (yyval.type)->attrs = check_struct_attrs((yyvsp[-1].attr_list)); ;} + break; + + case 34: +#line 409 "parser.y" + { (yyval.type) = (yyvsp[0].type); (yyval.type)->attrs = check_union_attrs((yyvsp[-1].attr_list)); ;} + break; + + case 35: +#line 412 "parser.y" + { (yyval.str) = (yyvsp[-1].str); ;} + break; + + case 36: +#line 414 "parser.y" { assert(yychar == YYEMPTY); (yyval.import) = xmalloc(sizeof(struct _import_t)); (yyval.import)->name = (yyvsp[-1].str); @@ -2633,37 +2628,34 @@ yyreduce: ;} break; - case 34: -#line 433 "parser.y" + case 37: +#line 422 "parser.y" { (yyval.str) = (yyvsp[-2].import)->name; if ((yyvsp[-2].import)->import_performed) pop_import(); free((yyvsp[-2].import)); - if (!parse_only && do_header) write_import((yyval.str)); - ;} - break; - - case 35: -#line 441 "parser.y" - { (yyval.str) = (yyvsp[-2].str); if(!parse_only) add_importlib((yyvsp[-2].str)); ;} - break; - - case 36: -#line 444 "parser.y" - { (yyval.str) = (yyvsp[0].str); ;} - break; - - case 37: -#line 446 "parser.y" - { (yyval.typelib) = make_library((yyvsp[-1].str), check_library_attrs((yyvsp[-1].str), (yyvsp[-2].attr_list))); - if (!parse_only) start_typelib((yyval.typelib)); - if (!parse_only && do_header) write_library((yyval.typelib)); - if (!parse_only && do_idfile) write_libid((yyval.typelib)); - is_inside_library = TRUE; ;} break; case 38: -#line 454 "parser.y" +#line 429 "parser.y" + { (yyval.str) = (yyvsp[-2].str); if(!parse_only) add_importlib((yyvsp[-2].str)); ;} + break; + + case 39: +#line 432 "parser.y" + { (yyval.str) = (yyvsp[0].str); ;} + break; + + case 40: +#line 434 "parser.y" + { (yyval.typelib) = make_library((yyvsp[-1].str), check_library_attrs((yyvsp[-1].str), (yyvsp[-2].attr_list))); + if (!parse_only) start_typelib((yyval.typelib)); + is_inside_library = TRUE; + ;} + break; + + case 41: +#line 440 "parser.y" { (yyval.typelib) = (yyvsp[-3].typelib); (yyval.typelib)->stmts = (yyvsp[-2].stmt_list); if (!parse_only) end_typelib(); @@ -2671,28 +2663,28 @@ yyreduce: ;} break; - case 39: -#line 461 "parser.y" - { (yyval.var_list) = NULL; ;} - break; - - case 41: -#line 465 "parser.y" - { (yyval.var_list) = NULL; ;} - break; - case 42: -#line 468 "parser.y" - { check_arg((yyvsp[0].var)); (yyval.var_list) = append_var( NULL, (yyvsp[0].var) ); ;} +#line 447 "parser.y" + { (yyval.var_list) = NULL; ;} break; - case 43: -#line 469 "parser.y" - { check_arg((yyvsp[0].var)); (yyval.var_list) = append_var( (yyvsp[-2].var_list), (yyvsp[0].var)); ;} + case 44: +#line 451 "parser.y" + { (yyval.var_list) = NULL; ;} break; case 45: -#line 474 "parser.y" +#line 454 "parser.y" + { check_arg((yyvsp[0].var)); (yyval.var_list) = append_var( NULL, (yyvsp[0].var) ); ;} + break; + + case 46: +#line 455 "parser.y" + { check_arg((yyvsp[0].var)); (yyval.var_list) = append_var( (yyvsp[-2].var_list), (yyvsp[0].var)); ;} + break; + + case 48: +#line 460 "parser.y" { (yyval.var) = (yyvsp[0].declarator)->var; (yyval.var)->attrs = (yyvsp[-2].attr_list); if ((yyvsp[-1].declspec)->stgclass != STG_NONE && (yyvsp[-1].declspec)->stgclass != STG_REGISTER) @@ -2702,8 +2694,8 @@ yyreduce: ;} break; - case 46: -#line 481 "parser.y" + case 49: +#line 467 "parser.y" { (yyval.var) = (yyvsp[0].declarator)->var; if ((yyvsp[-1].declspec)->stgclass != STG_NONE && (yyvsp[-1].declspec)->stgclass != STG_REGISTER) error_loc("invalid storage class for function parameter\n"); @@ -2712,484 +2704,481 @@ yyreduce: ;} break; - case 47: -#line 489 "parser.y" + case 50: +#line 475 "parser.y" { (yyval.expr) = (yyvsp[-1].expr); ;} break; - case 48: -#line 490 "parser.y" + case 51: +#line 476 "parser.y" { (yyval.expr) = make_expr(EXPR_VOID); ;} break; - case 49: -#line 493 "parser.y" + case 52: +#line 479 "parser.y" { (yyval.attr_list) = NULL; ;} break; - case 51: -#line 498 "parser.y" - { (yyval.attr_list) = (yyvsp[-1].attr_list); - if (!(yyval.attr_list)) - error_loc("empty attribute lists unsupported\n"); - ;} - break; - - case 52: -#line 504 "parser.y" - { (yyval.attr_list) = append_attr( NULL, (yyvsp[0].attr) ); ;} - break; - - case 53: -#line 505 "parser.y" - { (yyval.attr_list) = append_attr( (yyvsp[-2].attr_list), (yyvsp[0].attr) ); ;} - break; - case 54: -#line 506 "parser.y" - { (yyval.attr_list) = append_attr( (yyvsp[-3].attr_list), (yyvsp[0].attr) ); ;} +#line 484 "parser.y" + { (yyval.attr_list) = (yyvsp[-1].attr_list); ;} break; case 55: -#line 509 "parser.y" - { (yyval.str_list) = append_str( NULL, (yyvsp[0].str) ); ;} +#line 487 "parser.y" + { (yyval.attr_list) = append_attr( NULL, (yyvsp[0].attr) ); ;} break; case 56: -#line 510 "parser.y" - { (yyval.str_list) = append_str( (yyvsp[-2].str_list), (yyvsp[0].str) ); ;} +#line 488 "parser.y" + { (yyval.attr_list) = append_attr( (yyvsp[-2].attr_list), (yyvsp[0].attr) ); ;} break; case 57: -#line 513 "parser.y" - { (yyval.attr) = NULL; ;} +#line 489 "parser.y" + { (yyval.attr_list) = append_attr( (yyvsp[-3].attr_list), (yyvsp[0].attr) ); ;} break; case 58: -#line 514 "parser.y" - { (yyval.attr) = make_attr(ATTR_AGGREGATABLE); ;} +#line 492 "parser.y" + { (yyval.str_list) = append_str( NULL, (yyvsp[0].str) ); ;} break; case 59: -#line 515 "parser.y" - { (yyval.attr) = make_attr(ATTR_APPOBJECT); ;} +#line 493 "parser.y" + { (yyval.str_list) = append_str( (yyvsp[-2].str_list), (yyvsp[0].str) ); ;} break; case 60: -#line 516 "parser.y" - { (yyval.attr) = make_attr(ATTR_ASYNC); ;} +#line 496 "parser.y" + { (yyval.attr) = NULL; ;} break; case 61: -#line 517 "parser.y" - { (yyval.attr) = make_attr(ATTR_AUTO_HANDLE); ;} +#line 497 "parser.y" + { (yyval.attr) = make_attr(ATTR_AGGREGATABLE); ;} break; case 62: -#line 518 "parser.y" - { (yyval.attr) = make_attr(ATTR_BINDABLE); ;} +#line 498 "parser.y" + { (yyval.attr) = make_attr(ATTR_APPOBJECT); ;} break; case 63: -#line 519 "parser.y" - { (yyval.attr) = make_attr(ATTR_BROADCAST); ;} +#line 499 "parser.y" + { (yyval.attr) = make_attr(ATTR_ASYNC); ;} break; case 64: -#line 520 "parser.y" - { (yyval.attr) = make_attrp(ATTR_CALLAS, (yyvsp[-1].var)); ;} +#line 500 "parser.y" + { (yyval.attr) = make_attr(ATTR_AUTO_HANDLE); ;} break; case 65: -#line 521 "parser.y" - { (yyval.attr) = make_attrp(ATTR_CASE, (yyvsp[-1].expr_list)); ;} +#line 501 "parser.y" + { (yyval.attr) = make_attr(ATTR_BINDABLE); ;} break; case 66: -#line 522 "parser.y" - { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); ;} +#line 502 "parser.y" + { (yyval.attr) = make_attr(ATTR_BROADCAST); ;} break; case 67: -#line 523 "parser.y" - { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ ;} +#line 503 "parser.y" + { (yyval.attr) = make_attrp(ATTR_CALLAS, (yyvsp[-1].var)); ;} break; case 68: -#line 524 "parser.y" - { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ ;} +#line 504 "parser.y" + { (yyval.attr) = make_attrp(ATTR_CASE, (yyvsp[-1].expr_list)); ;} break; case 69: -#line 525 "parser.y" - { (yyval.attr) = make_attr(ATTR_CONTROL); ;} +#line 505 "parser.y" + { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); ;} break; case 70: -#line 526 "parser.y" - { (yyval.attr) = make_attr(ATTR_DEFAULT); ;} +#line 506 "parser.y" + { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ ;} break; case 71: -#line 527 "parser.y" - { (yyval.attr) = make_attr(ATTR_DEFAULTCOLLELEM); ;} +#line 507 "parser.y" + { (yyval.attr) = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ ;} break; case 72: -#line 528 "parser.y" - { (yyval.attr) = make_attrp(ATTR_DEFAULTVALUE, (yyvsp[-1].expr)); ;} +#line 508 "parser.y" + { (yyval.attr) = make_attr(ATTR_CONTROL); ;} break; case 73: -#line 529 "parser.y" - { (yyval.attr) = make_attr(ATTR_DEFAULTVTABLE); ;} +#line 509 "parser.y" + { (yyval.attr) = make_attr(ATTR_DEFAULT); ;} break; case 74: -#line 530 "parser.y" - { (yyval.attr) = make_attr(ATTR_DISPLAYBIND); ;} +#line 510 "parser.y" + { (yyval.attr) = make_attr(ATTR_DEFAULTCOLLELEM); ;} break; case 75: -#line 531 "parser.y" - { (yyval.attr) = make_attrp(ATTR_DLLNAME, (yyvsp[-1].str)); ;} +#line 511 "parser.y" + { (yyval.attr) = make_attrp(ATTR_DEFAULTVALUE, (yyvsp[-1].expr)); ;} break; case 76: -#line 532 "parser.y" - { (yyval.attr) = make_attr(ATTR_DUAL); ;} +#line 512 "parser.y" + { (yyval.attr) = make_attr(ATTR_DEFAULTVTABLE); ;} break; case 77: -#line 533 "parser.y" - { (yyval.attr) = make_attrp(ATTR_ENDPOINT, (yyvsp[-1].str_list)); ;} +#line 513 "parser.y" + { (yyval.attr) = make_attr(ATTR_DISPLAYBIND); ;} break; case 78: -#line 534 "parser.y" - { (yyval.attr) = make_attrp(ATTR_ENTRY, (yyvsp[-1].expr)); ;} +#line 514 "parser.y" + { (yyval.attr) = make_attrp(ATTR_DLLNAME, (yyvsp[-1].str)); ;} break; case 79: -#line 535 "parser.y" - { (yyval.attr) = make_attr(ATTR_EXPLICIT_HANDLE); ;} +#line 515 "parser.y" + { (yyval.attr) = make_attr(ATTR_DUAL); ;} break; case 80: -#line 536 "parser.y" - { (yyval.attr) = make_attr(ATTR_HANDLE); ;} +#line 516 "parser.y" + { (yyval.attr) = make_attrp(ATTR_ENDPOINT, (yyvsp[-1].str_list)); ;} break; case 81: -#line 537 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPCONTEXT, (yyvsp[-1].expr)); ;} +#line 517 "parser.y" + { (yyval.attr) = make_attrp(ATTR_ENTRY, (yyvsp[-1].expr)); ;} break; case 82: -#line 538 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPFILE, (yyvsp[-1].str)); ;} +#line 518 "parser.y" + { (yyval.attr) = make_attr(ATTR_EXPLICIT_HANDLE); ;} break; case 83: -#line 539 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPSTRING, (yyvsp[-1].str)); ;} +#line 519 "parser.y" + { (yyval.attr) = make_attr(ATTR_HANDLE); ;} break; case 84: -#line 540 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPSTRINGCONTEXT, (yyvsp[-1].expr)); ;} +#line 520 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPCONTEXT, (yyvsp[-1].expr)); ;} break; case 85: -#line 541 "parser.y" - { (yyval.attr) = make_attrp(ATTR_HELPSTRINGDLL, (yyvsp[-1].str)); ;} +#line 521 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPFILE, (yyvsp[-1].str)); ;} break; case 86: -#line 542 "parser.y" - { (yyval.attr) = make_attr(ATTR_HIDDEN); ;} +#line 522 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPSTRING, (yyvsp[-1].str)); ;} break; case 87: -#line 543 "parser.y" - { (yyval.attr) = make_attrp(ATTR_ID, (yyvsp[-1].expr)); ;} +#line 523 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPSTRINGCONTEXT, (yyvsp[-1].expr)); ;} break; case 88: -#line 544 "parser.y" - { (yyval.attr) = make_attr(ATTR_IDEMPOTENT); ;} +#line 524 "parser.y" + { (yyval.attr) = make_attrp(ATTR_HELPSTRINGDLL, (yyvsp[-1].str)); ;} break; case 89: -#line 545 "parser.y" - { (yyval.attr) = make_attrp(ATTR_IIDIS, (yyvsp[-1].expr)); ;} +#line 525 "parser.y" + { (yyval.attr) = make_attr(ATTR_HIDDEN); ;} break; case 90: -#line 546 "parser.y" - { (yyval.attr) = make_attr(ATTR_IMMEDIATEBIND); ;} +#line 526 "parser.y" + { (yyval.attr) = make_attrp(ATTR_ID, (yyvsp[-1].expr)); ;} break; case 91: -#line 547 "parser.y" - { (yyval.attr) = make_attrp(ATTR_IMPLICIT_HANDLE, (yyvsp[-1].str)); ;} +#line 527 "parser.y" + { (yyval.attr) = make_attr(ATTR_IDEMPOTENT); ;} break; case 92: -#line 548 "parser.y" - { (yyval.attr) = make_attr(ATTR_IN); ;} +#line 528 "parser.y" + { (yyval.attr) = make_attrp(ATTR_IIDIS, (yyvsp[-1].expr)); ;} break; case 93: -#line 549 "parser.y" - { (yyval.attr) = make_attr(ATTR_INPUTSYNC); ;} +#line 529 "parser.y" + { (yyval.attr) = make_attr(ATTR_IMMEDIATEBIND); ;} break; case 94: -#line 550 "parser.y" - { (yyval.attr) = make_attrp(ATTR_LENGTHIS, (yyvsp[-1].expr_list)); ;} +#line 530 "parser.y" + { (yyval.attr) = make_attrp(ATTR_IMPLICIT_HANDLE, (yyvsp[-1].str)); ;} break; case 95: -#line 551 "parser.y" - { (yyval.attr) = make_attrp(ATTR_LIBLCID, (yyvsp[-1].expr)); ;} +#line 531 "parser.y" + { (yyval.attr) = make_attr(ATTR_IN); ;} break; case 96: -#line 552 "parser.y" - { (yyval.attr) = make_attr(ATTR_LOCAL); ;} +#line 532 "parser.y" + { (yyval.attr) = make_attr(ATTR_INPUTSYNC); ;} break; case 97: -#line 553 "parser.y" - { (yyval.attr) = make_attr(ATTR_NONBROWSABLE); ;} +#line 533 "parser.y" + { (yyval.attr) = make_attrp(ATTR_LENGTHIS, (yyvsp[-1].expr_list)); ;} break; case 98: -#line 554 "parser.y" - { (yyval.attr) = make_attr(ATTR_NONCREATABLE); ;} +#line 534 "parser.y" + { (yyval.attr) = make_attrp(ATTR_LIBLCID, (yyvsp[-1].expr)); ;} break; case 99: -#line 555 "parser.y" - { (yyval.attr) = make_attr(ATTR_NONEXTENSIBLE); ;} +#line 535 "parser.y" + { (yyval.attr) = make_attr(ATTR_LOCAL); ;} break; case 100: -#line 556 "parser.y" - { (yyval.attr) = make_attr(ATTR_OBJECT); ;} +#line 536 "parser.y" + { (yyval.attr) = make_attr(ATTR_NONBROWSABLE); ;} break; case 101: -#line 557 "parser.y" - { (yyval.attr) = make_attr(ATTR_ODL); ;} +#line 537 "parser.y" + { (yyval.attr) = make_attr(ATTR_NONCREATABLE); ;} break; case 102: -#line 558 "parser.y" - { (yyval.attr) = make_attr(ATTR_OLEAUTOMATION); ;} +#line 538 "parser.y" + { (yyval.attr) = make_attr(ATTR_NONEXTENSIBLE); ;} break; case 103: -#line 559 "parser.y" - { (yyval.attr) = make_attr(ATTR_OPTIONAL); ;} +#line 539 "parser.y" + { (yyval.attr) = make_attr(ATTR_OBJECT); ;} break; case 104: -#line 560 "parser.y" - { (yyval.attr) = make_attr(ATTR_OUT); ;} +#line 540 "parser.y" + { (yyval.attr) = make_attr(ATTR_ODL); ;} break; case 105: -#line 561 "parser.y" - { (yyval.attr) = make_attrv(ATTR_POINTERDEFAULT, (yyvsp[-1].num)); ;} +#line 541 "parser.y" + { (yyval.attr) = make_attr(ATTR_OLEAUTOMATION); ;} break; case 106: -#line 562 "parser.y" - { (yyval.attr) = make_attr(ATTR_PROPGET); ;} +#line 542 "parser.y" + { (yyval.attr) = make_attr(ATTR_OPTIONAL); ;} break; case 107: -#line 563 "parser.y" - { (yyval.attr) = make_attr(ATTR_PROPPUT); ;} +#line 543 "parser.y" + { (yyval.attr) = make_attr(ATTR_OUT); ;} break; case 108: -#line 564 "parser.y" - { (yyval.attr) = make_attr(ATTR_PROPPUTREF); ;} +#line 544 "parser.y" + { (yyval.attr) = make_attrv(ATTR_POINTERDEFAULT, (yyvsp[-1].num)); ;} break; case 109: -#line 565 "parser.y" - { (yyval.attr) = make_attr(ATTR_PUBLIC); ;} +#line 545 "parser.y" + { (yyval.attr) = make_attr(ATTR_PROPGET); ;} break; case 110: -#line 567 "parser.y" +#line 546 "parser.y" + { (yyval.attr) = make_attr(ATTR_PROPPUT); ;} + break; + + case 111: +#line 547 "parser.y" + { (yyval.attr) = make_attr(ATTR_PROPPUTREF); ;} + break; + + case 112: +#line 548 "parser.y" + { (yyval.attr) = make_attr(ATTR_PUBLIC); ;} + break; + + case 113: +#line 550 "parser.y" { expr_list_t *list = append_expr( NULL, (yyvsp[-3].expr) ); list = append_expr( list, (yyvsp[-1].expr) ); (yyval.attr) = make_attrp(ATTR_RANGE, list); ;} break; - case 111: -#line 570 "parser.y" + case 114: +#line 553 "parser.y" { (yyval.attr) = make_attr(ATTR_READONLY); ;} break; - case 112: -#line 571 "parser.y" + case 115: +#line 554 "parser.y" { (yyval.attr) = make_attr(ATTR_REQUESTEDIT); ;} break; - case 113: -#line 572 "parser.y" + case 116: +#line 555 "parser.y" { (yyval.attr) = make_attr(ATTR_RESTRICTED); ;} break; - case 114: -#line 573 "parser.y" + case 117: +#line 556 "parser.y" { (yyval.attr) = make_attr(ATTR_RETVAL); ;} break; - case 115: -#line 574 "parser.y" + case 118: +#line 557 "parser.y" { (yyval.attr) = make_attrp(ATTR_SIZEIS, (yyvsp[-1].expr_list)); ;} break; - case 116: -#line 575 "parser.y" + case 119: +#line 558 "parser.y" { (yyval.attr) = make_attr(ATTR_SOURCE); ;} break; - case 117: -#line 576 "parser.y" + case 120: +#line 559 "parser.y" { (yyval.attr) = make_attr(ATTR_STRICTCONTEXTHANDLE); ;} break; - case 118: -#line 577 "parser.y" + case 121: +#line 560 "parser.y" { (yyval.attr) = make_attr(ATTR_STRING); ;} break; - case 119: -#line 578 "parser.y" + case 122: +#line 561 "parser.y" { (yyval.attr) = make_attrp(ATTR_SWITCHIS, (yyvsp[-1].expr)); ;} break; - case 120: -#line 579 "parser.y" + case 123: +#line 562 "parser.y" { (yyval.attr) = make_attrp(ATTR_SWITCHTYPE, (yyvsp[-1].type)); ;} break; - case 121: -#line 580 "parser.y" + case 124: +#line 563 "parser.y" { (yyval.attr) = make_attrp(ATTR_TRANSMITAS, (yyvsp[-1].type)); ;} break; - case 122: -#line 581 "parser.y" + case 125: +#line 564 "parser.y" { (yyval.attr) = make_attrp(ATTR_UUID, (yyvsp[-1].uuid)); ;} break; - case 123: -#line 582 "parser.y" + case 126: +#line 565 "parser.y" { (yyval.attr) = make_attr(ATTR_V1ENUM); ;} break; - case 124: -#line 583 "parser.y" + case 127: +#line 566 "parser.y" { (yyval.attr) = make_attr(ATTR_VARARG); ;} break; - case 125: -#line 584 "parser.y" + case 128: +#line 567 "parser.y" { (yyval.attr) = make_attrv(ATTR_VERSION, (yyvsp[-1].num)); ;} break; - case 126: -#line 585 "parser.y" + case 129: +#line 568 "parser.y" { (yyval.attr) = make_attrp(ATTR_WIREMARSHAL, (yyvsp[-1].type)); ;} break; - case 127: -#line 586 "parser.y" + case 130: +#line 569 "parser.y" { (yyval.attr) = make_attrv(ATTR_POINTERTYPE, (yyvsp[0].num)); ;} break; - case 129: -#line 591 "parser.y" + case 132: +#line 574 "parser.y" { if (!is_valid_uuid((yyvsp[0].str))) error_loc("invalid UUID: %s\n", (yyvsp[0].str)); (yyval.uuid) = parse_uuid((yyvsp[0].str)); ;} break; - case 130: -#line 596 "parser.y" - { (yyval.str) = (yyvsp[0].str); ;} - break; - - case 131: -#line 597 "parser.y" - { (yyval.str) = (yyvsp[0].str); ;} - break; - - case 132: -#line 598 "parser.y" - { (yyval.str) = (yyvsp[0].str); ;} - break; - case 133: -#line 599 "parser.y" +#line 579 "parser.y" { (yyval.str) = (yyvsp[0].str); ;} break; case 134: -#line 602 "parser.y" - { (yyval.var_list) = NULL; ;} +#line 580 "parser.y" + { (yyval.str) = (yyvsp[0].str); ;} break; case 135: -#line 603 "parser.y" - { (yyval.var_list) = append_var( (yyvsp[-1].var_list), (yyvsp[0].var) ); ;} +#line 581 "parser.y" + { (yyval.str) = (yyvsp[0].str); ;} break; case 136: -#line 606 "parser.y" +#line 582 "parser.y" + { (yyval.str) = (yyvsp[0].str); ;} + break; + + case 137: +#line 585 "parser.y" + { (yyval.var_list) = NULL; ;} + break; + + case 138: +#line 586 "parser.y" + { (yyval.var_list) = append_var( (yyvsp[-1].var_list), (yyvsp[0].var) ); ;} + break; + + case 139: +#line 589 "parser.y" { attr_t *a = make_attrp(ATTR_CASE, append_expr( NULL, (yyvsp[-2].expr) )); (yyval.var) = (yyvsp[0].var); if (!(yyval.var)) (yyval.var) = make_var(NULL); (yyval.var)->attrs = append_attr( (yyval.var)->attrs, a ); ;} break; - case 137: -#line 610 "parser.y" + case 140: +#line 593 "parser.y" { attr_t *a = make_attr(ATTR_DEFAULT); (yyval.var) = (yyvsp[0].var); if (!(yyval.var)) (yyval.var) = make_var(NULL); (yyval.var)->attrs = append_attr( (yyval.var)->attrs, a ); ;} break; - case 138: -#line 616 "parser.y" + case 141: +#line 599 "parser.y" { (yyval.var_list) = NULL; ;} break; - case 139: -#line 617 "parser.y" + case 142: +#line 600 "parser.y" { (yyval.var_list) = (yyvsp[-1].var_list); ;} break; - case 141: -#line 621 "parser.y" + case 144: +#line 604 "parser.y" { if (!(yyvsp[0].var)->eval) (yyvsp[0].var)->eval = make_exprl(EXPR_NUM, 0 /* default for first enum entry */); (yyval.var_list) = append_var( NULL, (yyvsp[0].var) ); ;} break; - case 142: -#line 625 "parser.y" + case 145: +#line 608 "parser.y" { if (!(yyvsp[0].var)->eval) { var_t *last = LIST_ENTRY( list_tail((yyval.var_list)), var_t, entry ); @@ -3199,331 +3188,325 @@ yyreduce: ;} break; - case 143: -#line 634 "parser.y" + case 146: +#line 617 "parser.y" { (yyval.var) = reg_const((yyvsp[-2].var)); (yyval.var)->eval = (yyvsp[0].expr); (yyval.var)->type = make_int(0); ;} break; - case 144: -#line 638 "parser.y" + case 147: +#line 621 "parser.y" { (yyval.var) = reg_const((yyvsp[0].var)); (yyval.var)->type = make_int(0); ;} break; - case 145: -#line 643 "parser.y" - { (yyval.type) = get_typev(RPC_FC_ENUM16, (yyvsp[-3].var), tsENUM); - (yyval.type)->kind = TKIND_ENUM; - (yyval.type)->fields_or_args = (yyvsp[-1].var_list); - (yyval.type)->defined = TRUE; - if(in_typelib) - add_typelib_entry((yyval.type)); - ;} - break; - - case 146: -#line 652 "parser.y" - { (yyval.expr_list) = append_expr( NULL, (yyvsp[0].expr) ); ;} - break; - - case 147: -#line 653 "parser.y" - { (yyval.expr_list) = append_expr( (yyvsp[-2].expr_list), (yyvsp[0].expr) ); ;} - break; - case 148: -#line 666 "parser.y" - { (yyval.expr) = make_expr(EXPR_VOID); ;} +#line 626 "parser.y" + { (yyval.type) = type_new_enum((yyvsp[-3].str), (yyvsp[-1].var_list)); ;} + break; + + case 149: +#line 629 "parser.y" + { (yyval.expr_list) = append_expr( NULL, (yyvsp[0].expr) ); ;} break; case 150: -#line 670 "parser.y" - { (yyval.expr) = make_exprl(EXPR_NUM, (yyvsp[0].num)); ;} - break; - - case 151: -#line 671 "parser.y" - { (yyval.expr) = make_exprl(EXPR_HEXNUM, (yyvsp[0].num)); ;} - break; - - case 152: -#line 672 "parser.y" - { (yyval.expr) = make_exprd(EXPR_DOUBLE, (yyvsp[0].dbl)); ;} - break; - - case 153: -#line 673 "parser.y" - { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 0); ;} - break; - - case 154: -#line 674 "parser.y" - { (yyval.expr) = make_exprl(EXPR_NUM, 0); ;} - break; - - case 155: -#line 675 "parser.y" - { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 1); ;} - break; - - case 156: -#line 676 "parser.y" - { (yyval.expr) = make_exprs(EXPR_STRLIT, (yyvsp[0].str)); ;} - break; - - case 157: -#line 677 "parser.y" - { (yyval.expr) = make_exprs(EXPR_WSTRLIT, (yyvsp[0].str)); ;} - break; - - case 158: -#line 678 "parser.y" - { (yyval.expr) = make_exprs(EXPR_IDENTIFIER, (yyvsp[0].str)); ;} - break; - - case 159: -#line 679 "parser.y" - { (yyval.expr) = make_expr3(EXPR_COND, (yyvsp[-4].expr), (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 160: -#line 680 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LOGOR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 161: -#line 681 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LOGAND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 162: -#line 682 "parser.y" - { (yyval.expr) = make_expr2(EXPR_OR , (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 163: -#line 683 "parser.y" - { (yyval.expr) = make_expr2(EXPR_XOR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 164: -#line 684 "parser.y" - { (yyval.expr) = make_expr2(EXPR_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 165: -#line 685 "parser.y" - { (yyval.expr) = make_expr2(EXPR_EQUALITY, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 166: -#line 686 "parser.y" - { (yyval.expr) = make_expr2(EXPR_INEQUALITY, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 167: -#line 687 "parser.y" - { (yyval.expr) = make_expr2(EXPR_GTR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 168: -#line 688 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LESS, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 169: -#line 689 "parser.y" - { (yyval.expr) = make_expr2(EXPR_GTREQL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 170: -#line 690 "parser.y" - { (yyval.expr) = make_expr2(EXPR_LESSEQL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 171: -#line 691 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SHL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 172: -#line 692 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SHR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 173: -#line 693 "parser.y" - { (yyval.expr) = make_expr2(EXPR_ADD, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 174: -#line 694 "parser.y" - { (yyval.expr) = make_expr2(EXPR_SUB, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 175: -#line 695 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MOD, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 176: -#line 696 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MUL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 177: -#line 697 "parser.y" - { (yyval.expr) = make_expr2(EXPR_DIV, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 178: -#line 698 "parser.y" - { (yyval.expr) = make_expr1(EXPR_LOGNOT, (yyvsp[0].expr)); ;} - break; - - case 179: -#line 699 "parser.y" - { (yyval.expr) = make_expr1(EXPR_NOT, (yyvsp[0].expr)); ;} - break; - - case 180: -#line 700 "parser.y" - { (yyval.expr) = make_expr1(EXPR_POS, (yyvsp[0].expr)); ;} - break; - - case 181: -#line 701 "parser.y" - { (yyval.expr) = make_expr1(EXPR_NEG, (yyvsp[0].expr)); ;} - break; - - case 182: -#line 702 "parser.y" - { (yyval.expr) = make_expr1(EXPR_ADDRESSOF, (yyvsp[0].expr)); ;} - break; - - case 183: -#line 703 "parser.y" - { (yyval.expr) = make_expr1(EXPR_PPTR, (yyvsp[0].expr)); ;} - break; - - case 184: -#line 704 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, (yyvsp[-2].expr)), make_exprs(EXPR_IDENTIFIER, (yyvsp[0].str))); ;} - break; - - case 185: -#line 705 "parser.y" - { (yyval.expr) = make_expr2(EXPR_MEMBER, (yyvsp[-2].expr), make_exprs(EXPR_IDENTIFIER, (yyvsp[0].str))); ;} - break; - - case 186: -#line 706 "parser.y" - { (yyval.expr) = make_exprt(EXPR_CAST, (yyvsp[-2].type), (yyvsp[0].expr)); ;} - break; - - case 187: -#line 707 "parser.y" - { (yyval.expr) = make_exprt(EXPR_SIZEOF, (yyvsp[-1].type), NULL); ;} - break; - - case 188: -#line 708 "parser.y" - { (yyval.expr) = make_expr2(EXPR_ARRAY, (yyvsp[-3].expr), (yyvsp[-1].expr)); ;} - break; - - case 189: -#line 709 "parser.y" - { (yyval.expr) = (yyvsp[-1].expr); ;} - break; - - case 190: -#line 712 "parser.y" - { (yyval.expr_list) = append_expr( NULL, (yyvsp[0].expr) ); ;} - break; - - case 191: -#line 713 "parser.y" +#line 630 "parser.y" { (yyval.expr_list) = append_expr( (yyvsp[-2].expr_list), (yyvsp[0].expr) ); ;} break; + case 151: +#line 643 "parser.y" + { (yyval.expr) = make_expr(EXPR_VOID); ;} + break; + + case 153: +#line 647 "parser.y" + { (yyval.expr) = make_exprl(EXPR_NUM, (yyvsp[0].num)); ;} + break; + + case 154: +#line 648 "parser.y" + { (yyval.expr) = make_exprl(EXPR_HEXNUM, (yyvsp[0].num)); ;} + break; + + case 155: +#line 649 "parser.y" + { (yyval.expr) = make_exprd(EXPR_DOUBLE, (yyvsp[0].dbl)); ;} + break; + + case 156: +#line 650 "parser.y" + { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 0); ;} + break; + + case 157: +#line 651 "parser.y" + { (yyval.expr) = make_exprl(EXPR_NUM, 0); ;} + break; + + case 158: +#line 652 "parser.y" + { (yyval.expr) = make_exprl(EXPR_TRUEFALSE, 1); ;} + break; + + case 159: +#line 653 "parser.y" + { (yyval.expr) = make_exprs(EXPR_STRLIT, (yyvsp[0].str)); ;} + break; + + case 160: +#line 654 "parser.y" + { (yyval.expr) = make_exprs(EXPR_WSTRLIT, (yyvsp[0].str)); ;} + break; + + case 161: +#line 655 "parser.y" + { (yyval.expr) = make_exprs(EXPR_IDENTIFIER, (yyvsp[0].str)); ;} + break; + + case 162: +#line 656 "parser.y" + { (yyval.expr) = make_expr3(EXPR_COND, (yyvsp[-4].expr), (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 163: +#line 657 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LOGOR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 164: +#line 658 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LOGAND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 165: +#line 659 "parser.y" + { (yyval.expr) = make_expr2(EXPR_OR , (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 166: +#line 660 "parser.y" + { (yyval.expr) = make_expr2(EXPR_XOR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 167: +#line 661 "parser.y" + { (yyval.expr) = make_expr2(EXPR_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 168: +#line 662 "parser.y" + { (yyval.expr) = make_expr2(EXPR_EQUALITY, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 169: +#line 663 "parser.y" + { (yyval.expr) = make_expr2(EXPR_INEQUALITY, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 170: +#line 664 "parser.y" + { (yyval.expr) = make_expr2(EXPR_GTR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 171: +#line 665 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LESS, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 172: +#line 666 "parser.y" + { (yyval.expr) = make_expr2(EXPR_GTREQL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 173: +#line 667 "parser.y" + { (yyval.expr) = make_expr2(EXPR_LESSEQL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 174: +#line 668 "parser.y" + { (yyval.expr) = make_expr2(EXPR_SHL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 175: +#line 669 "parser.y" + { (yyval.expr) = make_expr2(EXPR_SHR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 176: +#line 670 "parser.y" + { (yyval.expr) = make_expr2(EXPR_ADD, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 177: +#line 671 "parser.y" + { (yyval.expr) = make_expr2(EXPR_SUB, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 178: +#line 672 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MOD, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 179: +#line 673 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MUL, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 180: +#line 674 "parser.y" + { (yyval.expr) = make_expr2(EXPR_DIV, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} + break; + + case 181: +#line 675 "parser.y" + { (yyval.expr) = make_expr1(EXPR_LOGNOT, (yyvsp[0].expr)); ;} + break; + + case 182: +#line 676 "parser.y" + { (yyval.expr) = make_expr1(EXPR_NOT, (yyvsp[0].expr)); ;} + break; + + case 183: +#line 677 "parser.y" + { (yyval.expr) = make_expr1(EXPR_POS, (yyvsp[0].expr)); ;} + break; + + case 184: +#line 678 "parser.y" + { (yyval.expr) = make_expr1(EXPR_NEG, (yyvsp[0].expr)); ;} + break; + + case 185: +#line 679 "parser.y" + { (yyval.expr) = make_expr1(EXPR_ADDRESSOF, (yyvsp[0].expr)); ;} + break; + + case 186: +#line 680 "parser.y" + { (yyval.expr) = make_expr1(EXPR_PPTR, (yyvsp[0].expr)); ;} + break; + + case 187: +#line 681 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, (yyvsp[-2].expr)), make_exprs(EXPR_IDENTIFIER, (yyvsp[0].str))); ;} + break; + + case 188: +#line 682 "parser.y" + { (yyval.expr) = make_expr2(EXPR_MEMBER, (yyvsp[-2].expr), make_exprs(EXPR_IDENTIFIER, (yyvsp[0].str))); ;} + break; + + case 189: +#line 683 "parser.y" + { (yyval.expr) = make_exprt(EXPR_CAST, (yyvsp[-2].type), (yyvsp[0].expr)); ;} + break; + + case 190: +#line 684 "parser.y" + { (yyval.expr) = make_exprt(EXPR_SIZEOF, (yyvsp[-1].type), NULL); ;} + break; + + case 191: +#line 685 "parser.y" + { (yyval.expr) = make_expr2(EXPR_ARRAY, (yyvsp[-3].expr), (yyvsp[-1].expr)); ;} + break; + case 192: -#line 716 "parser.y" +#line 686 "parser.y" + { (yyval.expr) = (yyvsp[-1].expr); ;} + break; + + case 193: +#line 689 "parser.y" + { (yyval.expr_list) = append_expr( NULL, (yyvsp[0].expr) ); ;} + break; + + case 194: +#line 690 "parser.y" + { (yyval.expr_list) = append_expr( (yyvsp[-2].expr_list), (yyvsp[0].expr) ); ;} + break; + + case 195: +#line 693 "parser.y" { (yyval.expr) = (yyvsp[0].expr); if (!(yyval.expr)->is_const) error_loc("expression is not an integer constant\n"); ;} break; - case 193: -#line 722 "parser.y" + case 196: +#line 699 "parser.y" { (yyval.expr) = (yyvsp[0].expr); if (!(yyval.expr)->is_const && (yyval.expr)->type != EXPR_STRLIT && (yyval.expr)->type != EXPR_WSTRLIT) error_loc("expression is not constant\n"); ;} break; - case 194: -#line 728 "parser.y" + case 197: +#line 705 "parser.y" { (yyval.var_list) = NULL; ;} break; - case 195: -#line 729 "parser.y" + case 198: +#line 706 "parser.y" { (yyval.var_list) = append_var_list((yyvsp[-1].var_list), (yyvsp[0].var_list)); ;} break; - case 196: -#line 733 "parser.y" + case 199: +#line 710 "parser.y" { const char *first = LIST_ENTRY(list_head((yyvsp[-1].declarator_list)), declarator_t, entry)->var->name; check_field_attrs(first, (yyvsp[-3].attr_list)); (yyval.var_list) = set_var_types((yyvsp[-3].attr_list), (yyvsp[-2].declspec), (yyvsp[-1].declarator_list)); ;} break; - case 197: -#line 737 "parser.y" + case 200: +#line 714 "parser.y" { var_t *v = make_var(NULL); v->type = (yyvsp[-1].type); v->attrs = (yyvsp[-2].attr_list); (yyval.var_list) = append_var(NULL, v); ;} break; - case 198: -#line 744 "parser.y" - { (yyval.var) = (yyvsp[-1].var); ;} - break; - - case 199: -#line 745 "parser.y" - { (yyval.var) = make_var(NULL); (yyval.var)->attrs = (yyvsp[-1].attr_list); ;} - break; - - case 200: -#line 748 "parser.y" - { (yyval.var_list) = NULL; ;} - break; - case 201: -#line 749 "parser.y" - { (yyval.var_list) = append_var( (yyvsp[-1].var_list), (yyvsp[0].var) ); ;} +#line 721 "parser.y" + { (yyval.var) = (yyvsp[-1].var); ;} break; case 202: -#line 753 "parser.y" - { (yyval.var) = (yyvsp[-1].var); ;} +#line 722 "parser.y" + { (yyval.var) = make_var(NULL); (yyval.var)->attrs = (yyvsp[-1].attr_list); ;} break; case 203: -#line 754 "parser.y" - { (yyval.var) = NULL; ;} +#line 725 "parser.y" + { (yyval.var_list) = NULL; ;} break; case 204: -#line 757 "parser.y" +#line 726 "parser.y" + { (yyval.var_list) = append_var( (yyvsp[-1].var_list), (yyvsp[0].var) ); ;} + break; + + case 205: +#line 730 "parser.y" + { (yyval.var) = (yyvsp[-1].var); ;} + break; + + case 206: +#line 731 "parser.y" + { (yyval.var) = NULL; ;} + break; + + case 207: +#line 734 "parser.y" { (yyval.var) = (yyvsp[0].declarator)->var; (yyval.var)->attrs = check_field_attrs((yyval.var)->name, (yyvsp[-2].attr_list)); set_type((yyval.var), (yyvsp[-1].declspec), (yyvsp[0].declarator), FALSE); @@ -3531,8 +3514,8 @@ yyreduce: ;} break; - case 205: -#line 765 "parser.y" + case 208: +#line 742 "parser.y" { var_t *v = (yyvsp[0].declarator)->var; v->attrs = check_function_attrs(v->name, (yyvsp[-2].attr_list)); set_type(v, (yyvsp[-1].declspec), (yyvsp[0].declarator), FALSE); @@ -3541,8 +3524,8 @@ yyreduce: ;} break; - case 206: -#line 775 "parser.y" + case 209: +#line 752 "parser.y" { (yyval.var) = (yyvsp[0].declarator)->var; (yyval.var)->attrs = (yyvsp[-2].attr_list); set_type((yyval.var), (yyvsp[-1].declspec), (yyvsp[0].declarator), FALSE); @@ -3550,61 +3533,61 @@ yyreduce: ;} break; - case 207: -#line 780 "parser.y" + case 210: +#line 757 "parser.y" { (yyval.var) = (yyvsp[0].declarator)->var; set_type((yyval.var), (yyvsp[-1].declspec), (yyvsp[0].declarator), FALSE); free((yyvsp[0].declarator)); ;} break; - case 208: -#line 786 "parser.y" - { (yyval.var) = NULL; ;} - break; - - case 210: -#line 790 "parser.y" - { (yyval.var) = NULL; ;} - break; - case 211: -#line 791 "parser.y" - { (yyval.var) = make_var((yyvsp[0].str)); ;} - break; - - case 212: -#line 792 "parser.y" - { (yyval.var) = make_var((yyvsp[0].str)); ;} +#line 763 "parser.y" + { (yyval.var) = NULL; ;} break; case 213: -#line 795 "parser.y" - { (yyval.var) = make_var((yyvsp[0].str)); ;} +#line 767 "parser.y" + { (yyval.str) = NULL; ;} break; case 214: -#line 797 "parser.y" - { (yyval.var) = make_var((yyvsp[0].str)); ;} +#line 768 "parser.y" + { (yyval.str) = (yyvsp[0].str); ;} break; case 215: -#line 800 "parser.y" - { (yyval.type) = make_builtin((yyvsp[0].str)); ;} +#line 769 "parser.y" + { (yyval.str) = (yyvsp[0].str); ;} break; case 216: -#line 801 "parser.y" - { (yyval.type) = make_builtin((yyvsp[0].str)); ;} +#line 772 "parser.y" + { (yyval.var) = make_var((yyvsp[0].str)); ;} + break; + + case 217: +#line 774 "parser.y" + { (yyval.var) = make_var((yyvsp[0].str)); ;} break; case 218: -#line 803 "parser.y" - { (yyval.type) = (yyvsp[0].type); (yyval.type)->sign = 1; ;} +#line 777 "parser.y" + { (yyval.type) = make_builtin((yyvsp[0].str)); ;} break; case 219: -#line 804 "parser.y" +#line 778 "parser.y" + { (yyval.type) = make_builtin((yyvsp[0].str)); ;} + break; + + case 221: +#line 780 "parser.y" + { (yyval.type) = (yyvsp[0].type); (yyval.type)->sign = 1; ;} + break; + + case 222: +#line 781 "parser.y" { (yyval.type) = (yyvsp[0].type); (yyval.type)->sign = -1; switch ((yyval.type)->type) { case RPC_FC_CHAR: break; @@ -3623,83 +3606,83 @@ yyreduce: ;} break; - case 220: -#line 820 "parser.y" + case 223: +#line 797 "parser.y" { (yyval.type) = make_int(-1); ;} break; - case 221: -#line 821 "parser.y" - { (yyval.type) = make_builtin((yyvsp[0].str)); ;} - break; - - case 222: -#line 822 "parser.y" - { (yyval.type) = find_type("float", 0); ;} - break; - - case 223: -#line 823 "parser.y" - { (yyval.type) = make_builtin((yyvsp[0].str)); ;} - break; - case 224: -#line 824 "parser.y" +#line 798 "parser.y" { (yyval.type) = make_builtin((yyvsp[0].str)); ;} break; case 225: -#line 825 "parser.y" - { (yyval.type) = make_builtin((yyvsp[0].str)); ;} +#line 799 "parser.y" + { (yyval.type) = find_type("float", 0); ;} break; case 226: -#line 826 "parser.y" +#line 800 "parser.y" + { (yyval.type) = make_builtin((yyvsp[0].str)); ;} + break; + + case 227: +#line 801 "parser.y" + { (yyval.type) = make_builtin((yyvsp[0].str)); ;} + break; + + case 228: +#line 802 "parser.y" { (yyval.type) = make_builtin((yyvsp[0].str)); ;} break; case 229: -#line 833 "parser.y" - { (yyval.type) = make_builtin((yyvsp[0].str)); ;} - break; - - case 230: -#line 834 "parser.y" - { (yyval.type) = make_builtin((yyvsp[-1].str)); ;} - break; - - case 231: -#line 835 "parser.y" +#line 803 "parser.y" { (yyval.type) = make_builtin((yyvsp[0].str)); ;} break; case 232: -#line 836 "parser.y" - { (yyval.type) = make_builtin((yyvsp[-1].str)); ;} +#line 810 "parser.y" + { (yyval.type) = make_builtin((yyvsp[0].str)); ;} break; case 233: -#line 837 "parser.y" +#line 811 "parser.y" { (yyval.type) = make_builtin((yyvsp[-1].str)); ;} break; case 234: -#line 838 "parser.y" +#line 812 "parser.y" { (yyval.type) = make_builtin((yyvsp[0].str)); ;} break; case 235: -#line 839 "parser.y" - { (yyval.type) = make_builtin((yyvsp[0].str)); ;} +#line 813 "parser.y" + { (yyval.type) = make_builtin((yyvsp[-1].str)); ;} break; case 236: -#line 842 "parser.y" - { (yyval.type) = make_class((yyvsp[0].str)); ;} +#line 814 "parser.y" + { (yyval.type) = make_builtin((yyvsp[-1].str)); ;} break; case 237: -#line 843 "parser.y" +#line 815 "parser.y" + { (yyval.type) = make_builtin((yyvsp[0].str)); ;} + break; + + case 238: +#line 816 "parser.y" + { (yyval.type) = make_builtin((yyvsp[0].str)); ;} + break; + + case 239: +#line 819 "parser.y" + { (yyval.type) = make_class((yyvsp[0].str)); ;} + break; + + case 240: +#line 820 "parser.y" { (yyval.type) = find_type((yyvsp[0].str), 0); if ((yyval.type)->kind != TKIND_COCLASS) error_loc("%s was not declared a coclass at %s:%d\n", @@ -3708,452 +3691,394 @@ yyreduce: ;} break; - case 238: -#line 851 "parser.y" + case 241: +#line 828 "parser.y" { (yyval.type) = (yyvsp[0].type); check_def((yyval.type)); (yyval.type)->attrs = check_coclass_attrs((yyvsp[0].type)->name, (yyvsp[-1].attr_list)); - if (!parse_only && do_header) - write_coclass((yyval.type)); - if (!parse_only && do_idfile) - write_clsid((yyval.type)); ;} break; - case 239: -#line 862 "parser.y" + case 242: +#line 835 "parser.y" { (yyval.type) = (yyvsp[-4].type); (yyval.type)->ifaces = (yyvsp[-2].ifref_list); (yyval.type)->defined = TRUE; ;} break; - case 240: -#line 868 "parser.y" + case 243: +#line 841 "parser.y" { (yyval.ifref_list) = NULL; ;} break; - case 241: -#line 869 "parser.y" + case 244: +#line 842 "parser.y" { (yyval.ifref_list) = append_ifref( (yyvsp[-1].ifref_list), (yyvsp[0].ifref) ); ;} break; - case 242: -#line 873 "parser.y" + case 245: +#line 846 "parser.y" { (yyval.ifref) = make_ifref((yyvsp[0].type)); (yyval.ifref)->attrs = (yyvsp[-1].attr_list); ;} break; - case 243: -#line 876 "parser.y" + case 246: +#line 849 "parser.y" { (yyval.type) = get_type(RPC_FC_IP, (yyvsp[0].str), 0); (yyval.type)->kind = TKIND_DISPATCH; ;} break; - case 244: -#line 877 "parser.y" + case 247: +#line 850 "parser.y" { (yyval.type) = get_type(RPC_FC_IP, (yyvsp[0].str), 0); (yyval.type)->kind = TKIND_DISPATCH; ;} break; - case 245: -#line 880 "parser.y" + case 248: +#line 853 "parser.y" { attr_t *attrs; - is_in_interface = TRUE; is_object_interface = TRUE; (yyval.type) = (yyvsp[0].type); check_def((yyval.type)); attrs = make_attr(ATTR_DISPINTERFACE); (yyval.type)->attrs = append_attr( check_dispiface_attrs((yyvsp[0].type)->name, (yyvsp[-1].attr_list)), attrs ); - (yyval.type)->ref = find_type("IDispatch", 0); - if (!(yyval.type)->ref) error_loc("IDispatch is undefined\n"); (yyval.type)->defined = TRUE; - if (!parse_only && do_header) write_forward((yyval.type)); ;} break; - case 246: -#line 894 "parser.y" - { (yyval.var_list) = NULL; ;} - break; - - case 247: -#line 895 "parser.y" - { (yyval.var_list) = append_var( (yyvsp[-2].var_list), (yyvsp[-1].var) ); ;} - break; - - case 248: -#line 898 "parser.y" - { (yyval.func_list) = NULL; ;} - break; - case 249: -#line 899 "parser.y" - { (yyval.func_list) = append_func( (yyvsp[-2].func_list), (yyvsp[-1].func) ); ;} +#line 863 "parser.y" + { (yyval.var_list) = NULL; ;} break; case 250: -#line 905 "parser.y" - { (yyval.type) = (yyvsp[-4].type); - (yyval.type)->fields_or_args = (yyvsp[-2].var_list); - (yyval.type)->funcs = (yyvsp[-1].func_list); - if (!parse_only && do_header) write_interface((yyval.type)); - if (!parse_only && do_idfile) write_diid((yyval.type)); - is_in_interface = FALSE; - ;} +#line 864 "parser.y" + { (yyval.var_list) = append_var( (yyvsp[-2].var_list), (yyvsp[-1].var) ); ;} break; case 251: -#line 913 "parser.y" - { (yyval.type) = (yyvsp[-4].type); - (yyval.type)->fields_or_args = (yyvsp[-2].type)->fields_or_args; - (yyval.type)->funcs = (yyvsp[-2].type)->funcs; - if (!parse_only && do_header) write_interface((yyval.type)); - if (!parse_only && do_idfile) write_diid((yyval.type)); - is_in_interface = FALSE; - ;} +#line 867 "parser.y" + { (yyval.stmt_list) = NULL; ;} break; case 252: -#line 922 "parser.y" - { (yyval.type) = NULL; ;} +#line 868 "parser.y" + { (yyval.stmt_list) = append_func( (yyvsp[-2].stmt_list), (yyvsp[-1].func) ); ;} break; case 253: -#line 923 "parser.y" - { (yyval.type) = find_type_or_error2((yyvsp[0].str), 0); ;} +#line 874 "parser.y" + { (yyval.type) = (yyvsp[-4].type); + type_dispinterface_define((yyval.type), (yyvsp[-2].var_list), (yyvsp[-1].stmt_list)); + ;} break; case 254: -#line 926 "parser.y" - { (yyval.type) = get_type(RPC_FC_IP, (yyvsp[0].str), 0); (yyval.type)->kind = TKIND_INTERFACE; ;} +#line 878 "parser.y" + { (yyval.type) = (yyvsp[-4].type); + type_dispinterface_define_from_iface((yyval.type), (yyvsp[-2].type)); + ;} break; case 255: -#line 927 "parser.y" - { (yyval.type) = get_type(RPC_FC_IP, (yyvsp[0].str), 0); (yyval.type)->kind = TKIND_INTERFACE; ;} +#line 883 "parser.y" + { (yyval.type) = NULL; ;} break; case 256: -#line 930 "parser.y" +#line 884 "parser.y" + { (yyval.type) = find_type_or_error2((yyvsp[0].str), 0); ;} + break; + + case 257: +#line 887 "parser.y" + { (yyval.type) = get_type(RPC_FC_IP, (yyvsp[0].str), 0); (yyval.type)->kind = TKIND_INTERFACE; ;} + break; + + case 258: +#line 888 "parser.y" + { (yyval.type) = get_type(RPC_FC_IP, (yyvsp[0].str), 0); (yyval.type)->kind = TKIND_INTERFACE; ;} + break; + + case 259: +#line 891 "parser.y" { (yyval.ifinfo).interface = (yyvsp[0].type); (yyval.ifinfo).old_pointer_default = pointer_default; if (is_attr((yyvsp[-1].attr_list), ATTR_POINTERDEFAULT)) pointer_default = get_attrv((yyvsp[-1].attr_list), ATTR_POINTERDEFAULT); is_object_interface = is_object((yyvsp[-1].attr_list)); - is_in_interface = TRUE; check_def((yyvsp[0].type)); (yyvsp[0].type)->attrs = check_iface_attrs((yyvsp[0].type)->name, (yyvsp[-1].attr_list)); (yyvsp[0].type)->defined = TRUE; - if (!parse_only && do_header) write_forward((yyvsp[0].type)); ;} break; - case 257: -#line 944 "parser.y" - { (yyval.type) = (yyvsp[-5].ifinfo).interface; - (yyval.type)->ref = (yyvsp[-4].type); - (yyval.type)->funcs = (yyvsp[-2].func_list); - check_functions((yyval.type)); - compute_method_indexes((yyval.type)); - if (!parse_only && do_header) write_interface((yyval.type)); - if (!parse_only && local_stubs) write_locals(local_stubs, (yyval.type), TRUE); - if (!parse_only && do_idfile) write_iid((yyval.type)); - pointer_default = (yyvsp[-5].ifinfo).old_pointer_default; - is_in_interface = FALSE; - ;} - break; - - case 258: -#line 959 "parser.y" - { (yyval.type) = (yyvsp[-7].ifinfo).interface; - (yyval.type)->ref = find_type_or_error2((yyvsp[-5].str), 0); - if (!(yyval.type)->ref) error_loc("base class '%s' not found in import\n", (yyvsp[-5].str)); - (yyval.type)->funcs = (yyvsp[-2].func_list); - compute_method_indexes((yyval.type)); - if (!parse_only && do_header) write_interface((yyval.type)); - if (!parse_only && local_stubs) write_locals(local_stubs, (yyval.type), TRUE); - if (!parse_only && do_idfile) write_iid((yyval.type)); - pointer_default = (yyvsp[-7].ifinfo).old_pointer_default; - is_in_interface = FALSE; - ;} - break; - - case 259: -#line 970 "parser.y" - { (yyval.type) = (yyvsp[-1].type); ;} - break; - case 260: -#line 974 "parser.y" - { (yyval.type) = (yyvsp[-1].type); if (!parse_only && do_header) write_forward((yyval.type)); ;} +#line 903 "parser.y" + { (yyval.type) = (yyvsp[-5].ifinfo).interface; + type_interface_define((yyval.type), (yyvsp[-4].type), (yyvsp[-2].stmt_list)); + pointer_default = (yyvsp[-5].ifinfo).old_pointer_default; + ;} break; case 261: -#line 975 "parser.y" - { (yyval.type) = (yyvsp[-1].type); if (!parse_only && do_header) write_forward((yyval.type)); ;} +#line 911 "parser.y" + { (yyval.type) = (yyvsp[-7].ifinfo).interface; + type_interface_define((yyval.type), find_type_or_error2((yyvsp[-5].str), 0), (yyvsp[-2].stmt_list)); + pointer_default = (yyvsp[-7].ifinfo).old_pointer_default; + ;} break; case 262: -#line 978 "parser.y" - { (yyval.type) = make_type(0, NULL); (yyval.type)->name = (yyvsp[0].str); (yyval.type)->kind = TKIND_MODULE; ;} +#line 915 "parser.y" + { (yyval.type) = (yyvsp[-1].type); ;} break; case 263: -#line 979 "parser.y" - { (yyval.type) = make_type(0, NULL); (yyval.type)->name = (yyvsp[0].str); (yyval.type)->kind = TKIND_MODULE; ;} +#line 919 "parser.y" + { (yyval.type) = (yyvsp[-1].type); ;} break; case 264: -#line 982 "parser.y" +#line 920 "parser.y" + { (yyval.type) = (yyvsp[-1].type); ;} + break; + + case 265: +#line 923 "parser.y" + { (yyval.type) = make_type(0, NULL); (yyval.type)->name = (yyvsp[0].str); (yyval.type)->kind = TKIND_MODULE; ;} + break; + + case 266: +#line 924 "parser.y" + { (yyval.type) = make_type(0, NULL); (yyval.type)->name = (yyvsp[0].str); (yyval.type)->kind = TKIND_MODULE; ;} + break; + + case 267: +#line 927 "parser.y" { (yyval.type) = (yyvsp[0].type); (yyval.type)->attrs = check_module_attrs((yyvsp[0].type)->name, (yyvsp[-1].attr_list)); ;} break; - case 265: -#line 988 "parser.y" + case 268: +#line 933 "parser.y" { (yyval.type) = (yyvsp[-4].type); - (yyval.type)->funcs = (yyvsp[-2].func_list); - /* FIXME: if (!parse_only && do_header) write_module($$); */ + (yyval.type)->stmts = (yyvsp[-2].stmt_list); + (yyval.type)->funcs = gen_function_list((yyvsp[-2].stmt_list)); ;} break; - case 266: -#line 995 "parser.y" + case 269: +#line 940 "parser.y" { (yyval.stgclass) = STG_EXTERN; ;} break; - case 267: -#line 996 "parser.y" + case 270: +#line 941 "parser.y" { (yyval.stgclass) = STG_STATIC; ;} break; - case 268: -#line 997 "parser.y" + case 271: +#line 942 "parser.y" { (yyval.stgclass) = STG_REGISTER; ;} break; - case 269: -#line 1001 "parser.y" + case 272: +#line 946 "parser.y" { (yyval.attr) = make_attr(ATTR_INLINE); ;} break; - case 270: -#line 1005 "parser.y" + case 273: +#line 950 "parser.y" { (yyval.attr) = make_attr(ATTR_CONST); ;} break; - case 271: -#line 1008 "parser.y" + case 274: +#line 953 "parser.y" { (yyval.attr_list) = NULL; ;} break; - case 272: -#line 1009 "parser.y" + case 275: +#line 954 "parser.y" { (yyval.attr_list) = append_attr((yyvsp[-1].attr_list), (yyvsp[0].attr)); ;} break; - case 273: -#line 1012 "parser.y" + case 276: +#line 957 "parser.y" { (yyval.declspec) = make_decl_spec((yyvsp[-1].type), (yyvsp[0].declspec), NULL, NULL, STG_NONE); ;} break; - case 274: -#line 1014 "parser.y" + case 277: +#line 959 "parser.y" { (yyval.declspec) = make_decl_spec((yyvsp[-1].type), (yyvsp[-2].declspec), (yyvsp[0].declspec), NULL, STG_NONE); ;} break; - case 275: -#line 1017 "parser.y" + case 278: +#line 962 "parser.y" { (yyval.declspec) = NULL; ;} break; - case 277: -#line 1022 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[0].declspec), NULL, (yyvsp[-1].attr), STG_NONE); ;} - break; - - case 278: -#line 1023 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[0].declspec), NULL, (yyvsp[-1].attr), STG_NONE); ;} - break; - - case 279: -#line 1024 "parser.y" - { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[0].declspec), NULL, NULL, (yyvsp[-1].stgclass)); ;} - break; - case 280: -#line 1029 "parser.y" - { (yyval.declarator) = (yyvsp[0].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, make_pointer_type(NULL, (yyvsp[-1].attr_list))); ;} +#line 967 "parser.y" + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[0].declspec), NULL, (yyvsp[-1].attr), STG_NONE); ;} break; case 281: -#line 1030 "parser.y" - { (yyval.declarator) = (yyvsp[0].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[-1].str))); ;} +#line 968 "parser.y" + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[0].declspec), NULL, (yyvsp[-1].attr), STG_NONE); ;} + break; + + case 282: +#line 969 "parser.y" + { (yyval.declspec) = make_decl_spec(NULL, (yyvsp[0].declspec), NULL, NULL, (yyvsp[-1].stgclass)); ;} break; case 283: -#line 1035 "parser.y" - { (yyval.declarator) = make_declarator((yyvsp[0].var)); ;} +#line 974 "parser.y" + { (yyval.declarator) = (yyvsp[0].declarator); (yyval.declarator)->type = append_ptrchain_type((yyval.declarator)->type, type_new_pointer(NULL, (yyvsp[-1].attr_list))); ;} break; case 284: -#line 1036 "parser.y" - { (yyval.declarator) = (yyvsp[-1].declarator); ;} - break; - - case 285: -#line 1037 "parser.y" - { (yyval.declarator) = (yyvsp[-1].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[0].expr)); ;} +#line 975 "parser.y" + { (yyval.declarator) = (yyvsp[0].declarator); (yyval.declarator)->type->attrs = append_attr((yyval.declarator)->type->attrs, make_attrp(ATTR_CALLCONV, (yyvsp[-1].str))); ;} break; case 286: -#line 1038 "parser.y" +#line 980 "parser.y" + { (yyval.declarator) = make_declarator((yyvsp[0].var)); ;} + break; + + case 287: +#line 981 "parser.y" + { (yyval.declarator) = (yyvsp[-1].declarator); ;} + break; + + case 288: +#line 982 "parser.y" + { (yyval.declarator) = (yyvsp[-1].declarator); (yyval.declarator)->array = append_array((yyval.declarator)->array, (yyvsp[0].expr)); ;} + break; + + case 289: +#line 983 "parser.y" { (yyval.declarator) = (yyvsp[-3].declarator); - (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, make_func_type((yyvsp[-1].var_list))); + (yyval.declarator)->func_type = append_ptrchain_type((yyval.declarator)->type, type_new_function((yyvsp[-1].var_list))); (yyval.declarator)->type = NULL; ;} break; - case 287: -#line 1045 "parser.y" + case 290: +#line 990 "parser.y" { (yyval.declarator_list) = append_declarator( NULL, (yyvsp[0].declarator) ); ;} break; - case 288: -#line 1046 "parser.y" + case 291: +#line 991 "parser.y" { (yyval.declarator_list) = append_declarator( (yyvsp[-2].declarator_list), (yyvsp[0].declarator) ); ;} break; - case 289: -#line 1050 "parser.y" + case 292: +#line 995 "parser.y" { (yyval.declarator) = (yyvsp[0].declarator); ;} break; - case 290: -#line 1051 "parser.y" + case 293: +#line 996 "parser.y" { (yyval.declarator) = (yyvsp[-2].declarator); (yyvsp[-2].declarator)->var->eval = (yyvsp[0].expr); ;} break; - case 291: -#line 1055 "parser.y" + case 294: +#line 1000 "parser.y" { (yyval.num) = RPC_FC_RP; ;} break; - case 292: -#line 1056 "parser.y" + case 295: +#line 1001 "parser.y" { (yyval.num) = RPC_FC_UP; ;} break; - case 293: -#line 1057 "parser.y" + case 296: +#line 1002 "parser.y" { (yyval.num) = RPC_FC_FP; ;} break; - case 294: -#line 1060 "parser.y" - { (yyval.type) = get_typev(RPC_FC_STRUCT, (yyvsp[-3].var), tsSTRUCT); - /* overwrite RPC_FC_STRUCT with a more exact type */ - check_def((yyval.type)); - (yyval.type)->type = get_struct_type( (yyvsp[-1].var_list) ); - (yyval.type)->kind = TKIND_RECORD; - (yyval.type)->fields_or_args = (yyvsp[-1].var_list); - (yyval.type)->defined = TRUE; - if(in_typelib) - add_typelib_entry((yyval.type)); - ;} - break; - - case 295: -#line 1072 "parser.y" - { (yyval.type) = find_type_or_error("void", 0); ;} - break; - - case 296: -#line 1073 "parser.y" - { (yyval.type) = find_type_or_error((yyvsp[0].str), 0); ;} - break; - case 297: -#line 1074 "parser.y" - { (yyval.type) = (yyvsp[0].type); ;} +#line 1005 "parser.y" + { (yyval.type) = type_new_struct((yyvsp[-3].str), TRUE, (yyvsp[-1].var_list)); ;} break; case 298: -#line 1075 "parser.y" - { (yyval.type) = (yyvsp[0].type); ;} +#line 1008 "parser.y" + { (yyval.type) = find_type_or_error("void", 0); ;} break; case 299: -#line 1076 "parser.y" - { (yyval.type) = find_type_or_error2((yyvsp[0].str), tsENUM); ;} +#line 1009 "parser.y" + { (yyval.type) = find_type_or_error((yyvsp[0].str), 0); ;} break; case 300: -#line 1077 "parser.y" +#line 1010 "parser.y" { (yyval.type) = (yyvsp[0].type); ;} break; case 301: -#line 1078 "parser.y" - { (yyval.type) = get_type(RPC_FC_STRUCT, (yyvsp[0].str), tsSTRUCT); ;} - break; - - case 302: -#line 1079 "parser.y" +#line 1011 "parser.y" { (yyval.type) = (yyvsp[0].type); ;} break; + case 302: +#line 1012 "parser.y" + { (yyval.type) = find_type_or_error2((yyvsp[0].str), tsENUM); ;} + break; + case 303: -#line 1080 "parser.y" - { (yyval.type) = find_type_or_error2((yyvsp[0].str), tsUNION); ;} +#line 1013 "parser.y" + { (yyval.type) = (yyvsp[0].type); ;} break; case 304: -#line 1081 "parser.y" - { (yyval.type) = make_safearray((yyvsp[-1].type)); ;} +#line 1014 "parser.y" + { (yyval.type) = type_new_struct((yyvsp[0].str), FALSE, NULL); ;} break; case 305: -#line 1085 "parser.y" - { reg_typedefs((yyvsp[-1].declspec), (yyvsp[0].declarator_list), check_typedef_attrs((yyvsp[-2].attr_list))); - (yyval.statement) = process_typedefs((yyvsp[0].declarator_list)); - ;} +#line 1015 "parser.y" + { (yyval.type) = (yyvsp[0].type); ;} break; case 306: -#line 1091 "parser.y" - { (yyval.type) = get_typev(RPC_FC_NON_ENCAPSULATED_UNION, (yyvsp[-3].var), tsUNION); - check_def((yyval.type)); - (yyval.type)->kind = TKIND_UNION; - (yyval.type)->fields_or_args = (yyvsp[-1].var_list); - (yyval.type)->defined = TRUE; - ;} +#line 1016 "parser.y" + { (yyval.type) = find_type_or_error2((yyvsp[0].str), tsUNION); ;} break; case 307: -#line 1099 "parser.y" - { var_t *u = (yyvsp[-3].var); - (yyval.type) = get_typev(RPC_FC_ENCAPSULATED_UNION, (yyvsp[-8].var), tsUNION); - check_def((yyval.type)); - (yyval.type)->kind = TKIND_UNION; - if (!u) u = make_var( xstrdup("tagged_union") ); - u->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL); - u->type->kind = TKIND_UNION; - u->type->fields_or_args = (yyvsp[-1].var_list); - u->type->defined = TRUE; - (yyval.type)->fields_or_args = append_var( (yyval.type)->fields_or_args, (yyvsp[-5].var) ); - (yyval.type)->fields_or_args = append_var( (yyval.type)->fields_or_args, u ); - (yyval.type)->defined = TRUE; - ;} +#line 1017 "parser.y" + { (yyval.type) = make_safearray((yyvsp[-1].type)); ;} break; case 308: -#line 1115 "parser.y" - { (yyval.num) = MAKEVERSION((yyvsp[0].num), 0); ;} +#line 1021 "parser.y" + { reg_typedefs((yyvsp[-1].declspec), (yyvsp[0].declarator_list), check_typedef_attrs((yyvsp[-2].attr_list))); + (yyval.statement) = make_statement_typedef((yyvsp[0].declarator_list)); + ;} break; case 309: -#line 1116 "parser.y" +#line 1027 "parser.y" + { (yyval.type) = type_new_nonencapsulated_union((yyvsp[-3].str), (yyvsp[-1].var_list)); ;} + break; + + case 310: +#line 1030 "parser.y" + { (yyval.type) = type_new_encapsulated_union((yyvsp[-8].str), (yyvsp[-5].var), (yyvsp[-3].var), (yyvsp[-1].var_list)); ;} + break; + + case 311: +#line 1034 "parser.y" + { (yyval.num) = MAKEVERSION((yyvsp[0].num), 0); ;} + break; + + case 312: +#line 1035 "parser.y" { (yyval.num) = MAKEVERSION((yyvsp[-2].num), (yyvsp[0].num)); ;} break; @@ -4162,7 +4087,7 @@ yyreduce: } /* Line 1126 of yacc.c. */ -#line 4166 "parser.tab.c" +#line 4091 "parser.tab.c" yyvsp -= yylen; yyssp -= yylen; @@ -4430,7 +4355,7 @@ yyreturn: } -#line 1119 "parser.y" +#line 1038 "parser.y" static void decl_builtin(const char *name, unsigned char type) @@ -4681,6 +4606,13 @@ void set_all_tfswrite(int val) node->data.tfswrite = val; } +void clear_all_offsets(void) +{ + type_pool_node_t *node; + LIST_FOR_EACH_ENTRY(node, &type_pool, type_pool_node_t, link) + node->data.typestring_offset = node->data.ptrdesc = 0; +} + type_t *make_type(unsigned char type, type_t *ref) { type_t *t = alloc_type(); @@ -4691,7 +4623,7 @@ type_t *make_type(unsigned char type, type_t *ref) t->attrs = NULL; t->orig = NULL; t->funcs = NULL; - t->fields_or_args = NULL; + memset(&t->details, 0, sizeof(t->details)); t->ifaces = NULL; t->dim = 0; t->size_is = NULL; @@ -4711,18 +4643,87 @@ type_t *make_type(unsigned char type, type_t *ref) return t; } -static type_t *make_func_type(var_list_t *args) +static type_t *type_new_enum(char *name, var_list_t *enums) { - type_t *t = make_type(RPC_FC_FUNCTION, NULL); - t->fields_or_args = args; + type_t *t = get_type(RPC_FC_ENUM16, name, tsENUM); + t->kind = TKIND_ENUM; + if (enums) + { + t->details.enumeration = xmalloc(sizeof(*t->details.enumeration)); + t->details.enumeration->enums = enums; + } + else + t->details.enumeration = NULL; + t->defined = TRUE; + return t; +} + +static type_t *type_new_struct(char *name, int defined, var_list_t *fields) +{ + type_t *tag_type = name ? find_type(name, tsSTRUCT) : NULL; + type_t *t = make_type(RPC_FC_STRUCT, NULL); + t->name = name; + t->kind = TKIND_RECORD; + if (defined || (tag_type && tag_type->details.structure)) + { + if (tag_type && tag_type->details.structure) + { + t->details.structure = tag_type->details.structure; + t->type = tag_type->type; + } + else if (defined) + { + t->details.structure = xmalloc(sizeof(*t->details.structure)); + t->details.structure->fields = fields; + t->defined = TRUE; + } + } + if (name) + { + if (fields) + reg_type(t, name, tsSTRUCT); + else + add_incomplete(t); + } return t; } -static type_t *make_pointer_type(type_t *ref, attr_list_t *attrs) +static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields) { - type_t *t = make_type(pointer_default, ref); - t->attrs = attrs; - return t; + type_t *t = get_type(RPC_FC_NON_ENCAPSULATED_UNION, name, tsUNION); + t->kind = TKIND_UNION; + t->details.structure = xmalloc(sizeof(*t->details.structure)); + t->details.structure->fields = fields; + t->defined = TRUE; + return t; +} + +static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases) +{ + type_t *t = get_type(RPC_FC_ENCAPSULATED_UNION, name, tsUNION); + t->kind = TKIND_UNION; + if (!union_field) union_field = make_var( xstrdup("tagged_union") ); + union_field->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL); + union_field->type->kind = TKIND_UNION; + union_field->type->details.structure = xmalloc(sizeof(*union_field->type->details.structure)); + union_field->type->details.structure->fields = cases; + union_field->type->defined = TRUE; + t->details.structure = xmalloc(sizeof(*t->details.structure)); + t->details.structure->fields = append_var( NULL, switch_field ); + t->details.structure->fields = append_var( t->details.structure->fields, union_field ); + t->defined = TRUE; + return t; +} + +static void function_add_head_arg(func_t *func, var_t *arg) +{ + if (!func->def->type->details.function->args) + { + func->def->type->details.function->args = xmalloc( sizeof(*func->def->type->details.function->args) ); + list_init( func->def->type->details.function->args ); + } + list_add_head( func->def->type->details.function->args, &arg->entry ); + func->args = func->def->type->details.function->args; } static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type) @@ -4814,18 +4815,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, if (dim->is_const) { - unsigned int align = 0; - size_t size = type_memsize(v->type, &align); - - if (dim->cval <= 0) - error_loc("%s: array dimension must be positive\n", v->name); - - if (0xffffffffuL / size < (unsigned long) dim->cval) - error_loc("%s: total array size is too large\n", v->name); - else if (0xffffuL < size * dim->cval) - v->type = make_type(RPC_FC_LGFARRAY, v->type); - else - v->type = make_type(RPC_FC_SMFARRAY, v->type); + v->type = make_type(RPC_FC_LGFARRAY, v->type); } else { @@ -4896,29 +4886,6 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, } } - if (is_array(v->type)) - { - const type_t *rt = v->type->ref; - if (is_user_type(rt)) - v->type->type = RPC_FC_BOGUS_ARRAY; - else - switch (rt->type) - { - case RPC_FC_BOGUS_STRUCT: - case RPC_FC_NON_ENCAPSULATED_UNION: - case RPC_FC_ENCAPSULATED_UNION: - case RPC_FC_ENUM16: - v->type->type = RPC_FC_BOGUS_ARRAY; - break; - /* FC_RP should be above, but widl overuses these, and will break things. */ - case RPC_FC_UP: - case RPC_FC_RP: - if (rt->ref->type == RPC_FC_IP) - v->type->type = RPC_FC_BOGUS_ARRAY; - break; - } - } - /* v->type is currently pointing to the type on the left-side of the * declaration, so we need to fix this up so that it is the return type of the * function and make v->type point to the function side of the declaration */ @@ -5061,8 +5028,7 @@ static func_t *make_func(var_t *def) { func_t *f = xmalloc(sizeof(func_t)); f->def = def; - f->args = def->type->fields_or_args; - f->ignore = parse_only; + f->args = def->type->details.function->args; f->idx = -1; return f; } @@ -5088,7 +5054,6 @@ static typelib_t *make_library(const char *name, const attr_list_t *attrs) typelib->name = xstrdup(name); typelib->filename = NULL; typelib->attrs = attrs; - list_init( &typelib->entries ); list_init( &typelib->importlibs ); return typelib; } @@ -5133,6 +5098,8 @@ static type_t *reg_type(type_t *type, const char *name, int t) nt->t = t; nt->next = type_hash[hash]; type_hash[hash] = nt; + if ((t == tsSTRUCT || t == tsUNION)) + fix_incomplete_types(type); return type; } @@ -5153,7 +5120,8 @@ static void fix_type(type_t *t) if (t->kind == TKIND_ALIAS && is_incomplete(t)) { type_t *ot = t->orig; fix_type(ot); - t->fields_or_args = ot->fields_or_args; + if (is_struct(ot->type) || is_union(ot->type)) + t->details.structure = ot->details.structure; t->defined = ot->defined; } } @@ -5164,10 +5132,29 @@ static void fix_incomplete(void) LIST_FOR_EACH_ENTRY_SAFE(tn, next, &incomplete_types, struct typenode, entry) { fix_type(tn->type); + list_remove(&tn->entry); free(tn); } } +static void fix_incomplete_types(type_t *complete_type) +{ + struct typenode *tn, *next; + + LIST_FOR_EACH_ENTRY_SAFE(tn, next, &incomplete_types, struct typenode, entry) + { + if (((is_struct(complete_type->type) && is_struct(tn->type->type)) || + (is_union(complete_type->type) && is_union(tn->type->type))) && + !strcmp(complete_type->name, tn->type->name)) + { + tn->type->details.structure = complete_type->details.structure; + tn->type->type = complete_type->type; + list_remove(&tn->entry); + free(tn); + } + } +} + static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, attr_list_t *attrs) { const declarator_t *decl; @@ -5277,173 +5264,6 @@ static type_t *get_type(unsigned char type, char *name, int t) return reg_type(tp, name, t); } -static type_t *get_typev(unsigned char type, var_t *name, int t) -{ - char *sname = NULL; - if (name) { - sname = name->name; - free(name); - } - return get_type(type, sname, t); -} - -static int get_struct_type(var_list_t *fields) -{ - int has_pointer = 0; - int has_conformance = 0; - int has_variance = 0; - var_t *field; - - if (get_padding(fields)) - return RPC_FC_BOGUS_STRUCT; - - if (fields) LIST_FOR_EACH_ENTRY( field, fields, var_t, entry ) - { - type_t *t = field->type; - - if (is_user_type(t)) - return RPC_FC_BOGUS_STRUCT; - - if (is_ptr(t)) - { - do - t = t->ref; - while (is_ptr(t)); - - switch (t->type) - { - case RPC_FC_IP: - case RPC_FC_ENCAPSULATED_UNION: - case RPC_FC_NON_ENCAPSULATED_UNION: - case RPC_FC_BOGUS_STRUCT: - return RPC_FC_BOGUS_STRUCT; - } - - has_pointer = 1; - continue; - } - - if (field->type->declarray) - { - if (is_string_type(field->attrs, field->type)) - { - if (is_conformant_array(field->type)) - has_conformance = 1; - has_variance = 1; - continue; - } - - if (is_array(field->type->ref)) - return RPC_FC_BOGUS_STRUCT; - - if (is_conformant_array(field->type)) - { - has_conformance = 1; - if (field->type->declarray && list_next(fields, &field->entry)) - error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", - field->name); - } - if (field->type->length_is) - has_variance = 1; - - t = field->type->ref; - } - - switch (t->type) - { - /* - * RPC_FC_BYTE, RPC_FC_STRUCT, etc - * Simple types don't effect the type of struct. - * A struct containing a simple struct is still a simple struct. - * So long as we can block copy the data, we return RPC_FC_STRUCT. - */ - case 0: /* void pointer */ - case RPC_FC_BYTE: - case RPC_FC_CHAR: - case RPC_FC_SMALL: - case RPC_FC_USMALL: - case RPC_FC_WCHAR: - case RPC_FC_SHORT: - case RPC_FC_USHORT: - case RPC_FC_LONG: - case RPC_FC_ULONG: - case RPC_FC_INT3264: - case RPC_FC_UINT3264: - case RPC_FC_HYPER: - case RPC_FC_FLOAT: - case RPC_FC_DOUBLE: - case RPC_FC_STRUCT: - case RPC_FC_ENUM32: - break; - - case RPC_FC_RP: - case RPC_FC_UP: - case RPC_FC_FP: - case RPC_FC_OP: - case RPC_FC_CARRAY: - case RPC_FC_CVARRAY: - case RPC_FC_BOGUS_ARRAY: - has_pointer = 1; - break; - - /* - * Propagate member attributes - * a struct should be at least as complex as its member - */ - case RPC_FC_CVSTRUCT: - has_conformance = 1; - has_variance = 1; - has_pointer = 1; - break; - - case RPC_FC_CPSTRUCT: - has_conformance = 1; - if (list_next( fields, &field->entry )) - error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", - field->name); - has_pointer = 1; - break; - - case RPC_FC_CSTRUCT: - has_conformance = 1; - if (list_next( fields, &field->entry )) - error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", - field->name); - break; - - case RPC_FC_PSTRUCT: - has_pointer = 1; - break; - - default: - error_loc("Unknown struct member %s with type (0x%02x)\n", field->name, t->type); - /* fallthru - treat it as complex */ - - /* as soon as we see one of these these members, it's bogus... */ - case RPC_FC_ENCAPSULATED_UNION: - case RPC_FC_NON_ENCAPSULATED_UNION: - case RPC_FC_BOGUS_STRUCT: - case RPC_FC_ENUM16: - return RPC_FC_BOGUS_STRUCT; - } - } - - if( has_variance ) - { - if ( has_conformance ) - return RPC_FC_CVSTRUCT; - else - return RPC_FC_BOGUS_STRUCT; - } - if( has_conformance && has_pointer ) - return RPC_FC_CPSTRUCT; - if( has_conformance ) - return RPC_FC_CSTRUCT; - if( has_pointer ) - return RPC_FC_PSTRUCT; - return RPC_FC_STRUCT; -} - /***** constant repository *****/ struct rconst { @@ -5483,48 +5303,23 @@ var_t *find_const(const char *name, int f) return cur->var; } -static void write_libid(const typelib_t *typelib) +func_list_t *gen_function_list(const statement_list_t *stmts) { - const UUID *uuid = get_attrp(typelib->attrs, ATTR_UUID); - write_guid(idfile, "LIBID", typelib->name, uuid); -} - -static void write_clsid(type_t *cls) -{ - const UUID *uuid = get_attrp(cls->attrs, ATTR_UUID); - write_guid(idfile, "CLSID", cls->name, uuid); -} - -static void write_diid(type_t *iface) -{ - const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID); - write_guid(idfile, "DIID", iface->name, uuid); -} - -static void write_iid(type_t *iface) -{ - const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID); - write_guid(idfile, "IID", iface->name, uuid); -} - -static int compute_method_indexes(type_t *iface) -{ - int idx; - func_t *f; - - if (iface->ref) - idx = compute_method_indexes(iface->ref); - else - idx = 0; - - if (!iface->funcs) - return idx; - - LIST_FOR_EACH_ENTRY( f, iface->funcs, func_t, entry ) - if (! is_callas(f->def->attrs)) - f->idx = idx++; - - return idx; + func_list_t *func_list = NULL; + const statement_t *stmt; + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + if (stmt->type == STMT_DECLARATION) + { + var_t *var = stmt->u.var; + if (var->stgclass == STG_NONE && var->type->type == RPC_FC_FUNCTION) + { + check_function_attrs(var->name, var->type->attrs); + func_list = append_func(func_list, make_func(var)); + } + } + } + return func_list; } static char *gen_name(void) @@ -5560,6 +5355,9 @@ struct allowed_attr unsigned int on_function : 1; unsigned int on_arg : 1; unsigned int on_type : 1; + unsigned int on_enum : 1; + unsigned int on_struct : 1; + unsigned int on_union : 1; unsigned int on_field : 1; unsigned int on_library : 1; unsigned int on_dispinterface : 1; @@ -5570,79 +5368,79 @@ struct allowed_attr struct allowed_attr allowed_attr[] = { - /* attr { D ACF I Fn ARG T Fi L DI M C } */ - /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "aggregatable" }, - /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "appobject" }, - /* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, "async" }, - /* ATTR_AUTO_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" }, - /* ATTR_BINDABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "bindable" }, - /* ATTR_BROADCAST */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "broadcast" }, - /* ATTR_CALLAS */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "call_as" }, - /* ATTR_CALLCONV */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL }, - /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" }, - /* ATTR_CONST */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "const" }, - /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "context_handle" }, - /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" }, - /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, "default" }, - /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, - /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "defaultvalue" }, - /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" }, - /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, - /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, - /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" }, - /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, - /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, - /* ATTR_ENTRY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "entry" }, - /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, - /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "handle" }, - /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpcontext" }, - /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpfile" }, - /* ATTR_HELPSTRING */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpstring" }, - /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpstringcontext" }, - /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpstringdll" }, - /* ATTR_HIDDEN */ { 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, "hidden" }, - /* ATTR_ID */ { 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, "id" }, - /* ATTR_IDEMPOTENT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, - /* ATTR_IIDIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "iid_is" }, - /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, - /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, - /* ATTR_IN */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "in" }, - /* ATTR_INLINE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inline" }, - /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, - /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "length_is" }, - /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" }, - /* ATTR_LOCAL */ { 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "local" }, - /* ATTR_NONBROWSABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, - /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "noncreatable" }, - /* ATTR_NONEXTENSIBLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, - /* ATTR_OBJECT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, - /* ATTR_ODL */ { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, "odl" }, - /* ATTR_OLEAUTOMATION */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, - /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "optional" }, - /* ATTR_OUT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "out" }, - /* ATTR_POINTERDEFAULT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, - /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, "ref, unique or ptr" }, - /* ATTR_PROPGET */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propget" }, - /* ATTR_PROPPUT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propput" }, - /* ATTR_PROPPUTREF */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propputref" }, - /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "public" }, - /* ATTR_RANGE */ { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, "range" }, - /* ATTR_READONLY */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "readonly" }, - /* ATTR_REQUESTEDIT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, - /* ATTR_RESTRICTED */ { 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, "restricted" }, - /* ATTR_RETVAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "retval" }, - /* ATTR_SIZEIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "size_is" }, - /* ATTR_SOURCE */ { 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, "source" }, - /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" }, - /* ATTR_STRING */ { 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, "string" }, - /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "switch_is" }, - /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, "switch_type" }, - /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "transmit_as" }, - /* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, "uuid" }, - /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "v1_enum" }, - /* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "vararg" }, - /* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, "version" }, - /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "wire_marshal" }, + /* attr { D ACF I Fn ARG T En St Un Fi L DI M C } */ + /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "aggregatable" }, + /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "appobject" }, + /* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" }, + /* ATTR_AUTO_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" }, + /* ATTR_BINDABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "bindable" }, + /* ATTR_BROADCAST */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "broadcast" }, + /* ATTR_CALLAS */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "call_as" }, + /* ATTR_CALLCONV */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, + /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" }, + /* ATTR_CONST */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "const" }, + /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" }, + /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" }, + /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, "default" }, + /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, + /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultvalue" }, + /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" }, + /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, + /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, + /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" }, + /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, + /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, + /* ATTR_ENTRY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" }, + /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, + /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "handle" }, + /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpcontext" }, + /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpfile" }, + /* ATTR_HELPSTRING */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpstring" }, + /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpstringcontext" }, + /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpstringdll" }, + /* ATTR_HIDDEN */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, "hidden" }, + /* ATTR_ID */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "id" }, + /* ATTR_IDEMPOTENT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, + /* ATTR_IIDIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "iid_is" }, + /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, + /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, + /* ATTR_IN */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "in" }, + /* ATTR_INLINE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inline" }, + /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, + /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "length_is" }, + /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" }, + /* ATTR_LOCAL */ { 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" }, + /* ATTR_NONBROWSABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, + /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "noncreatable" }, + /* ATTR_NONEXTENSIBLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, + /* ATTR_OBJECT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, + /* ATTR_ODL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "odl" }, + /* ATTR_OLEAUTOMATION */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, + /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optional" }, + /* ATTR_OUT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "out" }, + /* ATTR_POINTERDEFAULT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, + /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "ref, unique or ptr" }, + /* ATTR_PROPGET */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propget" }, + /* ATTR_PROPPUT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propput" }, + /* ATTR_PROPPUTREF */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propputref" }, + /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "public" }, + /* ATTR_RANGE */ { 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, "range" }, + /* ATTR_READONLY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "readonly" }, + /* ATTR_REQUESTEDIT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, + /* ATTR_RESTRICTED */ { 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, "restricted" }, + /* ATTR_RETVAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "retval" }, + /* ATTR_SIZEIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "size_is" }, + /* ATTR_SOURCE */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "source" }, + /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" }, + /* ATTR_STRING */ { 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "string" }, + /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "switch_is" }, + /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, "switch_type" }, + /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "transmit_as" }, + /* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "uuid" }, + /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "v1_enum" }, + /* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" }, + /* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "version" }, + /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" }, }; const char *get_attr_display_name(enum attr_type type) @@ -5708,6 +5506,45 @@ static attr_list_t *check_typedef_attrs(attr_list_t *attrs) return attrs; } +static attr_list_t *check_enum_attrs(attr_list_t *attrs) +{ + const attr_t *attr; + if (!attrs) return attrs; + LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) + { + if (!allowed_attr[attr->type].on_enum) + error_loc("inapplicable attribute %s for enum\n", + allowed_attr[attr->type].display_name); + } + return attrs; +} + +static attr_list_t *check_struct_attrs(attr_list_t *attrs) +{ + const attr_t *attr; + if (!attrs) return attrs; + LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) + { + if (!allowed_attr[attr->type].on_struct) + error_loc("inapplicable attribute %s for struct\n", + allowed_attr[attr->type].display_name); + } + return attrs; +} + +static attr_list_t *check_union_attrs(attr_list_t *attrs) +{ + const attr_t *attr; + if (!attrs) return attrs; + LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) + { + if (!allowed_attr[attr->type].on_union) + error_loc("inapplicable attribute %s for union\n", + allowed_attr[attr->type].display_name); + } + return attrs; +} + static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs) { const attr_t *attr; @@ -5928,6 +5765,10 @@ static void check_remoting_fields(const var_t *var, type_t *type) const var_t *field; const var_list_t *fields = NULL; + /* find the real type */ + while (type->kind == TKIND_ALIAS) + type = type->orig; + if (type->checked) return; @@ -5935,21 +5776,13 @@ static void check_remoting_fields(const var_t *var, type_t *type) if (is_struct(type->type)) { - if (type->defined) - fields = type->fields_or_args; + if (type_is_complete(type)) + fields = type_struct_get_fields(type); else error_loc_info(&var->loc_info, "undefined type declaration %s\n", type->name); } else if (is_union(type->type)) - { - if (type->type == RPC_FC_ENCAPSULATED_UNION) - { - const var_t *uv = LIST_ENTRY(list_tail(type->fields_or_args), const var_t, entry); - fields = uv->type->fields_or_args; - } - else - fields = type->fields_or_args; - } + fields = type_union_get_cases(type); if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) if (field->type) check_field_common(type, type->name, field); @@ -6022,19 +5855,13 @@ static void add_explicit_handle_if_necessary(func_t *func) var_t *idl_handle = make_var(xstrdup("IDL_handle")); idl_handle->attrs = append_attr(NULL, make_attr(ATTR_IN)); idl_handle->type = find_type_or_error("handle_t", 0); - if (!func->def->type->fields_or_args) - { - func->def->type->fields_or_args = xmalloc( sizeof(*func->def->type->fields_or_args) ); - list_init( func->def->type->fields_or_args ); - } - list_add_head( func->def->type->fields_or_args, &idl_handle->entry ); - func->args = func->def->type->fields_or_args; + function_add_head_arg(func, idl_handle); } } } } -static void check_functions(const type_t *iface) +void check_functions(const type_t *iface) { if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE) && iface->funcs) { @@ -6061,7 +5888,8 @@ static void check_all_user_types(const statement_list_t *stmts) { if (stmt->type == STMT_LIBRARY) check_all_user_types(stmt->u.lib->stmts); - else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) + else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP && + !is_local(stmt->u.type->attrs)) { const func_t *f; const func_list_t *fs = stmt->u.type->funcs; @@ -6121,7 +5949,7 @@ static statement_t *make_statement_declaration(var_t *var) reg_const(var); } else if ((var->stgclass == STG_NONE || var->stgclass == STG_REGISTER) && - var->type->type != RPC_FC_FUNCTION) + var->type->type != RPC_FC_FUNCTION) error_loc("instantiation of data is illegal\n"); return stmt; } @@ -6161,7 +5989,7 @@ static statement_t *make_statement_module(type_t *type) return stmt; } -static statement_t *process_typedefs(declarator_list_t *decls) +static statement_t *make_statement_typedef(declarator_list_t *decls) { declarator_t *decl, *next; statement_t *stmt; @@ -6181,11 +6009,6 @@ static statement_t *process_typedefs(declarator_list_t *decls) (*type_list)->type = type; (*type_list)->next = NULL; - if (! parse_only && do_header) - write_typedef(type); - if (in_typelib && is_attr(type->attrs, ATTR_PUBLIC)) - add_typelib_entry(type); - type_list = &(*type_list)->next; free(decl); free(var); @@ -6206,20 +6029,6 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s return list; } -static func_list_t *append_func_from_statement(func_list_t *list, statement_t *stmt) -{ - if (stmt->type == STMT_DECLARATION) - { - var_t *var = stmt->u.var; - if (var->stgclass == STG_NONE && var->type->type == RPC_FC_FUNCTION) - { - check_function_attrs(var->name, var->type->attrs); - return append_func(list, make_func(stmt->u.var)); - } - } - return list; -} - void init_loc_info(loc_info_t *i) { i->input_name = input_name ? input_name : "stdin"; @@ -6233,4 +6042,3 @@ static void check_def(const type_t *t) error_loc("%s: redefinition error; original definition was at %s:%d\n", t->name, t->loc_info.input_name, t->loc_info.line_number); } - diff --git a/reactos/tools/widl/parser.tab.h b/reactos/tools/widl/parser.tab.h index 486bafe3c87..97d77965101 100644 --- a/reactos/tools/widl/parser.tab.h +++ b/reactos/tools/widl/parser.tab.h @@ -335,7 +335,7 @@ #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 179 "parser.y" +#line 177 "parser.y" typedef union YYSTYPE { attr_t *attr; attr_list_t *attr_list; @@ -374,4 +374,3 @@ typedef union YYSTYPE { extern YYSTYPE parser_lval; - diff --git a/reactos/tools/widl/parser.y b/reactos/tools/widl/parser.y index 0694090aa15..d9b5c3cbfdf 100644 --- a/reactos/tools/widl/parser.y +++ b/reactos/tools/widl/parser.y @@ -39,6 +39,7 @@ #include "typelib.h" #include "typegen.h" #include "expr.h" +#include "typetree.h" #if defined(YYBYACC) /* Berkeley yacc (byacc) doesn't seem to know about these */ @@ -68,7 +69,6 @@ #define YYERROR_VERBOSE unsigned char pointer_default = RPC_FC_UP; -static int is_in_interface = FALSE; static int is_object_interface = FALSE; /* are we inside a library block? */ static int is_inside_library = FALSE; @@ -96,6 +96,7 @@ typelist_t incomplete_types = LIST_INIT(incomplete_types); static void add_incomplete(type_t *t); static void fix_incomplete(void); +static void fix_incomplete_types(type_t *complete_type); static str_list_t *append_str(str_list_t *list, char *str); static attr_list_t *append_attr(attr_list_t *list, attr_t *attr); @@ -122,34 +123,30 @@ static type_t *make_safearray(type_t *type); static type_t *make_builtin(char *name); static type_t *make_int(int sign); static typelib_t *make_library(const char *name, const attr_list_t *attrs); -static type_t *make_func_type(var_list_t *args); -static type_t *make_pointer_type(type_t *ref, attr_list_t *attrs); static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type); +static type_t *type_new_enum(char *name, var_list_t *enums); +static type_t *type_new_struct(char *name, int defined, var_list_t *fields); +static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields); +static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases); + static type_t *reg_type(type_t *type, const char *name, int t); static type_t *reg_typedefs(decl_spec_t *decl_spec, var_list_t *names, attr_list_t *attrs); static type_t *find_type_or_error(const char *name, int t); static type_t *find_type_or_error2(char *name, int t); static type_t *get_type(unsigned char type, char *name, int t); -static type_t *get_typev(unsigned char type, var_t *name, int t); -static int get_struct_type(var_list_t *fields); static var_t *reg_const(var_t *var); -static void write_libid(const typelib_t *typelib); -static void write_clsid(type_t *cls); -static void write_diid(type_t *iface); -static void write_iid(type_t *iface); - -static int compute_method_indexes(type_t *iface); static char *gen_name(void); -static statement_t *process_typedefs(var_list_t *names); static void check_arg(var_t *arg); -static void check_functions(const type_t *iface); static void check_all_user_types(const statement_list_t *stmts); static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_typedef_attrs(attr_list_t *attrs); +static attr_list_t *check_enum_attrs(attr_list_t *attrs); +static attr_list_t *check_struct_attrs(attr_list_t *attrs); +static attr_list_t *check_union_attrs(attr_list_t *attrs); static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_library_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs); @@ -167,9 +164,10 @@ static statement_t *make_statement_library(typelib_t *typelib); static statement_t *make_statement_cppquote(const char *str); static statement_t *make_statement_importlib(const char *str); static statement_t *make_statement_module(type_t *type); +static statement_t *make_statement_typedef(var_list_t *names); static statement_t *make_statement_import(const char *str); +static statement_t *make_statement_typedef(var_list_t *names); static statement_list_t *append_statement(statement_list_t *list, statement_t *stmt); -static func_list_t *append_func_from_statement(func_list_t *list, statement_t *stmt); #define tsENUM 1 #define tsSTRUCT 2 @@ -317,19 +315,18 @@ static func_list_t *append_func_from_statement(func_list_t *list, statement_t *s %type coclass_ints %type arg ne_union_field union_field s_field case enum declaration %type m_args no_args args fields ne_union_fields cases enums enum_list dispint_props field -%type m_ident t_ident ident +%type m_ident ident %type declarator direct_declarator init_declarator %type declarator_list %type funcdef -%type int_statements dispint_meths %type coclass coclasshdr coclassdef %type pointer_type version -%type libraryhdr callconv cppquote importlib import +%type libraryhdr callconv cppquote importlib import t_ident %type uuid_string %type import_start %type library_start librarydef %type statement typedef -%type gbl_statements imp_statements +%type gbl_statements imp_statements int_statements dispint_meths %left ',' %right '?' ':' @@ -350,49 +347,45 @@ static func_list_t *append_func_from_statement(func_list_t *list, statement_t *s input: gbl_statements { fix_incomplete(); check_all_user_types($1); + write_header($1); + write_id_data($1); write_proxies($1); write_client($1); write_server($1); write_dlldata($1); + write_local_stubs($1); } ; gbl_statements: { $$ = NULL; } - | gbl_statements interfacedec { $$ = $1; } + | gbl_statements interfacedec { $$ = append_statement($1, make_statement_reference($2)); } | gbl_statements interfacedef { $$ = append_statement($1, make_statement_type_decl($2)); } | gbl_statements coclass ';' { $$ = $1; reg_type($2, $2->name, 0); - if (!parse_only && do_header) write_coclass_forward($2); } | gbl_statements coclassdef { $$ = append_statement($1, make_statement_type_decl($2)); - add_typelib_entry($2); reg_type($2, $2->name, 0); - if (!parse_only && do_header) write_coclass_forward($2); - } - | gbl_statements moduledef { $$ = append_statement($1, make_statement_module($2)); - add_typelib_entry($2); } + | gbl_statements moduledef { $$ = append_statement($1, make_statement_module($2)); } | gbl_statements librarydef { $$ = append_statement($1, make_statement_library($2)); } | gbl_statements statement { $$ = append_statement($1, $2); } ; imp_statements: { $$ = NULL; } - | imp_statements interfacedec { $$ = append_statement($1, make_statement_reference($2)); if (!parse_only) add_typelib_entry($2); } - | imp_statements interfacedef { $$ = append_statement($1, make_statement_type_decl($2)); if (!parse_only) add_typelib_entry($2); } - | imp_statements coclass ';' { $$ = $1; reg_type($2, $2->name, 0); if (!parse_only && do_header) write_coclass_forward($2); } + | imp_statements interfacedec { $$ = append_statement($1, make_statement_reference($2)); } + | imp_statements interfacedef { $$ = append_statement($1, make_statement_type_decl($2)); } + | imp_statements coclass ';' { $$ = $1; reg_type($2, $2->name, 0); } | imp_statements coclassdef { $$ = append_statement($1, make_statement_type_decl($2)); - if (!parse_only) add_typelib_entry($2); reg_type($2, $2->name, 0); - if (!parse_only && do_header) write_coclass_forward($2); } - | imp_statements moduledef { $$ = append_statement($1, make_statement_module($2)); if (!parse_only) add_typelib_entry($2); } + | imp_statements moduledef { $$ = append_statement($1, make_statement_module($2)); } | imp_statements statement { $$ = append_statement($1, $2); } | imp_statements importlib { $$ = append_statement($1, make_statement_importlib($2)); } | imp_statements librarydef { $$ = append_statement($1, make_statement_library($2)); } ; int_statements: { $$ = NULL; } - | int_statements statement { $$ = append_func_from_statement( $1, $2 ); } + | int_statements statement { $$ = append_statement($1, $2); } ; semicolon_opt: @@ -401,15 +394,8 @@ semicolon_opt: statement: cppquote { $$ = make_statement_cppquote($1); } - | typedecl ';' { $$ = make_statement_type_decl($1); - if (!parse_only && do_header) { - write_type_def_or_decl(header, $1, FALSE, NULL); - fprintf(header, ";\n\n"); - } - } - | declaration ';' { $$ = make_statement_declaration($1); - if (!parse_only && do_header) write_declaration($1, is_in_interface); - } + | typedecl ';' { $$ = make_statement_type_decl($1); } + | declaration ';' { $$ = make_statement_declaration($1); } | import { $$ = make_statement_import($1); } | typedef ';' { $$ = $1; } ; @@ -418,9 +404,12 @@ typedecl: enumdef | structdef | uniondef + | attributes enumdef { $$ = $2; $$->attrs = check_enum_attrs($1); } + | attributes structdef { $$ = $2; $$->attrs = check_struct_attrs($1); } + | attributes uniondef { $$ = $2; $$->attrs = check_union_attrs($1); } ; -cppquote: tCPPQUOTE '(' aSTRING ')' { $$ = $3; if (!parse_only && do_header) fprintf(header, "%s\n", $3); } +cppquote: tCPPQUOTE '(' aSTRING ')' { $$ = $3; } ; import_start: tIMPORT aSTRING ';' { assert(yychar == YYEMPTY); $$ = xmalloc(sizeof(struct _import_t)); @@ -433,7 +422,6 @@ import_start: tIMPORT aSTRING ';' { assert(yychar == YYEMPTY); import: import_start imp_statements aEOF { $$ = $1->name; if ($1->import_performed) pop_import(); free($1); - if (!parse_only && do_header) write_import($$); } ; @@ -445,8 +433,6 @@ libraryhdr: tLIBRARY aIDENTIFIER { $$ = $2; } ; library_start: attributes libraryhdr '{' { $$ = make_library($2, check_library_attrs($2, $1)); if (!parse_only) start_typelib($$); - if (!parse_only && do_header) write_library($$); - if (!parse_only && do_idfile) write_libid($$); is_inside_library = TRUE; } ; @@ -495,10 +481,7 @@ m_attributes: { $$ = NULL; } ; attributes: - '[' attrib_list ']' { $$ = $2; - if (!$$) - error_loc("empty attribute lists unsupported\n"); - } + '[' attrib_list ']' { $$ = $2; } ; attrib_list: attribute { $$ = append_attr( NULL, $1 ); } @@ -640,13 +623,7 @@ enum: ident '=' expr_int_const { $$ = reg_const($1); } ; -enumdef: tENUM t_ident '{' enums '}' { $$ = get_typev(RPC_FC_ENUM16, $2, tsENUM); - $$->kind = TKIND_ENUM; - $$->fields_or_args = $4; - $$->defined = TRUE; - if(in_typelib) - add_typelib_entry($$); - } +enumdef: tENUM t_ident '{' enums '}' { $$ = type_new_enum($2, $4); } ; m_exprs: m_expr { $$ = append_expr( NULL, $1 ); } @@ -743,7 +720,7 @@ field: m_attributes decl_spec declarator_list ';' ne_union_field: s_field ';' { $$ = $1; } | attributes ';' { $$ = make_var(NULL); $$->attrs = $1; } - ; + ; ne_union_fields: { $$ = NULL; } | ne_union_fields ne_union_field { $$ = append_var( $1, $2 ); } @@ -752,7 +729,7 @@ ne_union_fields: { $$ = NULL; } union_field: s_field ';' { $$ = $1; } | ';' { $$ = NULL; } - ; + ; s_field: m_attributes decl_spec declarator { $$ = $3->var; $$->attrs = check_field_attrs($$->name, $1); @@ -788,8 +765,8 @@ m_ident: { $$ = NULL; } ; t_ident: { $$ = NULL; } - | aIDENTIFIER { $$ = make_var($1); } - | aKNOWNTYPE { $$ = make_var($1); } + | aIDENTIFIER { $$ = $1; } + | aKNOWNTYPE { $$ = $1; } ; ident: aIDENTIFIER { $$ = make_var($1); } @@ -851,10 +828,6 @@ coclass: tCOCLASS aIDENTIFIER { $$ = make_class($2); } coclasshdr: attributes coclass { $$ = $2; check_def($$); $$->attrs = check_coclass_attrs($2->name, $1); - if (!parse_only && do_header) - write_coclass($$); - if (!parse_only && do_idfile) - write_clsid($$); } ; @@ -878,16 +851,12 @@ dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); $$- ; dispinterfacehdr: attributes dispinterface { attr_t *attrs; - is_in_interface = TRUE; is_object_interface = TRUE; $$ = $2; check_def($$); attrs = make_attr(ATTR_DISPINTERFACE); $$->attrs = append_attr( check_dispiface_attrs($2->name, $1), attrs ); - $$->ref = find_type("IDispatch", 0); - if (!$$->ref) error_loc("IDispatch is undefined\n"); $$->defined = TRUE; - if (!parse_only && do_header) write_forward($$); } ; @@ -903,19 +872,11 @@ dispinterfacedef: dispinterfacehdr '{' dispint_props dispint_meths '}' { $$ = $1; - $$->fields_or_args = $3; - $$->funcs = $4; - if (!parse_only && do_header) write_interface($$); - if (!parse_only && do_idfile) write_diid($$); - is_in_interface = FALSE; + type_dispinterface_define($$, $3, $4); } | dispinterfacehdr '{' interface ';' '}' { $$ = $1; - $$->fields_or_args = $3->fields_or_args; - $$->funcs = $3->funcs; - if (!parse_only && do_header) write_interface($$); - if (!parse_only && do_idfile) write_diid($$); - is_in_interface = FALSE; + type_dispinterface_define_from_iface($$, $3); } ; @@ -932,47 +893,31 @@ interfacehdr: attributes interface { $$.interface = $2; if (is_attr($1, ATTR_POINTERDEFAULT)) pointer_default = get_attrv($1, ATTR_POINTERDEFAULT); is_object_interface = is_object($1); - is_in_interface = TRUE; check_def($2); $2->attrs = check_iface_attrs($2->name, $1); $2->defined = TRUE; - if (!parse_only && do_header) write_forward($2); } ; interfacedef: interfacehdr inherit '{' int_statements '}' semicolon_opt { $$ = $1.interface; - $$->ref = $2; - $$->funcs = $4; - check_functions($$); - compute_method_indexes($$); - if (!parse_only && do_header) write_interface($$); - if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE); - if (!parse_only && do_idfile) write_iid($$); + type_interface_define($$, $2, $4); pointer_default = $1.old_pointer_default; - is_in_interface = FALSE; } /* MIDL is able to import the definition of a base class from inside the * definition of a derived class, I'll try to support it with this rule */ | interfacehdr ':' aIDENTIFIER '{' import int_statements '}' semicolon_opt { $$ = $1.interface; - $$->ref = find_type_or_error2($3, 0); - if (!$$->ref) error_loc("base class '%s' not found in import\n", $3); - $$->funcs = $6; - compute_method_indexes($$); - if (!parse_only && do_header) write_interface($$); - if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE); - if (!parse_only && do_idfile) write_iid($$); + type_interface_define($$, find_type_or_error2($3, 0), $6); pointer_default = $1.old_pointer_default; - is_in_interface = FALSE; } | dispinterfacedef semicolon_opt { $$ = $1; } ; interfacedec: - interface ';' { $$ = $1; if (!parse_only && do_header) write_forward($$); } - | dispinterface ';' { $$ = $1; if (!parse_only && do_header) write_forward($$); } + interface ';' { $$ = $1; } + | dispinterface ';' { $$ = $1; } ; module: tMODULE aIDENTIFIER { $$ = make_type(0, NULL); $$->name = $2; $$->kind = TKIND_MODULE; } @@ -986,8 +931,8 @@ modulehdr: attributes module { $$ = $2; moduledef: modulehdr '{' int_statements '}' semicolon_opt { $$ = $1; - $$->funcs = $3; - /* FIXME: if (!parse_only && do_header) write_module($$); */ + $$->stmts = $3; + $$->funcs = gen_function_list($3); } ; @@ -1026,7 +971,7 @@ decl_spec_no_type: declarator: '*' m_type_qual_list declarator %prec PPTR - { $$ = $3; $$->type = append_ptrchain_type($$->type, make_pointer_type(NULL, $2)); } + { $$ = $3; $$->type = append_ptrchain_type($$->type, type_new_pointer(NULL, $2)); } | callconv declarator { $$ = $2; $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); } | direct_declarator ; @@ -1036,7 +981,7 @@ direct_declarator: | '(' declarator ')' { $$ = $2; } | direct_declarator array { $$ = $1; $$->array = append_array($$->array, $2); } | direct_declarator '(' m_args ')' { $$ = $1; - $$->func_type = append_ptrchain_type($$->type, make_func_type($3)); + $$->func_type = append_ptrchain_type($$->type, type_new_function($3)); $$->type = NULL; } ; @@ -1057,16 +1002,7 @@ pointer_type: | tPTR { $$ = RPC_FC_FP; } ; -structdef: tSTRUCT t_ident '{' fields '}' { $$ = get_typev(RPC_FC_STRUCT, $2, tsSTRUCT); - /* overwrite RPC_FC_STRUCT with a more exact type */ - check_def($$); - $$->type = get_struct_type( $4 ); - $$->kind = TKIND_RECORD; - $$->fields_or_args = $4; - $$->defined = TRUE; - if(in_typelib) - add_typelib_entry($$); - } +structdef: tSTRUCT t_ident '{' fields '}' { $$ = type_new_struct($2, TRUE, $4); } ; type: tVOID { $$ = find_type_or_error("void", 0); } @@ -1075,7 +1011,7 @@ type: tVOID { $$ = find_type_or_error("void", 0); } | enumdef { $$ = $1; } | tENUM aIDENTIFIER { $$ = find_type_or_error2($2, tsENUM); } | structdef { $$ = $1; } - | tSTRUCT aIDENTIFIER { $$ = get_type(RPC_FC_STRUCT, $2, tsSTRUCT); } + | tSTRUCT aIDENTIFIER { $$ = type_new_struct($2, FALSE, NULL); } | uniondef { $$ = $1; } | tUNION aIDENTIFIER { $$ = find_type_or_error2($2, tsUNION); } | tSAFEARRAY '(' type ')' { $$ = make_safearray($3); } @@ -1083,32 +1019,15 @@ type: tVOID { $$ = find_type_or_error("void", 0); } typedef: tTYPEDEF m_attributes decl_spec declarator_list { reg_typedefs($3, $4, check_typedef_attrs($2)); - $$ = process_typedefs($4); + $$ = make_statement_typedef($4); } ; uniondef: tUNION t_ident '{' ne_union_fields '}' - { $$ = get_typev(RPC_FC_NON_ENCAPSULATED_UNION, $2, tsUNION); - check_def($$); - $$->kind = TKIND_UNION; - $$->fields_or_args = $4; - $$->defined = TRUE; - } + { $$ = type_new_nonencapsulated_union($2, $4); } | tUNION t_ident tSWITCH '(' s_field ')' - m_ident '{' cases '}' { var_t *u = $7; - $$ = get_typev(RPC_FC_ENCAPSULATED_UNION, $2, tsUNION); - check_def($$); - $$->kind = TKIND_UNION; - if (!u) u = make_var( xstrdup("tagged_union") ); - u->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL); - u->type->kind = TKIND_UNION; - u->type->fields_or_args = $9; - u->type->defined = TRUE; - $$->fields_or_args = append_var( $$->fields_or_args, $5 ); - $$->fields_or_args = append_var( $$->fields_or_args, u ); - $$->defined = TRUE; - } + m_ident '{' cases '}' { $$ = type_new_encapsulated_union($2, $5, $7, $9); } ; version: @@ -1366,6 +1285,13 @@ void set_all_tfswrite(int val) node->data.tfswrite = val; } +void clear_all_offsets(void) +{ + type_pool_node_t *node; + LIST_FOR_EACH_ENTRY(node, &type_pool, type_pool_node_t, link) + node->data.typestring_offset = node->data.ptrdesc = 0; +} + type_t *make_type(unsigned char type, type_t *ref) { type_t *t = alloc_type(); @@ -1376,7 +1302,7 @@ type_t *make_type(unsigned char type, type_t *ref) t->attrs = NULL; t->orig = NULL; t->funcs = NULL; - t->fields_or_args = NULL; + memset(&t->details, 0, sizeof(t->details)); t->ifaces = NULL; t->dim = 0; t->size_is = NULL; @@ -1396,18 +1322,87 @@ type_t *make_type(unsigned char type, type_t *ref) return t; } -static type_t *make_func_type(var_list_t *args) +static type_t *type_new_enum(char *name, var_list_t *enums) { - type_t *t = make_type(RPC_FC_FUNCTION, NULL); - t->fields_or_args = args; + type_t *t = get_type(RPC_FC_ENUM16, name, tsENUM); + t->kind = TKIND_ENUM; + if (enums) + { + t->details.enumeration = xmalloc(sizeof(*t->details.enumeration)); + t->details.enumeration->enums = enums; + } + else + t->details.enumeration = NULL; + t->defined = TRUE; + return t; +} + +static type_t *type_new_struct(char *name, int defined, var_list_t *fields) +{ + type_t *tag_type = name ? find_type(name, tsSTRUCT) : NULL; + type_t *t = make_type(RPC_FC_STRUCT, NULL); + t->name = name; + t->kind = TKIND_RECORD; + if (defined || (tag_type && tag_type->details.structure)) + { + if (tag_type && tag_type->details.structure) + { + t->details.structure = tag_type->details.structure; + t->type = tag_type->type; + } + else if (defined) + { + t->details.structure = xmalloc(sizeof(*t->details.structure)); + t->details.structure->fields = fields; + t->defined = TRUE; + } + } + if (name) + { + if (fields) + reg_type(t, name, tsSTRUCT); + else + add_incomplete(t); + } return t; } -static type_t *make_pointer_type(type_t *ref, attr_list_t *attrs) +static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields) { - type_t *t = make_type(pointer_default, ref); - t->attrs = attrs; - return t; + type_t *t = get_type(RPC_FC_NON_ENCAPSULATED_UNION, name, tsUNION); + t->kind = TKIND_UNION; + t->details.structure = xmalloc(sizeof(*t->details.structure)); + t->details.structure->fields = fields; + t->defined = TRUE; + return t; +} + +static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases) +{ + type_t *t = get_type(RPC_FC_ENCAPSULATED_UNION, name, tsUNION); + t->kind = TKIND_UNION; + if (!union_field) union_field = make_var( xstrdup("tagged_union") ); + union_field->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL); + union_field->type->kind = TKIND_UNION; + union_field->type->details.structure = xmalloc(sizeof(*union_field->type->details.structure)); + union_field->type->details.structure->fields = cases; + union_field->type->defined = TRUE; + t->details.structure = xmalloc(sizeof(*t->details.structure)); + t->details.structure->fields = append_var( NULL, switch_field ); + t->details.structure->fields = append_var( t->details.structure->fields, union_field ); + t->defined = TRUE; + return t; +} + +static void function_add_head_arg(func_t *func, var_t *arg) +{ + if (!func->def->type->details.function->args) + { + func->def->type->details.function->args = xmalloc( sizeof(*func->def->type->details.function->args) ); + list_init( func->def->type->details.function->args ); + } + list_add_head( func->def->type->details.function->args, &arg->entry ); + func->args = func->def->type->details.function->args; } static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type) @@ -1499,18 +1494,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, if (dim->is_const) { - unsigned int align = 0; - size_t size = type_memsize(v->type, &align); - - if (dim->cval <= 0) - error_loc("%s: array dimension must be positive\n", v->name); - - if (0xffffffffuL / size < (unsigned long) dim->cval) - error_loc("%s: total array size is too large\n", v->name); - else if (0xffffuL < size * dim->cval) - v->type = make_type(RPC_FC_LGFARRAY, v->type); - else - v->type = make_type(RPC_FC_SMFARRAY, v->type); + v->type = make_type(RPC_FC_LGFARRAY, v->type); } else { @@ -1581,29 +1565,6 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, } } - if (is_array(v->type)) - { - const type_t *rt = v->type->ref; - if (is_user_type(rt)) - v->type->type = RPC_FC_BOGUS_ARRAY; - else - switch (rt->type) - { - case RPC_FC_BOGUS_STRUCT: - case RPC_FC_NON_ENCAPSULATED_UNION: - case RPC_FC_ENCAPSULATED_UNION: - case RPC_FC_ENUM16: - v->type->type = RPC_FC_BOGUS_ARRAY; - break; - /* FC_RP should be above, but widl overuses these, and will break things. */ - case RPC_FC_UP: - case RPC_FC_RP: - if (rt->ref->type == RPC_FC_IP) - v->type->type = RPC_FC_BOGUS_ARRAY; - break; - } - } - /* v->type is currently pointing to the type on the left-side of the * declaration, so we need to fix this up so that it is the return type of the * function and make v->type point to the function side of the declaration */ @@ -1746,8 +1707,7 @@ static func_t *make_func(var_t *def) { func_t *f = xmalloc(sizeof(func_t)); f->def = def; - f->args = def->type->fields_or_args; - f->ignore = parse_only; + f->args = def->type->details.function->args; f->idx = -1; return f; } @@ -1773,7 +1733,6 @@ static typelib_t *make_library(const char *name, const attr_list_t *attrs) typelib->name = xstrdup(name); typelib->filename = NULL; typelib->attrs = attrs; - list_init( &typelib->entries ); list_init( &typelib->importlibs ); return typelib; } @@ -1818,6 +1777,8 @@ static type_t *reg_type(type_t *type, const char *name, int t) nt->t = t; nt->next = type_hash[hash]; type_hash[hash] = nt; + if ((t == tsSTRUCT || t == tsUNION)) + fix_incomplete_types(type); return type; } @@ -1838,7 +1799,8 @@ static void fix_type(type_t *t) if (t->kind == TKIND_ALIAS && is_incomplete(t)) { type_t *ot = t->orig; fix_type(ot); - t->fields_or_args = ot->fields_or_args; + if (is_struct(ot->type) || is_union(ot->type)) + t->details.structure = ot->details.structure; t->defined = ot->defined; } } @@ -1849,10 +1811,29 @@ static void fix_incomplete(void) LIST_FOR_EACH_ENTRY_SAFE(tn, next, &incomplete_types, struct typenode, entry) { fix_type(tn->type); + list_remove(&tn->entry); free(tn); } } +static void fix_incomplete_types(type_t *complete_type) +{ + struct typenode *tn, *next; + + LIST_FOR_EACH_ENTRY_SAFE(tn, next, &incomplete_types, struct typenode, entry) + { + if (((is_struct(complete_type->type) && is_struct(tn->type->type)) || + (is_union(complete_type->type) && is_union(tn->type->type))) && + !strcmp(complete_type->name, tn->type->name)) + { + tn->type->details.structure = complete_type->details.structure; + tn->type->type = complete_type->type; + list_remove(&tn->entry); + free(tn); + } + } +} + static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, attr_list_t *attrs) { const declarator_t *decl; @@ -1962,173 +1943,6 @@ static type_t *get_type(unsigned char type, char *name, int t) return reg_type(tp, name, t); } -static type_t *get_typev(unsigned char type, var_t *name, int t) -{ - char *sname = NULL; - if (name) { - sname = name->name; - free(name); - } - return get_type(type, sname, t); -} - -static int get_struct_type(var_list_t *fields) -{ - int has_pointer = 0; - int has_conformance = 0; - int has_variance = 0; - var_t *field; - - if (get_padding(fields)) - return RPC_FC_BOGUS_STRUCT; - - if (fields) LIST_FOR_EACH_ENTRY( field, fields, var_t, entry ) - { - type_t *t = field->type; - - if (is_user_type(t)) - return RPC_FC_BOGUS_STRUCT; - - if (is_ptr(t)) - { - do - t = t->ref; - while (is_ptr(t)); - - switch (t->type) - { - case RPC_FC_IP: - case RPC_FC_ENCAPSULATED_UNION: - case RPC_FC_NON_ENCAPSULATED_UNION: - case RPC_FC_BOGUS_STRUCT: - return RPC_FC_BOGUS_STRUCT; - } - - has_pointer = 1; - continue; - } - - if (field->type->declarray) - { - if (is_string_type(field->attrs, field->type)) - { - if (is_conformant_array(field->type)) - has_conformance = 1; - has_variance = 1; - continue; - } - - if (is_array(field->type->ref)) - return RPC_FC_BOGUS_STRUCT; - - if (is_conformant_array(field->type)) - { - has_conformance = 1; - if (field->type->declarray && list_next(fields, &field->entry)) - error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", - field->name); - } - if (field->type->length_is) - has_variance = 1; - - t = field->type->ref; - } - - switch (t->type) - { - /* - * RPC_FC_BYTE, RPC_FC_STRUCT, etc - * Simple types don't effect the type of struct. - * A struct containing a simple struct is still a simple struct. - * So long as we can block copy the data, we return RPC_FC_STRUCT. - */ - case 0: /* void pointer */ - case RPC_FC_BYTE: - case RPC_FC_CHAR: - case RPC_FC_SMALL: - case RPC_FC_USMALL: - case RPC_FC_WCHAR: - case RPC_FC_SHORT: - case RPC_FC_USHORT: - case RPC_FC_LONG: - case RPC_FC_ULONG: - case RPC_FC_INT3264: - case RPC_FC_UINT3264: - case RPC_FC_HYPER: - case RPC_FC_FLOAT: - case RPC_FC_DOUBLE: - case RPC_FC_STRUCT: - case RPC_FC_ENUM32: - break; - - case RPC_FC_RP: - case RPC_FC_UP: - case RPC_FC_FP: - case RPC_FC_OP: - case RPC_FC_CARRAY: - case RPC_FC_CVARRAY: - case RPC_FC_BOGUS_ARRAY: - has_pointer = 1; - break; - - /* - * Propagate member attributes - * a struct should be at least as complex as its member - */ - case RPC_FC_CVSTRUCT: - has_conformance = 1; - has_variance = 1; - has_pointer = 1; - break; - - case RPC_FC_CPSTRUCT: - has_conformance = 1; - if (list_next( fields, &field->entry )) - error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", - field->name); - has_pointer = 1; - break; - - case RPC_FC_CSTRUCT: - has_conformance = 1; - if (list_next( fields, &field->entry )) - error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", - field->name); - break; - - case RPC_FC_PSTRUCT: - has_pointer = 1; - break; - - default: - error_loc("Unknown struct member %s with type (0x%02x)\n", field->name, t->type); - /* fallthru - treat it as complex */ - - /* as soon as we see one of these these members, it's bogus... */ - case RPC_FC_ENCAPSULATED_UNION: - case RPC_FC_NON_ENCAPSULATED_UNION: - case RPC_FC_BOGUS_STRUCT: - case RPC_FC_ENUM16: - return RPC_FC_BOGUS_STRUCT; - } - } - - if( has_variance ) - { - if ( has_conformance ) - return RPC_FC_CVSTRUCT; - else - return RPC_FC_BOGUS_STRUCT; - } - if( has_conformance && has_pointer ) - return RPC_FC_CPSTRUCT; - if( has_conformance ) - return RPC_FC_CSTRUCT; - if( has_pointer ) - return RPC_FC_PSTRUCT; - return RPC_FC_STRUCT; -} - /***** constant repository *****/ struct rconst { @@ -2168,48 +1982,23 @@ var_t *find_const(const char *name, int f) return cur->var; } -static void write_libid(const typelib_t *typelib) +func_list_t *gen_function_list(const statement_list_t *stmts) { - const UUID *uuid = get_attrp(typelib->attrs, ATTR_UUID); - write_guid(idfile, "LIBID", typelib->name, uuid); -} - -static void write_clsid(type_t *cls) -{ - const UUID *uuid = get_attrp(cls->attrs, ATTR_UUID); - write_guid(idfile, "CLSID", cls->name, uuid); -} - -static void write_diid(type_t *iface) -{ - const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID); - write_guid(idfile, "DIID", iface->name, uuid); -} - -static void write_iid(type_t *iface) -{ - const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID); - write_guid(idfile, "IID", iface->name, uuid); -} - -static int compute_method_indexes(type_t *iface) -{ - int idx; - func_t *f; - - if (iface->ref) - idx = compute_method_indexes(iface->ref); - else - idx = 0; - - if (!iface->funcs) - return idx; - - LIST_FOR_EACH_ENTRY( f, iface->funcs, func_t, entry ) - if (! is_callas(f->def->attrs)) - f->idx = idx++; - - return idx; + func_list_t *func_list = NULL; + const statement_t *stmt; + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + if (stmt->type == STMT_DECLARATION) + { + var_t *var = stmt->u.var; + if (var->stgclass == STG_NONE && var->type->type == RPC_FC_FUNCTION) + { + check_function_attrs(var->name, var->type->attrs); + func_list = append_func(func_list, make_func(var)); + } + } + } + return func_list; } static char *gen_name(void) @@ -2245,6 +2034,9 @@ struct allowed_attr unsigned int on_function : 1; unsigned int on_arg : 1; unsigned int on_type : 1; + unsigned int on_enum : 1; + unsigned int on_struct : 1; + unsigned int on_union : 1; unsigned int on_field : 1; unsigned int on_library : 1; unsigned int on_dispinterface : 1; @@ -2255,79 +2047,79 @@ struct allowed_attr struct allowed_attr allowed_attr[] = { - /* attr { D ACF I Fn ARG T Fi L DI M C } */ - /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "aggregatable" }, - /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "appobject" }, - /* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, "async" }, - /* ATTR_AUTO_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" }, - /* ATTR_BINDABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "bindable" }, - /* ATTR_BROADCAST */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "broadcast" }, - /* ATTR_CALLAS */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "call_as" }, - /* ATTR_CALLCONV */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL }, - /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" }, - /* ATTR_CONST */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "const" }, - /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "context_handle" }, - /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" }, - /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, "default" }, - /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, - /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "defaultvalue" }, - /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" }, - /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, - /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, - /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" }, - /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, - /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, - /* ATTR_ENTRY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "entry" }, - /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, - /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "handle" }, - /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpcontext" }, - /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpfile" }, - /* ATTR_HELPSTRING */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpstring" }, - /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpstringcontext" }, - /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpstringdll" }, - /* ATTR_HIDDEN */ { 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, "hidden" }, - /* ATTR_ID */ { 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, "id" }, - /* ATTR_IDEMPOTENT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, - /* ATTR_IIDIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "iid_is" }, - /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, - /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, - /* ATTR_IN */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "in" }, - /* ATTR_INLINE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inline" }, - /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, - /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "length_is" }, - /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" }, - /* ATTR_LOCAL */ { 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "local" }, - /* ATTR_NONBROWSABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, - /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "noncreatable" }, - /* ATTR_NONEXTENSIBLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, - /* ATTR_OBJECT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, - /* ATTR_ODL */ { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, "odl" }, - /* ATTR_OLEAUTOMATION */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, - /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "optional" }, - /* ATTR_OUT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "out" }, - /* ATTR_POINTERDEFAULT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, - /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, "ref, unique or ptr" }, - /* ATTR_PROPGET */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propget" }, - /* ATTR_PROPPUT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propput" }, - /* ATTR_PROPPUTREF */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propputref" }, - /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "public" }, - /* ATTR_RANGE */ { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, "range" }, - /* ATTR_READONLY */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "readonly" }, - /* ATTR_REQUESTEDIT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, - /* ATTR_RESTRICTED */ { 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, "restricted" }, - /* ATTR_RETVAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "retval" }, - /* ATTR_SIZEIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "size_is" }, - /* ATTR_SOURCE */ { 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, "source" }, - /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" }, - /* ATTR_STRING */ { 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, "string" }, - /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "switch_is" }, - /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, "switch_type" }, - /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "transmit_as" }, - /* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, "uuid" }, - /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "v1_enum" }, - /* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "vararg" }, - /* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, "version" }, - /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "wire_marshal" }, + /* attr { D ACF I Fn ARG T En St Un Fi L DI M C } */ + /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "aggregatable" }, + /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "appobject" }, + /* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" }, + /* ATTR_AUTO_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" }, + /* ATTR_BINDABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "bindable" }, + /* ATTR_BROADCAST */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "broadcast" }, + /* ATTR_CALLAS */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "call_as" }, + /* ATTR_CALLCONV */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, + /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" }, + /* ATTR_CONST */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "const" }, + /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" }, + /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" }, + /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, "default" }, + /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, + /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultvalue" }, + /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" }, + /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, + /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, + /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" }, + /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, + /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, + /* ATTR_ENTRY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" }, + /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, + /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "handle" }, + /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpcontext" }, + /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpfile" }, + /* ATTR_HELPSTRING */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpstring" }, + /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "helpstringcontext" }, + /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpstringdll" }, + /* ATTR_HIDDEN */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, "hidden" }, + /* ATTR_ID */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "id" }, + /* ATTR_IDEMPOTENT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, + /* ATTR_IIDIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "iid_is" }, + /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, + /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, + /* ATTR_IN */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "in" }, + /* ATTR_INLINE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inline" }, + /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, + /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "length_is" }, + /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" }, + /* ATTR_LOCAL */ { 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" }, + /* ATTR_NONBROWSABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, + /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "noncreatable" }, + /* ATTR_NONEXTENSIBLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, + /* ATTR_OBJECT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, + /* ATTR_ODL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "odl" }, + /* ATTR_OLEAUTOMATION */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, + /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optional" }, + /* ATTR_OUT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "out" }, + /* ATTR_POINTERDEFAULT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, + /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "ref, unique or ptr" }, + /* ATTR_PROPGET */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propget" }, + /* ATTR_PROPPUT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propput" }, + /* ATTR_PROPPUTREF */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propputref" }, + /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "public" }, + /* ATTR_RANGE */ { 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, "range" }, + /* ATTR_READONLY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "readonly" }, + /* ATTR_REQUESTEDIT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, + /* ATTR_RESTRICTED */ { 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, "restricted" }, + /* ATTR_RETVAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "retval" }, + /* ATTR_SIZEIS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "size_is" }, + /* ATTR_SOURCE */ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "source" }, + /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" }, + /* ATTR_STRING */ { 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, "string" }, + /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, "switch_is" }, + /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, "switch_type" }, + /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "transmit_as" }, + /* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "uuid" }, + /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "v1_enum" }, + /* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" }, + /* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "version" }, + /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" }, }; const char *get_attr_display_name(enum attr_type type) @@ -2393,6 +2185,45 @@ static attr_list_t *check_typedef_attrs(attr_list_t *attrs) return attrs; } +static attr_list_t *check_enum_attrs(attr_list_t *attrs) +{ + const attr_t *attr; + if (!attrs) return attrs; + LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) + { + if (!allowed_attr[attr->type].on_enum) + error_loc("inapplicable attribute %s for enum\n", + allowed_attr[attr->type].display_name); + } + return attrs; +} + +static attr_list_t *check_struct_attrs(attr_list_t *attrs) +{ + const attr_t *attr; + if (!attrs) return attrs; + LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) + { + if (!allowed_attr[attr->type].on_struct) + error_loc("inapplicable attribute %s for struct\n", + allowed_attr[attr->type].display_name); + } + return attrs; +} + +static attr_list_t *check_union_attrs(attr_list_t *attrs) +{ + const attr_t *attr; + if (!attrs) return attrs; + LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) + { + if (!allowed_attr[attr->type].on_union) + error_loc("inapplicable attribute %s for union\n", + allowed_attr[attr->type].display_name); + } + return attrs; +} + static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs) { const attr_t *attr; @@ -2613,6 +2444,10 @@ static void check_remoting_fields(const var_t *var, type_t *type) const var_t *field; const var_list_t *fields = NULL; + /* find the real type */ + while (type->kind == TKIND_ALIAS) + type = type->orig; + if (type->checked) return; @@ -2620,21 +2455,13 @@ static void check_remoting_fields(const var_t *var, type_t *type) if (is_struct(type->type)) { - if (type->defined) - fields = type->fields_or_args; + if (type_is_complete(type)) + fields = type_struct_get_fields(type); else error_loc_info(&var->loc_info, "undefined type declaration %s\n", type->name); } else if (is_union(type->type)) - { - if (type->type == RPC_FC_ENCAPSULATED_UNION) - { - const var_t *uv = LIST_ENTRY(list_tail(type->fields_or_args), const var_t, entry); - fields = uv->type->fields_or_args; - } - else - fields = type->fields_or_args; - } + fields = type_union_get_cases(type); if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) if (field->type) check_field_common(type, type->name, field); @@ -2707,19 +2534,13 @@ static void add_explicit_handle_if_necessary(func_t *func) var_t *idl_handle = make_var(xstrdup("IDL_handle")); idl_handle->attrs = append_attr(NULL, make_attr(ATTR_IN)); idl_handle->type = find_type_or_error("handle_t", 0); - if (!func->def->type->fields_or_args) - { - func->def->type->fields_or_args = xmalloc( sizeof(*func->def->type->fields_or_args) ); - list_init( func->def->type->fields_or_args ); - } - list_add_head( func->def->type->fields_or_args, &idl_handle->entry ); - func->args = func->def->type->fields_or_args; + function_add_head_arg(func, idl_handle); } } } } -static void check_functions(const type_t *iface) +void check_functions(const type_t *iface) { if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE) && iface->funcs) { @@ -2746,7 +2567,8 @@ static void check_all_user_types(const statement_list_t *stmts) { if (stmt->type == STMT_LIBRARY) check_all_user_types(stmt->u.lib->stmts); - else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) + else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP && + !is_local(stmt->u.type->attrs)) { const func_t *f; const func_list_t *fs = stmt->u.type->funcs; @@ -2806,7 +2628,7 @@ static statement_t *make_statement_declaration(var_t *var) reg_const(var); } else if ((var->stgclass == STG_NONE || var->stgclass == STG_REGISTER) && - var->type->type != RPC_FC_FUNCTION) + var->type->type != RPC_FC_FUNCTION) error_loc("instantiation of data is illegal\n"); return stmt; } @@ -2846,7 +2668,7 @@ static statement_t *make_statement_module(type_t *type) return stmt; } -static statement_t *process_typedefs(declarator_list_t *decls) +static statement_t *make_statement_typedef(declarator_list_t *decls) { declarator_t *decl, *next; statement_t *stmt; @@ -2866,11 +2688,6 @@ static statement_t *process_typedefs(declarator_list_t *decls) (*type_list)->type = type; (*type_list)->next = NULL; - if (! parse_only && do_header) - write_typedef(type); - if (in_typelib && is_attr(type->attrs, ATTR_PUBLIC)) - add_typelib_entry(type); - type_list = &(*type_list)->next; free(decl); free(var); @@ -2891,20 +2708,6 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s return list; } -static func_list_t *append_func_from_statement(func_list_t *list, statement_t *stmt) -{ - if (stmt->type == STMT_DECLARATION) - { - var_t *var = stmt->u.var; - if (var->stgclass == STG_NONE && var->type->type == RPC_FC_FUNCTION) - { - check_function_attrs(var->name, var->type->attrs); - return append_func(list, make_func(stmt->u.var)); - } - } - return list; -} - void init_loc_info(loc_info_t *i) { i->input_name = input_name ? input_name : "stdin"; diff --git a/reactos/tools/widl/parser.yy.c b/reactos/tools/widl/parser.yy.c index 899a82123bc..677f9e36271 100644 --- a/reactos/tools/widl/parser.yy.c +++ b/reactos/tools/widl/parser.yy.c @@ -586,6 +586,8 @@ char *yytext; #include #include #include +#include +#include #ifdef HAVE_UNISTD_H #include @@ -621,6 +623,19 @@ struct { } import_stack[MAX_IMPORT_DEPTH]; int import_stack_ptr = 0; +/* converts an integer in string form to an unsigned long and prints an error + * on overflow */ +static unsigned long xstrtoul(const char *nptr, char **endptr, int base) +{ + unsigned long l; + + errno = 0; + l = strtoul(nptr, endptr, base); + if (l == ULONG_MAX && errno == ERANGE) + error_loc("integer constant %s is too large\n", nptr); + return l; +} + UUID *parse_uuid(const char *u) { UUID* uuid = xmalloc(sizeof(UUID)); @@ -646,7 +661,7 @@ UUID *parse_uuid(const char *u) * The flexer starts here ************************************************************************** */ -#line 650 "parser.yy.c" +#line 665 "parser.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -800,9 +815,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 112 "parser.l" +#line 127 "parser.l" -#line 806 "parser.yy.c" +#line 821 "parser.yy.c" if ( yy_init ) { @@ -888,12 +903,12 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 113 "parser.l" +#line 128 "parser.l" yy_push_state(PP_LINE); YY_BREAK case 2: YY_RULE_SETUP -#line 114 "parser.l" +#line 129 "parser.l" { int lineno; char *cptr, *fname; @@ -916,12 +931,12 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 133 "parser.l" +#line 148 "parser.l" yy_push_state(QUOTE); cbufidx = 0; YY_BREAK case 4: YY_RULE_SETUP -#line 134 "parser.l" +#line 149 "parser.l" { yy_pop_state(); parser_lval.str = get_buffered_cstring(); @@ -930,12 +945,12 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 139 "parser.l" +#line 154 "parser.l" yy_push_state(WSTRQUOTE); YY_BREAK case 6: YY_RULE_SETUP -#line 140 "parser.l" +#line 155 "parser.l" { yy_pop_state(); parser_lval.str = get_buffered_cstring(); @@ -943,40 +958,40 @@ YY_RULE_SETUP } YY_BREAK case 7: -#line 146 "parser.l" +#line 161 "parser.l" case 8: YY_RULE_SETUP -#line 146 "parser.l" +#line 161 "parser.l" addcchar(yytext[1]); YY_BREAK case 9: YY_RULE_SETUP -#line 147 "parser.l" +#line 162 "parser.l" addcchar('\\'); addcchar(yytext[1]); YY_BREAK case 10: YY_RULE_SETUP -#line 148 "parser.l" +#line 163 "parser.l" addcchar(yytext[0]); YY_BREAK case 11: YY_RULE_SETUP -#line 149 "parser.l" +#line 164 "parser.l" yy_push_state(ATTR); return '['; YY_BREAK case 12: YY_RULE_SETUP -#line 150 "parser.l" +#line 165 "parser.l" yy_pop_state(); return ']'; YY_BREAK case 13: YY_RULE_SETUP -#line 151 "parser.l" +#line 166 "parser.l" return attr_token(yytext); YY_BREAK case 14: YY_RULE_SETUP -#line 152 "parser.l" +#line 167 "parser.l" { parser_lval.uuid = parse_uuid(yytext); return aUUID; @@ -984,23 +999,23 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 156 "parser.l" +#line 171 "parser.l" { - parser_lval.num = strtoul(yytext, NULL, 0); + parser_lval.num = xstrtoul(yytext, NULL, 0); return aHEXNUM; } YY_BREAK case 16: YY_RULE_SETUP -#line 160 "parser.l" +#line 175 "parser.l" { - parser_lval.num = strtoul(yytext, NULL, 0); + parser_lval.num = xstrtoul(yytext, NULL, 0); return aNUM; } YY_BREAK case 17: YY_RULE_SETUP -#line 164 "parser.l" +#line 179 "parser.l" { parser_lval.dbl = strtod(yytext, NULL); return aDOUBLE; @@ -1011,72 +1026,72 @@ case 18: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 168 "parser.l" +#line 183 "parser.l" return tSAFEARRAY; YY_BREAK case 19: YY_RULE_SETUP -#line 169 "parser.l" +#line 184 "parser.l" return kw_token(yytext); YY_BREAK case 20: YY_RULE_SETUP -#line 170 "parser.l" +#line 185 "parser.l" line_number++; YY_BREAK case 21: YY_RULE_SETUP -#line 171 "parser.l" +#line 186 "parser.l" YY_BREAK case 22: YY_RULE_SETUP -#line 172 "parser.l" +#line 187 "parser.l" return SHL; YY_BREAK case 23: YY_RULE_SETUP -#line 173 "parser.l" +#line 188 "parser.l" return SHR; YY_BREAK case 24: YY_RULE_SETUP -#line 174 "parser.l" +#line 189 "parser.l" return MEMBERPTR; YY_BREAK case 25: YY_RULE_SETUP -#line 175 "parser.l" +#line 190 "parser.l" return EQUALITY; YY_BREAK case 26: YY_RULE_SETUP -#line 176 "parser.l" +#line 191 "parser.l" return INEQUALITY; YY_BREAK case 27: YY_RULE_SETUP -#line 177 "parser.l" +#line 192 "parser.l" return GREATEREQUAL; YY_BREAK case 28: YY_RULE_SETUP -#line 178 "parser.l" +#line 193 "parser.l" return LESSEQUAL; YY_BREAK case 29: YY_RULE_SETUP -#line 179 "parser.l" +#line 194 "parser.l" return LOGICALOR; YY_BREAK case 30: YY_RULE_SETUP -#line 180 "parser.l" +#line 195 "parser.l" return LOGICALAND; YY_BREAK case 31: YY_RULE_SETUP -#line 181 "parser.l" +#line 196 "parser.l" return yytext[0]; YY_BREAK case YY_STATE_EOF(INITIAL): @@ -1084,7 +1099,7 @@ case YY_STATE_EOF(QUOTE): case YY_STATE_EOF(WSTRQUOTE): case YY_STATE_EOF(ATTR): case YY_STATE_EOF(PP_LINE): -#line 182 "parser.l" +#line 197 "parser.l" { if (import_stack_ptr) return aEOF; @@ -1093,10 +1108,10 @@ case YY_STATE_EOF(PP_LINE): YY_BREAK case 32: YY_RULE_SETUP -#line 187 "parser.l" +#line 202 "parser.l" ECHO; YY_BREAK -#line 1100 "parser.yy.c" +#line 1115 "parser.yy.c" case YY_END_OF_BUFFER: { @@ -1982,7 +1997,7 @@ int main() return 0; } #endif -#line 187 "parser.l" +#line 202 "parser.l" #ifndef parser_wrap @@ -2043,7 +2058,7 @@ static const struct keyword keywords[] = { {"short", tSHORT}, {"signed", tSIGNED}, {"sizeof", tSIZEOF}, - {"small", tSMALL}, + {"small", tSMALL}, {"static", tSTATIC}, {"stdcall", tSTDCALL}, {"struct", tSTRUCT}, diff --git a/reactos/tools/widl/proxy.c b/reactos/tools/widl/proxy.c index 4476e39d146..b11aacef9ab 100644 --- a/reactos/tools/widl/proxy.c +++ b/reactos/tools/widl/proxy.c @@ -109,8 +109,24 @@ static void init_proxy(const statement_list_t *stmts) print_proxy( "\n"); print_proxy( "#include \"%s\"\n", header_name); print_proxy( "\n"); - write_formatstringsdecl(proxy, indent, stmts, need_proxy); - write_stubdescproto(); + print_proxy( "#ifndef DECLSPEC_HIDDEN\n"); + print_proxy( "#define DECLSPEC_HIDDEN\n"); + print_proxy( "#endif\n"); + print_proxy( "\n"); + write_exceptions( proxy ); + print_proxy( "\n"); + print_proxy( "struct __proxy_frame\n"); + print_proxy( "{\n"); + print_proxy( " __DECL_EXCEPTION_FRAME\n"); + print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n"); + print_proxy( " void *This;\n"); + print_proxy( "};\n"); + print_proxy( "\n"); + print_proxy("static int __proxy_filter( struct __proxy_frame *__frame )\n"); + print_proxy( "{\n"); + print_proxy( " return (__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE);\n"); + print_proxy( "}\n"); + print_proxy( "\n"); } static void clear_output_vars( const var_list_t *args ) @@ -145,6 +161,9 @@ int cant_be_null(const var_t *v) if (is_aliaschain_attr(type, ATTR_CONTEXTHANDLE)) return 0; + if (is_user_type(type)) + return 0; + if (! attrs && type) { attrs = type->attrs; @@ -173,6 +192,29 @@ int cant_be_null(const var_t *v) return 1; /* Default is RPC_FC_RP. */ } +static int need_delegation(const type_t *iface) +{ + return iface->ref && iface->ref->ref && iface->ref->ignore; +} + +static int get_delegation_indirect(const type_t *iface, const type_t ** delegate_to) +{ + const type_t * cur_iface; + for (cur_iface = iface; cur_iface != NULL; cur_iface = cur_iface->ref) + if (need_delegation(cur_iface)) + { + if(delegate_to) + *delegate_to = cur_iface->ref; + return 1; + } + return 0; +} + +static int need_delegation_indirect(const type_t *iface) +{ + return get_delegation_indirect(iface, NULL); +} + static void proxy_check_pointers( const var_list_t *args ) { const var_t *arg; @@ -189,7 +231,7 @@ static void proxy_check_pointers( const var_list_t *args ) } } -static void free_variable( const var_t *arg ) +static void free_variable( const var_t *arg, const char *local_var_prefix ) { unsigned int type_offset = arg->type->typestring_offset; expr_t *iid; @@ -198,10 +240,10 @@ static void free_variable( const var_t *arg ) if (size) { - print_proxy( "_StubMsg.MaxCount = " ); - write_expr(proxy, size, 0, 1, NULL, NULL); + print_proxy( "__frame->_StubMsg.MaxCount = " ); + write_expr(proxy, size, 0, 1, NULL, NULL, local_var_prefix); fprintf(proxy, ";\n\n"); - print_proxy( "NdrClearOutParameters( &_StubMsg, "); + print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, "); fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset ); fprintf(proxy, "(void*)%s );\n", arg->name ); return; @@ -226,11 +268,11 @@ static void free_variable( const var_t *arg ) iid = get_attrp( arg->attrs, ATTR_IIDIS ); if( iid ) { - print_proxy( "_StubMsg.MaxCount = (unsigned long) " ); - write_expr(proxy, iid, 1, 1, NULL, NULL); + print_proxy( "__frame->_StubMsg.MaxCount = (ULONG_PTR) " ); + write_expr(proxy, iid, 1, 1, NULL, NULL, local_var_prefix); print_proxy( ";\n\n" ); } - print_proxy( "NdrClearOutParameters( &_StubMsg, "); + print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, "); fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset ); fprintf(proxy, "(void*)%s );\n", arg->name ); break; @@ -240,7 +282,7 @@ static void free_variable( const var_t *arg ) } } -static void proxy_free_variables( var_list_t *args ) +static void proxy_free_variables( var_list_t *args, const char *local_var_prefix ) { const var_t *arg; @@ -248,7 +290,7 @@ static void proxy_free_variables( var_list_t *args ) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) if (is_attr(arg->attrs, ATTR_OUT)) { - free_variable( arg ); + free_variable( arg, local_var_prefix ); fprintf(proxy, "\n"); } } @@ -263,12 +305,23 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, if (!callconv) callconv = ""; indent = 0; + print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n", + iface->name, get_name(def) ); + print_proxy( "{\n"); + indent++; + if (has_full_pointer) write_full_pointer_free(proxy, indent, cur); + print_proxy( "NdrProxyFreeBuffer( __frame->This, &__frame->_StubMsg );\n" ); + indent--; + print_proxy( "}\n"); + print_proxy( "\n"); + write_type_decl_left(proxy, get_func_return_type(cur)); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(def)); write_args(proxy, cur->args, iface->name, 1, TRUE); print_proxy( ")\n"); print_proxy( "{\n"); indent ++; + print_proxy( "struct __proxy_frame __f, * const __frame = &__f;\n" ); /* local variables */ if (has_ret) { print_proxy( "" ); @@ -281,7 +334,6 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, print_proxy(" _RetVal = 0;\n"); } print_proxy( "RPC_MESSAGE _RpcMessage;\n" ); - print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n" ); if (has_ret) { if (decl_indirect(get_func_return_type(cur))) print_proxy("void *_p_%s = &%s;\n", @@ -289,6 +341,9 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, } print_proxy( "\n"); + print_proxy( "RpcExceptionInit( __proxy_filter, __finally_%s_%s_Proxy );\n", iface->name, get_name(def) ); + print_proxy( "__frame->This = This;\n" ); + if (has_full_pointer) write_full_pointer_init(proxy, indent, cur, FALSE); @@ -298,31 +353,31 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, print_proxy( "RpcTryExcept\n" ); print_proxy( "{\n" ); indent++; - print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &_StubMsg, &Object_StubDesc, %d);\n", idx); + print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &__frame->_StubMsg, &Object_StubDesc, %d);\n", idx); proxy_check_pointers( cur->args ); print_proxy( "RpcTryFinally\n" ); print_proxy( "{\n" ); indent++; - write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_BUFFERSIZE); + write_remoting_arguments(proxy, indent, cur, "", PASS_IN, PHASE_BUFFERSIZE); - print_proxy( "NdrProxyGetBuffer(This, &_StubMsg);\n" ); + print_proxy( "NdrProxyGetBuffer(This, &__frame->_StubMsg);\n" ); - write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_MARSHAL); + write_remoting_arguments(proxy, indent, cur, "", PASS_IN, PHASE_MARSHAL); - print_proxy( "NdrProxySendReceive(This, &_StubMsg);\n" ); + print_proxy( "NdrProxySendReceive(This, &__frame->_StubMsg);\n" ); fprintf(proxy, "\n"); - print_proxy( "_StubMsg.BufferStart = _RpcMessage.Buffer;\n" ); - print_proxy( "_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" ); + print_proxy( "__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n" ); + print_proxy( "__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" ); print_proxy("if ((_RpcMessage.DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; - print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset ); + print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset ); indent--; fprintf(proxy, "\n"); - write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_UNMARSHAL); + write_remoting_arguments(proxy, indent, cur, "", PASS_OUT, PHASE_UNMARSHAL); if (has_ret) { @@ -330,7 +385,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal"); else if (is_ptr(get_func_return_type(cur)) || is_array(get_func_return_type(cur))) print_proxy("%s = 0;\n", "_RetVal"); - write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_UNMARSHAL); + write_remoting_arguments(proxy, indent, cur, "", PASS_RETURN, PHASE_UNMARSHAL); } indent--; @@ -338,19 +393,17 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, print_proxy( "RpcFinally\n" ); print_proxy( "{\n" ); indent++; - if (has_full_pointer) - write_full_pointer_free(proxy, indent, cur); - print_proxy( "NdrProxyFreeBuffer(This, &_StubMsg);\n" ); + print_proxy( "__finally_%s_%s_Proxy( __frame );\n", iface->name, get_name(def) ); indent--; print_proxy( "}\n"); print_proxy( "RpcEndFinally\n" ); indent--; print_proxy( "}\n" ); - print_proxy( "RpcExcept(_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" ); + print_proxy( "RpcExcept(__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" ); print_proxy( "{\n" ); if (has_ret) { indent++; - proxy_free_variables( cur->args ); + proxy_free_variables( cur->args, "" ); print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" ); indent--; } @@ -374,6 +427,24 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas, int has_full_pointer = is_full_pointer_function(cur); indent = 0; + print_proxy( "struct __frame_%s_%s_Stub\n{\n", iface->name, get_name(def)); + indent++; + print_proxy( "__DECL_EXCEPTION_FRAME\n" ); + print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n"); + print_proxy( "%s * _This;\n", iface->name ); + declare_stub_args( proxy, indent, cur ); + indent--; + print_proxy( "};\n\n" ); + + print_proxy( "static void __finally_%s_%s_Stub(", iface->name, get_name(def) ); + print_proxy( " struct __frame_%s_%s_Stub *__frame )\n{\n", iface->name, get_name(def) ); + indent++; + write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_OUT, PHASE_FREE); + if (has_full_pointer) + write_full_pointer_free(proxy, indent, cur); + indent--; + print_proxy( "}\n\n" ); + print_proxy( "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(def)); indent++; print_proxy( "IRpcStubBuffer* This,\n"); @@ -383,17 +454,18 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas, indent--; print_proxy( "{\n"); indent++; - print_proxy("%s * _This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n", iface->name, iface->name); - print_proxy("MIDL_STUB_MESSAGE _StubMsg;\n"); - declare_stub_args( proxy, indent, cur ); - fprintf(proxy, "\n"); + print_proxy( "struct __frame_%s_%s_Stub __f, * const __frame = &__f;\n\n", + iface->name, get_name(def) ); + + print_proxy("__frame->_This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n\n", iface->name); /* FIXME: trace */ - print_proxy("NdrStubInitialize(_pRpcMessage, &_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n"); + print_proxy("NdrStubInitialize(_pRpcMessage, &__frame->_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n"); fprintf(proxy, "\n"); + print_proxy( "RpcExceptionInit( 0, __finally_%s_%s_Stub );\n", iface->name, get_name(def) ); - write_parameters_init(proxy, indent, cur); + write_parameters_init(proxy, indent, cur, "__frame->"); print_proxy("RpcTryFinally\n"); print_proxy("{\n"); @@ -402,73 +474,82 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas, write_full_pointer_init(proxy, indent, cur, TRUE); print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; - print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset ); + print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset ); indent--; fprintf(proxy, "\n"); - write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_UNMARSHAL); + write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_IN, PHASE_UNMARSHAL); fprintf(proxy, "\n"); - assign_stub_out_args( proxy, indent, cur ); + assign_stub_out_args( proxy, indent, cur, "__frame->" ); print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n"); fprintf(proxy, "\n"); print_proxy(""); - if (has_ret) fprintf(proxy, "_RetVal = "); + if (has_ret) fprintf(proxy, "__frame->_RetVal = "); if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas); - else fprintf(proxy, "_This->lpVtbl->%s", get_name(def)); - fprintf(proxy, "(_This"); + else fprintf(proxy, "__frame->_This->lpVtbl->%s", get_name(def)); + fprintf(proxy, "(__frame->_This"); if (cur->args) { LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry ) - fprintf(proxy, ", %s%s", arg->type->declarray ? "*" : "", get_name(arg)); + fprintf(proxy, ", %s__frame->%s", arg->type->declarray ? "*" : "", arg->name); } fprintf(proxy, ");\n"); fprintf(proxy, "\n"); print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n"); fprintf(proxy, "\n"); - write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_BUFFERSIZE); + write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_OUT, PHASE_BUFFERSIZE); if (!is_void(get_func_return_type(cur))) - write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_BUFFERSIZE); + write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE); - print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &_StubMsg);\n"); + print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &__frame->_StubMsg);\n"); - write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_MARSHAL); + write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_OUT, PHASE_MARSHAL); fprintf(proxy, "\n"); /* marshall the return value */ if (!is_void(get_func_return_type(cur))) - write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_MARSHAL); + write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_RETURN, PHASE_MARSHAL); indent--; print_proxy("}\n"); print_proxy("RpcFinally\n"); print_proxy("{\n"); - - write_remoting_arguments(proxy, indent+1, cur, PASS_OUT, PHASE_FREE); - - if (has_full_pointer) - write_full_pointer_free(proxy, indent, cur); - + indent++; + print_proxy( "__finally_%s_%s_Stub( __frame );\n", iface->name, get_name(def) ); + indent--; print_proxy("}\n"); print_proxy("RpcEndFinally\n"); - print_proxy("_pRpcMessage->BufferLength = _StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n"); + print_proxy("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n"); indent--; print_proxy("}\n"); print_proxy("\n"); } +static int count_methods(type_t *iface) +{ + const func_t *cur; + int count = 0; + + if (iface->ref) count = count_methods(iface->ref); + if (iface->funcs) + LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) + if (!is_callas(cur->def->attrs)) count++; + return count; +} + static int write_proxy_methods(type_t *iface, int skip) { const func_t *cur; int i = 0; - if (iface->ref) i = write_proxy_methods(iface->ref, iface->ref->ref != NULL); + if (iface->ref) i = write_proxy_methods(iface->ref, need_delegation(iface)); if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) { var_t *def = cur->def; if (!is_callas(def->attrs)) { @@ -486,7 +567,7 @@ static int write_stub_methods(type_t *iface, int skip) const func_t *cur; int i = 0; - if (iface->ref) i = write_stub_methods(iface->ref, TRUE); + if (iface->ref) i = write_stub_methods(iface->ref, need_delegation(iface)); else return i; /* skip IUnknown */ if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) { @@ -503,17 +584,15 @@ static int write_stub_methods(type_t *iface, int skip) static void write_proxy(type_t *iface, unsigned int *proc_offset) { - int midx = -1, stubs; + int midx = -1, count; const func_t *cur; - if (!iface->funcs) return; - /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */ fprintf(proxy, "/*****************************************************************************\n"); fprintf(proxy, " * %s interface\n", iface->name); fprintf(proxy, " */\n"); - LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) + if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) { const var_t *def = cur->def; if (!is_local(def->attrs)) { @@ -538,8 +617,11 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) } } + count = count_methods(iface); + if (midx != -1 && midx != count) error("invalid count %u/%u\n", count, midx); + /* proxy vtable */ - print_proxy( "static const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", midx, iface->name); + print_proxy( "static const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", count, iface->name); print_proxy( "{\n"); indent++; print_proxy( "{\n", iface->name); @@ -561,25 +643,26 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name); print_proxy( "{\n"); indent++; - stubs = write_stub_methods(iface, FALSE); + write_stub_methods(iface, FALSE); fprintf(proxy, "\n"); indent--; fprintf(proxy, "};\n"); print_proxy( "\n"); - print_proxy( "static const CInterfaceStubVtbl _%sStubVtbl =\n", iface->name); + print_proxy( "static %sCInterfaceStubVtbl _%sStubVtbl =\n", + need_delegation_indirect(iface) ? "" : "const ", iface->name); print_proxy( "{\n"); indent++; print_proxy( "{\n"); indent++; print_proxy( "&IID_%s,\n", iface->name); print_proxy( "0,\n"); - print_proxy( "%d,\n", stubs+3); + print_proxy( "%d,\n", count); print_proxy( "&%s_table[-3],\n", iface->name); indent--; print_proxy( "},\n", iface->name); print_proxy( "{\n"); indent++; - print_proxy( "CStdStubBuffer_METHODS\n"); + print_proxy( "CStdStubBuffer_%s\n", need_delegation_indirect(iface) ? "DELEGATING_METHODS" : "METHODS"); indent--; print_proxy( "}\n"); indent--; @@ -644,58 +727,53 @@ static void write_proxy_stmts(const statement_list_t *stmts, unsigned int *proc_ } } -static void write_proxy_iface_name_format(const statement_list_t *stmts, const char *format) +static int cmp_iid( const void *ptr1, const void *ptr2 ) { - const statement_t *stmt; - if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) - { - if (stmt->type == STMT_LIBRARY) - write_proxy_iface_name_format(stmt->u.lib->stmts, format); - else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) - { - type_t *iface = stmt->u.type; - if (iface->ref && iface->funcs && need_proxy(iface)) - fprintf(proxy, format, iface->name); - } - } + const type_t * const *iface1 = ptr1; + const type_t * const *iface2 = ptr2; + const UUID *uuid1 = get_attrp( (*iface1)->attrs, ATTR_UUID ); + const UUID *uuid2 = get_attrp( (*iface2)->attrs, ATTR_UUID ); + return memcmp( uuid1, uuid2, sizeof(UUID) ); } -static void write_iid_lookup(const statement_list_t *stmts, const char *file_id, int *c) +static void build_iface_list( const statement_list_t *stmts, type_t **ifaces[], int *count ) { - const statement_t *stmt; - if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) - { - if (stmt->type == STMT_LIBRARY) - write_iid_lookup(stmt->u.lib->stmts, file_id, c); - else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) + const statement_t *stmt; + + if (!stmts) return; + LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) { - type_t *iface = stmt->u.type; - if(iface->ref && iface->funcs && need_proxy(iface)) - { - fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, *c); - fprintf(proxy, " {\n"); - fprintf(proxy, " *pIndex = %d;\n", *c); - fprintf(proxy, " return 1;\n"); - fprintf(proxy, " }\n"); - (*c)++; - } + if (stmt->type == STMT_LIBRARY) + build_iface_list(stmt->u.lib->stmts, ifaces, count); + else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) + { + type_t *iface = stmt->u.type; + if (iface->ref && need_proxy(iface)) + { + *ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(*ifaces) ); + (*ifaces)[(*count)++] = iface; + } + } } - } } -void write_proxies(const statement_list_t *stmts) +static type_t **sort_interfaces( const statement_list_t *stmts, int *count ) +{ + type_t **ifaces = NULL; + + *count = 0; + build_iface_list( stmts, &ifaces, count ); + qsort( ifaces, *count, sizeof(*ifaces), cmp_iid ); + return ifaces; +} + +static void write_proxy_routines(const statement_list_t *stmts) { int expr_eval_routines; - char *file_id = proxy_token; - int c; unsigned int proc_offset = 0; - if (!do_proxies) return; - if (do_everything && !need_proxy_file(stmts)) return; - - init_proxy(stmts); - if(!proxy) return; - + write_formatstringsdecl(proxy, indent, stmts, need_proxy); + write_stubdescproto(); write_proxy_stmts(stmts, &proc_offset); expr_eval_routines = write_expr_eval_routines(proxy, proxy_token); @@ -704,52 +782,115 @@ void write_proxies(const statement_list_t *stmts) write_user_quad_list(proxy); write_stubdesc(expr_eval_routines); - print_proxy( "#if !defined(__RPC_WIN32__)\n"); + print_proxy( "#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32); print_proxy( "#error Currently only Wine and WIN32 are supported.\n"); print_proxy( "#endif\n"); print_proxy( "\n"); write_procformatstring(proxy, stmts, need_proxy); write_typeformatstring(proxy, stmts, need_proxy); +} + +void write_proxies(const statement_list_t *stmts) +{ + char *file_id = proxy_token; + int i, count, have_baseiid; + type_t **interfaces; + const type_t * delegate_to; + + if (!do_proxies) return; + if (do_everything && !need_proxy_file(stmts)) return; + + init_proxy(stmts); + if(!proxy) return; + + if (do_win32 && do_win64) + { + fprintf(proxy, "\n#ifndef _WIN64\n\n"); + pointer_size = 4; + write_proxy_routines( stmts ); + fprintf(proxy, "\n#else /* _WIN64 */\n\n"); + pointer_size = 8; + write_proxy_routines( stmts ); + fprintf(proxy, "#endif /* _WIN64 */\n\n"); + } + else if (do_win32) + { + pointer_size = 4; + write_proxy_routines( stmts ); + } + else if (do_win64) + { + pointer_size = 8; + write_proxy_routines( stmts ); + } + + interfaces = sort_interfaces(stmts, &count); fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id); fprintf(proxy, "{\n"); - write_proxy_iface_name_format(stmts, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n"); + for (i = 0; i < count; i++) + fprintf(proxy, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", interfaces[i]->name); fprintf(proxy, " 0\n"); fprintf(proxy, "};\n"); fprintf(proxy, "\n"); fprintf(proxy, "static const CInterfaceStubVtbl* const _%s_StubVtblList[] =\n", file_id); fprintf(proxy, "{\n"); - write_proxy_iface_name_format(stmts, " (const CInterfaceStubVtbl*)&_%sStubVtbl,\n"); + for (i = 0; i < count; i++) + fprintf(proxy, " &_%sStubVtbl,\n", interfaces[i]->name); fprintf(proxy, " 0\n"); fprintf(proxy, "};\n"); fprintf(proxy, "\n"); fprintf(proxy, "static PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id); fprintf(proxy, "{\n"); - write_proxy_iface_name_format(stmts, " \"%s\",\n"); + for (i = 0; i < count; i++) + fprintf(proxy, " \"%s\",\n", interfaces[i]->name); fprintf(proxy, " 0\n"); fprintf(proxy, "};\n"); fprintf(proxy, "\n"); - fprintf(proxy, "#define _%s_CHECK_IID(n) IID_GENERIC_CHECK_IID(_%s, pIID, n)\n", file_id, file_id); - fprintf(proxy, "\n"); - fprintf(proxy, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id); + if ((have_baseiid = does_any_iface(stmts, need_delegation_indirect))) + { + fprintf(proxy, "static const IID * _%s_BaseIIDList[] =\n", file_id); + fprintf(proxy, "{\n"); + for (i = 0; i < count; i++) + { + if (get_delegation_indirect(interfaces[i], &delegate_to)) + fprintf( proxy, " &IID_%s, /* %s */\n", delegate_to->name, interfaces[i]->name ); + else + fprintf( proxy, " 0,\n" ); + } + fprintf(proxy, " 0\n"); + fprintf(proxy, "};\n"); + fprintf(proxy, "\n"); + } + + fprintf(proxy, "static int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id); fprintf(proxy, "{\n"); - c = 0; - write_iid_lookup(stmts, file_id, &c); + fprintf(proxy, " int low = 0, high = %d;\n", count - 1); + fprintf(proxy, "\n"); + fprintf(proxy, " while (low <= high)\n"); + fprintf(proxy, " {\n"); + fprintf(proxy, " int pos = (low + high) / 2;\n"); + fprintf(proxy, " int res = IID_GENERIC_CHECK_IID(_%s, pIID, pos);\n", file_id); + fprintf(proxy, " if (!res) { *pIndex = pos; return 1; }\n"); + fprintf(proxy, " if (res > 0) low = pos + 1;\n"); + fprintf(proxy, " else high = pos - 1;\n"); + fprintf(proxy, " }\n"); fprintf(proxy, " return 0;\n"); fprintf(proxy, "}\n"); fprintf(proxy, "\n"); - fprintf(proxy, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id); + fprintf(proxy, "const ExtendedProxyFileInfo %s_ProxyFileInfo DECLSPEC_HIDDEN =\n", file_id); fprintf(proxy, "{\n"); fprintf(proxy, " (const PCInterfaceProxyVtblList*)_%s_ProxyVtblList,\n", file_id); fprintf(proxy, " (const PCInterfaceStubVtblList*)_%s_StubVtblList,\n", file_id); fprintf(proxy, " _%s_InterfaceNamesList,\n", file_id); - fprintf(proxy, " 0,\n"); + if (have_baseiid) fprintf(proxy, " _%s_BaseIIDList,\n", file_id); + else fprintf(proxy, " 0,\n"); fprintf(proxy, " _%s_IID_Lookup,\n", file_id); - fprintf(proxy, " %d,\n", c); + fprintf(proxy, " %d,\n", count); fprintf(proxy, " 1,\n"); fprintf(proxy, " 0,\n"); fprintf(proxy, " 0,\n"); diff --git a/reactos/tools/widl/server.c b/reactos/tools/widl/server.c index d79447bf156..20d0e7e43c7 100644 --- a/reactos/tools/widl/server.c +++ b/reactos/tools/widl/server.c @@ -63,34 +63,52 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) /* check for a defined binding handle */ explicit_handle_var = get_explicit_handle_var(func); + print_server("struct __frame_%s_%s\n{\n", iface->name, get_name(def)); + indent++; + print_server("__DECL_EXCEPTION_FRAME\n"); + print_server("MIDL_STUB_MESSAGE _StubMsg;\n"); + + /* Declare arguments */ + declare_stub_args(server, indent, func); + + indent--; + print_server("};\n\n"); + + print_server("static void __finally_%s_%s(", iface->name, get_name(def)); + fprintf(server," struct __frame_%s_%s *__frame )\n{\n", iface->name, get_name(def)); + + indent++; + write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_FREE); + + if (has_full_pointer) + write_full_pointer_free(server, indent, func); + + indent--; + print_server("}\n\n"); + print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(def)); /* write the functions body */ fprintf(server, "{\n"); indent++; - - /* Declare arguments */ - declare_stub_args(server, indent, func); - - print_server("MIDL_STUB_MESSAGE _StubMsg;\n"); - print_server("RPC_STATUS _Status;\n"); + print_server("struct __frame_%s_%s __f, * const __frame = &__f;\n", iface->name, get_name(def)); + if (has_out_arg_or_return(func)) print_server("RPC_STATUS _Status;\n"); fprintf(server, "\n"); - - print_server("((void)(_Status));\n"); print_server("NdrServerInitializeNew(\n"); indent++; print_server("_pRpcMessage,\n"); - print_server("&_StubMsg,\n"); + print_server("&__frame->_StubMsg,\n"); print_server("&%s_StubDesc);\n", iface->name); indent--; fprintf(server, "\n"); + print_server( "RpcExceptionInit( __server_filter, __finally_%s_%s );\n", iface->name, get_name(def)); - write_parameters_init(server, indent, func); + write_parameters_init(server, indent, func, "__frame->"); if (explicit_handle_var) { - print_server("%s = _pRpcMessage->Handle;\n", explicit_handle_var->name); + print_server("__frame->%s = _pRpcMessage->Handle;\n", explicit_handle_var->name); fprintf(server, "\n"); } @@ -108,18 +126,16 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) { print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; - print_server("NdrConvert(\n"); - indent++; - print_server("(PMIDL_STUB_MESSAGE)&_StubMsg,\n"); - print_server("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", *proc_offset); - indent -= 2; + print_server("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", + *proc_offset); + indent--; fprintf(server, "\n"); /* unmarshall arguments */ - write_remoting_arguments(server, indent, func, PASS_IN, PHASE_UNMARSHAL); + write_remoting_arguments(server, indent, func, "__frame->", PASS_IN, PHASE_UNMARSHAL); } - print_server("if (_StubMsg.Buffer > _StubMsg.BufferEnd)\n"); + print_server("if (__frame->_StubMsg.Buffer > __frame->_StubMsg.BufferEnd)\n"); print_server("{\n"); indent++; print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); @@ -137,11 +153,11 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) fprintf(server, "\n"); /* Assign 'out' arguments */ - assign_stub_out_args(server, indent, func); + assign_stub_out_args(server, indent, func, "__frame->"); /* Call the real server function */ if (!is_void(get_func_return_type(func))) - print_server("_RetVal = "); + print_server("__frame->_RetVal = "); else print_server(""); fprintf(server, "%s%s", prefix_server, get_name(def)); @@ -166,11 +182,12 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) int is_ch_ptr = is_aliaschain_attr(var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE; print_server("("); write_type_decl_left(server, var->type); - fprintf(server, ")%sNDRSContextValue(%s)", is_ch_ptr ? "" : "*", var->name); + fprintf(server, ")%sNDRSContextValue(__frame->%s)", + is_ch_ptr ? "" : "*", var->name); } else { - print_server("%s%s", var->type->declarray ? "*" : "", get_name(var)); + print_server("%s__frame->%s", var->type->declarray ? "*" : "", var->name); } } fprintf(server, ");\n"); @@ -183,12 +200,12 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) if (has_out_arg_or_return(func)) { - write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_BUFFERSIZE); + write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE); if (!is_void(get_func_return_type(func))) - write_remoting_arguments(server, indent, func, PASS_RETURN, PHASE_BUFFERSIZE); + write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE); - print_server("_pRpcMessage->BufferLength = _StubMsg.BufferLength;\n"); + print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.BufferLength;\n"); fprintf(server, "\n"); print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n"); print_server("if (_Status)\n"); @@ -196,38 +213,30 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_server("RpcRaiseException(_Status);\n"); indent--; fprintf(server, "\n"); - print_server("_StubMsg.Buffer = (unsigned char *)_pRpcMessage->Buffer;\n"); + print_server("__frame->_StubMsg.Buffer = _pRpcMessage->Buffer;\n"); fprintf(server, "\n"); } /* marshall arguments */ - write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_MARSHAL); + write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_MARSHAL); /* marshall the return value */ if (!is_void(get_func_return_type(func))) - write_remoting_arguments(server, indent, func, PASS_RETURN, PHASE_MARSHAL); + write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL); indent--; print_server("}\n"); print_server("RpcFinally\n"); print_server("{\n"); indent++; - - write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_FREE); - - if (has_full_pointer) - write_full_pointer_free(server, indent, func); - + print_server("__finally_%s_%s( __frame );\n", iface->name, get_name(def)); indent--; print_server("}\n"); print_server("RpcEndFinally\n"); /* calculate buffer length */ fprintf(server, "\n"); - print_server("_pRpcMessage->BufferLength =\n"); - indent++; - print_server("(unsigned int)(_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer);\n"); - indent--; + print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n"); indent--; fprintf(server, "}\n"); fprintf(server, "\n"); @@ -251,15 +260,13 @@ static void write_dispatchtable(type_t *iface) if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) { var_t *def = func->def; - print_server("%s_%s,\n", iface->name, get_name(def)); - method_count++; } print_server("0\n"); indent--; print_server("};\n"); - print_server("RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); print_server("{\n"); indent++; print_server("%u,\n", method_count); @@ -323,7 +330,7 @@ static void write_serverinterfacedecl(type_t *iface) if (endpoints) write_endpoints( server, iface->name, endpoints ); - print_server("extern RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); fprintf(server, "\n"); print_server("static const RPC_SERVER_INTERFACE %s___RpcServerInterface =\n", iface->name ); print_server("{\n"); @@ -351,10 +358,10 @@ static void write_serverinterfacedecl(type_t *iface) indent--; print_server("};\n"); if (old_names) - print_server("RPC_IF_HANDLE %s_ServerIfHandle = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n", + print_server("RPC_IF_HANDLE %s_ServerIfHandle DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n", iface->name, iface->name); else - print_server("RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n", + print_server("RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec DECLSPEC_HIDDEN = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n", prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name); fprintf(server, "\n"); } @@ -370,9 +377,25 @@ static void init_server(void) print_server("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name); print_server("#include \n"); fprintf(server, "\n"); - print_server("#define _SEH_NO_NATIVE_NLG\n"); print_server("#include \"%s\"\n", header_name); - fprintf(server, "\n"); + print_server("\n"); + print_server( "#ifndef DECLSPEC_HIDDEN\n"); + print_server( "#define DECLSPEC_HIDDEN\n"); + print_server( "#endif\n"); + print_server( "\n"); + write_exceptions( server ); + print_server("\n"); + print_server("struct __server_frame\n"); + print_server("{\n"); + print_server(" __DECL_EXCEPTION_FRAME\n"); + print_server(" MIDL_STUB_MESSAGE _StubMsg;\n"); + print_server("};\n"); + print_server("\n"); + print_server("static int __server_filter( struct __server_frame *__frame )\n"); + print_server( "{\n"); + print_server( " return RPC_BAD_STUB_DATA_EXCEPTION_FILTER;\n"); + print_server( "}\n"); + print_server( "\n"); } @@ -401,7 +424,7 @@ static void write_server_stmts(const statement_list_t *stmts, int expr_eval_rout write_function_stubs(iface, proc_offset); - print_server("#if !defined(__RPC_WIN32__)\n"); + print_server("#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32); print_server("#error Invalid build platform for this stub.\n"); print_server("#endif\n"); @@ -413,20 +436,11 @@ static void write_server_stmts(const statement_list_t *stmts, int expr_eval_rout } } -void write_server(const statement_list_t *stmts) +static void write_server_routines(const statement_list_t *stmts) { unsigned int proc_offset = 0; int expr_eval_routines; - if (!do_server) - return; - if (do_everything && !need_stub_files(stmts)) - return; - - init_server(); - if (!server) - return; - write_formatstringsdecl(server, indent, stmts, need_stub); expr_eval_routines = write_expr_eval_routines(server, server_token); if (expr_eval_routines) @@ -439,6 +453,39 @@ void write_server(const statement_list_t *stmts) write_procformatstring(server, stmts, need_stub); write_typeformatstring(server, stmts, need_stub); +} + +void write_server(const statement_list_t *stmts) +{ + if (!do_server) + return; + if (do_everything && !need_stub_files(stmts)) + return; + + init_server(); + if (!server) + return; + + if (do_win32 && do_win64) + { + fprintf(server, "\n#ifndef _WIN64\n\n"); + pointer_size = 4; + write_server_routines( stmts ); + fprintf(server, "\n#else /* _WIN64 */\n\n"); + pointer_size = 8; + write_server_routines( stmts ); + fprintf(server, "\n#endif /* _WIN64 */\n"); + } + else if (do_win32) + { + pointer_size = 4; + write_server_routines( stmts ); + } + else if (do_win64) + { + pointer_size = 8; + write_server_routines( stmts ); + } fclose(server); } diff --git a/reactos/tools/widl/typegen.c b/reactos/tools/widl/typegen.c index 81c744703d8..7810f80d507 100644 --- a/reactos/tools/widl/typegen.c +++ b/reactos/tools/widl/typegen.c @@ -36,7 +36,7 @@ #include "utils.h" #include "parser.h" #include "header.h" -#include "wine/list.h" +#include "typetree.h" #include "typegen.h" #include "expr.h" @@ -120,6 +120,199 @@ const char *string_of_type(unsigned char type) } } +static int get_struct_type(const type_t *type) +{ + int has_pointer = 0; + int has_conformance = 0; + int has_variance = 0; + var_t *field; + var_list_t *fields; + + if (type->type != RPC_FC_STRUCT) return type->type; + + fields = type_struct_get_fields(type); + + if (get_padding(fields)) + return RPC_FC_BOGUS_STRUCT; + + if (fields) LIST_FOR_EACH_ENTRY( field, fields, var_t, entry ) + { + type_t *t = field->type; + + if (is_user_type(t)) + return RPC_FC_BOGUS_STRUCT; + + if (field->type->declarray) + { + if (is_string_type(field->attrs, field->type)) + { + if (is_conformant_array(field->type)) + has_conformance = 1; + has_variance = 1; + continue; + } + + if (is_array(field->type->ref)) + return RPC_FC_BOGUS_STRUCT; + + if (is_conformant_array(field->type)) + { + has_conformance = 1; + if (field->type->declarray && list_next(fields, &field->entry)) + error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", + field->name); + } + if (field->type->length_is) + has_variance = 1; + + t = field->type->ref; + } + + switch (get_struct_type(t)) + { + /* + * RPC_FC_BYTE, RPC_FC_STRUCT, etc + * Simple types don't effect the type of struct. + * A struct containing a simple struct is still a simple struct. + * So long as we can block copy the data, we return RPC_FC_STRUCT. + */ + case 0: /* void pointer */ + case RPC_FC_BYTE: + case RPC_FC_CHAR: + case RPC_FC_SMALL: + case RPC_FC_USMALL: + case RPC_FC_WCHAR: + case RPC_FC_SHORT: + case RPC_FC_USHORT: + case RPC_FC_LONG: + case RPC_FC_ULONG: + case RPC_FC_INT3264: + case RPC_FC_UINT3264: + case RPC_FC_HYPER: + case RPC_FC_FLOAT: + case RPC_FC_DOUBLE: + case RPC_FC_STRUCT: + case RPC_FC_ENUM32: + break; + + case RPC_FC_RP: + return RPC_FC_BOGUS_STRUCT; + + case RPC_FC_UP: + case RPC_FC_FP: + case RPC_FC_OP: + if (pointer_size != 4) + return RPC_FC_BOGUS_STRUCT; + /* pointers to interfaces aren't really pointers and have to be + * marshalled specially so they make the structure complex */ + if (t->ref->type == RPC_FC_IP) + return RPC_FC_BOGUS_STRUCT; + has_pointer = 1; + break; + + case RPC_FC_CARRAY: + case RPC_FC_CVARRAY: + case RPC_FC_BOGUS_ARRAY: + { + unsigned int ptr_type = get_attrv(field->attrs, ATTR_POINTERTYPE); + if (!ptr_type || ptr_type == RPC_FC_RP) + return RPC_FC_BOGUS_STRUCT; + else if (pointer_size != 4) + return RPC_FC_BOGUS_STRUCT; + has_pointer = 1; + break; + } + + /* + * Propagate member attributes + * a struct should be at least as complex as its member + */ + case RPC_FC_CVSTRUCT: + has_conformance = 1; + has_variance = 1; + has_pointer = 1; + break; + + case RPC_FC_CPSTRUCT: + has_conformance = 1; + if (list_next( fields, &field->entry )) + error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", + field->name); + has_pointer = 1; + break; + + case RPC_FC_CSTRUCT: + has_conformance = 1; + if (list_next( fields, &field->entry )) + error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", + field->name); + break; + + case RPC_FC_PSTRUCT: + has_pointer = 1; + break; + + default: + error_loc("Unknown struct member %s with type (0x%02x)\n", field->name, t->type); + /* fallthru - treat it as complex */ + + /* as soon as we see one of these these members, it's bogus... */ + case RPC_FC_ENCAPSULATED_UNION: + case RPC_FC_NON_ENCAPSULATED_UNION: + case RPC_FC_BOGUS_STRUCT: + case RPC_FC_ENUM16: + return RPC_FC_BOGUS_STRUCT; + } + } + + if( has_variance ) + { + if ( has_conformance ) + return RPC_FC_CVSTRUCT; + else + return RPC_FC_BOGUS_STRUCT; + } + if( has_conformance && has_pointer ) + return RPC_FC_CPSTRUCT; + if( has_conformance ) + return RPC_FC_CSTRUCT; + if( has_pointer ) + return RPC_FC_PSTRUCT; + return RPC_FC_STRUCT; +} + +static int get_array_type(const type_t *type) +{ + if (is_array(type)) + { + const type_t *rt = type->ref; + if (is_user_type(rt)) + return RPC_FC_BOGUS_ARRAY; + switch (get_struct_type(rt)) + { + case RPC_FC_BOGUS_STRUCT: + case RPC_FC_NON_ENCAPSULATED_UNION: + case RPC_FC_ENCAPSULATED_UNION: + case RPC_FC_ENUM16: + return RPC_FC_BOGUS_ARRAY; + /* FC_RP should be above, but widl overuses these, and will break things. */ + case RPC_FC_UP: + case RPC_FC_RP: + if (rt->ref->type == RPC_FC_IP) return RPC_FC_BOGUS_ARRAY; + break; + } + + if (type->type == RPC_FC_LGFARRAY || type->type == RPC_FC_LGVARRAY) + { + unsigned int align = 0; + size_t size = type_memsize(type, &align); + if (size * type->dim <= 0xffff) + return (type->type == RPC_FC_LGFARRAY) ? RPC_FC_SMFARRAY : RPC_FC_SMVARRAY; + } + } + return type->type; +} + int is_struct(unsigned char type) { switch (type) @@ -138,7 +331,7 @@ int is_struct(unsigned char type) static int is_non_complex_struct(const type_t *type) { - switch (type->type) + switch (get_struct_type(type)) { case RPC_FC_STRUCT: case RPC_FC_PSTRUCT: @@ -173,8 +366,9 @@ static int type_has_pointers(const type_t *type) return type_has_pointers(type->ref); else if (is_struct(type->type)) { + var_list_t *fields = type_struct_get_fields(type); const var_t *field; - if (type->fields_or_args) LIST_FOR_EACH_ENTRY( field, type->fields_or_args, const var_t, entry ) + if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) { if (type_has_pointers(field->type)) return TRUE; @@ -184,13 +378,7 @@ static int type_has_pointers(const type_t *type) { var_list_t *fields; const var_t *field; - if (type->type == RPC_FC_ENCAPSULATED_UNION) - { - const var_t *uv = LIST_ENTRY(list_tail(type->fields_or_args), const var_t, entry); - fields = uv->type->fields_or_args; - } - else - fields = type->fields_or_args; + fields = type_union_get_cases(type); if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) { if (field->type && type_has_pointers(field->type)) @@ -213,8 +401,9 @@ static int type_has_full_pointer(const type_t *type) return type_has_full_pointer(type->ref); else if (is_struct(type->type)) { + var_list_t *fields = type_struct_get_fields(type); const var_t *field; - if (type->fields_or_args) LIST_FOR_EACH_ENTRY( field, type->fields_or_args, const var_t, entry ) + if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) { if (type_has_full_pointer(field->type)) return TRUE; @@ -224,13 +413,7 @@ static int type_has_full_pointer(const type_t *type) { var_list_t *fields; const var_t *field; - if (type->type == RPC_FC_ENCAPSULATED_UNION) - { - const var_t *uv = LIST_ENTRY(list_tail(type->fields_or_args), const var_t, entry); - fields = uv->type->fields_or_args; - } - else - fields = type->fields_or_args; + fields = type_union_get_cases(type); if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) { if (field->type && type_has_full_pointer(field->type)) @@ -341,26 +524,30 @@ void print(FILE *file, int indent, const char *format, va_list va) } -static void write_var_init(FILE *file, int indent, const type_t *t, const char *n) +static void write_var_init(FILE *file, int indent, const type_t *t, const char *n, const char *local_var_prefix) { if (decl_indirect(t)) - print_file(file, indent, "MIDL_memset(&%s, 0, sizeof(%s));\n", n, n); + { + print_file(file, indent, "MIDL_memset(&%s%s, 0, sizeof(%s%s));\n", + local_var_prefix, n, local_var_prefix, n); + print_file(file, indent, "%s_p_%s = &%s%s;\n", local_var_prefix, n, local_var_prefix, n); + } else if (is_ptr(t) || is_array(t)) - print_file(file, indent, "%s = 0;\n", n); + print_file(file, indent, "%s%s = 0;\n", local_var_prefix, n); } -void write_parameters_init(FILE *file, int indent, const func_t *func) +void write_parameters_init(FILE *file, int indent, const func_t *func, const char *local_var_prefix) { const var_t *var; if (!is_void(get_func_return_type(func))) - write_var_init(file, indent, get_func_return_type(func), "_RetVal"); + write_var_init(file, indent, get_func_return_type(func), "_RetVal", local_var_prefix); if (!func->args) return; LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) - write_var_init(file, indent, var->type, var->name); + write_var_init(file, indent, var->type, var->name, local_var_prefix); fprintf(file, "\n"); } @@ -377,6 +564,8 @@ static void write_formatdesc(FILE *f, int indent, const char *str) void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred) { + clear_all_offsets(); + print_file(f, indent, "#define TYPE_FORMAT_STRING_SIZE %d\n", get_size_typeformatstring(stmts, pred)); @@ -650,8 +839,9 @@ static size_t write_conf_or_var_desc(FILE *file, const type_t *structure, unsigned char param_type = 0; size_t offset = 0; const var_t *var; + var_list_t *fields = type_struct_get_fields(structure); - if (structure->fields_or_args) LIST_FOR_EACH_ENTRY( var, structure->fields_or_args, const var_t, entry ) + if (fields) LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry ) { unsigned int align = 0; /* FIXME: take alignment into account */ @@ -823,13 +1013,8 @@ size_t type_memsize(const type_t *t, unsigned int *align) } else if (is_ptr(t) || is_conformant_array(t)) { -#if defined(TARGET_i386) - size = 4; -#elif defined(TARGET_amd64) - size = 8; -#else -#error Unsupported CPU -#endif + assert( pointer_size ); + size = pointer_size; if (size > *align) *align = size; } else switch (t->type) @@ -867,11 +1052,13 @@ size_t type_memsize(const type_t *t, unsigned int *align) case RPC_FC_CSTRUCT: case RPC_FC_PSTRUCT: case RPC_FC_BOGUS_STRUCT: - size = fields_memsize(t->fields_or_args, align); + size = fields_memsize(type_struct_get_fields(t), align); break; case RPC_FC_ENCAPSULATED_UNION: + size = fields_memsize(type_encapsulated_union_get_fields(t), align); + break; case RPC_FC_NON_ENCAPSULATED_UNION: - size = union_memsize(t->fields_or_args, align); + size = union_memsize(type_union_get_cases(t), align); break; case RPC_FC_SMFARRAY: case RPC_FC_LGFARRAY: @@ -903,14 +1090,14 @@ int is_full_pointer_function(const func_t *func) void write_full_pointer_init(FILE *file, int indent, const func_t *func, int is_server) { - print_file(file, indent, "_StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,%s);\n", + print_file(file, indent, "__frame->_StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,%s);\n", is_server ? "XLAT_SERVER" : "XLAT_CLIENT"); fprintf(file, "\n"); } void write_full_pointer_free(FILE *file, int indent, const func_t *func) { - print_file(file, indent, "NdrFullPointerXlatFree(_StubMsg.FullPtrXlatTables);\n"); + print_file(file, indent, "NdrFullPointerXlatFree(__frame->_StubMsg.FullPtrXlatTables);\n"); fprintf(file, "\n"); } @@ -973,7 +1160,7 @@ static int user_type_has_variable_size(const type_t *t) if (is_ptr(t)) return TRUE; else - switch (t->type) + switch (get_struct_type(t)) { case RPC_FC_PSTRUCT: case RPC_FC_CSTRUCT: @@ -1065,7 +1252,7 @@ static void write_member_type(FILE *file, const type_t *cont, } else if (is_ptr(type) || is_conformant_array(type)) { - unsigned char fc = (cont->type == RPC_FC_BOGUS_STRUCT + unsigned char fc = (get_struct_type(cont) == RPC_FC_BOGUS_STRUCT ? RPC_FC_POINTER : RPC_FC_LONG); print_file(file, 2, "0x%x,\t/* %s */\n", fc, string_of_type(fc)); @@ -1089,7 +1276,7 @@ static void write_end(FILE *file, unsigned int *tfsoff) static void write_descriptors(FILE *file, type_t *type, unsigned int *tfsoff) { unsigned int offset = 0; - var_list_t *fs = type->fields_or_args; + var_list_t *fs = type_struct_get_fields(type); var_t *f; if (fs) LIST_FOR_EACH_ENTRY(f, fs, var_t, entry) @@ -1166,7 +1353,7 @@ static int write_no_repeat_pointer_descriptions( if (is_non_complex_struct(type)) { const var_t *v; - LIST_FOR_EACH_ENTRY( v, type->fields_or_args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( v, type_struct_get_fields(type), const var_t, entry ) { if (offset_in_memory && offset_in_buffer) { @@ -1244,7 +1431,7 @@ static int write_pointer_description_offsets( { /* otherwise search for interesting fields to parse */ const var_t *v; - LIST_FOR_EACH_ENTRY( v, type->fields_or_args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( v, type_struct_get_fields(type), const var_t, entry ) { if (offset_in_memory && offset_in_buffer) { @@ -1286,8 +1473,9 @@ static int write_fixed_array_pointer_descriptions( { unsigned int align; int pointer_count = 0; + int real_type = get_array_type( type ); - if (type->type == RPC_FC_SMFARRAY || type->type == RPC_FC_LGFARRAY) + if (real_type == RPC_FC_SMFARRAY || real_type == RPC_FC_LGFARRAY) { unsigned int temp = 0; /* unfortunately, this needs to be done in two passes to avoid @@ -1319,7 +1507,7 @@ static int write_fixed_array_pointer_descriptions( else if (is_struct(type->type)) { const var_t *v; - LIST_FOR_EACH_ENTRY( v, type->fields_or_args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( v, type_struct_get_fields(type), const var_t, entry ) { if (offset_in_memory && offset_in_buffer) { @@ -1438,7 +1626,7 @@ static int write_varying_array_pointer_descriptions( else if (is_struct(type->type)) { const var_t *v; - LIST_FOR_EACH_ENTRY( v, type->fields_or_args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( v, type_struct_get_fields(type), const var_t, entry ) { if (offset_in_memory && offset_in_buffer) { @@ -1508,7 +1696,7 @@ static void write_pointer_description(FILE *file, type_t *type, if ((!type->declarray || !current_structure) && is_conformant_array(type)) write_conformant_array_pointer_descriptions( file, NULL, type, 0, typestring_offset); - else if (type->type == RPC_FC_CPSTRUCT) + else if (get_struct_type(type) == RPC_FC_CPSTRUCT) { unsigned int align = 0; type_t *carray = find_array_or_string_in_struct(type)->type; @@ -1627,6 +1815,7 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type unsigned int align = 0; size_t size; size_t start_offset; + int real_type; int has_pointer; int pointer_type = get_attrv(attrs, ATTR_POINTERTYPE); unsigned int baseoff @@ -1644,20 +1833,19 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type align = 0; size = type_memsize((is_conformant_array(type) ? type->ref : type), &align); + real_type = get_array_type( type ); start_offset = *typestring_offset; update_tfsoff(type, start_offset, file); print_start_tfs_comment(file, type, start_offset); - print_file(file, 2, "0x%02x,\t/* %s */\n", type->type, string_of_type(type->type)); + print_file(file, 2, "0x%02x,\t/* %s */\n", real_type, string_of_type(real_type)); print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1); *typestring_offset += 2; align = 0; - if (type->type != RPC_FC_BOGUS_ARRAY) + if (real_type != RPC_FC_BOGUS_ARRAY) { - unsigned char tc = type->type; - - if (tc == RPC_FC_LGFARRAY || tc == RPC_FC_LGVARRAY) + if (real_type == RPC_FC_LGFARRAY || real_type == RPC_FC_LGVARRAY) { print_file(file, 2, "NdrFcLong(0x%x),\t/* %lu */\n", size, size); *typestring_offset += 4; @@ -1673,12 +1861,12 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type += write_conf_or_var_desc(file, current_structure, baseoff, type, size_is); - if (type->type == RPC_FC_SMVARRAY || type->type == RPC_FC_LGVARRAY) + if (real_type == RPC_FC_SMVARRAY || real_type == RPC_FC_LGVARRAY) { unsigned int elalign = 0; size_t elsize = type_memsize(type->ref, &elalign); - if (type->type == RPC_FC_LGVARRAY) + if (real_type == RPC_FC_LGVARRAY) { print_file(file, 2, "NdrFcLong(0x%x),\t/* %lu */\n", type->dim, type->dim); *typestring_offset += 4; @@ -1731,19 +1919,22 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type static const var_t *find_array_or_string_in_struct(const type_t *type) { + const var_list_t *fields = type_struct_get_fields(type); const var_t *last_field; const type_t *ft; + int real_type; - if (!type->fields_or_args || list_empty(type->fields_or_args)) + if (!fields || list_empty(fields)) return NULL; - last_field = LIST_ENTRY( list_tail(type->fields_or_args), const var_t, entry ); + last_field = LIST_ENTRY( list_tail(fields), const var_t, entry ); ft = last_field->type; if (ft->declarray && is_conformant_array(ft)) return last_field; - if (ft->type == RPC_FC_CSTRUCT || ft->type == RPC_FC_CPSTRUCT || ft->type == RPC_FC_CVSTRUCT) + real_type = get_struct_type( type ); + if (real_type == RPC_FC_CSTRUCT || real_type == RPC_FC_CPSTRUCT || real_type == RPC_FC_CVSTRUCT) return find_array_or_string_in_struct(ft); else return NULL; @@ -1756,8 +1947,9 @@ static void write_struct_members(FILE *file, const type_t *type, unsigned short offset = 0; int salign = -1; int padding; + var_list_t *fields = type_struct_get_fields(type); - if (type->fields_or_args) LIST_FOR_EACH_ENTRY( field, type->fields_or_args, const var_t, entry ) + if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry ) { type_t *ft = field->type; if (!ft->declarray || !is_conformant_array(ft)) @@ -1814,6 +2006,8 @@ static size_t write_struct_tfs(FILE *file, type_t *type, unsigned int align = 0; unsigned int corroff; var_t *f; + int real_type = get_struct_type( type ); + var_list_t *fields = type_struct_get_fields(type); guard_rec(type); current_structure = type; @@ -1823,7 +2017,7 @@ static size_t write_struct_tfs(FILE *file, type_t *type, error("structure size for %s exceeds %d bytes by %d bytes\n", name, USHRT_MAX, total_size - USHRT_MAX); - if (type->fields_or_args) LIST_FOR_EACH_ENTRY(f, type->fields_or_args, var_t, entry) + if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry) has_pointers |= write_embedded_types(file, f->attrs, f->type, f->name, FALSE, tfsoff); if (!has_pointers) has_pointers = type_has_pointers(type); @@ -1831,7 +2025,7 @@ static size_t write_struct_tfs(FILE *file, type_t *type, array = find_array_or_string_in_struct(type); if (array && !processed(array->type)) array_offset - = is_attr(array->attrs, ATTR_STRING) + = is_string_type(array->attrs, array->type) ? write_string_tfs(file, array->attrs, array->type, array->name, tfsoff) : write_array_tfs(file, array->attrs, array->type, array->name, tfsoff); @@ -1841,7 +2035,7 @@ static size_t write_struct_tfs(FILE *file, type_t *type, start_offset = *tfsoff; update_tfsoff(type, start_offset, file); print_start_tfs_comment(file, type, start_offset); - print_file(file, 2, "0x%x,\t/* %s */\n", type->type, string_of_type(type->type)); + print_file(file, 2, "0x%x,\t/* %s */\n", real_type, string_of_type(real_type)); print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1); print_file(file, 2, "NdrFcShort(0x%x),\t/* %d */\n", total_size, total_size); *tfsoff += 4; @@ -1854,13 +2048,13 @@ static size_t write_struct_tfs(FILE *file, type_t *type, reloff, reloff, absoff); *tfsoff += 2; } - else if (type->type == RPC_FC_BOGUS_STRUCT) + else if (real_type == RPC_FC_BOGUS_STRUCT) { print_file(file, 2, "NdrFcShort(0x0),\n"); *tfsoff += 2; } - if (type->type == RPC_FC_BOGUS_STRUCT) + if (real_type == RPC_FC_BOGUS_STRUCT) { /* On the sizing pass, type->ptrdesc may be zero, but it's ok as nothing is written to file yet. On the actual writing pass, @@ -1872,9 +2066,9 @@ static size_t write_struct_tfs(FILE *file, type_t *type, reloff, reloff, absoff); *tfsoff += 2; } - else if ((type->type == RPC_FC_PSTRUCT) || - (type->type == RPC_FC_CPSTRUCT) || - (type->type == RPC_FC_CVSTRUCT && has_pointers)) + else if ((real_type == RPC_FC_PSTRUCT) || + (real_type == RPC_FC_CPSTRUCT) || + (real_type == RPC_FC_CVSTRUCT && has_pointers)) { print_file(file, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP); print_file(file, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD); @@ -1886,13 +2080,12 @@ static size_t write_struct_tfs(FILE *file, type_t *type, write_struct_members(file, type, &corroff, tfsoff); - if (type->type == RPC_FC_BOGUS_STRUCT) + if (real_type == RPC_FC_BOGUS_STRUCT) { - const var_list_t *fs = type->fields_or_args; const var_t *f; type->ptrdesc = *tfsoff; - if (fs) LIST_FOR_EACH_ENTRY(f, fs, const var_t, entry) + if (fields) LIST_FOR_EACH_ENTRY(f, fields, const var_t, entry) { type_t *ft = f->type; if (is_ptr(ft)) @@ -1996,13 +2189,7 @@ static size_t write_union_tfs(FILE *file, type_t *type, unsigned int *tfsoff) guard_rec(type); - if (type->type == RPC_FC_ENCAPSULATED_UNION) - { - const var_t *uv = LIST_ENTRY(list_tail(type->fields_or_args), const var_t, entry); - fields = uv->type->fields_or_args; - } - else - fields = type->fields_or_args; + fields = type_union_get_cases(type); if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry) { @@ -2018,7 +2205,7 @@ static size_t write_union_tfs(FILE *file, type_t *type, unsigned int *tfsoff) print_start_tfs_comment(file, type, start_offset); if (type->type == RPC_FC_ENCAPSULATED_UNION) { - const var_t *sv = LIST_ENTRY(list_head(type->fields_or_args), const var_t, entry); + const var_t *sv = type_union_get_switch_value(type); const type_t *st = sv->type; switch (st->type) @@ -2476,7 +2663,7 @@ static unsigned int get_required_buffer_size_type( } else { - switch (type->type) + switch (get_struct_type(type)) { case RPC_FC_BYTE: case RPC_FC_CHAR: @@ -2510,11 +2697,12 @@ static unsigned int get_required_buffer_size_type( return 0; case RPC_FC_STRUCT: - return fields_memsize(type->fields_or_args, alignment); + if (!type_struct_get_fields(type)) return 0; + return fields_memsize(type_struct_get_fields(type), alignment); case RPC_FC_RP: return - is_base_type( type->ref->type ) || type->ref->type == RPC_FC_STRUCT + is_base_type( type->ref->type ) || get_struct_type(type->ref) == RPC_FC_STRUCT ? get_required_buffer_size_type( type->ref, name, alignment ) : 0; @@ -2579,7 +2767,7 @@ static unsigned int get_function_buffer_size( const func_t *func, enum pass pass } static void print_phase_function(FILE *file, int indent, const char *type, - enum remoting_phase phase, + const char *local_var_prefix, enum remoting_phase phase, const var_t *var, unsigned int type_offset) { const char *function; @@ -2604,10 +2792,11 @@ static void print_phase_function(FILE *file, int indent, const char *type, print_file(file, indent, "Ndr%s%s(\n", type, function); indent++; - print_file(file, indent, "&_StubMsg,\n"); - print_file(file, indent, "%s%s%s%s,\n", + print_file(file, indent, "&__frame->_StubMsg,\n"); + print_file(file, indent, "%s%s%s%s%s,\n", (phase == PHASE_UNMARSHAL) ? "(unsigned char **)" : "(unsigned char *)", (phase == PHASE_UNMARSHAL || decl_indirect(var->type)) ? "&" : "", + local_var_prefix, (phase == PHASE_UNMARSHAL && decl_indirect(var->type)) ? "_p_" : "", var->name); print_file(file, indent, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]%s\n", @@ -2617,8 +2806,8 @@ static void print_phase_function(FILE *file, int indent, const char *type, indent--; } -void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, - enum pass pass, const var_t *var, +void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, + enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname) { type_t *type = var->type; @@ -2676,8 +2865,8 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, } if (phase == PHASE_MARSHAL) - print_file(file, indent, "MIDL_memset(_StubMsg.Buffer, 0, (0x%x - (long)_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1); - print_file(file, indent, "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + %u) & ~0x%x);\n", + print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1); + print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n", alignment - 1, alignment - 1); if (phase == PHASE_MARSHAL) @@ -2685,17 +2874,17 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, print_file(file, indent, "*("); write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); if (is_ptr(type)) - fprintf(file, " *)_StubMsg.Buffer = *"); + fprintf(file, " *)__frame->_StubMsg.Buffer = *"); else - fprintf(file, " *)_StubMsg.Buffer = "); - fprintf(file, "%s", varname); + fprintf(file, " *)__frame->_StubMsg.Buffer = "); + fprintf(file, "%s%s", local_var_prefix, varname); fprintf(file, ";\n"); } else if (phase == PHASE_UNMARSHAL) { - print_file(file, indent, "if (_StubMsg.Buffer + sizeof("); + print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof("); write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); - fprintf(file, ") > _StubMsg.BufferEnd)\n"); + fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n"); print_file(file, indent, "{\n"); print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); print_file(file, indent, "}\n"); @@ -2703,16 +2892,16 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, print_file(file, indent, ""); else print_file(file, indent, "*"); - fprintf(file, "%s", varname); + fprintf(file, "%s%s", local_var_prefix, varname); if (pass == PASS_IN && is_ptr(type)) fprintf(file, " = ("); else fprintf(file, " = *("); write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); - fprintf(file, " *)_StubMsg.Buffer;\n"); + fprintf(file, " *)__frame->_StubMsg.Buffer;\n"); } - print_file(file, indent, "_StubMsg.Buffer += sizeof("); + print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof("); write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); fprintf(file, ");\n"); } @@ -2742,9 +2931,8 @@ expr_t *get_size_is_expr(const type_t *t, const char *name) return x; } -static void write_parameter_conf_or_var_exprs(FILE *file, int indent, - enum remoting_phase phase, - const var_t *var) +static void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char *local_var_prefix, + enum remoting_phase phase, const var_t *var) { const type_t *type = var->type; /* get fundamental type for the argument */ @@ -2760,16 +2948,16 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, { if (type->size_is) { - print_file(file, indent, "_StubMsg.MaxCount = (unsigned long)"); - write_expr(file, type->size_is, 1, 1, NULL, NULL); + print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)"); + write_expr(file, type->size_is, 1, 1, NULL, NULL, local_var_prefix); fprintf(file, ";\n\n"); } if (type->length_is) { - print_file(file, indent, "_StubMsg.Offset = (unsigned long)0;\n"); /* FIXME */ - print_file(file, indent, "_StubMsg.ActualCount = (unsigned long)"); - write_expr(file, type->length_is, 1, 1, NULL, NULL); - fprintf(file, ";\n\n"); + print_file(file, indent, "__frame->_StubMsg.Offset = 0;\n"); /* FIXME */ + print_file(file, indent, "__frame->_StubMsg.ActualCount = (ULONG_PTR)"); + write_expr(file, type->length_is, 1, 1, NULL, NULL, local_var_prefix); + fprintf(file, ";\n\n"); } } break; @@ -2778,8 +2966,8 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, { if (is_conformance_needed_for_phase(phase)) { - print_file(file, indent, "_StubMsg.MaxCount = (unsigned long)"); - write_expr(file, get_attrp(var->attrs, ATTR_SWITCHIS), 1, 1, NULL, NULL); + print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)"); + write_expr(file, get_attrp(var->attrs, ATTR_SWITCHIS), 1, 1, NULL, NULL, local_var_prefix); fprintf(file, ";\n\n"); } break; @@ -2790,8 +2978,8 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, if (is_conformance_needed_for_phase(phase) && (iid = get_attrp( var->attrs, ATTR_IIDIS ))) { - print_file( file, indent, "_StubMsg.MaxCount = (unsigned long) " ); - write_expr( file, iid, 1, 1, NULL, NULL ); + print_file( file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR) " ); + write_expr( file, iid, 1, 1, NULL, NULL, local_var_prefix ); fprintf( file, ";\n\n" ); } break; @@ -2803,9 +2991,8 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, } } -static void write_remoting_arg(FILE *file, int indent, const func_t *func, - enum pass pass, enum remoting_phase phase, - const var_t *var) +static void write_remoting_arg(FILE *file, int indent, const func_t *func, const char *local_var_prefix, + enum pass pass, enum remoting_phase phase, const var_t *var) { int in_attr, out_attr, pointer_type; const type_t *type = var->type; @@ -2834,8 +3021,8 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, break; } - write_parameter_conf_or_var_exprs(file, indent, phase, var); - rtype = type->type; + write_parameter_conf_or_var_exprs(file, indent, local_var_prefix, phase, var); + rtype = get_struct_type(type); if (is_context_handle(type)) { @@ -2848,15 +3035,15 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, * be direct, otherwise it is a pointer */ int is_ch_ptr = is_aliaschain_attr(type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE; print_file(file, indent, "NdrClientContextMarshall(\n"); - print_file(file, indent + 1, "&_StubMsg,\n"); - print_file(file, indent + 1, "(NDR_CCONTEXT)%s%s,\n", is_ch_ptr ? "*" : "", var->name); + print_file(file, indent + 1, "&__frame->_StubMsg,\n"); + print_file(file, indent + 1, "(NDR_CCONTEXT)%s%s%s,\n", is_ch_ptr ? "*" : "", local_var_prefix, var->name); print_file(file, indent + 1, "%s);\n", in_attr && out_attr ? "1" : "0"); } else { print_file(file, indent, "NdrServerContextNewMarshall(\n"); - print_file(file, indent + 1, "&_StubMsg,\n"); - print_file(file, indent + 1, "(NDR_SCONTEXT)%s,\n", var->name); + print_file(file, indent + 1, "&__frame->_StubMsg,\n"); + print_file(file, indent + 1, "(NDR_SCONTEXT)%s%s,\n", local_var_prefix, var->name); print_file(file, indent + 1, "(NDR_RUNDOWN)%s_rundown,\n", get_context_handle_type_name(var->type)); print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n", start_offset); } @@ -2866,41 +3053,42 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, if (pass == PASS_OUT) { if (!in_attr) - print_file(file, indent, "*%s = 0;\n", var->name); + print_file(file, indent, "*%s%s = 0;\n", local_var_prefix, var->name); print_file(file, indent, "NdrClientContextUnmarshall(\n"); - print_file(file, indent + 1, "&_StubMsg,\n"); - print_file(file, indent + 1, "(NDR_CCONTEXT *)%s,\n", var->name); - print_file(file, indent + 1, "_Handle);\n"); + print_file(file, indent + 1, "&__frame->_StubMsg,\n"); + print_file(file, indent + 1, "(NDR_CCONTEXT *)%s%s,\n", local_var_prefix, var->name); + print_file(file, indent + 1, "__frame->_Handle);\n"); } else { - print_file(file, indent, "%s = NdrServerContextNewUnmarshall(\n", var->name); - print_file(file, indent + 1, "&_StubMsg,\n"); + print_file(file, indent, "%s%s = NdrServerContextNewUnmarshall(\n", local_var_prefix, var->name); + print_file(file, indent + 1, "&__frame->_StubMsg,\n"); print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n", start_offset); } } } else if (is_user_type(var->type)) { - print_phase_function(file, indent, "UserMarshal", phase, var, start_offset); + print_phase_function(file, indent, "UserMarshal", local_var_prefix, phase, var, start_offset); } else if (is_string_type(var->attrs, var->type)) { if (is_array(type) && !is_conformant_array(type)) - print_phase_function(file, indent, "NonConformantString", phase, var, start_offset); + print_phase_function(file, indent, "NonConformantString", local_var_prefix, + phase, var, start_offset); else { if (phase == PHASE_FREE || pass == PASS_RETURN || pointer_type == RPC_FC_UP) - print_phase_function(file, indent, "Pointer", phase, var, + print_phase_function(file, indent, "Pointer", local_var_prefix, phase, var, start_offset - (type->size_is ? 4 : 2)); else - print_phase_function(file, indent, "ConformantString", phase, var, - start_offset); + print_phase_function(file, indent, "ConformantString", local_var_prefix, + phase, var, start_offset); } } else if (is_array(type)) { - unsigned char tc = type->type; + unsigned char tc = get_array_type( type ); const char *array_type = "FixedArray"; /* We already have the size_is expression since it's at the @@ -2926,25 +3114,25 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, } if (pointer_type != RPC_FC_RP) array_type = "Pointer"; - print_phase_function(file, indent, array_type, phase, var, start_offset); + print_phase_function(file, indent, array_type, local_var_prefix, phase, var, start_offset); if (phase == PHASE_FREE && pointer_type == RPC_FC_RP) { /* these are all unmarshalled by allocating memory */ - if (type->type == RPC_FC_BOGUS_ARRAY || - type->type == RPC_FC_CVARRAY || - ((type->type == RPC_FC_SMVARRAY || type->type == RPC_FC_LGVARRAY) && in_attr) || - (type->type == RPC_FC_CARRAY && !in_attr)) + if (tc == RPC_FC_BOGUS_ARRAY || + tc == RPC_FC_CVARRAY || + ((tc == RPC_FC_SMVARRAY || tc == RPC_FC_LGVARRAY) && in_attr) || + (tc == RPC_FC_CARRAY && !in_attr)) { - print_file(file, indent, "if (%s)\n", var->name); + print_file(file, indent, "if (%s%s)\n", local_var_prefix, var->name); indent++; - print_file(file, indent, "_StubMsg.pfnFree(%s);\n", var->name); + print_file(file, indent, "__frame->_StubMsg.pfnFree(%s%s);\n", local_var_prefix, var->name); } } } else if (!is_ptr(var->type) && is_base_type(rtype)) { if (phase != PHASE_FREE) - print_phase_basetype(file, indent, phase, pass, var, var->name); + print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name); } else if (!is_ptr(var->type)) { @@ -2952,17 +3140,17 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, { case RPC_FC_STRUCT: case RPC_FC_PSTRUCT: - print_phase_function(file, indent, "SimpleStruct", phase, var, start_offset); + print_phase_function(file, indent, "SimpleStruct", local_var_prefix, phase, var, start_offset); break; case RPC_FC_CSTRUCT: case RPC_FC_CPSTRUCT: - print_phase_function(file, indent, "ConformantStruct", phase, var, start_offset); + print_phase_function(file, indent, "ConformantStruct", local_var_prefix, phase, var, start_offset); break; case RPC_FC_CVSTRUCT: - print_phase_function(file, indent, "ConformantVaryingStruct", phase, var, start_offset); + print_phase_function(file, indent, "ConformantVaryingStruct", local_var_prefix, phase, var, start_offset); break; case RPC_FC_BOGUS_STRUCT: - print_phase_function(file, indent, "ComplexStruct", phase, var, start_offset); + print_phase_function(file, indent, "ComplexStruct", local_var_prefix, phase, var, start_offset); break; default: error("write_remoting_arguments: Unsupported type: %s (0x%02x)\n", var->name, rtype); @@ -2974,34 +3162,34 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, if (type->type == RPC_FC_RP && is_base_type(ref->type)) { if (phase != PHASE_FREE) - print_phase_basetype(file, indent, phase, pass, var, var->name); + print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name); } - else if (type->type == RPC_FC_RP && ref->type == RPC_FC_STRUCT && + else if (type->type == RPC_FC_RP && get_struct_type(ref) == RPC_FC_STRUCT && !is_user_type(ref)) { if (phase != PHASE_BUFFERSIZE && phase != PHASE_FREE) print_phase_function(file, indent, "SimpleStruct", - phase, var, + local_var_prefix, phase, var, ref->typestring_offset); } else { if (ref->type == RPC_FC_IP) - print_phase_function(file, indent, "InterfacePointer", phase, var, start_offset); + print_phase_function(file, indent, "InterfacePointer", local_var_prefix, phase, var, start_offset); else - print_phase_function(file, indent, "Pointer", phase, var, start_offset); + print_phase_function(file, indent, "Pointer", local_var_prefix, phase, var, start_offset); } } fprintf(file, "\n"); } -void write_remoting_arguments(FILE *file, int indent, const func_t *func, +void write_remoting_arguments(FILE *file, int indent, const func_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase) { if (phase == PHASE_BUFFERSIZE && pass != PASS_RETURN) { unsigned int size = get_function_buffer_size( func, pass ); - print_file(file, indent, "_StubMsg.BufferLength = %u;\n", size); + print_file(file, indent, "__frame->_StubMsg.BufferLength = %u;\n", size); } if (pass == PASS_RETURN) @@ -3010,7 +3198,7 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func, var = *func->def; var.type = get_func_return_type(func); var.name = xstrdup( "_RetVal" ); - write_remoting_arg( file, indent, func, pass, phase, &var ); + write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, &var ); free( var.name ); } else @@ -3019,7 +3207,7 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func, if (!func->args) return; LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) - write_remoting_arg( file, indent, func, pass, phase, var ); + write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, var ); } } @@ -3103,7 +3291,7 @@ void declare_stub_args( FILE *file, int indent, const func_t *func ) LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) { - int is_string = is_attr(var->attrs, ATTR_STRING); + int is_string = is_string_type(var->attrs, var->type); in_attr = is_attr(var->attrs, ATTR_IN); out_attr = is_attr(var->attrs, ATTR_OUT); @@ -3126,21 +3314,20 @@ void declare_stub_args( FILE *file, int indent, const func_t *func ) write_type_decl_left(file, var->type); fprintf(file, " "); if (var->type->declarray) { - fprintf(file, "(*%s)", get_name(var)); + fprintf(file, "(*%s)", var->name); } else - fprintf(file, "%s", get_name(var)); + fprintf(file, "%s", var->name); write_type_right(file, var->type, FALSE); fprintf(file, ";\n"); if (decl_indirect(var->type)) - print_file(file, indent, "void *_p_%s = &%s;\n", - var->name, var->name); + print_file(file, indent, "void *_p_%s;\n", var->name); } } } -void assign_stub_out_args( FILE *file, int indent, const func_t *func ) +void assign_stub_out_args( FILE *file, int indent, const func_t *func, const char *local_var_prefix ) { int in_attr, out_attr; int i = 0, sep = 0; @@ -3151,7 +3338,7 @@ void assign_stub_out_args( FILE *file, int indent, const func_t *func ) LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) { - int is_string = is_attr(var->attrs, ATTR_STRING); + int is_string = is_string_type(var->attrs, var->type); in_attr = is_attr(var->attrs, ATTR_IN); out_attr = is_attr(var->attrs, ATTR_OUT); if (!out_attr && !in_attr) @@ -3159,12 +3346,12 @@ void assign_stub_out_args( FILE *file, int indent, const func_t *func ) if (!in_attr) { - print_file(file, indent, "%s", get_name(var)); + print_file(file, indent, "%s%s", local_var_prefix, var->name); if (is_context_handle(var->type)) { fprintf(file, " = NdrContextHandleInitialize(\n"); - print_file(file, indent + 1, "&_StubMsg,\n"); + print_file(file, indent + 1, "&__frame->_StubMsg,\n"); print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n", var->type->typestring_offset); } @@ -3173,10 +3360,10 @@ void assign_stub_out_args( FILE *file, int indent, const func_t *func ) unsigned int size, align = 0; type_t *type = var->type; - fprintf(file, " = NdrAllocate(&_StubMsg, "); + fprintf(file, " = NdrAllocate(&__frame->_StubMsg, "); for ( ; type->size_is ; type = type->ref) { - write_expr(file, type->size_is, TRUE, TRUE, NULL, NULL); + write_expr(file, type->size_is, TRUE, TRUE, NULL, NULL, local_var_prefix); fprintf(file, " * "); } size = type_memsize(type, &align); @@ -3184,9 +3371,9 @@ void assign_stub_out_args( FILE *file, int indent, const func_t *func ) } else if (!is_string) { - fprintf(file, " = &_W%u;\n", i); + fprintf(file, " = &%s_W%u;\n", local_var_prefix, i); if (is_ptr(var->type) && !last_ptr(var->type)) - print_file(file, indent, "_W%u = 0;\n", i); + print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i); i++; } @@ -3217,8 +3404,8 @@ int write_expr_eval_routines(FILE *file, const char *iface) print_file (file, 1, "%s *%s = (%s *)(pStubMsg->StackTop - %u);\n", name, var_name, name, eval->baseoff); print_file(file, 1, "pStubMsg->Offset = 0;\n"); /* FIXME */ - print_file(file, 1, "pStubMsg->MaxCount = (unsigned long)"); - write_expr(file, eval->expr, 1, 1, var_name_expr, eval->structure); + print_file(file, 1, "pStubMsg->MaxCount = (ULONG_PTR)"); + write_expr(file, eval->expr, 1, 1, var_name_expr, eval->structure, ""); fprintf(file, ";\n"); print_file(file, 0, "}\n\n"); callback_offset++; @@ -3302,3 +3489,117 @@ void write_endpoints( FILE *f, const char *prefix, const str_list_t *list ) error: error("Invalid endpoint syntax '%s'\n", endpoint->str); } + +void write_exceptions( FILE *file ) +{ + fprintf( file, "#ifndef USE_COMPILER_EXCEPTIONS\n"); + fprintf( file, "\n"); + fprintf( file, "#include \"wine/exception.h\"\n"); + fprintf( file, "#undef RpcTryExcept\n"); + fprintf( file, "#undef RpcExcept\n"); + fprintf( file, "#undef RpcEndExcept\n"); + fprintf( file, "#undef RpcTryFinally\n"); + fprintf( file, "#undef RpcFinally\n"); + fprintf( file, "#undef RpcEndFinally\n"); + fprintf( file, "#undef RpcExceptionCode\n"); + fprintf( file, "#undef RpcAbnormalTermination\n"); + fprintf( file, "\n"); + fprintf( file, "struct __exception_frame;\n"); + fprintf( file, "typedef int (*__filter_func)(EXCEPTION_RECORD *, struct __exception_frame *);\n"); + fprintf( file, "typedef void (*__finally_func)(struct __exception_frame *);\n"); + fprintf( file, "\n"); + fprintf( file, "#define __DECL_EXCEPTION_FRAME \\\n"); + fprintf( file, " EXCEPTION_REGISTRATION_RECORD frame; \\\n"); + fprintf( file, " __filter_func filter; \\\n"); + fprintf( file, " __finally_func finally; \\\n"); + fprintf( file, " sigjmp_buf jmp; \\\n"); + fprintf( file, " DWORD code; \\\n"); + fprintf( file, " unsigned char abnormal_termination; \\\n"); + fprintf( file, " unsigned char filter_level; \\\n"); + fprintf( file, " unsigned char finally_level;\n"); + fprintf( file, "\n"); + fprintf( file, "struct __exception_frame\n{\n"); + fprintf( file, " __DECL_EXCEPTION_FRAME\n"); + fprintf( file, "};\n"); + fprintf( file, "\n"); + fprintf( file, "static DWORD __widl_exception_handler( EXCEPTION_RECORD *record,\n"); + fprintf( file, " EXCEPTION_REGISTRATION_RECORD *frame,\n"); + fprintf( file, " CONTEXT *context,\n"); + fprintf( file, " EXCEPTION_REGISTRATION_RECORD **pdispatcher )\n"); + fprintf( file, "{\n"); + fprintf( file, " struct __exception_frame *exc_frame = (struct __exception_frame *)frame;\n"); + fprintf( file, "\n"); + fprintf( file, " if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))\n"); + fprintf( file, " {\n" ); + fprintf( file, " if (exc_frame->finally_level && (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))\n"); + fprintf( file, " {\n" ); + fprintf( file, " exc_frame->abnormal_termination = 1;\n"); + fprintf( file, " exc_frame->finally( exc_frame );\n"); + fprintf( file, " }\n" ); + fprintf( file, " return ExceptionContinueSearch;\n"); + fprintf( file, " }\n" ); + fprintf( file, " exc_frame->code = record->ExceptionCode;\n"); + fprintf( file, " if (exc_frame->filter_level && exc_frame->filter( record, exc_frame ) == EXCEPTION_EXECUTE_HANDLER)\n" ); + fprintf( file, " {\n"); + fprintf( file, " __wine_rtl_unwind( frame, record );\n"); + fprintf( file, " if (exc_frame->finally_level > exc_frame->filter_level)\n" ); + fprintf( file, " {\n"); + fprintf( file, " exc_frame->abnormal_termination = 1;\n"); + fprintf( file, " exc_frame->finally( exc_frame );\n"); + fprintf( file, " __wine_pop_frame( frame );\n"); + fprintf( file, " }\n"); + fprintf( file, " exc_frame->filter_level = 0;\n"); + fprintf( file, " siglongjmp( exc_frame->jmp, 1 );\n"); + fprintf( file, " }\n"); + fprintf( file, " return ExceptionContinueSearch;\n"); + fprintf( file, "}\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcTryExcept \\\n"); + fprintf( file, " if (!sigsetjmp( __frame->jmp, 0 )) \\\n"); + fprintf( file, " { \\\n"); + fprintf( file, " if (!__frame->finally_level) \\\n" ); + fprintf( file, " __wine_push_frame( &__frame->frame ); \\\n"); + fprintf( file, " __frame->filter_level = __frame->finally_level + 1;\n" ); + fprintf( file, "\n"); + fprintf( file, "#define RpcExcept(expr) \\\n"); + fprintf( file, " if (!__frame->finally_level) \\\n" ); + fprintf( file, " __wine_pop_frame( &__frame->frame ); \\\n"); + fprintf( file, " __frame->filter_level = 0; \\\n" ); + fprintf( file, " } \\\n"); + fprintf( file, " else \\\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcEndExcept\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcExceptionCode() (__frame->code)\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcTryFinally \\\n"); + fprintf( file, " if (!__frame->filter_level) \\\n"); + fprintf( file, " __wine_push_frame( &__frame->frame ); \\\n"); + fprintf( file, " __frame->finally_level = __frame->filter_level + 1;\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcFinally \\\n"); + fprintf( file, " if (!__frame->filter_level) \\\n"); + fprintf( file, " __wine_pop_frame( &__frame->frame ); \\\n"); + fprintf( file, " __frame->finally_level = 0;\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcEndFinally\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcAbnormalTermination() (__frame->abnormal_termination)\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcExceptionInit(filter_func,finally_func) \\\n"); + fprintf( file, " do { \\\n"); + fprintf( file, " __frame->frame.Handler = __widl_exception_handler; \\\n"); + fprintf( file, " __frame->filter = (__filter_func)(filter_func); \\\n" ); + fprintf( file, " __frame->finally = (__finally_func)(finally_func); \\\n"); + fprintf( file, " __frame->abnormal_termination = 0; \\\n"); + fprintf( file, " __frame->filter_level = 0; \\\n"); + fprintf( file, " __frame->finally_level = 0; \\\n"); + fprintf( file, " } while (0)\n"); + fprintf( file, "\n"); + fprintf( file, "#else /* USE_COMPILER_EXCEPTIONS */\n"); + fprintf( file, "\n"); + fprintf( file, "#define RpcExceptionInit(filter_func,finally_func) do {} while(0)\n"); + fprintf( file, "#define __DECL_EXCEPTION_FRAME\n"); + fprintf( file, "\n"); + fprintf( file, "#endif /* USE_COMPILER_EXCEPTIONS */\n"); +} diff --git a/reactos/tools/widl/typegen.h b/reactos/tools/widl/typegen.h index a1013cb37f8..0276b7fa433 100644 --- a/reactos/tools/widl/typegen.h +++ b/reactos/tools/widl/typegen.h @@ -41,21 +41,24 @@ typedef int (*type_pred_t)(const type_t *); void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred); void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); -void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname); -void write_remoting_arguments(FILE *file, int indent, const func_t *func, enum pass pass, enum remoting_phase phase); +void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase, + enum pass pass, const var_t *var, const char *varname); +void write_remoting_arguments(FILE *file, int indent, const func_t *func, const char *local_var_prefix, + enum pass pass, enum remoting_phase phase); size_t get_size_procformatstring_type(const char *name, const type_t *type, const attr_list_t *attrs); size_t get_size_procformatstring_func(const func_t *func); size_t get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred); size_t get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred); -void assign_stub_out_args( FILE *file, int indent, const func_t *func ); +void assign_stub_out_args( FILE *file, int indent, const func_t *func, const char *local_var_prefix ); void declare_stub_args( FILE *file, int indent, const func_t *func ); int write_expr_eval_routines(FILE *file, const char *iface); void write_expr_eval_routine_list(FILE *file, const char *iface); void write_user_quad_list(FILE *file); void write_endpoints( FILE *f, const char *prefix, const str_list_t *list ); +void write_exceptions( FILE *file ); size_t type_memsize(const type_t *t, unsigned int *align); int decl_indirect(const type_t *t); -void write_parameters_init(FILE *file, int indent, const func_t *func); +void write_parameters_init(FILE *file, int indent, const func_t *func, const char *local_var_prefix); void print(FILE *file, int indent, const char *format, va_list ap); int get_padding(const var_list_t *fields); int is_user_type(const type_t *t); diff --git a/reactos/tools/widl/typelib.c b/reactos/tools/widl/typelib.c index c79f01646cf..116316b1693 100644 --- a/reactos/tools/widl/typelib.c +++ b/reactos/tools/widl/typelib.c @@ -45,8 +45,6 @@ #include "widltypes.h" #include "typelib_struct.h" -int in_typelib = 0; - static typelib_t *typelib; type_t *duptype(type_t *t, int dupname) @@ -245,7 +243,6 @@ unsigned short get_type_vt(type_t *t) void start_typelib(typelib_t *typelib_type) { - in_typelib++; if (!do_typelib) return; typelib = typelib_type; @@ -254,23 +251,11 @@ void start_typelib(typelib_t *typelib_type) void end_typelib(void) { - in_typelib--; if (!typelib) return; create_msft_typelib(typelib); } -void add_typelib_entry(type_t *t) -{ - typelib_entry_t *entry; - if (!typelib) return; - - chat("add kind %i: %s\n", t->kind, t->name); - entry = xmalloc(sizeof(*entry)); - entry->type = t; - list_add_tail( &typelib->entries, &entry->entry ); -} - static void tlb_read(int fd, void *buf, int count) { if(read(fd, buf, count) < count) @@ -353,10 +338,10 @@ static void read_importlib(importlib_t *importlib) file_name = wpp_find_include(importlib->name, NULL); if(file_name) { - fd = open(file_name, O_RDONLY | O_BINARY); + fd = open(file_name, O_RDONLY | O_BINARY ); free(file_name); }else { - fd = open(importlib->name, O_RDONLY | O_BINARY); + fd = open(importlib->name, O_RDONLY | O_BINARY ); } if(fd < 0) diff --git a/reactos/tools/widl/typelib.h b/reactos/tools/widl/typelib.h index 486dbb49e3e..58bad43f2e3 100644 --- a/reactos/tools/widl/typelib.h +++ b/reactos/tools/widl/typelib.h @@ -21,10 +21,8 @@ #ifndef __WIDL_TYPELIB_H #define __WIDL_TYPELIB_H -extern int in_typelib; extern void start_typelib(typelib_t *typelib_type); extern void end_typelib(void); -extern void add_typelib_entry(type_t *t); extern void add_importlib(const char *name); /* Copied from wtypes.h. Not included directly because that would create a diff --git a/reactos/tools/widl/typetree.c b/reactos/tools/widl/typetree.c new file mode 100644 index 00000000000..2b56bb8e6ff --- /dev/null +++ b/reactos/tools/widl/typetree.c @@ -0,0 +1,98 @@ +/* + * IDL Type Tree + * + * Copyright 2008 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 + */ + +#include "config.h" + +#include +#include + +#include "widl.h" +#include "utils.h" +#include "parser.h" +#include "typetree.h" +#include "header.h" + +type_t *type_new_function(var_list_t *args) +{ + type_t *t = make_type(RPC_FC_FUNCTION, NULL); + t->details.function = xmalloc(sizeof(*t->details.function)); + t->details.function->args = args; + return t; +} + +type_t *type_new_pointer(type_t *ref, attr_list_t *attrs) +{ + type_t *t = make_type(pointer_default, ref); + t->attrs = attrs; + return t; +} + +static int compute_method_indexes(type_t *iface) +{ + int idx; + func_t *f; + + if (iface->ref) + idx = compute_method_indexes(iface->ref); + else + idx = 0; + + if (!iface->funcs) + return idx; + + LIST_FOR_EACH_ENTRY( f, iface->funcs, func_t, entry ) + if (! is_callas(f->def->attrs)) + f->idx = idx++; + + return idx; +} + +void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts) +{ + iface->ref = inherit; + iface->details.iface = xmalloc(sizeof(*iface->details.iface)); + iface->funcs = gen_function_list(stmts); + iface->details.iface->disp_props = NULL; + iface->details.iface->disp_methods = NULL; + iface->stmts = stmts; + iface->defined = TRUE; + check_functions(iface); + compute_method_indexes(iface); +} + +void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods) +{ + iface->ref = find_type("IDispatch", 0); + if (!iface->ref) error_loc("IDispatch is undefined\n"); + iface->details.iface = xmalloc(sizeof(*iface->details.iface)); + iface->funcs = NULL; + iface->details.iface->disp_props = props; + iface->details.iface->disp_methods = methods; + iface->stmts = NULL; + iface->defined = TRUE; + check_functions(iface); + compute_method_indexes(iface); +} + +void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface) +{ + type_dispinterface_define(dispiface, iface->details.iface->disp_props, + iface->details.iface->disp_methods); +} diff --git a/reactos/tools/widl/typetree.h b/reactos/tools/widl/typetree.h new file mode 100644 index 00000000000..99c0d2f911d --- /dev/null +++ b/reactos/tools/widl/typetree.h @@ -0,0 +1,107 @@ +/* + * IDL Type Tree + * + * Copyright 2008 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 + */ + +#include "widltypes.h" +#include + +#ifndef WIDL_TYPE_TREE_H +#define WIDL_TYPE_TREE_H + +type_t *type_new_function(var_list_t *args); +type_t *type_new_pointer(type_t *ref, attr_list_t *attrs); +void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts); +void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods); +void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface); + +static inline var_list_t *type_struct_get_fields(const type_t *type) +{ + assert(is_struct(type->type)); + return type->details.structure->fields; +} + +static inline var_list_t *type_function_get_args(const type_t *type) +{ + assert(type->type == RPC_FC_FUNCTION); + return type->details.function->args; +} + +static inline var_list_t *type_enum_get_values(const type_t *type) +{ + assert(type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32); + return type->details.enumeration->enums; +} + +static inline var_t *type_union_get_switch_value(const type_t *type) +{ + assert(type->type == RPC_FC_ENCAPSULATED_UNION); + return LIST_ENTRY(list_head(type->details.structure->fields), var_t, entry); +} + +static inline var_list_t *type_encapsulated_union_get_fields(const type_t *type) +{ + assert(type->type == RPC_FC_ENCAPSULATED_UNION); + return type->details.structure->fields; +} + +static inline var_list_t *type_union_get_cases(const type_t *type) +{ + assert(type->type == RPC_FC_ENCAPSULATED_UNION || + type->type == RPC_FC_NON_ENCAPSULATED_UNION); + if (type->type == RPC_FC_ENCAPSULATED_UNION) + { + const var_t *uv = LIST_ENTRY(list_tail(type->details.structure->fields), const var_t, entry); + return uv->type->details.structure->fields; + } + else + return type->details.structure->fields; +} + +static inline var_list_t *type_dispiface_get_props(const type_t *type) +{ + assert(type->type == RPC_FC_IP); + return type->details.iface->disp_props; +} + +static inline var_list_t *type_dispiface_get_methods(const type_t *type) +{ + assert(type->type == RPC_FC_IP); + return type->details.iface->disp_methods; +} + +static inline int type_is_defined(const type_t *type) +{ + return type->defined; +} + +static inline int type_is_complete(const type_t *type) +{ + if (type->type == RPC_FC_FUNCTION) + return (type->details.function != NULL); + else if (type->type == RPC_FC_IP) + return (type->details.iface != NULL); + else if (type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32) + return (type->details.enumeration != NULL); + else if (is_struct(type->type) || is_union(type->type)) + return (type->details.structure != NULL); + else + return TRUE; +} + +#endif /* WIDL_TYPE_TREE_H */ diff --git a/reactos/tools/widl/widl.c b/reactos/tools/widl/widl.c index 3e6fd2d1148..ab1572611b3 100644 --- a/reactos/tools/widl/widl.c +++ b/reactos/tools/widl/widl.c @@ -78,6 +78,8 @@ static const char usage[] = " -U file Name of interface identifiers file (default is infile_i.c)\n" " -V Print version and exit\n" " -W Enable pedantic warnings\n" +" --win32 Only generate 32-bit code\n" +" --win64 Only generate 64-bit code\n" "Debug level 'n' is a bitmask with following meaning:\n" " * 0x01 Tell which resource is parsed (verbose mode)\n" " * 0x02 Dump internal structures\n" @@ -106,6 +108,8 @@ int do_idfile = 0; int do_dlldata = 0; int no_preprocess = 0; int old_names = 0; +int do_win32 = 1; +int do_win64 = 1; char *input_name; char *header_name; @@ -128,10 +132,10 @@ const char *prefix_server = ""; int line_number = 1; FILE *header; -FILE *local_stubs; -FILE *proxy; FILE *idfile; +size_t pointer_size = 0; + time_t now; enum { @@ -141,7 +145,9 @@ enum { LOCAL_STUBS_OPTION, PREFIX_ALL_OPTION, PREFIX_CLIENT_OPTION, - PREFIX_SERVER_OPTION + PREFIX_SERVER_OPTION, + WIN32_OPTION, + WIN64_OPTION }; static const char short_options[] = @@ -154,6 +160,8 @@ static const struct option long_options[] = { { "prefix-all", 1, 0, PREFIX_ALL_OPTION }, { "prefix-client", 1, 0, PREFIX_CLIENT_OPTION }, { "prefix-server", 1, 0, PREFIX_SERVER_OPTION }, + { "win32", 0, 0, WIN32_OPTION }, + { "win64", 0, 0, WIN64_OPTION }, { 0, 0, 0, 0 } }; @@ -174,7 +182,7 @@ static char *make_token(const char *name) token = xstrdup(name); for (i=0; token[i]; i++) { if (!isalnum(token[i])) token[i] = '_'; - else token[i] = tolower(token[i]); + else token[i] = toupper(token[i]); } return token; } @@ -205,14 +213,14 @@ static void set_everything(int x) do_dlldata = x; } -static void start_cplusplus_guard(FILE *fp) +void start_cplusplus_guard(FILE *fp) { fprintf(fp, "#ifdef __cplusplus\n"); fprintf(fp, "extern \"C\" {\n"); fprintf(fp, "#endif\n\n"); } -static void end_cplusplus_guard(FILE *fp) +void end_cplusplus_guard(FILE *fp) { fprintf(fp, "#ifdef __cplusplus\n"); fprintf(fp, "}\n"); @@ -333,6 +341,65 @@ void write_dlldata(const statement_list_t *stmts) free_filename_nodes(&filenames); } +static void write_id_data_stmts(const statement_list_t *stmts) +{ + const statement_t *stmt; + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) + { + if (stmt->type == STMT_TYPE) + { + const type_t *type = stmt->u.type; + if (type->type == RPC_FC_IP) + { + const UUID *uuid; + if (!is_object(type->attrs) && !is_attr(type->attrs, ATTR_DISPINTERFACE)) + continue; + uuid = get_attrp(type->attrs, ATTR_UUID); + write_guid(idfile, is_attr(type->attrs, ATTR_DISPINTERFACE) ? "DIID" : "IID", + type->name, uuid); + } + else if (type->type == RPC_FC_COCLASS) + { + const UUID *uuid = get_attrp(type->attrs, ATTR_UUID); + write_guid(idfile, "CLSID", type->name, uuid); + } + } + else if (stmt->type == STMT_LIBRARY) + { + const UUID *uuid = get_attrp(stmt->u.lib->attrs, ATTR_UUID); + write_guid(idfile, "LIBID", stmt->u.lib->name, uuid); + write_id_data_stmts(stmt->u.lib->stmts); + } + } +} + +void write_id_data(const statement_list_t *stmts) +{ + if (!do_idfile) return; + + idfile_token = make_token(idfile_name); + + idfile = fopen(idfile_name, "w"); + if (! idfile) { + error("Could not open %s for output\n", idfile_name); + return; + } + + fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION); + fprintf(idfile, "from %s - Do not edit ***/\n\n", input_name); + fprintf(idfile, "#include \n"); + fprintf(idfile, "#include \n\n"); + fprintf(idfile, "#include \n\n"); + start_cplusplus_guard(idfile); + + write_id_data_stmts(stmts); + + fprintf(idfile, "\n"); + end_cplusplus_guard(idfile); + + fclose(idfile); +} + int main(int argc,char *argv[]) { extern char* optarg; @@ -375,6 +442,14 @@ int main(int argc,char *argv[]) case PREFIX_SERVER_OPTION: prefix_server = xstrdup(optarg); break; + case WIN32_OPTION: + do_win32 = 1; + do_win64 = 0; + break; + case WIN64_OPTION: + do_win32 = 0; + do_win64 = 1; + break; case 'c': do_everything = 0; do_client = 1; @@ -551,77 +626,11 @@ int main(int argc,char *argv[]) } } - if(do_header) { - header_token = make_token(header_name); - - if(!(header = fopen(header_name, "w"))) { - fprintf(stderr, "Could not open %s for output\n", header_name); - return 1; - } - fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name); - fprintf(header, "#include \n" ); - fprintf(header, "#include \n\n" ); - fprintf(header, "#ifndef __%s__\n", header_token); - fprintf(header, "#define __%s__\n", header_token); - start_cplusplus_guard(header); - } - - if (local_stubs_name) { - local_stubs = fopen(local_stubs_name, "w"); - if (!local_stubs) { - fprintf(stderr, "Could not open %s for output\n", local_stubs_name); - return 1; - } - fprintf(local_stubs, "/* call_as/local stubs for %s */\n\n", input_name); - fprintf(local_stubs, "#include \n"); - fprintf(local_stubs, "#include \"%s\"\n\n", header_name); - } - - if (do_idfile) { - idfile_token = make_token(idfile_name); - - idfile = fopen(idfile_name, "w"); - if (! idfile) { - fprintf(stderr, "Could not open %s for output\n", idfile_name); - return 1; - } - - fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION); - fprintf(idfile, "from %s - Do not edit ***/\n\n", input_name); - fprintf(idfile, "#include \n"); - fprintf(idfile, "#include \n\n"); - fprintf(idfile, "#include \n\n"); - start_cplusplus_guard(idfile); - } + header_token = make_token(header_name); init_types(); ret = parser_parse(); - if(do_header) { - fprintf(header, "/* Begin additional prototypes for all interfaces */\n"); - fprintf(header, "\n"); - write_user_types(); - write_generic_handle_routines(); - write_context_handle_rundowns(); - fprintf(header, "\n"); - fprintf(header, "/* End additional prototypes */\n"); - fprintf(header, "\n"); - end_cplusplus_guard(header); - fprintf(header, "#endif /* __%s__ */\n", header_token); - fclose(header); - } - - if (local_stubs) { - fclose(local_stubs); - } - - if (do_idfile) { - fprintf(idfile, "\n"); - end_cplusplus_guard(idfile); - - fclose(idfile); - } - fclose(parser_in); if(ret) { diff --git a/reactos/tools/widl/widl.h b/reactos/tools/widl/widl.h index f08a9ae326a..d8c945ff524 100644 --- a/reactos/tools/widl/widl.h +++ b/reactos/tools/widl/widl.h @@ -45,9 +45,12 @@ extern int do_server; extern int do_idfile; extern int do_dlldata; extern int old_names; +extern int do_win32; +extern int do_win64; extern char *input_name; extern char *header_name; +extern char *header_token; extern char *local_stubs_name; extern char *typelib_name; extern char *dlldata_name; @@ -59,18 +62,21 @@ extern char *server_name; extern char *server_token; extern const char *prefix_client; extern const char *prefix_server; +extern size_t pointer_size; extern time_t now; extern int line_number; extern int char_number; -extern FILE* header; -extern FILE* local_stubs; -extern FILE* idfile; - +extern void write_header(const statement_list_t *stmts); +extern void write_id_data(const statement_list_t *stmts); extern void write_proxies(const statement_list_t *stmts); extern void write_client(const statement_list_t *stmts); extern void write_server(const statement_list_t *stmts); +extern void write_local_stubs(const statement_list_t *stmts); extern void write_dlldata(const statement_list_t *stmts); +extern void start_cplusplus_guard(FILE *fp); +extern void end_cplusplus_guard(FILE *fp); + #endif diff --git a/reactos/tools/widl/widl.rbuild b/reactos/tools/widl/widl.rbuild index fe519bd0d24..93189fa7a7b 100644 --- a/reactos/tools/widl/widl.rbuild +++ b/reactos/tools/widl/widl.rbuild @@ -13,6 +13,7 @@ server.c typegen.c typelib.c + typetree.c utils.c widl.c write_msft.c diff --git a/reactos/tools/widl/widltypes.h b/reactos/tools/widl/widltypes.h index b1805cfe8a0..31d7220de67 100644 --- a/reactos/tools/widl/widltypes.h +++ b/reactos/tools/widl/widltypes.h @@ -29,6 +29,7 @@ #define max(a, b) ((a) > (b) ? a : b) #include +#include #include "guiddef.h" #include "wine/rpcfc.h" #include "wine/list.h" @@ -268,14 +269,42 @@ struct _expr_t { struct list entry; }; +struct struct_details +{ + var_list_t *fields; +}; + +struct enumeration_details +{ + var_list_t *enums; +}; + +struct func_details +{ + var_list_t *args; +}; + +struct iface_details +{ + func_list_t *disp_methods; + var_list_t *disp_props; +}; + struct _type_t { const char *name; enum type_kind kind; unsigned char type; struct _type_t *ref; attr_list_t *attrs; + union + { + struct struct_details *structure; + struct enumeration_details *enumeration; + struct func_details *function; + struct iface_details *iface; + } details; func_list_t *funcs; /* interfaces and modules */ - var_list_t *fields_or_args; /* interfaces, structures, enumerations and functions (for args) */ + statement_list_t *stmts; /* interfaces and modules */ ifref_list_t *ifaces; /* coclasses */ unsigned long dim; /* array dimension */ expr_t *size_is, *length_is; @@ -320,7 +349,7 @@ struct _declarator_t { struct _func_t { var_t *def; var_list_t *args; - int ignore, idx; + int idx; /* parser-internal */ struct list entry; @@ -368,7 +397,6 @@ struct _typelib_t { char *name; char *filename; const attr_list_t *attrs; - struct list entries; struct list importlibs; statement_list_t *stmts; }; @@ -405,6 +433,7 @@ void check_for_additional_prototype_types(const var_list_t *list); void init_types(void); type_t *alloc_type(void); void set_all_tfswrite(int val); +void clear_all_offsets(void); type_t *duptype(type_t *t, int dupname); type_t *alias(type_t *t, const char *name); diff --git a/reactos/tools/widl/write_msft.c b/reactos/tools/widl/write_msft.c index ca7a4731ed0..8fecd0adc33 100644 --- a/reactos/tools/widl/write_msft.c +++ b/reactos/tools/widl/write_msft.c @@ -49,6 +49,7 @@ #include "utils.h" #include "header.h" #include "hash.h" +#include "typetree.h" enum MSFT_segment_index { MSFT_SEG_TYPEINFO = 0, /* type information */ @@ -1966,14 +1967,14 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte if (dispinterface->funcs) LIST_FOR_EACH_ENTRY( func, dispinterface->funcs, const func_t, entry ) idx++; - if (dispinterface->fields_or_args) - LIST_FOR_EACH_ENTRY( var, dispinterface->fields_or_args, var_t, entry ) + if (type_dispiface_get_props(dispinterface)) + LIST_FOR_EACH_ENTRY( var, type_dispiface_get_props(dispinterface), var_t, entry ) add_var_desc(msft_typeinfo, idx++, var); - if (dispinterface->funcs) + if (type_dispiface_get_methods(dispinterface)) { idx = 0; - LIST_FOR_EACH_ENTRY( func, dispinterface->funcs, const func_t, entry ) + LIST_FOR_EACH_ENTRY( func, type_dispiface_get_methods(dispinterface), const func_t, entry ) if(add_func_desc(msft_typeinfo, func, idx) == S_OK) idx++; } @@ -2050,8 +2051,8 @@ static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure) msft_typeinfo = create_msft_typeinfo(typelib, TKIND_RECORD, structure->name, structure->attrs); msft_typeinfo->typeinfo->size = 0; - if (structure->fields_or_args) - LIST_FOR_EACH_ENTRY( cur, structure->fields_or_args, var_t, entry ) + if (type_struct_get_fields(structure)) + LIST_FOR_EACH_ENTRY( cur, type_struct_get_fields(structure), var_t, entry ) add_var_desc(msft_typeinfo, idx++, cur); } @@ -2065,8 +2066,8 @@ static void add_enum_typeinfo(msft_typelib_t *typelib, type_t *enumeration) msft_typeinfo = create_msft_typeinfo(typelib, TKIND_ENUM, enumeration->name, enumeration->attrs); msft_typeinfo->typeinfo->size = 0; - if (enumeration->fields_or_args) - LIST_FOR_EACH_ENTRY( cur, enumeration->fields_or_args, var_t, entry ) + if (type_enum_get_values(enumeration)) + LIST_FOR_EACH_ENTRY( cur, type_enum_get_values(enumeration), var_t, entry ) add_var_desc(msft_typeinfo, idx++, cur); } @@ -2188,38 +2189,54 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module) msft_typeinfo->typeinfo->size = idx; } -static void add_entry(msft_typelib_t *typelib, typelib_entry_t *entry) +static void add_entry(msft_typelib_t *typelib, const statement_t *stmt) { - switch(entry->type->kind) { - case TKIND_INTERFACE: - case TKIND_DISPATCH: - add_interface_typeinfo(typelib, entry->type); + switch(stmt->type) { + case STMT_LIBRARY: + case STMT_IMPORT: + case STMT_CPPQUOTE: + case STMT_DECLARATION: + /* not included in typelib */ break; - - case TKIND_RECORD: - add_structure_typeinfo(typelib, entry->type); + case STMT_IMPORTLIB: + /* not processed here */ break; - - case TKIND_ENUM: - add_enum_typeinfo(typelib, entry->type); + case STMT_TYPEDEF: + { + const type_list_t *type_entry = stmt->u.type_list; + for (; type_entry; type_entry = type_entry->next) + if (is_attr(type_entry->type->attrs, ATTR_PUBLIC)) + add_typedef_typeinfo(typelib, type_entry->type); break; - - case TKIND_ALIAS: - add_typedef_typeinfo(typelib, entry->type); + } + case STMT_MODULE: + add_module_typeinfo(typelib, stmt->u.type); break; - - case TKIND_COCLASS: - add_coclass_typeinfo(typelib, entry->type); - break; - - case TKIND_MODULE: - add_module_typeinfo(typelib, entry->type); - break; - - default: - error("add_entry: unhandled type %d\n", entry->type->kind); + case STMT_TYPE: + case STMT_TYPEREF: + { + type_t *type = stmt->u.type; + switch (type->kind) { + case TKIND_INTERFACE: + case TKIND_DISPATCH: + add_interface_typeinfo(typelib, type); + break; + case TKIND_RECORD: + add_structure_typeinfo(typelib, type); + break; + case TKIND_ENUM: + add_enum_typeinfo(typelib, type); + break; + case TKIND_COCLASS: + add_coclass_typeinfo(typelib, type); + break; + default: + error("add_entry: unhandled type %d\n", type->kind); + break; + } break; } + } } static void set_name(msft_typelib_t *typelib) @@ -2494,7 +2511,7 @@ int create_msft_typelib(typelib_t *typelib) { msft_typelib_t *msft; int failed = 0; - typelib_entry_t *entry; + const statement_t *stmt; time_t cur_time; char *time_override; unsigned int version = 5 << 24 | 1 << 16 | 164; /* 5.01.0164 */ @@ -2547,8 +2564,9 @@ int create_msft_typelib(typelib_t *typelib) set_custdata(msft, &midl_time_guid, VT_UI4, &cur_time, &msft->typelib_header.CustomDataOffset); set_custdata(msft, &midl_version_guid, VT_UI4, &version, &msft->typelib_header.CustomDataOffset); - LIST_FOR_EACH_ENTRY( entry, &typelib->entries, typelib_entry_t, entry ) - add_entry(msft, entry); + if (typelib->stmts) + LIST_FOR_EACH_ENTRY( stmt, typelib->stmts, const statement_t, entry ) + add_entry(msft, stmt); save_all_changes(msft); free(msft);