2 * Format String Generator for IDL Compiler
4 * Copyright 2005-2006 Eric Kohl
5 * Copyright 2005-2006 Robert Shearman
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
41 #include "wine/list.h"
46 static const func_t
*current_func
;
47 static const type_t
*current_structure
;
49 /* name of the structure variable for structure callbacks */
50 #define STRUCT_EXPR_EVAL_VAR "pS"
52 static struct list expr_eval_routines
= LIST_INIT(expr_eval_routines
);
54 struct expr_eval_routine
57 const type_t
*structure
;
58 size_t structure_size
;
62 static size_t type_memsize(const type_t
*t
, int ptr_level
, const array_dims_t
*array
, unsigned int *align
);
63 static size_t fields_memsize(const var_list_t
*fields
, unsigned int *align
);
65 static int compare_expr(const expr_t
*a
, const expr_t
*b
)
69 if (a
->type
!= b
->type
)
70 return a
->type
- b
->type
;
77 return a
->u
.lval
- b
->u
.lval
;
79 return strcmp(a
->u
.sval
, b
->u
.sval
);
81 ret
= compare_expr(a
->ref
, b
->ref
);
84 ret
= compare_expr(a
->u
.ext
, b
->u
.ext
);
87 return compare_expr(a
->ext2
, b
->ext2
);
96 ret
= compare_expr(a
->ref
, b
->ref
);
99 return compare_expr(a
->u
.ext
, b
->u
.ext
);
105 return compare_expr(a
->ref
, b
->ref
);
112 #define WRITE_FCTYPE(file, fctype, typestring_offset) \
115 fprintf(file, "/* %2u */\n", typestring_offset); \
116 print_file((file), 2, "0x%02x, /* " #fctype " */\n", RPC_##fctype); \
120 static int print_file(FILE *file
, int indent
, const char *format
, ...)
127 va_start(va
, format
);
128 for (i
= 0; i
< indent
; i
++)
130 r
= vfprintf(file
, format
, va
);
135 static void write_formatdesc(FILE *f
, int indent
, const char *str
)
137 print_file(f
, indent
, "typedef struct _MIDL_%s_FORMAT_STRING\n", str
);
138 print_file(f
, indent
, "{\n");
139 print_file(f
, indent
+ 1, "short Pad;\n");
140 print_file(f
, indent
+ 1, "unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str
);
141 print_file(f
, indent
, "} MIDL_%s_FORMAT_STRING;\n", str
);
142 print_file(f
, indent
, "\n");
145 void write_formatstringsdecl(FILE *f
, int indent
, ifref_list_t
*ifaces
, int for_objects
)
147 print_file(f
, indent
, "#define TYPE_FORMAT_STRING_SIZE %d\n",
148 get_size_typeformatstring(ifaces
, for_objects
));
150 print_file(f
, indent
, "#define PROC_FORMAT_STRING_SIZE %d\n",
151 get_size_procformatstring(ifaces
, for_objects
));
154 write_formatdesc(f
, indent
, "TYPE");
155 write_formatdesc(f
, indent
, "PROC");
157 print_file(f
, indent
, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
158 print_file(f
, indent
, "static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
159 print_file(f
, indent
, "\n");
162 static int is_user_derived(const var_t
*v
)
164 const type_t
*type
= v
->type
;
166 if (v
->attrs
&& is_attr( v
->attrs
, ATTR_WIREMARSHAL
)) return 1;
170 if (type
->attrs
&& is_attr( type
->attrs
, ATTR_WIREMARSHAL
)) return 1;
176 static inline int is_base_type(unsigned char type
)
195 case RPC_FC_ERROR_STATUS_T
:
196 case RPC_FC_BIND_PRIMITIVE
:
204 static size_t write_procformatstring_var(FILE *file
, int indent
,
205 const var_t
*var
, int is_return
, unsigned int *type_offset
)
208 int ptr_level
= var
->ptr_level
;
209 const type_t
*type
= var
->type
;
211 int is_in
= is_attr(var
->attrs
, ATTR_IN
);
212 int is_out
= is_attr(var
->attrs
, ATTR_OUT
);
214 if (!is_in
&& !is_out
) is_in
= TRUE
;
216 if (ptr_level
== 0 && !var
->array
&& is_base_type(type
->type
))
219 print_file(file
, indent
, "0x53, /* FC_RETURN_PARAM_BASETYPE */\n");
221 print_file(file
, indent
, "0x4e, /* FC_IN_PARAM_BASETYPE */\n");
225 #define CASE_BASETYPE(fctype) \
227 print_file(file, indent, "0x%02x, /* " #fctype " */\n", RPC_##fctype); \
228 size = 2; /* includes param type prefix */ \
231 CASE_BASETYPE(FC_BYTE
);
232 CASE_BASETYPE(FC_CHAR
);
233 CASE_BASETYPE(FC_WCHAR
);
234 CASE_BASETYPE(FC_USHORT
);
235 CASE_BASETYPE(FC_SHORT
);
236 CASE_BASETYPE(FC_ULONG
);
237 CASE_BASETYPE(FC_LONG
);
238 CASE_BASETYPE(FC_HYPER
);
239 CASE_BASETYPE(FC_IGNORE
);
240 CASE_BASETYPE(FC_USMALL
);
241 CASE_BASETYPE(FC_SMALL
);
242 CASE_BASETYPE(FC_FLOAT
);
243 CASE_BASETYPE(FC_DOUBLE
);
244 CASE_BASETYPE(FC_ERROR_STATUS_T
);
247 case RPC_FC_BIND_PRIMITIVE
:
248 print_file(file
, indent
, "0x%02x, /* FC_IGNORE */\n", RPC_FC_IGNORE
);
249 size
= 2; /* includes param type prefix */
253 error("Unknown/unsupported type: %s (0x%02x)\n", var
->name
, type
->type
);
260 print_file(file
, indent
, "0x52, /* FC_RETURN_PARAM */\n");
261 else if (is_in
&& is_out
)
262 print_file(file
, indent
, "0x50, /* FC_IN_OUT_PARAM */\n");
264 print_file(file
, indent
, "0x51, /* FC_OUT_PARAM */\n");
266 print_file(file
, indent
, "0x4d, /* FC_IN_PARAM */\n");
268 print_file(file
, indent
, "0x01,\n");
269 print_file(file
, indent
, "NdrFcShort(0x%x),\n", *type_offset
);
270 size
= 4; /* includes param type prefix */
272 *type_offset
+= get_size_typeformatstring_var(var
);
276 void write_procformatstring(FILE *file
, const ifref_list_t
*ifaces
, int for_objects
)
278 const ifref_t
*iface
;
281 unsigned int type_offset
= 2;
283 print_file(file
, indent
, "static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =\n");
284 print_file(file
, indent
, "{\n");
286 print_file(file
, indent
, "0,\n");
287 print_file(file
, indent
, "{\n");
290 if (ifaces
) LIST_FOR_EACH_ENTRY( iface
, ifaces
, const ifref_t
, entry
)
292 if (for_objects
!= is_object(iface
->iface
->attrs
) || is_local(iface
->iface
->attrs
))
295 if (iface
->iface
->funcs
)
298 LIST_FOR_EACH_ENTRY( func
, iface
->iface
->funcs
, const func_t
, entry
)
300 if (is_local(func
->def
->attrs
)) continue;
301 /* emit argument data */
304 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
305 write_procformatstring_var(file
, indent
, var
, FALSE
, &type_offset
);
308 /* emit return value data */
310 if (is_void(var
->type
, NULL
))
312 print_file(file
, indent
, "0x5b, /* FC_END */\n");
313 print_file(file
, indent
, "0x5c, /* FC_PAD */\n");
316 write_procformatstring_var(file
, indent
, var
, TRUE
,
322 print_file(file
, indent
, "0x0\n");
324 print_file(file
, indent
, "}\n");
326 print_file(file
, indent
, "};\n");
327 print_file(file
, indent
, "\n");
330 static int write_base_type(FILE *file
, const type_t
*type
, unsigned int *typestring_offset
)
334 #define CASE_BASETYPE(fctype) \
336 print_file(file, 2, "0x%02x, /* " #fctype " */\n", RPC_##fctype); \
337 *typestring_offset += 1; \
340 CASE_BASETYPE(FC_BYTE
);
341 CASE_BASETYPE(FC_CHAR
);
342 CASE_BASETYPE(FC_SMALL
);
343 CASE_BASETYPE(FC_USMALL
);
344 CASE_BASETYPE(FC_WCHAR
);
345 CASE_BASETYPE(FC_SHORT
);
346 CASE_BASETYPE(FC_USHORT
);
347 CASE_BASETYPE(FC_LONG
);
348 CASE_BASETYPE(FC_ULONG
);
349 CASE_BASETYPE(FC_FLOAT
);
350 CASE_BASETYPE(FC_HYPER
);
351 CASE_BASETYPE(FC_DOUBLE
);
352 CASE_BASETYPE(FC_ENUM16
);
353 CASE_BASETYPE(FC_ENUM32
);
354 CASE_BASETYPE(FC_IGNORE
);
355 CASE_BASETYPE(FC_ERROR_STATUS_T
);
361 /* write conformance / variance descriptor */
362 static size_t write_conf_or_var_desc(FILE *file
, const func_t
*func
, const type_t
*structure
, const expr_list_t
*expr_list
)
364 unsigned char operator_type
= 0;
365 const char *operator_string
= "no operators";
366 const expr_t
*expr
, *subexpr
;
367 unsigned char correlation_type
;
369 if (!file
) return 4; /* optimisation for sizing pass */
371 if (list_count(expr_list
) > 1)
372 error("write_conf_or_var_desc: multi-dimensional arrays not supported yet\n");
374 expr
= subexpr
= LIST_ENTRY( list_head(expr_list
), const expr_t
, entry
);
378 if (expr
->cval
> UCHAR_MAX
* (USHRT_MAX
+ 1) + USHRT_MAX
)
379 error("write_conf_or_var_desc: constant value %ld is greater than "
380 "the maximum constant size of %d\n", expr
->cval
,
381 UCHAR_MAX
* (USHRT_MAX
+ 1) + USHRT_MAX
);
383 print_file(file
, 2, "0x%x, /* Corr desc: constant, val = %ld */\n",
384 RPC_FC_CONSTANT_CONFORMANCE
, expr
->cval
);
385 print_file(file
, 2, "0x%x,\n", expr
->cval
& ~USHRT_MAX
);
386 print_file(file
, 2, "NdrFcShort(0x%x),\n", expr
->cval
& USHRT_MAX
);
391 switch (subexpr
->type
)
394 subexpr
= subexpr
->ref
;
395 operator_type
= RPC_FC_DEREFERENCE
;
396 operator_string
= "FC_DEREFERENCE";
399 if (subexpr
->u
.ext
->is_const
&& (subexpr
->u
.ext
->cval
== 2))
401 subexpr
= subexpr
->ref
;
402 operator_type
= RPC_FC_DIV_2
;
403 operator_string
= "FC_DIV_2";
407 if (subexpr
->u
.ext
->is_const
&& (subexpr
->u
.ext
->cval
== 2))
409 subexpr
= subexpr
->ref
;
410 operator_type
= RPC_FC_MULT_2
;
411 operator_string
= "FC_MULT_2";
415 if (subexpr
->u
.ext
->is_const
&& (subexpr
->u
.ext
->cval
== 1))
417 subexpr
= subexpr
->ref
;
418 operator_type
= RPC_FC_SUB_1
;
419 operator_string
= "FC_SUB_1";
423 if (subexpr
->u
.ext
->is_const
&& (subexpr
->u
.ext
->cval
== 1))
425 subexpr
= subexpr
->ref
;
426 operator_type
= RPC_FC_ADD_1
;
427 operator_string
= "FC_ADD_1";
434 if (subexpr
->type
== EXPR_IDENTIFIER
)
436 const type_t
*correlation_variable
= NULL
;
437 unsigned char correlation_variable_type
;
438 unsigned char param_type
= 0;
439 const char *param_type_string
= NULL
;
447 if (structure
->fields
) LIST_FOR_EACH_ENTRY( var
, structure
->fields
, const var_t
, entry
)
449 unsigned int align
= 0;
450 offset
-= type_memsize(var
->type
, var
->ptr_level
, var
->array
, &align
);
451 /* FIXME: take alignment into account */
452 if (!strcmp(var
->name
, subexpr
->u
.sval
))
454 correlation_variable
= var
->type
;
458 if (!correlation_variable
)
459 error("write_conf_or_var_desc: couldn't find variable %s in structure\n",
462 correlation_type
= RPC_FC_NORMAL_CONFORMANCE
;
469 if (func
->args
) LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
471 if (!strcmp(var
->name
, subexpr
->u
.sval
))
473 correlation_variable
= var
->type
;
476 /* FIXME: not all stack variables are sizeof(void *) */
477 offset
+= sizeof(void *);
479 if (!correlation_variable
)
480 error("write_conf_or_var_desc: couldn't find variable %s in function\n",
483 correlation_type
= RPC_FC_TOP_LEVEL_CONFORMANCE
;
486 correlation_variable_type
= correlation_variable
->type
;
488 switch (correlation_variable_type
)
492 param_type
= RPC_FC_SMALL
;
493 param_type_string
= "FC_SMALL";
497 param_type
= RPC_FC_USMALL
;
498 param_type_string
= "FC_USMALL";
502 param_type
= RPC_FC_SHORT
;
503 param_type_string
= "FC_SHORT";
506 param_type
= RPC_FC_USHORT
;
507 param_type_string
= "FC_USHORT";
510 param_type
= RPC_FC_LONG
;
511 param_type_string
= "FC_LONG";
514 param_type
= RPC_FC_ULONG
;
515 param_type_string
= "FC_ULONG";
518 error("write_conf_or_var_desc: conformance variable type not supported 0x%x\n",
519 correlation_variable_type
);
522 print_file(file
, 2, "0x%x, /* Corr desc: %s%s */\n",
523 correlation_type
| param_type
,
524 correlation_type
== RPC_FC_TOP_LEVEL_CONFORMANCE
? "parameter, " : "",
526 print_file(file
, 2, "0x%x, /* %s */\n", operator_type
, operator_string
);
527 print_file(file
, 2, "NdrFcShort(0x%x), /* %soffset = %d */\n",
529 correlation_type
== RPC_FC_TOP_LEVEL_CONFORMANCE
? "x86 stack size / " : "",
534 unsigned int callback_offset
= 0;
538 struct expr_eval_routine
*eval
;
541 LIST_FOR_EACH_ENTRY(eval
, &expr_eval_routines
, struct expr_eval_routine
, entry
)
543 if (!strcmp(eval
->structure
->name
, structure
->name
) &&
544 !compare_expr(eval
->expr
, expr
))
554 unsigned int align
= 0;
555 eval
= xmalloc(sizeof(*eval
));
556 eval
->structure
= structure
;
557 eval
->structure_size
= fields_memsize(structure
->fields
, &align
);
559 list_add_tail(&expr_eval_routines
, &eval
->entry
);
562 correlation_type
= RPC_FC_NORMAL_CONFORMANCE
;
566 error("write_conf_or_var_desc: top-level callback conformance unimplemented\n");
567 correlation_type
= RPC_FC_TOP_LEVEL_CONFORMANCE
;
570 if (callback_offset
> USHRT_MAX
)
571 error("Maximum number of callback routines reached\n");
573 print_file(file
, 2, "0x%x, /* Corr desc: %s */\n",
575 correlation_type
== RPC_FC_TOP_LEVEL_CONFORMANCE
? "parameter" : "");
576 print_file(file
, 2, "0x%x, /* %s */\n", RPC_FC_CALLBACK
, "FC_CALLBACK");
577 print_file(file
, 2, "NdrFcShort(0x%x), /* %u */\n", callback_offset
, callback_offset
);
582 static size_t fields_memsize(const var_list_t
*fields
, unsigned int *align
)
587 if (!fields
) return 0;
588 LIST_FOR_EACH_ENTRY( v
, fields
, const var_t
, entry
)
589 size
+= type_memsize(v
->type
, v
->ptr_level
, v
->array
, align
);
594 static size_t get_array_size( const array_dims_t
*array
)
599 if (!array
) return 0;
601 LIST_FOR_EACH_ENTRY( dim
, array
, expr_t
, entry
)
603 if (!dim
->is_const
) return 0;
610 static size_t type_memsize(const type_t
*t
, int ptr_level
, const array_dims_t
*array
, unsigned int *align
)
616 size
= sizeof(void *);
617 if (size
> *align
) *align
= size
;
619 else switch (t
->type
)
626 if (size
> *align
) *align
= size
;
633 if (size
> *align
) *align
= size
;
637 case RPC_FC_ERROR_STATUS_T
:
641 if (size
> *align
) *align
= size
;
646 if (size
> *align
) *align
= size
;
649 case RPC_FC_CVSTRUCT
:
650 case RPC_FC_CPSTRUCT
:
653 case RPC_FC_BOGUS_STRUCT
:
654 case RPC_FC_ENCAPSULATED_UNION
:
655 case RPC_FC_NON_ENCAPSULATED_UNION
:
656 size
= fields_memsize(t
->fields
, align
);
659 error("type_memsize: Unknown type %d\n", t
->type
);
663 if (array
) size
*= get_array_size( array
);
667 static int write_pointers(FILE *file
, const attr_list_t
*attrs
,
668 const type_t
*type
, int ptr_level
,
669 const array_dims_t
*array
, int level
,
670 unsigned int *typestring_offset
)
672 int pointers_written
= 0;
675 /* don't generate a pointer for first-level arrays since we want to
676 * descend into them to write their pointers, not stop here */
677 if ((level
== 0 || ptr_level
== 0) && is_array_type(attrs
, ptr_level
, array
))
679 return write_pointers(file
, NULL
, type
, 0, NULL
, level
+ 1, typestring_offset
);
684 /* FIXME: only general algorithm implemented, not the actual writing */
685 error("write_pointers: Writing type format string for pointer is unimplemented\n");
691 /* note: don't descend into complex structures or unions since these
692 * will always be generated as a separate type */
694 case RPC_FC_CVSTRUCT
:
695 case RPC_FC_CPSTRUCT
:
698 if (!type
->fields
) break;
699 LIST_FOR_EACH_ENTRY( v
, type
->fields
, const var_t
, entry
)
700 pointers_written
+= write_pointers(file
, v
->attrs
, v
->type
,
701 v
->ptr_level
, v
->array
,
712 return pointers_written
;
715 static size_t write_pointer_description(FILE *file
, const attr_list_t
*attrs
,
716 const type_t
*type
, int ptr_level
,
717 const array_dims_t
*array
, int level
,
718 size_t typestring_offset
)
723 /* don't generate a pointer for first-level arrays since we want to
724 * descend into them to write their pointers, not stop here */
725 if ((level
== 0 || ptr_level
== 0) && is_array_type(attrs
, ptr_level
, array
))
727 return write_pointer_description(file
, NULL
, type
, 0, NULL
,
728 level
+ 1, typestring_offset
);
733 /* FIXME: only general algorithm implemented, not the actual writing */
734 error("write_pointer_description: Writing pointer description is unimplemented\n");
738 /* FIXME: search through all refs for pointers too */
742 /* note: don't descend into complex structures or unions since these
743 * will always be generated as a separate type */
745 case RPC_FC_CVSTRUCT
:
746 case RPC_FC_CPSTRUCT
:
749 if (!type
->fields
) break;
750 LIST_FOR_EACH_ENTRY( v
, type
->fields
, const var_t
, entry
)
751 size
+= write_pointer_description(file
, v
->attrs
, v
->type
,
752 v
->ptr_level
, v
->array
,
766 static size_t write_string_tfs(FILE *file
, const attr_list_t
*attrs
,
767 const type_t
*type
, const array_dims_t
*array
,
768 const char *name
, unsigned int *typestring_offset
)
770 const expr_list_t
*size_is
= get_attrp(attrs
, ATTR_SIZEIS
);
771 int has_size
= is_non_void(size_is
);
772 size_t start_offset
= *typestring_offset
;
773 unsigned char flags
= 0;
779 pointer_type
= type
->type
;
783 pointer_type
= get_attrv(attrs
, ATTR_POINTERTYPE
);
786 pointer_type
= RPC_FC_RP
;
788 if (!get_attrp(attrs
, ATTR_SIZEIS
))
789 flags
|= RPC_FC_P_SIMPLEPOINTER
;
793 if ((rtype
!= RPC_FC_BYTE
) && (rtype
!= RPC_FC_CHAR
) && (rtype
!= RPC_FC_WCHAR
))
795 error("write_string_tfs: Unimplemented for type 0x%x of name: %s\n", rtype
, name
);
799 print_file(file
, 2,"0x%x, 0x%x, /* %s%s */\n",
801 pointer_type
== RPC_FC_FP
? "FC_FP" : (pointer_type
== RPC_FC_UP
? "FC_UP" : "FC_RP"),
802 (flags
& RPC_FC_P_SIMPLEPOINTER
) ? " [simple_pointer]" : "");
803 *typestring_offset
+= 2;
805 if (!(flags
& RPC_FC_P_SIMPLEPOINTER
))
807 print_file(file
, 2, "NdrFcShort(0x2),\n");
808 *typestring_offset
+= 2;
811 if (array
&& !is_conformant_array(array
))
813 /* FIXME: multi-dimensional array */
814 const expr_t
*dim
= LIST_ENTRY( list_head( array
), expr_t
, entry
);
815 if (dim
->cval
> USHRT_MAX
)
816 error("array size for parameter %s exceeds %d bytes by %ld bytes\n",
817 name
, USHRT_MAX
, dim
->cval
- USHRT_MAX
);
819 if (rtype
== RPC_FC_CHAR
)
820 WRITE_FCTYPE(file
, FC_CSTRING
, *typestring_offset
);
822 WRITE_FCTYPE(file
, FC_WSTRING
, *typestring_offset
);
823 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
824 *typestring_offset
+= 2;
826 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", dim
->cval
, dim
->cval
);
827 *typestring_offset
+= 2;
833 if (rtype
== RPC_FC_CHAR
)
834 WRITE_FCTYPE(file
, FC_C_CSTRING
, *typestring_offset
);
836 WRITE_FCTYPE(file
, FC_C_WSTRING
, *typestring_offset
);
837 print_file(file
, 2, "0x%x, /* FC_STRING_SIZED */\n", RPC_FC_STRING_SIZED
);
838 *typestring_offset
+= 2;
840 *typestring_offset
+= write_conf_or_var_desc(file
, current_func
, NULL
, size_is
);
846 if (rtype
== RPC_FC_CHAR
)
847 WRITE_FCTYPE(file
, FC_C_CSTRING
, *typestring_offset
);
849 WRITE_FCTYPE(file
, FC_C_WSTRING
, *typestring_offset
);
850 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
851 *typestring_offset
+= 2;
857 static size_t write_array_tfs(FILE *file
, const attr_list_t
*attrs
,
858 const type_t
*type
, const array_dims_t
*array
,
859 const char *name
, unsigned int *typestring_offset
)
861 const expr_list_t
*length_is
= get_attrp(attrs
, ATTR_LENGTHIS
);
862 const expr_list_t
*size_is
= get_attrp(attrs
, ATTR_SIZEIS
);
863 int has_length
= is_non_void(length_is
);
864 int has_size
= is_non_void(size_is
) || is_conformant_array(array
);
866 int pointer_type
= get_attrv(attrs
, ATTR_POINTERTYPE
);
868 pointer_type
= RPC_FC_RP
;
870 print_file(file
, 2, "0x%x, 0x00, /* %s */\n",
872 pointer_type
== RPC_FC_FP
? "FC_FP" : (pointer_type
== RPC_FC_UP
? "FC_UP" : "FC_RP"));
873 print_file(file
, 2, "NdrFcShort(0x2),\n");
874 *typestring_offset
+= 4;
876 if (array
&& list_count(array
) > 1) /* multi-dimensional array */
878 error("write_array_tfs: Multi-dimensional arrays not implemented yet (param %s)\n", name
);
883 const expr_t
*dim
= array
? LIST_ENTRY( list_head( array
), expr_t
, entry
) : NULL
;
884 size_t pointer_start_offset
= *typestring_offset
;
887 if (write_pointers(file
, attrs
, type
, 0, array
, 0, typestring_offset
) > 0)
890 start_offset
= *typestring_offset
;
892 if (!has_length
&& !has_size
)
895 unsigned int align
= 0;
896 size_t size
= type_memsize(type
, 0, array
, &align
);
897 if (size
< USHRT_MAX
)
899 WRITE_FCTYPE(file
, FC_SMFARRAY
, *typestring_offset
);
901 print_file(file
, 2, "0x%02x,\n", align
- 1);
903 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", size
, size
);
904 *typestring_offset
+= 4;
908 WRITE_FCTYPE(file
, FC_LGFARRAY
, *typestring_offset
);
910 print_file(file
, 2, "0x%02x,\n", align
- 1);
912 print_file(file
, 2, "NdrFcLong(0x%x), /* %d */\n", size
, size
);
913 *typestring_offset
+= 6;
918 print_file(file
, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP
);
919 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
920 *typestring_offset
+= 2;
921 *typestring_offset
= write_pointer_description(file
, attrs
,
922 type
, 0, array
, 0, pointer_start_offset
);
923 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
924 *typestring_offset
+= 1;
927 if (!write_base_type( file
, type
, typestring_offset
))
929 print_file(file
, 2, "0x0, /* FIXME: write out conversion data */\n");
930 *typestring_offset
+= 1;
932 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
933 *typestring_offset
+= 1;
937 else if (has_length
&& !has_size
)
940 unsigned int align
= 0;
941 size_t element_size
= type_memsize(type
, 0, NULL
, &align
);
942 size_t elements
= dim
->cval
;
943 size_t total_size
= element_size
* elements
;
945 if (total_size
< USHRT_MAX
)
947 WRITE_FCTYPE(file
, FC_SMVARRAY
, *typestring_offset
);
949 print_file(file
, 2, "0x%02x,\n", align
- 1);
951 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", total_size
, total_size
);
952 /* number of elements */
953 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", elements
, elements
);
954 *typestring_offset
+= 6;
958 WRITE_FCTYPE(file
, FC_LGVARRAY
, *typestring_offset
);
960 print_file(file
, 2, "0x%02x,\n", align
- 1);
962 print_file(file
, 2, "NdrFcLong(0x%x), /* %d */\n", total_size
, total_size
);
963 /* number of elements */
964 print_file(file
, 2, "NdrFcLong(0x%x), /* %d */\n", elements
, elements
);
965 *typestring_offset
+= 10;
968 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", element_size
, element_size
);
969 *typestring_offset
+= 2;
971 *typestring_offset
+= write_conf_or_var_desc(file
, current_func
,
977 print_file(file
, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP
);
978 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
979 *typestring_offset
+= 2;
980 *typestring_offset
+= write_pointer_description(file
, attrs
,
981 type
, 0, array
, 0, pointer_start_offset
);
982 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
983 *typestring_offset
+= 1;
986 if (!write_base_type( file
, type
, typestring_offset
))
988 print_file(file
, 2, "0x0, /* FIXME: write out conversion data */\n");
989 *typestring_offset
+= 1;
991 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
992 *typestring_offset
+= 1;
996 else if (!has_length
&& has_size
)
998 /* conformant array */
999 unsigned int align
= 0;
1000 size_t element_size
= type_memsize(type
, 0, NULL
, &align
);
1002 WRITE_FCTYPE(file
, FC_CARRAY
, *typestring_offset
);
1004 print_file(file
, 2, "0x%02x,\n", align
- 1);
1006 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", element_size
, element_size
);
1007 *typestring_offset
+= 4;
1009 *typestring_offset
+= write_conf_or_var_desc(file
, current_func
,
1011 size_is
? size_is
: array
);
1015 print_file(file
, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP
);
1016 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
1017 *typestring_offset
+= 2;
1018 *typestring_offset
+= write_pointer_description(file
, attrs
,
1019 type
, 0, array
, 0, pointer_start_offset
);
1020 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1021 *typestring_offset
+= 1;
1024 if (!write_base_type( file
, type
, typestring_offset
))
1026 print_file(file
, 2, "0x0, /* FIXME: write out conversion data */\n");
1027 *typestring_offset
+= 1;
1029 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1030 *typestring_offset
+= 1;
1032 return start_offset
;
1036 /* conformant varying array */
1037 unsigned int align
= 0;
1038 size_t element_size
= type_memsize(type
, 0, NULL
, &align
);
1040 WRITE_FCTYPE(file
, FC_CVARRAY
, *typestring_offset
);
1042 print_file(file
, 2, "0x%02x,\n", align
- 1);
1044 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", element_size
, element_size
);
1045 *typestring_offset
+= 4;
1047 *typestring_offset
+= write_conf_or_var_desc(file
, current_func
,
1049 size_is
? size_is
: array
);
1050 *typestring_offset
+= write_conf_or_var_desc(file
, current_func
,
1056 print_file(file
, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP
);
1057 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
1058 *typestring_offset
+= 2;
1059 *typestring_offset
+= write_pointer_description(file
, attrs
,
1060 type
, 0, array
, 0, pointer_start_offset
);
1061 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1062 *typestring_offset
+= 1;
1065 if (!write_base_type( file
, type
, typestring_offset
))
1067 print_file(file
, 2, "0x0, /* FIXME: write out conversion data */\n");
1068 *typestring_offset
+= 1;
1070 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1071 *typestring_offset
+= 1;
1073 return start_offset
;
1078 static const var_t
*find_array_or_string_in_struct(const type_t
*type
)
1080 const var_t
*last_field
= LIST_ENTRY( list_tail(type
->fields
), const var_t
, entry
);
1082 if (is_array_type(last_field
->attrs
, last_field
->ptr_level
, last_field
->array
))
1085 assert((last_field
->type
->type
== RPC_FC_CSTRUCT
) ||
1086 (last_field
->type
->type
== RPC_FC_CPSTRUCT
) ||
1087 (last_field
->type
->type
== RPC_FC_CVSTRUCT
));
1089 return find_array_or_string_in_struct(last_field
->type
);
1092 static void write_struct_members(FILE *file
, const type_t
*type
, unsigned int *typestring_offset
)
1096 if (type
->fields
) LIST_FOR_EACH_ENTRY( field
, type
->fields
, const var_t
, entry
)
1098 unsigned char rtype
= field
->type
->type
;
1101 write_array_tfs( file
, field
->attrs
, field
->type
, field
->array
,
1102 field
->name
, typestring_offset
);
1103 else if (!write_base_type( file
, field
->type
, typestring_offset
))
1104 error("Unsupported member type 0x%x\n", rtype
);
1107 if (!(*typestring_offset
% 2))
1109 print_file(file
, 2, "0x%x,\t\t/* FC_PAD */\n", RPC_FC_PAD
);
1110 *typestring_offset
+= 1;
1113 print_file(file
, 2, "0x%x,\t\t/* FC_END */\n", RPC_FC_END
);
1114 *typestring_offset
+= 1;
1117 static size_t write_struct_tfs(FILE *file
, const type_t
*type
,
1118 const char *name
, unsigned int *typestring_offset
)
1120 unsigned int total_size
;
1122 size_t start_offset
;
1123 size_t array_offset
;
1124 size_t pointer_offset
;
1125 unsigned int align
= 0;
1130 case RPC_FC_PSTRUCT
:
1131 total_size
= type_memsize(type
, 0, NULL
, &align
);
1133 if (total_size
> USHRT_MAX
)
1134 error("structure size for parameter %s exceeds %d bytes by %d bytes\n",
1135 name
, USHRT_MAX
, total_size
- USHRT_MAX
);
1137 if (type
->type
== RPC_FC_PSTRUCT
)
1139 pointer_offset
= *typestring_offset
;
1140 write_pointers(file
, NULL
, type
, 0, NULL
, 0, typestring_offset
);
1142 else pointer_offset
= 0; /* silence warning */
1144 start_offset
= *typestring_offset
;
1145 if (type
->type
== RPC_FC_STRUCT
)
1146 WRITE_FCTYPE(file
, FC_STRUCT
, *typestring_offset
);
1148 WRITE_FCTYPE(file
, FC_PSTRUCT
, *typestring_offset
);
1150 print_file(file
, 2, "0x%02x,\n", align
- 1);
1152 print_file(file
, 2, "NdrFcShort(0x%x), /* %u */\n", total_size
, total_size
);
1153 *typestring_offset
+= 4;
1155 if (type
->type
== RPC_FC_PSTRUCT
)
1157 print_file(file
, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP
);
1158 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
1159 *typestring_offset
+= 2;
1160 *typestring_offset
+= write_pointer_description(file
, NULL
,
1161 type
, 0, NULL
, 0, pointer_offset
);
1162 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1163 *typestring_offset
+= 1;
1167 write_struct_members(file
, type
, typestring_offset
);
1168 return start_offset
;
1169 case RPC_FC_CSTRUCT
:
1170 case RPC_FC_CPSTRUCT
:
1171 total_size
= type_memsize(type
, 0, NULL
, &align
);
1173 if (total_size
> USHRT_MAX
)
1174 error("structure size for parameter %s exceeds %d bytes by %d bytes\n",
1175 name
, USHRT_MAX
, total_size
- USHRT_MAX
);
1177 array
= find_array_or_string_in_struct(type
);
1178 current_structure
= type
;
1179 array_offset
= write_array_tfs(file
, array
->attrs
, array
->type
,
1180 array
->array
, array
->name
,
1182 current_structure
= NULL
;
1184 if (type
->type
== RPC_FC_CPSTRUCT
)
1186 pointer_offset
= *typestring_offset
;
1187 write_pointers(file
, NULL
, type
, 0, NULL
, 0, typestring_offset
);
1189 else pointer_offset
= 0; /* silence warning */
1191 start_offset
= *typestring_offset
;
1192 if (type
->type
== RPC_FC_CSTRUCT
)
1193 WRITE_FCTYPE(file
, FC_CSTRUCT
, *typestring_offset
);
1195 WRITE_FCTYPE(file
, FC_CPSTRUCT
, *typestring_offset
);
1197 print_file(file
, 2, "0x%02x,\n", align
- 1);
1199 print_file(file
, 2, "NdrFcShort(0x%x), /* %u */\n", total_size
, total_size
);
1200 *typestring_offset
+= 4;
1201 print_file(file
, 2, "NdrFcShort(0x%x), /* offset = %d (%u) */\n",
1202 array_offset
- *typestring_offset
,
1203 array_offset
- *typestring_offset
,
1205 *typestring_offset
+= 2;
1207 if (type
->type
== RPC_FC_CPSTRUCT
)
1209 print_file(file
, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP
);
1210 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
1211 *typestring_offset
+= 2;
1212 *typestring_offset
+= write_pointer_description(file
, NULL
,
1213 type
, 0, NULL
, 0, pointer_offset
);
1214 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1215 *typestring_offset
+= 1;
1218 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1219 *typestring_offset
+= 1;
1221 return start_offset
;
1222 case RPC_FC_CVSTRUCT
:
1223 total_size
= type_memsize(type
, 0, NULL
, &align
);
1225 if (total_size
> USHRT_MAX
)
1226 error("structure size for parameter %s exceeds %d bytes by %d bytes\n",
1227 name
, USHRT_MAX
, total_size
- USHRT_MAX
);
1229 array
= find_array_or_string_in_struct(type
);
1230 current_structure
= type
;
1231 if (is_attr(array
->attrs
, ATTR_STRING
))
1232 array_offset
= write_string_tfs(file
, array
->attrs
, array
->type
,
1233 array
->array
, array
->name
,
1236 array_offset
= write_array_tfs(file
, array
->attrs
, array
->type
,
1237 array
->array
, array
->name
,
1239 current_structure
= NULL
;
1241 pointer_offset
= *typestring_offset
;
1242 if (!write_pointers(file
, NULL
, type
, 0, NULL
, 0, typestring_offset
))
1245 start_offset
= *typestring_offset
;
1246 WRITE_FCTYPE(file
, FC_CVSTRUCT
, *typestring_offset
);
1248 print_file(file
, 2, "0x%02x,\n", align
- 1);
1250 print_file(file
, 2, "NdrFcShort(0x%x), /* %u */\n", total_size
, total_size
);
1251 *typestring_offset
+= 4;
1252 print_file(file
, 2, "NdrFcShort(0x%x), /* offset = %d (%u) */\n",
1253 array_offset
- *typestring_offset
,
1254 array_offset
- *typestring_offset
,
1256 *typestring_offset
+= 2;
1258 if (pointer_offset
!= 0)
1260 print_file(file
, 2, "0x%x, /* FC_PP */\n", RPC_FC_PP
);
1261 print_file(file
, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD
);
1262 *typestring_offset
+= 2;
1263 *typestring_offset
+= write_pointer_description(file
, NULL
,
1264 type
, 0, NULL
, 0, pointer_offset
);
1265 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1266 *typestring_offset
+= 1;
1269 print_file(file
, 2, "0x%x, /* FC_END */\n", RPC_FC_END
);
1270 *typestring_offset
+= 1;
1272 return start_offset
;
1274 error("write_struct_tfs: Unimplemented for type 0x%x\n", type
->type
);
1275 return *typestring_offset
;
1279 static void write_pointer_only_tfs(FILE *file
, const attr_list_t
*attrs
, int pointer_type
,
1280 unsigned char flags
, size_t offset
,
1281 unsigned int *typeformat_offset
)
1283 int in_attr
, out_attr
;
1284 in_attr
= is_attr(attrs
, ATTR_IN
);
1285 out_attr
= is_attr(attrs
, ATTR_OUT
);
1286 if (!in_attr
&& !out_attr
) in_attr
= 1;
1288 if (out_attr
&& !in_attr
&& pointer_type
== RPC_FC_RP
)
1291 print_file(file
, 2, "0x%x, 0x%x,\t\t/* %s",
1294 pointer_type
== RPC_FC_FP
? "FC_FP" : (pointer_type
== RPC_FC_UP
? "FC_UP" : "FC_RP"));
1298 fprintf(file
, " [allocated_on_stack]");
1300 fprintf(file
, " [pointer_deref]");
1301 fprintf(file
, " */\n");
1304 print_file(file
, 2, "NdrFcShort(0x%x), /* %d */\n", offset
, offset
);
1305 *typeformat_offset
+= 4;
1308 static size_t write_union_tfs(FILE *file
, const attr_list_t
*attrs
,
1309 const type_t
*type
, const char *name
,
1310 unsigned int *typeformat_offset
)
1312 error("write_union_tfs: Unimplemented\n");
1313 return *typeformat_offset
;
1316 static size_t write_ip_tfs(FILE *file
, const attr_list_t
*attrs
,
1317 const char *name
, unsigned int *typeformat_offset
)
1320 size_t start_offset
= *typeformat_offset
;
1321 const UUID
*uuid
= get_attrp(attrs
, ATTR_UUID
);
1324 error("%s: interface %s missing UUID\n", __FUNCTION__
, name
);
1326 print_file(file
, 2, "0x2f,\t/* FC_IP */\n");
1327 print_file(file
, 2, "0x5a,\t/* FC_CONSTANT_IID */\n");
1328 print_file(file
, 2, "NdrFcLong(0x%08lx),\n", uuid
->Data1
);
1329 print_file(file
, 2, "NdrFcShort(0x%04x),\n", uuid
->Data2
);
1330 print_file(file
, 2, "NdrFcShort(0x%04x),\n", uuid
->Data3
);
1331 for (i
= 0; i
< 8; ++i
)
1332 print_file(file
, 2, "0x%02x,\n", uuid
->Data4
[i
]);
1335 fprintf(file
, "\n");
1337 *typeformat_offset
+= 18;
1338 return start_offset
;
1341 static int get_ptr_attr(const type_t
*t
, int def_type
)
1345 int ptr_attr
= get_attrv(t
->attrs
, ATTR_POINTERTYPE
);
1348 if (t
->kind
!= TKIND_ALIAS
)
1354 static size_t write_typeformatstring_var(FILE *file
, int indent
,
1355 const var_t
*var
, unsigned int *typeformat_offset
)
1357 const type_t
*type
= var
->type
;
1358 int var_ptrs
= var
->ptr_level
, type_ptrs
= 0;
1359 int is_str
= is_attr(var
->attrs
, ATTR_STRING
);
1361 chat("write_typeformatstring_var: %s\n", var
->name
);
1365 is_str
= is_str
|| is_attr(type
->attrs
, ATTR_STRING
);
1366 if (type
->kind
== TKIND_ALIAS
)
1368 else if (is_ptr(type
))
1382 int ptr_level
= var_ptrs
+ type_ptrs
;
1383 int pointer_type
= 0;
1385 chat("write_typeformatstring: type->type = 0x%x, type->name = %s, ptr_level = %d\n", type
->type
, type
->name
, ptr_level
);
1387 /* var attrs only effect the rightmost pointer */
1388 if ((0 < var
->ptr_level
&& var_ptrs
== var
->ptr_level
)
1389 || (var
->ptr_level
== 0 && type
== var
->type
))
1391 int pointer_attr
= get_attrv(var
->attrs
, ATTR_POINTERTYPE
);
1395 error("'%s': pointer attribute applied to non-pointer type",
1397 pointer_type
= pointer_attr
;
1400 pointer_type
= RPC_FC_RP
;
1402 else /* pointers below other pointers default to unique */
1403 pointer_type
= var_ptrs
? RPC_FC_UP
: get_ptr_attr(type
, RPC_FC_UP
);
1405 if (is_str
&& ptr_level
+ (var
->array
!= NULL
) == 1)
1406 return write_string_tfs(file
, var
->attrs
, type
, var
->array
, var
->name
, typeformat_offset
);
1408 if (is_array_type(var
->attrs
, ptr_level
, var
->array
))
1409 return write_array_tfs(file
, var
->attrs
, type
, var
->array
, var
->name
, typeformat_offset
);
1413 /* basic types don't need a type format string */
1414 if (is_base_type(type
->type
))
1420 case RPC_FC_PSTRUCT
:
1421 case RPC_FC_CSTRUCT
:
1422 case RPC_FC_CPSTRUCT
:
1423 case RPC_FC_CVSTRUCT
:
1424 case RPC_FC_BOGUS_STRUCT
:
1425 return write_struct_tfs(file
, type
, var
->name
, typeformat_offset
);
1426 case RPC_FC_ENCAPSULATED_UNION
:
1427 case RPC_FC_NON_ENCAPSULATED_UNION
:
1428 return write_union_tfs(file
, var
->attrs
, type
, var
->name
, typeformat_offset
);
1430 case RPC_FC_BIND_PRIMITIVE
:
1434 error("write_typeformatstring_var: Unsupported type 0x%x for variable %s\n", type
->type
, var
->name
);
1437 else if (ptr_level
== 1)
1439 size_t start_offset
= *typeformat_offset
;
1440 int in_attr
= is_attr(var
->attrs
, ATTR_IN
);
1441 int out_attr
= is_attr(var
->attrs
, ATTR_OUT
);
1442 const type_t
*base
= is_ptr(type
) ? type
->ref
: type
;
1444 if (base
->type
== RPC_FC_IP
)
1446 return write_ip_tfs(file
, base
->attrs
, base
->name
, typeformat_offset
);
1449 /* special case for pointers to base types */
1452 #define CASE_BASETYPE(fctype) \
1453 case RPC_##fctype: \
1454 print_file(file, indent, "0x%x, 0x%x, /* %s %s[simple_pointer] */\n", \
1456 (!in_attr && out_attr) ? 0x0C : 0x08, \
1457 pointer_type == RPC_FC_FP ? "FC_FP" : (pointer_type == RPC_FC_UP ? "FC_UP" : "FC_RP"), \
1458 (!in_attr && out_attr) ? "[allocated_on_stack] " : ""); \
1459 print_file(file, indent, "0x%02x, /* " #fctype " */\n", RPC_##fctype); \
1460 print_file(file, indent, "0x5c, /* FC_PAD */\n"); \
1461 *typeformat_offset += 4; \
1463 CASE_BASETYPE(FC_BYTE
);
1464 CASE_BASETYPE(FC_CHAR
);
1465 CASE_BASETYPE(FC_SMALL
);
1466 CASE_BASETYPE(FC_USMALL
);
1467 CASE_BASETYPE(FC_WCHAR
);
1468 CASE_BASETYPE(FC_SHORT
);
1469 CASE_BASETYPE(FC_USHORT
);
1470 CASE_BASETYPE(FC_LONG
);
1471 CASE_BASETYPE(FC_ULONG
);
1472 CASE_BASETYPE(FC_FLOAT
);
1473 CASE_BASETYPE(FC_HYPER
);
1474 CASE_BASETYPE(FC_DOUBLE
);
1475 CASE_BASETYPE(FC_ENUM16
);
1476 CASE_BASETYPE(FC_ENUM32
);
1477 CASE_BASETYPE(FC_IGNORE
);
1478 CASE_BASETYPE(FC_ERROR_STATUS_T
);
1484 assert(ptr_level
> 0);
1487 fprintf(file
, "/* %2u */\n", *typeformat_offset
);
1488 write_pointer_only_tfs(file
, var
->attrs
, pointer_type
,
1489 1 < ptr_level
? 0x10 : 0,
1490 2, typeformat_offset
);
1503 void write_typeformatstring(FILE *file
, const ifref_list_t
*ifaces
, int for_objects
)
1507 unsigned int typeformat_offset
;
1508 const ifref_t
*iface
;
1510 print_file(file
, indent
, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =\n");
1511 print_file(file
, indent
, "{\n");
1513 print_file(file
, indent
, "0,\n");
1514 print_file(file
, indent
, "{\n");
1516 print_file(file
, indent
, "NdrFcShort(0x0),\n");
1517 typeformat_offset
= 2;
1519 if (ifaces
) LIST_FOR_EACH_ENTRY( iface
, ifaces
, const ifref_t
, entry
)
1521 if (for_objects
!= is_object(iface
->iface
->attrs
) || is_local(iface
->iface
->attrs
))
1524 if (iface
->iface
->funcs
)
1527 LIST_FOR_EACH_ENTRY( func
, iface
->iface
->funcs
, const func_t
, entry
)
1529 if (is_local(func
->def
->attrs
)) continue;
1530 current_func
= func
;
1532 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
1533 write_typeformatstring_var(file
, indent
, var
,
1534 &typeformat_offset
);
1539 print_file(file
, indent
, "0x0\n");
1541 print_file(file
, indent
, "}\n");
1543 print_file(file
, indent
, "};\n");
1544 print_file(file
, indent
, "\n");
1547 static unsigned int get_required_buffer_size_type(
1548 const type_t
*type
, int ptr_level
, const array_dims_t
*array
,
1549 const char *name
, unsigned int *alignment
)
1576 case RPC_FC_ERROR_STATUS_T
:
1588 case RPC_FC_BIND_PRIMITIVE
:
1594 if (!type
->fields
) return 0;
1595 LIST_FOR_EACH_ENTRY( field
, type
->fields
, const var_t
, entry
)
1597 unsigned int alignment
;
1598 size
+= get_required_buffer_size_type(
1599 field
->type
, field
->ptr_level
, field
->array
, field
->name
,
1606 if (is_base_type( type
->ref
->type
) || type
->ref
->type
== RPC_FC_STRUCT
)
1607 size
= get_required_buffer_size_type( type
->ref
, 0, NULL
, name
, alignment
);
1611 error("get_required_buffer_size: Unknown/unsupported type: %s (0x%02x)\n", name
, type
->type
);
1614 if (array
) size
*= get_array_size( array
);
1619 static unsigned int get_required_buffer_size(const var_t
*var
, unsigned int *alignment
, enum pass pass
)
1621 expr_list_t
*size_is
= get_attrp(var
->attrs
, ATTR_SIZEIS
);
1622 int has_size
= is_non_void(size_is
);
1623 int in_attr
= is_attr(var
->attrs
, ATTR_IN
);
1624 int out_attr
= is_attr(var
->attrs
, ATTR_OUT
);
1626 if (!in_attr
&& !out_attr
)
1631 if (pass
== PASS_OUT
)
1633 if (out_attr
&& var
->ptr_level
> 0)
1635 type_t
*type
= var
->type
;
1637 if (type
->type
== RPC_FC_STRUCT
)
1640 unsigned int size
= 36;
1642 if (!type
->fields
) return size
;
1643 LIST_FOR_EACH_ENTRY( field
, type
->fields
, const var_t
, entry
)
1646 size
+= get_required_buffer_size_type(
1647 field
->type
, field
->ptr_level
, field
->array
, field
->name
,
1657 if ((!out_attr
|| in_attr
) && !has_size
&& !is_attr(var
->attrs
, ATTR_STRING
) && !var
->array
)
1659 if (var
->ptr_level
> 0)
1661 type_t
*type
= var
->type
;
1663 if (is_base_type(type
->type
))
1667 else if (type
->type
== RPC_FC_STRUCT
)
1669 unsigned int size
= 36;
1672 if (!type
->fields
) return size
;
1673 LIST_FOR_EACH_ENTRY( field
, type
->fields
, const var_t
, entry
)
1676 size
+= get_required_buffer_size_type(
1677 field
->type
, field
->ptr_level
, field
->array
, field
->name
,
1685 return get_required_buffer_size_type(var
->type
, var
->ptr_level
, var
->array
, var
->name
, alignment
);
1689 static unsigned int get_function_buffer_size( const func_t
*func
, enum pass pass
)
1692 unsigned int total_size
= 0, alignment
;
1696 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
1698 total_size
+= get_required_buffer_size(var
, &alignment
, pass
);
1699 total_size
+= alignment
;
1703 if (pass
== PASS_OUT
&& !is_void(func
->def
->type
, NULL
))
1705 total_size
+= get_required_buffer_size(func
->def
, &alignment
, PASS_RETURN
);
1706 total_size
+= alignment
;
1711 static void print_phase_function(FILE *file
, int indent
, const char *type
,
1712 enum remoting_phase phase
,
1713 const char *varname
, unsigned int type_offset
)
1715 const char *function
;
1718 case PHASE_BUFFERSIZE
:
1719 function
= "BufferSize";
1722 function
= "Marshall";
1724 case PHASE_UNMARSHAL
:
1725 function
= "Unmarshall";
1735 print_file(file
, indent
, "Ndr%s%s(\n", type
, function
);
1737 print_file(file
, indent
, "&_StubMsg,\n");
1738 print_file(file
, indent
, "%s%s,\n",
1739 (phase
== PHASE_UNMARSHAL
) ? "(unsigned char **)&" : "(unsigned char *)",
1741 print_file(file
, indent
, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]%s\n",
1742 type_offset
, (phase
== PHASE_UNMARSHAL
) ? "," : ");");
1743 if (phase
== PHASE_UNMARSHAL
)
1744 print_file(file
, indent
, "0);\n");
1748 void print_phase_basetype(FILE *file
, int indent
, enum remoting_phase phase
,
1749 enum pass pass
, const var_t
*var
,
1750 const char *varname
)
1752 const type_t
*type
= var
->type
;
1754 unsigned int alignment
= 0;
1755 unsigned char rtype
;
1757 /* no work to do for other phases, buffer sizing is done elsewhere */
1758 if (phase
!= PHASE_MARSHAL
&& phase
!= PHASE_UNMARSHAL
)
1783 case RPC_FC_ERROR_STATUS_T
:
1795 case RPC_FC_BIND_PRIMITIVE
:
1796 /* no marshalling needed */
1800 error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n", var
->name
, rtype
);
1804 print_file(file
, indent
, "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + %u) & ~0x%x);\n",
1805 alignment
- 1, alignment
- 1);
1807 if (phase
== PHASE_MARSHAL
)
1809 print_file(file
, indent
, "*(");
1810 write_type(file
, var
->type
, NULL
, var
->tname
);
1812 fprintf(file
, " *)_StubMsg.Buffer = *");
1814 fprintf(file
, " *)_StubMsg.Buffer = ");
1815 fprintf(file
, varname
);
1816 fprintf(file
, ";\n");
1818 else if (phase
== PHASE_UNMARSHAL
)
1820 if (pass
== PASS_IN
|| pass
== PASS_RETURN
)
1821 print_file(file
, indent
, "");
1823 print_file(file
, indent
, "*");
1824 fprintf(file
, varname
);
1825 if (pass
== PASS_IN
&& var
->ptr_level
)
1826 fprintf(file
, " = (");
1828 fprintf(file
, " = *(");
1829 write_type(file
, var
->type
, NULL
, var
->tname
);
1830 fprintf(file
, " *)_StubMsg.Buffer;\n");
1833 print_file(file
, indent
, "_StubMsg.Buffer += sizeof(");
1834 write_type(file
, var
->type
, NULL
, var
->tname
);
1835 fprintf(file
, ");\n");
1838 /* returns whether the MaxCount, Offset or ActualCount members need to be
1839 * filled in for the specified phase */
1840 static inline int is_size_needed_for_phase(enum remoting_phase phase
)
1842 return (phase
!= PHASE_UNMARSHAL
);
1845 void write_remoting_arguments(FILE *file
, int indent
, const func_t
*func
,
1846 unsigned int *type_offset
, enum pass pass
,
1847 enum remoting_phase phase
)
1849 const expr_list_t
*length_is
;
1850 const expr_list_t
*size_is
;
1851 int in_attr
, out_attr
, has_length
, has_size
, pointer_type
;
1857 if (phase
== PHASE_BUFFERSIZE
)
1859 unsigned int size
= get_function_buffer_size( func
, pass
);
1860 print_file(file
, indent
, "_StubMsg.BufferLength = %u;\n", size
);
1863 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
1865 const type_t
*type
= var
->type
;
1866 unsigned char rtype
;
1868 length_is
= get_attrp(var
->attrs
, ATTR_LENGTHIS
);
1869 size_is
= get_attrp(var
->attrs
, ATTR_SIZEIS
);
1870 has_length
= is_non_void(length_is
);
1871 has_size
= is_non_void(size_is
) || (var
->array
&& is_conformant_array(var
->array
));
1873 pointer_type
= get_attrv(var
->attrs
, ATTR_POINTERTYPE
);
1875 pointer_type
= RPC_FC_RP
;
1877 in_attr
= is_attr(var
->attrs
, ATTR_IN
);
1878 out_attr
= is_attr(var
->attrs
, ATTR_OUT
);
1879 if (!in_attr
&& !out_attr
)
1885 if (!in_attr
) goto next
;
1888 if (!out_attr
) goto next
;
1896 if (is_user_derived( var
))
1898 print_phase_function(file
, indent
, "UserMarshal", phase
, var
->name
, *type_offset
);
1900 else if (is_string_type(var
->attrs
, var
->ptr_level
, var
->array
))
1902 if (var
->array
&& !is_conformant_array(var
->array
))
1903 print_phase_function(file
, indent
, "NonConformantString", phase
, var
->name
, *type_offset
);
1906 if (size_is
&& is_size_needed_for_phase(phase
))
1908 const expr_t
*size
= LIST_ENTRY( list_head(size_is
), const expr_t
, entry
);
1909 print_file(file
, indent
, "_StubMsg.MaxCount = (unsigned long)");
1910 write_expr(file
, size
, 1);
1911 fprintf(file
, ";\n");
1914 if ((phase
== PHASE_FREE
) || (pointer_type
== RPC_FC_UP
))
1915 print_phase_function(file
, indent
, "Pointer", phase
, var
->name
, *type_offset
);
1917 print_phase_function(file
, indent
, "ConformantString", phase
, var
->name
,
1918 *type_offset
+ (has_size
? 4 : 2));
1921 else if (is_array_type(var
->attrs
, var
->ptr_level
, var
->array
))
1923 const char *array_type
;
1925 if (var
->array
&& list_count(var
->array
) > 1) /* multi-dimensional array */
1926 array_type
= "ComplexArray";
1929 if (!has_length
&& !has_size
)
1930 array_type
= "FixedArray";
1931 else if (has_length
&& !has_size
)
1933 if (is_size_needed_for_phase(phase
))
1935 const expr_t
*length
= LIST_ENTRY( list_head(length_is
), const expr_t
, entry
);
1936 print_file(file
, indent
, "_StubMsg.Offset = (unsigned long)0;\n"); /* FIXME */
1937 print_file(file
, indent
, "_StubMsg.ActualCount = (unsigned long)");
1938 write_expr(file
, length
, 1);
1939 fprintf(file
, ";\n\n");
1941 array_type
= "VaryingArray";
1943 else if (!has_length
&& has_size
)
1945 if (is_size_needed_for_phase(phase
) && phase
!= PHASE_FREE
)
1947 const expr_t
*size
= LIST_ENTRY( list_head(size_is
? size_is
: var
->array
),
1948 const expr_t
, entry
);
1949 print_file(file
, indent
, "_StubMsg.MaxCount = (unsigned long)");
1950 write_expr(file
, size
, 1);
1951 fprintf(file
, ";\n\n");
1953 array_type
= "ConformantArray";
1957 if (is_size_needed_for_phase(phase
))
1959 const expr_t
*length
= LIST_ENTRY( list_head(length_is
), const expr_t
, entry
);
1960 const expr_t
*size
= LIST_ENTRY( list_head(size_is
? size_is
: var
->array
),
1961 const expr_t
, entry
);
1962 print_file(file
, indent
, "_StubMsg.MaxCount = (unsigned long)");
1963 write_expr(file
, size
, 1);
1964 fprintf(file
, ";\n");
1965 print_file(file
, indent
, "_StubMsg.Offset = (unsigned long)0;\n"); /* FIXME */
1966 print_file(file
, indent
, "_StubMsg.ActualCount = (unsigned long)");
1967 write_expr(file
, length
, 1);
1968 fprintf(file
, ";\n\n");
1970 array_type
= "ConformantVaryingArray";
1974 if (!in_attr
&& phase
== PHASE_FREE
)
1976 print_file(file
, indent
, "if (%s)\n", var
->name
);
1978 print_file(file
, indent
, "_StubMsg.pfnFree(%s);\n", var
->name
);
1980 else if (phase
!= PHASE_FREE
)
1982 if (pointer_type
== RPC_FC_UP
)
1983 print_phase_function(file
, indent
, "Pointer", phase
, var
->name
, *type_offset
);
1985 print_phase_function(file
, indent
, array_type
, phase
, var
->name
, *type_offset
+ 4);
1988 else if (var
->ptr_level
== 0 && is_base_type(rtype
))
1990 print_phase_basetype(file
, indent
, phase
, pass
, var
, var
->name
);
1992 else if (var
->ptr_level
== 0)
1997 print_phase_function(file
, indent
, "SimpleStruct", phase
, var
->name
, *type_offset
);
1999 case RPC_FC_CSTRUCT
:
2000 case RPC_FC_CPSTRUCT
:
2001 print_phase_function(file
, indent
, "ConformantStruct", phase
, var
->name
, *type_offset
);
2003 case RPC_FC_CVSTRUCT
:
2004 print_phase_function(file
, indent
, "ConformantVaryingStruct", phase
, var
->name
, *type_offset
);
2006 case RPC_FC_BOGUS_STRUCT
:
2007 print_phase_function(file
, indent
, "ComplexStruct", phase
, var
->name
, *type_offset
);
2010 if (is_base_type( var
->type
->ref
->type
))
2012 print_phase_basetype(file
, indent
, phase
, pass
, var
, var
->name
);
2014 else if (var
->type
->ref
->type
== RPC_FC_STRUCT
)
2016 if (phase
!= PHASE_BUFFERSIZE
&& phase
!= PHASE_FREE
)
2017 print_phase_function(file
, indent
, "SimpleStruct", phase
, var
->name
, *type_offset
+ 4);
2022 if ((iid
= get_attrp( var
->attrs
, ATTR_IIDIS
)))
2023 print_file( file
, indent
, "_StubMsg.MaxCount = (unsigned long)%s;\n", iid
->name
);
2024 print_phase_function(file
, indent
, "Pointer", phase
, var
->name
, *type_offset
);
2028 error("write_remoting_arguments: Unsupported type: %s (0x%02x, ptr_level: %d)\n",
2029 var
->name
, rtype
, var
->ptr_level
);
2034 if ((var
->ptr_level
== 1) && (pointer_type
== RPC_FC_RP
) && is_base_type(rtype
))
2036 print_phase_basetype(file
, indent
, phase
, pass
, var
, var
->name
);
2038 else if ((var
->ptr_level
== 1) && (pointer_type
== RPC_FC_RP
) && (rtype
== RPC_FC_STRUCT
))
2040 if (phase
!= PHASE_BUFFERSIZE
&& phase
!= PHASE_FREE
)
2041 print_phase_function(file
, indent
, "SimpleStruct", phase
, var
->name
, *type_offset
+ 4);
2046 if ((iid
= get_attrp( var
->attrs
, ATTR_IIDIS
)))
2047 print_file( file
, indent
, "_StubMsg.MaxCount = (unsigned long)%s;\n", iid
->name
);
2048 print_phase_function(file
, indent
, "Pointer", phase
, var
->name
, *type_offset
);
2051 fprintf(file
, "\n");
2053 *type_offset
+= get_size_typeformatstring_var(var
);
2058 size_t get_size_procformatstring_var(const var_t
*var
)
2060 unsigned int type_offset
= 2;
2061 return write_procformatstring_var(NULL
, 0, var
, FALSE
, &type_offset
);
2065 size_t get_size_procformatstring_func(const func_t
*func
)
2070 /* argument list size */
2072 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
2073 size
+= get_size_procformatstring_var(var
);
2075 /* return value size */
2076 if (is_void(func
->def
->type
, NULL
))
2077 size
+= 2; /* FC_END and FC_PAD */
2079 size
+= get_size_procformatstring_var(func
->def
);
2084 size_t get_size_typeformatstring_var(const var_t
*var
)
2086 unsigned int type_offset
= 0;
2087 write_typeformatstring_var(NULL
, 0, var
, &type_offset
);
2091 size_t get_size_procformatstring(const ifref_list_t
*ifaces
, int for_objects
)
2093 const ifref_t
*iface
;
2097 if (ifaces
) LIST_FOR_EACH_ENTRY( iface
, ifaces
, const ifref_t
, entry
)
2099 if (for_objects
!= is_object(iface
->iface
->attrs
) || is_local(iface
->iface
->attrs
))
2102 if (iface
->iface
->funcs
)
2103 LIST_FOR_EACH_ENTRY( func
, iface
->iface
->funcs
, const func_t
, entry
)
2104 if (!is_local(func
->def
->attrs
))
2105 size
+= get_size_procformatstring_func( func
);
2110 size_t get_size_typeformatstring(const ifref_list_t
*ifaces
, int for_objects
)
2112 const ifref_t
*iface
;
2117 if (ifaces
) LIST_FOR_EACH_ENTRY( iface
, ifaces
, const ifref_t
, entry
)
2119 if (for_objects
!= is_object(iface
->iface
->attrs
) || is_local(iface
->iface
->attrs
))
2122 if (iface
->iface
->funcs
)
2124 LIST_FOR_EACH_ENTRY( func
, iface
->iface
->funcs
, const func_t
, entry
)
2126 if (is_local(func
->def
->attrs
)) continue;
2127 /* argument list size */
2129 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
2130 size
+= get_size_typeformatstring_var(var
);
2137 static void write_struct_expr(FILE *h
, const expr_t
*e
, int brackets
,
2138 const var_list_t
*fields
, const char *structvar
)
2144 fprintf(h
, "%ld", e
->u
.lval
);
2147 fprintf(h
, "0x%lx", e
->u
.lval
);
2149 case EXPR_TRUEFALSE
:
2151 fprintf(h
, "FALSE");
2155 case EXPR_IDENTIFIER
:
2158 LIST_FOR_EACH_ENTRY( field
, fields
, const var_t
, entry
)
2159 if (!strcmp(e
->u
.sval
, field
->name
))
2161 fprintf(h
, "%s->%s", structvar
, e
->u
.sval
);
2165 if (&field
->entry
== fields
) error("no field found for identifier %s\n", e
->u
.sval
);
2170 write_struct_expr(h
, e
->ref
, 1, fields
, structvar
);
2174 write_struct_expr(h
, e
->ref
, 1, fields
, structvar
);
2178 write_struct_expr(h
, e
->ref
, 1, fields
, structvar
);
2182 write_type(h
, e
->u
.tref
->ref
, NULL
, e
->u
.tref
->name
);
2184 write_struct_expr(h
, e
->ref
, 1, fields
, structvar
);
2187 fprintf(h
, "sizeof(");
2188 write_type(h
, e
->u
.tref
->ref
, NULL
, e
->u
.tref
->name
);
2199 if (brackets
) fprintf(h
, "(");
2200 write_struct_expr(h
, e
->ref
, 1, fields
, structvar
);
2202 case EXPR_SHL
: fprintf(h
, " << "); break;
2203 case EXPR_SHR
: fprintf(h
, " >> "); break;
2204 case EXPR_MUL
: fprintf(h
, " * "); break;
2205 case EXPR_DIV
: fprintf(h
, " / "); break;
2206 case EXPR_ADD
: fprintf(h
, " + "); break;
2207 case EXPR_SUB
: fprintf(h
, " - "); break;
2208 case EXPR_AND
: fprintf(h
, " & "); break;
2209 case EXPR_OR
: fprintf(h
, " | "); break;
2212 write_struct_expr(h
, e
->u
.ext
, 1, fields
, structvar
);
2213 if (brackets
) fprintf(h
, ")");
2216 if (brackets
) fprintf(h
, "(");
2217 write_struct_expr(h
, e
->ref
, 1, fields
, structvar
);
2219 write_struct_expr(h
, e
->u
.ext
, 1, fields
, structvar
);
2221 write_struct_expr(h
, e
->ext2
, 1, fields
, structvar
);
2222 if (brackets
) fprintf(h
, ")");
2228 void declare_stub_args( FILE *file
, int indent
, const func_t
*func
)
2230 int in_attr
, out_attr
;
2232 const var_t
*def
= func
->def
;
2235 /* declare return value '_RetVal' */
2236 if (!is_void(def
->type
, NULL
))
2238 print_file(file
, indent
, "");
2239 write_type(file
, def
->type
, def
, def
->tname
);
2240 fprintf(file
, " _RetVal;\n");
2246 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
2248 const expr_list_t
*size_is
= get_attrp(var
->attrs
, ATTR_SIZEIS
);
2249 int has_size
= is_non_void(size_is
);
2250 int is_string
= is_attr(var
->attrs
, ATTR_STRING
);
2252 in_attr
= is_attr(var
->attrs
, ATTR_IN
);
2253 out_attr
= is_attr(var
->attrs
, ATTR_OUT
);
2254 if (!out_attr
&& !in_attr
)
2257 if (!in_attr
&& !has_size
&& !is_string
)
2260 print_file(file
, indent
, "");
2261 write_type(file
, var
->type
, NULL
, var
->tname
);
2262 for (indirection
= 0; indirection
< var
->ptr_level
- 1; indirection
++)
2264 fprintf(file
, " _W%u;\n", i
++);
2267 print_file(file
, indent
, "");
2268 write_type(file
, var
->type
, var
, var
->tname
);
2270 write_name(file
, var
);
2271 write_array(file
, var
->array
, 0);
2272 fprintf(file
, ";\n");
2277 void assign_stub_out_args( FILE *file
, int indent
, const func_t
*func
)
2279 int in_attr
, out_attr
;
2282 const expr_list_t
*size_is
;
2288 LIST_FOR_EACH_ENTRY( var
, func
->args
, const var_t
, entry
)
2290 int is_string
= is_attr(var
->attrs
, ATTR_STRING
);
2291 size_is
= get_attrp(var
->attrs
, ATTR_SIZEIS
);
2292 has_size
= is_non_void(size_is
);
2293 in_attr
= is_attr(var
->attrs
, ATTR_IN
);
2294 out_attr
= is_attr(var
->attrs
, ATTR_OUT
);
2295 if (!out_attr
&& !in_attr
)
2300 print_file(file
, indent
, "");
2301 write_name(file
, var
);
2306 unsigned int size
, align
= 0;
2307 type_t
*type
= var
->type
;
2309 fprintf(file
, " = NdrAllocate(&_StubMsg, ");
2310 LIST_FOR_EACH_ENTRY( expr
, size_is
, const expr_t
, entry
)
2312 if (expr
->type
== EXPR_VOID
) continue;
2313 write_expr( file
, expr
, 1 );
2314 fprintf(file
, " * ");
2316 size
= type_memsize(type
, 0, NULL
, &align
);
2317 fprintf(file
, "%u);\n", size
);
2319 else if (!is_string
)
2321 fprintf(file
, " = &_W%u;\n", i
);
2322 if (var
->ptr_level
> 1)
2323 print_file(file
, indent
, "_W%u = 0;\n", i
);
2331 fprintf(file
, "\n");
2335 int write_expr_eval_routines(FILE *file
, const char *iface
)
2338 struct expr_eval_routine
*eval
;
2339 unsigned short callback_offset
= 0;
2341 LIST_FOR_EACH_ENTRY(eval
, &expr_eval_routines
, struct expr_eval_routine
, entry
)
2345 print_file(file
, indent
, "static void __RPC_USER %s_%sExprEval_%04u(PMIDL_STUB_MESSAGE pStubMsg)\n",
2346 iface
, eval
->structure
->name
, callback_offset
);
2347 print_file(file
, indent
, "{\n");
2349 print_file(file
, indent
, "struct %s *" STRUCT_EXPR_EVAL_VAR
" = (struct %s *)(pStubMsg->StackTop - %u);\n",
2350 eval
->structure
->name
, eval
->structure
->name
, eval
->structure_size
);
2351 fprintf(file
, "\n");
2352 print_file(file
, indent
, "pStubMsg->Offset = 0;\n"); /* FIXME */
2353 print_file(file
, indent
, "pStubMsg->MaxCount = (unsigned long)");
2354 write_struct_expr(file
, eval
->expr
, 1, eval
->structure
->fields
, STRUCT_EXPR_EVAL_VAR
);
2355 fprintf(file
, ";\n");
2357 print_file(file
, indent
, "}\n\n");
2363 void write_expr_eval_routine_list(FILE *file
, const char *iface
)
2365 struct expr_eval_routine
*eval
;
2366 struct expr_eval_routine
*cursor
;
2367 unsigned short callback_offset
= 0;
2369 fprintf(file
, "static const EXPR_EVAL ExprEvalRoutines[] =\n");
2370 fprintf(file
, "{\n");
2372 LIST_FOR_EACH_ENTRY_SAFE(eval
, cursor
, &expr_eval_routines
, struct expr_eval_routine
, entry
)
2374 print_file(file
, 1, "%s_%sExprEval_%04u,\n",
2375 iface
, eval
->structure
->name
, callback_offset
);
2378 list_remove(&eval
->entry
);
2382 fprintf(file
, "};\n\n");