The same entries can have a different call_as between the synchronous and asynchronous interfaces and shouldn't be mixed up. --- tools/widl/header.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 223ab5c5ca9..43be8d74cbe 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1535,7 +1535,7 @@ static void write_com_interface_start(FILE *header, const type_t *iface) fprintf(header,"#define __%s_%sINTERFACE_DEFINED__\n\n", iface->c_name, dispinterface ? "DISP" : ""); }
-static void write_com_interface_end(FILE *header, type_t *iface) +static void write_com_interface_end(FILE *header, type_t *iface, int as_async) { int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE); const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID); @@ -1614,7 +1614,8 @@ static void write_com_interface_end(FILE *header, type_t *iface) if (!dispinterface && !winrt_mode) { write_method_proto(header, iface); - write_locals(header, iface, FALSE); + if (!as_async) + write_locals(header, iface, FALSE); fprintf(header, "\n"); } fprintf(header, "#endif /* __%s_%sINTERFACE_DEFINED__ */\n", iface->c_name, dispinterface ? "DISP" : ""); @@ -1808,11 +1809,11 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons { write_com_interface_start(header, iface); write_header_stmts(header, type_iface_get_stmts(iface), stmt->u.type, TRUE); - write_com_interface_end(header, iface); + write_com_interface_end(header, iface, FALSE); if (async_iface) { write_com_interface_start(header, async_iface); - write_com_interface_end(header, async_iface); + write_com_interface_end(header, async_iface, TRUE); } } else
When compiled with mingw64 the output files have Windows line endings instead of UNIX ones. --- tools/widl/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 43be8d74cbe..5457185538e 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1893,7 +1893,7 @@ void write_header(const statement_list_t *stmts)
if (!do_header) return;
- if(!(header = fopen(header_name, "w"))) { + if(!(header = fopen(header_name, "wb"))) { error("Could not open %s for output\n", header_name); return; }
On Wed, 16 Dec 2020 at 12:44, Steve Lhomme robux4@ycbcr.xyz wrote:
When compiled with mingw64 the output files have Windows line endings instead of UNIX ones.
Isn't that what you'd want when building for Windows?
On 2020-12-16 14:13, Henri Verbeet wrote:
On Wed, 16 Dec 2020 at 12:44, Steve Lhomme robux4@ycbcr.xyz wrote:
When compiled with mingw64 the output files have Windows line endings instead of UNIX ones.
Isn't that what you'd want when building for Windows?
On Windows that would be the mingw-w64 generator and it's expecting files with only \n (otherwise it makes huge diffs).
I'm not sure if there are other cases where widl would be used to produce Windows based headers.
Hi Steve,
On 16.12.2020 10:14, Steve Lhomme wrote:
When compiled with mingw64 the output files have Windows line endings instead of UNIX ones.
tools/widl/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 43be8d74cbe..5457185538e 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1893,7 +1893,7 @@ void write_header(const statement_list_t *stmts)
if (!do_header) return;
- if(!(header = fopen(header_name, "w"))) {
- if(!(header = fopen(header_name, "wb"))) {
There are more places that would need to be fixed for consistency. Maybe we could use _set_fmode(_O_BINARY) in main() instead?
Thanks,
Jacek
On 2020-12-16 15:18, Jacek Caban wrote:
Hi Steve,
On 16.12.2020 10:14, Steve Lhomme wrote:
When compiled with mingw64 the output files have Windows line endings instead of UNIX ones.
tools/widl/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 43be8d74cbe..5457185538e 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1893,7 +1893,7 @@ void write_header(const statement_list_t *stmts) if (!do_header) return; - if(!(header = fopen(header_name, "w"))) { + if(!(header = fopen(header_name, "wb"))) {
There are more places that would need to be fixed for consistency. Maybe we could use _set_fmode(_O_BINARY) in main() instead?
Is this a MS-only thing ? I don't mind having this patch only in mingw-w64-tools (which also have some extra patch as well).
In general it may not be the proper way to handle this. For writing all files widl generates, it should be fine. But for reading files the "binary" mode is not currently used and it may break reading files that used to be read properly on Windows ?
On 16.12.2020 15:35, Steve Lhomme wrote:
On 2020-12-16 15:18, Jacek Caban wrote:
Hi Steve,
On 16.12.2020 10:14, Steve Lhomme wrote:
When compiled with mingw64 the output files have Windows line endings instead of UNIX ones.
tools/widl/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 43be8d74cbe..5457185538e 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1893,7 +1893,7 @@ void write_header(const statement_list_t *stmts) if (!do_header) return; - if(!(header = fopen(header_name, "w"))) { + if(!(header = fopen(header_name, "wb"))) {
There are more places that would need to be fixed for consistency. Maybe we could use _set_fmode(_O_BINARY) in main() instead?
Is this a MS-only thing ? I don't mind having this patch only in mingw-w64-tools (which also have some extra patch as well).
Yes, it would need an #ifdef.
In general it may not be the proper way to handle this. For writing all files widl generates, it should be fine. But for reading files the "binary" mode is not currently used and it may break reading files that used to be read properly on Windows ?
Which files do you mean? The only non-binary files that widl generates are headers and C files.
Generally speaking, widl output is cross platform, so it should generate the same output on regardless of host platform used. Windows line ending breaks that.
Jacek
On 2020-12-16 16:41, Jacek Caban wrote:
On 16.12.2020 15:35, Steve Lhomme wrote:
On 2020-12-16 15:18, Jacek Caban wrote:
Hi Steve,
On 16.12.2020 10:14, Steve Lhomme wrote:
When compiled with mingw64 the output files have Windows line endings instead of UNIX ones.
tools/widl/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 43be8d74cbe..5457185538e 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1893,7 +1893,7 @@ void write_header(const statement_list_t *stmts) if (!do_header) return; - if(!(header = fopen(header_name, "w"))) { + if(!(header = fopen(header_name, "wb"))) {
There are more places that would need to be fixed for consistency. Maybe we could use _set_fmode(_O_BINARY) in main() instead?
Is this a MS-only thing ? I don't mind having this patch only in mingw-w64-tools (which also have some extra patch as well).
Yes, it would need an #ifdef.
OK for me.
In general it may not be the proper way to handle this. For writing all files widl generates, it should be fine. But for reading files the "binary" mode is not currently used and it may break reading files that used to be read properly on Windows ?
Which files do you mean? The only non-binary files that widl generates are headers and C files.
I meant that for generated files it's fine, so I agree with you. I fear that forcing binary mode for input files as well may break reading some files with windows line ending on Windows. I don't think that's the case in mingw-w64 but it may have some side effects elsewhere.
Generally speaking, widl output is cross platform, so it should generate the same output on regardless of host platform used. Windows line ending breaks that.
That's a good incentive to fix this.
On 17.12.2020 08:06, Steve Lhomme wrote:
I meant that for generated files it's fine, so I agree with you. I fear that forcing binary mode for input files as well may break reading some files with windows line ending on Windows. I don't think that's the case in mingw-w64 but it may have some side effects elsewhere.
Note that binary mode results in more or less what we use on Unix, so if reading in text or binary mode changes output, it would most likely mean that we don't do it right on one of hosts. In practice, new lines are consumed by lexer and both modes should be fine.
Jacek
Hi Steve,
On 16.12.2020 10:14, Steve Lhomme wrote:
-static void write_com_interface_end(FILE *header, type_t *iface) +static void write_com_interface_end(FILE *header, type_t *iface, int as_async) { int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE); const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID); @@ -1614,7 +1614,8 @@ static void write_com_interface_end(FILE *header, type_t *iface) if (!dispinterface && !winrt_mode) { write_method_proto(header, iface);
- write_locals(header, iface, FALSE);
- if (!as_async)
write_locals(header, iface, FALSE);
You could use something like
if (type_iface_get_async_iface(iface) == iface)
to avoid extra as_async argument.
Thanks,
Jacek