ReactOS 0.4.16-dev-1948-gd260c1d
client.c File Reference
#include "config.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 "widltypes.h"
#include "typegen.h"
#include "expr.h"
Include dependency graph for client.c:

Go to the source code of this file.

Functions

static void print_client (const char *format,...) __attribute__((format(printf
 
static void write_client_func_decl (const type_t *iface, const var_t *func)
 
static void write_function_stub (const type_t *iface, const var_t *func, int method_count, unsigned int proc_offset)
 
static void write_serialize_function (FILE *file, const type_t *type, const type_t *iface, const char *func_name, const char *ret_type)
 
void write_serialize_functions (FILE *file, const type_t *type, const type_t *iface)
 
static void write_function_stubs (type_t *iface, unsigned int *proc_offset)
 
static void write_stubdescdecl (type_t *iface)
 
static void write_stubdescriptor (type_t *iface, int expr_eval_routines)
 
static void write_clientinterfacedecl (type_t *iface)
 
static void write_implicithandledecl (type_t *iface)
 
static void init_client (void)
 
static void write_client_ifaces (const statement_list_t *stmts, int expr_eval_routines, unsigned int *proc_offset)
 
static void write_generic_handle_routine_list (void)
 
static void write_client_routines (const statement_list_t *stmts)
 
void write_client (const statement_list_t *stmts)
 

Variables

static FILEclient
 
static int indent = 0
 

Function Documentation

◆ init_client()

static void init_client ( void  )
static

Definition at line 495 of file client.c.

496{
497 if (client) return;
498 if (!(client = fopen(client_name, "w")))
499 error("Could not open %s for output\n", client_name);
500
501 print_client("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
502 print_client("#include <string.h>\n");
503 print_client( "\n");
504 print_client("#include \"%s\"\n", header_name);
505 print_client( "\n");
506}
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define error(str)
Definition: mkdosfs.c:1605
static FILE * client
Definition: client.c:37
static void print_client(const char *format,...) __attribute__((format(printf
Definition: client.c:41
char * client_name
Definition: widl.c:126
char * header_name
Definition: widl.c:119
char * input_name
Definition: widl.c:116

Referenced by write_client().

◆ print_client()

static void static void print_client ( const char format,
  ... 
)
static

Definition at line 41 of file client.c.

42{
43 va_list va;
44 va_start(va, format);
46 va_end(va);
47}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
Definition: print.c:438
static int indent
Definition: client.c:38
Definition: format.c:58

Referenced by init_client(), write_client_func_decl(), write_client_ifaces(), write_client_routines(), write_clientinterfacedecl(), write_function_stub(), write_function_stubs(), write_generic_handle_routine_list(), write_stubdescdecl(), and write_stubdescriptor().

◆ write_client()

void write_client ( const statement_list_t stmts)

Definition at line 613 of file client.c.

614{
615 if (!do_client)
616 return;
617 if (do_everything && !need_stub_files(stmts))
618 return;
619
620 init_client();
621 if (!client)
622 return;
623
624 write_client_routines( stmts );
625 fclose(client);
626}
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
static void init_client(void)
Definition: client.c:495
static void write_client_routines(const statement_list_t *stmts)
Definition: client.c:587
int need_stub_files(const statement_list_t *stmts)
Definition: proxy.c:845
int do_everything
Definition: widl.c:98
int do_client
Definition: widl.c:103

◆ write_client_func_decl()

static void write_client_func_decl ( const type_t iface,
const var_t func 
)
static

Definition at line 49 of file client.c.

50{
51 const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
52 const var_list_t *args = type_function_get_args(func->declspec.type);
53 const decl_spec_t *rettype = type_function_get_ret(func->declspec.type);
54
55 if (!callconv) callconv = "__cdecl";
57 fprintf(client, " %s ", callconv);
59 indent++;
60 if (args) write_args(client, args, iface->name, 0, TRUE, NAME_DEFAULT);
61 else
62 print_client("void");
63 fprintf(client, ")\n");
64 indent--;
65}
int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name)
Definition: util.c:55
Definition: list.h:37
#define TRUE
Definition: types.h:120
GLenum func
Definition: glext.h:6028
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void * get_attrp(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:87
void write_type_decl_left(FILE *f, const decl_spec_t *ds)
Definition: header.c:593
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
const char * name
Definition: widltypes.h:500
Definition: match.c:390
static const decl_spec_t * type_function_get_ret(const type_t *type)
Definition: typetree.h:153
@ NAME_DEFAULT
Definition: typetree.h:31
static var_list_t * type_function_get_args(const type_t *type)
Definition: typetree.h:139
const char * prefix_client
Definition: widl.c:135
@ ATTR_CALLCONV
Definition: widltypes.h:84

Referenced by write_function_stub().

◆ write_client_ifaces()

static void write_client_ifaces ( const statement_list_t stmts,
int  expr_eval_routines,
unsigned int proc_offset 
)
static

Definition at line 509 of file client.c.

510{
511 const statement_t *stmt;
512 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
513 {
514 if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
515 {
516 int needs_stub = 0;
517 const statement_t *stmt2;
518 type_t *iface = stmt->u.type;
519 if (!need_stub(iface))
520 return;
521
522 fprintf(client, "/*****************************************************************************\n");
523 fprintf(client, " * %s interface\n", iface->name);
524 fprintf(client, " */\n");
525 fprintf(client, "\n");
526
528 {
529 if (stmt2->type == STMT_DECLARATION && stmt2->u.var->declspec.stgclass == STG_NONE &&
531 {
532 needs_stub = 1;
533 break;
534 }
535 if (stmt2->type == STMT_TYPEDEF)
536 {
537 typeref_t *ref;
539 {
540 if (is_attr(ref->type->attrs, ATTR_ENCODE)
541 || is_attr(ref->type->attrs, ATTR_DECODE))
542 {
543 needs_stub = 1;
544 break;
545 }
546 }
547 if (needs_stub)
548 break;
549 }
550 }
551 if (needs_stub)
552 {
554
556 write_stubdescdecl(iface);
557 write_function_stubs(iface, proc_offset);
558
559 print_client("#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32);
560 print_client("#error Invalid build platform for this stub.\n");
561 print_client("#endif\n");
562
563 fprintf(client, "\n");
565 }
566 }
567 }
568}
uint32_t entry
Definition: isohybrid.c:63
#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 void write_stubdescdecl(type_t *iface)
Definition: client.c:387
static void write_clientinterfacedecl(type_t *iface)
Definition: client.c:440
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
Definition: client.c:350
static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
Definition: client.c:394
static void write_implicithandledecl(type_t *iface)
Definition: client.c:483
int need_stub(const type_t *iface)
Definition: proxy.c:799
type_t * type
Definition: widltypes.h:334
enum storage_class stgclass
Definition: widltypes.h:335
statement_type_t type
Definition: parser.h:124
var_t * var
Definition: widltypes.h:631
typeref_list_t * type_list
Definition: widltypes.h:633
union _statement_t::@5358 u
decl_spec_t declspec
Definition: widltypes.h:542
Definition: send.c:48
static struct list expr_eval_routines
Definition: typegen.c:50
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:201
unsigned int pointer_size
Definition: widl.c:147
@ TYPE_INTERFACE
Definition: widltypes.h:488
@ TYPE_FUNCTION
Definition: widltypes.h:487
@ STG_NONE
Definition: widltypes.h:247
@ ATTR_DECODE
Definition: widltypes.h:94
@ ATTR_ENCODE
Definition: widltypes.h:108
@ STMT_TYPE
Definition: widltypes.h:267
@ STMT_DECLARATION
Definition: widltypes.h:266
@ STMT_TYPEDEF
Definition: widltypes.h:270
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:679

Referenced by write_client_routines().

◆ write_client_routines()

static void write_client_routines ( const statement_list_t stmts)
static

Definition at line 587 of file client.c.

588{
589 unsigned int proc_offset = 0;
591
592 if (need_inline_stubs_file( stmts ))
593 {
595 print_client( "\n");
596 }
597
604
605 write_client_ifaces(stmts, expr_eval_routines, &proc_offset);
606
607 fprintf(client, "\n");
608
611}
static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_routines, unsigned int *proc_offset)
Definition: client.c:509
static void write_generic_handle_routine_list(void)
Definition: client.c:570
int need_inline_stubs_file(const statement_list_t *stmts)
Definition: proxy.c:850
void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:1770
void write_user_quad_list(FILE *file)
Definition: typegen.c:5162
void write_expr_eval_routine_list(FILE *file, const char *iface)
Definition: typegen.c:5140
void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:4003
void write_exceptions(FILE *file)
Definition: typegen.c:5277
int write_expr_eval_routines(FILE *file, const char *iface)
Definition: typegen.c:5100
void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:1034
char * client_token
Definition: widl.c:127

Referenced by write_client().

◆ write_clientinterfacedecl()

static void write_clientinterfacedecl ( type_t iface)
static

Definition at line 440 of file client.c.

441{
442 unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
443 const struct uuid *uuid = get_attrp(iface->attrs, ATTR_UUID);
444 const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT);
445
446 if (endpoints) write_endpoints( client, iface->name, endpoints );
447
448 print_client("static const RPC_CLIENT_INTERFACE %s___RpcClientInterface =\n", iface->name );
449 print_client("{\n");
450 indent++;
451 print_client("sizeof(RPC_CLIENT_INTERFACE),\n");
452 print_client("{{0x%08x,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n",
453 uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
454 uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
455 uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver));
456 print_client("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
457 print_client("0,\n");
458 if (endpoints)
459 {
460 print_client("%u,\n", list_count(endpoints));
461 print_client("(PRPC_PROTSEQ_ENDPOINT)%s__RpcProtseqEndpoint,\n", iface->name);
462 }
463 else
464 {
465 print_client("0,\n");
466 print_client("0,\n");
467 }
468 print_client("0,\n");
469 print_client("0,\n");
470 print_client("0,\n");
471 indent--;
472 print_client("};\n");
473 if (old_names)
474 print_client("RPC_IF_HANDLE %s_ClientIfHandle = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
475 iface->name, iface->name);
476 else
477 print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
478 prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name);
479 fprintf(client, "\n");
480}
Definition: msctf.idl:532
unsigned short Data3
Definition: widltypes.h:34
unsigned int Data1
Definition: widltypes.h:32
unsigned char Data4[8]
Definition: widltypes.h:35
unsigned short Data2
Definition: widltypes.h:33
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
unsigned int get_attrv(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:78
#define MINORVERSION(version)
Definition: utils.h:49
#define MAJORVERSION(version)
Definition: utils.h:48
attr_list_t * attrs
Definition: widltypes.h:503
void write_endpoints(FILE *f, const char *prefix, const str_list_t *list)
Definition: typegen.c:5184
int old_names
Definition: widl.c:109
@ ATTR_UUID
Definition: widltypes.h:182
@ ATTR_VERSION
Definition: widltypes.h:185
@ ATTR_ENDPOINT
Definition: widltypes.h:109

Referenced by write_client_ifaces().

◆ write_function_stub()

static void write_function_stub ( const type_t iface,
const var_t func,
int  method_count,
unsigned int  proc_offset 
)
static

Definition at line 67 of file client.c.

69{
70 unsigned char explicit_fc, implicit_fc;
71 int has_full_pointer = is_full_pointer_function(func);
72 var_t *retval = type_function_get_retval(func->declspec.type);
73 const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
74 int has_ret = !is_void(retval->declspec.type);
75
76 if (is_interpreted_func( iface, func ))
77 {
79 write_client_call_routine( client, iface, func, iface->name, proc_offset );
80 return;
81 }
82
83 print_client( "struct __frame_%s%s\n{\n", prefix_client, get_name(func) );
84 indent++;
85 print_client( "__DECL_EXCEPTION_FRAME\n" );
86 print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
87 if (handle_var)
88 {
89 if (explicit_fc == FC_BIND_GENERIC)
90 print_client("%s %s;\n",
91 get_explicit_generic_handle_type(handle_var)->name, handle_var->name );
92 print_client("RPC_BINDING_HANDLE _Handle;\n");
93 }
94
95 if (has_ret && decl_indirect(retval->declspec.type))
96 {
97 print_client("void *_p_%s;\n", retval->name);
98 }
99 indent--;
100 print_client( "};\n\n" );
101
102 print_client( "static void __finally_%s%s(", prefix_client, get_name(func) );
103 print_client( " struct __frame_%s%s *__frame )\n{\n", prefix_client, get_name(func) );
104 indent++;
105
106 if (has_full_pointer)
108
109 if (interpreted_mode) print_client("NdrCorrelationFree(&__frame->_StubMsg);\n");
110 print_client("NdrFreeBuffer(&__frame->_StubMsg);\n");
111
112 if (explicit_fc == FC_BIND_GENERIC)
113 {
114 fprintf(client, "\n");
115 print_client("if (__frame->_Handle)\n");
116 indent++;
117 print_client("%s_unbind(__frame->%s, __frame->_Handle);\n",
118 get_explicit_generic_handle_type(handle_var)->name, handle_var->name);
119 indent--;
120 }
121 indent--;
122 print_client( "}\n\n" );
123
125
126 /* write the functions body */
127 fprintf(client, "{\n");
128 indent++;
129 print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(func) );
130
131 /* declare return value */
132 if (has_ret)
133 {
134 print_client("%s", "");
135 write_type_decl(client, &retval->declspec, retval->name);
136 fprintf(client, ";\n");
137 }
138 if (interpreted_mode) print_client("ULONG _NdrCorrCache[256];\n");
139 print_client("RPC_MESSAGE _RpcMessage;\n");
140
141 if (handle_var)
142 {
143 print_client( "__frame->_Handle = 0;\n" );
144 if (explicit_fc == FC_BIND_GENERIC)
145 print_client("__frame->%s = %s;\n", handle_var->name, handle_var->name );
146 }
147 if (has_ret && decl_indirect(retval->declspec.type))
148 {
149 print_client("__frame->_p_%s = &%s;\n", retval->name, retval->name);
150 }
151 fprintf(client, "\n");
152
153 print_client( "RpcExceptionInit( 0, __finally_%s%s );\n", prefix_client, get_name(func) );
154
155 if (has_full_pointer)
157
158 /* check pointers */
160
161 print_client("RpcTryFinally\n");
162 print_client("{\n");
163 indent++;
164
165 print_client("NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, &%s_StubDesc, %d);\n",
166 iface->name, method_count);
167
168 if (is_attr(func->attrs, ATTR_IDEMPOTENT) || is_attr(func->attrs, ATTR_BROADCAST))
169 {
170 print_client("_RpcMessage.RpcFlags = ( RPC_NCA_FLAGS_DEFAULT ");
171 if (is_attr(func->attrs, ATTR_IDEMPOTENT))
172 fprintf(client, "| RPC_NCA_FLAGS_IDEMPOTENT ");
173 if (is_attr(func->attrs, ATTR_BROADCAST))
174 fprintf(client, "| RPC_NCA_FLAGS_BROADCAST ");
175 fprintf(client, ");\n\n");
176 }
177
178 switch (explicit_fc)
179 {
181 print_client("__frame->_Handle = %s;\n", handle_var->name);
182 fprintf(client, "\n");
183 break;
184 case FC_BIND_GENERIC:
185 print_client("__frame->_Handle = %s_bind(%s);\n",
186 get_explicit_generic_handle_type(handle_var)->name, handle_var->name);
187 fprintf(client, "\n");
188 break;
189 case FC_BIND_CONTEXT:
190 {
191 /* if the context_handle attribute appears in the chain of types
192 * without pointers being followed, then the context handle must
193 * be direct, otherwise it is a pointer */
194 int is_ch_ptr = !is_aliaschain_attr(handle_var->declspec.type, ATTR_CONTEXTHANDLE);
195 print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", handle_var->name);
196 indent++;
197 print_client("__frame->_Handle = NDRCContextBinding(%s%s);\n",
198 is_ch_ptr ? "*" : "", handle_var->name);
199 indent--;
200 if (is_attr(handle_var->attrs, ATTR_IN) && !is_attr(handle_var->attrs, ATTR_OUT))
201 {
202 print_client("else\n");
203 indent++;
204 print_client("RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);\n");
205 indent--;
206 }
207 fprintf(client, "\n");
208 break;
209 }
210 case 0: /* implicit handle */
211 if (handle_var)
212 {
213 print_client("__frame->_Handle = %s;\n", handle_var->name);
214 fprintf(client, "\n");
215 }
216 break;
217 }
219 print_client( "NdrCorrelationInitialize(&__frame->_StubMsg, _NdrCorrCache, sizeof(_NdrCorrCache), 0);\n" );
220
222
223 print_client("NdrGetBuffer(&__frame->_StubMsg, __frame->_StubMsg.BufferLength, ");
224 if (handle_var)
225 fprintf(client, "__frame->_Handle);\n\n");
226 else
227 fprintf(client,"%s__MIDL_AutoBindHandle);\n\n", iface->name);
228
229 /* marshal arguments */
231
232 /* send/receive message */
233 /* print_client("NdrNsSendReceive(\n"); */
234 /* print_client("(unsigned char *)__frame->_StubMsg.Buffer,\n"); */
235 /* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */
236 print_client("NdrSendReceive(&__frame->_StubMsg, __frame->_StubMsg.Buffer);\n\n");
237
238 print_client("__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n");
239 print_client("__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n");
240
242 {
243 fprintf(client, "\n");
244
245 print_client("if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
246 indent++;
247 print_client("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
248 proc_offset);
249 indent--;
250 }
251
252 /* unmarshall arguments */
253 fprintf(client, "\n");
255
256 /* unmarshal return value */
257 if (has_ret)
258 {
259 if (decl_indirect(retval->declspec.type))
260 print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name);
261 else if (is_ptr(retval->declspec.type) || is_array(retval->declspec.type))
262 print_client("%s = 0;\n", retval->name);
264 }
265
266 indent--;
267 print_client("}\n");
268 print_client("RpcFinally\n");
269 print_client("{\n");
270 indent++;
271 print_client( "__finally_%s%s( __frame );\n", prefix_client, get_name(func) );
272 indent--;
273 print_client("}\n");
274 print_client("RpcEndFinally\n");
275
276
277 /* emit return code */
278 if (has_ret)
279 {
280 fprintf(client, "\n");
281 print_client("return %s;\n", retval->name);
282 }
283
284 indent--;
285 fprintf(client, "}\n");
286 fprintf(client, "\n");
287}
#define FALSE
Definition: types.h:117
@ FC_BIND_PRIMITIVE
Definition: ndrtypes.h:194
@ FC_BIND_GENERIC
Definition: ndrtypes.h:193
@ FC_BIND_CONTEXT
Definition: ndrtypes.h:191
int is_aliaschain_attr(const type_t *type, enum attr_type attr_type)
Definition: attribute.c:67
static void write_client_func_decl(const type_t *iface, const var_t *func)
Definition: client.c:49
int has_out_arg_or_return(const var_t *func)
Definition: header.c:952
const var_t * get_func_handle_var(const type_t *iface, const var_t *func, unsigned char *explicit_fc, unsigned char *implicit_fc)
Definition: header.c:911
void write_type_decl(FILE *f, const decl_spec_t *t, const char *name)
Definition: header.c:588
const type_t * get_explicit_generic_handle_type(const var_t *var)
Definition: header.c:899
static int is_void(const type_t *t)
Definition: header.h:70
static int is_ptr(const type_t *t)
Definition: header.h:55
static int is_array(const type_t *t)
Definition: header.h:60
char * name
Definition: widltypes.h:541
attr_list_t * attrs
Definition: widltypes.h:543
Definition: name.c:39
void write_pointer_checks(FILE *file, int indent, const var_t *func)
Definition: typegen.c:5088
void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server)
Definition: typegen.c:2356
int decl_indirect(const type_t *t)
Definition: typegen.c:1053
void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase)
Definition: typegen.c:4800
int is_full_pointer_function(const var_t *func)
Definition: typegen.c:2343
void write_client_call_routine(FILE *file, const type_t *iface, const var_t *func, const char *prefix, unsigned int proc_offset)
Definition: typegen.c:5218
int is_interpreted_func(const type_t *iface, const var_t *func)
Definition: typegen.c:1352
void write_full_pointer_free(FILE *file, int indent, const var_t *func)
Definition: typegen.c:2363
@ PASS_RETURN
Definition: typegen.h:28
@ PASS_OUT
Definition: typegen.h:27
@ PASS_IN
Definition: typegen.h:26
@ PHASE_MARSHAL
Definition: typegen.h:34
@ PHASE_BUFFERSIZE
Definition: typegen.h:33
@ PHASE_UNMARSHAL
Definition: typegen.h:35
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:146
int retval
Definition: wcstombs.cpp:91
int interpreted_mode
Definition: widl.c:112
@ ATTR_BROADCAST
Definition: widltypes.h:82
@ ATTR_IN
Definition: widltypes.h:131
@ ATTR_CONTEXTHANDLE
Definition: widltypes.h:89
@ ATTR_IDEMPOTENT
Definition: widltypes.h:126
@ ATTR_OUT
Definition: widltypes.h:151

Referenced by write_function_stubs().

◆ write_function_stubs()

static void write_function_stubs ( type_t iface,
unsigned int proc_offset 
)
static

Definition at line 350 of file client.c.

351{
352 const statement_t *stmt;
354 int method_count = 0;
355
356 if (!implicit_handle)
357 print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n\n", iface->name);
358
360 {
361 switch (stmt->type)
362 {
363 case STMT_DECLARATION:
364 {
365 const var_t *func = stmt->u.var;
366 if (stmt->u.var->declspec.stgclass != STG_NONE
368 continue;
369 write_function_stub( iface, func, method_count++, *proc_offset );
370 *proc_offset += get_size_procformatstring_func( iface, func );
371 break;
372 }
373 case STMT_TYPEDEF:
374 {
375 typeref_t *ref;
377 write_serialize_functions(client, ref->type, iface);
378 break;
379 }
380 default:
381 break;
382 }
383 }
384}
implicit_handle(handle_t browser_hBinding)] interface browser
Definition: browser.idl:136
static void write_function_stub(const type_t *iface, const var_t *func, int method_count, unsigned int proc_offset)
Definition: client.c:67
void write_serialize_functions(FILE *file, const type_t *type, const type_t *iface)
Definition: client.c:336
unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func)
Definition: typegen.c:4825
@ ATTR_IMPLICIT_HANDLE
Definition: widltypes.h:130

Referenced by write_client_ifaces().

◆ write_generic_handle_routine_list()

static void write_generic_handle_routine_list ( void  )
static

Definition at line 570 of file client.c.

571{
573
574 if (list_empty( &generic_handle_list )) return;
575 print_client( "static const GENERIC_BINDING_ROUTINE_PAIR BindingRoutines[] =\n" );
576 print_client( "{\n" );
577 indent++;
579 {
580 print_client( "{ (GENERIC_BINDING_ROUTINE)%s_bind, (GENERIC_UNBIND_ROUTINE)%s_unbind },\n",
581 gh->name, gh->name );
582 }
583 indent--;
584 print_client( "};\n\n" );
585}
static int list_empty(struct list_entry *head)
Definition: list.h:58
generic_handle_list_t generic_handle_list
Definition: header.c:41
const char * name
Definition: widltypes.h:621

Referenced by write_client_routines().

◆ write_implicithandledecl()

static void write_implicithandledecl ( type_t iface)
static

Definition at line 483 of file client.c.

484{
486
487 if (implicit_handle)
488 {
490 fprintf(client, ";\n\n");
491 }
492}

Referenced by write_client_ifaces().

◆ write_serialize_function()

static void write_serialize_function ( FILE file,
const type_t type,
const type_t iface,
const char func_name,
const char ret_type 
)
static

Definition at line 289 of file client.c.

291{
292 static int emitted_pickling_info;
293
294 if (iface && !type->typestring_offset)
295 {
296 /* FIXME: Those are mostly basic types. They should be implemented
297 * using NdrMesSimpleType* functions */
298 if (ret_type) warning("Serialization of type %s is not supported\n", type->name);
299 return;
300 }
301
302 if (!emitted_pickling_info && iface && interpreted_mode)
303 {
304 fprintf(file, "static const MIDL_TYPE_PICKLING_INFO __MIDL_TypePicklingInfo =\n");
305 fprintf(file, "{\n");
306 fprintf(file, " 0x33205054,\n");
307 fprintf(file, " 0x3,\n");
308 fprintf(file, " 0,\n");
309 fprintf(file, " 0,\n");
310 fprintf(file, " 0\n");
311 fprintf(file, "};\n");
312 fprintf(file, "\n");
313 emitted_pickling_info = 1;
314 }
315
316 /* FIXME: Assuming explicit handle */
317
318 fprintf(file, "%s __cdecl %s_%s(handle_t IDL_handle, %s *IDL_type)%s\n",
319 ret_type ? ret_type : "void", type->name, func_name, type->name, iface ? "" : ";");
320 if (!iface) return; /* declaration only */
321
322 fprintf(file, "{\n");
323 fprintf(file, " %sNdrMesType%s%s(\n", ret_type ? "return " : "", func_name,
324 interpreted_mode ? "2" : "");
325 fprintf(file, " IDL_handle,\n");
327 fprintf(file, " (MIDL_TYPE_PICKLING_INFO*)&__MIDL_TypePicklingInfo,\n");
328 fprintf(file, " &%s_StubDesc,\n", iface->name);
329 fprintf(file, " (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u],\n",
330 type->typestring_offset);
331 fprintf(file, " IDL_type);\n");
332 fprintf(file, "}\n");
333 fprintf(file, "\n");
334}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void func_name(void)
#define warning(s)
Definition: debug.h:83
Definition: fci.c:127
char name[1]
Definition: fci.c:135

Referenced by write_serialize_functions().

◆ 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}
#define NULL
Definition: types.h:112
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

Referenced by write_function_stubs(), and write_serialize_function_decl().

◆ write_stubdescdecl()

static void write_stubdescdecl ( type_t iface)
static

Definition at line 387 of file client.c.

388{
389 print_client("static const MIDL_STUB_DESC %s_StubDesc;\n", iface->name);
390 fprintf(client, "\n");
391}

Referenced by write_client_ifaces().

◆ write_stubdescriptor()

static void write_stubdescriptor ( type_t iface,
int  expr_eval_routines 
)
static

Definition at line 394 of file client.c.

395{
397
398 print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
399 print_client("{\n");
400 indent++;
401 print_client("(void *)& %s___RpcClientInterface,\n", iface->name);
402 print_client("MIDL_user_allocate,\n");
403 print_client("MIDL_user_free,\n");
404 print_client("{\n");
405 indent++;
406 if (implicit_handle)
407 print_client("&%s,\n", implicit_handle->name);
408 else
409 print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
410 indent--;
411 print_client("},\n");
412 print_client("0,\n");
414 print_client("BindingRoutines,\n");
415 else
416 print_client("0,\n");
418 print_client("ExprEvalRoutines,\n");
419 else
420 print_client("0,\n");
421 print_client("0,\n");
422 print_client("__MIDL_TypeFormatString.Format,\n");
423 print_client("1, /* -error bounds_check flag */\n");
424 print_client("0x%x, /* Ndr library version */\n", interpreted_mode ? 0x50002 : 0x10001);
425 print_client("0,\n");
426 print_client("0x50200ca, /* MIDL Version 5.2.202 */\n");
427 print_client("0,\n");
428 print_client("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
429 print_client("0, /* notify & notify_flag routine table */\n");
430 print_client("1, /* Flags */\n");
431 print_client("0, /* Reserved3 */\n");
432 print_client("0, /* Reserved4 */\n");
433 print_client("0 /* Reserved5 */\n");
434 indent--;
435 print_client("};\n");
436 fprintf(client, "\n");
437}
user_type_list_t user_type_list
Definition: header.c:39

Referenced by write_client_ifaces().

Variable Documentation

◆ client

FILE* client
static

Definition at line 37 of file client.c.

Referenced by __rpcb_findaddr_timed(), AcceptConnections(), BUTTON_WindowProc(), ButtonWndProc_common(), CB_Paint(), CC_PaintLumBar(), CC_PrepareColorGraph(), cl_addr_compare(), cl_exid_compare(), ClassUnlinkClient(), client_name_cache(), client_server(), client_state_add(), client_state_remove(), client_supports_pnfs(), clnt_raw_create(), COMBOEX_Create(), create_client_object(), create_configuration(), create_overlapped_pipe(), create_pipe_pair(), create_rpcsec_auth_client(), dde_server_wndproc(), debugclient_CreateClient(), debugclient_ExitDispatch(), debugclient_GetOtherOutputMask(), debugclient_SetOtherOutputMask(), DECLARE_INTERFACE_(), DefMDIChildProcA(), DefMDIChildProcW(), delegation_find(), delegation_remove(), delegation_return(), delegation_truncate(), editor_draw(), file_layout_read_thread(), file_layout_recall_all(), file_layout_recall_file(), file_layout_recall_fsid(), file_layout_write_thread(), FileOpenDlgProc95(), fnTextSrv_OnTxInPlaceActivate(), fnTextSrv_OnTxSetCursor(), get_client_disp_property(), get_client_for_netaddr(), get_client_info(), getclnthandle(), handle_mount(), IFileDialog2_fnAdvise(), IFileDialog2_fnUnadvise(), init_client(), init_explorerbrowser(), INTERNET_InternetOpenUrlW(), is_dst_name_opened(), local_rpcb(), marshal_STGMEDIUM(), marshal_WdtpInterfacePointer(), mdi_child_wnd_proc(), mdi_child_wnd_proc_1(), MDI_ChildActivate(), MDI_ChildGetMinMaxInfo(), MDICascade(), MDIDestroyChild(), MDITile(), MMDevEnum_RegisterEndpointNotificationCallback(), MMDevEnum_UnregisterEndpointNotificationCallback(), mmTaskCreate(), MonitorChildThread(), MONTHCAL_GetDayFromPos(), MONTHCAL_UpdateSize(), nfs41_abs_path_compare(), nfs41_client_create(), nfs41_client_delegation_free(), nfs41_client_delegation_recovery(), nfs41_client_delegation_return_lru(), nfs41_client_free(), nfs41_client_renew(), nfs41_client_state_revoked(), nfs41_delegate_open(), nfs41_delegation_getattr(), nfs41_delegation_granted(), nfs41_delegation_recall(), nfs41_delegation_return(), nfs41_recover_client_state(), nfs41_recovery_finish(), nfs41_recovery_start_or_wait(), nfs41_root_mount_addrs(), nfs41_root_session(), nfs41_rpc_clnt_create(), nfs41_session_create(), OleControl_OnAmbientPropertyChange(), OleObject_Close(), OleObject_DoVerb(), OnBPPChanged(), PersistMoniker_Load(), pmap_getmaps(), pmap_getport(), pnfs_client_init(), pnfs_file_layout_recall(), print_client(), ReadFromPipeThread(), referral_resolve(), RichEditWndProc_common(), root_client_create(), rpc_reconnect(), rpcb_getmaps(), rpcb_gettime(), rpcb_set(), rpcb_taddr2uaddr(), rpcb_uaddr2taddr(), rpcb_unset(), rpcrt4_conn_tcp_handoff(), RunShell(), send_null(), session_alloc(), set_format(), ShowColorSpectrum(), START_TEST(), TerminateShell(), test_authentication(), test_completion(), test_dpi_mapping(), test_file_info(), test_kernel32_tp_io(), test_layered_window(), test_mqtt_connection_cb(), test_NamedPipeHandleState(), test_notifications(), test_overlapped_transport(), test_ReadFile(), test_readfileex_pending(), test_security_info(), test_tp_io(), test_TxDraw(), test_TxGetScroll(), testAuth(), testInitializeSecurityContextFlags(), testSignSeal(), TOOLBAR_Size(), update_client_rect(), update_exchangeid_res(), update_server(), UserLogin(), UserLoginThread(), WDML_EventProc(), WDML_RemoveServer(), write_client(), write_client_func_decl(), write_client_ifaces(), write_client_routines(), write_clientinterfacedecl(), write_function_stub(), write_function_stubs(), write_implicithandledecl(), write_stubdescdecl(), write_stubdescriptor(), and WriteToPipeThread().

◆ indent