Commit ee490ee2 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

widl: Support WinRT apicontract type.

parent 19b5f3e0
......@@ -744,6 +744,7 @@ SOURCES = \
windns.h \
windows.foundation.idl \
windows.h \
windowscontracts.idl \
windowsx.h \
wine/debug.h \
wine/exception.h \
......
......@@ -22,6 +22,7 @@
import "inspectable.idl";
/* import "asyncinfo.idl"; */
import "windowscontracts.idl";
/* import "eventtoken.idl"; */
/* import "ivectorchangedeventargs.idl"; */
......
/*
* Copyright 2020 Rémi Bernon for CodeWeavers
*
* 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
*/
#ifdef __WIDL__
#pragma winrt ns_prefix
#endif
namespace Windows {
namespace Foundation {
[contractversion(4)]
apicontract FoundationContract
{};
[contractversion(10)]
apicontract UniversalApiContract
{};
}
}
......@@ -462,6 +462,7 @@ static type_t *find_identifier(const char *identifier, const type_t *cont_type,
case TYPE_POINTER:
case TYPE_ARRAY:
case TYPE_BITFIELD:
case TYPE_APICONTRACT:
/* nothing to do */
break;
case TYPE_ALIAS:
......
......@@ -471,6 +471,10 @@ void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, i
else write_type_left(h, ds, name_type, declonly, write_callconv);
break;
}
case TYPE_APICONTRACT:
/* shouldn't be here */
assert(0);
break;
}
}
}
......@@ -533,6 +537,10 @@ void write_type_right(FILE *h, type_t *t, int is_field)
case TYPE_COCLASS:
case TYPE_INTERFACE:
break;
case TYPE_APICONTRACT:
/* not supposed to be here */
assert(0);
break;
}
}
......@@ -1452,6 +1460,14 @@ static void write_forward(FILE *header, type_t *iface)
fprintf(header, "#endif\n\n" );
}
static char *format_apicontract_macro(const type_t *type)
{
char *name = format_namespace(type->namespace, "", "_", type->name, NULL);
int i;
for (i = strlen(name); i > 0; --i) name[i - 1] = toupper(name[i - 1]);
return name;
}
static void write_com_interface_start(FILE *header, const type_t *iface)
{
int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE);
......@@ -1616,6 +1632,15 @@ static void write_coclass_forward(FILE *header, type_t *cocl)
fprintf(header, "#endif /* defined __%s_FWD_DEFINED__ */\n\n", cocl->name );
}
static void write_apicontract(FILE *header, type_t *apicontract)
{
char *name = format_apicontract_macro(apicontract);
fprintf(header, "#if !defined(%s_VERSION)\n", name);
fprintf(header, "#define %s_VERSION %#x\n", name, get_attrv(apicontract->attrs, ATTR_CONTRACTVERSION));
fprintf(header, "#endif // defined(%s_VERSION)\n\n", name);
free(name);
}
static void write_import(FILE *header, const char *fname)
{
char *hname, *p;
......@@ -1734,6 +1759,8 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
}
else if (type_get_type(stmt->u.type) == TYPE_COCLASS)
write_coclass(header, stmt->u.type);
else if (type_get_type(stmt->u.type) == TYPE_APICONTRACT)
write_apicontract(header, stmt->u.type);
else
{
write_type_definition(header, stmt->u.type, stmt->declonly);
......
......@@ -267,6 +267,7 @@ static const struct keyword keywords[] = {
{"_fastcall", tFASTCALL, 0},
{"_pascal", tPASCAL, 0},
{"_stdcall", tSTDCALL, 0},
{"apicontract", tAPICONTRACT, 1},
{"boolean", tBOOLEAN, 0},
{"byte", tBYTE, 0},
{"case", tCASE, 0},
......
......@@ -374,6 +374,10 @@ enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *att
case TYPE_ALIAS:
case TYPE_BITFIELD:
break;
case TYPE_APICONTRACT:
/* not supposed to be here */
assert(0);
break;
}
return TGT_INVALID;
}
......@@ -1966,6 +1970,7 @@ unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
case TYPE_MODULE:
case TYPE_FUNCTION:
case TYPE_BITFIELD:
case TYPE_APICONTRACT:
/* these types should not be encountered here due to language
* restrictions (interface, void, coclass, module), logical
* restrictions (alias - due to type_get_type call above) or
......@@ -2067,6 +2072,7 @@ static unsigned int type_buffer_alignment(const type_t *t)
case TYPE_MODULE:
case TYPE_FUNCTION:
case TYPE_BITFIELD:
case TYPE_APICONTRACT:
/* these types should not be encountered here due to language
* restrictions (interface, void, coclass, module), logical
* restrictions (alias - due to type_get_type call above) or
......
......@@ -224,7 +224,8 @@ unsigned short get_type_vt(type_t *t)
return VT_VOID;
case TYPE_ALIAS:
/* aliases should be filtered out by the type_get_type call above */
case TYPE_APICONTRACT:
/* not supposed to be here */
assert(0);
break;
......
......@@ -223,6 +223,9 @@ static inline int type_is_complete(const type_t *type)
case TYPE_ARRAY:
case TYPE_BITFIELD:
return TRUE;
case TYPE_APICONTRACT:
assert(0);
break;
}
return FALSE;
}
......
......@@ -440,6 +440,7 @@ enum type_type
TYPE_POINTER,
TYPE_ARRAY,
TYPE_BITFIELD,
TYPE_APICONTRACT,
};
struct _type_t {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment