ReactOS 0.4.16-dev-1946-g52006dd
header.h File Reference
#include "typetree.h"
Include dependency graph for header.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const charget_name (const var_t *v)
 
void write_type_left (FILE *h, const decl_spec_t *ds, enum name_type name_type, bool define, int write_callconv)
 
void write_type_right (FILE *h, type_t *t, int is_field)
 
void write_type_decl (FILE *f, const decl_spec_t *t, const char *name)
 
void write_type_decl_left (FILE *f, const decl_spec_t *ds)
 
unsigned int get_context_handle_offset (const type_t *type)
 
unsigned int get_generic_handle_offset (const type_t *type)
 
int needs_space_after (type_t *t)
 
int is_object (const type_t *iface)
 
int is_local (const attr_list_t *list)
 
int count_methods (const type_t *iface)
 
const statement_tget_callas_source (const type_t *iface, const var_t *def)
 
int need_stub (const type_t *iface)
 
int need_proxy (const type_t *iface)
 
int need_inline_stubs (const type_t *iface)
 
int need_stub_files (const statement_list_t *stmts)
 
int need_proxy_file (const statement_list_t *stmts)
 
int need_proxy_delegation (const statement_list_t *stmts)
 
int need_inline_stubs_file (const statement_list_t *stmts)
 
const var_tis_callas (const attr_list_t *list)
 
void write_args (FILE *h, const var_list_t *arg, const char *name, int obj, int do_indent, enum name_type name_type)
 
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_const_decl (const var_t *var)
 
void write_serialize_functions (FILE *file, const type_t *type, const type_t *iface)
 
static int is_ptr (const type_t *t)
 
static int is_array (const type_t *t)
 
static int is_func (const type_t *t)
 
static int is_void (const type_t *t)
 
static int is_declptr (const type_t *t)
 
static int is_conformant_array (const type_t *t)
 
static int last_ptr (const type_t *type)
 
static int last_array (const type_t *type)
 
static int is_string_type (const attr_list_t *attrs, const type_t *type)
 
static int is_context_handle (const type_t *type)
 

Function Documentation

◆ count_methods()

int count_methods ( const type_t iface)

Definition at line 460 of file proxy.c.

461{
462 const statement_t *stmt;
463 int count = 0;
464
465 if (type_iface_get_inherit(iface))
467
469 const var_t *func = stmt->u.var;
470 if (!is_callas(func->attrs)) count++;
471 }
472 return count;
473}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum func
Definition: glext.h:6028
const var_t * is_callas(const attr_list_t *a)
Definition: header.c:987
int count_methods(const type_t *iface)
Definition: proxy.c:460
var_t * var
Definition: widltypes.h:631
union _statement_t::@5358 u
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:208
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:201
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:684

Referenced by count_methods(), write_iface_procformatstring(), write_interface(), and write_proxy().

◆ get_callas_source()

const statement_t * get_callas_source ( const type_t iface,
const var_t def 
)

Definition at line 475 of file proxy.c.

476{
477 const statement_t * source;
479 const var_t * cas = is_callas(source->u.var->attrs );
480 if (cas && !strcmp(def->name, cas->name))
481 return source;
482 }
483 return NULL;
484}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define NULL
Definition: types.h:112
char * name
Definition: widltypes.h:541

Referenced by write_iface_procformatstring(), write_proxy_methods(), write_proxy_procformatstring_offsets(), write_stub_methods(), and write_thunk_methods().

◆ get_context_handle_offset()

unsigned int get_context_handle_offset ( const type_t type)

Definition at line 625 of file header.c.

