ReactOS 0.4.16-dev-1946-g52006dd
proxy.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 "typegen.h"
#include "expr.h"
Include dependency graph for proxy.c:

Go to the source code of this file.

Functions

static void print_proxy (const char *format,...) __attribute__((format(printf
 
static void write_stubdescproto (void)
 
static void write_stubdesc (int expr_eval_routines)
 
static void init_proxy (const statement_list_t *stmts)
 
static void clear_output_vars (const var_list_t *args)
 
static int need_delegation (const type_t *iface)
 
static int get_delegation_indirect (const type_t *iface, const type_t **delegate_to)
 
static int need_delegation_indirect (const type_t *iface)
 
static void free_variable (const var_t *arg, const char *local_var_prefix)
 
static void proxy_free_variables (var_list_t *args, const char *local_var_prefix)
 
static void gen_proxy (type_t *iface, const var_t *func, int idx, unsigned int proc_offset)
 
static void gen_stub (type_t *iface, const var_t *func, const char *cas, unsigned int proc_offset)
 
static void gen_stub_thunk (type_t *iface, const var_t *func, unsigned int proc_offset)
 
int count_methods (const type_t *iface)
 
const statement_tget_callas_source (const type_t *iface, const var_t *def)
 
static void write_proxy_procformatstring_offsets (const type_t *iface, int skip)
 
static int write_proxy_methods (type_t *iface, int skip)
 
static int write_stub_methods (type_t *iface, int skip)
 
static void write_thunk_methods (type_t *iface, int skip)
 
static void write_proxy (type_t *iface, unsigned int *proc_offset)
 
static int does_any_iface (const statement_list_t *stmts, type_pred_t pred)
 
int need_proxy (const type_t *iface)
 
int need_stub (const type_t *iface)
 
int need_proxy_file (const statement_list_t *stmts)
 
int need_proxy_delegation (const statement_list_t *stmts)
 
int need_inline_stubs (const type_t *iface)
 
static int need_proxy_and_inline_stubs (const type_t *iface)
 
int need_stub_files (const statement_list_t *stmts)
 
int need_inline_stubs_file (const statement_list_t *stmts)
 
static void write_proxy_stmts (const statement_list_t *stmts, unsigned int *proc_offset)
 
static int cmp_iid (const void *ptr1, const void *ptr2)
 
static void build_iface_list (const statement_list_t *stmts, type_t **ifaces[], int *count)
 
static type_t ** sort_interfaces (const statement_list_t *stmts, int *count)
 
static void write_proxy_routines (const statement_list_t *stmts)
 
void write_proxies (const statement_list_t *stmts)
 

Variables

static FILEproxy
 
static int indent = 0
 

Function Documentation

◆ build_iface_list()

static void build_iface_list ( const statement_list_t stmts,
type_t **  ifaces[],
int count 
)
static

Definition at line 882 of file proxy.c.

883{
884 const statement_t *stmt;
885
886 if (!stmts) return;
887 LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
888 {
889 if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
890 {
891 type_t *iface = stmt->u.type;
892 if (type_iface_get_inherit(iface) && need_proxy(iface))
893 {
894 *ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(**ifaces) );
895 (*ifaces)[(*count)++] = iface;
897 {
898 iface = type_iface_get_async_iface(iface);
899 *ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(**ifaces) );
900 (*ifaces)[(*count)++] = iface;
901 }
902 }
903 }
904 }
905}
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
GLuint GLuint GLsizei count
Definition: gl.h:1545
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
int need_proxy(const type_t *iface)
Definition: proxy.c:791
statement_type_t type
Definition: parser.h:124
union _statement_t::@5358 u
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113
static type_t * type_iface_get_async_iface(const type_t *type)
Definition: typetree.h:222
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:208
@ TYPE_INTERFACE
Definition: widltypes.h:488
@ STMT_TYPE
Definition: widltypes.h:267

Referenced by sort_interfaces().

◆ clear_output_vars()

static void clear_output_vars ( const var_list_t args)
static

Definition at line 99 of file proxy.c.

100{
101 const var_t *arg;
102
103 if (!args) return;
105 {
106 if (is_attr(arg->attrs, ATTR_IN)) continue;
107 if (!is_attr(arg->attrs, ATTR_OUT)) continue;
108 if (is_ptr(arg->declspec.type))
109 {
110 if (type_get_type(type_pointer_get_ref_type(arg->declspec.type)) == TYPE_BASIC) continue;
111 if (type_get_type(type_pointer_get_ref_type(arg->declspec.type)) == TYPE_ENUM) continue;
112 }
113 print_proxy( "if (%s) MIDL_memset( %s, 0, ", arg->name, arg->name );
114 if (is_array(arg->declspec.type) && type_array_has_conformance(arg->declspec.type))
115 {
116 write_expr( proxy, type_array_get_conformance(arg->declspec.type), 1, 1, NULL, NULL, "" );
117 fprintf( proxy, " * " );
118 }
119 fprintf( proxy, "sizeof( *%s ));\n", arg->name );
120 }
121}
#define NULL
Definition: types.h:112
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
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
static int is_array(const type_t *t)
Definition: header.h:60
static void print_proxy(const char *format,...) __attribute__((format(printf
Definition: proxy.c:40
static FILE * proxy
Definition: proxy.c:36
Definition: match.c:390
static int type_array_has_conformance(const type_t *type)
Definition: typetree.h:289
static expr_t * type_array_get_conformance(const type_t *type)
Definition: typetree.h:310
static type_t * type_pointer_get_ref_type(const type_t *type)
Definition: typetree.h:424
@ TYPE_ENUM
Definition: widltypes.h:480
@ TYPE_BASIC
Definition: widltypes.h:479
@ ATTR_IN
Definition: widltypes.h:131
@ ATTR_OUT
Definition: widltypes.h:151
void * arg
Definition: msvc.h:10

Referenced by gen_proxy().

◆ cmp_iid()

static int cmp_iid ( const void ptr1,
const void ptr2 
)
static

Definition at line 873 of file proxy.c.

874{
875 const type_t * const *iface1 = ptr1;
876 const type_t * const *iface2 = ptr2;
877 const struct uuid *uuid1 = get_attrp( (*iface1)->attrs, ATTR_UUID );
878 const struct uuid *uuid2 = get_attrp( (*iface2)->attrs, ATTR_UUID );
879 return memcmp( uuid1, uuid2, sizeof(*uuid1) );
880}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: msctf.idl:532
void * get_attrp(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:87
@ ATTR_UUID
Definition: widltypes.h:182

Referenced by sort_interfaces().

◆ 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}
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
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().

◆ does_any_iface()

static int does_any_iface ( const statement_list_t stmts,
type_pred_t  pred 
)
static

Definition at line 774 of file proxy.c.

775{
776 const statement_t *stmt;
777
778 if (stmts)
779 LIST_FOR_EACH_ENTRY(stmt, stmts, const statement_t, entry)
780 {
781 if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
782 {
783 if (pred(stmt->u.type))
784 return TRUE;
785 }
786 }
787
788 return FALSE;
789}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Referenced by need_inline_stubs_file(), need_proxy_delegation(), need_proxy_file(), need_stub_files(), and write_proxy_routines().

◆ free_variable()

static void free_variable ( const var_t arg,
const char local_var_prefix 
)
static

Definition at line 147 of file proxy.c.

148{
149 unsigned int type_offset = arg->typestring_offset;
150 type_t *type = arg->declspec.type;
151
153
155 {
156 case TGT_ENUM:
157 case TGT_BASIC:
158 break;
159
160 case TGT_STRUCT:
162 print_proxy("/* FIXME: %s code for %s struct type 0x%x missing */\n", __FUNCTION__, arg->name, get_struct_fc(type) );
163 break;
164
166 case TGT_POINTER:
167 case TGT_ARRAY:
168 print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
169 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
170 fprintf(proxy, "(void *)%s );\n", arg->name );
171 break;
172
173 default:
174 print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type_get_type(type) );
175 }
176}
#define __FUNCTION__
Definition: types.h:116
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static unsigned char get_struct_fc(ITypeInfo *typeinfo, TYPEATTR *attr)
Definition: ndr_typelib.c:319
@ FC_STRUCT
Definition: ndrtypes.h:157
static int indent
Definition: proxy.c:37
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:324
void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase, const var_t *var, int valid_variance)
Definition: typegen.c:4369
@ PHASE_FREE
Definition: typegen.h:36
@ TDT_IGNORE_STRINGS
Definition: typegen.h:42
@ TGT_POINTER
Definition: typegen.h:53
@ TGT_STRUCT
Definition: typegen.h:58
@ TGT_ARRAY
Definition: typegen.h:54
@ TGT_ENUM
Definition: typegen.h:57
@ TGT_BASIC
Definition: typegen.h:56
@ TGT_IFACE_POINTER
Definition: typegen.h:55

Referenced by proxy_free_variables().

◆ gen_proxy()

static void gen_proxy ( type_t iface,
const var_t func,
int  idx,
unsigned int  proc_offset 
)
static

Definition at line 191 of file proxy.c.

193{
194 var_t *retval = type_function_get_retval(func->declspec.type);
195 int has_ret = !is_void(retval->declspec.type);
196 int has_full_pointer = is_full_pointer_function(func);
197 const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV);
198 const var_list_t *args = type_function_get_args(func->declspec.type);
199 if (!callconv) callconv = "STDMETHODCALLTYPE";
200
201 indent = 0;
202 if (is_interpreted_func( iface, func ))
203 {
204 if (!is_callas( func->attrs )) return;
205 write_type_decl_left(proxy, &retval->declspec);
206 print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
207 write_args(proxy, args, iface->name, 1, TRUE, NAME_DEFAULT);
208 print_proxy( ")\n");
209 write_client_call_routine( proxy, iface, func, "Object", proc_offset );
210 return;
211 }
212 print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n",
213 iface->name, get_name(func) );
214 print_proxy( "{\n");
215 indent++;
216 if (has_full_pointer) write_full_pointer_free(proxy, indent, func);
217 print_proxy( "NdrProxyFreeBuffer( __frame->This, &__frame->_StubMsg );\n" );
218 indent--;
219 print_proxy( "}\n");
220 print_proxy( "\n");
221
222 write_type_decl_left(proxy, &retval->declspec);
223 print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
224 write_args(proxy, args, iface->name, 1, TRUE, NAME_DEFAULT);
225 print_proxy( ")\n");
226 print_proxy( "{\n");
227 indent ++;
228 print_proxy( "struct __proxy_frame __f, * const __frame = &__f;\n" );
229 /* local variables */
230 if (has_ret) {
231 print_proxy( "%s", "" );
232 write_type_decl(proxy, &retval->declspec, retval->name);
233 fprintf( proxy, ";\n" );
234 }
235 print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
236 if (has_ret) {
237 if (decl_indirect(retval->declspec.type))
238 print_proxy("void *_p_%s = &%s;\n", retval->name, retval->name);
239 }
240 print_proxy( "\n");
241
242 print_proxy( "RpcExceptionInit( __proxy_filter, __finally_%s_%s_Proxy );\n", iface->name, get_name(func) );
243 print_proxy( "__frame->This = This;\n" );
244
245 if (has_full_pointer)
247
248 /* FIXME: trace */
250
251 print_proxy( "RpcTryExcept\n" );
252 print_proxy( "{\n" );
253 indent++;
254 print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &__frame->_StubMsg, &Object_StubDesc, %d);\n", idx);
256
257 print_proxy( "RpcTryFinally\n" );
258 print_proxy( "{\n" );
259 indent++;
260
262
263 print_proxy( "NdrProxyGetBuffer(This, &__frame->_StubMsg);\n" );
264
266
267 print_proxy( "NdrProxySendReceive(This, &__frame->_StubMsg);\n" );
268 fprintf(proxy, "\n");
269 print_proxy( "__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n" );
270 print_proxy( "__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" );
271
272 print_proxy("if ((_RpcMessage.DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
273 indent++;
274 print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
275 indent--;
276 fprintf(proxy, "\n");
277
279
280 if (has_ret)
281 {
282 if (decl_indirect(retval->declspec.type))
283 print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", retval->name, retval->name);
284 else if (is_ptr(retval->declspec.type) || is_array(retval->declspec.type))
285 print_proxy("%s = 0;\n", retval->name);
287 }
288
289 indent--;
290 print_proxy( "}\n");
291 print_proxy( "RpcFinally\n" );
292 print_proxy( "{\n" );
293 indent++;
294 print_proxy( "__finally_%s_%s_Proxy( __frame );\n", iface->name, get_name(func) );
295 indent--;
296 print_proxy( "}\n");
297 print_proxy( "RpcEndFinally\n" );
298 indent--;
299 print_proxy( "}\n" );
300 print_proxy( "RpcExcept(__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" );
301 print_proxy( "{\n" );
302 if (has_ret) {
303 indent++;
304 proxy_free_variables( type_function_get_args(func->declspec.type), "" );
305 print_proxy( "/* coverity[uninit_use_in_call:SUPPRESS] */\n" );
306 print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
307 indent--;
308 }
309 print_proxy( "}\n" );
310 print_proxy( "RpcEndExcept\n" );
311
312 if (has_ret) {
313 print_proxy( "return _RetVal;\n" );
314 }
315 indent--;
316 print_proxy( "}\n");
317 print_proxy( "\n");
318}
int get_name(unsigned char **pos, uint32_t *remaining, const char **out_name)
Definition: util.c:55
Definition: list.h:37
unsigned int idx
Definition: utils.c:41
void write_type_decl_left(FILE *f, const decl_spec_t *ds)
Definition: header.c:593
void write_type_decl(FILE *f, const decl_spec_t *t, const char *name)
Definition: header.c:588
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_void(const type_t *t)
Definition: header.h:70
static void proxy_free_variables(var_list_t *args, const char *local_var_prefix)
Definition: proxy.c:178
static void clear_output_vars(const var_list_t *args)
Definition: proxy.c:99
const char * name
Definition: widltypes.h:500
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
@ NAME_DEFAULT
Definition: typetree.h:31
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:146
static var_list_t * type_function_get_args(const type_t *type)
Definition: typetree.h:139
int retval
Definition: wcstombs.cpp:91
@ ATTR_CALLCONV
Definition: widltypes.h:84

Referenced by write_proxy().

◆ gen_stub()

static void gen_stub ( type_t iface,
const var_t func,
const char cas,
unsigned int  proc_offset 
)
static

Definition at line 320 of file proxy.c.

322{
323 const var_t *arg;
324 int has_ret = !is_void(type_function_get_rettype(func->declspec.type));
325 int has_full_pointer = is_full_pointer_function(func);
326
327 if (is_interpreted_func( iface, func )) return;
328
329 indent = 0;
330 print_proxy( "struct __frame_%s_%s_Stub\n{\n", iface->name, get_name(func));
331 indent++;
332 print_proxy( "__DECL_EXCEPTION_FRAME\n" );
333 print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n");
334 print_proxy( "%s * _This;\n", iface->name );
336 indent--;
337 print_proxy( "};\n\n" );
338
339 print_proxy( "static void __finally_%s_%s_Stub(", iface->name, get_name(func) );
340 print_proxy( " struct __frame_%s_%s_Stub *__frame )\n{\n", iface->name, get_name(func) );
341 indent++;
343 if (has_full_pointer)
345 indent--;
346 print_proxy( "}\n\n" );
347
348 print_proxy( "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(func));
349 indent++;
350 print_proxy( "IRpcStubBuffer* This,\n");
351 print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
352 print_proxy( "PRPC_MESSAGE _pRpcMessage,\n");
353 print_proxy( "DWORD* _pdwStubPhase)\n");
354 indent--;
355 print_proxy( "{\n");
356 indent++;
357 print_proxy( "struct __frame_%s_%s_Stub __f, * const __frame = &__f;\n\n",
358 iface->name, get_name(func) );
359
360 print_proxy("__frame->_This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n\n", iface->name);
361
362 /* FIXME: trace */
363
364 print_proxy("NdrStubInitialize(_pRpcMessage, &__frame->_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n");
365 fprintf(proxy, "\n");
366 print_proxy( "RpcExceptionInit( 0, __finally_%s_%s_Stub );\n", iface->name, get_name(func) );
367
368 write_parameters_init(proxy, indent, func, "__frame->");
369
370 print_proxy("RpcTryFinally\n");
371 print_proxy("{\n");
372 indent++;
373 if (has_full_pointer)
375 print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
376 indent++;
377 print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
378 indent--;
379 fprintf(proxy, "\n");
380
382 fprintf(proxy, "\n");
383
384 assign_stub_out_args( proxy, indent, func, "__frame->" );
385
386 print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
387 fprintf(proxy, "\n");
388 print_proxy( "%s", has_ret ? "__frame->_RetVal = " : "" );
389 if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas);
390 else fprintf(proxy, "__frame->_This->lpVtbl->%s", get_name(func));
391 fprintf(proxy, "(__frame->_This");
392
393 if (type_function_get_args(func->declspec.type))
394 {
396 fprintf(proxy, ", %s__frame->%s", is_array(arg->declspec.type) && !type_array_is_decl_as_ptr(arg->declspec.type) ? "*" :"" , arg->name);
397 }
398 fprintf(proxy, ");\n");
399 fprintf(proxy, "\n");
400 print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
401 fprintf(proxy, "\n");
402
404
405 if (!is_void(type_function_get_rettype(func->declspec.type)))
407
408 print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &__frame->_StubMsg);\n");
409
411 fprintf(proxy, "\n");
412
413 /* marshall the return value */
414 if (!is_void(type_function_get_rettype(func->declspec.type)))
416
417 indent--;
418 print_proxy("}\n");
419 print_proxy("RpcFinally\n");
420 print_proxy("{\n");
421 indent++;
422 print_proxy( "__finally_%s_%s_Stub( __frame );\n", iface->name, get_name(func) );
423 indent--;
424 print_proxy("}\n");
425 print_proxy("RpcEndFinally\n");
426
427 print_proxy("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
428 indent--;
429
430 print_proxy("}\n");
431 print_proxy("\n");
432}
void declare_stub_args(FILE *file, int indent, const var_t *func)
Definition: typegen.c:4856
void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix)
Definition: typegen.c:1008
void assign_stub_out_args(FILE *file, int indent, const var_t *func, const char *local_var_prefix)
Definition: typegen.c:4922
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:350
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:158

Referenced by write_proxy().

◆ gen_stub_thunk()

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

Definition at line 434 of file proxy.c.

435{
436 int has_ret = !is_void( type_function_get_rettype( func->declspec.type ));
437 const var_t *arg, *callas = is_callas( func->attrs );
438 const var_list_t *args = type_function_get_args( func->declspec.type );
439
440 indent = 0;
441 print_proxy( "void __RPC_API %s_%s_Thunk( PMIDL_STUB_MESSAGE pStubMsg )\n",
442 iface->name, get_name(func) );
443 print_proxy( "{\n");
444 indent++;
445 write_func_param_struct( proxy, iface, func->declspec.type,
446 "*pParamStruct = (struct _PARAM_STRUCT *)pStubMsg->StackTop", has_ret );
447 print_proxy( "%s%s_%s_Stub( pParamStruct->This",
448 has_ret ? "pParamStruct->_RetVal = " : "", iface->name, callas->name );
449 indent++;
450 if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
451 {
452 fprintf( proxy, ",\n%*spParamStruct->%s", 4 * indent, "", arg->name );
453 }
454 fprintf( proxy, " );\n" );
455 indent--;
456 indent--;
457 print_proxy( "}\n\n");
458}
char * name
Definition: widltypes.h:541
void write_func_param_struct(FILE *file, const type_t *iface, const type_t *func, const char *var_decl, int add_retval)
Definition: typegen.c:5035

Referenced by 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

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

◆ get_delegation_indirect()

static int get_delegation_indirect ( const type_t iface,
const type_t **  delegate_to 
)
static

Definition at line 129 of file proxy.c.

130{
131 const type_t * cur_iface;
132 for (cur_iface = iface; cur_iface != NULL; cur_iface = type_iface_get_inherit(cur_iface))
133 if (need_delegation(cur_iface))
134 {
135 if(delegate_to)
136 *delegate_to = type_iface_get_inherit(cur_iface);
137 return 1;
138 }
139 return 0;
140}
static int need_delegation(const type_t *iface)
Definition: proxy.c:123

Referenced by need_delegation_indirect(), and write_proxy_routines().

◆ init_proxy()

static void init_proxy ( const statement_list_t stmts)
static

Definition at line 79 of file proxy.c.

80{
81 if (proxy) return;
82 if(!(proxy = fopen(proxy_name, "w")))
83 error("Could not open %s for output\n", proxy_name);
84 print_proxy( "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
85 print_proxy( "\n");
86#ifdef __REACTOS__
87 print_proxy( "#define __midl_proxy\n\n");
88 print_proxy( "#ifdef __REACTOS__\n");
89 print_proxy( "#define WIN32_NO_STATUS\n");
90 print_proxy( "#define WIN32_LEAN_AND_MEAN\n");
91 print_proxy( "#endif\n\n");
92#else
93 print_proxy( "#define __midl_proxy\n");
94#endif
95 print_proxy( "#include \"objbase.h\"\n");
96 print_proxy( "\n");
97}
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define error(str)
Definition: mkdosfs.c:1605
char * proxy_name
Definition: widl.c:124
char * input_name
Definition: widl.c:116

Referenced by write_proxies().

◆ need_delegation()

static int need_delegation ( const type_t iface)
static

Definition at line 123 of file proxy.c.

124{
125 const type_t *parent = type_iface_get_inherit( iface );
126 return parent && type_iface_get_inherit(parent) && (parent->ignore || is_local( parent->attrs ));
127}
r parent
Definition: btrfs.c:3010
int is_local(const attr_list_t *a)
Definition: header.c:982

Referenced by get_delegation_indirect(), need_proxy_delegation(), write_proxy(), write_proxy_methods(), write_proxy_procformatstring_offsets(), write_stub_methods(), and write_thunk_methods().

◆ need_delegation_indirect()

static int need_delegation_indirect ( const type_t iface)
static

Definition at line 142 of file proxy.c.

143{
144 return get_delegation_indirect(iface, NULL);
145}
static int get_delegation_indirect(const type_t *iface, const type_t **delegate_to)
Definition: proxy.c:129

Referenced by write_proxy().

◆ 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 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_list_t * attrs
Definition: widltypes.h:503
@ 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_and_inline_stubs()

static int need_proxy_and_inline_stubs ( const type_t iface)
static

Definition at line 829 of file proxy.c.

830{
831 const statement_t *stmt;
832
833 if (!need_proxy( iface )) return 0;
834 if (!interpreted_mode) return 1;
835
837 {
838 const var_t *func = stmt->u.var;
839 if (is_local( func->attrs )) continue;
840 if (!is_interpreted_func( iface, func )) return 1;
841 }
842 return 0;
843}

Referenced by write_proxy_routines().

◆ 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}

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}

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().

◆ print_proxy()

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

Definition at line 40 of file proxy.c.

41{
42 va_list va;
43 va_start( va, format );
44 print( proxy, indent, format, va );
45 va_end( va );
46}
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
Definition: format.c:58

Referenced by clear_output_vars(), free_variable(), gen_proxy(), gen_stub(), gen_stub_thunk(), init_proxy(), write_proxy(), write_proxy_methods(), write_proxy_procformatstring_offsets(), write_proxy_routines(), write_stub_methods(), write_stubdesc(), write_stubdescproto(), and write_thunk_methods().

◆ proxy_free_variables()

static void proxy_free_variables ( var_list_t args,
const char local_var_prefix 
)
static

Definition at line 178 of file proxy.c.

179{
180 const var_t *arg;
181
182 if (!args) return;
184 if (is_attr(arg->attrs, ATTR_OUT))
185 {
186 free_variable( arg, local_var_prefix );
187 fprintf(proxy, "\n");
188 }
189}
static void free_variable(const var_t *arg, const char *local_var_prefix)
Definition: proxy.c:147

Referenced by gen_proxy().

◆ sort_interfaces()

static type_t ** sort_interfaces ( const statement_list_t stmts,
int count 
)
static

Definition at line 907 of file proxy.c.

908{
909 type_t **ifaces = NULL;
910
911 *count = 0;
912 build_iface_list( stmts, &ifaces, count );
913 qsort( ifaces, *count, sizeof(*ifaces), cmp_iid );
914 return ifaces;
915}
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
static void build_iface_list(const statement_list_t *stmts, type_t **ifaces[], int *count)
Definition: proxy.c:882
static int cmp_iid(const void *ptr1, const void *ptr2)
Definition: proxy.c:873

Referenced by write_proxy_routines().

◆ write_proxies()

void write_proxies ( const statement_list_t stmts)

Definition at line 1072 of file proxy.c.

1073{
1074 if (!do_proxies) return;
1075 if (do_everything && !need_proxy_file(stmts)) return;
1076
1077 init_proxy(stmts);
1078 if(!proxy) return;
1079
1080 write_proxy_routines( stmts );
1081 fclose(proxy);
1082}
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
static void write_proxy_routines(const statement_list_t *stmts)
Definition: proxy.c:917
int need_proxy_file(const statement_list_t *stmts)
Definition: proxy.c:804
static void init_proxy(const statement_list_t *stmts)
Definition: proxy.c:79
int do_everything
Definition: widl.c:98
int do_proxies
Definition: widl.c:102

◆ write_proxy()

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

Definition at line 607 of file proxy.c.

608{
609 int count;
610 const statement_t *stmt;
611 int first_func = 1;
612 int needs_stub_thunks = 0;
613 int needs_inline_stubs = need_inline_stubs( iface ) || need_delegation( iface );
614
616 var_t *func = stmt->u.var;
617 if (first_func) {
618 fprintf(proxy, "/*****************************************************************************\n");
619 fprintf(proxy, " * %s interface\n", iface->name);
620 fprintf(proxy, " */\n");
621 first_func = 0;
622 }
623 if (!is_local(func->attrs)) {
624 const var_t *cas = is_callas(func->attrs);
625 const char *cname = cas ? cas->name : NULL;
626 int idx = func->func_idx;
627 if (cname) {
628 const statement_t *stmt2;
630 const var_t *m = stmt2->u.var;
631 if (!strcmp(m->name, cname))
632 {
633 idx = m->func_idx;
634 break;
635 }
636 }
637 }
638 func->procstring_offset = *proc_offset;
639 gen_proxy(iface, func, idx, *proc_offset);
640 gen_stub(iface, func, cname, *proc_offset);
641 if (cas && is_interpreted_func( iface, func ))
642 {
643 needs_stub_thunks = 1;
644 gen_stub_thunk(iface, func, *proc_offset);
645 }
646 *proc_offset += get_size_procformatstring_func( iface, func );
647 }
648 }
649
650 count = count_methods(iface);
651
652 print_proxy( "static const unsigned short %s_FormatStringOffsetTable[] =\n", iface->name );
653 print_proxy( "{\n" );
654 indent++;
655#ifdef __REACTOS__ /* r57019 / c3be8a3 */
656 if (write_proxy_procformatstring_offsets( iface, 0 ) == 0)
657 {
658 print_proxy( "0\n" );
659 }
660#else
662#endif
663 indent--;
664 print_proxy( "};\n\n" );
665
666 /* proxy info */
668 {
669 print_proxy( "static const MIDL_STUBLESS_PROXY_INFO %s_ProxyInfo =\n", iface->name );
670 print_proxy( "{\n" );
671 indent++;
672 print_proxy( "&Object_StubDesc,\n" );
673 print_proxy( "__MIDL_ProcFormatString.Format,\n" );
674 print_proxy( "&%s_FormatStringOffsetTable[-3],\n", iface->name );
675 print_proxy( "0,\n" );
676 print_proxy( "0,\n" );
677 print_proxy( "0\n" );
678 indent--;
679 print_proxy( "};\n\n" );
680 }
681
682 /* proxy vtable */
683 print_proxy( "static %sCINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n",
684 (interpreted_mode || need_delegation_indirect(iface)) ? "" : "const ",
685 count, iface->name);
686 print_proxy( "{\n");
687 indent++;
688 print_proxy( "{\n");
689 indent++;
690 if (interpreted_mode) print_proxy( "&%s_ProxyInfo,\n", iface->name );
691 print_proxy( "&IID_%s,\n", iface->name);
692 indent--;
693 print_proxy( "},\n");
694 print_proxy( "{\n");
695 indent++;
697 indent--;
698 print_proxy( "}\n");
699 indent--;
700 print_proxy( "};\n\n");
701
702 /* stub thunk table */
703 if (needs_stub_thunks)
704 {
705 print_proxy( "static const STUB_THUNK %s_StubThunkTable[] =\n", iface->name);
706 print_proxy( "{\n");
707 indent++;
708 write_thunk_methods( iface, 0 );
709 indent--;
710 print_proxy( "};\n\n");
711 }
712
713 /* server info */
714 print_proxy( "static const MIDL_SERVER_INFO %s_ServerInfo =\n", iface->name );
715 print_proxy( "{\n" );
716 indent++;
717 print_proxy( "&Object_StubDesc,\n" );
718 print_proxy( "0,\n" );
719 print_proxy( "__MIDL_ProcFormatString.Format,\n" );
720 print_proxy( "&%s_FormatStringOffsetTable[-3],\n", iface->name );
721 if (needs_stub_thunks)
722 print_proxy( "&%s_StubThunkTable[-3],\n", iface->name );
723 else
724 print_proxy( "0,\n" );
725 print_proxy( "0,\n" );
726 print_proxy( "0,\n" );
727 print_proxy( "0\n" );
728 indent--;
729 print_proxy( "};\n\n" );
730
731 /* stub vtable */
732 if (needs_inline_stubs)
733 {
734 print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
735 print_proxy( "{\n");
736 indent++;
737#ifdef __REACTOS__ /* r57019 / c3be8a3 */
738 if (write_stub_methods(iface, FALSE) == 0)
739 {
740 fprintf(proxy, "0");
741 }
742#else
744#endif
745 fprintf(proxy, "\n");
746 indent--;
747 fprintf(proxy, "};\n\n");
748 }
749 print_proxy( "static %sCInterfaceStubVtbl _%sStubVtbl =\n",
750 need_delegation_indirect(iface) ? "" : "const ", iface->name);
751 print_proxy( "{\n");
752 indent++;
753 print_proxy( "{\n");
754 indent++;
755 print_proxy( "&IID_%s,\n", iface->name);
756 print_proxy( "&%s_ServerInfo,\n", iface->name );
757 print_proxy( "%d,\n", count);
758 if (needs_inline_stubs) print_proxy( "&%s_table[-3]\n", iface->name );
759 else print_proxy( "0\n" );
760 indent--;
761 print_proxy( "},\n");
762 print_proxy( "{\n");
763 indent++;
764 print_proxy( "%s_%s\n",
765 type_iface_get_async_iface(iface) == iface ? "CStdAsyncStubBuffer" : "CStdStubBuffer",
766 need_delegation_indirect(iface) ? "DELEGATING_METHODS" : "METHODS");
767 indent--;
768 print_proxy( "}\n");
769 indent--;
770 print_proxy( "};\n");
771 print_proxy( "\n");
772}
const GLfloat * m
Definition: glext.h:10848
static int write_stub_methods(type_t *iface, int skip)
Definition: proxy.c:550
static void write_thunk_methods(type_t *iface, int skip)
Definition: proxy.c:583
static int need_delegation_indirect(const type_t *iface)
Definition: proxy.c:142
static void gen_stub(type_t *iface, const var_t *func, const char *cas, unsigned int proc_offset)
Definition: proxy.c:320
static void gen_stub_thunk(type_t *iface, const var_t *func, unsigned int proc_offset)
Definition: proxy.c:434
static int write_proxy_methods(type_t *iface, int skip)
Definition: proxy.c:525
static void write_proxy_procformatstring_offsets(const type_t *iface, int skip)
Definition: proxy.c:489
static void gen_proxy(type_t *iface, const var_t *func, int idx, unsigned int proc_offset)
Definition: proxy.c:191
unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func)
Definition: typegen.c:4825

Referenced by write_proxy_stmts().

◆ write_proxy_methods()

static int write_proxy_methods ( type_t iface,
int  skip 
)
static

Definition at line 525 of file proxy.c.

526{
527 const statement_t *stmt;
528 int i = 0;
529
530 if (type_iface_get_inherit(iface))
532 need_delegation(iface));
534 const var_t *func = stmt->u.var;
535 if (!is_callas(func->attrs)) {
536 if (skip || (is_local(func->attrs) && !get_callas_source(iface, func)))
537 print_proxy( "0, /* %s::%s */\n", iface->name, get_name(func));
538 else if (is_interpreted_func( iface, func ) &&
539 !is_local( func->attrs ) &&
541 print_proxy( "(void *)-1, /* %s::%s */\n", iface->name, get_name(func));
542 else
543 print_proxy( "%s_%s_Proxy,\n", iface->name, get_name(func));
544 i++;
545 }
546 }
547 return i;
548}
#define skip(...)
Definition: atltest.h:64
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
const statement_t * get_callas_source(const type_t *iface, const var_t *def)
Definition: proxy.c:475

Referenced by write_proxy(), and write_proxy_methods().

◆ write_proxy_procformatstring_offsets()

static void write_proxy_procformatstring_offsets ( const type_t iface,
int  skip 
)
static

Definition at line 489 of file proxy.c.

491{
492 const statement_t *stmt;
493 int i = 0;
494
495 if (type_iface_get_inherit(iface))
497 else
498 return 0;
499
501 {
502 const var_t *func = stmt->u.var;
503 int missing = 0;
504
505 if (is_callas(func->attrs)) continue;
506 if (is_local(func->attrs))
507 {
508 const statement_t * callas_source = get_callas_source(iface, func);
509 if (!callas_source)
510 missing = 1;
511 else
512 func = callas_source->u.var;
513 }
514 if (skip || missing)
515 print_proxy( "(unsigned short)-1, /* %s::%s */\n", iface->name, get_name(func));
516 else
517 print_proxy( "%u, /* %s::%s */\n", func->procstring_offset, iface->name, get_name(func));
518 i++;
519 }
520#ifdef __REACTOS__ /* r57019 / c3be8a3 */
521 return i;
522#endif
523}

Referenced by write_proxy(), and write_proxy_procformatstring_offsets().

◆ write_proxy_routines()

static void write_proxy_routines ( const statement_list_t stmts)
static

Definition at line 917 of file proxy.c.

