ReactOS 0.4.16-dev-338-g34e76ad
header.c File Reference
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
#include "expr.h"
#include "typetree.h"
#include "typelib.h"
Include dependency graph for header.c:

Go to the source code of this file.

Functions

static void write_type_def_or_decl (FILE *f, type_t *t, int field, const char *name)
 
static void indent (FILE *h, int delta)
 
static void write_line (FILE *f, int delta, const char *fmt,...)
 
int is_ptrchain_attr (const var_t *var, enum attr_type t)
 
int is_aliaschain_attr (const type_t *type, enum attr_type attr)
 
int is_attr (const attr_list_t *list, enum attr_type t)
 
voidget_attrp (const attr_list_t *list, enum attr_type t)
 
unsigned int get_attrv (const attr_list_t *list, enum attr_type t)
 
static void write_guid (FILE *f, const char *guid_prefix, const char *name, const UUID *uuid)
 
static void write_uuid_decl (FILE *f, type_t *type, const UUID *uuid)
 
static const charuuid_string (const UUID *uuid)
 
static void write_namespace_start (FILE *header, struct namespace *namespace)
 
static void write_namespace_end (FILE *header, struct namespace *namespace)
 
const charget_name (const var_t *v)
 
static void write_fields (FILE *h, var_list_t *fields)
 
static void write_enums (FILE *h, var_list_t *enums, const char *enum_name)
 
int needs_space_after (type_t *t)
 
static void write_pointer_left (FILE *h, type_t *ref)
 
void write_type_left (FILE *h, type_t *t, enum name_type name_type, int declonly)
 
void write_type_right (FILE *h, type_t *t, int is_field)
 
static void write_type_v (FILE *h, type_t *t, int is_field, int declonly, const char *name)
 
static void write_type_definition (FILE *f, type_t *t)
 
void write_type_decl (FILE *f, type_t *t, const char *name)
 
void write_type_decl_left (FILE *f, type_t *t)
 
static int user_type_registered (const char *name)
 
static int context_handle_registered (const char *name)
 
static int generic_handle_registered (const char *name)
 
unsigned int get_context_handle_offset (const type_t *type)
 
unsigned int get_generic_handle_offset (const type_t *type)
 
void check_for_additional_prototype_types (const var_list_t *list)
 
static int write_serialize_function_decl (FILE *header, const type_t *type)
 
static int serializable_exists (FILE *header, const type_t *type)
 
static int for_each_serializable (const statement_list_t *stmts, FILE *header, int(*proc)(FILE *, const type_t *))
 
static void write_user_types (FILE *header)
 
static void write_context_handle_rundowns (FILE *header)
 
static void write_generic_handle_routines (FILE *header)
 
static void write_typedef (FILE *header, type_t *type)
 
int is_const_decl (const var_t *var)
 
static void write_declaration (FILE *header, const var_t *v)
 
static void write_library (FILE *header, const typelib_t *typelib)
 
const type_tget_explicit_generic_handle_type (const var_t *var)
 
const var_tget_func_handle_var (const type_t *iface, const var_t *func, unsigned char *explicit_fc, unsigned char *implicit_fc)
 
int has_out_arg_or_return (const var_t *func)
 
int is_object (const type_t *iface)
 
int is_local (const attr_list_t *a)
 
const var_tis_callas (const attr_list_t *a)
 
static int is_inherited_method (const type_t *iface, const var_t *func)
 
static int is_override_method (const type_t *iface, const type_t *child, const var_t *func)
 
static int is_aggregate_return (const var_t *func)
 
static charget_vtbl_entry_name (const type_t *iface, const var_t *func)
 
static void write_method_macro (FILE *header, const type_t *iface, const type_t *child, const char *name)
 
void write_args (FILE *h, const var_list_t *args, const char *name, int method, int do_indent)
 
static void write_cpp_method_def (FILE *header, const type_t *iface)
 
static void write_inline_wrappers (FILE *header, const type_t *iface, const type_t *child, const char *name)
 
static void do_write_c_method_def (FILE *header, const type_t *iface, const char *name)
 
static void write_c_method_def (FILE *header, const type_t *iface)
 
static void write_c_disp_method_def (FILE *header, const type_t *iface)
 
static void write_method_proto (FILE *header, const type_t *iface)
 
static void write_locals (FILE *fp, const type_t *iface, int body)
 
static void write_local_stubs_stmts (FILE *local_stubs, const statement_list_t *stmts)
 
void write_local_stubs (const statement_list_t *stmts)
 
static void write_function_proto (FILE *header, const type_t *iface, const var_t *fun, const char *prefix)
 
static void write_forward (FILE *header, type_t *iface)
 
static void write_com_interface_start (FILE *header, const type_t *iface)
 
static void write_com_interface_end (FILE *header, type_t *iface)
 
static void write_rpc_interface_start (FILE *header, const type_t *iface)
 
static void write_rpc_interface_end (FILE *header, const type_t *iface)
 
static void write_coclass (FILE *header, type_t *cocl)
 
static void write_coclass_forward (FILE *header, type_t *cocl)
 
static void write_import (FILE *header, const char *fname)
 
static void write_imports (FILE *header, const statement_list_t *stmts)
 
static void write_forward_decls (FILE *header, const statement_list_t *stmts)
 
static void write_header_stmts (FILE *header, const statement_list_t *stmts, const type_t *iface, int ignore_funcs)
 
void write_header (const statement_list_t *stmts)
 

Variables

static int indentation = 0
 
static int is_object_interface = 0
 
user_type_list_t user_type_list = LIST_INIT(user_type_list)
 
context_handle_list_t context_handle_list = LIST_INIT(context_handle_list)
 
generic_handle_list_t generic_handle_list = LIST_INIT(generic_handle_list)
 

Function Documentation

◆ check_for_additional_prototype_types()

void check_for_additional_prototype_types ( const var_list_t list)

Definition at line 640 of file header.c.

641{
642 const var_t *v;
643
644 if (!list) return;
646 {
647 type_t *type = v->type;
648 if (!type) continue;
649 for (;;) {
650 const char *name = type->name;
651 if (type->user_types_registered) break;
652 type->user_types_registered = 1;
653 if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) {
655 {
656 context_handle_t *ch = xmalloc(sizeof(*ch));
657 ch->name = xstrdup(name);
659 }
660 /* don't carry on parsing fields within this type */
661 break;
662 }
663 if ((type_get_type(type) != TYPE_BASIC ||
665 is_attr(type->attrs, ATTR_HANDLE)) {
667 {
668 generic_handle_t *gh = xmalloc(sizeof(*gh));
669 gh->name = xstrdup(name);
671 }
672 /* don't carry on parsing fields within this type */
673 break;
674 }
675 if (is_attr(type->attrs, ATTR_WIREMARSHAL)) {
677 {
678 user_type_t *ut = xmalloc(sizeof *ut);
679 ut->name = xstrdup(name);
681 }
682 /* don't carry on parsing fields within this type as we are already
683 * using a wire marshaled type */
684 break;
685 }
686 else if (type_is_complete(type))
687 {
688 var_list_t *vars;
690 {
691 case TYPE_ENUM:
693 break;
694 case TYPE_STRUCT:
696 break;
697 case TYPE_UNION:
699 break;
700 default:
701 vars = NULL;
702 break;
703 }
705 }
706
707 if (type_is_alias(type))
709 else if (is_ptr(type))
711 else if (is_array(type))
713 else
714 break;
715 }
716 }
717}
char * xstrdup(const char *s)
Definition: uimain.c:768
void * xmalloc(int size)
Definition: uimain.c:747
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
Definition: list.h:37
#define NULL
Definition: types.h:112
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static int is_ptr(const type_t *t)
Definition: header.h:59
static int is_array(const type_t *t)
Definition: header.h:64
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static int generic_handle_registered(const char *name)
Definition: header.c:589
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99
static int user_type_registered(const char *name)
Definition: header.c:571
static int context_handle_registered(const char *name)
Definition: header.c:580
generic_handle_list_t generic_handle_list
Definition: header.c:44
void check_for_additional_prototype_types(const var_list_t *list)
Definition: header.c:640
user_type_list_t user_type_list
Definition: header.c:42
struct list entry
Definition: widltypes.h:522
const char * name
Definition: widltypes.h:523
Definition: name.c:39
WCHAR * name
Definition: name.c:42
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
static var_list_t * type_union_get_cases(const type_t *type)
Definition: typetree.h:134
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
static type_t * type_alias_get_aliasee(const type_t *type)
Definition: typetree.h:279
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:87
static int type_is_complete(const type_t *type)
Definition: typetree.h:191
static int type_is_alias(const type_t *type)
Definition: typetree.h:274
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
static var_list_t * type_enum_get_values(const type_t *type)
Definition: typetree.h:113
@ TYPE_ENUM
Definition: widltypes.h:404
@ TYPE_BASIC
Definition: widltypes.h:403
@ TYPE_UNION
Definition: widltypes.h:407
@ TYPE_STRUCT
Definition: widltypes.h:405
@ ATTR_CONTEXTHANDLE
Definition: widltypes.h:85
@ ATTR_HANDLE
Definition: widltypes.h:105
@ ATTR_WIREMARSHAL
Definition: widltypes.h:171
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:590
@ TYPE_BASIC_HANDLE
Definition: widltypes.h:277

Referenced by check_for_additional_prototype_types().

◆ context_handle_registered()

static int context_handle_registered ( const char name)
static

Definition at line 580 of file header.c.

581{
584 if (!strcmp(name, ch->name))
585 return 1;
586 return 0;
587}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by check_for_additional_prototype_types().

◆ do_write_c_method_def()

static void do_write_c_method_def ( FILE header,
const type_t iface,
const char name 
)
static

Definition at line 1240 of file header.c.

1241{
1242 const statement_t *stmt;
1243 int first_iface = 1;
1244
1245 if (type_iface_get_inherit(iface))
1247#ifdef __REACTOS__ /* r59312 / 3ab1571 */
1248 else if (type_iface_get_stmts(iface) == NULL)
1249 {
1250 fprintf(header, "#ifndef __cplusplus\n");
1251 indent(header, 0);
1252 fprintf(header, "char dummy;\n");
1253 fprintf(header, "#endif\n");
1254 fprintf(header, "\n");
1255 return;
1256 }
1257#endif
1258
1260 {
1261 const var_t *func = stmt->u.var;
1262 if (first_iface) {
1263 indent(header, 0);
1264 fprintf(header, "/*** %s methods ***/\n", iface->name);
1265 first_iface = 0;
1266 }
1267 if (!is_callas(func->attrs)) {
1268 const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
1269 if (!callconv) callconv = "STDMETHODCALLTYPE";
1270 indent(header, 0);
1273 fprintf(header, " *");
1274 if (is_inherited_method(iface, func))
1275 fprintf(header, " (%s *%s_%s)(\n", callconv, iface->name, func->name);
1276 else
1277 fprintf(header, " (%s *%s)(\n", callconv, get_name(func));
1278 ++indentation;
1279 indent(header, 0);
1280 fprintf(header, "%s *This", name);
1282 fprintf(header, ",\n");
1283 indent(header, 0);
1285 fprintf(header, " *__ret");
1286 }
1287 --indentation;
1288 if (type_get_function_args(func->type)) {
1289 fprintf(header, ",\n");
1291 }
1292 fprintf(header, ");\n");
1293 fprintf(header, "\n");
1294 }
1295 }
1296}
#define TRUE
Definition: types.h:120
static const WCHAR indent[]
Definition: object.c:1156
GLenum func
Definition: glext.h:6028
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static int indentation
Definition: header.c:40
static void do_write_c_method_def(FILE *header, const type_t *iface, const char *name)
Definition: header.c:1240
static int is_aggregate_return(const var_t *func)
Definition: header.c:996
void write_args(FILE *h, const var_list_t *args, const char *name, int method, int do_indent)
Definition: header.c:1058
void write_type_decl_left(FILE *f, type_t *t)
Definition: header.c:566
const var_t * is_callas(const attr_list_t *a)
Definition: header.c:943
static int is_inherited_method(const type_t *iface, const var_t *func)
Definition: header.c:948
const char * get_name(const var_t *v)
Definition: header.c:181
void * get_attrp(const attr_list_t *list, enum attr_type t)
Definition: header.c:107
union _statement_t::@5031 u
var_t * var
Definition: widltypes.h:539
const char * name
Definition: widltypes.h:419
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:108
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:158
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151
@ ATTR_CALLCONV
Definition: widltypes.h:80
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:585
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:597

Referenced by do_write_c_method_def(), write_c_disp_method_def(), and write_c_method_def().

◆ for_each_serializable()

static int for_each_serializable ( const statement_list_t stmts,
FILE header,
int(*)(FILE *, const type_t *)  proc 
)
static

Definition at line 730 of file header.c.

732{
733 statement_t *stmt, *iface_stmt;
734 statement_list_t *iface_stmts;
735 const type_list_t *type_entry;
736
737 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry )
738 {
739 if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
740 continue;
741
742 iface_stmts = type_iface_get_stmts(stmt->u.type);
743 if (iface_stmts) LIST_FOR_EACH_ENTRY( iface_stmt, iface_stmts, statement_t, entry )
744 {
745 if (iface_stmt->type != STMT_TYPEDEF) continue;
746 for (type_entry = iface_stmt->u.type_list; type_entry; type_entry = type_entry->next)
747 {
748 if (!is_attr(type_entry->type->attrs, ATTR_ENCODE)
749 && !is_attr(type_entry->type->attrs, ATTR_DECODE))
750 continue;
751 if (!proc(header, type_entry->type))
752 return 0;
753 }
754 }
755 }
756
757 return 1;
758}
static HANDLE proc()
Definition: pdb.c:34
statement_type_t type
Definition: parser.h:124
type_list_t * type_list
Definition: widltypes.h:541
struct _type_list_t * next
Definition: widltypes.h:528
type_t * type
Definition: widltypes.h:527
attr_list_t * attrs
Definition: widltypes.h:422
@ TYPE_INTERFACE
Definition: widltypes.h:412
@ ATTR_DECODE
Definition: widltypes.h:87
@ ATTR_ENCODE
Definition: widltypes.h:99
@ STMT_TYPE
Definition: widltypes.h:242
@ STMT_TYPEDEF
Definition: widltypes.h:245

Referenced by write_header().

◆ generic_handle_registered()

static int generic_handle_registered ( const char name)
static

Definition at line 589 of file header.c.

590{
593 if (!strcmp(name, gh->name))
594 return 1;
595 return 0;
596}

Referenced by check_for_additional_prototype_types().

◆ get_attrp()

◆ get_attrv()

◆ get_context_handle_offset()

unsigned int get_context_handle_offset ( const type_t type)

Definition at line 598 of file header.c.

599{
601 unsigned int index = 0;
602
603 while (!is_attr( type->attrs, ATTR_CONTEXTHANDLE ))
604 {
606 else if (is_ptr( type )) type = type_pointer_get_ref( type );
607 else error( "internal error: %s is not a context handle\n", type->name );
608 }
610 {
611 if (!strcmp( type->name, ch->name )) return index;
612 index++;
613 }
614 error( "internal error: %s is not registered as a context handle\n", type->name );
615 return index;
616}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
#define error(str)
Definition: mkdosfs.c:1605

Referenced by write_contexthandle_tfs(), and write_proc_func_header().

◆ get_explicit_generic_handle_type()

const type_t * get_explicit_generic_handle_type ( const var_t var)

Definition at line 855 of file header.c.

856{
857 const type_t *t;
858 for (t = var->type;
859 is_ptr(t) || type_is_alias(t);
862 is_attr(t->attrs, ATTR_HANDLE))
863 return t;
864 return NULL;
865}
return
Definition: dirsup.c:529
if(dx< 0)
Definition: linetemp.h:194
const char * var
Definition: shader.c:5666

Referenced by get_func_handle_var(), and write_function_stub().

◆ get_func_handle_var()

const var_t * get_func_handle_var ( const type_t iface,
const var_t func,
unsigned char explicit_fc,
unsigned char implicit_fc 
)

Definition at line 867 of file header.c.