626{
628 unsigned int index = 0;
629
630 while (!is_attr( type->attrs, ATTR_CONTEXTHANDLE ))
631 {
634 else error( "internal error: %s is not a context handle\n", type->name );
635 }
637 {
638 if (!strcmp( type->name, ch->name )) return index;
639 index++;
640 }
641 error( "internal error: %s is not registered as a context handle\n", type->name );
642 return index;
643}
#define index(s, c)
Definition: various.h:29
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
uint32_t entry
Definition: isohybrid.c:63
#define error(str)
Definition: mkdosfs.c:1605
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
int is_attr(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:45
static int is_ptr(const type_t *t)
Definition: header.h:55
const char * name
Definition: widltypes.h:621
static type_t * type_alias_get_aliasee_type(const type_t *type)
Definition: typetree.h:373
static type_t * type_pointer_get_ref_type(const type_t *type)
Definition: typetree.h:424
static int type_is_alias(const type_t *type)
Definition: typetree.h:357
@ ATTR_CONTEXTHANDLE
Definition: widltypes.h:89

Referenced by write_contexthandle_tfs(), and write_proc_func_interp().

◆ get_explicit_generic_handle_type()

const type_t * get_explicit_generic_handle_type ( const var_t var)

Definition at line 899 of file header.c.

900{
901 const type_t *t;
902 for (t = var->declspec.type;
903 is_ptr(t) || type_is_alias(t);
906 is_attr(t->attrs, ATTR_HANDLE))
907 return t;
908 return NULL;
909}
return
Definition: dirsup.c:529
GLdouble GLdouble t
Definition: gl.h:2047
if(dx< 0)
Definition: linetemp.h:194
const char * var
Definition: shader.c:5666
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:118
@ TYPE_BASIC
Definition: widltypes.h:479
@ ATTR_HANDLE
Definition: widltypes.h:118
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:679
@ TYPE_BASIC_HANDLE
Definition: widltypes.h:310

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 911 of file header.c.

913{
914 const var_t *var;
915 const var_list_t *args = type_function_get_args( func->declspec.type );
916
917 *explicit_fc = *implicit_fc = 0;
918 if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
919 {
920 if (!is_attr( var->attrs, ATTR_IN ) && is_attr( var->attrs, ATTR_OUT )) continue;
921 if (type_get_type( var->declspec.type ) == TYPE_BASIC && type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE)
922 {
923 *explicit_fc = FC_BIND_PRIMITIVE;
924 return var;
925 }
927 {
928 *explicit_fc = FC_BIND_GENERIC;
929 return var;
930 }
931 if (is_context_handle( var->declspec.type ))
932 {
933 *explicit_fc = FC_BIND_CONTEXT;
934 return var;
935 }
936 }
937
938 if ((var = get_attrp( iface->attrs, ATTR_IMPLICIT_HANDLE )))
939 {
940 if (type_get_type( var->declspec.type ) == TYPE_BASIC &&
941 type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE)
942 *implicit_fc = FC_BIND_PRIMITIVE;
943 else
944 *implicit_fc = FC_BIND_GENERIC;
945 return var;
946 }
947
948 *implicit_fc = FC_AUTO_HANDLE;
949 return NULL;
950}
Definition: list.h:37
@ 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
void * get_attrp(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:87
const type_t * get_explicit_generic_handle_type(const var_t *var)
Definition: header.c:899
static int is_context_handle(const type_t *type)
Definition: header.h:101
attr_list_t * attrs
Definition: widltypes.h:503
Definition: match.c:390
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113
static var_list_t * type_function_get_args(const type_t *type)
Definition: typetree.h:139
@ ATTR_IN
Definition: widltypes.h:131
@ ATTR_IMPLICIT_HANDLE
Definition: widltypes.h:130
@ ATTR_OUT
Definition: widltypes.h:151

Referenced by write_function_stub(), and write_proc_func_interp().

◆ get_generic_handle_offset()

unsigned int get_generic_handle_offset ( const type_t type)

Definition at line 645 of file header.c.

646{
648 unsigned int index = 0;
649
650 while (!is_attr( type->attrs, ATTR_HANDLE ))
651 {
654 else error( "internal error: %s is not a generic handle\n", type->name );
655 }
657 {
658 if (!strcmp( type->name, gh->name )) return index;
659 index++;
660 }
661 error( "internal error: %s is not registered as a generic handle\n", type->name );
662 return index;
663}
generic_handle_list_t generic_handle_list
Definition: header.c:41

Referenced by write_proc_func_interp().

◆ get_name()

const char * get_name ( const var_t v)

Definition at line 143 of file header.c.

144{
145 static char *buffer;
146 free( buffer );
147 if (is_attr( v->attrs, ATTR_EVENTADD ))
148 return buffer = strmake( "add_%s", v->name );
149 if (is_attr( v->attrs, ATTR_EVENTREMOVE ))
150 return buffer = strmake( "remove_%s", v->name );
151 if (is_attr( v->attrs, ATTR_PROPGET ))
152 return buffer = strmake( "get_%s", v->name );
153 if (is_attr( v->attrs, ATTR_PROPPUT ))
154 return buffer = strmake( "put_%s", v->name );
155 if (is_attr( v->attrs, ATTR_PROPPUTREF ))
156 return buffer = strmake( "putref_%s", v->name );
157 buffer = NULL;
158 return v->name;
159}
#define free
Definition: debug_ros.c:5
const GLdouble * v
Definition: gl.h:2040
GLuint buffer
Definition: glext.h:5915
char * strmake(size_t *lenp,...)
Definition: util.c:82
char * name
Definition: compiler.c:66
@ ATTR_EVENTREMOVE
Definition: widltypes.h:112
@ ATTR_PROPPUT
Definition: widltypes.h:159
@ ATTR_PROPPUTREF
Definition: widltypes.h:160
@ ATTR_EVENTADD
Definition: widltypes.h:111
@ ATTR_PROPGET
Definition: widltypes.h:158

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(), write_method_proto(), write_parameterized_implementation(), and write_widl_using_method_macros().

◆ has_out_arg_or_return()

int has_out_arg_or_return ( const var_t func)

Definition at line 952 of file header.c.

953{
954 const var_t *var;
955
956 if (!is_void(type_function_get_rettype(func->declspec.type)))
957 return 1;
958
959 if (!type_function_get_args(func->declspec.type))
960 return 0;
961
963 if (is_attr(var->attrs, ATTR_OUT))
964 return 1;
965
966 return 0;
967}
static int is_void(const type_t *t)
Definition: header.h:70
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:158

Referenced by write_function_stub().

◆ is_array()

◆ is_callas()

◆ is_conformant_array()

◆ is_const_decl()

int is_const_decl ( const var_t var)

Definition at line 845 of file header.c.

846{
847 const decl_spec_t *t;
848 /* strangely, MIDL accepts a const attribute on any pointer in the
849 * declaration to mean that data isn't being instantiated. this appears
850 * to be a bug, but there is no benefit to being incompatible with MIDL,
851 * so we'll do the same thing */
852 for (t = &var->declspec; ; )
853 {
854 if (t->qualifier & TYPE_QUALIFIER_CONST)
855 return TRUE;
856 else if (is_ptr(t->type))
857 t = type_pointer_get_ref(t->type);
858 else break;
859 }
860 return FALSE;
861}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const decl_spec_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:417
@ TYPE_QUALIFIER_CONST
Definition: widltypes.h:255

Referenced by write_declaration().

◆ is_context_handle()

static int is_context_handle ( const type_t type)
inlinestatic

Definition at line 101 of file header.h.

102{
103 const type_t *t;
104 for (t = type;
105 is_ptr(t) || type_is_alias(t);
107 if (is_attr(t->attrs, ATTR_CONTEXTHANDLE))
108 return 1;
109 return 0;
110}

Referenced by declare_stub_args(), get_func_handle_var(), and write_function_stub().

◆ is_declptr()

static int is_declptr ( const type_t t)
inlinestatic

Definition at line 75 of file header.h.

76{
78}
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:350

Referenced by get_parameter_fc(), last_ptr(), write_nonsimple_pointer(), write_remoting_arg(), and write_string_tfs().

◆ is_func()

static int is_func ( const type_t t)
inlinestatic

Definition at line 65 of file header.h.

66{
67 return type_get_type(t) == TYPE_FUNCTION;
68}
@ TYPE_FUNCTION
Definition: widltypes.h:487

Referenced by decl_needs_parens().

◆ is_local()

◆ is_object()

int is_object ( const type_t iface)

Definition at line 972 of file header.c.

973{
974 const attr_t *attr;
975 if (type_is_defined(iface) && (type_get_type(iface) == TYPE_DELEGATE || type_iface_get_inherit(iface)))
976 return 1;
977 if (iface->attrs) LIST_FOR_EACH_ENTRY( attr, iface->attrs, const attr_t, entry )
978 if (attr->type == ATTR_OBJECT || attr->type == ATTR_ODL) return 1;
979 return 0;
980}
Definition: cookie.c:202
static int type_is_defined(const type_t *type)
Definition: typetree.h:250
@ TYPE_DELEGATE
Definition: widltypes.h:496
@ ATTR_OBJECT
Definition: widltypes.h:146
@ ATTR_ODL
Definition: widltypes.h:147

Referenced by fill_params_array(), 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_interp(), and write_typelib_interface().

◆ is_ptr()

◆ is_string_type()

static int is_string_type ( const attr_list_t attrs,
const type_t type 
)
inlinestatic

Definition at line 95 of file header.h.

96{
98 && (last_ptr(type) || last_array(type)));
99}
int is_aliaschain_attr(const type_t *type, enum attr_type attr_type)
Definition: attribute.c:67
static int last_ptr(const type_t *type)
Definition: header.h:85
static int last_array(const type_t *type)
Definition: header.h:90
@ ATTR_STRING
Definition: widltypes.h:174

Referenced by builtin_vt(), get_parameter_fc(), get_required_buffer_size(), get_required_buffer_size_type(), get_struct_fc(), typegen_detect_type(), write_array_element_type(), write_array_tfs(), write_pointer_description_offsets(), write_simple_pointer(), and write_struct_tfs().

◆ is_void()

◆ last_array()

static int last_array ( const type_t type)
inlinestatic

Definition at line 90 of file header.h.

91{
93}
static type_t * type_array_get_element_type(const type_t *type)
Definition: typetree.h:345

Referenced by is_string_type().

◆ last_ptr()

static int last_ptr ( const type_t type)
inlinestatic

Definition at line 85 of file header.h.

86{
88}
static int is_declptr(const type_t *t)
Definition: header.h:75

Referenced by is_string_type().

◆ need_inline_stubs()

int need_inline_stubs ( const type_t iface)

Definition at line 814 of file proxy.c.

815{
816 const statement_t *stmt;
817
818 if (!interpreted_mode) return 1;
819
821 {
822 const var_t *func = stmt->u.var;
823 if (is_local( func->attrs )) continue;
824 if (!is_interpreted_func( iface, func )) return 1;
825 }
826 return 0;
827}
int is_local(const attr_list_t *a)
Definition: header.c:982
int is_interpreted_func(const type_t *iface, const var_t *func)
Definition: typegen.c:1352
int interpreted_mode
Definition: widl.c:112

Referenced by need_inline_stubs_file(), and write_proxy().

◆ need_inline_stubs_file()

int need_inline_stubs_file ( const statement_list_t stmts)

Definition at line 850 of file proxy.c.

851{
852 return does_any_iface(stmts, need_inline_stubs);
853}
static int does_any_iface(const statement_list_t *stmts, type_pred_t pred)
Definition: proxy.c:774
int need_inline_stubs(const type_t *iface)
Definition: proxy.c:814

Referenced by write_client_routines(), and write_server_routines().

◆ need_proxy()

int need_proxy ( const type_t iface)

Definition at line 791 of file proxy.c.

792{
793 if (!is_object( iface )) return 0;
794 if (is_local( iface->attrs )) return 0;
795 if (is_attr( iface->attrs, ATTR_DISPINTERFACE )) return 0;
796 return 1;
797}
int is_object(const type_t *iface)
Definition: header.c:972
@ ATTR_DISPINTERFACE
Definition: widltypes.h:103

Referenced by build_iface_list(), need_proxy_and_inline_stubs(), need_proxy_file(), write_proxy_routines(), and write_proxy_stmts().

◆ need_proxy_delegation()

int need_proxy_delegation ( const statement_list_t stmts)

Definition at line 809 of file proxy.c.

810{
811 return does_any_iface(stmts, need_delegation);
812}
static int need_delegation(const type_t *iface)
Definition: proxy.c:123

Referenced by write_dlldata().

◆ need_proxy_file()

int need_proxy_file ( const statement_list_t stmts)

Definition at line 804 of file proxy.c.

805{
806 return does_any_iface(stmts, need_proxy);
807}
int need_proxy(const type_t *iface)
Definition: proxy.c:791

Referenced by write_dlldata(), write_proxies(), and write_regscript().

◆ need_stub()

int need_stub ( const type_t iface)

Definition at line 799 of file proxy.c.

800{
801 return !is_object(iface) && !is_local(iface->attrs);
802}

Referenced by need_stub_files(), write_client_ifaces(), write_client_routines(), write_server_routines(), and write_server_stmts().

◆ need_stub_files()

int need_stub_files ( const statement_list_t stmts)

Definition at line 845 of file proxy.c.

846{
847 return does_any_iface(stmts, need_stub);
848}
int need_stub(const type_t *iface)
Definition: proxy.c:799

Referenced by write_client(), and write_server().

◆ needs_space_after()

int needs_space_after ( type_t t)

Definition at line 252 of file header.c.

253{
254 return (type_is_alias(t) ||
255 (!is_ptr(t) && (!is_array(t) || !type_array_is_decl_as_ptr(t) || t->name)));
256}

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

◆ write_args()

void write_args ( FILE h,
const var_list_t arg,
const char name,
int  obj,
int  do_indent,
enum name_type  name_type 
)

Definition at line 1103 of file header.c.

1104{
1105 const var_t *arg;
1106 int count = 0;
1107
1108 if (do_indent)
1109 {
1110 indentation++;
1111 indent(h, 0);
1112 }
1113 if (method == 1) {
1114 fprintf(h, "%s* This", name);
1115 count++;
1116 }
1117 if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) {
1118 if (count) {
1119 if (do_indent)
1120 {
1121 fprintf(h, ",\n");
1122 indent(h, 0);
1123 }
1124 else fprintf(h, ",");
1125 }
1126 /* In theory we should be writing the definition using write_type_v(..., arg->define),
1127 * but that causes redefinition in e.g. proxy files. In fact MIDL disallows
1128 * defining UDTs inside of an argument list. */
1129 write_type_v(h, &arg->declspec, FALSE, false, arg->name, name_type);
1130 if (method == 2) {
1131 const expr_t *expr = get_attrp(arg->attrs, ATTR_DEFAULTVALUE);
1132 if (expr) {
1133 const var_t *tail_arg;
1134
1135 /* Output default value only if all following arguments also have default value. */
1136 LIST_FOR_EACH_ENTRY_REV( tail_arg, args, const var_t, entry ) {
1137 if(tail_arg == arg) {
1138 expr_t bstr;
1139
1140 /* Fixup the expression type for a BSTR like midl does. */
1141 if (get_type_vt(arg->declspec.type) == VT_BSTR && expr->type == EXPR_STRLIT)
1142 {
1143 bstr = *expr;
1144 bstr.type = EXPR_WSTRLIT;
1145 expr = &bstr;
1146 }
1147
1148 fprintf(h, " = ");
1149 write_expr( h, expr, 0, 1, NULL, NULL, "" );
1150 break;
1151 }
1152 if(!get_attrp(tail_arg->attrs, ATTR_DEFAULTVALUE))
1153 break;
1154 }
1155 }
1156 }
1157 count++;
1158 }
1159 if (do_indent) indentation--;
1160}
static const WCHAR indent[]
Definition: object.c:1156
@ 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:680
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define LIST_FOR_EACH_ENTRY_REV(elem, list, type, field)
Definition: list.h:222
static int indentation
Definition: header.c:37
static void write_type_v(FILE *f, const decl_spec_t *t, int is_field, bool define, const char *name, enum name_type name_type)
unsigned short get_type_vt(type_t *t)
Definition: typelib.c:124
enum expr_type type
Definition: widltypes.h:360
attr_list_t * attrs
Definition: widltypes.h:543
Definition: query.h:86
int type
Definition: query.h:87
Definition: name.c:39
name_type
Definition: typetree.h:30
@ EXPR_WSTRLIT
Definition: widltypes.h:227
@ EXPR_STRLIT
Definition: widltypes.h:226
@ ATTR_DEFAULTVALUE
Definition: widltypes.h:99
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(), write_parameterized_implementation(), and write_type_right().

◆ write_serialize_functions()

void write_serialize_functions ( FILE file,
const type_t type,
const type_t iface 
)

Definition at line 336 of file client.c.

337{
338 if (is_attr(type->attrs, ATTR_ENCODE))
339 {
340 write_serialize_function(file, type, iface, "AlignSize", "SIZE_T");
341 write_serialize_function(file, type, iface, "Encode", NULL);
342 }
343 if (is_attr(type->attrs, ATTR_DECODE))
344 {
345 write_serialize_function(file, type, iface, "Decode", NULL);
346 write_serialize_function(file, type, iface, "Free", NULL);
347 }
348}
static void write_serialize_function(FILE *file, const type_t *type, const type_t *iface, const char *func_name, const char *ret_type)
Definition: client.c:289
Definition: fci.c:127
@ ATTR_DECODE
Definition: widltypes.h:94
@ ATTR_ENCODE
Definition: widltypes.h:108

Referenced by write_function_stubs(), and write_serialize_function_decl().

◆ write_type_decl()

◆ write_type_decl_left()

void write_type_decl_left ( FILE f,
const decl_spec_t ds 
)

Definition at line 593 of file header.c.

594{
596}
#define ds
Definition: i386-dis.c:443
void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, bool define, int write_callconv)
Definition: header.c:282

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(), write_method_proto(), and write_parameterized_implementation().

◆ write_type_left()

void write_type_left ( FILE h,
const decl_spec_t ds,
enum name_type  name_type,
bool  define,
int  write_callconv 
)

Definition at line 282 of file header.c.

283{
284 type_t *t = ds->type;
285 const char *decl_name, *name;
286 char *args;
287
288 if (!h) return;
289
290 decl_name = type_get_decl_name(t, name_type);
292
293 if (ds->func_specifier & FUNCTION_SPECIFIER_INLINE)
294 fprintf(h, "inline ");
295
296 if ((ds->qualifier & TYPE_QUALIFIER_CONST) && (type_is_alias(t) || !is_ptr(t)))
297 fprintf(h, "const ");
298
299 if (type_is_alias(t)) fprintf(h, "%s", name);
300 else {
301 switch (type_get_type_detect_alias(t)) {
302 case TYPE_ENUM:
303 if (!define) fprintf(h, "enum %s", decl_name ? decl_name : "");
304 else if (!t->written) {
305 assert(t->defined);
306 if (decl_name) fprintf(h, "enum %s {\n", decl_name);
307 else fprintf(h, "enum {\n");
308 t->written = TRUE;
309 indentation++;
311 indent(h, -1);
312 fprintf(h, "}");
313 }
314 else if (winrt_mode && name_type == NAME_DEFAULT && name) fprintf(h, "%s", name);
315 else fprintf(h, "enum %s", name ? name : "");
316 break;
317 case TYPE_STRUCT:
319 if (!define) fprintf(h, "struct %s", decl_name ? decl_name : "");
320 else if (!t->written) {
321 assert(t->defined);
322 if (decl_name) fprintf(h, "struct %s {\n", decl_name);
323 else fprintf(h, "struct {\n");
324 t->written = TRUE;
325 indentation++;
328 else
330 indent(h, -1);
331 fprintf(h, "}");
332 }
333 else if (winrt_mode && name_type == NAME_DEFAULT && name) fprintf(h, "%s", name);
334 else fprintf(h, "struct %s", name ? name : "");
335 break;
336 case TYPE_UNION:
337 if (!define) fprintf(h, "union %s", decl_name ? decl_name : "");
338 else if (!t->written) {
339 assert(t->defined);
340 if (decl_name) fprintf(h, "union %s {\n", decl_name);
341 else fprintf(h, "union {\n");
342 t->written = TRUE;
343 indentation++;
345 indent(h, -1);
346 fprintf(h, "}");
347 }
348 else if (winrt_mode && name_type == NAME_DEFAULT && name) fprintf(h, "%s", name);
349 else fprintf(h, "union %s", name ? name : "");
350 break;
351 case TYPE_POINTER:
352 {
355 if (ds->qualifier & TYPE_QUALIFIER_CONST) fprintf(h, "const ");
356 break;
357 }
358 case TYPE_ARRAY:
359 if (t->name && type_array_is_decl_as_ptr(t))
360 fprintf(h, "%s", t->name);
361 else
362 {
366 }
367 break;
368 case TYPE_FUNCTION:
369 {
371
372 /* A pointer to a function has to write the calling convention inside
373 * the parentheses. There's no way to handle that here, so we have to
374 * use an extra parameter to tell us whether to write the calling
375 * convention or not. */
376 if (write_callconv)
377 {
378 const char *callconv = get_attrp(t->attrs, ATTR_CALLCONV);
379 if (!callconv && is_object_interface) callconv = "STDMETHODCALLTYPE";
380 if (callconv) fprintf(h, " %s ", callconv);
381 }
382 break;
383 }
384 case TYPE_BASIC:
389 {
390 if (type_basic_get_sign(t) < 0) fprintf(h, "signed ");
391 else if (type_basic_get_sign(t) > 0) fprintf(h, "unsigned ");
392 }
393 switch (type_basic_get_type(t))
394 {
395 case TYPE_BASIC_INT8: fprintf(h, "small"); break;
396 case TYPE_BASIC_INT16: fprintf(h, "short"); break;
397 case TYPE_BASIC_INT: fprintf(h, "int"); break;
398 case TYPE_BASIC_INT3264: fprintf(h, "__int3264"); break;
399 case TYPE_BASIC_BYTE: fprintf(h, "byte"); break;
400 case TYPE_BASIC_CHAR: fprintf(h, "char"); break;
401 case TYPE_BASIC_WCHAR: fprintf(h, "wchar_t"); break;
402 case TYPE_BASIC_FLOAT: fprintf(h, "float"); break;
403 case TYPE_BASIC_DOUBLE: fprintf(h, "double"); break;
404 case TYPE_BASIC_ERROR_STATUS_T: fprintf(h, "error_status_t"); break;
405 case TYPE_BASIC_HANDLE: fprintf(h, "handle_t"); break;
406 case TYPE_BASIC_INT32:
407 if (type_basic_get_sign(t) > 0)
408 fprintf(h, "UINT32");
409 else
410 fprintf(h, "INT32");
411 break;
412 case TYPE_BASIC_LONG:
413 if (type_basic_get_sign(t) > 0)
414 fprintf(h, "ULONG");
415 else
416 fprintf(h, "LONG");
417 break;
418 case TYPE_BASIC_INT64:
419 if (type_basic_get_sign(t) > 0)
420 fprintf(h, "UINT64");
421 else
422 fprintf(h, "INT64");
423 break;
424 case TYPE_BASIC_HYPER:
425 if (type_basic_get_sign(t) > 0)
426 fprintf(h, "MIDL_uhyper");
427 else
428 fprintf(h, "hyper");
429 break;
430 }
431 break;
432 case TYPE_INTERFACE:
433 case TYPE_MODULE:
434 case TYPE_COCLASS:
436 break;
439 break;
440 case TYPE_DELEGATE:
442 break;
443 case TYPE_VOID:
444 fprintf(h, "void");
445 break;
446 case TYPE_BITFIELD:
447 {
448 const decl_spec_t ds = {.type = type_bitfield_get_field(t)};
450 break;
451 }
452 case TYPE_ALIAS:
453 /* handled elsewhere */
454 assert(0);
455 break;
457 {
459 if (type_get_type(iface) == TYPE_DELEGATE) iface = type_delegate_get_iface(iface);
460 args = format_parameterized_type_args(t, "", "_logical");
461 fprintf(h, "%s<%s>", iface->name, args);
462 free(args);
463 break;
464 }
465 case TYPE_PARAMETER:
466 fprintf(h, "%s_abi", t->name);
467 break;
468 case TYPE_APICONTRACT:
469 /* shouldn't be here */
470 assert(0);
471 break;
472 }
473 }
474}
#define assert(x)
Definition: debug.h:53
#define args
Definition: format.c:66
static void write_pointer_left(FILE *h, type_t *ref)
Definition: header.c:267
static char * format_parameterized_type_args(const type_t *type, const char *prefix, const char *suffix)
Definition: header.c:68
static void write_fields(FILE *h, var_list_t *fields, enum name_type name_type)
Definition: header.c:161
static int is_object_interface
Definition: header.c:38
static void write_enums(FILE *h, var_list_t *enums, const char *enum_name)
Definition: header.c:227
const char * name
Definition: widltypes.h:500
const char * type_get_decl_name(const type_t *type, enum name_type name_type)
Definition: typetree.c:88
const char * type_get_name(const type_t *type, enum name_type name_type)
Definition: typetree.c:101
static type_t * type_runtimeclass_get_default_iface(const type_t *type, int check)
Definition: typetree.h:393
static const decl_spec_t * type_function_get_ret(const type_t *type)
Definition: typetree.h:153
static type_t * type_delegate_get_iface(const type_t *type)
Definition: typetree.h:410
static int type_basic_get_sign(const type_t *type)
Definition: typetree.h:125
static var_list_t * type_union_get_cases(const type_t *type)
Definition: typetree.h:184
static type_t * type_bitfield_get_field(const type_t *type)
Definition: typetree.h:435
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:132
static var_list_t * type_encapsulated_union_get_fields(const type_t *type)
Definition: typetree.h:177
static type_t * type_parameterized_type_get_real_type(const type_t *type)
Definition: typetree.h:105
static var_list_t * type_enum_get_values(const type_t *type)
Definition: typetree.h:163
static const decl_spec_t * type_array_get_element(const type_t *type)
Definition: typetree.h:338
int winrt_mode
Definition: widl.c:111
@ TYPE_PARAMETER
Definition: widltypes.h:495
@ TYPE_ENUM
Definition: widltypes.h:480
@ TYPE_BITFIELD
Definition: widltypes.h:491
@ TYPE_UNION
Definition: widltypes.h:483
@ TYPE_ALIAS
Definition: widltypes.h:484
@ TYPE_PARAMETERIZED_TYPE
Definition: widltypes.h:494
@ TYPE_ENCAPSULATED_UNION
Definition: widltypes.h:482
@ TYPE_COCLASS
Definition: widltypes.h:486
@ TYPE_STRUCT
Definition: widltypes.h:481
@ TYPE_MODULE
Definition: widltypes.h:485
@ TYPE_RUNTIMECLASS
Definition: widltypes.h:493
@ TYPE_INTERFACE
Definition: widltypes.h:488
@ TYPE_APICONTRACT
Definition: widltypes.h:492
@ ATTR_CALLCONV
Definition: widltypes.h:84
static int is_global_namespace(const struct namespace *namespace)
Definition: widltypes.h:701
@ TYPE_BASIC_DOUBLE
Definition: widltypes.h:308
@ TYPE_BASIC_INT32
Definition: widltypes.h:298
@ TYPE_BASIC_ERROR_STATUS_T
Definition: widltypes.h:309
@ TYPE_BASIC_CHAR
Definition: widltypes.h:303
@ TYPE_BASIC_WCHAR
Definition: widltypes.h:306
@ TYPE_BASIC_INT16
Definition: widltypes.h:297
@ TYPE_BASIC_HYPER
Definition: widltypes.h:304
@ TYPE_BASIC_INT8
Definition: widltypes.h:296
@ TYPE_BASIC_INT3264
Definition: widltypes.h:301
@ TYPE_BASIC_LONG
Definition: widltypes.h:302
@ TYPE_BASIC_INT64
Definition: widltypes.h:299
@ TYPE_BASIC_BYTE
Definition: widltypes.h:305
@ TYPE_BASIC_INT
Definition: widltypes.h:300
@ TYPE_BASIC_FLOAT
Definition: widltypes.h:307
@ FUNCTION_SPECIFIER_INLINE
Definition: widltypes.h:260

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 476 of file header.c.

