ReactOS 0.4.15-dev-8219-ge8b88cf
typegen.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include "widl.h"
#include "utils.h"
#include "parser.h"
#include "header.h"
#include "typetree.h"
#include "typegen.h"
#include "expr.h"
Include dependency graph for typegen.c:

Go to the source code of this file.

Classes

struct  expr_eval_routine
 

Macros

#define ROUND_SIZE(size, alignment)   (((size) + ((alignment) - 1)) & ~((alignment) - 1))
 
#define ROUNDING(size, alignment)   (((alignment) - 1) - (((size) + ((alignment) - 1)) & ((alignment) - 1)))
 
#define WRITE_FCTYPE(file, fctype, typestring_offset)
 

Enumerations

enum  type_context { TYPE_CONTEXT_TOPLEVELPARAM , TYPE_CONTEXT_PARAM , TYPE_CONTEXT_CONTAINER , TYPE_CONTEXT_CONTAINER_NO_POINTERS }
 

Functions

static unsigned int field_memsize (const type_t *type, unsigned int *offset)
 
static unsigned int fields_memsize (const var_list_t *fields, unsigned int *align)
 
static unsigned int write_array_tfs (FILE *file, const attr_list_t *attrs, type_t *type, const char *name, unsigned int *typestring_offset)
 
static unsigned int write_struct_tfs (FILE *file, type_t *type, const char *name, unsigned int *tfsoff)
 
static int write_embedded_types (FILE *file, const attr_list_t *attrs, type_t *type, const char *name, int write_ptr, unsigned int *tfsoff)
 
static const var_tfind_array_or_string_in_struct (const type_t *type)
 
static unsigned int write_string_tfs (FILE *file, const attr_list_t *attrs, type_t *type, enum type_context context, const char *name, unsigned int *typestring_offset)
 
static unsigned int get_required_buffer_size_type (const type_t *type, const char *name, const attr_list_t *attrs, int toplevel_param, unsigned int *alignment)
 
static unsigned int get_function_buffer_size (const var_t *func, enum pass pass)
 
static const charstring_of_type (unsigned char type)
 
static voidget_aliaschain_attrp (const type_t *type, enum attr_type attr)
 
unsigned char get_basic_fc (const type_t *type)
 
static unsigned char get_basic_fc_signed (const type_t *type)
 
static unsigned int clamp_align (unsigned int align)
 
unsigned char get_pointer_fc (const type_t *type, const attr_list_t *attrs, int toplevel_param)
 
static unsigned char get_pointer_fc_context (const type_t *type, const attr_list_t *attrs, enum type_context context)
 
static unsigned char get_enum_fc (const type_t *type)
 
static type_tget_user_type (const type_t *t, const char **pname)
 
static int is_user_type (const type_t *t)
 
enum typegen_type typegen_detect_type (const type_t *type, const attr_list_t *attrs, unsigned int flags)
 
static int cant_be_null (const var_t *v)
 
static int get_padding (const var_list_t *fields)
 
static unsigned int get_stack_size (const var_t *var, int *by_value)
 
static unsigned char get_contexthandle_flags (const type_t *iface, const attr_list_t *attrs, const type_t *type)
 
static unsigned int get_rpc_flags (const attr_list_t *attrs)
 
unsigned char get_struct_fc (const type_t *type)
 
static unsigned char get_array_fc (const type_t *type)
 
static int is_non_complex_struct (const type_t *type)
 
static int type_has_pointers (const type_t *type)
 
static int type_has_full_pointer (const type_t *type, const attr_list_t *attrs, int toplevel_param)
 
static unsigned short user_type_offset (const char *name)
 
static void update_tfsoff (type_t *type, unsigned int offset, FILE *file)
 
static void guard_rec (type_t *type)
 
static int is_embedded_complex (const type_t *type)
 
static const charget_context_handle_type_name (const type_t *type)
 
static void print_file (FILE *file, int indent, const char *format,...) __attribute__((format(printf
 
void print (FILE *file, int indent, const char *format, va_list va)
 
static void write_var_init (FILE *file, int indent, const type_t *t, const char *n, const char *local_var_prefix)
 
void write_parameters_init (FILE *file, int indent, const var_t *func, const char *local_var_prefix)
 
static void write_formatdesc (FILE *f, int indent, const char *str)
 
void write_formatstringsdecl (FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred)
 
int decl_indirect (const type_t *t)
 
static unsigned char get_parameter_fc (const var_t *var, int is_return, unsigned short *flags, unsigned int *stack_size, unsigned int *typestring_offset)
 
static unsigned char get_func_oi2_flags (const var_t *func)
 
static unsigned int write_new_procformatstring_type (FILE *file, int indent, const var_t *var, int is_return, unsigned int *stack_offset)
 
static unsigned int write_old_procformatstring_type (FILE *file, int indent, const var_t *var, int is_return, int is_interpreted)
 
int is_interpreted_func (const type_t *iface, const var_t *func)
 
static void write_proc_func_header (FILE *file, int indent, const type_t *iface, const var_t *func, unsigned int *offset, unsigned short num_proc)
 
static void write_procformatstring_func (FILE *file, int indent, const type_t *iface, const var_t *func, unsigned int *offset, unsigned short num_proc)
 
static void for_each_iface (const statement_list_t *stmts, void(*proc)(type_t *iface, FILE *file, int indent, unsigned int *offset), type_pred_t pred, FILE *file, int indent, unsigned int *offset)
 
static void write_iface_procformatstring (type_t *iface, FILE *file, int indent, unsigned int *offset)
 
void write_procformatstring (FILE *file, const statement_list_t *stmts, type_pred_t pred)
 
void write_procformatstring_offsets (FILE *file, const type_t *iface)
 
static int write_base_type (FILE *file, const type_t *type, unsigned int *typestring_offset)
 
static unsigned int write_conf_or_var_desc (FILE *file, const type_t *cont_type, unsigned int baseoff, const type_t *type, const expr_t *expr)
 
static unsigned int union_memsize (const var_list_t *fields, unsigned int *pmaxa)
 
unsigned int type_memsize_and_alignment (const type_t *t, unsigned int *align)
 
unsigned int type_memsize (const type_t *t)
 
static unsigned int type_buffer_alignment (const type_t *t)
 
int is_full_pointer_function (const var_t *func)
 
void write_full_pointer_init (FILE *file, int indent, const var_t *func, int is_server)
 
void write_full_pointer_free (FILE *file, int indent, const var_t *func)
 
static unsigned int write_nonsimple_pointer (FILE *file, const attr_list_t *attrs, const type_t *type, enum type_context context, unsigned int offset, unsigned int *typeformat_offset)
 
static unsigned int write_simple_pointer (FILE *file, const attr_list_t *attrs, const type_t *type, enum type_context context)
 
static void print_start_tfs_comment (FILE *file, type_t *t, unsigned int tfsoff)
 
static unsigned int write_pointer_tfs (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int ref_offset, enum type_context context, unsigned int *typestring_offset)
 
static int processed (const type_t *type)
 
static int user_type_has_variable_size (const type_t *t)
 
static unsigned int write_user_tfs (FILE *file, type_t *type, unsigned int *tfsoff)
 
static void write_member_type (FILE *file, const type_t *cont, int cont_is_complex, const attr_list_t *attrs, const type_t *type, unsigned int *corroff, unsigned int *tfsoff)
 
static void write_array_element_type (FILE *file, const attr_list_t *attrs, const type_t *type, int cont_is_complex, unsigned int *tfsoff)
 
static void write_end (FILE *file, unsigned int *tfsoff)
 
static void write_descriptors (FILE *file, type_t *type, unsigned int *tfsoff)
 
static int write_pointer_description_offsets (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *offset_in_memory, unsigned int *offset_in_buffer, unsigned int *typestring_offset)
 
static int write_no_repeat_pointer_descriptions (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *offset_in_memory, unsigned int *offset_in_buffer, unsigned int *typestring_offset)
 
static int write_fixed_array_pointer_descriptions (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *offset_in_memory, unsigned int *offset_in_buffer, unsigned int *typestring_offset)
 
static int write_conformant_array_pointer_descriptions (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int offset_in_memory, unsigned int *typestring_offset)
 
static int write_varying_array_pointer_descriptions (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *offset_in_memory, unsigned int *offset_in_buffer, unsigned int *typestring_offset)
 
static void write_pointer_description (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *typestring_offset)
 
static void write_struct_members (FILE *file, const type_t *type, int is_complex, unsigned int *corroff, unsigned int *typestring_offset)
 
static void write_branch_type (FILE *file, const type_t *t, unsigned int *tfsoff)
 
static unsigned int write_union_tfs (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *tfsoff)
 
static unsigned int write_ip_tfs (FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *typeformat_offset)
 
static unsigned int write_contexthandle_tfs (FILE *file, const attr_list_t *attrs, type_t *type, int toplevel_param, unsigned int *typeformat_offset)
 
static unsigned int write_range_tfs (FILE *file, const attr_list_t *attrs, type_t *type, expr_list_t *range_list, unsigned int *typeformat_offset)
 
static unsigned int write_type_tfs (FILE *file, int indent, const attr_list_t *attrs, type_t *type, const char *name, enum type_context context, unsigned int *typeformat_offset)
 
static void process_tfs_iface (type_t *iface, FILE *file, int indent, unsigned int *offset)
 
static unsigned int process_tfs (FILE *file, const statement_list_t *stmts, type_pred_t pred)
 
void write_typeformatstring (FILE *file, const statement_list_t *stmts, type_pred_t pred)
 
static unsigned int get_required_buffer_size (const var_t *var, unsigned int *alignment, enum pass pass)
 
static unsigned int get_function_buffer_size (const var_t *func, enum pass pass)
 
static void print_phase_function (FILE *file, int indent, const char *type, const char *local_var_prefix, enum remoting_phase phase, const var_t *var, unsigned int type_offset)
 
void print_phase_basetype (FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname)
 
static int is_conformance_needed_for_phase (enum remoting_phase phase)
 
expr_tget_size_is_expr (const type_t *t, const char *name)
 
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)
 
static void write_remoting_arg (FILE *file, int indent, const var_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase, const var_t *var)
 
void write_remoting_arguments (FILE *file, int indent, const var_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase)
 
unsigned int get_size_procformatstring_func (const type_t *iface, const var_t *func)
 
static void get_size_procformatstring_iface (type_t *iface, FILE *file, int indent, unsigned int *size)
 
unsigned int get_size_procformatstring (const statement_list_t *stmts, type_pred_t pred)
 
unsigned int get_size_typeformatstring (const statement_list_t *stmts, type_pred_t pred)
 
void declare_stub_args (FILE *file, int indent, const var_t *func)
 
void assign_stub_out_args (FILE *file, int indent, const var_t *func, const char *local_var_prefix)
 
void write_func_param_struct (FILE *file, const type_t *iface, const type_t *func, const char *var_decl, int add_retval)
 
void write_pointer_checks (FILE *file, int indent, const var_t *func)
 
int write_expr_eval_routines (FILE *file, const char *iface)
 
void write_expr_eval_routine_list (FILE *file, const char *iface)
 
void write_user_quad_list (FILE *file)
 
void write_endpoints (FILE *f, const char *prefix, const str_list_t *list)
 
void write_client_call_routine (FILE *file, const type_t *iface, const var_t *func, const char *prefix, unsigned int proc_offset)
 
void write_exceptions (FILE *file)
 

Variables

static const type_tcurrent_structure
 
static const var_tcurrent_func
 
static const type_tcurrent_iface
 
static struct list expr_eval_routines = LIST_INIT(expr_eval_routines)
 
static const unsigned short MustSize = 0x0001
 
static const unsigned short MustFree = 0x0002
 
static const unsigned short IsPipe = 0x0004
 
static const unsigned short IsIn = 0x0008
 
static const unsigned short IsOut = 0x0010
 
static const unsigned short IsReturn = 0x0020
 
static const unsigned short IsBasetype = 0x0040
 
static const unsigned short IsByValue = 0x0080
 
static const unsigned short IsSimpleRef = 0x0100
 

Macro Definition Documentation

◆ ROUND_SIZE

#define ROUND_SIZE (   size,
  alignment 
)    (((size) + ((alignment) - 1)) & ~((alignment) - 1))

Definition at line 45 of file typegen.c.

◆ ROUNDING

#define ROUNDING (   size,
  alignment 
)    (((alignment) - 1) - (((size) + ((alignment) - 1)) & ((alignment) - 1)))

Definition at line 47 of file typegen.c.

◆ WRITE_FCTYPE

#define WRITE_FCTYPE (   file,
  fctype,
  typestring_offset 
)
Value:
do { \
if (file) \
fprintf(file, "/* %2u */\n", typestring_offset); \
print_file((file), 2, "0x%02x,\t/* " #fctype " */\n", fctype); \
} \
while (0)
Definition: fci.c:127

Definition at line 862 of file typegen.c.

Enumeration Type Documentation

◆ type_context

Enumerator
TYPE_CONTEXT_TOPLEVELPARAM 
TYPE_CONTEXT_PARAM 
TYPE_CONTEXT_CONTAINER 
TYPE_CONTEXT_CONTAINER_NO_POINTERS 

Definition at line 64 of file typegen.c.

65{
70};
@ TYPE_CONTEXT_PARAM
Definition: typegen.c:67
@ TYPE_CONTEXT_CONTAINER
Definition: typegen.c:68
@ TYPE_CONTEXT_CONTAINER_NO_POINTERS
Definition: typegen.c:69
@ TYPE_CONTEXT_TOPLEVELPARAM
Definition: typegen.c:66

Function Documentation

◆ assign_stub_out_args()

void assign_stub_out_args ( FILE file,
int  indent,
const var_t func,
const char local_var_prefix 
)

Definition at line 4676 of file typegen.c.

4677{
4678 int in_attr, out_attr;
4679 int i = 0, sep = 0;
4680 const var_t *var;
4681 type_t *ref;
4682
4683 if (!type_get_function_args(func->type))
4684 return;
4685
4687 {
4688 in_attr = is_attr(var->attrs, ATTR_IN);
4689 out_attr = is_attr(var->attrs, ATTR_OUT);
4690 if (!out_attr && !in_attr)
4691 in_attr = 1;
4692
4693 if (!in_attr)
4694 {
4695 print_file(file, indent, "%s%s", local_var_prefix, var->name);
4696
4697 switch (typegen_detect_type(var->type, var->attrs, TDT_IGNORE_STRINGS))
4698 {
4700 fprintf(file, " = NdrContextHandleInitialize(\n");
4701 print_file(file, indent + 1, "&__frame->_StubMsg,\n");
4702 print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n",
4703 var->typestring_offset);
4704 break;
4705 case TGT_ARRAY:
4707 {
4708 unsigned int size;
4709 type_t *type;
4710
4711 fprintf(file, " = NdrAllocate(&__frame->_StubMsg, ");
4712 for (type = var->type;
4715 {
4717 TRUE, NULL, NULL, local_var_prefix);
4718 fprintf(file, " * ");
4719 }
4721 fprintf(file, "%u);\n", size);
4722
4723 print_file(file, indent, "memset(%s%s, 0, ", local_var_prefix, var->name);
4724 for (type = var->type;
4727 {
4729 TRUE, NULL, NULL, local_var_prefix);
4730 fprintf(file, " * ");
4731 }
4733 fprintf(file, "%u);\n", size);
4734 }
4735 else
4736 fprintf(file, " = &%s_W%u;\n", local_var_prefix, i++);
4737 break;
4738 case TGT_POINTER:
4739 fprintf(file, " = &%s_W%u;\n", local_var_prefix, i);
4740 ref = type_pointer_get_ref(var->type);
4742 {
4743 case TGT_BASIC:
4744 case TGT_ENUM:
4745 case TGT_POINTER:
4746 case TGT_RANGE:
4747 case TGT_IFACE_POINTER:
4748 print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4749 break;
4750 case TGT_USER_TYPE:
4751 print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4752 local_var_prefix, i, local_var_prefix, i);
4753 break;
4754 case TGT_ARRAY:
4756 {
4757 print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4758 break;
4759 }
4761 /* fall through */
4762 case TGT_STRUCT:
4763 case TGT_UNION:
4765 print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4766 local_var_prefix, i, local_var_prefix, i);
4767 break;
4768 case TGT_CTXT_HANDLE:
4770 case TGT_INVALID:
4771 case TGT_STRING:
4772 /* not initialised */
4773 break;
4774 }
4775 i++;
4776 break;
4777 default:
4778 break;
4779 }
4780
4781 sep = 1;
4782 }
4783 }
4784 if (sep)
4785 fprintf(file, "\n");
4786}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static const WCHAR indent[]
Definition: object.c:1156
void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix, const type_t *cont_type, const char *local_var_prefix)
Definition: expr.c:691
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLenum func
Definition: glext.h:6028
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
static int is_array(const type_t *t)
Definition: header.h:64
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
uint32_t entry
Definition: isohybrid.c:63
const char * var
Definition: shader.c:5666
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99
Definition: send.c:48
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
unsigned int type_memsize(const type_t *t)
Definition: typegen.c:1975
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
static int type_has_pointers(const type_t *type)
Definition: typegen.c:703
@ TDT_IGNORE_STRINGS
Definition: typegen.h:42
@ TGT_INVALID
Definition: typegen.h:48
@ TGT_USER_TYPE
Definition: typegen.h:49
@ TGT_POINTER
Definition: typegen.h:53
@ TGT_UNION
Definition: typegen.h:59
@ TGT_STRUCT
Definition: typegen.h:58
@ TGT_ARRAY
Definition: typegen.h:54
@ TGT_CTXT_HANDLE_POINTER
Definition: typegen.h:51
@ TGT_ENUM
Definition: typegen.h:57
@ TGT_CTXT_HANDLE
Definition: typegen.h:50
@ TGT_RANGE
Definition: typegen.h:60
@ TGT_STRING
Definition: typegen.h:52
@ TGT_BASIC
Definition: typegen.h:56
@ TGT_IFACE_POINTER
Definition: typegen.h:55
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260
static int type_array_has_conformance(const type_t *type)
Definition: typetree.h:218
static expr_t * type_array_get_conformance(const type_t *type)
Definition: typetree.h:239
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
@ ATTR_IN
Definition: widltypes.h:118
@ ATTR_OUT
Definition: widltypes.h:138
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:585

Referenced by gen_stub(), and write_function_stub().

◆ cant_be_null()

static int cant_be_null ( const var_t v)
static

Definition at line 379 of file typegen.c.

380{
381 switch (typegen_detect_type(v->type, v->attrs, TDT_IGNORE_STRINGS))
382 {
383 case TGT_ARRAY:
384 if (!type_array_is_decl_as_ptr( v->type )) return 0;
385 /* fall through */
386 case TGT_POINTER:
387 return (get_pointer_fc(v->type, v->attrs, TRUE) == FC_RP);
389 return TRUE;
390 default:
391 return 0;
392 }
393
394}
const GLdouble * v
Definition: gl.h:2040
@ FC_RP
Definition: ndrtypes.h:152
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:258

Referenced by write_pointer_checks().

◆ clamp_align()

static unsigned int clamp_align ( unsigned int  align)
inlinestatic

Definition at line 251 of file typegen.c.

252{
253 unsigned int packing = (pointer_size == 4) ? win32_packing : win64_packing;
254 if(align > packing) align = packing;
255 return align;
256}
int align(int length, int align)
Definition: dsound8.c:36
unsigned int pointer_size
Definition: widl.c:158
int win64_packing
Definition: widl.c:128
int win32_packing
Definition: widl.c:127

Referenced by fields_memsize(), get_padding(), and write_struct_members().

◆ decl_indirect()

int decl_indirect ( const type_t t)

Definition at line 948 of file typegen.c.

949{
950 if (is_user_type(t))
951 return TRUE;
952 return (type_get_type(t) != TYPE_BASIC &&
956}
GLdouble GLdouble t
Definition: gl.h:2047
static int is_user_type(const type_t *t)
Definition: typegen.c:324
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
@ TYPE_ENUM
Definition: widltypes.h:404
@ TYPE_BASIC
Definition: widltypes.h:403
@ TYPE_POINTER
Definition: widltypes.h:413
@ TYPE_ARRAY
Definition: widltypes.h:414

Referenced by declare_stub_args(), gen_proxy(), print_phase_function(), write_function_stub(), and write_var_init().

◆ declare_stub_args()

void declare_stub_args ( FILE file,
int  indent,
const var_t func 
)

Definition at line 4615 of file typegen.c.

4616{
4617 int in_attr, out_attr;
4618 int i = 0;
4619 const var_t *var = type_function_get_retval(func->type);
4620
4621 /* declare return value */
4622 if (!is_void(var->type))
4623 {
4624 print_file(file, indent, "%s", "");
4625 write_type_decl(file, var->type, var->name);
4626 fprintf(file, ";\n");
4627 }
4628
4629 if (!type_get_function_args(func->type))
4630 return;
4631
4633 {
4634 in_attr = is_attr(var->attrs, ATTR_IN);
4635 out_attr = is_attr(var->attrs, ATTR_OUT);
4636 if (!out_attr && !in_attr)
4637 in_attr = 1;
4638
4639 if (is_context_handle(var->type))
4640 print_file(file, indent, "NDR_SCONTEXT %s;\n", var->name);
4641 else
4642 {
4643 if (!in_attr && !is_conformant_array(var->type))
4644 {
4645 type_t *type_to_print;
4646 char name[16];
4647 print_file(file, indent, "%s", "");
4648 if (type_get_type(var->type) == TYPE_ARRAY &&
4650 type_to_print = var->type;
4651 else
4652 type_to_print = type_pointer_get_ref(var->type);
4653 sprintf(name, "_W%u", i++);
4654 write_type_decl(file, type_to_print, name);
4655 fprintf(file, ";\n");
4656 }
4657
4658 print_file(file, indent, "%s", "");
4660 fprintf(file, " ");
4661 if (type_get_type(var->type) == TYPE_ARRAY &&
4663 fprintf(file, "(*%s)", var->name);
4664 } else
4665 fprintf(file, "%s", var->name);
4666 write_type_right(file, var->type, FALSE);
4667 fprintf(file, ";\n");
4668
4669 if (decl_indirect(var->type))
4670 print_file(file, indent, "void *_p_%s;\n", var->name);
4671 }
4672 }
4673}
#define FALSE
Definition: types.h:117
static int is_context_handle(const type_t *type)
Definition: header.h:100
static int is_void(const type_t *t)
Definition: header.h:69
static int is_conformant_array(const type_t *t)
Definition: header.h:79
#define sprintf(buf, format,...)
Definition: sprintf.c:55
void write_type_right(FILE *h, type_t *t, int is_field)
Definition: header.c:437
void write_type_decl_left(FILE *f, type_t *t)
Definition: header.c:566
void write_type_decl(FILE *f, type_t *t, const char *name)
Definition: header.c:561
Definition: name.c:39
int decl_indirect(const type_t *t)
Definition: typegen.c:948
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101

Referenced by gen_stub(), and write_function_stub().

◆ field_memsize()

static unsigned int field_memsize ( const type_t type,
unsigned int offset 
)
static

Definition at line 1814 of file typegen.c.

1815{
1816 unsigned int align = 0;
1817 unsigned int size = type_memsize_and_alignment( type, &align );
1818
1819 *offset = ROUND_SIZE( *offset, align );
1820 return size;
1821}
GLintptr offset
Definition: glext.h:5920
#define ROUND_SIZE(size, alignment)
Definition: typegen.c:45
unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
Definition: typegen.c:1866

Referenced by write_conf_or_var_desc(), and write_descriptors().

◆ fields_memsize()

static unsigned int fields_memsize ( const var_list_t fields,
unsigned int align 
)
static

Definition at line 1823 of file typegen.c.

1824{
1825 unsigned int size = 0;
1826 unsigned int max_align;
1827 const var_t *v;
1828
1829 if (!fields) return 0;
1831 {
1832 unsigned int falign = 0;
1833 unsigned int fsize = type_memsize_and_alignment(v->type, &falign);
1834 if (*align < falign) *align = falign;
1835 falign = clamp_align(falign);
1836 size = ROUND_SIZE(size, falign);
1837 size += fsize;
1838 }
1839
1840 max_align = clamp_align(*align);
1841 size = ROUND_SIZE(size, max_align);
1842
1843 return size;
1844}
GLint fsize
Definition: glext.h:9408
const char * fields[10]
Definition: parser.c:313
static unsigned int clamp_align(unsigned int align)
Definition: typegen.c:251

Referenced by get_required_buffer_size_type(), and type_memsize_and_alignment().

◆ find_array_or_string_in_struct()

static const var_t * find_array_or_string_in_struct ( const type_t type)
static

Definition at line 3059 of file typegen.c.

3060{
3062 const var_t *last_field;
3063 const type_t *ft;
3064
3065 if (!fields || list_empty(fields))
3066 return NULL;
3067
3068 last_field = LIST_ENTRY( list_tail(fields), const var_t, entry );
3069 ft = last_field->type;
3070
3072 return last_field;
3073
3074 if (type_get_type(ft) == TYPE_STRUCT)
3076 else
3077 return NULL;
3078}
static int list_empty(struct list_entry *head)
Definition: list.h:58
Definition: list.h:37
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:137
type_t * type
Definition: widltypes.h:453
#define LIST_ENTRY(type)
Definition: queue.h:175
static const var_t * find_array_or_string_in_struct(const type_t *type)
Definition: typegen.c:3059
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:87
@ TYPE_STRUCT
Definition: widltypes.h:405

Referenced by find_array_or_string_in_struct(), write_pointer_description(), and write_struct_tfs().

◆ for_each_iface()

static void for_each_iface ( const statement_list_t stmts,
void(*)(type_t *iface, FILE *file, int indent, unsigned int *offset proc,
type_pred_t  pred,
FILE file,
int  indent,
unsigned int offset 
)
static

Definition at line 1480 of file typegen.c.

1483{
1484 const statement_t *stmt;
1485 type_t *iface;
1486
1487 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
1488 {
1489 if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
1490 continue;
1491 iface = stmt->u.type;
1492 if (!pred(iface)) continue;
1493 proc(iface, file, indent, offset);
1494 if (iface->details.iface->async_iface)
1495 proc(iface->details.iface->async_iface, file, indent, offset);
1496 }
1497}
static HANDLE proc()
Definition: pdb.c:34
statement_type_t type
Definition: parser.h:124
union _statement_t::@5043 u
union _type_t::@5042 details
struct iface_details * iface
Definition: widltypes.h:428
@ TYPE_INTERFACE
Definition: widltypes.h:412
@ STMT_TYPE
Definition: widltypes.h:242

Referenced by get_size_procformatstring(), process_tfs(), and write_procformatstring().

◆ get_aliaschain_attrp()

static void * get_aliaschain_attrp ( const type_t type,
enum attr_type  attr 
)
static

Definition at line 191 of file typegen.c.

192{
193 const type_t *t = type;
194 for (;;)
195 {
196 if (is_attr(t->attrs, attr))
197 return get_attrp(t->attrs, attr);
198 else if (type_is_alias(t))
200 else return NULL;
201 }
202}
void * get_attrp(const attr_list_t *list, enum attr_type t)
Definition: header.c:107
Definition: cookie.c:202
static type_t * type_alias_get_aliasee(const type_t *type)
Definition: typetree.h:279
static int type_is_alias(const type_t *type)
Definition: typetree.h:274

Referenced by write_remoting_arg(), and write_type_tfs().

◆ get_array_fc()

static unsigned char get_array_fc ( const type_t type)
static

Definition at line 617 of file typegen.c.

618{
619 unsigned char fc;
620 const expr_t *size_is;
621 const type_t *elem_type;
622
623 elem_type = type_array_get_element(type);
625
626 if (!size_is)
627 {
628 unsigned int size = type_memsize(elem_type);
629 if (size * type_array_get_dim(type) > 0xffffuL)
630 fc = FC_LGFARRAY;
631 else
632 fc = FC_SMFARRAY;
633 }
634 else
635 fc = FC_CARRAY;
636
638 {
639 if (fc == FC_SMFARRAY)
640 fc = FC_SMVARRAY;
641 else if (fc == FC_LGFARRAY)
642 fc = FC_LGVARRAY;
643 else if (fc == FC_CARRAY)
644 fc = FC_CVARRAY;
645 }
646
647 switch (typegen_detect_type(elem_type, NULL, TDT_IGNORE_STRINGS))
648 {
649 case TGT_USER_TYPE:
651 break;
652 case TGT_BASIC:
653 if (type_basic_get_type(elem_type) == TYPE_BASIC_INT3264 &&
654 pointer_size != 4)
656 break;
657 case TGT_STRUCT:
658 switch (get_struct_fc(elem_type))
659 {
660 case FC_BOGUS_STRUCT:
662 break;
663 }
664 break;
665 case TGT_ENUM:
666 /* is 16-bit enum - if so, wire size differs from mem size and so
667 * the array cannot be block copied, which means the array is complex */
668 if (get_enum_fc(elem_type) == FC_ENUM16)
670 break;
671 case TGT_UNION:
674 break;
675 case TGT_POINTER:
676 /* ref pointers cannot just be block copied. unique pointers to
677 * interfaces need special treatment. either case means the array is
678 * complex */
679 if (get_pointer_fc(elem_type, NULL, FALSE) == FC_RP || pointer_size != 4)
681 break;
682 case TGT_RANGE:
684 break;
685 case TGT_CTXT_HANDLE:
687 case TGT_STRING:
688 case TGT_INVALID:
689 case TGT_ARRAY:
690 /* nothing to do for everything else */
691 break;
692 }
693
694 return fc;
695}
PFOR_CONTEXT fc
Definition: for.c:57
@ FC_BOGUS_STRUCT
Definition: ndrtypes.h:162
@ FC_SMFARRAY
Definition: ndrtypes.h:166
@ FC_ENUM16
Definition: ndrtypes.h:147
@ FC_LGVARRAY
Definition: ndrtypes.h:169
@ FC_BOGUS_ARRAY
Definition: ndrtypes.h:170
@ FC_CARRAY
Definition: ndrtypes.h:164
@ FC_SMVARRAY
Definition: ndrtypes.h:168
@ FC_CVARRAY
Definition: ndrtypes.h:165
@ FC_LGFARRAY
Definition: ndrtypes.h:167
unsigned char get_struct_fc(const type_t *type)
Definition: typegen.c:478
static unsigned char get_enum_fc(const type_t *type)
Definition: typegen.c:296
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:232
static int type_array_has_variance(const type_t *type)
Definition: typetree.h:225
@ TYPE_BASIC_INT3264
Definition: widltypes.h:268

Referenced by get_required_buffer_size_type(), write_array_tfs(), and write_remoting_arg().

◆ get_basic_fc()

unsigned char get_basic_fc ( const type_t type)

Definition at line 204 of file typegen.c.

205{
207 switch (type_basic_get_type(type))
208 {
209 case TYPE_BASIC_INT8: return (sign <= 0 ? FC_SMALL : FC_USMALL);
210 case TYPE_BASIC_INT16: return (sign <= 0 ? FC_SHORT : FC_USHORT);
211 case TYPE_BASIC_INT32:
212 case TYPE_BASIC_LONG: return (sign <= 0 ? FC_LONG : FC_ULONG);
213 case TYPE_BASIC_INT64: return FC_HYPER;
214 case TYPE_BASIC_INT: return (sign <= 0 ? FC_LONG : FC_ULONG);
215 case TYPE_BASIC_INT3264: return (sign <= 0 ? FC_INT3264 : FC_UINT3264);
216 case TYPE_BASIC_BYTE: return FC_BYTE;
217 case TYPE_BASIC_CHAR: return FC_CHAR;
218 case TYPE_BASIC_WCHAR: return FC_WCHAR;
219 case TYPE_BASIC_HYPER: return FC_HYPER;
220 case TYPE_BASIC_FLOAT: return FC_FLOAT;
221 case TYPE_BASIC_DOUBLE: return FC_DOUBLE;
224 }
225 return 0;
226}
#define sign(x)
Definition: mapdesc.cc:613
@ FC_BIND_PRIMITIVE
Definition: ndrtypes.h:194
@ FC_USMALL
Definition: ndrtypes.h:138
@ FC_INT3264
Definition: ndrtypes.h:268
@ FC_SMALL
Definition: ndrtypes.h:137
@ FC_DOUBLE
Definition: ndrtypes.h:146
@ FC_USHORT
Definition: ndrtypes.h:141
@ FC_ERROR_STATUS_T
Definition: ndrtypes.h:150
@ FC_LONG
Definition: ndrtypes.h:142
@ FC_CHAR
Definition: ndrtypes.h:136
@ FC_HYPER
Definition: ndrtypes.h:145
@ FC_ULONG
Definition: ndrtypes.h:143
@ FC_FLOAT
Definition: ndrtypes.h:144
@ FC_BYTE
Definition: ndrtypes.h:135
@ FC_UINT3264
Definition: ndrtypes.h:269
@ FC_SHORT
Definition: ndrtypes.h:140
@ FC_WCHAR
Definition: ndrtypes.h:139
static int type_basic_get_sign(const type_t *type)
Definition: typetree.h:80
@ TYPE_BASIC_DOUBLE
Definition: widltypes.h:275
@ TYPE_BASIC_INT32
Definition: widltypes.h:265
@ TYPE_BASIC_ERROR_STATUS_T
Definition: widltypes.h:276
@ TYPE_BASIC_CHAR
Definition: widltypes.h:270
@ TYPE_BASIC_WCHAR
Definition: widltypes.h:273
@ TYPE_BASIC_INT16
Definition: widltypes.h:264
@ TYPE_BASIC_HYPER
Definition: widltypes.h:271
@ TYPE_BASIC_HANDLE
Definition: widltypes.h:277
@ TYPE_BASIC_INT8
Definition: widltypes.h:263
@ TYPE_BASIC_LONG
Definition: widltypes.h:269
@ TYPE_BASIC_INT64
Definition: widltypes.h:266
@ TYPE_BASIC_BYTE
Definition: widltypes.h:272
@ TYPE_BASIC_INT
Definition: widltypes.h:267
@ TYPE_BASIC_FLOAT
Definition: widltypes.h:274

Referenced by get_parameter_fc(), get_required_buffer_size_type(), print_phase_basetype(), type_buffer_alignment(), type_memsize_and_alignment(), write_branch_type(), write_conf_or_var_desc(), write_range_tfs(), write_simple_pointer(), write_string_tfs(), write_union_tfs(), and write_user_tfs().

◆ get_basic_fc_signed()

static unsigned char get_basic_fc_signed ( const type_t type)
static

Definition at line 228 of file typegen.c.

229{
230 switch (type_basic_get_type(type))
231 {
232 case TYPE_BASIC_INT8: return FC_SMALL;
233 case TYPE_BASIC_INT16: return FC_SHORT;
234 case TYPE_BASIC_INT32: return FC_LONG;
235 case TYPE_BASIC_INT64: return FC_HYPER;
236 case TYPE_BASIC_INT: return FC_LONG;
237 case TYPE_BASIC_INT3264: return FC_INT3264;
238 case TYPE_BASIC_LONG: return FC_LONG;
239 case TYPE_BASIC_BYTE: return FC_BYTE;
240 case TYPE_BASIC_CHAR: return FC_CHAR;
241 case TYPE_BASIC_WCHAR: return FC_WCHAR;
242 case TYPE_BASIC_HYPER: return FC_HYPER;
243 case TYPE_BASIC_FLOAT: return FC_FLOAT;
244 case TYPE_BASIC_DOUBLE: return FC_DOUBLE;
247 }
248 return 0;
249}

Referenced by get_parameter_fc(), write_base_type(), and write_old_procformatstring_type().

◆ get_context_handle_type_name()

static const char * get_context_handle_type_name ( const type_t type)
static

Definition at line 850 of file typegen.c.

851{
852 const type_t *t;
853 for (t = type;
854 is_ptr(t) || type_is_alias(t);
856 if (is_attr(t->attrs, ATTR_CONTEXTHANDLE))
857 return t->name;
858 assert(0);
859 return NULL;
860}
return
Definition: dirsup.c:529
#define assert(x)
Definition: debug.h:53
static int is_ptr(const type_t *t)
Definition: header.h:59
if(dx< 0)
Definition: linetemp.h:194
@ ATTR_CONTEXTHANDLE
Definition: widltypes.h:85

Referenced by write_remoting_arg().

◆ get_contexthandle_flags()

static unsigned char get_contexthandle_flags ( const type_t iface,
const attr_list_t attrs,
const type_t type 
)
static

Definition at line 444 of file typegen.c.

446{
447 unsigned char flags = 0;
448
450
451 if (is_ptr(type) &&
452 !is_attr( type->attrs, ATTR_CONTEXTHANDLE ) &&
453 !is_attr( attrs, ATTR_CONTEXTHANDLE ))
454 flags |= 0x80;
455
456 if (is_attr(attrs, ATTR_IN))
457 {
458 flags |= 0x40;
460 }
461 if (is_attr(attrs, ATTR_OUT)) flags |= 0x20;
462
463 return flags;
464}
GLbitfield flags
Definition: glext.h:7161
#define NDR_CONTEXT_HANDLE_CANNOT_BE_NULL
Definition: ndrtypes.h:288
#define NDR_STRICT_CONTEXT_HANDLE
Definition: ndrtypes.h:285
attr_list_t * attrs
Definition: widltypes.h:422
@ ATTR_STRICTCONTEXTHANDLE
Definition: widltypes.h:157

Referenced by write_contexthandle_tfs(), and write_proc_func_header().

◆ get_enum_fc()

◆ get_func_oi2_flags()

static unsigned char get_func_oi2_flags ( const var_t func)
static

Definition at line 1115 of file typegen.c.

1116{
1117 const var_t *var;
1119 var_t *retval = type_function_get_retval( func->type );
1120 unsigned char oi2_flags = 0x40; /* HasExtensions */
1121 unsigned short flags;
1122 unsigned int stack_size, typestring_offset;
1123
1124 if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
1125 {
1126 get_parameter_fc( var, 0, &flags, &stack_size, &typestring_offset );
1127 if (flags & MustSize)
1128 {
1129 if (flags & IsIn) oi2_flags |= 0x02; /* ClientMustSize */
1130 if (flags & IsOut) oi2_flags |= 0x01; /* ServerMustSize */
1131 }
1132 }
1133
1134 if (!is_void( retval->type ))
1135 {
1136 oi2_flags |= 0x04; /* HasRet */
1137 get_parameter_fc( retval, 1, &flags, &stack_size, &typestring_offset );
1138 if (flags & MustSize) oi2_flags |= 0x01; /* ServerMustSize */
1139 }
1140 return oi2_flags;
1141}
Definition: match.c:390
static const unsigned short IsOut
Definition: typegen.c:77
static const unsigned short MustSize
Definition: typegen.c:73
static unsigned char get_parameter_fc(const var_t *var, int is_return, unsigned short *flags, unsigned int *stack_size, unsigned int *typestring_offset)
Definition: typegen.c:958
static const unsigned short IsIn
Definition: typegen.c:76

Referenced by write_proc_func_header().

◆ get_function_buffer_size() [1/2]

static unsigned int get_function_buffer_size ( const var_t func,
enum pass  pass 
)
static

◆ get_function_buffer_size() [2/2]

static unsigned int get_function_buffer_size ( const var_t func,
enum pass  pass 
)
static

Definition at line 3922 of file typegen.c.

3923{
3924 const var_t *var;
3925 unsigned int total_size = 0, alignment;
3926
3927 if (type_get_function_args(func->type))
3928 {
3930 {
3931 total_size += get_required_buffer_size(var, &alignment, pass);
3932 total_size += alignment;
3933 }
3934 }
3935
3937 {
3938 var_t v = *func;
3939 v.type = type_function_get_rettype(func->type);
3940 total_size += get_required_buffer_size(&v, &alignment, PASS_RETURN);
3941 total_size += alignment;
3942 }
3943 return total_size;
3944}
static unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass)
Definition: typegen.c:3896
pass
Definition: typegen.h:25
@ PASS_RETURN
Definition: typegen.h:28
@ PASS_OUT
Definition: typegen.h:27
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:108

◆ get_padding()

static int get_padding ( const var_list_t fields)
static

Definition at line 396 of file typegen.c.

397{
398 unsigned short offset = 0;
399 unsigned int salign = 1;
400 const var_t *f;
401
402 if (!fields)
403 return 0;
404
406 {
407 type_t *ft = f->type;
408 unsigned int align = 0;
409 unsigned int size = type_memsize_and_alignment(ft, &align);
411 if (align > salign) salign = align;
413 offset += size;
414 }
415
416 return ROUNDING(offset, salign);
417}
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
#define ROUNDING(size, alignment)
Definition: typegen.c:47

Referenced by get_struct_fc().

◆ get_parameter_fc()

static unsigned char get_parameter_fc ( const var_t var,
int  is_return,
unsigned short flags,
unsigned int stack_size,
unsigned int typestring_offset 
)
static

Definition at line 958 of file typegen.c.

960{
961 unsigned int alignment, server_size = 0, buffer_size = 0;
962 unsigned char fc = 0;
963 int is_byval;
964 int is_in = is_attr(var->attrs, ATTR_IN);
965 int is_out = is_attr(var->attrs, ATTR_OUT);
966
967 if (is_return) is_out = TRUE;
968 else if (!is_in && !is_out) is_in = TRUE;
969
970 *flags = 0;
971 *stack_size = get_stack_size( var, &is_byval );
972 *typestring_offset = var->typestring_offset;
973
974 if (is_in) *flags |= IsIn;
975 if (is_out) *flags |= IsOut;
976 if (is_return) *flags |= IsReturn;
977
978 if (!is_string_type( var->attrs, var->type ))
979 buffer_size = get_required_buffer_size_type( var->type, NULL, var->attrs, TRUE, &alignment );
980
981 switch (typegen_detect_type( var->type, var->attrs, TDT_ALL_TYPES ))
982 {
983 case TGT_BASIC:
984 *flags |= IsBasetype;
985 fc = get_basic_fc_signed( var->type );
986 if (fc == FC_BIND_PRIMITIVE)
987 {
988 buffer_size = 4; /* actually 0 but avoids setting MustSize */
989 fc = FC_LONG;
990 }
991 break;
992 case TGT_ENUM:
993 *flags |= IsBasetype;
994 fc = get_enum_fc( var->type );
995 break;
996 case TGT_RANGE:
997 *flags |= IsByValue;
998 break;
999 case TGT_STRUCT:
1000 case TGT_UNION:
1001 case TGT_USER_TYPE:
1002 *flags |= MustFree | (is_byval ? IsByValue : IsSimpleRef);
1003 break;
1004 case TGT_IFACE_POINTER:
1005 *flags |= MustFree;
1006 break;
1007 case TGT_ARRAY:
1008 *flags |= MustFree;
1009 if (type_array_is_decl_as_ptr(var->type) && var->type->details.array.ptr_tfsoff &&
1010 get_pointer_fc( var->type, var->attrs, !is_return ) == FC_RP)
1011 {
1012 *typestring_offset = var->type->typestring_offset;
1013 *flags |= IsSimpleRef;
1014 }
1015 break;
1016 case TGT_STRING:
1017 *flags |= MustFree;
1018 if (is_declptr( var->type ) && get_pointer_fc( var->type, var->attrs, !is_return ) == FC_RP)
1019 {
1020 /* skip over pointer description straight to string description */
1021 if (is_conformant_array( var->type )) *typestring_offset += 4;
1022 else *typestring_offset += 2;
1023 *flags |= IsSimpleRef;
1024 }
1025 break;
1027 *flags |= IsSimpleRef;
1028 *typestring_offset += 4;
1029 /* fall through */
1030 case TGT_CTXT_HANDLE:
1031 buffer_size = 20;
1032 break;
1033 case TGT_POINTER:
1034 if (get_pointer_fc( var->type, var->attrs, !is_return ) == FC_RP)
1035 {
1036 const type_t *ref = type_pointer_get_ref( var->type );
1037
1038 if (!is_string_type( var->attrs, ref ))
1040
1042 {
1043 case TGT_BASIC:
1045 fc = get_basic_fc( ref );
1046 if (!is_in && is_out) server_size = pointer_size;
1047 break;
1048 case TGT_ENUM:
1049 if ((fc = get_enum_fc( ref )) == FC_ENUM32)
1050 {
1052 if (!is_in && is_out) server_size = pointer_size;
1053 }
1054 else
1055 {
1056 server_size = pointer_size;
1057 }
1058 break;
1059 case TGT_UNION:
1060 case TGT_USER_TYPE:
1061 case TGT_RANGE:
1062 case TGT_ARRAY:
1064 *typestring_offset = ref->typestring_offset;
1065 if (!is_in && is_out) server_size = type_memsize( ref );
1066 break;
1067 case TGT_STRING:
1068 case TGT_POINTER:
1069 case TGT_CTXT_HANDLE:
1071 *flags |= MustFree;
1072 server_size = pointer_size;
1073 break;
1074 case TGT_IFACE_POINTER:
1075 *flags |= MustFree;
1076 if (is_in && is_out) server_size = pointer_size;
1077 break;
1078 case TGT_STRUCT:
1080 *typestring_offset = ref->typestring_offset;
1081 switch (get_struct_fc(ref))
1082 {
1083 case FC_STRUCT:
1084 case FC_PSTRUCT:
1085 case FC_BOGUS_STRUCT:
1086 if (!is_in && is_out) server_size = type_memsize( ref );
1087 break;
1088 default:
1089 break;
1090 }
1091 break;
1092 case TGT_INVALID:
1093 assert(0);
1094 }
1095 }
1096 else /* not ref pointer */
1097 {
1098 *flags |= MustFree;
1099 }
1100 break;
1101 case TGT_INVALID:
1102 assert(0);
1103 }
1104
1105 if (!buffer_size) *flags |= MustSize;
1106
1107 if (server_size)
1108 {
1109 server_size = (server_size + 7) / 8;
1110 if (server_size < 8) *flags |= server_size << 13;
1111 }
1112 return fc;
1113}
static int is_declptr(const type_t *t)
Definition: header.h:74
static int is_string_type(const attr_list_t *attrs, const type_t *type)
Definition: header.h:94
@ FC_STRUCT
Definition: ndrtypes.h:157
@ FC_PSTRUCT
Definition: ndrtypes.h:158
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
static const unsigned short IsReturn
Definition: typegen.c:78
static const unsigned short IsBasetype
Definition: typegen.c:79
static const unsigned short IsSimpleRef
Definition: typegen.c:81
static unsigned int get_stack_size(const var_t *var, int *by_value)
Definition: typegen.c:419
static unsigned int get_required_buffer_size_type(const type_t *type, const char *name, const attr_list_t *attrs, int toplevel_param, unsigned int *alignment)
Definition: typegen.c:3784
static unsigned char get_basic_fc_signed(const type_t *type)
Definition: typegen.c:228
static const unsigned short MustFree
Definition: typegen.c:74
static const unsigned short IsByValue
Definition: typegen.c:80
unsigned char get_basic_fc(const type_t *type)
Definition: typegen.c:204
@ TDT_ALL_TYPES
Definition: typegen.h:41

Referenced by get_func_oi2_flags(), and write_new_procformatstring_type().

◆ get_pointer_fc()

unsigned char get_pointer_fc ( const type_t type,
const attr_list_t attrs,
int  toplevel_param 
)

Definition at line 258 of file typegen.c.

259{
260 const type_t *t;
261 int pointer_type;
262
264
265 pointer_type = get_attrv(attrs, ATTR_POINTERTYPE);
266 if (pointer_type)
267 return pointer_type;
268
270 {
271 pointer_type = get_attrv(t->attrs, ATTR_POINTERTYPE);
272 if (pointer_type)
273 return pointer_type;
274 }
275
276 if (toplevel_param)
277 return FC_RP;
278 else if (is_ptr(type))
280 else
282}
unsigned int get_attrv(const attr_list_t *list, enum attr_type t)
Definition: header.c:115
static unsigned char type_pointer_get_default_fc(const type_t *type)
Definition: typetree.h:299
static unsigned char type_array_get_ptr_default_fc(const type_t *type)
Definition: typetree.h:267
@ ATTR_POINTERTYPE
Definition: widltypes.h:142

Referenced by cant_be_null(), get_array_fc(), get_parameter_fc(), get_pointer_fc_context(), get_required_buffer_size_type(), get_struct_fc(), type_has_full_pointer(), write_contexthandle_tfs(), write_remoting_arg(), write_type_tfs(), and write_user_tfs().

◆ get_pointer_fc_context()

static unsigned char get_pointer_fc_context ( const type_t type,
const attr_list_t attrs,
enum type_context  context 
)
static

Definition at line 284 of file typegen.c.

286{
287 int pointer_fc = get_pointer_fc(type, attrs, context == TYPE_CONTEXT_TOPLEVELPARAM);
288
289 if (pointer_fc == FC_UP && is_attr( attrs, ATTR_OUT ) &&
291 pointer_fc = FC_OP;
292
293 return pointer_fc;
294}
@ FC_OP
Definition: ndrtypes.h:154
@ FC_UP
Definition: ndrtypes.h:153
int is_object(const type_t *iface)
Definition: header.c:928
Definition: http.c:7252
static const type_t * current_iface
Definition: typegen.c:51

Referenced by write_nonsimple_pointer(), write_simple_pointer(), and write_string_tfs().

◆ get_required_buffer_size()

static unsigned int get_required_buffer_size ( const var_t var,
unsigned int alignment,
enum pass  pass 
)
static

Definition at line 3896 of file typegen.c.

3897{
3898 int in_attr = is_attr(var->attrs, ATTR_IN);
3899 int out_attr = is_attr(var->attrs, ATTR_OUT);
3900
3901 if (!in_attr && !out_attr)
3902 in_attr = 1;
3903
3904 *alignment = 0;
3905
3906 if ((pass == PASS_IN && in_attr) || (pass == PASS_OUT && out_attr) ||
3907 pass == PASS_RETURN)
3908 {
3910 {
3911 *alignment = 4;
3912 return 20;
3913 }
3914
3915 if (!is_string_type(var->attrs, var->type))
3916 return get_required_buffer_size_type(var->type, var->name,
3917 var->attrs, TRUE, alignment);
3918 }
3919 return 0;
3920}
int is_ptrchain_attr(const var_t *var, enum attr_type t)
Definition: header.c:66
@ PASS_IN
Definition: typegen.h:26

Referenced by get_function_buffer_size(), and write_remoting_arg().

◆ get_required_buffer_size_type()

static unsigned int get_required_buffer_size_type ( const type_t type,
const char name,
const attr_list_t attrs,
int  toplevel_param,
unsigned int alignment 
)
static

Definition at line 3784 of file typegen.c.

3786{
3787 *alignment = 0;
3789 {
3790 case TGT_USER_TYPE:
3791 {
3792 const char *uname = NULL;
3793 const type_t *utype = get_user_type(type, &uname);
3794 return get_required_buffer_size_type(utype, uname, NULL, FALSE, alignment);
3795 }
3796 case TGT_BASIC:
3797 switch (get_basic_fc(type))
3798 {
3799 case FC_BYTE:
3800 case FC_CHAR:
3801 case FC_USMALL:
3802 case FC_SMALL:
3803 *alignment = 4;
3804 return 1;
3805
3806 case FC_WCHAR:
3807 case FC_USHORT:
3808 case FC_SHORT:
3809 *alignment = 4;
3810 return 2;
3811
3812 case FC_ULONG:
3813 case FC_LONG:
3814 case FC_FLOAT:
3815 case FC_ERROR_STATUS_T:
3816 *alignment = 4;
3817 return 4;
3818
3819 case FC_HYPER:
3820 case FC_DOUBLE:
3821 *alignment = 8;
3822 return 8;
3823
3824 case FC_INT3264:
3825 case FC_UINT3264:
3827 *alignment = pointer_size;
3828 return pointer_size;
3829
3830 case FC_IGNORE:
3831 case FC_BIND_PRIMITIVE:
3832 return 0;
3833
3834 default:
3835 error("get_required_buffer_size: unknown basic type 0x%02x\n",
3837 return 0;
3838 }
3839 break;
3840
3841 case TGT_ENUM:
3842 switch (get_enum_fc(type))
3843 {
3844 case FC_ENUM32:
3845 *alignment = 4;
3846 return 4;
3847 case FC_ENUM16:
3848 *alignment = 4;
3849 return 2;
3850 }
3851 break;
3852
3853 case TGT_STRUCT:
3855 {
3856 if (!type_struct_get_fields(type)) return 0;
3857 return fields_memsize(type_struct_get_fields(type), alignment);
3858 }
3859 break;
3860
3861 case TGT_POINTER:
3862 {
3863 unsigned int size, align;
3865 if (is_string_type( attrs, ref )) break;
3866 if (!(size = get_required_buffer_size_type( ref, name, NULL, FALSE, &align ))) break;
3867 if (get_pointer_fc(type, attrs, toplevel_param) != FC_RP)
3868 {
3869 size += 4 + align;
3870 align = 4;
3871 }
3872 *alignment = align;
3873 return size;
3874 }
3875
3876 case TGT_ARRAY:
3877 if (get_pointer_fc(type, attrs, toplevel_param) == FC_RP)
3878 {
3879 switch (get_array_fc(type))
3880 {
3881 case FC_SMFARRAY:
3882 case FC_LGFARRAY:
3883 return type_array_get_dim(type) *
3885 NULL, FALSE, alignment);
3886 }
3887 }
3888 break;
3889
3890 default:
3891 break;
3892 }
3893 return 0;
3894}
#define error(str)
Definition: mkdosfs.c:1605
@ FC_IGNORE
Definition: ndrtypes.h:149
static type_t * get_user_type(const type_t *t, const char **pname)
Definition: typegen.c:305
static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align)
Definition: typegen.c:1823
static unsigned char get_array_fc(const type_t *type)
Definition: typegen.c:617
@ TDT_IGNORE_RANGES
Definition: typegen.h:43

Referenced by get_parameter_fc(), get_required_buffer_size(), and get_required_buffer_size_type().

◆ get_rpc_flags()

static unsigned int get_rpc_flags ( const attr_list_t attrs)
static

Definition at line 466 of file typegen.c.

467{
468 unsigned int flags = 0;
469
470 if (is_attr( attrs, ATTR_IDEMPOTENT )) flags |= 0x0001;
471 if (is_attr( attrs, ATTR_BROADCAST )) flags |= 0x0002;
472 if (is_attr( attrs, ATTR_MAYBE )) flags |= 0x0004;
473 if (is_attr( attrs, ATTR_MESSAGE )) flags |= 0x0100;
474 if (is_attr( attrs, ATTR_ASYNC )) flags |= 0x4000;
475 return flags;
476}
@ ATTR_BROADCAST
Definition: widltypes.h:78
@ ATTR_ASYNC
Definition: widltypes.h:74
@ ATTR_MAYBE
Definition: widltypes.h:125
@ ATTR_MESSAGE
Definition: widltypes.h:126
@ ATTR_IDEMPOTENT
Definition: widltypes.h:113

Referenced by write_proc_func_header().

◆ get_size_is_expr()

expr_t * get_size_is_expr ( const type_t t,
const char name 
)

Definition at line 4110 of file typegen.c.

4111{
4112 expr_t *x = NULL;
4113
4114 for ( ; is_array(t); t = type_array_get_element(t))
4117 {
4118 if (!x)
4120 else
4121 error("%s: multidimensional conformant"
4122 " arrays not supported at the top level\n",
4123 name);
4124 }
4125
4126 return x;
4127}
@ EXPR_VOID
Definition: parser.h:231
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
enum expr_type type
Definition: widltypes.h:308

Referenced by write_remoting_arg().

◆ get_size_procformatstring()

unsigned int get_size_procformatstring ( const statement_list_t stmts,
type_pred_t  pred 
)

Definition at line 4602 of file typegen.c.

4603{
4604 unsigned int size = 1;
4606 return size;
4607}
static void get_size_procformatstring_iface(type_t *iface, FILE *file, int indent, unsigned int *size)
Definition: typegen.c:4591
static void for_each_iface(const statement_list_t *stmts, void(*proc)(type_t *iface, FILE *file, int indent, unsigned int *offset), type_pred_t pred, FILE *file, int indent, unsigned int *offset)
Definition: typegen.c:1480

Referenced by write_formatstringsdecl().

◆ get_size_procformatstring_func()

unsigned int get_size_procformatstring_func ( const type_t iface,
const var_t func 
)

Definition at line 4584 of file typegen.c.

4585{
4586 unsigned int offset = 0;
4587 write_procformatstring_func( NULL, 0, iface, func, &offset, 0 );
4588 return offset;
4589}
static void write_procformatstring_func(FILE *file, int indent, const type_t *iface, const var_t *func, unsigned int *offset, unsigned short num_proc)
Definition: typegen.c:1425

Referenced by get_size_procformatstring_iface(), write_function_stubs(), and write_proxy().

◆ get_size_procformatstring_iface()

static void get_size_procformatstring_iface ( type_t iface,
FILE file,
int  indent,
unsigned int size 
)
static

Definition at line 4591 of file typegen.c.

4592{
4593 const statement_t *stmt;
4595 {
4596 const var_t *func = stmt->u.var;
4597 if (!is_local(func->attrs))
4599 }
4600}
int is_local(const attr_list_t *a)
Definition: header.c:938
var_t * var
Definition: widltypes.h:539
unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func)
Definition: typegen.c:4584
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:597

Referenced by get_size_procformatstring().

◆ get_size_typeformatstring()

unsigned int get_size_typeformatstring ( const statement_list_t stmts,
type_pred_t  pred 
)

Definition at line 4609 of file typegen.c.

4610{
4612 return process_tfs(NULL, stmts, pred);
4613}
static unsigned int process_tfs(FILE *file, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:3753
void set_all_tfswrite(int val)

Referenced by write_formatstringsdecl().

◆ get_stack_size()

static unsigned int get_stack_size ( const var_t var,
int by_value 
)
static

Definition at line 419 of file typegen.c.

420{
421 unsigned int stack_size;
422 int by_val;
423
424 switch (typegen_detect_type( var->type, var->attrs, TDT_ALL_TYPES ))
425 {
426 case TGT_BASIC:
427 case TGT_ENUM:
428 case TGT_RANGE:
429 case TGT_STRUCT:
430 case TGT_UNION:
431 case TGT_USER_TYPE:
432 stack_size = type_memsize( var->type );
433 by_val = (pointer_size < 8 || stack_size <= pointer_size); /* FIXME: should be platform-specific */
434 break;
435 default:
436 by_val = 0;
437 break;
438 }
439 if (!by_val) stack_size = pointer_size;
440 if (by_value) *by_value = by_val;
441 return ROUND_SIZE( stack_size, pointer_size );
442}

Referenced by get_parameter_fc(), write_conf_or_var_desc(), write_old_procformatstring_type(), and write_proc_func_header().

◆ get_struct_fc()

unsigned char get_struct_fc ( const type_t type)

Definition at line 478 of file typegen.c.

479{
480 int has_pointer = 0;
481 int has_conformance = 0;
482 int has_variance = 0;
483 var_t *field;
485
487
488 if (get_padding(fields))
489 return FC_BOGUS_STRUCT;
490
492 {
493 type_t *t = field->type;
495
497
499 {
500 if (is_string_type(field->attrs, field->type))
501 {
503 has_conformance = 1;
504 has_variance = 1;
505 continue;
506 }
507
509 return FC_BOGUS_STRUCT;
510
512 {
513 has_conformance = 1;
514 if (list_next(fields, &field->entry))
515 error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n",
516 field->name);
517 }
519 has_variance = 1;
520
523 }
524
525 switch (typegen_type)
526 {
527 case TGT_USER_TYPE:
529 return FC_BOGUS_STRUCT;
530 case TGT_BASIC:
532 return FC_BOGUS_STRUCT;
533 break;
534 case TGT_ENUM:
535 if (get_enum_fc(t) == FC_ENUM16)
536 return FC_BOGUS_STRUCT;
537 break;
538 case TGT_POINTER:
539 case TGT_ARRAY:
540 if (get_pointer_fc(t, field->attrs, FALSE) == FC_RP || pointer_size != 4)
541 return FC_BOGUS_STRUCT;
542 has_pointer = 1;
543 break;
544 case TGT_UNION:
545 return FC_BOGUS_STRUCT;
546 case TGT_STRUCT:
547 {
548 unsigned char fc = get_struct_fc(t);
549 switch (fc)
550 {
551 case FC_STRUCT:
552 break;
553 case FC_CVSTRUCT:
554 has_conformance = 1;
555 has_variance = 1;
556 has_pointer = 1;
557 break;
558
559 case FC_CPSTRUCT:
560 has_conformance = 1;
561 if (list_next( fields, &field->entry ))
562 error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n",
563 field->name);
564 has_pointer = 1;
565 break;
566
567 case FC_CSTRUCT:
568 has_conformance = 1;
569 if (list_next( fields, &field->entry ))
570 error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n",
571 field->name);
572 break;
573
574 case FC_PSTRUCT:
575 has_pointer = 1;
576 break;
577
578 default:
579 error_loc("Unknown struct member %s with type (0x%02x)\n", field->name, fc);
580 /* fallthru - treat it as complex */
581
582 /* as soon as we see one of these these members, it's bogus... */
583 case FC_BOGUS_STRUCT:
584 return FC_BOGUS_STRUCT;
585 }
586 break;
587 }
588 case TGT_RANGE:
589 return FC_BOGUS_STRUCT;
590 case TGT_STRING:
591 /* shouldn't get here because of TDT_IGNORE_STRINGS above. fall through */
592 case TGT_INVALID:
593 case TGT_CTXT_HANDLE:
595 /* checking after parsing should mean that we don't get here. if we do,
596 * it's a checker bug */
597 assert(0);
598 }
599 }
600
601 if( has_variance )
602 {
603 if ( has_conformance )
604 return FC_CVSTRUCT;
605 else
606 return FC_BOGUS_STRUCT;
607 }
608 if( has_conformance && has_pointer )
609 return FC_CPSTRUCT;
610 if( has_conformance )
611 return FC_CSTRUCT;
612 if( has_pointer )
613 return FC_PSTRUCT;
614 return FC_STRUCT;
615}
@ FC_CPSTRUCT
Definition: ndrtypes.h:160
@ FC_CVSTRUCT
Definition: ndrtypes.h:161
@ FC_CSTRUCT
Definition: ndrtypes.h:159
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
void error_loc(const char *s,...)
Definition: utils.c:69
Definition: parser.c:44
static int get_padding(const var_list_t *fields)
Definition: typegen.c:396
typegen_type
Definition: typegen.h:47

Referenced by get_array_fc(), get_parameter_fc(), get_required_buffer_size_type(), get_struct_fc(), is_non_complex_struct(), user_type_has_variable_size(), write_pointer_description(), write_remoting_arg(), and write_struct_tfs().

◆ get_user_type()

static type_t * get_user_type ( const type_t t,
const char **  pname 
)
static

Definition at line 305 of file typegen.c.

306{
307 for (;;)
308 {
309 type_t *ut = get_attrp(t->attrs, ATTR_WIREMARSHAL);
310 if (ut)
311 {
312 if (pname)
313 *pname = t->name;
314 return ut;
315 }
316
317 if (type_is_alias(t))
319 else
320 return NULL;
321 }
322}
GLenum pname
Definition: glext.h:5645
@ ATTR_WIREMARSHAL
Definition: widltypes.h:171

Referenced by get_required_buffer_size_type(), is_user_type(), and write_user_tfs().

◆ guard_rec()

static void guard_rec ( type_t type)
static

Definition at line 824 of file typegen.c.

825{
826 /* types that contain references to themselves (like a linked list),
827 need to be shielded from infinite recursion when writing embedded
828 types */
829 if (type->typestring_offset)
830 type->tfswrite = FALSE;
831 else
832 type->typestring_offset = 1;
833}

