- Added creation of dispinterface header.

- Added creation of coclass header.
- Added messages when fopen fails.
oldstable
Jacek Caban 2004-10-11 19:54:37 +00:00 committed by Alexandre Julliard
parent b741905cf1
commit 2161b36ac4
6 changed files with 89 additions and 11 deletions

View File

@ -596,6 +596,11 @@ static void write_c_method_def(type_t *iface)
do_write_c_method_def(iface, iface->name);
}
static void write_c_disp_method_def(type_t *iface)
{
do_write_c_method_def(iface->ref, iface->name);
}
static void write_method_proto(type_t *iface)
{
func_t *cur = iface->funcs;
@ -686,13 +691,30 @@ void write_forward(type_t *iface)
}
}
void write_guid(type_t *iface)
void write_guid(const char *guid_prefix, const char *name, UUID *uuid)
{
if (!uuid) return;
fprintf(header, "DEFINE_GUID(%s_%s, 0x%08lx, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x);\n",
guid_prefix, name, uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
}
void write_iface_guid(type_t *iface)
{
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
if (!uuid) return;
fprintf(header, "DEFINE_GUID(IID_%s, 0x%08lx, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x);\n",
iface->name, uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
write_guid("IID", iface->name, uuid);
}
void write_dispiface_guid(type_t *iface)
{
UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
write_guid("DIID", iface->name, uuid);
}
void write_coclass_guid(class_t *cocl)
{
UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
write_guid("CLSID", cocl->name, uuid);
}
void write_com_interface(type_t *iface)
@ -707,7 +729,7 @@ void write_com_interface(type_t *iface)
fprintf(header, " */\n");
fprintf(header,"#ifndef __%s_INTERFACE_DEFINED__\n", iface->name);
fprintf(header,"#define __%s_INTERFACE_DEFINED__\n\n", iface->name);
write_guid(iface);
write_iface_guid(iface);
write_forward(iface);
/* C++ interface */
fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n");
@ -766,7 +788,7 @@ void write_rpc_interface(type_t *iface)
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s interface (v%d.%d)\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, " */\n");
write_guid(iface);
write_iface_guid(iface);
fprintf(header, "extern RPC_IF_HANDLE %s_v%d_%d_c_ifspec;\n", iface->name, LOWORD(ver), HIWORD(ver));
fprintf(header, "extern RPC_IF_HANDLE %s_v%d_%d_s_ifspec;\n", iface->name, LOWORD(ver), HIWORD(ver));
write_function_proto(iface);
@ -782,3 +804,50 @@ void write_interface(type_t *iface)
else
write_rpc_interface(iface);
}
void write_dispinterface(type_t *iface)
{
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s dispinterface\n", iface->name);
fprintf(header, " */\n");
fprintf(header,"#ifndef __%s_DISPINTERFACE_DEFINED__\n", iface->name);
fprintf(header,"#define __%s_DISPINTERFACE_DEFINED__\n\n", iface->name);
write_dispiface_guid(iface);
write_forward(iface);
/* C++ interface */
fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n");
fprintf(header, "struct %s : public %s\n", iface->name, iface->ref->name);
fprintf(header, "{\n");
fprintf(header, "};\n");
fprintf(header, "#else\n");
/* C interface */
fprintf(header, "typedef struct %sVtbl %sVtbl;\n", iface->name, iface->name);
fprintf(header, "struct %s {\n", iface->name);
fprintf(header, " const %sVtbl* lpVtbl;\n", iface->name);
fprintf(header, "};\n");
fprintf(header, "struct %sVtbl {\n", iface->name);
indentation++;
fprintf(header, " BEGIN_INTERFACE\n");
fprintf(header, "\n");
write_c_disp_method_def(iface);
indentation--;
fprintf(header, " END_INTERFACE\n");
fprintf(header, "};\n");
fprintf(header, "\n");
fprintf(header, "#ifdef COBJMACROS\n");
write_method_macro(iface->ref, iface->name);
fprintf(header, "#endif\n");
fprintf(header, "\n");
fprintf(header, "#endif\n");
fprintf(header, "\n");
fprintf(header,"#endif /* __%s_DISPINTERFACE_DEFINED__ */\n\n", iface->name);
}
void write_coclass(class_t *cocl)
{
fprintf(header, "/*****************************************************************************\n");
fprintf(header, " * %s coclass\n", cocl->name);
fprintf(header, " */\n\n");
write_coclass_guid(cocl);
fprintf(header, "\n");
}

View File

@ -34,6 +34,8 @@ extern var_t *is_callas(attr_t *a);
extern void write_args(FILE *h, var_t *arg, char *name, int obj, int do_indent);
extern void write_forward(type_t *iface);
extern void write_interface(type_t *iface);
extern void write_dispinterface(type_t *iface);
extern void write_coclass(class_t *iface);
extern void write_typedef(type_t *type, var_t *names);
extern void write_expr(FILE *h, expr_t *e);
extern void write_constdef(var_t *v);

View File

@ -571,6 +571,7 @@ coclass: tCOCLASS aIDENTIFIER { $$ = make_class($2); }
coclasshdr: attributes coclass { $$ = $2;
$$->attrs = $1;
if (!parse_only) write_coclass($$);
}
;
@ -617,7 +618,7 @@ dispinterfacedef: dispinterfacehdr '{'
'}' { $$ = $1;
$$->fields = $3;
$$->funcs = $4;
if (!parse_only) write_interface($$);
if (!parse_only) write_dispinterface($$);
}
/* FIXME: not sure how to handle this yet
| dispinterfacehdr '{' interface '}' { $$ = $1;

View File

@ -144,7 +144,8 @@ static void write_formatstring( int proc )
static void init_proxy()
{
if (proxy) return;
proxy = fopen(proxy_name, "w");
if(!(proxy = fopen(proxy_name, "w")))
error("Could not open %s for output\n", proxy_name);
print_proxy( "/*** Autogenerated by WIDL %s - Do not edit ***/\n", WIDL_FULLVERSION);
print_proxy( "\n");
print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
@ -956,6 +957,7 @@ void write_proxies(ifref_t *ifaces)
END_OF_LIST(lcur);
init_proxy();
if(!proxy) return;
cur = lcur;
while (cur) {

View File

@ -219,7 +219,8 @@ void start_typelib(char *name, attr_t *attrs)
{
in_typelib++;
if (!do_everything && !typelib_only) return;
typelib = fopen(typelib_name, "wb");
if(!(typelib = fopen(typelib_name, "wb")))
error("Could not open %s for output\n", typelib_name);
}
void end_typelib(void)

View File

@ -249,7 +249,10 @@ int main(int argc,char *argv[])
header_token = make_token(header_name);
header = fopen(header_name, "w");
if(!(header = fopen(header_name, "w"))) {
fprintf(stderr, "Could not open %s for output\n", header_name);
return 1;
}
fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", WIDL_FULLVERSION, input_name);
fprintf(header, "#include <rpc.h>\n" );
fprintf(header, "#include <rpcndr.h>\n\n" );