869{
870 const var_t *var;
871 const var_list_t *args = type_get_function_args( func->type );
872
873 *explicit_fc = *implicit_fc = 0;
874 if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
875 {
876 if (!is_attr( var->attrs, ATTR_IN ) && is_attr( var->attrs, ATTR_OUT )) continue;
878 {
879 *explicit_fc = FC_BIND_PRIMITIVE;
880 return var;
881 }
883 {
884 *explicit_fc = FC_BIND_GENERIC;
885 return var;
886 }
887 if (is_context_handle( var->type ))
888 {
889 *explicit_fc = FC_BIND_CONTEXT;
890 return var;
891 }
892 }
893
894 if ((var = get_attrp( iface->attrs, ATTR_IMPLICIT_HANDLE )))
895 {
896 if (type_get_type( var->type ) == TYPE_BASIC &&
898 *implicit_fc = FC_BIND_PRIMITIVE;
899 else
900 *implicit_fc = FC_BIND_GENERIC;
901 return var;
902 }
903
904 *implicit_fc = FC_AUTO_HANDLE;
905 return NULL;
906}
static int is_context_handle(const type_t *type)
Definition: header.h:100
@ FC_BIND_PRIMITIVE
Definition: ndrtypes.h:194
@ FC_BIND_GENERIC
Definition: ndrtypes.h:193
@ FC_AUTO_HANDLE
Definition: ndrtypes.h:195
@ FC_BIND_CONTEXT
Definition: ndrtypes.h:191
const type_t * get_explicit_generic_handle_type(const var_t *var)
Definition: header.c:855
Definition: match.c:390
@ ATTR_IN
Definition: widltypes.h:118
@ ATTR_IMPLICIT_HANDLE
Definition: widltypes.h:117
@ ATTR_OUT
Definition: widltypes.h:138

Referenced by write_function_stub(), write_proc_func_header(), and write_procformatstring_func().

◆ get_generic_handle_offset()

unsigned int get_generic_handle_offset ( const type_t type)

Definition at line 618 of file header.c.

619{
621 unsigned int index = 0;
622
623 while (!is_attr( type->attrs, ATTR_HANDLE ))
624 {
626 else if (is_ptr( type )) type = type_pointer_get_ref( type );
627 else error( "internal error: %s is not a generic handle\n", type->name );
628 }
630 {
631 if (!strcmp( type->name, gh->name )) return index;
632 index++;
633 }
634 error( "internal error: %s is not registered as a generic handle\n", type->name );
635 return index;
636}

Referenced by write_proc_func_header().

◆ get_name()

const char * get_name ( const var_t v)

Definition at line 181 of file header.c.

182{
183 static char buffer[256];
184
185 if (is_attr( v->attrs, ATTR_PROPGET ))
186 strcpy( buffer, "get_" );
187 else if (is_attr( v->attrs, ATTR_PROPPUT ))
188 strcpy( buffer, "put_" );
189 else if (is_attr( v->attrs, ATTR_PROPPUTREF ))
190 strcpy( buffer, "putref_" );
191 else
192 buffer[0] = 0;
193 strcat( buffer, v->name );
194 return buffer;
195}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLuint buffer
Definition: glext.h:5915
@ ATTR_PROPPUT
Definition: widltypes.h:145
@ ATTR_PROPPUTREF
Definition: widltypes.h:146
@ ATTR_PROPGET
Definition: widltypes.h:144

Referenced by do_write_c_method_def(), get_vtbl_entry_name(), is_inherited_method(), is_override_method(), write_cpp_method_def(), write_enums(), write_function_proto(), write_inline_wrappers(), write_locals(), write_method_macro(), and write_method_proto().

◆ get_vtbl_entry_name()

static char * get_vtbl_entry_name ( const type_t iface,
const var_t func 
)
static

Definition at line 1003 of file header.c.

1004{
1005 static char buff[255];
1006 if (is_inherited_method(iface, func))
1007 sprintf(buff, "%s_%s", iface->name, get_name(func));
1008 else
1009 sprintf(buff, "%s", get_name(func));
1010 return buff;
1011}
static unsigned char buff[32768]
Definition: fatten.c:17
#define sprintf(buf, format,...)
Definition: sprintf.c:55

Referenced by write_inline_wrappers(), and write_method_macro().

◆ has_out_arg_or_return()

int has_out_arg_or_return ( const var_t func)

Definition at line 908 of file header.c.

909{
910 const var_t *var;
911
913 return 1;
914
915 if (!type_get_function_args(func->type))
916 return 0;
917
919 if (is_attr(var->attrs, ATTR_OUT))
920 return 1;
921
922 return 0;
923}
static int is_void(const type_t *t)
Definition: header.h:69

Referenced by write_function_stub().

◆ indent()

static void indent ( FILE h,
int  delta 
)
static

Definition at line 48 of file header.c.

49{
50 int c;
51 if (delta < 0) indentation += delta;
52 for (c=0; c<indentation; c++) fprintf(h, " ");
53 if (delta > 0) indentation += delta;
54}
const GLubyte * c
Definition: glext.h:8905
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define c
Definition: ke_i.h:80

◆ is_aggregate_return()

static int is_aggregate_return ( const var_t func)
static

Definition at line 996 of file header.c.

997{
999 return type == TYPE_STRUCT || type == TYPE_UNION ||
1001}
type_type
Definition: widltypes.h:401
@ TYPE_COCLASS
Definition: widltypes.h:410

Referenced by do_write_c_method_def(), write_cpp_method_def(), write_inline_wrappers(), and write_method_macro().

◆ is_aliaschain_attr()

int is_aliaschain_attr ( const type_t type,
enum attr_type  attr 
)

Definition at line 86 of file header.c.

87{
88 const type_t *t = type;
89 for (;;)
90 {
91 if (is_attr(t->attrs, attr))
92 return 1;
93 else if (type_is_alias(t))
95 else return 0;
96 }
97}

Referenced by get_enum_fc(), is_string_type(), typegen_detect_type(), write_function_stub(), and write_remoting_arg().

◆ is_attr()

◆ is_callas()

◆ is_const_decl()

int is_const_decl ( const var_t var)

Definition at line 801 of file header.c.

802{
803 const type_t *t;
804 /* strangely, MIDL accepts a const attribute on any pointer in the
805 * declaration to mean that data isn't being instantiated. this appears
806 * to be a bug, but there is no benefit to being incompatible with MIDL,
807 * so we'll do the same thing */
808 for (t = var->type; ; )
809 {
810 if (is_attr(t->attrs, ATTR_CONST))
811 return TRUE;
812 else if (is_ptr(t))
814 else break;
815 }
816 return FALSE;
817}
#define FALSE
Definition: types.h:117
@ ATTR_CONST
Definition: widltypes.h:84

Referenced by write_declaration().

◆ is_inherited_method()

static int is_inherited_method ( const type_t iface,
const var_t func 
)
static

Definition at line 948 of file header.c.

949{
950 while ((iface = type_iface_get_inherit(iface)))
951 {
952 const statement_t *stmt;
954 {
955 const var_t *funccmp = stmt->u.var;
956
957 if (!is_callas(func->attrs))
958 {
959 char inherit_name[256];
960 /* compare full name including property prefix */
961 strcpy(inherit_name, get_name(funccmp));
962 if (!strcmp(inherit_name, get_name(func))) return 1;
963 }
964 }
965 }
966
967 return 0;
968}

Referenced by do_write_c_method_def(), and get_vtbl_entry_name().

◆ is_local()

◆ is_object()

int is_object ( const type_t iface)

Definition at line 928 of file header.c.

929{
930 const attr_t *attr;
931 if (type_is_defined(iface) && type_iface_get_inherit(iface))
932 return 1;
933 if (iface->attrs) LIST_FOR_EACH_ENTRY( attr, iface->attrs, const attr_t, entry )
934 if (attr->type == ATTR_OBJECT || attr->type == ATTR_ODL) return 1;
935 return 0;
936}
static int type_is_defined(const type_t *type)
Definition: typetree.h:186
@ ATTR_OBJECT
Definition: widltypes.h:133
@ ATTR_ODL
Definition: widltypes.h:134

Referenced by get_pointer_fc_context(), need_proxy(), need_stub(), write_client_call_routine(), write_conf_or_var_desc(), write_forward_decls(), write_func_param_struct(), write_header_stmts(), write_id_data_stmts(), write_interface(), write_locals(), write_proc_func_header(), write_procformatstring_func(), and write_typelib_interface().

◆ is_override_method()

static int is_override_method ( const type_t iface,
const type_t child,
const var_t func 
)
static

Definition at line 970 of file header.c.

971{
972 if (iface == child)
973 return 0;
974
975 do
976 {
977 const statement_t *stmt;
979 {
980 const var_t *funccmp = stmt->u.var;
981
982 if (!is_callas(func->attrs))
983 {
984 char inherit_name[256];
985 /* compare full name including property prefix */
986 strcpy(inherit_name, get_name(funccmp));
987 if (!strcmp(inherit_name, get_name(func))) return 1;
988 }
989 }
990 }
991 while ((child = type_iface_get_inherit(child)) && child != iface);
992
993 return 0;
994}
static HWND child
Definition: cursoricon.c:298

Referenced by write_inline_wrappers(), and write_method_macro().

◆ is_ptrchain_attr()

int is_ptrchain_attr ( const var_t var,
enum attr_type  t 
)

Definition at line 66 of file header.c.

67{
68 if (is_attr(var->attrs, t))
69 return 1;
70 else
71 {
72 type_t *type = var->type;
73 for (;;)
74 {
75 if (is_attr(type->attrs, t))
76 return 1;
77 else if (type_is_alias(type))
79 else if (is_ptr(type))
81 else return 0;
82 }
83 }
84}

Referenced by get_required_buffer_size().

◆ needs_space_after()

int needs_space_after ( type_t t)

Definition at line 282 of file header.c.

283{
284 return (type_is_alias(t) ||
285 (!is_ptr(t) && (!is_array(t) || !type_array_is_decl_as_ptr(t) || t->name)));
286}
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260

Referenced by write_func_param_struct(), write_pointer_left(), and write_type_v().

◆ serializable_exists()

static int serializable_exists ( FILE header,
const type_t type 
)
static

Definition at line 725 of file header.c.

726{
727 return 0;
728}

Referenced by write_header().

◆ user_type_registered()

static int user_type_registered ( const char name)
static

Definition at line 571 of file header.c.

572{
573 user_type_t *ut;
575 if (!strcmp(name, ut->name))
576 return 1;
577 return 0;
578}

Referenced by check_for_additional_prototype_types().

◆ uuid_string()

static const char * uuid_string ( const UUID uuid)
static

Definition at line 146 of file header.c.

147{
148 static char buf[37];
149
150 sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
151 uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1], uuid->Data4[2],
152 uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
153
154 return buf;
155}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: msctf.idl:550

Referenced by macho_map_file(), try_dsym(), write_coclass(), and write_com_interface_end().

◆ write_args()

void write_args ( FILE h,
const var_list_t args,
const char name,
int  method,
int  do_indent 
)

Definition at line 1058 of file header.c.

1059{
1060 const var_t *arg;
1061 int count = 0;
1062
1063 if (do_indent)
1064 {
1065 indentation++;
1066 indent(h, 0);
1067 }
1068 if (method == 1) {
1069 fprintf(h, "%s* This", name);
1070 count++;
1071 }
1072 if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) {
1073 if (count) {
1074 if (do_indent)
1075 {
1076 fprintf(h, ",\n");
1077 indent(h, 0);
1078 }
1079 else fprintf(h, ",");
1080 }
1081 write_type_decl(h, arg->type, arg->name);
1082 if (method == 2) {
1083 const expr_t *expr = get_attrp(arg->attrs, ATTR_DEFAULTVALUE);
1084 if (expr) {
1085 const var_t *tail_arg;
1086
1087 /* Output default value only if all following arguments also have default value. */
1088 LIST_FOR_EACH_ENTRY_REV( tail_arg, args, const var_t, entry ) {
1089 if(tail_arg == arg) {
1090 expr_t bstr;
1091
1092 /* Fixup the expression type for a BSTR like midl does. */
1093 if (get_type_vt(arg->type) == VT_BSTR && expr->type == EXPR_STRLIT)
1094 {
1095 bstr = *expr;
1096 bstr.type = EXPR_WSTRLIT;
1097 expr = &bstr;
1098 }
1099
1100 fprintf(h, " = ");
1101 write_expr( h, expr, 0, 1, NULL, NULL, "" );
1102 break;
1103 }
1104 if(!get_attrp(tail_arg->attrs, ATTR_DEFAULTVALUE))
1105 break;
1106 }
1107 }
1108 }
1109 count++;
1110 }
1111 if (do_indent) indentation--;
1112}
@ VT_BSTR
Definition: compat.h:2303
method
Definition: dragdrop.c:54
void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix, const type_t *cont_type, const char *local_var_prefix)
Definition: expr.c:691
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define LIST_FOR_EACH_ENTRY_REV(elem, list, type, field)
Definition: list.h:222
void write_type_decl(FILE *f, type_t *t, const char *name)
Definition: header.c:561
unsigned short get_type_vt(type_t *t)
Definition: typelib.c:129
enum expr_type type
Definition: widltypes.h:308
attr_list_t * attrs
Definition: widltypes.h:454
Definition: query.h:86
int type
Definition: query.h:87
@ EXPR_WSTRLIT
Definition: widltypes.h:212
@ EXPR_STRLIT
Definition: widltypes.h:211
@ ATTR_DEFAULTVALUE
Definition: widltypes.h:91
void * arg
Definition: msvc.h:10

Referenced by do_write_c_method_def(), gen_proxy(), nfs41_write(), write_client_func_decl(), write_cpp_method_def(), write_function_proto(), write_inline_wrappers(), write_locals(), write_method_proto(), and write_type_v().

◆ write_c_disp_method_def()

static void write_c_disp_method_def ( FILE header,
const type_t iface 
)
static

Definition at line 1303 of file header.c.

1304{
1306}
const char * c_name
Definition: widltypes.h:436

Referenced by write_com_interface_end().

◆ write_c_method_def()

static void write_c_method_def ( FILE header,
const type_t iface 
)
static

Definition at line 1298 of file header.c.

1299{
1300 do_write_c_method_def(header, iface, iface->c_name);
1301}

Referenced by write_com_interface_end().

◆ write_coclass()

static void write_coclass ( FILE header,
type_t cocl 
)
static

Definition at line 1581 of file header.c.

1582{
1583 const UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
1584
1585 fprintf(header, "/*****************************************************************************\n");
1586 fprintf(header, " * %s coclass\n", cocl->name);
1587 fprintf(header, " */\n\n");
1588 if (uuid)
1589 write_guid(header, "CLSID", cocl->name, uuid);
1590 fprintf(header, "\n#ifdef __cplusplus\n");
1591 if (uuid)
1592 {
1593 fprintf(header, "class DECLSPEC_UUID(\"%s\") %s;\n", uuid_string(uuid), cocl->name);
1594 write_uuid_decl(header, cocl, uuid);
1595 }
1596 else
1597 {
1598 fprintf(header, "class %s;\n", cocl->name);
1599 }
1600 fprintf(header, "#endif\n");
1601 fprintf(header, "\n");
1602}
static const char * uuid_string(const UUID *uuid)
Definition: header.c:146
static void write_uuid_decl(FILE *f, type_t *type, const UUID *uuid)
Definition: header.c:133
static void write_guid(FILE *f, const char *guid_prefix, const char *name, const UUID *uuid)
Definition: header.c:123
@ ATTR_UUID
Definition: widltypes.h:166

Referenced by write_header_stmts().

◆ write_coclass_forward()

static void write_coclass_forward ( FILE header,
type_t cocl 
)
static