Referenced by write_struct_tfs(), write_union_tfs(), and write_user_tfs().

◆ is_conformance_needed_for_phase()

static int is_conformance_needed_for_phase ( enum remoting_phase  phase)
inlinestatic

Definition at line 4105 of file typegen.c.

4106{
4107 return (phase != PHASE_UNMARSHAL);
4108}
@ PHASE_UNMARSHAL
Definition: typegen.h:35

Referenced by write_parameter_conf_or_var_exprs().

◆ is_embedded_complex()

static int is_embedded_complex ( const type_t type)
static

Definition at line 835 of file typegen.c.

836{
838 {
839 case TGT_USER_TYPE:
840 case TGT_STRUCT:
841 case TGT_UNION:
842 case TGT_ARRAY:
844 return TRUE;
845 default:
846 return FALSE;
847 }
848}

Referenced by write_array_element_type(), and write_member_type().

◆ is_full_pointer_function()

int is_full_pointer_function ( const var_t func)

Definition at line 2075 of file typegen.c.

2076{
2077 const var_t *var;
2079 return TRUE;
2080 if (!type_get_function_args(func->type))
2081 return FALSE;
2083 if (type_has_full_pointer( var->type, var->attrs, TRUE ))
2084 return TRUE;
2085 return FALSE;
2086}
static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:750

Referenced by gen_proxy(), gen_stub(), write_function_stub(), and write_proc_func_header().

◆ is_interpreted_func()

int is_interpreted_func ( const type_t iface,
const var_t func 
)

Definition at line 1240 of file typegen.c.

1241{
1242 const char *str;
1243 const var_t *var;
1244 const var_list_t *args = type_get_function_args( func->type );
1245 const type_t *ret_type = type_function_get_rettype( func->type );
1246
1247 if (type_get_type( ret_type ) == TYPE_BASIC)
1248 {
1249 switch (type_basic_get_type( ret_type ))
1250 {
1251 case TYPE_BASIC_INT64:
1252 case TYPE_BASIC_HYPER:
1253 /* return value must fit in a long_ptr */
1254 if (pointer_size < 8) return 0;
1255 break;
1256 case TYPE_BASIC_FLOAT:
1257 case TYPE_BASIC_DOUBLE:
1258 /* floating point values can't be returned */
1259 return 0;
1260 default:
1261 break;
1262 }
1263 }
1264 if (get_stub_mode() != MODE_Oif && args)
1265 {
1267 switch (type_get_type( var->type ))
1268 {
1269 case TYPE_BASIC:
1270 switch (type_basic_get_type( var->type ))
1271 {
1272 /* floating point arguments are not supported in Oi mode */
1273 case TYPE_BASIC_FLOAT: return 0;
1274 case TYPE_BASIC_DOUBLE: return 0;
1275 default: break;
1276 }
1277 break;
1278 /* unions passed by value are not supported in Oi mode */
1279 case TYPE_UNION: return 0;
1280 case TYPE_ENCAPSULATED_UNION: return 0;
1281 default: break;
1282 }
1283 }
1284
1285 if ((str = get_attrp( func->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" );
1286 if ((str = get_attrp( iface->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" );
1287 return (get_stub_mode() != MODE_Os);
1288}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
const WCHAR * str
enum stub_mode get_stub_mode(void)
Definition: widl.c:211
@ MODE_Os
Definition: widl.h:87
@ MODE_Oif
Definition: widl.h:89
@ TYPE_UNION
Definition: widltypes.h:407
@ TYPE_ENCAPSULATED_UNION
Definition: widltypes.h:406
@ ATTR_OPTIMIZE
Definition: widltypes.h:136

Referenced by gen_proxy(), gen_stub(), need_inline_stubs(), need_proxy_and_inline_stubs(), write_conf_or_var_desc(), write_dispatchtable(), write_function_stub(), write_nonsimple_pointer(), write_procformatstring_func(), write_proxy(), write_proxy_methods(), write_simple_pointer(), write_stub_methods(), and write_thunk_methods().

◆ is_non_complex_struct()

static int is_non_complex_struct ( const type_t type)
static

Definition at line 697 of file typegen.c.

698{
699 return (type_get_type(type) == TYPE_STRUCT &&
701}

Referenced by write_no_repeat_pointer_descriptions(), and write_pointer_description_offsets().

◆ is_user_type()

static int is_user_type ( const type_t t)
static

Definition at line 324 of file typegen.c.

325{
326 return get_user_type(t, NULL) != NULL;
327}

Referenced by decl_indirect(), typegen_detect_type(), and write_nonsimple_pointer().

◆ print()

void print ( FILE file,
int  indent,
const char format,
va_list  va 
)

Definition at line 879 of file typegen.c.

880{
881 if (file)
882 {
883 if (format[0] != '\n')
884 while (0 < indent--)
885 fprintf(file, " ");
886 vfprintf(file, format, va);
887 }
888}
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)

Referenced by print_file().

◆ print_file()

static void static void print_file ( FILE file,
int  indent,
const char format,
  ... 
)
static

Definition at line 871 of file typegen.c.

872{
873 va_list va;
874 va_start(va, format);
875 print(file, indent, format, va);
876 va_end(va);
877}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
void print(FILE *file, int indent, const char *format, va_list va)
Definition: typegen.c:879

Referenced by assign_stub_out_args(), declare_stub_args(), print_phase_basetype(), print_phase_function(), print_start_tfs_comment(), write_array_tfs(), write_base_type(), write_branch_type(), write_client_call_routine(), write_conf_or_var_desc(), write_conformant_array_pointer_descriptions(), write_contexthandle_tfs(), write_descriptors(), write_end(), write_endpoints(), write_expr_eval_routine_list(), write_expr_eval_routines(), write_fixed_array_pointer_descriptions(), write_formatdesc(), write_formatstringsdecl(), write_full_pointer_free(), write_full_pointer_init(), write_func_param_struct(), write_ip_tfs(), write_member_type(), write_new_procformatstring_type(), write_no_repeat_pointer_descriptions(), write_nonsimple_pointer(), write_old_procformatstring_type(), write_parameter_conf_or_var_exprs(), write_pointer_checks(), write_pointer_description_offsets(), write_proc_func_header(), write_procformatstring(), write_procformatstring_func(), write_procformatstring_offsets(), write_range_tfs(), write_remoting_arg(), write_remoting_arguments(), write_simple_pointer(), write_string_tfs(), write_struct_members(), write_struct_tfs(), write_type_tfs(), write_typeformatstring(), write_union_tfs(), write_user_quad_list(), write_user_tfs(), write_var_init(), and write_varying_array_pointer_descriptions().

◆ print_phase_basetype()

void print_phase_basetype ( FILE file,
int  indent,
const char local_var_prefix,
enum remoting_phase  phase,
enum pass pass pass  ,
const var_t var,
const char varname 
)

Definition at line 3986 of file typegen.c.

3989{
3990 type_t *type = var->type;
3991 unsigned int alignment = 0;
3992
3993 /* no work to do for other phases, buffer sizing is done elsewhere */
3994 if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL)
3995 return;
3996
3997 if (type_get_type(type) == TYPE_ENUM ||
4000 pointer_size != 4))
4001 {
4002 unsigned char fc;
4003
4005 fc = get_enum_fc(type);
4006 else
4007 fc = get_basic_fc(type);
4008
4009 if (phase == PHASE_MARSHAL)
4010 print_file(file, indent, "NdrSimpleTypeMarshall(\n");
4011 else
4012 print_file(file, indent, "NdrSimpleTypeUnmarshall(\n");
4013 print_file(file, indent+1, "&__frame->_StubMsg,\n");
4014 print_file(file, indent+1, "(unsigned char *)&%s%s,\n",
4015 local_var_prefix,
4016 var->name);
4017 print_file(file, indent+1, "0x%02x /* %s */);\n", fc, string_of_type(fc));
4018 }
4019 else
4020 {
4022 switch (get_basic_fc(ref))
4023 {
4024 case FC_BYTE:
4025 case FC_CHAR:
4026 case FC_SMALL:
4027 case FC_USMALL:
4028 alignment = 1;
4029 break;
4030
4031 case FC_WCHAR:
4032 case FC_USHORT:
4033 case FC_SHORT:
4034 alignment = 2;
4035 break;
4036
4037 case FC_ULONG:
4038 case FC_LONG:
4039 case FC_FLOAT:
4040 case FC_ERROR_STATUS_T:
4041 /* pointer_size must be 4 if we got here in these two cases */
4042 case FC_INT3264:
4043 case FC_UINT3264:
4044 alignment = 4;
4045 break;
4046
4047 case FC_HYPER:
4048 case FC_DOUBLE:
4049 alignment = 8;
4050 break;
4051
4052 case FC_IGNORE:
4053 case FC_BIND_PRIMITIVE:
4054 /* no marshalling needed */
4055 return;
4056
4057 default:
4058 error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n",
4059 var->name, get_basic_fc(ref));
4060 }
4061
4062 if (phase == PHASE_MARSHAL && alignment > 1)
4063 print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1);
4064 print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n",
4065 alignment - 1, alignment - 1);
4066
4067 if (phase == PHASE_MARSHAL)
4068 {
4069 print_file(file, indent, "*(");
4071 if (is_ptr(type))
4072 fprintf(file, " *)__frame->_StubMsg.Buffer = *");
4073 else
4074 fprintf(file, " *)__frame->_StubMsg.Buffer = ");
4075 fprintf(file, "%s%s", local_var_prefix, varname);
4076 fprintf(file, ";\n");
4077 }
4078 else if (phase == PHASE_UNMARSHAL)
4079 {
4080 print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof(");
4082 fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n");
4083 print_file(file, indent, "{\n");
4084 print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
4085 print_file(file, indent, "}\n");
4086 print_file(file, indent, "%s%s%s",
4087 (pass == PASS_IN || pass == PASS_RETURN) ? "" : "*",
4088 local_var_prefix, varname);
4089 if (pass == PASS_IN && is_ptr(type))
4090 fprintf(file, " = (");
4091 else
4092 fprintf(file, " = *(");
4094 fprintf(file, " *)__frame->_StubMsg.Buffer;\n");
4095 }
4096
4097 print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof(");
4099 fprintf(file, ");\n");
4100 }
4101}
static const char * string_of_type(unsigned char type)
Definition: typegen.c:101
@ PHASE_MARSHAL
Definition: typegen.h:34

Referenced by write_remoting_arg().

◆ print_phase_function()

static void print_phase_function ( FILE file,
int  indent,
const char type,
const char local_var_prefix,
enum remoting_phase  phase,
const var_t var,
unsigned int  type_offset 
)
static

Definition at line 3946 of file typegen.c.

3949{
3950 const char *function;
3951 switch (phase)
3952 {
3953 case PHASE_BUFFERSIZE:
3954 function = "BufferSize";
3955 break;
3956 case PHASE_MARSHAL:
3957 function = "Marshall";
3958 break;
3959 case PHASE_UNMARSHAL:
3960 function = "Unmarshall";
3961 break;
3962 case PHASE_FREE:
3963 function = "Free";
3964 break;
3965 default:
3966 assert(0);
3967 return;
3968 }
3969
3970 print_file(file, indent, "Ndr%s%s(\n", type, function);
3971 indent++;
3972 print_file(file, indent, "&__frame->_StubMsg,\n");
3973 print_file(file, indent, "%s%s%s%s%s,\n",
3974 (phase == PHASE_UNMARSHAL) ? "(unsigned char **)" : "(unsigned char *)",
3975 (phase == PHASE_UNMARSHAL || decl_indirect(var->type)) ? "&" : "",
3976 local_var_prefix,
3977 (phase == PHASE_UNMARSHAL && decl_indirect(var->type)) ? "_p_" : "",
3978 var->name);
3979 print_file(file, indent, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]%s\n",
3980 type_offset, (phase == PHASE_UNMARSHAL) ? "," : ");");
3981 if (phase == PHASE_UNMARSHAL)
3982 print_file(file, indent, "0);\n");
3983 indent--;
3984}
@ PHASE_BUFFERSIZE
Definition: typegen.h:33
@ PHASE_FREE
Definition: typegen.h:36

Referenced by write_remoting_arg().

◆ print_start_tfs_comment()

static void print_start_tfs_comment ( FILE file,
type_t t,
unsigned int  tfsoff 
)
static

Definition at line 2221 of file typegen.c.

2222{
2223 print_file(file, 0, "/* %u (", tfsoff);
2225 print_file(file, 0, ") */\n");
2226}

Referenced by write_array_tfs(), write_contexthandle_tfs(), write_ip_tfs(), write_pointer_tfs(), write_string_tfs(), write_struct_tfs(), write_union_tfs(), and write_user_tfs().

◆ process_tfs()

static unsigned int process_tfs ( FILE file,
const statement_list_t stmts,
type_pred_t  pred 
)
static

Definition at line 3753 of file typegen.c.

3754{
3755 unsigned int typeformat_offset = 2;
3756 for_each_iface(stmts, process_tfs_iface, pred, file, 0, &typeformat_offset);
3757 return typeformat_offset + 1;
3758}
static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned int *offset)
Definition: typegen.c:3700

Referenced by get_size_typeformatstring(), and write_typeformatstring().

◆ process_tfs_iface()

static void process_tfs_iface ( type_t iface,
FILE file,
int  indent,
unsigned int offset 
)
static

Definition at line 3700 of file typegen.c.

3701{
3702 const statement_list_t *stmts = type_iface_get_stmts(iface);
3703 const statement_t *stmt;
3704 var_t *var;
3705
3706 current_iface = iface;
3707 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry )
3708 {
3709 switch(stmt->type)
3710 {
3711 case STMT_DECLARATION:
3712 {
3713 const var_t *func = stmt->u.var;
3714
3715 if(stmt->u.var->stgclass != STG_NONE
3717 continue;
3718
3720 if (is_local(func->attrs)) continue;
3721
3723 if (!is_void(var->type))
3724 var->typestring_offset = write_type_tfs( file, 2, func->attrs, var->type, func->name,
3726
3727 if (type_get_function_args(func->type))
3729 var->typestring_offset = write_type_tfs( file, 2, var->attrs, var->type, var->name,
3731 break;
3732
3733 }
3734 case STMT_TYPEDEF:
3735 {
3736 const type_list_t *type_entry;
3737 for (type_entry = stmt->u.type_list; type_entry; type_entry = type_entry->next)
3738 {
3739 if (is_attr(type_entry->type->attrs, ATTR_ENCODE)
3740 || is_attr(type_entry->type->attrs, ATTR_DECODE))
3741 type_entry->type->typestring_offset = write_type_tfs( file, 2,
3742 type_entry->type->attrs, type_entry->type, type_entry->type->name,
3744 }
3745 break;
3746 }
3747 default:
3748 break;
3749 }
3750 }
3751}
type_list_t * type_list
Definition: widltypes.h:541
struct _type_list_t * next
Definition: widltypes.h:528
type_t * type
Definition: widltypes.h:527
unsigned int typestring_offset
Definition: widltypes.h:438
const char * name
Definition: widltypes.h:419
enum storage_class stgclass
Definition: widltypes.h:456
static unsigned int write_type_tfs(FILE *file, int indent, const attr_list_t *attrs, type_t *type, const char *name, enum type_context context, unsigned int *typeformat_offset)
Definition: typegen.c:3589
static const var_t * current_func
Definition: typegen.c:50
@ TYPE_FUNCTION
Definition: widltypes.h:411
@ STG_NONE
Definition: widltypes.h:232
@ ATTR_DECODE
Definition: widltypes.h:87
@ ATTR_ENCODE
Definition: widltypes.h:99
@ STMT_DECLARATION
Definition: widltypes.h:241
@ STMT_TYPEDEF
Definition: widltypes.h:245
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:590

Referenced by process_tfs().

◆ processed()

◆ string_of_type()

static const char * string_of_type ( unsigned char  type)
static

Definition at line 101 of file typegen.c.

102{
103 switch (type)
104 {
105 case FC_BYTE: return "FC_BYTE";
106 case FC_CHAR: return "FC_CHAR";
107 case FC_SMALL: return "FC_SMALL";
108 case FC_USMALL: return "FC_USMALL";
109 case FC_WCHAR: return "FC_WCHAR";
110 case FC_SHORT: return "FC_SHORT";
111 case FC_USHORT: return "FC_USHORT";
112 case FC_LONG: return "FC_LONG";
113 case FC_ULONG: return "FC_ULONG";
114 case FC_FLOAT: return "FC_FLOAT";
115 case FC_HYPER: return "FC_HYPER";
116 case FC_DOUBLE: return "FC_DOUBLE";
117 case FC_ENUM16: return "FC_ENUM16";
118 case FC_ENUM32: return "FC_ENUM32";
119 case FC_IGNORE: return "FC_IGNORE";
120 case FC_ERROR_STATUS_T: return "FC_ERROR_STATUS_T";
121 case FC_RP: return "FC_RP";
122 case FC_UP: return "FC_UP";
123 case FC_OP: return "FC_OP";
124 case FC_FP: return "FC_FP";
125 case FC_ENCAPSULATED_UNION: return "FC_ENCAPSULATED_UNION";
126 case FC_NON_ENCAPSULATED_UNION: return "FC_NON_ENCAPSULATED_UNION";
127 case FC_STRUCT: return "FC_STRUCT";
128 case FC_PSTRUCT: return "FC_PSTRUCT";
129 case FC_CSTRUCT: return "FC_CSTRUCT";
130 case FC_CPSTRUCT: return "FC_CPSTRUCT";
131 case FC_CVSTRUCT: return "FC_CVSTRUCT";
132 case FC_BOGUS_STRUCT: return "FC_BOGUS_STRUCT";
133 case FC_SMFARRAY: return "FC_SMFARRAY";
134 case FC_LGFARRAY: return "FC_LGFARRAY";
135 case FC_SMVARRAY: return "FC_SMVARRAY";
136 case FC_LGVARRAY: return "FC_LGVARRAY";
137 case FC_CARRAY: return "FC_CARRAY";
138 case FC_CVARRAY: return "FC_CVARRAY";
139 case FC_BOGUS_ARRAY: return "FC_BOGUS_ARRAY";
140 case FC_ALIGNM2: return "FC_ALIGNM2";
141 case FC_ALIGNM4: return "FC_ALIGNM4";
142 case FC_ALIGNM8: return "FC_ALIGNM8";
143 case FC_POINTER: return "FC_POINTER";
144 case FC_C_CSTRING: return "FC_C_CSTRING";
145 case FC_C_WSTRING: return "FC_C_WSTRING";
146 case FC_CSTRING: return "FC_CSTRING";
147 case FC_WSTRING: return "FC_WSTRING";
148 case FC_BYTE_COUNT_POINTER: return "FC_BYTE_COUNT_POINTER";
149 case FC_TRANSMIT_AS: return "FC_TRANSMIT_AS";
150 case FC_REPRESENT_AS: return "FC_REPRESENT_AS";
151 case FC_IP: return "FC_IP";
152 case FC_BIND_CONTEXT: return "FC_BIND_CONTEXT";
153 case FC_BIND_GENERIC: return "FC_BIND_GENERIC";
154 case FC_BIND_PRIMITIVE: return "FC_BIND_PRIMITIVE";
155 case FC_AUTO_HANDLE: return "FC_AUTO_HANDLE";
156 case FC_CALLBACK_HANDLE: return "FC_CALLBACK_HANDLE";
157 case FC_STRUCTPAD1: return "FC_STRUCTPAD1";
158 case FC_STRUCTPAD2: return "FC_STRUCTPAD2";
159 case FC_STRUCTPAD3: return "FC_STRUCTPAD3";
160 case FC_STRUCTPAD4: return "FC_STRUCTPAD4";
161 case FC_STRUCTPAD5: return "FC_STRUCTPAD5";
162 case FC_STRUCTPAD6: return "FC_STRUCTPAD6";
163 case FC_STRUCTPAD7: return "FC_STRUCTPAD7";
164 case FC_STRING_SIZED: return "FC_STRING_SIZED";
165 case FC_NO_REPEAT: return "FC_NO_REPEAT";
166 case FC_FIXED_REPEAT: return "FC_FIXED_REPEAT";
167 case FC_VARIABLE_REPEAT: return "FC_VARIABLE_REPEAT";
168 case FC_FIXED_OFFSET: return "FC_FIXED_OFFSET";
169 case FC_VARIABLE_OFFSET: return "FC_VARIABLE_OFFSET";
170 case FC_PP: return "FC_PP";
171 case FC_EMBEDDED_COMPLEX: return "FC_EMBEDDED_COMPLEX";
172 case FC_DEREFERENCE: return "FC_DEREFERENCE";
173 case FC_DIV_2: return "FC_DIV_2";
174 case FC_MULT_2: return "FC_MULT_2";
175 case FC_ADD_1: return "FC_ADD_1";
176 case FC_SUB_1: return "FC_SUB_1";
177 case FC_CALLBACK: return "FC_CALLBACK";
178 case FC_CONSTANT_IID: return "FC_CONSTANT_IID";
179 case FC_END: return "FC_END";
180 case FC_PAD: return "FC_PAD";
181 case FC_USER_MARSHAL: return "FC_USER_MARSHAL";
182 case FC_RANGE: return "FC_RANGE";
183 case FC_INT3264: return "FC_INT3264";
184 case FC_UINT3264: return "FC_UINT3264";
185 default:
186 error("string_of_type: unknown type 0x%02x\n", type);
187 return NULL;
188 }
189}
@ FC_STRUCTPAD4
Definition: ndrtypes.h:213
@ FC_ADD_1
Definition: ndrtypes.h:246
@ FC_BIND_GENERIC
Definition: ndrtypes.h:193
@ FC_SUB_1
Definition: ndrtypes.h:247
@ FC_DEREFERENCE
Definition: ndrtypes.h:243
@ FC_C_CSTRING
Definition: ndrtypes.h:172
@ FC_ALIGNM4
Definition: ndrtypes.h:203
@ FC_ALIGNM2
Definition: ndrtypes.h:202
@ FC_C_WSTRING
Definition: ndrtypes.h:175
@ FC_BYTE_COUNT_POINTER
Definition: ndrtypes.h:184
@ FC_ENCAPSULATED_UNION
Definition: ndrtypes.h:181
@ FC_RANGE
Definition: ndrtypes.h:266
@ FC_NO_REPEAT
Definition: ndrtypes.h:222
@ FC_CONSTANT_IID
Definition: ndrtypes.h:251
@ FC_STRUCTPAD1
Definition: ndrtypes.h:210
@ FC_EMBEDDED_COMPLEX
Definition: ndrtypes.h:233
@ FC_CSTRING
Definition: ndrtypes.h:176
@ FC_STRUCTPAD7
Definition: ndrtypes.h:216
@ FC_PP
Definition: ndrtypes.h:228
@ FC_ALIGNM8
Definition: ndrtypes.h:204
@ FC_MULT_2
Definition: ndrtypes.h:245
@ FC_AUTO_HANDLE
Definition: ndrtypes.h:195
@ FC_NON_ENCAPSULATED_UNION
Definition: ndrtypes.h:182
@ FC_POINTER
Definition: ndrtypes.h:200
@ FC_CALLBACK
Definition: ndrtypes.h:249
@ FC_PAD
Definition: ndrtypes.h:254
@ FC_STRING_SIZED
Definition: ndrtypes.h:218
@ FC_FIXED_REPEAT
Definition: ndrtypes.h:223
@ FC_STRUCTPAD5
Definition: ndrtypes.h:214
@ FC_WSTRING
Definition: ndrtypes.h:179
@ FC_STRUCTPAD2
Definition: ndrtypes.h:211
@ FC_USER_MARSHAL
Definition: ndrtypes.h:261
@ FC_BIND_CONTEXT
Definition: ndrtypes.h:191
@ FC_VARIABLE_OFFSET
Definition: ndrtypes.h:226
@ FC_FIXED_OFFSET
Definition: ndrtypes.h:225
@ FC_STRUCTPAD6
Definition: ndrtypes.h:215
@ FC_FP
Definition: ndrtypes.h:155
@ FC_REPRESENT_AS
Definition: ndrtypes.h:187
@ FC_END
Definition: ndrtypes.h:253
@ FC_DIV_2
Definition: ndrtypes.h:244
@ FC_CALLBACK_HANDLE
Definition: ndrtypes.h:196
@ FC_TRANSMIT_AS
Definition: ndrtypes.h:186
@ FC_STRUCTPAD3
Definition: ndrtypes.h:212
@ FC_IP
Definition: ndrtypes.h:189
@ FC_VARIABLE_REPEAT
Definition: ndrtypes.h:224

Referenced by print_phase_basetype(), write_array_tfs(), write_base_type(), write_branch_type(), write_conf_or_var_desc(), write_contexthandle_tfs(), write_member_type(), write_new_procformatstring_type(), write_nonsimple_pointer(), write_old_procformatstring_type(), write_proc_func_header(), write_range_tfs(), write_simple_pointer(), write_string_tfs(), write_struct_members(), write_struct_tfs(), write_type_tfs(), write_union_tfs(), and write_user_tfs().

◆ type_buffer_alignment()

static unsigned int type_buffer_alignment ( const type_t t)
static

Definition at line 1981 of file typegen.c.

1982{
1983 const var_list_t *fields;
1984 const var_t *var;
1985 unsigned int max = 0, align;
1986
1987 switch (type_get_type(t))
1988 {
1989 case TYPE_BASIC:
1990 switch (get_basic_fc(t))
1991 {
1992 case FC_BYTE:
1993 case FC_CHAR:
1994 case FC_USMALL:
1995 case FC_SMALL:
1996 return 1;
1997 case FC_WCHAR:
1998 case FC_USHORT:
1999 case FC_SHORT:
2000 return 2;
2001 case FC_ULONG:
2002 case FC_LONG:
2003 case FC_ERROR_STATUS_T:
2004 case FC_FLOAT:
2005 case FC_INT3264:
2006 case FC_UINT3264:
2007 return 4;
2008 case FC_HYPER:
2009 case FC_DOUBLE:
2010 return 8;
2011 default:
2012 error("type_buffer_alignment: Unknown type 0x%x\n", get_basic_fc(t));
2013 }
2014 break;
2015 case TYPE_ENUM:
2016 switch (get_enum_fc(t))
2017 {
2018 case FC_ENUM16:
2019 return 2;
2020 case FC_ENUM32:
2021 return 4;
2022 default:
2023 error("type_buffer_alignment: Unknown enum type\n");
2024 }
2025 break;
2026 case TYPE_STRUCT:
2027 if (!(fields = type_struct_get_fields(t))) break;
2029 {
2030 if (!var->type) continue;
2031 align = type_buffer_alignment( var->type );
2032 if (max < align) max = align;
2033 }
2034 break;
2038 {
2039 if (!var->type) continue;
2040 align = type_buffer_alignment( var->type );
2041 if (max < align) max = align;
2042 }
2043 break;
2044 case TYPE_UNION:
2045 if (!(fields = type_union_get_cases(t))) break;
2047 {
2048 if (!var->type) continue;
2049 align = type_buffer_alignment( var->type );
2050 if (max < align) max = align;
2051 }
2052 break;
2053 case TYPE_ARRAY:
2056 /* else fall through */
2057 case TYPE_POINTER:
2058 return 4;
2059 case TYPE_INTERFACE:
2060 case TYPE_ALIAS:
2061 case TYPE_VOID:
2062 case TYPE_COCLASS:
2063 case TYPE_MODULE:
2064 case TYPE_FUNCTION:
2065 case TYPE_BITFIELD:
2066 /* these types should not be encountered here due to language
2067 * restrictions (interface, void, coclass, module), logical
2068 * restrictions (alias - due to type_get_type call above) or
2069 * checking restrictions (function, bitfield). */
2070 assert(0);
2071 }
2072 return max;
2073}
#define max(a, b)
Definition: svc.c:63
static unsigned int type_buffer_alignment(const type_t *t)
Definition: typegen.c:1981
static var_list_t * type_union_get_cases(const type_t *type)
Definition: typetree.h:134
static var_list_t * type_encapsulated_union_get_fields(const type_t *type)
Definition: typetree.h:127
@ TYPE_BITFIELD
Definition: widltypes.h:415
@ TYPE_ALIAS
Definition: widltypes.h:408
@ TYPE_VOID
Definition: widltypes.h:402
@ TYPE_COCLASS
Definition: widltypes.h:410
@ TYPE_MODULE
Definition: widltypes.h:409

Referenced by type_buffer_alignment(), write_array_tfs(), write_struct_tfs(), and write_user_tfs().

◆ type_has_full_pointer()

static int type_has_full_pointer ( const type_t type,
const attr_list_t attrs,
int  toplevel_param 
)
static

Definition at line 750 of file typegen.c.

752{
754 {
755 case TGT_USER_TYPE:
756 return FALSE;
757 case TGT_POINTER:
758 if (get_pointer_fc(type, attrs, toplevel_param) == FC_FP)
759 return TRUE;
760 else
761 return FALSE;
762 case TGT_ARRAY:
763 if (get_pointer_fc(type, attrs, toplevel_param) == FC_FP)
764 return TRUE;
765 else
767 case TGT_STRUCT:
768 {
770 const var_t *field;
772 {
774 return TRUE;
775 }
776 break;
777 }
778 case TGT_UNION:
779 {
781 const var_t *field;
784 {
786 return TRUE;
787 }
788 break;
789 }
790 case TGT_CTXT_HANDLE:
792 case TGT_STRING:
794 case TGT_BASIC:
795 case TGT_ENUM:
796 case TGT_RANGE:
797 case TGT_INVALID:
798 break;
799 }
800
801 return FALSE;
802}

Referenced by is_full_pointer_function(), and type_has_full_pointer().

◆ type_has_pointers()

static int type_has_pointers ( const type_t type)
static

Definition at line 703 of file typegen.c.

704{
706 {
707 case TGT_USER_TYPE:
708 return FALSE;
709 case TGT_POINTER:
710 return TRUE;
711 case TGT_ARRAY:
713 case TGT_STRUCT:
714 {
716 const var_t *field;
718 {
720 return TRUE;
721 }
722 break;
723 }
724 case TGT_UNION:
725 {
727 const var_t *field;
730 {
732 return TRUE;
733 }
734 break;
735 }
736 case TGT_CTXT_HANDLE:
738 case TGT_STRING:
740 case TGT_BASIC:
741 case TGT_ENUM:
742 case TGT_RANGE:
743 case TGT_INVALID:
744 break;
745 }
746
747 return FALSE;
748}

Referenced by assign_stub_out_args(), type_has_pointers(), write_array_tfs(), and write_struct_tfs().

◆ type_memsize()

◆ type_memsize_and_alignment()

unsigned int type_memsize_and_alignment ( const type_t t,
unsigned int align 
)

Definition at line 1866 of file typegen.c.

1867{
1868 unsigned int size = 0;
1869
1870 switch (type_get_type(t))
1871 {
1872 case TYPE_BASIC:
1873 switch (get_basic_fc(t))
1874 {
1875 case FC_BYTE:
1876 case FC_CHAR:
1877 case FC_USMALL:
1878 case FC_SMALL:
1879 size = 1;
1880 if (size > *align) *align = size;
1881 break;
1882 case FC_WCHAR:
1883 case FC_USHORT:
1884 case FC_SHORT:
1885 size = 2;
1886 if (size > *align) *align = size;
1887 break;
1888 case FC_ULONG:
1889 case FC_LONG:
1890 case FC_ERROR_STATUS_T:
1891 case FC_FLOAT:
1892 size = 4;
1893 if (size > *align) *align = size;
1894 break;
1895 case FC_HYPER:
1896 case FC_DOUBLE:
1897 size = 8;
1898 if (size > *align) *align = size;
1899 break;
1900 case FC_INT3264:
1901 case FC_UINT3264:
1902 case FC_BIND_PRIMITIVE:
1905 if (size > *align) *align = size;
1906 break;
1907 default:
1908 error("type_memsize: Unknown type 0x%x\n", get_basic_fc(t));
1909 size = 0;
1910 }
1911 break;
1912 case TYPE_ENUM:
1913 switch (get_enum_fc(t))
1914 {
1915 case FC_ENUM16:
1916 case FC_ENUM32:
1917 size = 4;
1918 if (size > *align) *align = size;
1919 break;
1920 default:
1921 error("type_memsize: Unknown enum type\n");
1922 size = 0;
1923 }
1924 break;
1925 case TYPE_STRUCT:
1927 break;
1930 break;
1931 case TYPE_UNION:
1933 break;
1934 case TYPE_POINTER:
1935 case TYPE_INTERFACE:
1938 if (size > *align) *align = size;
1939 break;
1940 case TYPE_ARRAY:
1942 {
1944 {
1946 size = 0;
1947 }
1948 else
1951 }
1952 else /* declared as a pointer */
1953 {
1956 if (size > *align) *align = size;
1957 }
1958 break;
1959 case TYPE_ALIAS:
1960 case TYPE_VOID:
1961 case TYPE_COCLASS:
1962 case TYPE_MODULE:
1963 case TYPE_FUNCTION:
1964 case TYPE_BITFIELD:
1965 /* these types should not be encountered here due to language
1966 * restrictions (interface, void, coclass, module), logical
1967 * restrictions (alias - due to type_get_type call above) or
1968 * checking restrictions (function, bitfield). */
1969 assert(0);
1970 }
1971
1972 return size;
1973}
static unsigned int union_memsize(const var_list_t *fields, unsigned int *pmaxa)
Definition: typegen.c:1846

Referenced by add_typedef_typeinfo(), add_var_desc(), field_memsize(), fields_memsize(), get_padding(), type_memsize(), type_memsize_and_alignment(), union_memsize(), write_fixed_array_pointer_descriptions(), write_func_param_struct(), write_no_repeat_pointer_descriptions(), write_pointer_description_offsets(), write_struct_members(), write_union_tfs(), and write_varying_array_pointer_descriptions().

◆ typegen_detect_type()

enum typegen_type typegen_detect_type ( const type_t type,
const attr_list_t attrs,
unsigned int  flags 
)

Definition at line 329 of file typegen.c.

330{
331 if (is_user_type(type))
332 return TGT_USER_TYPE;
333
335 return TGT_CTXT_HANDLE;
336
337 if (!(flags & TDT_IGNORE_STRINGS) && is_string_type(attrs, type))
338 return TGT_STRING;
339
340 switch (type_get_type(type))
341 {
342 case TYPE_BASIC:
343 if (!(flags & TDT_IGNORE_RANGES) &&
345 return TGT_RANGE;
346 return TGT_BASIC;
347 case TYPE_ENUM:
348 if (!(flags & TDT_IGNORE_RANGES) &&
350 return TGT_RANGE;
351 return TGT_ENUM;
352 case TYPE_POINTER:
355 return TGT_IFACE_POINTER;
358 else
359 return TGT_POINTER;
360 case TYPE_STRUCT:
361 return TGT_STRUCT;
363 case TYPE_UNION:
364 return TGT_UNION;
365 case TYPE_ARRAY:
366 return TGT_ARRAY;
367 case TYPE_FUNCTION:
368 case TYPE_COCLASS:
369 case TYPE_INTERFACE:
370 case TYPE_MODULE:
371 case TYPE_VOID:
372 case TYPE_ALIAS:
373 case TYPE_BITFIELD:
374 break;
375 }
376 return TGT_INVALID;
377}
@ ATTR_RANGE
Definition: widltypes.h:149
@ ATTR_IIDIS
Definition: widltypes.h:115

Referenced by assign_stub_out_args(), cant_be_null(), free_variable(), get_array_fc(), get_parameter_fc(), get_required_buffer_size_type(), get_stack_size(), get_struct_fc(), is_embedded_complex(), type_has_full_pointer(), type_has_pointers(), write_nonsimple_pointer(), write_parameter_conf_or_var_exprs(), write_pointer_tfs(), write_remoting_arg(), write_struct_tfs(), and write_type_tfs().

◆ union_memsize()

static unsigned int union_memsize ( const var_list_t fields,
unsigned int pmaxa 
)
static

Definition at line 1846 of file typegen.c.

1847{
1848 unsigned int size, maxs = 0;
1849 unsigned int align = *pmaxa;
1850 const var_t *v;
1851
1852 if (fields) LIST_FOR_EACH_ENTRY( v, fields, const var_t, entry )
1853 {
1854 /* we could have an empty default field with NULL type */
1855 if (v->type)
1856 {
1858 if (maxs < size) maxs = size;
1859 if (*pmaxa < align) *pmaxa = align;
1860 }
1861 }
1862
1863 return maxs;
1864}

Referenced by type_memsize_and_alignment(), and write_union_tfs().

◆ update_tfsoff()

static void update_tfsoff ( type_t type,
unsigned int  offset,
FILE file 
)
static

◆ user_type_has_variable_size()

static int user_type_has_variable_size ( const type_t t)
static

Definition at line 2259 of file typegen.c.

2260{
2261 if (is_ptr(t))
2262 return TRUE;
2263 else if (type_get_type(t) == TYPE_STRUCT)
2264 {
2265 switch (get_struct_fc(t))
2266 {
2267 case FC_PSTRUCT:
2268 case FC_CSTRUCT:
2269 case FC_CPSTRUCT:
2270 case FC_CVSTRUCT:
2271 return TRUE;
2272 }
2273 }
2274 /* Note: Since this only applies to user types, we can't have a conformant
2275 array here, and strings should get filed under pointer in this case. */
2276 return FALSE;
2277}

Referenced by write_user_tfs().

◆ user_type_offset()

static unsigned short user_type_offset ( const char name)
static

Definition at line 804 of file typegen.c.

805{
806 user_type_t *ut;
807 unsigned short off = 0;
809 {
810 if (strcmp(name, ut->name) == 0)
811 return off;
812 ++off;
813 }
814 error("user_type_offset: couldn't find type (%s)\n", name);
815 return 0;
816}
user_type_list_t user_type_list
Definition: header.c:42
const char * name
Definition: widltypes.h:523

Referenced by write_user_tfs().

◆ write_array_element_type()

static void write_array_element_type ( FILE file,
const attr_list_t attrs,
const type_t type,
int  cont_is_complex,
unsigned int tfsoff 
)
static

Definition at line 2382 of file typegen.c.

2384{
2386
2388 {
2390
2391 if (processed(ref))
2392 {
2394 ref->typestring_offset, tfsoff);
2395 return;
2396 }
2397 if (cont_is_complex && is_string_type(attrs, elem))
2398 {
2400 return;
2401 }
2402 if (!is_string_type(NULL, elem) &&
2404 {
2406 return;
2407 }
2408 }
2409 write_member_type(file, type, cont_is_complex, NULL, elem, NULL, tfsoff);
2410}
static size_t elem
Definition: string.c:68
static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs, const type_t *type, enum type_context context)
Definition: typegen.c:2179
static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs, const type_t *type, enum type_context context, unsigned int offset, unsigned int *typeformat_offset)
Definition: typegen.c:2101
static int is_embedded_complex(const type_t *type)
Definition: typegen.c:835
static int processed(const type_t *type)
Definition: typegen.c:2254
static void write_member_type(FILE *file, const type_t *cont, int cont_is_complex, const attr_list_t *attrs, const type_t *type, unsigned int *corroff, unsigned int *tfsoff)
Definition: typegen.c:2342
static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs, type_t *type, enum type_context context, const char *name, unsigned int *typestring_offset)
Definition: typegen.c:2840

Referenced by write_array_tfs().

◆ write_array_tfs()

static unsigned int write_array_tfs ( FILE file,
const attr_list_t attrs,
type_t type,
const char name,
unsigned int typestring_offset 
)
static

Definition at line 2950 of file typegen.c.

2952{
2953 const expr_t *length_is = type_array_get_variance(type);
2954 const expr_t *size_is = type_array_get_conformance(type);
2955 unsigned int align;
2956 unsigned int size;
2957 unsigned int start_offset;
2958 unsigned char fc;
2959 int pointer_type = get_attrv(attrs, ATTR_POINTERTYPE);
2960 unsigned int baseoff
2963 : 0;
2964
2965 if (!pointer_type)
2966 pointer_type = FC_RP;
2967
2969 write_embedded_types(file, attrs, type_array_get_element(type), name, FALSE, typestring_offset);
2970
2973 fc = get_array_fc(type);
2974
2975 start_offset = *typestring_offset;
2976 update_tfsoff(type, start_offset, file);
2977 print_start_tfs_comment(file, type, start_offset);
2978 print_file(file, 2, "0x%02x,\t/* %s */\n", fc, string_of_type(fc));
2979 print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1);
2980 *typestring_offset += 2;
2981
2982 align = 0;
2983 if (fc != FC_BOGUS_ARRAY)
2984 {
2985 if (fc == FC_LGFARRAY || fc == FC_LGVARRAY)
2986 {
2987 print_file(file, 2, "NdrFcLong(0x%x),\t/* %u */\n", size, size);
2988 *typestring_offset += 4;
2989 }
2990 else
2991 {
2992 print_file(file, 2, "NdrFcShort(0x%hx),\t/* %u */\n", (unsigned short)size, size);
2993 *typestring_offset += 2;
2994 }
2995
2997 *typestring_offset
2999 type, size_is);
3000
3001 if (fc == FC_SMVARRAY || fc == FC_LGVARRAY)
3002 {
3003 unsigned int elsize = type_memsize(type_array_get_element(type));
3004 unsigned int dim = type_array_get_dim(type);
3005
3006 if (fc == FC_LGVARRAY)
3007 {
3008 print_file(file, 2, "NdrFcLong(0x%x),\t/* %u */\n", dim, dim);
3009 *typestring_offset += 4;
3010 }
3011 else
3012 {
3013 print_file(file, 2, "NdrFcShort(0x%hx),\t/* %u */\n", (unsigned short)dim, dim);
3014 *typestring_offset += 2;
3015 }
3016
3017 print_file(file, 2, "NdrFcShort(0x%hx),\t/* %u */\n", (unsigned short)elsize, elsize);
3018 *typestring_offset += 2;
3019 }
3020
3021 if (length_is)
3022 *typestring_offset
3024 type, length_is);
3025
3028 {
3029 print_file(file, 2, "0x%x,\t/* FC_PP */\n", FC_PP);
3030 print_file(file, 2, "0x%x,\t/* FC_PAD */\n", FC_PAD);
3031 *typestring_offset += 2;
3032 write_pointer_description(file, is_string_type(attrs, type) ? attrs : NULL, type, typestring_offset);
3033 print_file(file, 2, "0x%x,\t/* FC_END */\n", FC_END);
3034 *typestring_offset += 1;
3035 }
3036
3037 write_array_element_type(file, is_string_type(attrs, type) ? attrs : NULL, type, FALSE, typestring_offset);
3038 write_end(file, typestring_offset);
3039 }
3040 else
3041 {
3042 unsigned int dim = size_is ? 0 : type_array_get_dim(type);
3043 print_file(file, 2, "NdrFcShort(0x%hx),\t/* %u */\n", (unsigned short)dim, dim);
3044 *typestring_offset += 2;
3045 *typestring_offset
3047 type, size_is);
3048 *typestring_offset
3050 type, length_is);
3051
3052 write_array_element_type(file, is_string_type(attrs, type) ? attrs : NULL, type, TRUE, typestring_offset);
3053 write_end(file, typestring_offset);
3054 }
3055
3056 return start_offset;
3057}
static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *type, const char *name, int write_ptr, unsigned int *tfsoff)
Definition: typegen.c:3694
static void write_pointer_description(FILE *file, const attr_list_t *attrs, type_t *type, unsigned int *typestring_offset)
Definition: typegen.c:2794
static unsigned int write_conf_or_var_desc(FILE *file, const type_t *cont_type, unsigned int baseoff, const type_t *type, const expr_t *expr)
Definition: typegen.c:1571
static void write_array_element_type(FILE *file, const attr_list_t *attrs, const type_t *type, int cont_is_complex, unsigned int *tfsoff)
Definition: typegen.c:2382
static void write_end(FILE *file, unsigned int *tfsoff)
Definition: typegen.c:2412
static void print_start_tfs_comment(FILE *file, type_t *t, unsigned int tfsoff)
Definition: typegen.c:2221
static const type_t * current_structure
Definition: typegen.c:49
static void update_tfsoff(type_t *type, unsigned int offset, FILE *file)
Definition: typegen.c:818
static expr_t * type_array_get_variance(const type_t *type)
Definition: typetree.h:246

