widl: Write serialize function declarations in header.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ed11765665
commit
dc03ca5e15
|
@ -287,6 +287,29 @@ static void write_function_stub( const type_t *iface, const var_t *func,
|
||||||
fprintf(client, "\n");
|
fprintf(client, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_serialize_function(FILE *file, const type_t *type, const type_t *iface,
|
||||||
|
const char *func_name, const char *ret_type)
|
||||||
|
{
|
||||||
|
/* FIXME: Assuming explicit handle */
|
||||||
|
|
||||||
|
fprintf(file, "%s __cdecl %s_%s(handle_t IDL_handle, %s *IDL_type)%s\n",
|
||||||
|
ret_type ? ret_type : "void", type->name, func_name, type->name, iface ? "" : ";");
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_serialize_functions(FILE *file, const type_t *type, const type_t *iface)
|
||||||
|
{
|
||||||
|
if (is_attr(type->attrs, ATTR_ENCODE))
|
||||||
|
{
|
||||||
|
write_serialize_function(file, type, iface, "AlignSize", "SIZE_T");
|
||||||
|
write_serialize_function(file, type, iface, "Encode", NULL);
|
||||||
|
}
|
||||||
|
if (is_attr(type->attrs, ATTR_DECODE))
|
||||||
|
{
|
||||||
|
write_serialize_function(file, type, iface, "Decode", NULL);
|
||||||
|
write_serialize_function(file, type, iface, "Free", NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||||
{
|
{
|
||||||
const statement_t *stmt;
|
const statement_t *stmt;
|
||||||
|
|
|
@ -716,6 +716,47 @@ void check_for_additional_prototype_types(const var_list_t *list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int write_serialize_function_decl(FILE *header, const type_t *type)
|
||||||
|
{
|
||||||
|
write_serialize_functions(header, type, NULL);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int serializable_exists(FILE *header, const type_t *type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int for_each_serializable(const statement_list_t *stmts, FILE *header,
|
||||||
|
int (*proc)(FILE*, const type_t*))
|
||||||
|
{
|
||||||
|
statement_t *stmt, *iface_stmt;
|
||||||
|
statement_list_t *iface_stmts;
|
||||||
|
const type_list_t *type_entry;
|
||||||
|
|
||||||
|
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry )
|
||||||
|
{
|
||||||
|
if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
iface_stmts = type_iface_get_stmts(stmt->u.type);
|
||||||
|
if (iface_stmts) LIST_FOR_EACH_ENTRY( iface_stmt, iface_stmts, statement_t, entry )
|
||||||
|
{
|
||||||
|
if (iface_stmt->type != STMT_TYPEDEF) continue;
|
||||||
|
for (type_entry = iface_stmt->u.type_list; type_entry; type_entry = type_entry->next)
|
||||||
|
{
|
||||||
|
if (!is_attr(type_entry->type->attrs, ATTR_ENCODE)
|
||||||
|
&& !is_attr(type_entry->type->attrs, ATTR_DECODE))
|
||||||
|
continue;
|
||||||
|
if (!proc(header, type_entry->type))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void write_user_types(FILE *header)
|
static void write_user_types(FILE *header)
|
||||||
{
|
{
|
||||||
user_type_t *ut;
|
user_type_t *ut;
|
||||||
|
@ -1748,7 +1789,10 @@ void write_header(const statement_list_t *stmts)
|
||||||
fprintf(header, "#endif\n\n");
|
fprintf(header, "#endif\n\n");
|
||||||
|
|
||||||
fprintf(header, "#include <rpc.h>\n" );
|
fprintf(header, "#include <rpc.h>\n" );
|
||||||
fprintf(header, "#include <rpcndr.h>\n\n" );
|
fprintf(header, "#include <rpcndr.h>\n" );
|
||||||
|
if (!for_each_serializable(stmts, NULL, serializable_exists))
|
||||||
|
fprintf(header, "#include <midles.h>\n" );
|
||||||
|
fprintf(header, "\n" );
|
||||||
|
|
||||||
fprintf(header, "#ifndef COM_NO_WINDOWS_H\n");
|
fprintf(header, "#ifndef COM_NO_WINDOWS_H\n");
|
||||||
fprintf(header, "#include <windows.h>\n");
|
fprintf(header, "#include <windows.h>\n");
|
||||||
|
@ -1770,6 +1814,7 @@ void write_header(const statement_list_t *stmts)
|
||||||
|
|
||||||
fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
|
fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
|
||||||
fprintf(header, "\n");
|
fprintf(header, "\n");
|
||||||
|
for_each_serializable(stmts, header, write_serialize_function_decl);
|
||||||
write_user_types(header);
|
write_user_types(header);
|
||||||
write_generic_handle_routines(header);
|
write_generic_handle_routines(header);
|
||||||
write_context_handle_rundowns(header);
|
write_context_handle_rundowns(header);
|
||||||
|
|
|
@ -54,6 +54,8 @@ extern const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
|
||||||
extern int has_out_arg_or_return(const var_t *func);
|
extern int has_out_arg_or_return(const var_t *func);
|
||||||
extern int is_const_decl(const var_t *var);
|
extern int is_const_decl(const var_t *var);
|
||||||
|
|
||||||
|
extern void write_serialize_functions(FILE *file, const type_t *type, const type_t *iface);
|
||||||
|
|
||||||
static inline int is_ptr(const type_t *t)
|
static inline int is_ptr(const type_t *t)
|
||||||
{
|
{
|
||||||
return type_get_type(t) == TYPE_POINTER;
|
return type_get_type(t) == TYPE_POINTER;
|
||||||
|
|
Loading…
Reference in New Issue