Definition at line 1604 of file header.c.

1605{
1606 fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", cocl->name);
1607 fprintf(header, "#define __%s_FWD_DEFINED__\n", cocl->name);
1608 fprintf(header, "#ifdef __cplusplus\n");
1609 fprintf(header, "typedef class %s %s;\n", cocl->name, cocl->name);
1610 fprintf(header, "#else\n");
1611 fprintf(header, "typedef struct %s %s;\n", cocl->name, cocl->name);
1612 fprintf(header, "#endif /* defined __cplusplus */\n");
1613 fprintf(header, "#endif /* defined __%s_FWD_DEFINED__ */\n\n", cocl->name );
1614}

Referenced by write_forward_decls().

◆ write_com_interface_end()

static void write_com_interface_end ( FILE header,
type_t iface 
)
static

Definition at line 1462 of file header.c.

1463{
1464 int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE);
1465 const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
1466 type_t *type;
1467
1468 if (uuid)
1469 write_guid(header, dispinterface ? "DIID" : "IID", iface->c_name, uuid);
1470
1471 /* C++ interface */
1472 fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n");
1473 if (!is_global_namespace(iface->namespace)) {
1474 write_line(header, 0, "} /* extern \"C\" */");
1475 write_namespace_start(header, iface->namespace);
1476 }
1477 if (uuid) {
1478 write_line(header, 0, "MIDL_INTERFACE(\"%s\")", uuid_string(uuid));
1479 indent(header, 0);
1480 }else {
1481 indent(header, 0);
1482 fprintf(header, "interface ");
1483 }
1484 if (type_iface_get_inherit(iface))
1485 {
1486 fprintf(header, "%s : public %s\n", iface->name,
1488 write_line(header, 1, "{");
1489 }
1490 else
1491 {
1492 fprintf(header, "%s\n", iface->name);
1493 write_line(header, 1, "{\n");
1494 write_line(header, 0, "BEGIN_INTERFACE\n");
1495 }
1496 /* dispinterfaces don't have real functions, so don't write C++ functions for
1497 * them */
1498 if (!dispinterface)
1500 if (!type_iface_get_inherit(iface))
1501 write_line(header, 0, "END_INTERFACE\n");
1502 write_line(header, -1, "};");
1503 if (!is_global_namespace(iface->namespace)) {
1504 write_namespace_end(header, iface->namespace);
1505 write_line(header, 0, "extern \"C\" {");
1506 }
1507 if (uuid)
1508 write_uuid_decl(header, iface, uuid);
1509 fprintf(header, "#else\n");
1510 /* C interface */
1511 write_line(header, 1, "typedef struct %sVtbl {", iface->c_name);
1512 write_line(header, 0, "BEGIN_INTERFACE\n");
1513 if (dispinterface)
1515 else
1516 write_c_method_def(header, iface);
1517 write_line(header, 0, "END_INTERFACE");
1518 write_line(header, -1, "} %sVtbl;\n", iface->c_name);
1519 fprintf(header, "interface %s {\n", iface->c_name);
1520 fprintf(header, " CONST_VTBL %sVtbl* lpVtbl;\n", iface->c_name);
1521 fprintf(header, "};\n\n");
1522 fprintf(header, "#ifdef COBJMACROS\n");
1523 /* dispinterfaces don't have real functions, so don't write macros for them,
1524 * only for the interface this interface inherits from, i.e. IDispatch */
1525 fprintf(header, "#ifndef WIDL_C_INLINE_WRAPPERS\n");
1526 type = dispinterface ? type_iface_get_inherit(iface) : iface;
1528 fprintf(header, "#else\n");
1530 fprintf(header, "#endif\n");
1531 fprintf(header, "#endif\n");
1532 fprintf(header, "\n");
1533 fprintf(header, "#endif\n");
1534 fprintf(header, "\n");
1535 /* dispinterfaces don't have real functions, so don't write prototypes for
1536 * them */
1537 if (!dispinterface && !winrt_mode)
1538 {
1539 write_method_proto(header, iface);
1540 write_locals(header, iface, FALSE);
1541 fprintf(header, "\n");
1542 }
1543 fprintf(header,"#endif /* __%s_%sINTERFACE_DEFINED__ */\n\n", iface->c_name, dispinterface ? "DISP" : "");
1544}
static void write_line(FILE *f, int delta, const char *fmt,...)
Definition: header.c:56
static void write_method_macro(FILE *header, const type_t *iface, const type_t *child, const char *name)
Definition: header.c:1013
static void write_method_proto(FILE *header, const type_t *iface)
Definition: header.c:1308
static void write_locals(FILE *fp, const type_t *iface, int body)
Definition: header.c:1334
static void write_cpp_method_def(FILE *header, const type_t *iface)
Definition: header.c:1114
static void write_namespace_start(FILE *header, struct namespace *namespace)
Definition: header.c:157
static void write_c_method_def(FILE *header, const type_t *iface)
Definition: header.c:1298
static void write_c_disp_method_def(FILE *header, const type_t *iface)
Definition: header.c:1303
static void write_inline_wrappers(FILE *header, const type_t *iface, const type_t *child, const char *name)
Definition: header.c:1184
static void write_namespace_end(FILE *header, struct namespace *namespace)
Definition: header.c:169
int winrt_mode
Definition: widl.c:129
@ ATTR_DISPINTERFACE
Definition: widltypes.h:94
static int is_global_namespace(const struct namespace *namespace)
Definition: widltypes.h:614

Referenced by write_header_stmts().

◆ write_com_interface_start()

static void write_com_interface_start ( FILE header,
const type_t iface 
)
static

Definition at line 1452 of file header.c.

1453{
1454 int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE);
1455 fprintf(header, "/*****************************************************************************\n");
1456 fprintf(header, " * %s %sinterface\n", iface->name, dispinterface ? "disp" : "");
1457 fprintf(header, " */\n");
1458 fprintf(header,"#ifndef __%s_%sINTERFACE_DEFINED__\n", iface->c_name, dispinterface ? "DISP" : "");
1459 fprintf(header,"#define __%s_%sINTERFACE_DEFINED__\n\n", iface->c_name, dispinterface ? "DISP" : "");
1460}

Referenced by write_header_stmts().

◆ write_context_handle_rundowns()

static void write_context_handle_rundowns ( FILE header)
static

Definition at line 773 of file header.c.

774{
777 {
778 const char *name = ch->name;
779 fprintf(header, "void __RPC_USER %s_rundown(%s);\n", name, name);
780 }
781}

Referenced by write_header().

◆ write_cpp_method_def()

static void write_cpp_method_def ( FILE header,
const type_t iface 
)
static

Definition at line 1114 of file header.c.

1115{
1116 const statement_t *stmt;
1117
1119 {
1120 const var_t *func = stmt->u.var;
1121 if (!is_callas(func->attrs)) {
1122 const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
1124 const var_t *arg;
1125
1126 if (!callconv) callconv = "STDMETHODCALLTYPE";
1127
1129 fprintf(header, "#ifdef WIDL_EXPLICIT_AGGREGATE_RETURNS\n");
1130
1131 indent(header, 0);
1132 fprintf(header, "virtual ");
1134 fprintf(header, "* %s %s(\n", callconv, get_name(func));
1135 ++indentation;
1136 indent(header, 0);
1138 fprintf(header, " *__ret");
1139 --indentation;
1140 if (args) {
1141 fprintf(header, ",\n");
1142 write_args(header, args, iface->name, 2, TRUE);
1143 }
1144 fprintf(header, ") = 0;\n");
1145
1146 indent(header, 0);
1148 fprintf(header, " %s %s(\n", callconv, get_name(func));
1149 write_args(header, args, iface->name, 2, TRUE);
1150 fprintf(header, ")\n");
1151 indent(header, 0);
1152 fprintf(header, "{\n");
1153 ++indentation;
1154 indent(header, 0);
1156 fprintf(header, " __ret;\n");
1157 indent(header, 0);
1158 fprintf(header, "return *%s(&__ret", get_name(func));
1159 if (args)
1161 fprintf(header, ", %s", arg->name);
1162 fprintf(header, ");\n");
1163 --indentation;
1164 indent(header, 0);
1165 fprintf(header, "}\n");
1166
1167 fprintf(header, "#else\n");
1168 }
1169
1170 indent(header, 0);
1171 fprintf(header, "virtual ");
1173 fprintf(header, " %s %s(\n", callconv, get_name(func));
1174 write_args(header, args, iface->name, 2, TRUE);
1175 fprintf(header, ") = 0;\n");
1176
1178 fprintf(header, "#endif\n");
1179 fprintf(header, "\n");
1180 }
1181 }
1182}

Referenced by write_com_interface_end().

◆ write_declaration()

static void write_declaration ( FILE header,
const var_t v 
)
static

Definition at line 819 of file header.c.

820{
821 if (is_const_decl(v) && v->eval)
822 {
823 fprintf(header, "#define %s (", v->name);
824 write_expr(header, v->eval, 0, 1, NULL, NULL, "");
825 fprintf(header, ")\n\n");
826 }
827 else
828 {
829 switch (v->stgclass)
830 {
831 case STG_NONE:
832 case STG_REGISTER: /* ignored */
833 break;
834 case STG_STATIC:
835 fprintf(header, "static ");
836 break;
837 case STG_EXTERN:
838 fprintf(header, "extern ");
839 break;
840 }
842 fprintf(header, ";\n\n");
843 }
844}
static void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name)
Definition: header.c:532
int is_const_decl(const var_t *var)
Definition: header.c:801
char * name
Definition: compiler.c:66
@ STG_REGISTER
Definition: widltypes.h:235
@ STG_NONE
Definition: widltypes.h:232
@ STG_EXTERN
Definition: widltypes.h:234
@ STG_STATIC
Definition: widltypes.h:233

Referenced by write_header_stmts().

◆ write_enums()

static void write_enums ( FILE h,
var_list_t enums,
const char enum_name 
)
static

Definition at line 260 of file header.c.

261{
262 var_t *v;
263 if (!enums) return;
265 {
266 if (v->name) {
267 indent(h, 0);
268 if(!enum_name)
269 fprintf(h, "%s", get_name(v));
270 else
271 fprintf(h, "%s_%s", enum_name, get_name(v));
272 if (v->eval) {
273 fprintf(h, " = ");
274 write_expr(h, v->eval, 0, 1, NULL, NULL, "");
275 }
276 }
277 if (list_next( enums, &v->entry )) fprintf(h, ",\n");
278 }
279 fprintf(h, "\n");
280}
static const struct encodedInt enums[]
Definition: encode.c:365
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115

Referenced by write_type_left().

◆ write_fields()

static void write_fields ( FILE h,
var_list_t fields 
)
static

Definition at line 197 of file header.c.

198{
199 unsigned nameless_struct_cnt = 0, nameless_struct_i = 0, nameless_union_cnt = 0, nameless_union_i = 0;
200 const char *name;
201 char buf[32];
202 var_t *v;
203
204 if (!fields) return;
205
207 if (!v || !v->type) continue;
208
209 switch(type_get_type_detect_alias(v->type)) {
210 case TYPE_STRUCT:
212 nameless_struct_cnt++;
213 break;
214 case TYPE_UNION:
215 nameless_union_cnt++;
216 break;
217 default:
218 ;
219 }
220 }
221
223 if (!v || !v->type) continue;
224
225 indent(h, 0);
226 name = v->name;
227
228 switch(type_get_type_detect_alias(v->type)) {
229 case TYPE_STRUCT:
231 if(!v->name) {
232 fprintf(h, "__C89_NAMELESS ");
233 if(nameless_struct_cnt == 1) {
234 name = "__C89_NAMELESSSTRUCTNAME";
235 }else if(nameless_struct_i < 5 /* # of supporting macros */) {
236 sprintf(buf, "__C89_NAMELESSSTRUCTNAME%d", ++nameless_struct_i);
237 name = buf;
238 }
239 }
240 break;
241 case TYPE_UNION:
242 if(!v->name) {
243 fprintf(h, "__C89_NAMELESS ");
244 if(nameless_union_cnt == 1) {
245 name = "__C89_NAMELESSUNIONNAME";
246 }else if(nameless_union_i < 8 /* # of supporting macros */ ) {
247 sprintf(buf, "__C89_NAMELESSUNIONNAME%d", ++nameless_union_i);
248 name = buf;
249 }
250 }
251 break;
252 default:
253 ;
254 }
256 fprintf(h, ";\n");
257 }
258}
const char * fields[10]
Definition: parser.c:313
@ TYPE_ENCAPSULATED_UNION
Definition: widltypes.h:406

Referenced by write_type_left().

◆ write_forward()

static void write_forward ( FILE header,
type_t iface 
)
static

Definition at line 1439 of file header.c.

1440{
1441 fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", iface->c_name);
1442 fprintf(header, "#define __%s_FWD_DEFINED__\n", iface->c_name);
1443 fprintf(header, "typedef interface %s %s;\n", iface->c_name, iface->c_name);
1444 fprintf(header, "#ifdef __cplusplus\n");
1445 write_namespace_start(header, iface->namespace);
1446 write_line(header, 0, "interface %s;", iface->name);
1447 write_namespace_end(header, iface->namespace);
1448 fprintf(header, "#endif /* __cplusplus */\n");
1449 fprintf(header, "#endif\n\n" );
1450}

Referenced by write_forward_decls(), and write_header_stmts().

◆ write_forward_decls()

static void write_forward_decls ( FILE header,
const statement_list_t stmts 
)
static

Definition at line 1660 of file header.c.

1661{
1662 const statement_t *stmt;
1663 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
1664 {
1665 switch (stmt->type)
1666 {
1667 case STMT_TYPE:
1668 if (type_get_type(stmt->u.type) == TYPE_INTERFACE)
1669 {
1670 type_t *iface = stmt->u.type;
1671 if (is_object(iface) || is_attr(iface->attrs, ATTR_DISPINTERFACE))
1672 {
1673 write_forward(header, iface);
1674 if (iface->details.iface->async_iface)
1675 write_forward(header, iface->details.iface->async_iface);
1676 }
1677 }
1678 else if (type_get_type(stmt->u.type) == TYPE_COCLASS)
1680 break;
1681 case STMT_TYPEREF:
1682 case STMT_IMPORTLIB:
1683 /* not included in header */
1684 break;
1685 case STMT_IMPORT:
1686 case STMT_TYPEDEF:
1687 case STMT_MODULE:
1688 case STMT_CPPQUOTE:
1689 case STMT_PRAGMA:
1690 case STMT_DECLARATION:
1691 /* not processed here */
1692 break;
1693 case STMT_LIBRARY:
1695 break;
1696 }
1697 }
1698}
static void write_forward_decls(FILE *header, const statement_list_t *stmts)
Definition: header.c:1660
static void write_forward(FILE *header, type_t *iface)
Definition: header.c:1439
static void write_coclass_forward(FILE *header, type_t *cocl)
Definition: header.c:1604
int is_object(const type_t *iface)
Definition: header.c:928
typelib_t * lib
Definition: widltypes.h:540
struct iface_details * iface
Definition: widltypes.h:428
union _type_t::@5030 details
statement_list_t * stmts
Definition: widltypes.h:518
@ STMT_MODULE
Definition: widltypes.h:244
@ STMT_IMPORT
Definition: widltypes.h:246
@ STMT_IMPORTLIB
Definition: widltypes.h:247
@ STMT_DECLARATION
Definition: widltypes.h:241
@ STMT_LIBRARY
Definition: widltypes.h:240
@ STMT_CPPQUOTE
Definition: widltypes.h:249
@ STMT_TYPEREF
Definition: widltypes.h:243
@ STMT_PRAGMA
Definition: widltypes.h:248

Referenced by write_forward_decls(), and write_header().

◆ write_function_proto()

static void write_function_proto ( FILE header,
const type_t iface,
const var_t fun,
const char prefix 
)
static

Definition at line 1423 of file header.c.

1424{
1425 const char *callconv = get_attrp(fun->type->attrs, ATTR_CALLCONV);
1426
1427 if (!callconv) callconv = "__cdecl";
1428 /* FIXME: do we need to handle call_as? */
1430 fprintf(header, " %s ", callconv);
1431 fprintf(header, "%s%s(\n", prefix, get_name(fun));
1432 if (type_get_function_args(fun->type))
1434 else
1435 fprintf(header, " void");
1436 fprintf(header, ");\n\n");
1437}
type_t * type
Definition: widltypes.h:453

Referenced by write_header_stmts().

◆ write_generic_handle_routines()

static void write_generic_handle_routines ( FILE header)
static

Definition at line 783 of file header.c.

784{
787 {
788 const char *name = gh->name;
789 fprintf(header, "handle_t __RPC_USER %s_bind(%s);\n", name, name);
790 fprintf(header, "void __RPC_USER %s_unbind(%s, handle_t);\n", name, name);
791 }
792}

Referenced by write_header().

◆ write_guid()

static void write_guid ( FILE f,
const char guid_prefix,
const char name,
const UUID uuid 
)
static

Definition at line 123 of file header.c.

124{
125 if (!uuid) return;
126 fprintf(f, "DEFINE_GUID(%s_%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
127 "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x);\n",
128 guid_prefix, name, uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0],
129 uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5],
130 uuid->Data4[6], uuid->Data4[7]);
131}
GLfloat f
Definition: glext.h:7540

Referenced by write_coclass(), write_com_interface_end(), and write_library().

◆ write_header()

void write_header ( const statement_list_t stmts)

Definition at line 1790 of file header.c.

1791{
1792 FILE *header;
1793
1794 if (!do_header) return;
1795
1796 if(!(header = fopen(header_name, "w"))) {
1797 error("Could not open %s for output\n", header_name);
1798 return;
1799 }
1800 fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n\n", PACKAGE_VERSION, input_name);
1801
1802 fprintf(header, "#ifdef _WIN32\n");
1803 fprintf(header, "#ifndef __REQUIRED_RPCNDR_H_VERSION__\n");
1804 fprintf(header, "#define __REQUIRED_RPCNDR_H_VERSION__ 475\n");
1805 fprintf(header, "#endif\n\n");
1806
1807 fprintf(header, "#ifdef __REACTOS__\n");
1808 fprintf(header, "#define WIN32_LEAN_AND_MEAN\n");
1809 fprintf(header, "#endif\n\n");
1810
1811 fprintf(header, "#include <rpc.h>\n" );
1812 fprintf(header, "#include <rpcndr.h>\n" );
1814 fprintf(header, "#include <midles.h>\n" );
1815 fprintf(header, "#endif\n\n");
1816
1817 fprintf(header, "#ifndef COM_NO_WINDOWS_H\n");
1818 fprintf(header, "#include <windows.h>\n");
1819 fprintf(header, "#include <ole2.h>\n");
1820 fprintf(header, "#endif\n\n");
1821
1822 fprintf(header, "#ifndef __%s__\n", header_token);
1823 fprintf(header, "#define __%s__\n\n", header_token);
1824
1825 fprintf(header, "/* Forward declarations */\n\n");
1827
1828 fprintf(header, "/* Headers for imported files */\n\n");
1829 write_imports(header, stmts);
1830 fprintf(header, "\n");
1832
1834
1835 fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
1836 fprintf(header, "\n");
1841 fprintf(header, "\n");
1842 fprintf(header, "/* End additional prototypes */\n");
1843 fprintf(header, "\n");
1844
1846 fprintf(header, "#endif /* __%s__ */\n", header_token);
1847
1848 fclose(header);
1849}
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define PACKAGE_VERSION
Definition: config.h:835
static void write_generic_handle_routines(FILE *header)
Definition: header.c:783
static void write_imports(FILE *header, const statement_list_t *stmts)
Definition: header.c:1628
static int for_each_serializable(const statement_list_t *stmts, FILE *header, int(*proc)(FILE *, const type_t *))
Definition: header.c:730
static int write_serialize_function_decl(FILE *header, const type_t *type)
Definition: header.c:719
static void write_user_types(FILE *header)
Definition: header.c:760
static void write_context_handle_rundowns(FILE *header)
Definition: header.c:773
static void write_header_stmts(FILE *header, const statement_list_t *stmts, const type_t *iface, int ignore_funcs)
Definition: header.c:1700
static int serializable_exists(FILE *header, const type_t *type)
Definition: header.c:725
void start_cplusplus_guard(FILE *fp)
Definition: widl.c:340
int do_header
Definition: widl.c:116
char * header_token
Definition: widl.c:138
void end_cplusplus_guard(FILE *fp)
Definition: widl.c:347
char * header_name
Definition: widl.c:136
char * input_name
Definition: widl.c:133

◆ write_header_stmts()

static void write_header_stmts ( FILE header,
const statement_list_t stmts,
const type_t iface,
int  ignore_funcs 
)
static

Definition at line 1700 of file header.c.

1701{
1702 const statement_t *stmt;
1703 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
1704 {
1705 switch (stmt->type)
1706 {
1707 case STMT_TYPE:
1708 if (type_get_type(stmt->u.type) == TYPE_INTERFACE)
1709 {
1710 type_t *iface = stmt->u.type;
1711 type_t *async_iface = iface->details.iface->async_iface;
1712 if (is_object(iface)) is_object_interface++;
1713 if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type))
1714 {
1718 if (async_iface)
1719 {
1720 write_com_interface_start(header, async_iface);
1721 write_com_interface_end(header, async_iface);
1722 }
1723 }
1724 else
1725 {
1729 }
1730 if (is_object(iface)) is_object_interface--;
1731 }
1732 else if (type_get_type(stmt->u.type) == TYPE_COCLASS)
1733 write_coclass(header, stmt->u.type);
1734 else
1735 {
1737 }
1738 break;
1739 case STMT_TYPEREF:
1740 /* FIXME: shouldn't write out forward declarations for undefined
1741 * interfaces but a number of our IDL files depend on this */
1742 if (type_get_type(stmt->u.type) == TYPE_INTERFACE && !stmt->u.type->written)
1743 write_forward(header, stmt->u.type);
1744 break;
1745 case STMT_IMPORTLIB:
1746 case STMT_MODULE:
1747 case STMT_PRAGMA:
1748 /* not included in header */
1749 break;
1750 case STMT_IMPORT:
1751 /* not processed here */
1752 break;
1753 case STMT_TYPEDEF:
1754 {
1755 const type_list_t *type_entry = stmt->u.type_list;
1756 for (; type_entry; type_entry = type_entry->next)
1757 write_typedef(header, type_entry->type);
1758 break;
1759 }
1760 case STMT_LIBRARY:
1761 write_library(header, stmt->u.lib);
1763 break;
1764 case STMT_CPPQUOTE:
1765 fprintf(header, "%s\n", stmt->u.str);
1766 break;
1767 case STMT_DECLARATION:
1768 if (iface && type_get_type(stmt->u.var->type) == TYPE_FUNCTION)
1769 {
1770 if (!ignore_funcs)
1771 {
1772 int prefixes_differ = strcmp(prefix_client, prefix_server);
1773
1774 if (prefixes_differ)
1775 {
1776 fprintf(header, "/* client prototype */\n");
1778 fprintf(header, "/* server prototype */\n");
1779 }
1781 }
1782 }
1783 else
1784 write_declaration(header, stmt->u.var);
1785 break;
1786 }
1787 }
1788}
static void write_coclass(FILE *header, type_t *cocl)
Definition: header.c:1581
static void write_typedef(FILE *header, type_t *type)
Definition: header.c:794
static void write_com_interface_end(FILE *header, type_t *iface)
Definition: header.c:1462
static void write_com_interface_start(FILE *header, const type_t *iface)
Definition: header.c:1452
static int is_object_interface
Definition: header.c:41
static void write_library(FILE *header, const typelib_t *typelib)
Definition: header.c:846
static void write_rpc_interface_end(FILE *header, const type_t *iface)
Definition: header.c:1576
static void write_declaration(FILE *header, const var_t *v)
Definition: header.c:819
static void write_rpc_interface_start(FILE *header, const type_t *iface)
Definition: header.c:1546
static void write_type_definition(FILE *f, type_t *t)
Definition: header.c:537
static void write_function_proto(FILE *header, const type_t *iface, const var_t *fun, const char *prefix)
Definition: header.c:1423
const char * str
Definition: widltypes.h:538
const char * prefix_server
Definition: widl.c:152
const char * prefix_client
Definition: widl.c:151
@ TYPE_FUNCTION
Definition: widltypes.h:411

Referenced by write_header(), and write_header_stmts().

◆ write_import()

static void write_import ( FILE header,
const char fname 
)
static

Definition at line 1616 of file header.c.

1617{
1618 char *hname, *p;
1619
1620 hname = dup_basename(fname, ".idl");
1621 p = hname + strlen(hname) - 2;
1622 if (p <= hname || strcmp( p, ".h" )) strcat(hname, ".h");
1623
1624 fprintf(header, "#include <%s>\n", hname);
1625 free(hname);
1626}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define free
Definition: debug_ros.c:5
GLfloat GLfloat p
Definition: glext.h:8902
char * dup_basename(const char *name, const char *ext)
Definition: utils.c:143

Referenced by write_imports().

◆ write_imports()

static void write_imports ( FILE header,
const statement_list_t stmts 
)
static

Definition at line 1628 of file header.c.

1629{
1630 const statement_t *stmt;
1631 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
1632 {
1633 switch (stmt->type)
1634 {
1635 case STMT_TYPE:
1636 if (type_get_type(stmt->u.type) == TYPE_INTERFACE)
1638 break;
1639 case STMT_TYPEREF:
1640 case STMT_IMPORTLIB:
1641 /* not included in header */
1642 break;
1643 case STMT_IMPORT:
1644 write_import(header, stmt->u.str);
1645 break;
1646 case STMT_TYPEDEF:
1647 case STMT_MODULE:
1648 case STMT_CPPQUOTE:
1649 case STMT_PRAGMA:
1650 case STMT_DECLARATION:
1651 /* not processed here */
1652 break;
1653 case STMT_LIBRARY:
1654 write_imports(header, stmt->u.lib->stmts);
1655 break;
1656 }
1657 }
1658}
static void write_import(FILE *header, const char *fname)
Definition: header.c:1616

Referenced by write_header(), and write_imports().

◆ write_inline_wrappers()

static void write_inline_wrappers ( FILE header,
const type_t iface,
const type_t child,
const char name 
)
static

Definition at line 1184 of file header.c.

1185{
1186 const statement_t *stmt;
1187 int first_iface = 1;
1188
1189 if (type_iface_get_inherit(iface))
1191
1193 {
1194 const var_t *func = stmt->u.var;
1195
1196 if (first_iface)
1197 {
1198 fprintf(header, "/*** %s methods ***/\n", iface->name);
1199 first_iface = 0;
1200 }
1201
1202 if (is_override_method(iface, child, func))
1203 continue;
1204
1205 if (!is_callas(func->attrs)) {
1206 const var_t *arg;
1207
1208#ifdef __REACTOS__
1209 fprintf(header, "FORCEINLINE ");
1210#else
1211 fprintf(header, "static FORCEINLINE ");
1212#endif
1214 fprintf(header, " %s_%s(", name, get_name(func));
1216 fprintf(header, ") {\n");
1217 ++indentation;
1218 if (!is_aggregate_return(func)) {
1219 indent(header, 0);
1220 fprintf(header, "%sThis->lpVtbl->%s(This",
1221 is_void(type_function_get_rettype(func->type)) ? "" : "return ",
1222 get_vtbl_entry_name(iface, func));
1223 } else {
1224 indent(header, 0);
1226 fprintf(header, " __ret;\n");
1227 indent(header, 0);
1228 fprintf(header, "return *This->lpVtbl->%s(This,&__ret", get_vtbl_entry_name(iface, func));
1229 }
1230 if (type_get_function_args(func->type))
1232 fprintf(header, ",%s", arg->name);
1233 fprintf(header, ");\n");
1234 --indentation;
1235 fprintf(header, "}\n");
1236 }
1237 }
1238}
static int is_override_method(const type_t *iface, const type_t *child, const var_t *func)
Definition: header.c:970
static char * get_vtbl_entry_name(const type_t *iface, const var_t *func)
Definition: header.c:1003

Referenced by write_com_interface_end(), and write_inline_wrappers().

◆ write_library()

static void write_library ( FILE header,
const typelib_t typelib 
)
static

Definition at line 846 of file header.c.

847{
848 const UUID *uuid = get_attrp(typelib->attrs, ATTR_UUID);
849 fprintf(header, "\n");
850 write_guid(header, "LIBID", typelib->name, uuid);
851 fprintf(header, "\n");
852}

Referenced by write_header_stmts().

◆ write_line()

static void write_line ( FILE f,
int  delta,
const char fmt,
  ... 
)
static

Definition at line 56 of file header.c.

57{
58 va_list ap;
59 indent(f, delta);
60 va_start(ap, fmt);
61 vfprintf(f, fmt, ap);
62 va_end(ap);
63 fprintf(f, "\n");
64}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: dsound.c:943
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by write_com_interface_end(), write_forward(), write_namespace_end(), and write_namespace_start().

◆ write_local_stubs()

void write_local_stubs ( const statement_list_t stmts)

Definition at line 1403 of file header.c.

1404{
1405 FILE *local_stubs;
1406
1407 if (!local_stubs_name) return;
1408
1409 local_stubs = fopen(local_stubs_name, "w");
1410 if (!local_stubs) {
1411 error("Could not open %s for output\n", local_stubs_name);
1412 return;
1413 }
1414 fprintf(local_stubs, "/* call_as/local stubs for %s */\n\n", input_name);
1415 fprintf(local_stubs, "#include <objbase.h>\n");
1416 fprintf(local_stubs, "#include \"%s\"\n\n", header_name);
1417
1418 write_local_stubs_stmts(local_stubs, stmts);
1419
1420 fclose(local_stubs);
1421}
static void write_local_stubs_stmts(FILE *local_stubs, const statement_list_t *stmts)
Definition: header.c:1393
char * local_stubs_name
Definition: widl.c:137

◆ write_local_stubs_stmts()

static void write_local_stubs_stmts ( FILE local_stubs,
const statement_list_t stmts 
)
static

Definition at line 1393 of file header.c.

1394{
1395 const statement_t *stmt;
1396 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
1397 {
1398 if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
1399 write_locals(local_stubs, stmt->u.type, TRUE);
1400 }
1401}

Referenced by write_local_stubs().

◆ write_locals()

static void write_locals ( FILE fp,
const type_t iface,
int  body 
)
static

Definition at line 1334 of file header.c.

1335{
1336 static const char comment[]
1337 = "/* WIDL-generated stub. You must provide an implementation for this. */";
1338 const statement_t *stmt;
1339
1340 if (!is_object(iface))
1341 return;
1342
1344 const var_t *func = stmt->u.var;
1345 const var_t *cas = is_callas(func->attrs);
1346
1347 if (cas) {
1348 const statement_t *stmt2 = NULL;
1350 if (!strcmp(get_name(stmt2->u.var), cas->name))
1351 break;
1352 if (&stmt2->entry != type_iface_get_stmts(iface)) {
1353 const var_t *m = stmt2->u.var;
1354 /* proxy prototype - use local prototype */
1356 fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(m));
1357 write_args(fp, type_get_function_args(m->type), iface->name, 1, TRUE);
1358 fprintf(fp, ")");
1359 if (body) {
1360 type_t *rt = type_function_get_rettype(m->type);
1361 fprintf(fp, "\n{\n");
1362 fprintf(fp, " %s\n", comment);
1363 if (rt->name && strcmp(rt->name, "HRESULT") == 0)
1364 fprintf(fp, " return E_NOTIMPL;\n");
1365 else if (type_get_type(rt) != TYPE_VOID) {
1366 fprintf(fp, " ");
1367 write_type_decl(fp, rt, "rv");
1368 fprintf(fp, ";\n");
1369 fprintf(fp, " memset(&rv, 0, sizeof rv);\n");
1370 fprintf(fp, " return rv;\n");
1371 }
1372 fprintf(fp, "}\n\n");
1373 }
1374 else
1375 fprintf(fp, ";\n");
1376 /* stub prototype - use remotable prototype */
1378 fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(m));
1379 write_args(fp, type_get_function_args(func->type), iface->name, 1, TRUE);
1380 fprintf(fp, ")");
1381 if (body)
1382 /* Remotable methods must all return HRESULTs. */
1383 fprintf(fp, "\n{\n %s\n return E_NOTIMPL;\n}\n\n", comment);
1384 else
1385 fprintf(fp, ";\n");
1386 }
1387 else
1388 error_loc("invalid call_as attribute (%s -> %s)\n", func->name, cas->name);
1389 }
1390 }
1391}
const GLfloat * m
Definition: glext.h:10848
#define comment(fmt, arg1)
Definition: rebar.c:847
static const void * body(MD5_CTX *ctx, const void *data, unsigned long size)
Definition: md5.c:100
void error_loc(const char *s,...)
Definition: utils.c:69
struct list entry
Definition: widltypes.h:532
char * name
Definition: widltypes.h:452
@ TYPE_VOID
Definition: widltypes.h:402

Referenced by write_com_interface_end(), and write_local_stubs_stmts().

◆ write_method_macro()

static void write_method_macro ( FILE header,
const type_t iface,
const type_t child,
const char name 
)
static

Definition at line 1013 of file header.c.

1014{
1015 const statement_t *stmt;
1016 int first_iface = 1;
1017
1018 if (type_iface_get_inherit(iface))
1020
1022 {
1023 const var_t *func = stmt->u.var;
1024
1025 if (first_iface)
1026 {
1027 fprintf(header, "/*** %s methods ***/\n", iface->name);
1028 first_iface = 0;
1029 }
1030
1031 if (is_override_method(iface, child, func))
1032 continue;
1033
1034 if (!is_callas(func->attrs)) {
1035 const var_t *arg;
1036
1037 fprintf(header, "#define %s_%s(This", name, get_name(func));
1038 if (type_get_function_args(func->type))
1040 fprintf(header, ",%s", arg->name);
1041 fprintf(header, ") ");
1042
1044 {
1045 fprintf(header, "%s_%s_define_WIDL_C_INLINE_WRAPPERS_for_aggregate_return_support\n", name, get_name(func));
1046 continue;
1047 }
1048
1049 fprintf(header, "(This)->lpVtbl->%s(This", get_vtbl_entry_name(iface, func));
1050 if (type_get_function_args(func->type))
1052 fprintf(header, ",%s", arg->name);
1053 fprintf(header, ")\n");
1054 }
1055 }
1056}

Referenced by write_com_interface_end(), and write_method_macro().

◆ write_method_proto()

static void write_method_proto ( FILE header,
const type_t iface 
)
static

Definition at line 1308 of file header.c.

1309{
1310 const statement_t *stmt;
1311
1313 {
1314 const var_t *func = stmt->u.var;
1315
1316 if (is_callas(func->attrs)) {
1317 const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
1318 if (!callconv) callconv = "STDMETHODCALLTYPE";
1319 /* proxy prototype */
1321 fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
1323 fprintf(header, ");\n");
1324 /* stub prototype */
1325 fprintf(header, "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(func));
1326 fprintf(header, " IRpcStubBuffer* This,\n");
1327 fprintf(header, " IRpcChannelBuffer* pRpcChannelBuffer,\n");
1328 fprintf(header, " PRPC_MESSAGE pRpcMessage,\n");
1329 fprintf(header, " DWORD* pdwStubPhase);\n");
1330 }
1331 }
1332}

Referenced by write_com_interface_end().

◆ write_namespace_end()

static void write_namespace_end ( FILE header,
struct namespace namespace 
)
static

Definition at line 169 of file header.c.

170{
171 if(is_global_namespace(namespace)) {
173 write_line(header, -1, "}", namespace->name);
174 return;
175 }
176
177 write_line(header, -1, "}", namespace->name);
179}
struct namespace * parent
Definition: widltypes.h:394
const char * name
Definition: widltypes.h:393
int use_abi_namespace
Definition: widl.c:130

Referenced by write_com_interface_end(), write_forward(), write_namespace_end(), and write_type_definition().

◆ write_namespace_start()

static void write_namespace_start ( FILE header,
struct namespace namespace 
)
static

Definition at line 157 of file header.c.

158{
159 if(is_global_namespace(namespace)) {
161 write_line(header, 1, "namespace ABI {");
162 return;
163 }
164
166 write_line(header, 1, "namespace %s {", namespace->name);
167}

Referenced by write_com_interface_end(), write_forward(), write_namespace_start(), and write_type_definition().

◆ write_pointer_left()

static void write_pointer_left ( FILE h,
type_t ref 
)
static

Definition at line 288 of file header.c.

289{
291 fprintf(h, " ");
293 fprintf(h, "(");
294 fprintf(h, "*");
295}
int needs_space_after(type_t *t)
Definition: header.c:282
Definition: send.c:48

Referenced by write_type_left().

◆ write_rpc_interface_end()

static void write_rpc_interface_end ( FILE header,
const type_t iface 
)
static

Definition at line 1576 of file header.c.

1577{
1578 fprintf(header,"\n#endif /* __%s_INTERFACE_DEFINED__ */\n\n", iface->name);
1579}

Referenced by write_header_stmts().

◆ write_rpc_interface_start()

static void write_rpc_interface_start ( FILE header,
const type_t iface 
)
static

Definition at line 1546 of file header.c.

1547{
1548 unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
1549 const var_t *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
1550
1551 fprintf(header, "/*****************************************************************************\n");
1552 fprintf(header, " * %s interface (v%d.%d)\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
1553 fprintf(header, " */\n");
1554 fprintf(header,"#ifndef __%s_INTERFACE_DEFINED__\n", iface->name);
1555 fprintf(header,"#define __%s_INTERFACE_DEFINED__\n\n", iface->name);
1556 if (var)
1557 {
1558 fprintf(header, "extern ");
1559 write_type_decl( header, var->type, var->name );
1560 fprintf(header, ";\n");
1561 }
1562 if (old_names)
1563 {
1564 fprintf(header, "extern RPC_IF_HANDLE %s%s_ClientIfHandle;\n", prefix_client, iface->name);
1565 fprintf(header, "extern RPC_IF_HANDLE %s%s_ServerIfHandle;\n", prefix_server, iface->name);
1566 }
1567 else
1568 {
1569 fprintf(header, "extern RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec;\n",
1570 prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver));
1571 fprintf(header, "extern RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec;\n",
1572 prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver));
1573 }
1574}
unsigned int get_attrv(const attr_list_t *list, enum attr_type t)
Definition: header.c:115
#define MINORVERSION(version)
Definition: utils.h:76
#define MAJORVERSION(version)
Definition: utils.h:75
int old_names
Definition: widl.c:126
@ ATTR_VERSION
Definition: widltypes.h:169

Referenced by write_header_stmts().

◆ write_serialize_function_decl()

static int write_serialize_function_decl ( FILE header,
const type_t type 
)
static

Definition at line 719 of file header.c.

720{
722 return 1;
723}
void write_serialize_functions(FILE *file, const type_t *type, const type_t *iface)
Definition: client.c:338

Referenced by write_header().

◆ write_type_decl()

void write_type_decl ( FILE f,
type_t t,
const char name 
)

Definition at line 561 of file header.c.

562{
564}
static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *name)
Definition: header.c:488

Referenced by declare_stub_args(), gen_proxy(), print_phase_basetype(), print_start_tfs_comment(), write_args(), write_expr(), write_func_param_struct(), write_function_stub(), write_implicithandledecl(), write_locals(), write_remoting_arg(), and write_rpc_interface_start().

◆ write_type_decl_left()

void write_type_decl_left ( FILE f,
type_t t 
)

Definition at line 566 of file header.c.

567{
569}
void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly)
Definition: header.c:297
@ NAME_DEFAULT
Definition: typetree.h:28

Referenced by declare_stub_args(), do_write_c_method_def(), gen_proxy(), write_client_call_routine(), write_client_func_decl(), write_cpp_method_def(), write_function_proto(), write_function_stub(), write_inline_wrappers(), write_locals(), and write_method_proto().

◆ write_type_def_or_decl()

static void write_type_def_or_decl ( FILE f,
type_t t,
int  field,
const char name 
)
static

Definition at line 532 of file header.c.

533{
535}
Definition: parser.c:44

Referenced by write_declaration(), write_fields(), and write_typedef().

◆ write_type_definition()

static void write_type_definition ( FILE f,
type_t t 
)
static

Definition at line 537 of file header.c.

538{
539 int in_namespace = t->namespace && !is_global_namespace(t->namespace);
540 int save_written = t->written;
541
542 if(in_namespace) {
543 fprintf(f, "#ifdef __cplusplus\n");
544 fprintf(f, "} /* extern \"C\" */\n");
545 write_namespace_start(f, t->namespace);
546 }
547 indent(f, 0);
549 fprintf(f, ";\n");
550 if(in_namespace) {
551 t->written = save_written;
552 write_namespace_end(f, t->namespace);
553 fprintf(f, "extern \"C\" {\n");
554 fprintf(f, "#else\n");
556 fprintf(f, ";\n");
557 fprintf(f, "#endif\n\n");
558 }
559}
@ NAME_C
Definition: typetree.h:29

Referenced by write_header_stmts().

◆ write_type_left()

void write_type_left ( FILE h,
type_t t,
enum name_type name_type name_type  ,
int  declonly 
)

Definition at line 297 of file header.c.

298{
299 const char *name;
300
301 if (!h) return;
302
304
305 if (is_attr(t->attrs, ATTR_CONST) &&
306 (type_is_alias(t) || !is_ptr(t)))
307 fprintf(h, "const ");
308
309 if (type_is_alias(t)) fprintf(h, "%s", t->name);
310 else {
311 switch (type_get_type_detect_alias(t)) {
312 case TYPE_ENUM:
313 if (!declonly && t->defined && !t->written) {
314 if (name) fprintf(h, "enum %s {\n", name);
315 else fprintf(h, "enum {\n");
316 t->written = TRUE;
317 indentation++;
319 indent(h, -1);
320 fprintf(h, "}");
321 }
322 else fprintf(h, "enum %s", name ? name : "");
323 break;
324 case TYPE_STRUCT:
326 if (!declonly && t->defined && !t->written) {
327 if (name) fprintf(h, "struct %s {\n", name);
328 else fprintf(h, "struct {\n");
329 t->written = TRUE;
330 indentation++;
333 else
335 indent(h, -1);
336 fprintf(h, "}");
337 }
338 else fprintf(h, "struct %s", name ? name : "");
339 break;
340 case TYPE_UNION:
341 if (!declonly && t->defined && !t->written) {
342 if (t->name) fprintf(h, "union %s {\n", t->name);
343 else fprintf(h, "union {\n");
344 t->written = TRUE;
345 indentation++;
347 indent(h, -1);
348 fprintf(h, "}");
349 }
350 else fprintf(h, "union %s", t->name ? t->name : "");
351 break;
352 case TYPE_POINTER:
353 {
356 if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const ");
357 break;
358 }
359 case TYPE_ARRAY:
360 if (t->name && type_array_is_decl_as_ptr(t))
361 fprintf(h, "%s", t->name);
362 else
363 {
367 }
368 break;
369 case TYPE_BASIC:
374 {
375 if (type_basic_get_sign(t) < 0) fprintf(h, "signed ");
376 else if (type_basic_get_sign(t) > 0) fprintf(h, "unsigned ");
377 }
378 switch (type_basic_get_type(t))
379 {
380 case TYPE_BASIC_INT8: fprintf(h, "small"); break;
381 case TYPE_BASIC_INT16: fprintf(h, "short"); break;
382 case TYPE_BASIC_INT: fprintf(h, "int"); break;
383 case TYPE_BASIC_INT3264: fprintf(h, "__int3264"); break;
384 case TYPE_BASIC_BYTE: fprintf(h, "byte"); break;
385 case TYPE_BASIC_CHAR: fprintf(h, "char"); break;
386 case TYPE_BASIC_WCHAR: fprintf(h, "wchar_t"); break;
387 case TYPE_BASIC_FLOAT: fprintf(h, "float"); break;
388 case TYPE_BASIC_DOUBLE: fprintf(h, "double"); break;
389 case TYPE_BASIC_ERROR_STATUS_T: fprintf(h, "error_status_t"); break;
390 case TYPE_BASIC_HANDLE: fprintf(h, "handle_t"); break;
391 case TYPE_BASIC_INT32:
392 if (type_basic_get_sign(t) > 0)
393 fprintf(h, "UINT32");
394 else
395 fprintf(h, "INT32");
396 break;
397 case TYPE_BASIC_LONG:
398 if (type_basic_get_sign(t) > 0)
399 fprintf(h, "ULONG");
400 else
401 fprintf(h, "LONG");
402 break;
403 case TYPE_BASIC_INT64:
404 if (type_basic_get_sign(t) > 0)
405 fprintf(h, "UINT64");
406 else
407 fprintf(h, "INT64");
408 break;
409 case TYPE_BASIC_HYPER:
410 if (type_basic_get_sign(t) > 0)
411 fprintf(h, "MIDL_uhyper");
412 else
413 fprintf(h, "hyper");
414 break;
415 }
416 break;
417 case TYPE_INTERFACE:
418 case TYPE_MODULE:
419 case TYPE_COCLASS:
420 fprintf(h, "%s", t->name);
421 break;
422 case TYPE_VOID:
423 fprintf(h, "void");
424 break;
425 case TYPE_BITFIELD:
427 break;
428 case TYPE_ALIAS:
429 case TYPE_FUNCTION:
430 /* handled elsewhere */
431 assert(0);
432 break;
433 }
434 }
435}
#define assert(x)
Definition: debug.h:53
static void write_pointer_left(FILE *h, type_t *ref)
Definition: header.c:288
static void write_fields(FILE *h, var_list_t *fields)
Definition: header.c:197
static void write_enums(FILE *h, var_list_t *enums, const char *enum_name)
Definition: header.c:260
const char * type_get_name(const type_t *type, enum name_type name_type)
Definition: typetree.c:81
static int type_basic_get_sign(const type_t *type)
Definition: typetree.h:80
static type_t * type_bitfield_get_field(const type_t *type)
Definition: typetree.h:306
name_type
Definition: typetree.h:27
static var_list_t * type_encapsulated_union_get_fields(const type_t *type)
Definition: typetree.h:127
@ TYPE_BITFIELD
Definition: widltypes.h:415
@ TYPE_ALIAS
Definition: widltypes.h:408
@ TYPE_POINTER
Definition: widltypes.h:413
@ TYPE_MODULE
Definition: widltypes.h:409
@ TYPE_ARRAY
Definition: widltypes.h:414
@ TYPE_BASIC_DOUBLE
Definition: widltypes.h:275
@ TYPE_BASIC_INT32
Definition: widltypes.h:265
@ TYPE_BASIC_ERROR_STATUS_T
Definition: widltypes.h:276
@ TYPE_BASIC_CHAR
Definition: widltypes.h:270
@ TYPE_BASIC_WCHAR
Definition: widltypes.h:273
@ TYPE_BASIC_INT16
Definition: widltypes.h:264
@ TYPE_BASIC_HYPER
Definition: widltypes.h:271
@ TYPE_BASIC_INT8
Definition: widltypes.h:263
@ TYPE_BASIC_INT3264
Definition: widltypes.h:268
@ TYPE_BASIC_LONG
Definition: widltypes.h:269
@ TYPE_BASIC_INT64
Definition: widltypes.h:266
@ TYPE_BASIC_BYTE
Definition: widltypes.h:272
@ TYPE_BASIC_INT
Definition: widltypes.h:267
@ TYPE_BASIC_FLOAT
Definition: widltypes.h:274

Referenced by write_expr_eval_routines(), write_func_param_struct(), write_type_decl_left(), write_type_definition(), write_type_left(), and write_type_v().

◆ write_type_right()

void write_type_right ( FILE h,
type_t t,
int  is_field 
)

Definition at line 437 of file header.c.

438{
439 if (!h) return;
440 if (type_is_alias(t)) return;
441
442 switch (type_get_type(t))
443 {
444 case TYPE_ARRAY:
445 {
448 {
450 fprintf(h, ")");
451 }
452 else
453 {
455 fprintf(h, "[%s]", is_field ? "1" : "");
456 else
457 fprintf(h, "[%u]", type_array_get_dim(t));
458 }
460 break;
461 }
462 case TYPE_POINTER:
463 {
466 fprintf(h, ")");
468 break;
469 }
470 case TYPE_BITFIELD:
472 break;
473 case TYPE_VOID:
474 case TYPE_BASIC:
475 case TYPE_ENUM:
476 case TYPE_STRUCT:
478 case TYPE_UNION:
479 case TYPE_ALIAS:
480 case TYPE_MODULE:
481 case TYPE_COCLASS:
482 case TYPE_FUNCTION:
483 case TYPE_INTERFACE:
484 break;
485 }
486}
static int is_conformant_array(const type_t *t)
Definition: header.h:79
static size_t elem
Definition: string.c:68
void write_type_right(FILE *h, type_t *t, int is_field)
Definition: header.c:437
static const expr_t * type_bitfield_get_bits(const type_t *type)
Definition: typetree.h:313
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:232

Referenced by declare_stub_args(), write_type_right(), and write_type_v().

◆ write_type_v()

static void write_type_v ( FILE h,
type_t t,
int  is_field,
int  declonly,
const char name 
)
static

Definition at line 488 of file header.c.

489{
490 type_t *pt = NULL;
491 int ptr_level = 0;
492
493 if (!h) return;
494
495 if (t) {
496 for (pt = t; is_ptr(pt); pt = type_pointer_get_ref(pt), ptr_level++)
497 ;
498
500 int i;
501 const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV);
502 if (!callconv && is_object_interface) callconv = "STDMETHODCALLTYPE";
503 if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline ");
505 fputc(' ', h);
506 if (ptr_level) fputc('(', h);
507 if (callconv) fprintf(h, "%s ", callconv);
508 for (i = 0; i < ptr_level; i++)
509 fputc('*', h);
510 } else
511 write_type_left(h, t, NAME_DEFAULT, declonly);
512 }
513
514 if (name) fprintf(h, "%s%s", !t || needs_space_after(t) ? " " : "", name );
515
516 if (t) {
519
520 if (ptr_level) fputc(')', h);
521 fputc('(', h);
522 if (args)
523 write_args(h, args, NULL, 0, FALSE);
524 else
525 fprintf(h, "void");
526 fputc(')', h);
527 } else
528 write_type_right(h, t, is_field);
529 }
530}
#define pt(x, y)
Definition: drawing.c:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
static var_list_t * type_function_get_args(const type_t *type)
Definition: typetree.h:94
@ ATTR_INLINE
Definition: widltypes.h:119

Referenced by write_type_decl(), and write_type_def_or_decl().

◆ write_typedef()

static void write_typedef ( FILE header,
type_t type 
)
static

Definition at line 794 of file header.c.

795{
796 fprintf(header, "typedef ");
798 fprintf(header, ";\n");
799}

Referenced by write_header_stmts().

◆ write_user_types()

static void write_user_types ( FILE header)
static

Definition at line 760 of file header.c.

761{
762 user_type_t *ut;
764 {
765 const char *name = ut->name;
766 fprintf(header, "ULONG __RPC_USER %s_UserSize (ULONG *, ULONG, %s *);\n", name, name);
767 fprintf(header, "unsigned char * __RPC_USER %s_UserMarshal (ULONG *, unsigned char *, %s *);\n", name, name);
768 fprintf(header, "unsigned char * __RPC_USER %s_UserUnmarshal(ULONG *, unsigned char *, %s *);\n", name, name);
769 fprintf(header, "void __RPC_USER %s_UserFree (ULONG *, %s *);\n", name, name);
770 }
771}

Referenced by write_header().

◆ write_uuid_decl()

static void write_uuid_decl ( FILE f,
type_t type,
const UUID uuid 
)
static

Definition at line 133 of file header.c.

134{
135 char *name = format_namespace(type->namespace, "", "::", type->name);
136 fprintf(f, "#ifdef __CRT_UUID_DECL\n");
137 fprintf(f, "__CRT_UUID_DECL(%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
138 "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n",
139 name, uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
140 uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
141 uuid->Data4[7]);
142 fprintf(f, "#endif\n");
143 free(name);
144}
char * format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix)
Definition: typetree.c:110

Referenced by write_coclass(), and write_com_interface_end().

Variable Documentation

◆ context_handle_list

◆ generic_handle_list

◆ indentation

int indentation = 0
static

◆ is_object_interface

int is_object_interface = 0
static

Definition at line 41 of file header.c.

Referenced by write_header_stmts(), and write_type_v().

◆ user_type_list