Referenced by write_string_tfs(), write_struct_tfs(), and write_type_tfs().

◆ write_base_type()

static int write_base_type ( FILE file,
const type_t type,
unsigned int typestring_offset 
)
static

Definition at line 1554 of file typegen.c.

1555{
1556 unsigned char fc;
1557
1560 else if (type_get_type(type) == TYPE_ENUM)
1561 fc = get_enum_fc(type);
1562 else
1563 return 0;
1564
1565 print_file(file, 2, "0x%02x,\t/* %s */\n", fc, string_of_type(fc));
1566 *typestring_offset += 1;
1567 return 1;
1568}

Referenced by write_member_type().

◆ write_branch_type()

static void write_branch_type ( FILE file,
const type_t t,
unsigned int tfsoff 
)
static

Definition at line 3272 of file typegen.c.

3273{
3274 if (t == NULL)
3275 {
3276 print_file(file, 2, "NdrFcShort(0x0),\t/* No type */\n");
3277 }
3278 else
3279 {
3281 {
3282 unsigned char fc;
3283 if (type_get_type(t) == TYPE_BASIC)
3284 fc = get_basic_fc(t);
3285 else
3286 fc = get_enum_fc(t);
3287 print_file(file, 2, "NdrFcShort(0x80%02x),\t/* Simple arm type: %s */\n",
3288 fc, string_of_type(fc));
3289 }
3290 else if (t->typestring_offset)
3291 {
3292 short reloff = t->typestring_offset - *tfsoff;
3293 print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %d (%d) */\n",
3294 reloff, reloff, t->typestring_offset);
3295 }
3296 else
3297 error("write_branch_type: type unimplemented %d\n", type_get_type(t));
3298 }
3299
3300 *tfsoff += 2;
3301}