477{
478 if (!h) return;
479 if (type_is_alias(t)) return;
480
481 switch (type_get_type(t))
482 {
483 case TYPE_ARRAY:
484 {
487 {
489 fprintf(h, ")");
490 }
491 else
492 {
494 fprintf(h, "[%s]", is_field ? "1" : "");
495 else
496 fprintf(h, "[%u]", type_array_get_dim(t));
497 }
499 break;
500 }
501 case TYPE_FUNCTION:
502 {
504 fputc('(', h);
506 else
507 fprintf(h, "void");
508 fputc(')', h);
510 break;
511 }
512 case TYPE_POINTER:
513 {
516 fprintf(h, ")");
518 break;
519 }
520 case TYPE_BITFIELD:
522 break;
523 case TYPE_VOID:
524 case TYPE_BASIC:
525 case TYPE_ENUM:
526 case TYPE_STRUCT:
528 case TYPE_UNION:
529 case TYPE_ALIAS:
530 case TYPE_MODULE:
531 case TYPE_COCLASS:
532 case TYPE_INTERFACE:
534 case TYPE_DELEGATE:
536 case TYPE_PARAMETER:
537 break;
538 case TYPE_APICONTRACT:
539 /* not supposed to be here */
540 assert(0);
541 break;
542 }
543}
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
static size_t elem
Definition: string.c:71
void write_type_right(FILE *h, type_t *t, int is_field)
Definition: header.c:476
static int decl_needs_parens(const type_t *t)
Definition: header.c:258
void write_args(FILE *h, const var_list_t *args, const char *name, int method, int do_indent, enum name_type name_type)
Definition: header.c:1103
static int is_conformant_array(const type_t *t)
Definition: header.h:80
Definition: send.c:48
static const expr_t * type_bitfield_get_bits(const type_t *type)
Definition: typetree.h:442
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:303

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