Using #ifdef to selectively register runtimeclasses from the public IDLs isn't going to work out, this implements explicit class registration instead.
For now we are missing a possible useful check in widl to make sure the referenced class is defined, this will be added later on after all modules are made explicit.
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/parser.y | 3 ++- tools/widl/register.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 91ac325be82..83af2721cf4 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -429,7 +429,8 @@ gbl_statements | gbl_statements apicontract ';' { $$ = $1; reg_type($2, $2->name, current_namespace, 0); } | gbl_statements apicontract_def { $$ = append_statement($1, make_statement_type_decl($2)); reg_type($2, $2->name, current_namespace, 0); } - | gbl_statements runtimeclass ';' { $$ = $1; reg_type($2, $2->name, current_namespace, 0); } + | gbl_statements runtimeclass ';' { $$ = append_statement($1, make_statement_reference($2)); + reg_type($2, $2->name, current_namespace, 0); } | gbl_statements runtimeclass_def { $$ = append_statement($1, make_statement_type_decl($2)); reg_type($2, $2->name, current_namespace, 0); } | gbl_statements moduledef { $$ = append_statement($1, make_statement_module($2)); } diff --git a/tools/widl/register.c b/tools/widl/register.c index 9ad0314d2da..91079b65fd6 100644 --- a/tools/widl/register.c +++ b/tools/widl/register.c @@ -194,9 +194,11 @@ static void write_runtimeclasses_registry( const statement_list_t *stmts )
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) { - if (stmt->type != STMT_TYPE) continue; + if (stmt->type != STMT_TYPE && stmt->type != STMT_TYPEREF) continue; if (type_get_type((type = stmt->u.type)) != TYPE_RUNTIMECLASS) continue; if (!get_attrp(type->attrs, ATTR_ACTIVATABLE) && !get_attrp(type->attrs, ATTR_STATIC)) continue; + if (stmt->type == STMT_TYPEREF && !type->defined) continue; + put_str( indent, "ForceRemove %s\n", format_namespace( type->namespace, "", ".", type->name, NULL ) ); put_str( indent++, "{\n" ); put_str( indent, "val 'DllPath' = s '%%MODULE%%'\n" );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.storage.applicationdata/classes.idl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlls/windows.storage.applicationdata/classes.idl b/dlls/windows.storage.applicationdata/classes.idl index 8b926c63e10..6029ac1ff10 100644 --- a/dlls/windows.storage.applicationdata/classes.idl +++ b/dlls/windows.storage.applicationdata/classes.idl @@ -19,6 +19,10 @@ */
#pragma makedep register +#pragma winrt ns_prefix
-#define _WINDOWS_APPLICATIONDATA -#include "windows.storage.idl" +import "windows.storage.idl"; + +namespace Windows.Storage { + runtimeclass ApplicationData; +}
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/windows.storage/classes.idl | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/dlls/windows.storage/classes.idl b/dlls/windows.storage/classes.idl index c77d7ec9ebb..d64d1c45ec8 100644 --- a/dlls/windows.storage/classes.idl +++ b/dlls/windows.storage/classes.idl @@ -19,10 +19,7 @@ */
#pragma makedep register - -#ifdef __WIDL__ #pragma winrt ns_prefix -#endif
import "inspectable.idl"; import "asyncinfo.idl"; @@ -30,10 +27,8 @@ import "eventtoken.idl"; import "windows.foundation.idl"; import "windowscontracts.idl"; import "windows.system.idl"; +import "windows.storage.idl";
-#define _WINDOWS_STORAGE -#define DO_NO_IMPORTS -#include "windows.storage.fileproperties.idl" -#include "windows.storage.search.idl" -#include "windows.storage.streams.idl" -#include "windows.storage.idl" +namespace Windows.Storage.Streams { + runtimeclass RandomAccessStreamReference; +}
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/wintypes/classes.idl | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/dlls/wintypes/classes.idl b/dlls/wintypes/classes.idl index 648eafddc16..139b25b2f85 100644 --- a/dlls/wintypes/classes.idl +++ b/dlls/wintypes/classes.idl @@ -19,13 +19,22 @@ */
#pragma makedep register - -#ifdef __WIDL__ #pragma winrt ns_prefix -#endif
-#define DO_NO_IMPORTS -#define _WINTYPES -#include "windows.foundation.idl" -#include "windows.foundation.metadata.idl" -#include "windows.storage.streams.idl" +import "windows.foundation.idl"; +import "windows.foundation.metadata.idl"; +import "windows.storage.streams.idl"; + +namespace Windows.Foundation { + runtimeclass PropertyValue; +} +namespace Windows.Foundation.Collections { + runtimeclass PropertySet; +} +namespace Windows.Foundation.Metadata { + runtimeclass ApiInformation; +} +namespace Windows.Storage.Streams { + runtimeclass Buffer; + runtimeclass DataWriter; +}
From: Rémi Bernon rbernon@codeweavers.com
--- include/windows.foundation.idl | 12 ------------ include/windows.storage.streams.idl | 10 ---------- 2 files changed, 22 deletions(-)
diff --git a/include/windows.foundation.idl b/include/windows.foundation.idl index d6b96175b2d..f4c1ea2800e 100644 --- a/include/windows.foundation.idl +++ b/include/windows.foundation.idl @@ -125,22 +125,16 @@ namespace Windows.Foundation { interface Windows.Foundation.Collections.IIterable<HSTRING>; interface Windows.Foundation.Collections.IIterable<IInspectable *>; interface Windows.Foundation.Collections.IIterable<IWwwFormUrlDecoderEntry *>; -#ifndef _WINTYPES interface Windows.Foundation.Collections.IIterable<Uri *>; -#endif interface Windows.Foundation.Collections.IIterator<HSTRING>; interface Windows.Foundation.Collections.IIterator<IInspectable *>; interface Windows.Foundation.Collections.IIterator<IWwwFormUrlDecoderEntry *>; -#ifndef _WINTYPES interface Windows.Foundation.Collections.IIterator<Uri *>; -#endif interface Windows.Foundation.Collections.IVectorView<BYTE>; interface Windows.Foundation.Collections.IVectorView<HSTRING>; interface Windows.Foundation.Collections.IVectorView<IInspectable *>; interface Windows.Foundation.Collections.IVectorView<IWwwFormUrlDecoderEntry *>; -#ifndef _WINTYPES interface Windows.Foundation.Collections.IVectorView<Windows.Foundation.Uri *>; -#endif interface Windows.Foundation.Collections.IVector<HSTRING>; interface Windows.Foundation.Collections.IVector<IInspectable *>; interface Windows.Foundation.Collections.IMapView<HSTRING, Windows.Foundation.Collections.IVectorView<HSTRING> *>; @@ -150,18 +144,14 @@ namespace Windows.Foundation { interface Windows.Foundation.AsyncOperationCompletedHandler<boolean>; interface Windows.Foundation.AsyncOperationCompletedHandler<HSTRING>; interface Windows.Foundation.AsyncOperationCompletedHandler<UINT32>; -#ifndef _WINTYPES interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Foundation.Uri *>; -#endif interface Windows.Foundation.AsyncOperationProgressHandler<UINT32, UINT32>; interface Windows.Foundation.AsyncOperationWithProgressCompletedHandler<UINT32, UINT32>; interface Windows.Foundation.IAsyncOperation<HSTRING>; interface Windows.Foundation.IAsyncOperation<IInspectable *>; interface Windows.Foundation.IAsyncOperation<boolean>; interface Windows.Foundation.IAsyncOperation<UINT32>; -#ifndef _WINTYPES interface Windows.Foundation.IAsyncOperation<Windows.Foundation.Uri *>; -#endif interface Windows.Foundation.IAsyncOperationWithProgress<UINT32, UINT32>; interface Windows.Foundation.IReference<BYTE>; interface Windows.Foundation.IReference<DOUBLE>; @@ -588,7 +578,6 @@ namespace Windows.Foundation { { }
-#ifndef _WINTYPES [ activatable(Windows.Foundation.IUriRuntimeClassFactory, Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), @@ -615,7 +604,6 @@ namespace Windows.Foundation { interface Windows.Foundation.Collections.IVectorView<Windows.Foundation.IWwwFormUrlDecoderEntry *>; interface Windows.Foundation.Collections.IIterable<Windows.Foundation.IWwwFormUrlDecoderEntry *>; } -#endif
[ contract(Windows.Foundation.UniversalApiContract, 1.0), diff --git a/include/windows.storage.streams.idl b/include/windows.storage.streams.idl index 35340895215..3ef6254c0ec 100644 --- a/include/windows.storage.streams.idl +++ b/include/windows.storage.streams.idl @@ -50,18 +50,15 @@ namespace Windows.Storage.Streams { runtimeclass Buffer; runtimeclass DataWriter; runtimeclass DataWriterStoreOperation; -#ifndef _WINTYPES runtimeclass InMemoryRandomAccessStream; runtimeclass RandomAccessStream; runtimeclass RandomAccessStreamReference; -#endif
declare { interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IBuffer *>; interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Storage.Streams.IOutputStream *>; interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IBuffer *>; interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IOutputStream *>; -#ifndef _WINTYPES interface Windows.Foundation.Collections.IIterable<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.Collections.IIterator<Windows.Storage.Streams.IRandomAccessStream *>; interface Windows.Foundation.Collections.IMapView<HSTRING, Windows.Storage.Streams.RandomAccessStreamReference *>; @@ -81,7 +78,6 @@ namespace Windows.Storage.Streams { interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IRandomAccessStreamWithContentType *>; interface Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.RandomAccessStreamReference *>; interface Windows.Foundation.IAsyncOperationWithProgress<UINT64,UINT64>; -#endif }
[ @@ -198,7 +194,6 @@ namespace Windows.Storage.Streams { HRESULT FlushAsync([out, retval] Windows.Foundation.IAsyncOperation<boolean> **operation); }
-#ifndef _WINTYPES [ contract(Windows.Foundation.UniversalApiContract, 1.0), exclusiveto(Windows.Storage.Streams.RandomAccessStream), @@ -270,9 +265,7 @@ namespace Windows.Storage.Streams { Windows.Storage.Streams.IContentTypeProvider { } -#endif
-#ifndef _WINDOWS_STORAGE [ activatable(Windows.Storage.Streams.IBufferFactory, Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), @@ -306,9 +299,7 @@ namespace Windows.Storage.Streams { { [default] interface Windows.Foundation.IAsyncOperation<UINT32>; } -#endif
-#ifndef _WINTYPES [ activatable(Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), @@ -340,6 +331,5 @@ namespace Windows.Storage.Streams { { [default] interface Windows.Storage.Streams.IRandomAccessStreamReference; } -#endif
}