Commit a7f0e61e authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Avoid using Windows types where possible.

parent dbfdcb13
......@@ -437,7 +437,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
static void write_clientinterfacedecl(type_t *iface)
{
unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(iface->attrs, ATTR_UUID);
const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT);
if (endpoints) write_endpoints( client, iface->name, endpoints );
......
......@@ -503,10 +503,10 @@ static const unsigned char Lookup_224[128 * 3] = {
* skind and lcid, while the low word is based on a repeated string
* hash of skind/str.
*/
unsigned int lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
unsigned int lhash_val_of_name_sys( syskind_t skind, int lcid, const char *lpStr)
{
ULONG nOffset, nMask = skind == SYS_MAC ? 1 : 0;
ULONG nHiWord, nLoWord = 0x0deadbee;
unsigned int nOffset, nMask = skind == SYS_MAC ? 1 : 0;
unsigned int nHiWord, nLoWord = 0x0deadbee;
const unsigned char *str = (const unsigned char *)lpStr, *pnLookup = NULL;
if (!str)
......@@ -669,7 +669,7 @@ unsigned int lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
/* Hash a single 512-bit block. This is the core of the algorithm. */
static void sha1_transform(struct sha1_context *ctx)
{
DWORD a, b, c, d, e, *block = (DWORD *)ctx->buffer;
unsigned int a, b, c, d, e, *block = (unsigned int *)ctx->buffer;
/* Copy ctx->state[] to working variables */
a = ctx->state[0];
......@@ -748,7 +748,7 @@ void sha1_update(struct sha1_context *ctx, const char *data, size_t data_size)
}
}
void sha1_finalize(struct sha1_context *ctx, DWORD result[5])
void sha1_finalize(struct sha1_context *ctx, unsigned int result[5])
{
unsigned int *count, length_hi, length_lo, i;
size_t pad_size, buffer_size;
......
......@@ -22,19 +22,17 @@
#ifndef __WIDL_HASH_H
#define __WIDL_HASH_H
#include "windef.h"
extern unsigned int lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr);
extern unsigned int lhash_val_of_name_sys( syskind_t skind, int lcid, const char *lpStr);
struct sha1_context
{
DWORD state[5];
DWORD count[2];
char buffer[64];
unsigned int state[5];
unsigned int count[2];
char buffer[64];
};
void sha1_init(struct sha1_context *ctx);
void sha1_update(struct sha1_context *ctx, const char *data, size_t data_size);
void sha1_finalize(struct sha1_context *ctx, DWORD hash[5]);
void sha1_finalize(struct sha1_context *ctx, unsigned int hash[5]);
#endif
......@@ -141,7 +141,7 @@ static char *format_parameterized_type_args(const type_t *type, const char *pref
return buf;
}
static void write_guid(FILE *f, const char *guid_prefix, const char *name, const UUID *uuid)
static void write_guid(FILE *f, const char *guid_prefix, const char *name, const uuid_t *uuid)
{
if (!uuid) return;
fprintf(f, "DEFINE_GUID(%s_%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
......@@ -151,7 +151,7 @@ static void write_guid(FILE *f, const char *guid_prefix, const char *name, const
uuid->Data4[6], uuid->Data4[7]);
}
static void write_uuid_decl(FILE *f, type_t *type, const UUID *uuid)
static void write_uuid_decl(FILE *f, type_t *type, const uuid_t *uuid)
{
fprintf(f, "#ifdef __CRT_UUID_DECL\n");
fprintf(f, "__CRT_UUID_DECL(%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
......@@ -162,7 +162,7 @@ static void write_uuid_decl(FILE *f, type_t *type, const UUID *uuid)
fprintf(f, "#endif\n");
}
static const char *uuid_string(const UUID *uuid)
static const char *uuid_string(const uuid_t *uuid)
{
static char buf[37];
......@@ -937,7 +937,7 @@ static void write_declaration(FILE *header, const var_t *v)
static void write_library(FILE *header, const typelib_t *typelib)
{
const UUID *uuid = get_attrp(typelib->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(typelib->attrs, ATTR_UUID);
fprintf(header, "\n");
write_guid(header, "LIBID", typelib->name, uuid);
fprintf(header, "\n");
......@@ -1680,7 +1680,7 @@ static void write_widl_using_method_macros(FILE *header, const type_t *iface, co
static void write_widl_using_macros(FILE *header, type_t *iface)
{
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(iface->attrs, ATTR_UUID);
const char *name = iface->short_name ? iface->short_name : iface->name;
char *macro;
......@@ -1702,7 +1702,7 @@ static void write_widl_using_macros(FILE *header, type_t *iface)
static void write_com_interface_end(FILE *header, type_t *iface)
{
int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE);
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(iface->attrs, ATTR_UUID);
expr_t *contract = get_attrp(iface->attrs, ATTR_CONTRACT);
type_t *type;
......@@ -1836,7 +1836,7 @@ static void write_rpc_interface_end(FILE *header, const type_t *iface)
static void write_coclass(FILE *header, type_t *cocl)
{
const UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(cocl->attrs, ATTR_UUID);
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s coclass\n", cocl->name);
......
......@@ -96,9 +96,9 @@ static unsigned int xstrtoul(const char *nptr, char **endptr, int base)
return val;
}
UUID *parse_uuid(const char *u)
uuid_t *parse_uuid(const char *u)
{
UUID* uuid = xmalloc(sizeof(UUID));
uuid_t* uuid = xmalloc(sizeof(*uuid));
char b[3];
/* it would be nice to use UuidFromStringA */
uuid->Data1 = strtoul(u, NULL, 16);
......
......@@ -50,7 +50,7 @@ static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t
enum storage_class stgclass, enum type_qualifier qual, enum function_specifier func_specifier);
static attr_t *make_attr(enum attr_type type);
static attr_t *make_attrv(enum attr_type type, unsigned int val);
static attr_t *make_custom_attr(UUID *id, expr_t *pval);
static attr_t *make_custom_attr(uuid_t *id, expr_t *pval);
static expr_list_t *append_expr(expr_list_t *list, expr_t *expr);
static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, declarator_t *decl, int top);
static var_list_t *set_var_types(attr_list_t *attrs, decl_spec_t *decl_spec, declarator_list_t *decls);
......@@ -141,7 +141,7 @@ static typelib_t *current_typelib;
typeref_t *typeref;
typeref_list_t *typeref_list;
char *str;
UUID *uuid;
uuid_t *uuid;
unsigned int num;
double dbl;
typelib_t *typelib;
......@@ -1523,7 +1523,7 @@ attr_t *make_attrp(enum attr_type type, void *val)
return a;
}
static attr_t *make_custom_attr(UUID *id, expr_t *pval)
static attr_t *make_custom_attr(uuid_t *id, expr_t *pval)
{
attr_t *a = xmalloc(sizeof(attr_t));
attr_custdata_t *cstdata = xmalloc(sizeof(attr_custdata_t));
......
......@@ -847,9 +847,9 @@ static int cmp_iid( const void *ptr1, const void *ptr2 )
{
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) );
const uuid_t *uuid1 = get_attrp( (*iface1)->attrs, ATTR_UUID );
const uuid_t *uuid2 = get_attrp( (*iface2)->attrs, ATTR_UUID );
return memcmp( uuid1, uuid2, sizeof(*uuid1) );
}
static void build_iface_list( const statement_list_t *stmts, type_t **ifaces[], int *count )
......
......@@ -34,7 +34,7 @@
static int indent;
static const char *format_uuid( const UUID *uuid )
static const char *format_uuid( const uuid_t *uuid )
{
static char buffer[40];
sprintf( buffer, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
......@@ -76,8 +76,8 @@ static const type_t *find_ps_factory( const statement_list_t *stmts )
static void write_interface( const type_t *iface, const type_t *ps_factory )
{
const UUID *uuid = get_attrp( iface->attrs, ATTR_UUID );
const UUID *ps_uuid = get_attrp( ps_factory->attrs, ATTR_UUID );
const uuid_t *uuid = get_attrp( iface->attrs, ATTR_UUID );
const uuid_t *ps_uuid = get_attrp( ps_factory->attrs, ATTR_UUID );
if (!uuid) return;
if (!is_object( iface )) return;
......@@ -109,8 +109,8 @@ static void write_interfaces( const statement_list_t *stmts, const type_t *ps_fa
static void write_typelib_interface( const type_t *iface, const typelib_t *typelib )
{
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
const UUID *uuid = get_attrp( iface->attrs, ATTR_UUID );
const uuid_t *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
const uuid_t *uuid = get_attrp( iface->attrs, ATTR_UUID );
unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION );
if (!uuid) return;
......@@ -139,7 +139,7 @@ static void write_typelib_interfaces( const typelib_t *typelib )
static int write_coclass( const type_t *class, const typelib_t *typelib )
{
const UUID *uuid = get_attrp( class->attrs, ATTR_UUID );
const uuid_t *uuid = get_attrp( class->attrs, ATTR_UUID );
const char *descr = get_attrp( class->attrs, ATTR_HELPSTRING );
const char *progid = get_attrp( class->attrs, ATTR_PROGID );
const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID );
......@@ -157,7 +157,7 @@ static int write_coclass( const type_t *class, const typelib_t *typelib )
if (progid) put_str( indent, "ProgId = s '%s'\n", progid );
if (typelib)
{
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
const uuid_t *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
put_str( indent, "TypeLib = s '%s'\n", format_uuid( typelib_uuid ));
if (!version) version = get_attrv( typelib->attrs, ATTR_VERSION );
}
......@@ -200,7 +200,7 @@ static void write_runtimeclasses_registry( const statement_list_t *stmts )
static int write_progid( const type_t *class )
{
const UUID *uuid = get_attrp( class->attrs, ATTR_UUID );
const uuid_t *uuid = get_attrp( class->attrs, ATTR_UUID );
const char *descr = get_attrp( class->attrs, ATTR_HELPSTRING );
const char *progid = get_attrp( class->attrs, ATTR_PROGID );
const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID );
......@@ -324,7 +324,7 @@ void write_typelib_regscript( const statement_list_t *stmts )
void output_typelib_regscript( const typelib_t *typelib )
{
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
const uuid_t *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
const char *descr = get_attrp( typelib->attrs, ATTR_HELPSTRING );
const expr_t *lcid_expr = get_attrp( typelib->attrs, ATTR_LIBLCID );
unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION );
......
......@@ -399,7 +399,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
static void write_serverinterfacedecl(type_t *iface)
{
unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
uuid_t *uuid = get_attrp(iface->attrs, ATTR_UUID);
const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT);
if (endpoints) write_endpoints( server, iface->name, endpoints );
......
......@@ -3506,7 +3506,7 @@ static unsigned int write_ip_tfs(FILE *file, const attr_list_t *attrs, type_t *t
else
{
const type_t *base = is_ptr(type) ? type_pointer_get_ref_type(type) : type;
const UUID *uuid = get_attrp(base->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(base->attrs, ATTR_UUID);
if (! uuid)
error("%s: interface %s missing UUID\n", __FUNCTION__, base->name);
......
......@@ -239,7 +239,7 @@ unsigned short get_type_vt(type_t *t)
return 0;
}
static void msft_read_guid(void *data, MSFT_SegDir *segdir, int offset, GUID *guid)
static void msft_read_guid(void *data, MSFT_SegDir *segdir, int offset, uuid_t *guid)
{
memcpy( guid, (char *)data + segdir->pGuidTab.offset + offset, sizeof(*guid) );
}
......
......@@ -160,7 +160,7 @@ static size_t append_var_list_signature(char **buf, size_t *len, size_t pos, var
static size_t append_type_signature(char **buf, size_t *len, size_t pos, type_t *type)
{
const GUID *uuid;
const uuid_t *uuid;
size_t n = 0;
if (!type) return 0;
......@@ -329,7 +329,7 @@ static char *format_parameterized_type_signature(type_t *type, typeref_list_t *p
size_t len = 0, pos = 0;
char *buf = NULL;
typeref_t *ref;
const GUID *uuid;
const uuid_t *uuid;
if (!(uuid = get_attrp(type->attrs, ATTR_UUID)))
error_loc_info(&type->loc_info, "cannot compute type signature, no uuid found for type %s.\n", type->name);
......@@ -1237,18 +1237,18 @@ static void compute_interface_signature_uuid(type_t *iface)
static const int version = 5;
struct sha1_context ctx;
unsigned char hash[20];
GUID *uuid;
uuid_t *uuid;
if (!(uuid = get_attrp(iface->attrs, ATTR_UUID)))
{
uuid = xmalloc(sizeof(GUID));
uuid = xmalloc(sizeof(*uuid));
iface->attrs = append_attr(iface->attrs, make_attrp(ATTR_UUID, uuid));
}
sha1_init(&ctx);
sha1_update(&ctx, winrt_pinterface_namespace, sizeof(winrt_pinterface_namespace));
sha1_update(&ctx, iface->signature, strlen(iface->signature));
sha1_finalize(&ctx, (ULONG *)hash);
sha1_finalize(&ctx, (unsigned int *)hash);
/* https://tools.ietf.org/html/rfc4122:
......@@ -1263,10 +1263,10 @@ static void compute_interface_signature_uuid(type_t *iface)
hash[6] = ((hash[6] & 0x0f) | (version << 4));
hash[8] = ((hash[8] & 0x3f) | 0x80);
uuid->Data1 = ((DWORD)hash[0] << 24)|((DWORD)hash[1] << 16)|((DWORD)hash[2] << 8)|(DWORD)hash[3];
uuid->Data2 = ((WORD)hash[4] << 8)|(WORD)hash[5];
uuid->Data3 = ((WORD)hash[6] << 8)|(WORD)hash[7];
memcpy(&uuid->Data4, hash + 8, sizeof(*uuid) - offsetof(GUID, Data4));
uuid->Data1 = ((unsigned int)hash[0] << 24) | ((unsigned int)hash[1] << 16) | ((unsigned int)hash[2] << 8) | hash[3];
uuid->Data2 = ((unsigned short)hash[4] << 8) | hash[5];
uuid->Data3 = ((unsigned short)hash[6] << 8) | hash[7];
memcpy(&uuid->Data4, hash + 8, sizeof(*uuid) - offsetof(uuid_t, Data4));
}
type_t *type_parameterized_type_specialize_define(type_t *type)
......
......@@ -35,7 +35,7 @@ size_t strappend(char **buf, size_t *len, size_t pos, const char* fmt, ...) __at
size_t widl_getline(char **linep, size_t *lenp, FILE *fp);
UUID *parse_uuid(const char *u);
uuid_t *parse_uuid(const char *u);
int is_valid_uuid(const char *s);
/* buffer management */
......
......@@ -382,7 +382,7 @@ void write_dlldata(const statement_list_t *stmts)
write_dlldata_list(filenames, define_proxy_delegation);
}
static void write_id_guid(FILE *f, const char *type, const char *guid_prefix, const char *name, const UUID *uuid)
static void write_id_guid(FILE *f, const char *type, const char *guid_prefix, const char *name, const uuid_t *uuid)
{
if (!uuid) return;
fprintf(f, "MIDL_DEFINE_GUID(%s, %s_%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
......@@ -402,7 +402,7 @@ static void write_id_data_stmts(const statement_list_t *stmts)
const type_t *type = stmt->u.type;
if (type_get_type(type) == TYPE_INTERFACE)
{
const UUID *uuid;
const uuid_t *uuid;
if (!is_object(type) && !is_attr(type->attrs, ATTR_DISPINTERFACE))
continue;
uuid = get_attrp(type->attrs, ATTR_UUID);
......@@ -416,13 +416,13 @@ static void write_id_data_stmts(const statement_list_t *stmts)
}
else if (type_get_type(type) == TYPE_COCLASS)
{
const UUID *uuid = get_attrp(type->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(type->attrs, ATTR_UUID);
write_id_guid(idfile, "CLSID", "CLSID", type->name, uuid);
}
}
else if (stmt->type == STMT_LIBRARY)
{
const UUID *uuid = get_attrp(stmt->u.lib->attrs, ATTR_UUID);
const uuid_t *uuid = get_attrp(stmt->u.lib->attrs, ATTR_UUID);
write_id_guid(idfile, "IID", "LIBID", stmt->u.lib->name, uuid);
write_id_data_stmts(stmt->u.lib->stmts);
}
......
......@@ -23,14 +23,16 @@
#include <stdarg.h>
#include <assert.h>
#include "guiddef.h"
#include "ndrtypes.h"
#include "wine/list.h"
#ifndef UUID_DEFINED
#define UUID_DEFINED
typedef GUID UUID;
#endif
typedef struct
{
unsigned int Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} uuid_t;
#define TRUE 1
#define FALSE 0
......@@ -357,7 +359,7 @@ struct _expr_t {
};
struct _attr_custdata_t {
GUID id;
uuid_t id;
expr_t *pval;
};
......@@ -562,7 +564,7 @@ struct _typelib_entry_t {
struct _importinfo_t {
int offset;
GUID guid;
uuid_t guid;
int flags;
int id;
......@@ -576,7 +578,7 @@ struct _importlib_t {
char *name;
int version;
GUID guid;
uuid_t guid;
importinfo_t *importinfos;
int ntypeinfos;
......
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