918{
920 unsigned int proc_offset = 0;
921 char *file_id = proxy_token;
922 int i, count, have_baseiid = 0;
923 unsigned int table_version;
924 type_t **interfaces;
925 const type_t * delegate_to;
926
927 print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
928 print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ %u\n", interpreted_mode ? 475 : 440);
929 print_proxy( "#endif\n");
930 print_proxy( "\n");
931 if (interpreted_mode) print_proxy( "#define USE_STUBLESS_PROXY\n");
932 print_proxy( "#include \"rpcproxy.h\"\n");
933 print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
934 print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
935 print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
936 print_proxy( "\n");
937 print_proxy( "#include \"%s\"\n", header_name);
938 print_proxy( "\n");
939
941 {
943 print_proxy( "\n");
944 print_proxy( "struct __proxy_frame\n");
945 print_proxy( "{\n");
946 print_proxy( " __DECL_EXCEPTION_FRAME\n");
947 print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n");
948 print_proxy( " void *This;\n");
949 print_proxy( "};\n");
950 print_proxy( "\n");
951 print_proxy("static int __proxy_filter( struct __proxy_frame *__frame )\n");
952 print_proxy( "{\n");
953 print_proxy( " return (__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE);\n");
954 print_proxy( "}\n");
955 print_proxy( "\n");
956 }
957
960 write_proxy_stmts(stmts, &proc_offset);
961
967
968 print_proxy( "#if !defined(__RPC_WIN%u__)\n", pointer_size == 8 ? 64 : 32);
969 print_proxy( "#error Invalid build platform for this proxy.\n");
970 print_proxy( "#endif\n");
971 print_proxy( "\n");
974
975 interfaces = sort_interfaces(stmts, &count);
976 fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id);
977 fprintf(proxy, "{\n");
978 for (i = 0; i < count; i++)
979 fprintf(proxy, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", interfaces[i]->name);
980 fprintf(proxy, " 0\n");
981 fprintf(proxy, "};\n");
982 fprintf(proxy, "\n");
983
984 fprintf(proxy, "static const CInterfaceStubVtbl* const _%s_StubVtblList[] =\n", file_id);
985 fprintf(proxy, "{\n");
986 for (i = 0; i < count; i++)
987 fprintf(proxy, " &_%sStubVtbl,\n", interfaces[i]->name);
988 fprintf(proxy, " 0\n");
989 fprintf(proxy, "};\n");
990 fprintf(proxy, "\n");
991
992 fprintf(proxy, "static PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id);
993 fprintf(proxy, "{\n");
994 for (i = 0; i < count; i++)
995 fprintf(proxy, " \"%s\",\n", interfaces[i]->name);
996 fprintf(proxy, " 0\n");
997 fprintf(proxy, "};\n");
998 fprintf(proxy, "\n");
999
1000 for (i = 0; i < count; i++)
1001 if ((have_baseiid = get_delegation_indirect( interfaces[i], NULL ))) break;
1002
1003 if (have_baseiid)
1004 {
1005 fprintf(proxy, "static const IID * _%s_BaseIIDList[] =\n", file_id);
1006 fprintf(proxy, "{\n");
1007 for (i = 0; i < count; i++)
1008 {
1009 if (get_delegation_indirect(interfaces[i], &delegate_to))
1010 fprintf( proxy, " &IID_%s, /* %s */\n", delegate_to->name, interfaces[i]->name );
1011 else
1012 fprintf( proxy, " 0,\n" );
1013 }
1014 fprintf(proxy, " 0\n");
1015 fprintf(proxy, "};\n");
1016 fprintf(proxy, "\n");
1017 }
1018
1019 fprintf(proxy, "static int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id);
1020 fprintf(proxy, "{\n");
1021 fprintf(proxy, " int low = 0, high = %d;\n", count - 1);
1022 fprintf(proxy, "\n");
1023 fprintf(proxy, " while (low <= high)\n");
1024 fprintf(proxy, " {\n");
1025 fprintf(proxy, " int pos = (low + high) / 2;\n");
1026 fprintf(proxy, " int res = IID_GENERIC_CHECK_IID(_%s, pIID, pos);\n", file_id);
1027 fprintf(proxy, " if (!res) { *pIndex = pos; return 1; }\n");
1028 fprintf(proxy, " if (res > 0) low = pos + 1;\n");
1029 fprintf(proxy, " else high = pos - 1;\n");
1030 fprintf(proxy, " }\n");
1031 fprintf(proxy, " return 0;\n");
1032 fprintf(proxy, "}\n");
1033 fprintf(proxy, "\n");
1034
1035 table_version = interpreted_mode ? 2 : 1;
1036 for (i = 0; i < count; i++)
1037 {
1038 if (type_iface_get_async_iface(interfaces[i]) != interfaces[i]) continue;
1039 if (table_version != 6)
1040 {
1041 fprintf(proxy, "static const IID *_AsyncInterfaceTable[] =\n");
1042 fprintf(proxy, "{\n");
1043 table_version = 6;
1044 }
1045 fprintf(proxy, " &IID_%s,\n", interfaces[i]->name);
1046 fprintf(proxy, " (IID*)(LONG_PTR)-1,\n");
1047 }
1048 if (table_version == 6)
1049 {
1050 fprintf(proxy, " 0\n");
1051 fprintf(proxy, "};\n");
1052 fprintf(proxy, "\n");
1053 }
1054
1055 fprintf(proxy, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id);
1056 fprintf(proxy, "{\n");
1057 fprintf(proxy, " (const PCInterfaceProxyVtblList*)_%s_ProxyVtblList,\n", file_id);
1058 fprintf(proxy, " (const PCInterfaceStubVtblList*)_%s_StubVtblList,\n", file_id);
1059 fprintf(proxy, " _%s_InterfaceNamesList,\n", file_id);
1060 if (have_baseiid) fprintf(proxy, " _%s_BaseIIDList,\n", file_id);
1061 else fprintf(proxy, " 0,\n");
1062 fprintf(proxy, " _%s_IID_Lookup,\n", file_id);
1063 fprintf(proxy, " %d,\n", count);
1064 fprintf(proxy, " %u,\n", table_version);
1065 fprintf(proxy, " %s,\n", table_version == 6 ? "_AsyncInterfaceTable" : "0");
1066 fprintf(proxy, " 0,\n");
1067 fprintf(proxy, " 0,\n");
1068 fprintf(proxy, " 0\n");
1069 fprintf(proxy, "};\n");
1070}
static void write_proxy_stmts(const statement_list_t *stmts, unsigned int *proc_offset)
Definition: proxy.c:855
static int need_proxy_and_inline_stubs(const type_t *iface)
Definition: proxy.c:829
static type_t ** sort_interfaces(const statement_list_t *stmts, int *count)
Definition: proxy.c:907
static void write_stubdescproto(void)
Definition: proxy.c:48
static void write_stubdesc(int expr_eval_routines)
Definition: proxy.c:54
Definition: name.c:39
void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:1770
static struct list expr_eval_routines
Definition: typegen.c:50
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
unsigned int pointer_size
Definition: widl.c:147
char * proxy_token
Definition: widl.c:125
char * header_name
Definition: widl.c:119

Referenced by write_proxies().

◆ write_proxy_stmts()

static void write_proxy_stmts ( const statement_list_t stmts,
unsigned int proc_offset 
)
static

Definition at line 855 of file proxy.c.

856{
857 const statement_t *stmt;
858 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
859 {
860 if (stmt->type == STMT_TYPE && type_get_type(stmt->u.type) == TYPE_INTERFACE)
861 {
862 type_t *iface = stmt->u.type;
863 if (need_proxy(iface))
864 {
865 write_proxy(iface, proc_offset);
867 write_proxy(type_iface_get_async_iface(iface), proc_offset);
868 }
869 }
870 }
871}
static void write_proxy(type_t *iface, unsigned int *proc_offset)
Definition: proxy.c:607

Referenced by write_proxy_routines().

◆ write_stub_methods()

static int write_stub_methods ( type_t iface,
int  skip 
)
static

Definition at line 550 of file proxy.c.

551{
552 const statement_t *stmt;
553 int i = 0;
554
555 if (type_iface_get_inherit(iface))
557 else
558 return i; /* skip IUnknown */
559
561 const var_t *func = stmt->u.var;
562 if (!is_callas(func->attrs)) {
563 int missing = 0;
564 const char * fname = get_name(func);
565 if(is_local(func->attrs)) {
566 const statement_t * callas_source = get_callas_source(iface, func);
567 if(!callas_source)
568 missing = 1;
569 else
570 fname = get_name(callas_source->u.var);
571 }
572 if (i) fprintf(proxy,",\n");
573 if (skip || missing) print_proxy("STUB_FORWARDING_FUNCTION");
574 else if (is_interpreted_func( iface, func ))
575 print_proxy( "(PRPC_STUB_FUNCTION)%s", interpreted_mode ? "NdrStubCall2" : "NdrStubCall" );
576 else print_proxy( "%s_%s_Stub", iface->name, fname);
577 i++;
578 }
579 }
580 return i;
581}

Referenced by write_proxy(), and write_stub_methods().

◆ write_stubdesc()

static void write_stubdesc ( int  expr_eval_routines)
static

Definition at line 54 of file proxy.c.

55{
56 print_proxy( "static const MIDL_STUB_DESC Object_StubDesc =\n{\n");
57 indent++;
58 print_proxy( "0,\n");
59 print_proxy( "NdrOleAllocate,\n");
60 print_proxy( "NdrOleFree,\n");
61 print_proxy( "{0}, 0, 0, %s, 0,\n", expr_eval_routines ? "ExprEvalRoutines" : "0");
62 print_proxy( "__MIDL_TypeFormatString.Format,\n");
63 print_proxy( "1, /* -error bounds_check flag */\n");
64 print_proxy( "0x%x, /* Ndr library version */\n", interpreted_mode ? 0x50002 : 0x10001);
65 print_proxy( "0,\n");
66 print_proxy( "0x50200ca, /* MIDL Version 5.2.202 */\n");
67 print_proxy( "0,\n");
68 print_proxy("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
69 print_proxy( "0, /* notify & notify_flag routine table */\n");
70 print_proxy( "1, /* Flags */\n");
71 print_proxy( "0, /* Reserved3 */\n");
72 print_proxy( "0, /* Reserved4 */\n");
73 print_proxy( "0 /* Reserved5 */\n");
74 indent--;
75 print_proxy( "};\n");
76 print_proxy( "\n");
77}
static int list_empty(struct list_entry *head)
Definition: list.h:58
user_type_list_t user_type_list
Definition: header.c:39

Referenced by write_proxy_routines().

◆ write_stubdescproto()

static void write_stubdescproto ( void  )
static

Definition at line 48 of file proxy.c.

49{
50 print_proxy( "static const MIDL_STUB_DESC Object_StubDesc;\n");
51 print_proxy( "\n");
52}

Referenced by write_proxy_routines().

◆ write_thunk_methods()

static void write_thunk_methods ( type_t iface,
int  skip 
)
static

Definition at line 583 of file proxy.c.

584{
585 const statement_t *stmt;
586
587 if (type_iface_get_inherit( iface ))
589 else
590 return; /* skip IUnknown */
591
593 {
594 var_t *func = stmt->u.var;
595 const statement_t * callas_source = NULL;
596
597 if (is_callas(func->attrs)) continue;
598 if (is_local(func->attrs)) callas_source = get_callas_source(iface, func);
599
600 if (!skip && callas_source && is_interpreted_func( iface, func ))
601 print_proxy( "%s_%s_Thunk,\n", iface->name, get_name(callas_source->u.var) );
602 else
603 print_proxy( "0, /* %s::%s */\n", iface->name, get_name(func) );
604 }
605}

Referenced by write_proxy(), and write_thunk_methods().

Variable Documentation

◆ indent

◆ proxy