Commit e71219e6 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Add the parsing of storage classes into declaration-specifiers.

Support the static and register keywords. This consolidates externdef and constdef rules into one declaration rule.
parent d64e4c26
......@@ -477,18 +477,49 @@ void write_typedef(type_t *type)
fprintf(header, ";\n");
}
void write_constdef(const var_t *v)
int is_const_decl(const var_t *var)
{
fprintf(header, "#define %s (", v->name);
write_expr(header, v->eval, 0, 1, NULL, NULL);
fprintf(header, ")\n\n");
const type_t *t;
/* strangely, MIDL accepts a const attribute on any pointer in the
* declaration to mean that data isn't being instantiated. this appears
* to be a bug, but there is no benefit to being incompatible with MIDL,
* so we'll do the same thing */
for (t = var->type; ; )
{
if (is_attr(t->attrs, ATTR_CONST))
return TRUE;
else if (is_ptr(t))
t = t->ref;
else break;
}
return FALSE;
}
void write_externdef(const var_t *v)
void write_declaration(const var_t *v, int is_in_interface)
{
fprintf(header, "extern const ");
write_type_def_or_decl(header, v->type, FALSE, "%s", v->name);
fprintf(header, ";\n\n");
if (is_const_decl(v) && v->eval)
{
fprintf(header, "#define %s (", v->name);
write_expr(header, v->eval, 0, 1, NULL, NULL);
fprintf(header, ")\n\n");
}
else if (v->type->type != RPC_FC_FUNCTION || !is_in_interface)
{
switch (v->stgclass)
{
case STG_NONE:
case STG_REGISTER: /* ignored */
break;
case STG_STATIC:
fprintf(header, "static ");
break;
case STG_EXTERN:
fprintf(header, "extern ");
break;
}
write_type_def_or_decl(header, v->type, FALSE, "%s", v->name);
fprintf(header, ";\n\n");
}
}
void write_library(const typelib_t *typelib)
......
......@@ -57,8 +57,7 @@ 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_constdef(const var_t *v);
extern void write_externdef(const var_t *v);
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);
......@@ -70,6 +69,7 @@ extern const var_t* get_context_handle_var(const func_t* func);
extern int has_out_arg_or_return(const func_t *func);
extern void write_guid(FILE *f, const char *guid_prefix, const char *name,
const UUID *uuid);
extern int is_const_decl(const var_t *var);
static inline int last_ptr(const type_t *type)
{
......
......@@ -239,10 +239,12 @@ static const struct keyword keywords[] = {
{"module", tMODULE},
{"pascal", tPASCAL},
{"properties", tPROPERTIES},
{"register", tREGISTER},
{"short", tSHORT},
{"signed", tSIGNED},
{"sizeof", tSIZEOF},
{"small", tSMALL},
{"static", tSTATIC},
{"stdcall", tSTDCALL},
{"struct", tSTRUCT},
{"switch", tSWITCH},
......
......@@ -209,8 +209,7 @@ enum storage_class
enum statement_type
{
STMT_LIBRARY,
STMT_INITDECL,
STMT_EXTERN,
STMT_DECLARATION,
STMT_TYPE,
STMT_TYPEREF,
STMT_MODULE,
......
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