Referenced by write_union_tfs().

◆ write_client_call_routine()

void write_client_call_routine ( FILE file,
const type_t iface,
const var_t func,
const char prefix,
unsigned int  proc_offset 
)

Definition at line 4974 of file typegen.c.

4976{
4977 type_t *rettype = type_function_get_rettype( func->type );
4978 int has_ret = !is_void( rettype );
4979 const var_list_t *args = type_get_function_args( func->type );
4980 const var_t *arg;
4981 int len, needs_params = 0;
4982
4983 /* we need a param structure if we have more than one arg */
4984 if (pointer_size == 4 && args) needs_params = is_object( iface ) || list_count( args ) > 1;
4985
4986 print_file( file, 0, "{\n");
4987 if (needs_params)
4988 {
4989 if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n" );
4990 write_func_param_struct( file, iface, func->type, "__params", FALSE );
4991 if (is_object( iface )) print_file( file, 1, "__params.This = This;\n" );
4992 if (args)
4994 print_file( file, 1, "__params.%s = %s;\n", arg->name, arg->name );
4995 }
4996 else if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" );
4997
4998 len = fprintf( file, " %s%s( ",
4999 has_ret ? "_RetVal = " : "",
5000 get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall" );
5001 fprintf( file, "&%s_StubDesc,", prefix );
5002 fprintf( file, "\n%*s&__MIDL_ProcFormatString.Format[%u]", len, "", proc_offset );
5003 if (needs_params)
5004 {
5005 fprintf( file, ",\n%*s&__params", len, "" );
5006 }
5007 else if (pointer_size == 8)
5008 {
5009 if (is_object( iface )) fprintf( file, ",\n%*sThis", len, "" );
5010 if (args)
5012 fprintf( file, ",\n%*s%s", len, "", arg->name );
5013 }
5014 else
5015 {
5016 if (is_object( iface )) fprintf( file, ",\n%*s&This", len, "" );
5017 else if (args)
5018 {
5019 arg = LIST_ENTRY( list_head(args), const var_t, entry );
5020 fprintf( file, ",\n%*s&%s", len, "", arg->name );
5021 }
5022 }
5023 fprintf( file, " );\n" );
5024 if (has_ret)
5025 {
5026 print_file( file, 1, "return (" );
5027 write_type_decl_left(file, rettype);
5028 fprintf( file, ")%s;\n", pointer_size == 8 ? "_RetVal.Simple" : "*(LONG_PTR *)&_RetVal" );
5029 }
5030 print_file( file, 0, "}\n\n");
5031}
GLenum GLsizei len
Definition: glext.h:6722
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
Definition: list.h:15
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:4789
void * arg
Definition: msvc.h:10

Referenced by gen_proxy(), and write_function_stub().

◆ write_conf_or_var_desc()

static unsigned int write_conf_or_var_desc ( FILE file,
const type_t cont_type,
unsigned int  baseoff,
const type_t type,
const expr_t expr 
)
static

Definition at line 1571 of file typegen.c.

1574{
1575 unsigned char operator_type = 0;
1576 unsigned char conftype = FC_NORMAL_CONFORMANCE;
1577 const char *conftype_string = "field";
1578 const expr_t *subexpr;
1579 const type_t *iface = NULL;
1580 const char *name;
1581
1582 if (!expr)
1583 {
1584 print_file(file, 2, "NdrFcLong(0xffffffff),\t/* -1 */\n");
1585 return 4;
1586 }
1587
1588 if (expr->is_const)
1589 {
1590 if (expr->cval > UCHAR_MAX * (USHRT_MAX + 1) + USHRT_MAX)
1591 error("write_conf_or_var_desc: constant value %d is greater than "
1592 "the maximum constant size of %d\n", expr->cval,
1593 UCHAR_MAX * (USHRT_MAX + 1) + USHRT_MAX);
1594
1595 print_file(file, 2, "0x%x, /* Corr desc: constant, val = %d */\n",
1597 print_file(file, 2, "0x%x,\n", expr->cval >> 16);
1598 print_file(file, 2, "NdrFcShort(0x%hx),\n", (unsigned short)expr->cval);
1599
1600 return 4;
1601 }
1602
1603 if (!cont_type) /* top-level conformance */
1604 {
1605 conftype = FC_TOP_LEVEL_CONFORMANCE;
1606 conftype_string = "parameter";
1607 cont_type = current_func->type;
1609 iface = current_iface;
1610 }
1611 else
1612 {
1613 name = cont_type->name;
1615 {
1616 conftype = FC_POINTER_CONFORMANCE;
1617 conftype_string = "field pointer";
1618 }
1619 }
1620
1621 subexpr = expr;
1622 switch (subexpr->type)
1623 {
1624 case EXPR_PPTR:
1625 subexpr = subexpr->ref;
1626 operator_type = FC_DEREFERENCE;
1627 break;
1628 case EXPR_DIV:
1629 if (subexpr->u.ext->is_const && (subexpr->u.ext->cval == 2))
1630 {
1631 subexpr = subexpr->ref;
1632 operator_type = FC_DIV_2;
1633 }
1634 break;
1635 case EXPR_MUL:
1636 if (subexpr->u.ext->is_const && (subexpr->u.ext->cval == 2))
1637 {
1638 subexpr = subexpr->ref;
1639 operator_type = FC_MULT_2;
1640 }
1641 break;
1642 case EXPR_SUB:
1643 if (subexpr->u.ext->is_const && (subexpr->u.ext->cval == 1))
1644 {
1645 subexpr = subexpr->ref;
1646 operator_type = FC_SUB_1;
1647 }
1648 break;
1649 case EXPR_ADD:
1650 if (subexpr->u.ext->is_const && (subexpr->u.ext->cval == 1))
1651 {
1652 subexpr = subexpr->ref;
1653 operator_type = FC_ADD_1;
1654 }
1655 break;
1656 default:
1657 break;
1658 }
1659
1660 if (subexpr->type == EXPR_IDENTIFIER)
1661 {
1662 const type_t *correlation_variable = NULL;
1663 unsigned char param_type = 0;
1664 unsigned int offset = 0;
1665 const var_t *var;
1666 struct expr_loc expr_loc;
1667
1668 if (type_get_type(cont_type) == TYPE_FUNCTION)
1669 {
1670 var_list_t *args = type_get_function_args( cont_type );
1671
1672 if (is_object( iface )) offset += pointer_size;
1673 if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
1674 {
1675 if (var->name && !strcmp(var->name, subexpr->u.sval))
1676 {
1677 expr_loc.v = var;
1678 correlation_variable = var->type;
1679 break;
1680 }
1682 }
1683 }
1684 else
1685 {
1687
1689 {
1690 unsigned int size = field_memsize( var->type, &offset );
1691 if (var->name && !strcmp(var->name, subexpr->u.sval))
1692 {
1693 expr_loc.v = var;
1694 correlation_variable = var->type;
1695 break;
1696 }
1697 offset += size;
1698 }
1699 }
1700
1701 if (!correlation_variable)
1702 error("write_conf_or_var_desc: couldn't find variable %s in %s\n", subexpr->u.sval, name);
1703 expr_loc.attr = NULL;
1704 correlation_variable = expr_resolve_type(&expr_loc, cont_type, expr);
1705
1706 offset -= baseoff;
1707
1708 if (type_get_type(correlation_variable) == TYPE_BASIC)
1709 {
1710 switch (get_basic_fc(correlation_variable))
1711 {
1712 case FC_CHAR:
1713 case FC_SMALL:
1714 param_type = FC_SMALL;
1715 break;
1716 case FC_BYTE:
1717 case FC_USMALL:
1718 param_type = FC_USMALL;
1719 break;
1720 case FC_WCHAR:
1721 case FC_SHORT:
1722 param_type = FC_SHORT;
1723 break;
1724 case FC_USHORT:
1725 param_type = FC_USHORT;
1726 break;
1727 case FC_LONG:
1728 param_type = FC_LONG;
1729 break;
1730 case FC_ULONG:
1731 param_type = FC_ULONG;
1732 break;
1733 default:
1734 error("write_conf_or_var_desc: conformance variable type not supported 0x%x\n",
1735 get_basic_fc(correlation_variable));
1736 }
1737 }
1738 else if (type_get_type(correlation_variable) == TYPE_ENUM)
1739 {
1740 if (get_enum_fc(correlation_variable) == FC_ENUM32)
1741 param_type = FC_LONG;
1742 else
1743 param_type = FC_SHORT;
1744 }
1745 else if (type_get_type(correlation_variable) == TYPE_POINTER)
1746 {
1747 if (pointer_size == 8)
1748 param_type = FC_HYPER;
1749 else
1750 param_type = FC_LONG;
1751 }
1752 else
1753 {
1754 error("write_conf_or_var_desc: non-arithmetic type used as correlation variable %s\n",
1755 subexpr->u.sval);
1756 return 0;
1757 }
1758
1759 print_file(file, 2, "0x%x,\t/* Corr desc: %s %s, %s */\n",
1760 conftype | param_type, conftype_string, subexpr->u.sval, string_of_type(param_type));
1761 print_file(file, 2, "0x%x,\t/* %s */\n", operator_type,
1762 operator_type ? string_of_type(operator_type) : "no operators");
1763 print_file(file, 2, "NdrFcShort(0x%hx),\t/* offset = %d */\n",
1764 (unsigned short)offset, offset);
1765 }
1766 else if (!iface || is_interpreted_func( iface, current_func ))
1767 {
1768 unsigned int callback_offset = 0;
1769 struct expr_eval_routine *eval;
1770 int found = 0;
1771
1773 {
1774 if (eval->cont_type == cont_type ||
1776 eval->iface == iface &&
1777 eval->name && name && !strcmp(eval->name, name) &&
1778 !compare_expr(eval->expr, expr)))
1779 {
1780 found = 1;
1781 break;
1782 }
1783 callback_offset++;
1784 }
1785
1786 if (!found)
1787 {
1788 eval = xmalloc (sizeof(*eval));
1789 eval->iface = iface;
1790 eval->cont_type = cont_type;
1791 eval->name = xstrdup( name );
1792 eval->baseoff = baseoff;
1793 eval->expr = expr;
1795 }
1796
1797 if (callback_offset > USHRT_MAX)
1798 error("Maximum number of callback routines reached\n");
1799
1800 print_file(file, 2, "0x%x,\t/* Corr desc: %s in %s */\n", conftype, conftype_string, name);
1801 print_file(file, 2, "0x%x,\t/* %s */\n", FC_CALLBACK, "FC_CALLBACK");
1802 print_file(file, 2, "NdrFcShort(0x%hx),\t/* %u */\n", (unsigned short)callback_offset, callback_offset);
1803 }
1804 else /* output a dummy corr desc that isn't used */
1805 {
1806 print_file(file, 2, "0x%x,\t/* Corr desc: unused for %s */\n", conftype, name);
1807 print_file(file, 2, "0x0,\n" );
1808 print_file(file, 2, "NdrFcShort(0x0),\n" );
1809 }
1810 return 4;
1811}
char * xstrdup(const char *s)
Definition: uimain.c:768
void * xmalloc(int size)
Definition: