ReactOS  0.4.14-dev-1332-g6db3d88
typegen.h File Reference
#include <stdarg.h>
Include dependency graph for typegen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef int(* type_pred_t) (const type_t *)
 

Enumerations

enum  pass { PASS_IN, PASS_OUT, PASS_RETURN }
 
enum  remoting_phase { PHASE_BUFFERSIZE, PHASE_MARSHAL, PHASE_UNMARSHAL, PHASE_FREE }
 
enum  typegen_detect_flags { TDT_ALL_TYPES = 1 << 0, TDT_IGNORE_STRINGS = 1 << 1, TDT_IGNORE_RANGES = 1 << 2 }
 
enum  typegen_type {
  TGT_INVALID, TGT_USER_TYPE, TGT_CTXT_HANDLE, TGT_CTXT_HANDLE_POINTER,
  TGT_STRING, TGT_POINTER, TGT_ARRAY, TGT_IFACE_POINTER,
  TGT_BASIC, TGT_ENUM, TGT_STRUCT, TGT_UNION,
  TGT_RANGE
}
 

Functions

void write_formatstringsdecl (FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred)
 
void write_procformatstring (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)
 
void write_procformatstring_offsets (FILE *file, const type_t *iface)
 
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)
 
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)
 
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)
 
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 assign_stub_out_args (FILE *file, int indent, const var_t *func, const char *local_var_prefix)
 
void declare_stub_args (FILE *file, int indent, const var_t *func)
 
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)
 
unsigned int type_memsize (const type_t *t)
 
int decl_indirect (const type_t *t)
 
int is_interpreted_func (const type_t *iface, const var_t *func)
 
void write_parameters_init (FILE *file, int indent, const var_t *func, const char *local_var_prefix)
 
void print (FILE *file, int indent, const char *format, va_list ap)
 
expr_tget_size_is_expr (const type_t *t, const char *name)
 
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)
 
unsigned char get_basic_fc (const type_t *type)
 
unsigned char get_pointer_fc (const type_t *type, const attr_list_t *attrs, int toplevel_param)
 
unsigned char get_struct_fc (const type_t *type)
 
enum typegen_type typegen_detect_type (const type_t *type, const attr_list_t *attrs, unsigned int flags)
 
unsigned int type_memsize_and_alignment (const type_t *t, unsigned int *align)
 

Typedef Documentation

◆ type_pred_t

typedef int(* type_pred_t) (const type_t *)

Definition at line 63 of file typegen.h.

Enumeration Type Documentation

◆ pass

Enumerator
PASS_IN 
PASS_OUT 
PASS_RETURN 

Definition at line 24 of file typegen.h.

25 {
26  PASS_IN,
27  PASS_OUT,
29 };

◆ remoting_phase

Enumerator
PHASE_BUFFERSIZE 
PHASE_MARSHAL 
PHASE_UNMARSHAL 
PHASE_FREE 

Definition at line 31 of file typegen.h.

◆ typegen_detect_flags

Enumerator
TDT_ALL_TYPES 
TDT_IGNORE_STRINGS 
TDT_IGNORE_RANGES 

Definition at line 39 of file typegen.h.

40 {
41  TDT_ALL_TYPES = 1 << 0,
42  TDT_IGNORE_STRINGS = 1 << 1,
43  TDT_IGNORE_RANGES = 1 << 2,
44 };

◆ typegen_type

Enumerator
TGT_INVALID 
TGT_USER_TYPE 
TGT_CTXT_HANDLE 
TGT_CTXT_HANDLE_POINTER 
TGT_STRING 
TGT_POINTER 
TGT_ARRAY 
TGT_IFACE_POINTER 
TGT_BASIC 
TGT_ENUM 
TGT_STRUCT 
TGT_UNION 
TGT_RANGE 

Definition at line 46 of file typegen.h.

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 4658 of file typegen.c.

4659 {
4660  int in_attr, out_attr;
4661  int i = 0, sep = 0;
4662  const var_t *var;
4663  type_t *ref;
4664 
4665  if (!type_get_function_args(func->type))
4666  return;
4667 
4669  {
4670  in_attr = is_attr(var->attrs, ATTR_IN);
4671  out_attr = is_attr(var->attrs, ATTR_OUT);
4672  if (!out_attr && !in_attr)
4673  in_attr = 1;
4674 
4675  if (!in_attr)
4676  {
4677  print_file(file, indent, "%s%s", local_var_prefix, var->name);
4678 
4679  switch (typegen_detect_type(var->type, var->attrs, TDT_IGNORE_STRINGS))
4680  {
4682  fprintf(file, " = NdrContextHandleInitialize(\n");
4683  print_file(file, indent + 1, "&__frame->_StubMsg,\n");
4684  print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n",
4685  var->typestring_offset);
4686  break;
4687  case TGT_ARRAY:
4688  if (type_array_has_conformance(var->type))
4689  {
4690  unsigned int size;
4691  type_t *type;
4692 
4693  fprintf(file, " = NdrAllocate(&__frame->_StubMsg, ");
4694  for (type = var->type;
4697  {
4699  TRUE, NULL, NULL, local_var_prefix);
4700  fprintf(file, " * ");
4701  }
4702  size = type_memsize(type);
4703  fprintf(file, "%u);\n", size);
4704 
4705  print_file(file, indent, "memset(%s%s, 0, ", local_var_prefix, var->name);
4706  for (type = var->type;
4709  {
4711  TRUE, NULL, NULL, local_var_prefix);
4712  fprintf(file, " * ");
4713  }
4714  size = type_memsize(type);
4715  fprintf(file, "%u);\n", size);
4716  }
4717  else
4718  fprintf(file, " = &%s_W%u;\n", local_var_prefix, i++);
4719  break;
4720  case TGT_POINTER:
4721  fprintf(file, " = &%s_W%u;\n", local_var_prefix, i);
4722  ref = type_pointer_get_ref(var->type);
4723  switch (typegen_detect_type(ref, var->attrs, TDT_IGNORE_STRINGS))
4724  {
4725  case TGT_BASIC:
4726  case TGT_ENUM:
4727  case TGT_POINTER:
4728  case TGT_RANGE:
4729  case TGT_IFACE_POINTER:
4730  print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4731  break;
4732  case TGT_USER_TYPE:
4733  print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4734  local_var_prefix, i, local_var_prefix, i);
4735  break;
4736  case TGT_ARRAY:
4738  {
4739  print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4740  break;
4741  }
4743  /* fall through */
4744  case TGT_STRUCT:
4745  case TGT_UNION:
4746  if (type_has_pointers(ref))
4747  print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4748  local_var_prefix, i, local_var_prefix, i);
4749  break;
4750  case TGT_CTXT_HANDLE:
4752  case TGT_INVALID:
4753  case TGT_STRING:
4754  /* not initialised */
4755  break;
4756  }
4757  i++;
4758  break;
4759  default:
4760  break;
4761  }
4762 
4763  sep = 1;
4764  }
4765  }
4766  if (sep)
4767  fprintf(file, "\n");
4768 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
const char * var
Definition: shader.c:5666
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
#define TRUE
Definition: types.h:120
static const WCHAR indent[]
Definition: object.c:1156
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static int type_has_pointers(const type_t *type)
Definition: typegen.c:703
Definition: send.c:47
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
GLenum GLint ref
Definition: glext.h:6028
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
smooth NULL
Definition: ftsmooth.c:416
static int is_array(const type_t *t)
Definition: header.h:64
GLsizeiptr size
Definition: glext.h:5919
uint32_t entry
Definition: isohybrid.c:63
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
unsigned int type_memsize(const type_t *t)
Definition: typegen.c:1964
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
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99
Definition: fci.c:126

Referenced by gen_stub(), and write_function_stub().

◆ 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 &&
953  type_get_type(t) != TYPE_ENUM &&
956 }
static int is_user_type(const type_t *t)
Definition: typegen.c:324
#define TRUE
Definition: types.h:120
GLdouble GLdouble t
Definition: gl.h:2047
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68

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 4597 of file typegen.c.

4598 {
4599  int in_attr, out_attr;
4600  int i = 0;
4601  const var_t *var = type_function_get_retval(func->type);
4602 
4603  /* declare return value */
4604  if (!is_void(var->type))
4605  {
4606  print_file(file, indent, "%s", "");
4607  write_type_decl(file, var->type, var->name);
4608  fprintf(file, ";\n");
4609  }
4610 
4611  if (!type_get_function_args(func->type))
4612  return;
4613 
4615  {
4616  in_attr = is_attr(var->attrs, ATTR_IN);
4617  out_attr = is_attr(var->attrs, ATTR_OUT);
4618  if (!out_attr && !in_attr)
4619  in_attr = 1;
4620 
4621  if (is_context_handle(var->type))
4622  print_file(file, indent, "NDR_SCONTEXT %s;\n", var->name);
4623  else
4624  {
4625  if (!in_attr && !is_conformant_array(var->type))
4626  {
4627  type_t *type_to_print;
4628  char name[16];
4629  print_file(file, indent, "%s", "");
4630  if (type_get_type(var->type) == TYPE_ARRAY &&
4632  type_to_print = var->type;
4633  else
4634  type_to_print = type_pointer_get_ref(var->type);
4635  sprintf(name, "_W%u", i++);
4636  write_type_decl(file, type_to_print, name);
4637  fprintf(file, ";\n");
4638  }
4639 
4640  print_file(file, indent, "%s", "");
4641  write_type_decl_left(file, var->type);
4642  fprintf(file, " ");
4643  if (type_get_type(var->type) == TYPE_ARRAY &&
4644  !type_array_is_decl_as_ptr(var->type)) {
4645  fprintf(file, "(*%s)", var->name);
4646  } else
4647  fprintf(file, "%s", var->name);
4648  write_type_right(file, var->type, FALSE);
4649  fprintf(file, ";\n");
4650 
4651  if (decl_indirect(var->type))
4652  print_file(file, indent, "void *_p_%s;\n", var->name);
4653  }
4654  }
4655 }
const char * var
Definition: shader.c:5666
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
static const WCHAR indent[]
Definition: object.c:1156
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
static int is_conformant_array(const type_t *t)
Definition: header.h:79
void write_type_decl(FILE *f, type_t *t, const char *name)
Definition: header.c:561
int decl_indirect(const type_t *t)
Definition: typegen.c:948
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
void write_type_decl_left(FILE *f, type_t *t)
Definition: header.c:566
void write_type_right(FILE *h, type_t *t, int is_field)
Definition: header.c:437
uint32_t entry
Definition: isohybrid.c:63
static int is_context_handle(const type_t *type)
Definition: header.h:100
Definition: name.c:38
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260
static int is_void(const type_t *t)
Definition: header.h:69
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99
Definition: fci.c:126

Referenced by gen_stub(), and write_function_stub().

◆ 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 }
static size_t double int int int * sign
Definition: printf.c:69
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
static int type_basic_get_sign(const type_t *type)
Definition: typetree.h:80

Referenced by declare_var(), 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_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 }
static unsigned char type_array_get_ptr_default_fc(const type_t *type)
Definition: typetree.h:267
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
GLdouble GLdouble t
Definition: gl.h:2047
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
static int is_ptr(const type_t *t)
Definition: header.h:59
static int type_is_alias(const type_t *type)
Definition: typetree.h:274
static int is_array(const type_t *t)
Definition: header.h:64
static type_t * type_alias_get_aliasee(const type_t *type)
Definition: typetree.h:279

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

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

Definition at line 4092 of file typegen.c.

4093 {
4094  expr_t *x = NULL;
4095 
4096  for ( ; is_array(t); t = type_array_get_element(t))
4099  {
4100  if (!x)
4102  else
4103  error("%s: multidimensional conformant"
4104  " arrays not supported at the top level\n",
4105  name);
4106  }
4107 
4108  return x;
4109 }
#define error(str)
Definition: mkdosfs.c:1605
enum expr_type type
Definition: widltypes.h:307
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
GLdouble GLdouble t
Definition: gl.h:2047
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
smooth NULL
Definition: ftsmooth.c:416
static int is_array(const type_t *t)
Definition: header.h:64
Definition: name.c:38
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

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 4584 of file typegen.c.

4585 {
4586  unsigned int size = 1;
4588  return size;
4589 }
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
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:1469
static void get_size_procformatstring_iface(type_t *iface, FILE *file, int indent, unsigned int *size)
Definition: typegen.c:4573

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 4566 of file typegen.c.

4567 {
4568  unsigned int offset = 0;
4570  return offset;
4571 }
GLenum func
Definition: glext.h:6028
GLintptr offset
Definition: glext.h:5920
smooth NULL
Definition: ftsmooth.c:416
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:1423
const type_t * iface
Definition: typegen.c:57

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

◆ get_size_typeformatstring()

unsigned int get_size_typeformatstring ( const statement_list_t stmts,
type_pred_t  pred 
)

Definition at line 4591 of file typegen.c.

4592 {
4594  return process_tfs(NULL, stmts, pred);
4595 }
void set_all_tfswrite(int val)
Definition: parser.tab.c:5524
smooth NULL
Definition: ftsmooth.c:416
static unsigned int process_tfs(FILE *file, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:3735

Referenced by write_formatstringsdecl().

◆ 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;
484  var_list_t *fields;
485 
486  fields = type_struct_get_fields(type);
487 
488  if (get_padding(fields))
489  return FC_BOGUS_STRUCT;
490 
491  if (fields) LIST_FOR_EACH_ENTRY( field, fields, var_t, entry )
492  {
493  type_t *t = field->type;
495 
497 
499  {
500  if (is_string_type(field->attrs, field->type))
501  {
502  if (is_conformant_array(t))
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:
528  case TGT_IFACE_POINTER:
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 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:258
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:87
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
GLdouble GLdouble t
Definition: gl.h:2047
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
static int get_padding(const var_list_t *fields)
Definition: typegen.c:396
typegen_type
Definition: typegen.h:46
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
void error_loc(const char *s,...)
Definition: utils.c:69
static int is_array(const type_t *t)
Definition: header.h:64
static int is_conformant_array(const type_t *t)
Definition: header.h:79
static int is_string_type(const attr_list_t *attrs, const type_t *type)
Definition: header.h:94
Definition: parser.c:43
LPFOR_CONTEXT fc
Definition: for.c:53
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
unsigned char get_struct_fc(const type_t *type)
Definition: typegen.c:478
unsigned int pointer_size
Definition: widl.c:158
static int type_array_has_variance(const type_t *type)
Definition: typetree.h:225
static unsigned char get_enum_fc(const type_t *type)
Definition: typegen.c:296
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
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

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

◆ is_full_pointer_function()

int is_full_pointer_function ( const var_t func)

Definition at line 2064 of file typegen.c.

2065 {
2066  const var_t *var;
2068  return TRUE;
2069  if (!type_get_function_args(func->type))
2070  return FALSE;
2072  if (type_has_full_pointer( var->type, var->attrs, TRUE ))
2073  return TRUE;
2074  return FALSE;
2075 }
const char * var
Definition: shader.c:5666
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
#define TRUE
Definition: types.h:120
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
attr_list_t * attrs
Definition: widltypes.h:421
uint32_t entry
Definition: isohybrid.c:63
static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:750
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:108

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  {
1266  LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
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 }
const char * var
Definition: shader.c:5666
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
void * get_attrp(const attr_list_t *list, enum attr_type t)
Definition: header.c:107
enum stub_mode get_stub_mode(void)
Definition: widl.c:211
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
Definition: match.c:390
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
const WCHAR * str
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
attr_list_t * attrs
Definition: widltypes.h:421
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
unsigned int pointer_size
Definition: widl.c:158
Definition: widl.h:87
const type_t * iface
Definition: typegen.c:57
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:108
Definition: widl.h:89

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

◆ print()

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

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 }
static const WCHAR indent[]
Definition: object.c:1156
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Definition: fci.c:126

Referenced by print_file().

◆ print_phase_basetype()

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 
)

Definition at line 3968 of file typegen.c.

3971 {
3972  type_t *type = var->type;
3973  unsigned int alignment = 0;
3974 
3975  /* no work to do for other phases, buffer sizing is done elsewhere */
3976  if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL)
3977  return;
3978 
3979  if (type_get_type(type) == TYPE_ENUM ||
3980  (type_get_type(type) == TYPE_BASIC &&
3982  pointer_size != 4))
3983  {
3984  unsigned char fc;
3985 
3986  if (type_get_type(type) == TYPE_ENUM)
3987  fc = get_enum_fc(type);
3988  else
3989  fc = get_basic_fc(type);
3990 
3991  if (phase == PHASE_MARSHAL)
3992  print_file(file, indent, "NdrSimpleTypeMarshall(\n");
3993  else
3994  print_file(file, indent, "NdrSimpleTypeUnmarshall(\n");
3995  print_file(file, indent+1, "&__frame->_StubMsg,\n");
3996  print_file(file, indent+1, "(unsigned char *)&%s%s,\n",
3997  local_var_prefix,
3998  var->name);
3999  print_file(file, indent+1, "0x%02x /* %s */);\n", fc, string_of_type(fc));
4000  }
4001  else
4002  {
4004  switch (get_basic_fc(ref))
4005  {
4006  case FC_BYTE:
4007  case FC_CHAR:
4008  case FC_SMALL:
4009  case FC_USMALL:
4010  alignment = 1;
4011  break;
4012 
4013  case FC_WCHAR:
4014  case FC_USHORT:
4015  case FC_SHORT:
4016  alignment = 2;
4017  break;
4018 
4019  case FC_ULONG:
4020  case FC_LONG:
4021  case FC_FLOAT:
4022  case FC_ERROR_STATUS_T:
4023  /* pointer_size must be 4 if we got here in these two cases */
4024  case FC_INT3264:
4025  case FC_UINT3264:
4026  alignment = 4;
4027  break;
4028 
4029  case FC_HYPER:
4030  case FC_DOUBLE:
4031  alignment = 8;
4032  break;
4033 
4034  case FC_IGNORE:
4035  case FC_BIND_PRIMITIVE:
4036  /* no marshalling needed */
4037  return;
4038 
4039  default:
4040  error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n",
4041  var->name, get_basic_fc(ref));
4042  }
4043 
4044  if (phase == PHASE_MARSHAL && alignment > 1)
4045  print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1);
4046  print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n",
4047  alignment - 1, alignment - 1);
4048 
4049  if (phase == PHASE_MARSHAL)
4050  {
4051  print_file(file, indent, "*(");
4053  if (is_ptr(type))
4054  fprintf(file, " *)__frame->_StubMsg.Buffer = *");
4055  else
4056  fprintf(file, " *)__frame->_StubMsg.Buffer = ");
4057  fprintf(file, "%s%s", local_var_prefix, varname);
4058  fprintf(file, ";\n");
4059  }
4060  else if (phase == PHASE_UNMARSHAL)
4061  {
4062  print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof(");
4064  fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n");
4065  print_file(file, indent, "{\n");
4066  print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
4067  print_file(file, indent, "}\n");
4068  print_file(file, indent, "%s%s%s",
4069  (pass == PASS_IN || pass == PASS_RETURN) ? "" : "*",
4070  local_var_prefix, varname);
4071  if (pass == PASS_IN && is_ptr(type))
4072  fprintf(file, " = (");
4073  else
4074  fprintf(file, " = *(");
4076  fprintf(file, " *)__frame->_StubMsg.Buffer;\n");
4077  }
4078 
4079  print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof(");
4081  fprintf(file, ");\n");
4082  }
4083 }
const char * var
Definition: shader.c:5666
static const WCHAR indent[]
Definition: object.c:1156
#define error(str)
Definition: mkdosfs.c:1605
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
Definition: send.c:47
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
pass
Definition: typegen.h:24
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static int is_ptr(const type_t *t)
Definition: header.h:59
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
smooth NULL
Definition: ftsmooth.c:416
void write_type_decl(FILE *f, type_t *t, const char *name)
Definition: header.c:561
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
unsigned char get_basic_fc(const type_t *type)
Definition: typegen.c:204
LPFOR_CONTEXT fc
Definition: for.c:53
unsigned int pointer_size
Definition: widl.c:158
static const char * string_of_type(unsigned char type)
Definition: typegen.c:101
static unsigned char get_enum_fc(const type_t *type)
Definition: typegen.c:296
Definition: fci.c:126

Referenced by write_remoting_arg().

◆ type_memsize()

◆ type_memsize_and_alignment()

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

Definition at line 1855 of file typegen.c.

1856 {
1857  unsigned int size = 0;
1858 
1859  switch (type_get_type(t))
1860  {
1861  case TYPE_BASIC:
1862  switch (get_basic_fc(t))
1863  {
1864  case FC_BYTE:
1865  case FC_CHAR:
1866  case FC_USMALL:
1867  case FC_SMALL:
1868  size = 1;
1869  if (size > *align) *align = size;
1870  break;
1871  case FC_WCHAR:
1872  case FC_USHORT:
1873  case FC_SHORT:
1874  size = 2;
1875  if (size > *align) *align = size;
1876  break;
1877  case FC_ULONG:
1878  case FC_LONG:
1879  case FC_ERROR_STATUS_T:
1880  case FC_FLOAT:
1881  size = 4;
1882  if (size > *align) *align = size;
1883  break;
1884  case FC_HYPER:
1885  case FC_DOUBLE:
1886  size = 8;
1887  if (size > *align) *align = size;
1888  break;
1889  case FC_INT3264:
1890  case FC_UINT3264:
1891  case FC_BIND_PRIMITIVE:
1892  assert( pointer_size );
1893  size = pointer_size;
1894  if (size > *align) *align = size;
1895  break;
1896  default:
1897  error("type_memsize: Unknown type 0x%x\n", get_basic_fc(t));
1898  size = 0;
1899  }
1900  break;
1901  case TYPE_ENUM:
1902  switch (get_enum_fc(t))
1903  {
1904  case FC_ENUM16:
1905  case FC_ENUM32:
1906  size = 4;
1907  if (size > *align) *align = size;
1908  break;
1909  default:
1910  error("type_memsize: Unknown enum type\n");
1911  size = 0;
1912  }
1913  break;
1914  case TYPE_STRUCT:
1916  break;
1919  break;
1920  case TYPE_UNION:
1922  break;
1923  case TYPE_POINTER:
1924  case TYPE_INTERFACE:
1925  assert( pointer_size );
1926  size = pointer_size;
1927  if (size > *align) *align = size;
1928  break;
1929  case TYPE_ARRAY:
1931  {
1932  if (is_conformant_array(t))
1933  {
1935  size = 0;
1936  }
1937  else
1940  }
1941  else /* declared as a pointer */
1942  {
1943  assert( pointer_size );
1944  size = pointer_size;
1945  if (size > *align) *align = size;
1946  }
1947  break;
1948  case TYPE_ALIAS:
1949  case TYPE_VOID:
1950  case TYPE_COCLASS:
1951  case TYPE_MODULE:
1952  case TYPE_FUNCTION:
1953  case TYPE_BITFIELD:
1954  /* these types should not be encountered here due to language
1955  * restrictions (interface, void, coclass, module), logical
1956  * restrictions (alias - due to type_get_type call above) or
1957  * checking restrictions (function, bitfield). */
1958  assert(0);
1959  }
1960 
1961  return size;
1962 }
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:232
#define error(str)
Definition: mkdosfs.c:1605
unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
Definition: typegen.c:1855
static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align)
Definition: typegen.c:1812
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:87
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
static unsigned int union_memsize(const var_list_t *fields, unsigned int *pmaxa)
Definition: typegen.c:1835
static var_list_t * type_union_get_cases(const type_t *type)
Definition: typetree.h:134
GLdouble GLdouble t
Definition: gl.h:2047
#define assert(x)
Definition: debug.h:53
int align(int length, int align)
Definition: dsound8.c:36
static var_list_t * type_encapsulated_union_get_fields(const type_t *type)
Definition: typetree.h:127
static int is_conformant_array(const type_t *t)
Definition: header.h:79
GLsizeiptr size
Definition: glext.h:5919
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
unsigned char get_basic_fc(const type_t *type)
Definition: typegen.c:204
unsigned int pointer_size
Definition: widl.c:158
static unsigned char get_enum_fc(const type_t *type)
Definition: typegen.c:296
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260

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 }
static int is_user_type(const type_t *t)
Definition: typegen.c:324
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
int is_aliaschain_attr(const type_t *type, enum attr_type attr)
Definition: header.c:86
static int is_string_type(const attr_list_t *attrs, const type_t *type)
Definition: header.h:94
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
GLbitfield flags
Definition: glext.h:7161
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99

Referenced by assign_stub_out_args(), cant_be_null(), check_field_common(), check_remoting_args(), 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().

◆ 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 4956 of file typegen.c.

4958 {
4959  type_t *rettype = type_function_get_rettype( func->type );
4960  int has_ret = !is_void( rettype );
4961  const var_list_t *args = type_get_function_args( func->type );
4962  const var_t *arg;
4963  int len, needs_params = 0;
4964 
4965  /* we need a param structure if we have more than one arg */
4966  if (pointer_size == 4 && args) needs_params = is_object( iface ) || list_count( args ) > 1;
4967 
4968  print_file( file, 0, "{\n");
4969  if (needs_params)
4970  {
4971  if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n" );
4972  write_func_param_struct( file, iface, func->type, "__params", FALSE );
4973  if (is_object( iface )) print_file( file, 1, "__params.This = This;\n" );
4974  if (args)
4975  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4976  print_file( file, 1, "__params.%s = %s;\n", arg->name, arg->name );
4977  }
4978  else if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" );
4979 
4980  len = fprintf( file, " %s%s( ",
4981  has_ret ? "_RetVal = " : "",
4982  get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall" );
4983  fprintf( file, "&%s_StubDesc,", prefix );
4984  fprintf( file, "\n%*s&__MIDL_ProcFormatString.Format[%u]", len, "", proc_offset );
4985  if (needs_params)
4986  {
4987  fprintf( file, ",\n%*s&__params", len, "" );
4988  }
4989  else if (pointer_size == 8)
4990  {
4991  if (is_object( iface )) fprintf( file, ",\n%*sThis", len, "" );
4992  if (args)
4993  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4994  fprintf( file, ",\n%*s%s", len, "", arg->name );
4995  }
4996  else
4997  {
4998  if (is_object( iface )) fprintf( file, ",\n%*s&This", len, "" );
4999  else if (args)
5000  {
5001  arg = LIST_ENTRY( list_head(args), const var_t, entry );
5002  fprintf( file, ",\n%*s&%s", len, "", arg->name );
5003  }
5004  }
5005  fprintf( file, " );\n" );
5006  if (has_ret)
5007  {
5008  print_file( file, 1, "return (" );
5009  write_type_decl_left(file, rettype);
5010  fprintf( file, ")%s;\n", pointer_size == 8 ? "_RetVal.Simple" : "*(LONG_PTR *)&_RetVal" );
5011  }
5012  print_file( file, 0, "}\n\n");
5013 }
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
enum stub_mode get_stub_mode(void)
Definition: widl.c:211
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:4771
void * arg
Definition: msvc.h:10
Definition: match.c:390
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
void write_type_decl_left(FILE *f, type_t *t)
Definition: header.c:566
uint32_t entry
Definition: isohybrid.c:63
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
unsigned int pointer_size
Definition: widl.c:158
int is_object(const type_t *iface)
Definition: header.c:928
const type_t * iface
Definition: typegen.c:57
static int is_void(const type_t *t)
Definition: header.h:69
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:108
#define LIST_ENTRY(type)
Definition: queue.h:175
Definition: widl.h:89
Definition: fci.c:126

Referenced by gen_proxy(), and write_function_stub().

◆ write_endpoints()

void write_endpoints ( FILE f,
const char prefix,
const str_list_t list 
)

Definition at line 4922 of file typegen.c.

4923 {
4924  const struct str_list_entry_t *endpoint;
4925  const char *p;
4926 
4927  /* this should be an array of RPC_PROTSEQ_ENDPOINT but we want const strings */
4928  print_file( f, 0, "static const unsigned char * const %s__RpcProtseqEndpoint[][2] =\n{\n", prefix );
4930  {
4931  print_file( f, 1, "{ (const unsigned char *)\"" );
4932  for (p = endpoint->str; *p && *p != ':'; p++)
4933  {
4934  if (*p == '"' || *p == '\\') fputc( '\\', f );
4935  fputc( *p, f );
4936  }
4937  if (!*p) goto error;
4938  if (p[1] != '[') goto error;
4939 
4940  fprintf( f, "\", (const unsigned char *)\"" );
4941  for (p += 2; *p && *p != ']'; p++)
4942  {
4943  if (*p == '"' || *p == '\\') fputc( '\\', f );
4944  fputc( *p, f );
4945  }
4946  if (*p != ']') goto error;
4947  fprintf( f, "\" },\n" );
4948  }
4949  print_file( f, 0, "};\n\n" );
4950  return;
4951 
4952 error:
4953  error("Invalid endpoint syntax '%s'\n", endpoint->str);
4954 }
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
#define error(str)
Definition: mkdosfs.c:1605
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
GLfloat f
Definition: glext.h:7540
struct endpoint endpoint
Definition: nis.h:15
Definition: widltypes.h:290
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
Definition: nis.h:10
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by write_clientinterfacedecl(), and write_serverinterfacedecl().

◆ write_exceptions()

void write_exceptions ( FILE file)

Definition at line 5015 of file typegen.c.

5016 {
5017  fprintf( file, "#ifndef USE_COMPILER_EXCEPTIONS\n");
5018  fprintf( file, "\n");
5019  fprintf( file, "#include \"wine/exception.h\"\n");
5020  fprintf( file, "#undef RpcTryExcept\n");
5021  fprintf( file, "#undef RpcExcept\n");
5022  fprintf( file, "#undef RpcEndExcept\n");
5023  fprintf( file, "#undef RpcTryFinally\n");
5024  fprintf( file, "#undef RpcFinally\n");
5025  fprintf( file, "#undef RpcEndFinally\n");
5026  fprintf( file, "#undef RpcExceptionCode\n");
5027  fprintf( file, "#undef RpcAbnormalTermination\n");
5028  fprintf( file, "\n");
5029  fprintf( file, "struct __exception_frame;\n");
5030  fprintf( file, "typedef int (*__filter_func)(struct __exception_frame *);\n");
5031  fprintf( file, "typedef void (*__finally_func)(struct __exception_frame *);\n");
5032  fprintf( file, "\n");
5033  fprintf( file, "#define __DECL_EXCEPTION_FRAME \\\n");
5034  fprintf( file, " EXCEPTION_REGISTRATION_RECORD frame; \\\n");
5035  fprintf( file, " __filter_func filter; \\\n");
5036  fprintf( file, " __finally_func finally; \\\n");
5037  fprintf( file, " sigjmp_buf jmp; \\\n");
5038  fprintf( file, " DWORD code; \\\n");
5039  fprintf( file, " unsigned char abnormal_termination; \\\n");
5040  fprintf( file, " unsigned char filter_level; \\\n");
5041  fprintf( file, " unsigned char finally_level;\n");
5042  fprintf( file, "\n");
5043  fprintf( file, "struct __exception_frame\n{\n");
5044  fprintf( file, " __DECL_EXCEPTION_FRAME\n");
5045  fprintf( file, "};\n");
5046  fprintf( file, "\n");
5047  fprintf( file, "static inline void __widl_unwind_target(void)\n" );
5048  fprintf( file, "{\n");
5049  fprintf( file, " struct __exception_frame *exc_frame = (struct __exception_frame *)__wine_get_frame();\n" );
5050  fprintf( file, " if (exc_frame->finally_level > exc_frame->filter_level)\n" );
5051  fprintf( file, " {\n");
5052  fprintf( file, " exc_frame->abnormal_termination = 1;\n");
5053  fprintf( file, " exc_frame->finally( exc_frame );\n");
5054  fprintf( file, " __wine_pop_frame( &exc_frame->frame );\n");
5055  fprintf( file, " }\n");
5056  fprintf( file, " exc_frame->filter_level = 0;\n");
5057  fprintf( file, " siglongjmp( exc_frame->jmp, 1 );\n");
5058  fprintf( file, "}\n");
5059  fprintf( file, "\n");
5060  fprintf( file, "static DWORD __widl_exception_handler( EXCEPTION_RECORD *record,\n");
5061  fprintf( file, " EXCEPTION_REGISTRATION_RECORD *frame,\n");
5062  fprintf( file, " CONTEXT *context,\n");
5063  fprintf( file, " EXCEPTION_REGISTRATION_RECORD **pdispatcher )\n");
5064  fprintf( file, "{\n");
5065  fprintf( file, " struct __exception_frame *exc_frame = (struct __exception_frame *)frame;\n");
5066  fprintf( file, "\n");
5067  fprintf( file, " if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL))\n");
5068  fprintf( file, " {\n" );
5069  fprintf( file, " if (exc_frame->finally_level && (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))\n");
5070  fprintf( file, " {\n" );
5071  fprintf( file, " exc_frame->abnormal_termination = 1;\n");
5072  fprintf( file, " exc_frame->finally( exc_frame );\n");
5073  fprintf( file, " }\n" );
5074  fprintf( file, " return ExceptionContinueSearch;\n");
5075  fprintf( file, " }\n" );
5076  fprintf( file, " exc_frame->code = record->ExceptionCode;\n");
5077  fprintf( file, " if (exc_frame->filter_level && exc_frame->filter( exc_frame ) == EXCEPTION_EXECUTE_HANDLER)\n" );
5078  fprintf( file, " __wine_rtl_unwind( frame, record, __widl_unwind_target );\n");
5079  fprintf( file, " return ExceptionContinueSearch;\n");
5080  fprintf( file, "}\n");
5081  fprintf( file, "\n");
5082  fprintf( file, "#define RpcTryExcept \\\n");
5083  fprintf( file, " if (!sigsetjmp( __frame->jmp, 0 )) \\\n");
5084  fprintf( file, " { \\\n");
5085  fprintf( file, " if (!__frame->finally_level) \\\n" );
5086  fprintf( file, " __wine_push_frame( &__frame->frame ); \\\n");
5087  fprintf( file, " __frame->filter_level = __frame->finally_level + 1;\n" );
5088  fprintf( file, "\n");
5089  fprintf( file, "#define RpcExcept(expr) \\\n");
5090  fprintf( file, " if (!__frame->finally_level) \\\n" );
5091  fprintf( file, " __wine_pop_frame( &__frame->frame ); \\\n");
5092  fprintf( file, " __frame->filter_level = 0; \\\n" );
5093  fprintf( file, " } \\\n");
5094  fprintf( file, " else \\\n");
5095  fprintf( file, "\n");
5096  fprintf( file, "#define RpcEndExcept\n");
5097  fprintf( file, "\n");
5098  fprintf( file, "#define RpcExceptionCode() (__frame->code)\n");
5099  fprintf( file, "\n");
5100  fprintf( file, "#define RpcTryFinally \\\n");
5101  fprintf( file, " if (!__frame->filter_level) \\\n");
5102  fprintf( file, " __wine_push_frame( &__frame->frame ); \\\n");
5103  fprintf( file, " __frame->finally_level = __frame->filter_level + 1;\n");
5104  fprintf( file, "\n");
5105  fprintf( file, "#define RpcFinally \\\n");
5106  fprintf( file, " if (!__frame->filter_level) \\\n");
5107  fprintf( file, " __wine_pop_frame( &__frame->frame ); \\\n");
5108  fprintf( file, " __frame->finally_level = 0;\n");
5109  fprintf( file, "\n");
5110  fprintf( file, "#define RpcEndFinally\n");
5111  fprintf( file, "\n");
5112  fprintf( file, "#define RpcAbnormalTermination() (__frame->abnormal_termination)\n");
5113  fprintf( file, "\n");
5114  fprintf( file, "#define RpcExceptionInit(filter_func,finally_func) \\\n");
5115  fprintf( file, " do { \\\n");
5116  fprintf( file, " __frame->frame.Handler = __widl_exception_handler; \\\n");
5117  fprintf( file, " __frame->filter = (__filter_func)(filter_func); \\\n" );
5118  fprintf( file, " __frame->finally = (__finally_func)(finally_func); \\\n");
5119  fprintf( file, " __frame->abnormal_termination = 0; \\\n");
5120  fprintf( file, " __frame->filter_level = 0; \\\n");
5121  fprintf( file, " __frame->finally_level = 0; \\\n");
5122  fprintf( file, " } while (0)\n");
5123  fprintf( file, "\n");
5124  fprintf( file, "#else /* USE_COMPILER_EXCEPTIONS */\n");
5125  fprintf( file, "\n");
5126  fprintf( file, "#define RpcExceptionInit(filter_func,finally_func) \\\n");
5127  fprintf( file, " do { (void)(filter_func); } while(0)\n");
5128  fprintf( file, "\n");
5129  fprintf( file, "#define __DECL_EXCEPTION_FRAME \\\n");
5130  fprintf( file, " DWORD code;\n");
5131  fprintf( file, "\n");
5132  fprintf( file, "#endif /* USE_COMPILER_EXCEPTIONS */\n");
5133 }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
Definition: fci.c:126

Referenced by write_client_routines(), write_proxy_routines(), and write_server_routines().

◆ write_expr_eval_routine_list()

void write_expr_eval_routine_list ( FILE file,
const char iface 
)

Definition at line 4878 of file typegen.c.

4879 {
4880  struct expr_eval_routine *eval;
4881  struct expr_eval_routine *cursor;
4882  unsigned short callback_offset = 0;
4883 
4884  fprintf(file, "static const EXPR_EVAL ExprEvalRoutines[] =\n");
4885  fprintf(file, "{\n");
4886 
4888  {
4889  print_file(file, 1, "%s_%sExprEval_%04u,\n",
4890  eval->iface ? eval->iface->name : iface, eval->name, callback_offset);
4891  callback_offset++;
4892  list_remove(&eval->entry);
4893  free(eval->name);
4894  free(eval);
4895  }
4896 
4897  fprintf(file, "};\n\n");
4898 }
static struct list expr_eval_routines
Definition: typegen.c:53
struct list entry
Definition: typegen.c:56
#define free
Definition: debug_ros.c:5
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
const char * name
Definition: widltypes.h:418
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
const char cursor[]
Definition: icontest.c:13
const type_t * iface
Definition: typegen.c:57
Definition: fci.c:126

Referenced by write_client_routines(), write_proxy_routines(), and write_server_routines().

◆ write_expr_eval_routines()

int write_expr_eval_routines ( FILE file,
const char iface 
)

Definition at line 4839 of file typegen.c.

4840 {
4841  static const char *var_name = "pS";
4842  static const char *var_name_expr = "pS->";
4843  int result = 0;
4844  struct expr_eval_routine *eval;
4845  unsigned short callback_offset = 0;
4846 
4848  {
4849  const char *name = eval->name;
4850  result = 1;
4851 
4852  print_file(file, 0, "static void __RPC_USER %s_%sExprEval_%04u(PMIDL_STUB_MESSAGE pStubMsg)\n",
4853  eval->iface ? eval->iface->name : iface, name, callback_offset);
4854  print_file(file, 0, "{\n");
4855  if (type_get_type( eval->cont_type ) == TYPE_FUNCTION)
4856  {
4858  "*pS = (struct _PARAM_STRUCT *)pStubMsg->StackTop", FALSE );
4859  }
4860  else
4861  {
4862  print_file(file, 1, "%s", "");
4864  fprintf(file, " *%s = (", var_name);
4866  fprintf(file, " *)(pStubMsg->StackTop - %u);\n", eval->baseoff);
4867  }
4868  print_file(file, 1, "pStubMsg->Offset = 0;\n"); /* FIXME */
4869  print_file(file, 1, "pStubMsg->MaxCount = (ULONG_PTR)");
4870  write_expr(file, eval->expr, 1, 1, var_name_expr, eval->cont_type, "");
4871  fprintf(file, ";\n");
4872  print_file(file, 0, "}\n\n");
4873  callback_offset++;
4874  }
4875  return result;
4876 }
static struct list expr_eval_routines
Definition: typegen.c:53
const type_t * cont_type
Definition: typegen.c:58
#define TRUE
Definition: types.h:120
unsigned int baseoff
Definition: typegen.c:60
const expr_t * expr
Definition: typegen.c:61
void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly)
Definition: header.c:297
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:4771
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
const char * name
Definition: widltypes.h:418
uint32_t entry
Definition: isohybrid.c:63
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
Definition: name.c:38
const type_t * iface
Definition: typegen.c:57
GLuint64EXT * result
Definition: glext.h:11304
Definition: fci.c:126

Referenced by write_client_routines(), write_proxy_routines(), and write_server_routines().

◆ write_formatstringsdecl()

void write_formatstringsdecl ( FILE f,
int  indent,
const statement_list_t stmts,
type_pred_t  pred 
)

Definition at line 929 of file typegen.c.

930 {
932 
933  print_file(f, indent, "#define TYPE_FORMAT_STRING_SIZE %d\n",
934  get_size_typeformatstring(stmts, pred));
935 
936  print_file(f, indent, "#define PROC_FORMAT_STRING_SIZE %d\n",
937  get_size_procformatstring(stmts, pred));
938 
939  fprintf(f, "\n");
940  write_formatdesc(f, indent, "TYPE");
941  write_formatdesc(f, indent, "PROC");
942  fprintf(f, "\n");
943  print_file(f, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
944  print_file(f, indent, "static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
945  print_file(f, indent, "\n");
946 }
static const WCHAR indent[]
Definition: object.c:1156
void clear_all_offsets(void)
Definition: parser.tab.c:5531
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
unsigned int get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:4591
unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:4584
GLfloat f
Definition: glext.h:7540
static void write_formatdesc(FILE *f, int indent, const char *str)
Definition: typegen.c:919

Referenced by write_client_routines(), write_proxy_routines(), and write_server_routines().

◆ write_full_pointer_free()

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

Definition at line 2084 of file typegen.c.

2085 {
2086  print_file(file, indent, "NdrFullPointerXlatFree(__frame->_StubMsg.FullPtrXlatTables);\n");
2087  fprintf(file, "\n");
2088 }
static const WCHAR indent[]
Definition: object.c:1156
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
Definition: fci.c:126

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

◆ write_full_pointer_init()

void write_full_pointer_init ( FILE file,
int  indent,
const var_t func,
int  is_server 
)

Definition at line 2077 of file typegen.c.

2078 {
2079  print_file(file, indent, "__frame->_StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,%s);\n",
2080  is_server ? "XLAT_SERVER" : "XLAT_CLIENT");
2081  fprintf(file, "\n");
2082 }
static const WCHAR indent[]
Definition: object.c:1156
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
Definition: fci.c:126

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

◆ write_func_param_struct()

void write_func_param_struct ( FILE file,
const type_t iface,
const type_t func,
const char var_decl,
int  add_retval 
)

Definition at line 4771 of file typegen.c.

4773 {
4774  var_t *retval = type_function_get_retval( func );
4776  const var_t *arg;
4777  int needs_packing;
4778  unsigned int align = 0;
4779 
4780  if (args)
4781  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4782  if (!is_array( arg->type )) type_memsize_and_alignment( arg->type, &align );
4783 
4784  needs_packing = (align > pointer_size);
4785 
4786  if (needs_packing) print_file( file, 0, "#include <pshpack%u.h>\n", pointer_size );
4787  print_file(file, 1, "struct _PARAM_STRUCT\n" );
4788  print_file(file, 1, "{\n" );
4789  if (is_object( iface )) print_file(file, 2, "%s *This;\n", iface->name );
4790 
4791  if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4792  {
4793  print_file(file, 2, "%s", "");
4795  if (needs_space_after( arg->type )) fputc( ' ', file );
4796  if (is_array( arg->type ) && !type_array_is_decl_as_ptr( arg->type )) fputc( '*', file );
4797 
4798  /* FIXME: should check for large args being passed by pointer */
4799  align = 0;
4800  if (is_array( arg->type ) || is_ptr( arg->type )) align = pointer_size;
4801  else type_memsize_and_alignment( arg->type, &align );
4802 
4803  if (align >= pointer_size)
4804  fprintf( file, "%s;\n", arg->name );
4805  else
4806 #ifdef __REACTOS__
4807  fprintf( file, "DECLSPEC_ALIGN(%u) %s;\n", pointer_size, arg->name );
4808 #else
4809  fprintf( file, "%s DECLSPEC_ALIGN(%u);\n", arg->name, pointer_size );
4810 #endif
4811  }
4812  if (add_retval && !is_void( retval->type ))
4813  {
4814  print_file(file, 2, "%s", "");
4815  write_type_decl( file, retval->type, retval->name );
4816  if (is_array( retval->type ) || is_ptr( retval->type ) ||
4817  type_memsize( retval->type ) == pointer_size)
4818  fprintf( file, ";\n" );
4819  else
4820  fprintf( file, " DECLSPEC_ALIGN(%u);\n", pointer_size );
4821  }
4822  print_file(file, 1, "} %s;\n", var_decl );
4823  if (needs_packing) print_file( file, 0, "#include <poppack.h>\n" );
4824  print_file( file, 0, "\n" );
4825 }
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
#define TRUE
Definition: types.h:120
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
Definition: typegen.c:1855
void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly)
Definition: header.c:297
void * arg
Definition: msvc.h:10
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101
int align(int length, int align)
Definition: dsound8.c:36
Definition: match.c:390
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static int is_ptr(const type_t *t)
Definition: header.h:59
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
static int is_array(const type_t *t)
Definition: header.h:64
void write_type_decl(FILE *f, type_t *t, const char *name)
Definition: header.c:561
type_t * type
Definition: widltypes.h:452
int needs_space_after(type_t *t)
Definition: header.c:282
const char * name
Definition: widltypes.h:418
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
unsigned int pointer_size
Definition: widl.c:158
unsigned int type_memsize(const type_t *t)
Definition: typegen.c:1964
char * name
Definition: widltypes.h:451
int is_object(const type_t *iface)
Definition: header.c:928
const type_t * iface
Definition: typegen.c:57
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260
static int is_void(const type_t *t)
Definition: header.h:69
Definition: fci.c:126

Referenced by gen_stub_thunk(), write_client_call_routine(), and write_expr_eval_routines().

◆ write_parameter_conf_or_var_exprs()

void write_parameter_conf_or_var_exprs ( FILE file,
int  indent,
const char local_var_prefix,
enum remoting_phase  phase,
const var_t var,
int  valid_variance 
)

Definition at line 4111 of file typegen.c.

4113 {
4114  const type_t *type = var->type;
4115  /* get fundamental type for the argument */
4116  for (;;)
4117  {
4119  {
4120  case TGT_ARRAY:
4122  {
4125  {
4126  print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)");
4127  write_expr(file, type_array_get_conformance(type), 1, 1, NULL, NULL, local_var_prefix);
4128  fprintf(file, ";\n\n");
4129  }
4131  {
4132  print_file(file, indent, "__frame->_StubMsg.Offset = 0;\n"); /* FIXME */
4133  if (valid_variance)
4134  {
4135  print_file(file, indent, "__frame->_StubMsg.ActualCount = (ULONG_PTR)");
4136  write_expr(file, type_array_get_variance(type), 1, 1, NULL, NULL, local_var_prefix);
4137  fprintf(file, ";\n\n");
4138  }
4139  else
4140  print_file(file, indent, "__frame->_StubMsg.ActualCount = __frame->_StubMsg.MaxCount;\n\n");
4141  }
4142  }
4143  break;
4144  case TGT_UNION:
4145  if (type_get_type(type) == TYPE_UNION &&
4147  {
4148  print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)");
4149  write_expr(file, get_attrp(var->attrs, ATTR_SWITCHIS), 1, 1, NULL, NULL, local_var_prefix);
4150  fprintf(file, ";\n\n");
4151  }
4152  break;
4153  case TGT_IFACE_POINTER:
4154  {
4155  expr_t *iid;
4156 
4157  if (is_conformance_needed_for_phase(phase) && (iid = get_attrp( var->attrs, ATTR_IIDIS )))
4158  {
4159  print_file( file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR) " );
4160  write_expr( file, iid, 1, 1, NULL, NULL, local_var_prefix );
4161  fprintf( file, ";\n\n" );
4162  }
4163  break;
4164  }
4165  case TGT_POINTER:
4167  continue;
4168  case TGT_INVALID:
4169  case TGT_USER_TYPE:
4170  case TGT_CTXT_HANDLE:
4172  case TGT_STRING:
4173  case TGT_BASIC:
4174  case TGT_ENUM:
4175  case TGT_STRUCT:
4176  case TGT_RANGE:
4177  break;
4178  }
4179  break;
4180  }
4181 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
const char * var
Definition: shader.c:5666
static const WCHAR indent[]
Definition: object.c:1156
void * get_attrp(const attr_list_t *list, enum attr_type t)
Definition: header.c:107
static int is_conformance_needed_for_phase(enum remoting_phase phase)
Definition: typegen.c:4087
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
smooth NULL
Definition: ftsmooth.c:416
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
static expr_t * type_array_get_variance(const type_t *type)
Definition: typetree.h:246
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
static int type_array_has_variance(const type_t *type)
Definition: typetree.h:225
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
Definition: fci.c:126

Referenced by free_variable(), and write_remoting_arg().

◆ write_parameters_init()

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

Definition at line 903 of file typegen.c.

904 {
905  const var_t *var = type_function_get_retval(func->type);
906 
907  if (!is_void(var->type))
908  write_var_init(file, indent, var->type, var->name, local_var_prefix);
909 
910  if (!type_get_function_args(func->type))
911  return;
912 
914  write_var_init(file, indent, var->type, var->name, local_var_prefix);
915 
916  fprintf(file, "\n");
917 }
const char * var
Definition: shader.c:5666
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
static const WCHAR indent[]
Definition: object.c:1156
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101
static void write_var_init(FILE *file, int indent, const type_t *t, const char *n, const char *local_var_prefix)
Definition: typegen.c:891
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
_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
static int is_void(const type_t *t)
Definition: header.h:69
Definition: fci.c:126

Referenced by gen_stub(), and write_function_stub().

◆ write_pointer_checks()

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

Definition at line 4827 of file typegen.c.

4828 {
4829  const var_list_t *args = type_get_function_args( func->type );
4830  const var_t *var;
4831 
4832  if (!args) return;
4833 
4834  LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
4835  if (cant_be_null( var ))
4836  print_file( file, indent, "if (!%s) RpcRaiseException(RPC_X_NULL_REF_POINTER);\n", var->name );
4837 }
const char * var
Definition: shader.c:5666
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
static const WCHAR indent[]
Definition: object.c:1156
static int cant_be_null(const var_t *v)
Definition: typegen.c:379
Definition: match.c:390
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
Definition: fci.c:126

Referenced by gen_proxy(), and write_function_stub().

◆ write_procformatstring()

void write_procformatstring ( FILE file,
const statement_list_t stmts,
type_pred_t  pred 
)

Definition at line 1502 of file typegen.c.

1503 {
1504  int indent = 0;
1505  unsigned int offset = 0;
1506 
1507  print_file(file, indent, "static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =\n");
1508  print_file(file, indent, "{\n");
1509  indent++;
1510  print_file(file, indent, "0,\n");
1511  print_file(file, indent, "{\n");
1512  indent++;
1513 
1515 
1516  print_file(file, indent, "0x0\n");
1517  indent--;
1518  print_file(file, indent, "}\n");
1519  indent--;
1520  print_file(file, indent, "};\n");
1521  print_file(file, indent, "\n");
1522 }
static const WCHAR indent[]
Definition: object.c:1156
GLintptr offset
Definition: glext.h:5920
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
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:1469
static void write_iface_procformatstring(type_t *iface, FILE *file, int indent, unsigned int *offset)
Definition: typegen.c:1488
Definition: fci.c:126

Referenced by write_client_routines(), write_proxy_routines(), and write_server_routines().

◆ write_procformatstring_offsets()

void write_procformatstring_offsets ( FILE file,
const type_t iface 
)

Definition at line 1524 of file typegen.c.

1525 {
1526  const statement_t *stmt;
1527  int indent = 0;
1528 
1529  print_file( file, indent, "static const unsigned short %s_FormatStringOffsetTable[] =\n",
1530  iface->name );
1531  print_file( file, indent, "{\n" );
1532  indent++;
1534  {
1535  var_t *func = stmt->u.var;
1536  if (is_local( func->attrs )) continue;
1537  print_file( file, indent, "%u, /* %s */\n", func->procstring_offset, func->name );
1538  }
1539  indent--;
1540  print_file( file, indent, "};\n\n" );
1541 }
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:596
GLenum func
Definition: glext.h:6028
static const WCHAR indent[]
Definition: object.c:1156
var_t * var
Definition: widltypes.h:538
int is_local(const attr_list_t *a)
Definition: header.c:938
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
union _statement_t::@4078 u
const char * name
Definition: widltypes.h:418
const type_t * iface
Definition: typegen.c:57
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151
Definition: fci.c:126

Referenced by write_server_stmts().

◆ write_remoting_arguments()

void write_remoting_arguments ( FILE file,
int  indent,
const var_t func,
const char local_var_prefix,
enum pass  pass,
enum remoting_phase  phase 
)

Definition at line 4541 of file typegen.c.

4543 {
4544  if (phase == PHASE_BUFFERSIZE && pass != PASS_RETURN)
4545  {
4546  unsigned int size = get_function_buffer_size( func, pass );
4547  print_file(file, indent, "__frame->_StubMsg.BufferLength = %u;\n", size);
4548  }
4549 
4550  if (pass == PASS_RETURN)
4551  {
4552  write_remoting_arg( file, indent, func, local_var_prefix, pass, phase,
4553  type_function_get_retval(func->type) );
4554  }
4555  else
4556  {
4557  const var_t *var;
4558  if (!type_get_function_args(func->type))
4559  return;
4561  write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, var );
4562  }
4563 }
const char * var
Definition: shader.c:5666
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
static const WCHAR indent[]
Definition: object.c:1156
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)
Definition: typegen.c:4183
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101
pass
Definition: typegen.h:24
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
GLsizeiptr size
Definition: glext.h:5919
static unsigned int get_function_buffer_size(const var_t *func, enum pass pass)
uint32_t entry
Definition: isohybrid.c:63
Definition: fci.c:126

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

◆ write_typeformatstring()

void write_typeformatstring ( FILE file,
const statement_list_t stmts,
type_pred_t  pred 
)

Definition at line 3743 of file typegen.c.

3744 {
3745  int indent = 0;
3746 
3747  print_file(file, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =\n");
3748  print_file(file, indent, "{\n");
3749  indent++;
3750  print_file(file, indent, "0,\n");
3751  print_file(file, indent, "{\n");
3752  indent++;
3753  print_file(file, indent, "NdrFcShort(0x0),\n");
3754 
3756  process_tfs(file, stmts, pred);
3757 
3758  print_file(file, indent, "0x0\n");
3759  indent--;
3760  print_file(file, indent, "}\n");
3761  indent--;
3762  print_file(file, indent, "};\n");
3763  print_file(file, indent, "\n");
3764 }
#define TRUE
Definition: types.h:120
static const WCHAR indent[]
Definition: object.c:1156
void set_all_tfswrite(int val)
Definition: parser.tab.c:5524
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
static unsigned int process_tfs(FILE *file, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:3735
Definition: fci.c:126

Referenced by write_client_routines(), write_proxy_routines(), and write_server_routines().

◆ write_user_quad_list()

void write_user_quad_list ( FILE file)

Definition at line 4900 of file typegen.c.

4901 {
4902  user_type_t *ut;
4903 
4904  if (list_empty(&user_type_list))
4905  return;
4906 
4907  fprintf(file, "static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[] =\n");
4908  fprintf(file, "{\n");
4910  {
4911  const char *sep = &ut->entry == list_tail(&user_type_list) ? "" : ",";
4912  print_file(file, 1, "{\n");
4913  print_file(file, 2, "(USER_MARSHAL_SIZING_ROUTINE)%s_UserSize,\n", ut->name);
4914  print_file(file, 2, "(USER_MARSHAL_MARSHALLING_ROUTINE)%s_UserMarshal,\n", ut->name);
4915  print_file(file, 2, "(USER_MARSHAL_UNMARSHALLING_ROUTINE)%s_UserUnmarshal,\n", ut->name);
4916  print_file(file, 2, "(USER_MARSHAL_FREEING_ROUTINE)%s_UserFree\n", ut->name);
4917  print_file(file, 1, "}%s\n", sep);
4918  }
4919  fprintf(file, "};\n\n");
4920 }
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:137
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
user_type_list_t user_type_list
Definition: header.c:42
uint32_t entry
Definition: isohybrid.c:63
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
const char * name
Definition: widltypes.h:522
struct list entry
Definition: widltypes.h:521
Definition: fci.c:126

Referenced by write_client_routines(), write_proxy_routines(), and write_server_routines().