widl: Added an extension that uses inline functions instead of macros for C interface calls.
This commit is contained in:
parent
b06e8103f7
commit
6b34eea6fc
|
@ -902,6 +902,43 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
|
|||
}
|
||||
}
|
||||
|
||||
static void write_inline_wrappers(FILE *header, const type_t *iface, const char *name)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
int first_iface = 1;
|
||||
|
||||
if (type_iface_get_inherit(iface))
|
||||
write_inline_wrappers(header, type_iface_get_inherit(iface), name);
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
|
||||
{
|
||||
const var_t *func = stmt->u.var;
|
||||
|
||||
if (first_iface)
|
||||
{
|
||||
fprintf(header, "/*** %s methods ***/\n", iface->name);
|
||||
first_iface = 0;
|
||||
}
|
||||
|
||||
if (!is_callas(func->attrs)) {
|
||||
const var_t *arg;
|
||||
|
||||
fprintf(header, "static FORCEINLINE ");
|
||||
write_type_decl_left(header, type_function_get_rettype(func->type));
|
||||
fprintf(header, " %s_%s(", name, get_name(func));
|
||||
write_args(header, type_get_function_args(func->type), name, 1, FALSE);
|
||||
fprintf(header, ") {\n");
|
||||
fprintf(header, " %s", is_void(type_function_get_rettype(func->type)) ? "" : "return ");
|
||||
fprintf(header, "This->lpVtbl->%s(This", get_name(func));
|
||||
if (type_get_function_args(func->type))
|
||||
LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry )
|
||||
fprintf(header, ",%s", arg->name);
|
||||
fprintf(header, ");\n");
|
||||
fprintf(header, "}\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void do_write_c_method_def(FILE *header, const type_t *iface, const char *name)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
@ -1150,7 +1187,11 @@ static void write_com_interface_end(FILE *header, type_t *iface)
|
|||
fprintf(header, "#ifdef COBJMACROS\n");
|
||||
/* dispinterfaces don't have real functions, so don't write macros for them,
|
||||
* only for the interface this interface inherits from, i.e. IDispatch */
|
||||
fprintf(header, "#ifndef WIDL_C_INLINE_WRAPPERS\n");
|
||||
write_method_macro(header, dispinterface ? type_iface_get_inherit(iface) : iface, iface->name);
|
||||
fprintf(header, "#else\n");
|
||||
write_inline_wrappers(header, dispinterface ? type_iface_get_inherit(iface) : iface, iface->name);
|
||||
fprintf(header, "#endif\n");
|
||||
fprintf(header, "#endif\n");
|
||||
fprintf(header, "\n");
|
||||
fprintf(header, "#endif\n");
|
||||
|
|
Loading…
Reference in New Issue