ReactOS  0.4.15-dev-1632-g4e289ce
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 4665 of file typegen.c.

4666 {
4667  int in_attr, out_attr;
4668  int i = 0, sep = 0;
4669  const var_t *var;
4670  type_t *ref;
4671 
4672  if (!type_get_function_args(func->type))
4673  return;
4674 
4676  {
4677  in_attr = is_attr(var->attrs, ATTR_IN);
4678  out_attr = is_attr(var->attrs, ATTR_OUT);
4679  if (!out_attr && !in_attr)
4680  in_attr = 1;
4681 
4682  if (!in_attr)
4683  {
4684  print_file(file, indent, "%s%s", local_var_prefix, var->name);
4685 
4686  switch (typegen_detect_type(var->type, var->attrs, TDT_IGNORE_STRINGS))
4687  {
4689  fprintf(file, " = NdrContextHandleInitialize(\n");
4690  print_file(file, indent + 1, "&__frame->_StubMsg,\n");
4691  print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n",
4692  var->typestring_offset);
4693  break;
4694  case TGT_ARRAY:
4695  if (type_array_has_conformance(var->type))
4696  {
4697  unsigned int size;
4698  type_t *type;
4699 
4700  fprintf(file, " = NdrAllocate(&__frame->_StubMsg, ");
4701  for (type = var->type;
4704  {
4706  TRUE, NULL, NULL, local_var_prefix);
4707  fprintf(file, " * ");
4708  }
4709  size = type_memsize(type);
4710  fprintf(file, "%u);\n", size);
4711 
4712  print_file(file, indent, "memset(%s%s, 0, ", local_var_prefix, var->name);
4713  for (type = var->type;
4716  {
4718  TRUE, NULL, NULL, local_var_prefix);
4719  fprintf(file, " * ");
4720  }
4721  size = type_memsize(type);
4722  fprintf(file, "%u);\n", size);
4723  }
4724  else
4725  fprintf(file, " = &%s_W%u;\n", local_var_prefix, i++);
4726  break;
4727  case TGT_POINTER:
4728  fprintf(file, " = &%s_W%u;\n", local_var_prefix, i);
4729  ref = type_pointer_get_ref(var->type);
4730  switch (typegen_detect_type(ref, var->attrs, TDT_IGNORE_STRINGS))
4731  {
4732  case TGT_BASIC:
4733  case TGT_ENUM:
4734  case TGT_POINTER:
4735  case TGT_RANGE:
4736  case TGT_IFACE_POINTER:
4737  print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4738  break;
4739  case TGT_USER_TYPE:
4740  print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4741  local_var_prefix, i, local_var_prefix, i);
4742  break;
4743  case TGT_ARRAY:
4745  {
4746  print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4747  break;
4748  }
4750  /* fall through */
4751  case TGT_STRUCT:
4752  case TGT_UNION:
4753  if (type_has_pointers(ref))
4754  print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4755  local_var_prefix, i, local_var_prefix, i);
4756  break;
4757  case TGT_CTXT_HANDLE:
4759  case TGT_INVALID:
4760  case TGT_STRING:
4761  /* not initialised */
4762  break;
4763  }
4764  i++;
4765  break;
4766  default:
4767  break;
4768  }
4769 
4770  sep = 1;
4771  }
4772  }
4773  if (sep)
4774  fprintf(file, "\n");
4775 }
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:585
static const WCHAR indent[]
Definition: object.c:1156
#define TRUE
Definition: types.h:120
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
static int type_has_pointers(const type_t *type)
Definition: typegen.c:703
Definition: send.c:48
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
_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
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
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
#define NULL
Definition: types.h:112
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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 4604 of file typegen.c.

4605 {
4606  int in_attr, out_attr;
4607  int i = 0;
4608  const var_t *var = type_function_get_retval(func->type);
4609 
4610  /* declare return value */
4611  if (!is_void(var->type))
4612  {
4613  print_file(file, indent, "%s", "");
4614  write_type_decl(file, var->type, var->name);
4615  fprintf(file, ";\n");
4616  }
4617 
4618  if (!type_get_function_args(func->type))
4619  return;
4620 
4622  {
4623  in_attr = is_attr(var->attrs, ATTR_IN);
4624  out_attr = is_attr(var->attrs, ATTR_OUT);
4625  if (!out_attr && !in_attr)
4626  in_attr = 1;
4627 
4628  if (is_context_handle(var->type))
4629  print_file(file, indent, "NDR_SCONTEXT %s;\n", var->name);
4630  else
4631  {
4632  if (!in_attr && !is_conformant_array(var->type))
4633  {
4634  type_t *type_to_print;
4635  char name[16];
4636  print_file(file, indent, "%s", "");
4637  if (type_get_type(var->type) == TYPE_ARRAY &&
4639  type_to_print = var->type;
4640  else
4641  type_to_print = type_pointer_get_ref(var->type);
4642  sprintf(name, "_W%u", i++);
4643  write_type_decl(file, type_to_print, name);
4644  fprintf(file, ";\n");
4645  }
4646 
4647  print_file(file, indent, "%s", "");
4648  write_type_decl_left(file, var->type);
4649  fprintf(file, " ");
4650  if (type_get_type(var->type) == TYPE_ARRAY &&
4651  !type_array_is_decl_as_ptr(var->type)) {
4652  fprintf(file, "(*%s)", var->name);
4653  } else
4654  fprintf(file, "%s", var->name);
4655  write_type_right(file, var->type, FALSE);
4656  fprintf(file, ";\n");
4657 
4658  if (decl_indirect(var->type))
4659  print_file(file, indent, "void *_p_%s;\n", var->name);
4660  }
4661  }
4662 }
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:585
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
#define FALSE
Definition: types.h:117
_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
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_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
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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
#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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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

4100 {
4101  expr_t *x = NULL;
4102 
4103  for ( ; is_array(t); t = type_array_get_element(t))
4106  {
4107  if (!x)
4109  else
4110  error("%s: multidimensional conformant"
4111  " arrays not supported at the top level\n",
4112  name);
4113  }
4114 
4115  return x;
4116 }
#define error(str)
Definition: mkdosfs.c:1605
enum expr_type type
Definition: widltypes.h:308
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
static int is_array(const type_t *t)
Definition: header.h:64
#define NULL
Definition: types.h:112
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 4591 of file typegen.c.

4592 {
4593  unsigned int size = 1;
4595  return size;
4596 }
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:4580
#define NULL
Definition: types.h:112

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

4574 {
4575  unsigned int offset = 0;
4577  return offset;
4578 }
GLenum func
Definition: glext.h:6028
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
GLintptr offset
Definition: glext.h:5920
#define NULL
Definition: types.h:112
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 4598 of file typegen.c.

4599 {
4601  return process_tfs(NULL, stmts, pred);
4602 }
void set_all_tfswrite(int val)
Definition: parser.tab.c:5719
#define FALSE
Definition: types.h:117
static unsigned int process_tfs(FILE *file, const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:3742
#define NULL
Definition: types.h:112

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
#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
#define FALSE
Definition: types.h:117
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
PFOR_CONTEXT fc
Definition: for.c:57
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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:585
#define TRUE
Definition: types.h:120
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define FALSE
Definition: types.h:117
attr_list_t * attrs
Definition: widltypes.h:422
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:585
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:422
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 3975 of file typegen.c.

3978 {
3979  type_t *type = var->type;
3980  unsigned int alignment = 0;
3981 
3982  /* no work to do for other phases, buffer sizing is done elsewhere */
3983  if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL)
3984  return;
3985 
3986  if (type_get_type(type) == TYPE_ENUM ||
3987  (type_get_type(type) == TYPE_BASIC &&
3989  pointer_size != 4))
3990  {
3991  unsigned char fc;
3992 
3993  if (type_get_type(type) == TYPE_ENUM)
3994  fc = get_enum_fc(type);
3995  else
3996  fc = get_basic_fc(type);
3997 
3998  if (phase == PHASE_MARSHAL)
3999  print_file(file, indent, "NdrSimpleTypeMarshall(\n");
4000  else
4001  print_file(file, indent, "NdrSimpleTypeUnmarshall(\n");
4002  print_file(file, indent+1, "&__frame->_StubMsg,\n");
4003  print_file(file, indent+1, "(unsigned char *)&%s%s,\n",
4004  local_var_prefix,
4005  var->name);
4006  print_file(file, indent+1, "0x%02x /* %s */);\n", fc, string_of_type(fc));
4007  }
4008  else
4009  {
4011  switch (get_basic_fc(ref))
4012  {
4013  case FC_BYTE:
4014  case FC_CHAR:
4015  case FC_SMALL:
4016  case FC_USMALL:
4017  alignment = 1;
4018  break;
4019 
4020  case FC_WCHAR:
4021  case FC_USHORT:
4022  case FC_SHORT:
4023  alignment = 2;
4024  break;
4025 
4026  case FC_ULONG:
4027  case FC_LONG:
4028  case FC_FLOAT:
4029  case FC_ERROR_STATUS_T:
4030  /* pointer_size must be 4 if we got here in these two cases */
4031  case FC_INT3264:
4032  case FC_UINT3264:
4033  alignment = 4;
4034  break;
4035 
4036  case FC_HYPER:
4037  case FC_DOUBLE:
4038  alignment = 8;
4039  break;
4040 
4041  case FC_IGNORE:
4042  case FC_BIND_PRIMITIVE:
4043  /* no marshalling needed */
4044  return;
4045 
4046  default:
4047  error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n",
4048  var->name, get_basic_fc(ref));
4049  }
4050 
4051  if (phase == PHASE_MARSHAL && alignment > 1)
4052  print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1);
4053  print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n",
4054  alignment - 1, alignment - 1);
4055 
4056  if (phase == PHASE_MARSHAL)
4057  {
4058  print_file(file, indent, "*(");
4060  if (is_ptr(type))
4061  fprintf(file, " *)__frame->_StubMsg.Buffer = *");
4062  else
4063  fprintf(file, " *)__frame->_StubMsg.Buffer = ");
4064  fprintf(file, "%s%s", local_var_prefix, varname);
4065  fprintf(file, ";\n");
4066  }
4067  else if (phase == PHASE_UNMARSHAL)
4068  {
4069  print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof(");
4071  fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n");
4072  print_file(file, indent, "{\n");
4073  print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
4074  print_file(file, indent, "}\n");
4075  print_file(file, indent, "%s%s%s",
4076  (pass == PASS_IN || pass == PASS_RETURN) ? "" : "*",
4077  local_var_prefix, varname);
4078  if (pass == PASS_IN && is_ptr(type))
4079  fprintf(file, " = (");
4080  else
4081  fprintf(file, " = *(");
4083  fprintf(file, " *)__frame->_StubMsg.Buffer;\n");
4084  }
4085 
4086  print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof(");
4088  fprintf(file, ");\n");
4089  }
4090 }
const char * var
Definition: shader.c:5666
static const WCHAR indent[]
Definition: object.c:1156
#define error(str)
Definition: mkdosfs.c:1605
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
Definition: send.c:48
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
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
PFOR_CONTEXT fc
Definition: for.c:57
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
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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 4963 of file typegen.c.

4965 {
4966  type_t *rettype = type_function_get_rettype( func->type );
4967  int has_ret = !is_void( rettype );
4968  const var_list_t *args = type_get_function_args( func->type );
4969  const var_t *arg;
4970  int len, needs_params = 0;
4971 
4972  /* we need a param structure if we have more than one arg */
4973  if (pointer_size == 4 && args) needs_params = is_object( iface ) || list_count( args ) > 1;
4974 
4975  print_file( file, 0, "{\n");
4976  if (needs_params)
4977  {
4978  if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n" );
4979  write_func_param_struct( file, iface, func->type, "__params", FALSE );
4980  if (is_object( iface )) print_file( file, 1, "__params.This = This;\n" );
4981  if (args)
4982  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4983  print_file( file, 1, "__params.%s = %s;\n", arg->name, arg->name );
4984  }
4985  else if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" );
4986 
4987  len = fprintf( file, " %s%s( ",
4988  has_ret ? "_RetVal = " : "",
4989  get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall" );
4990  fprintf( file, "&%s_StubDesc,", prefix );
4991  fprintf( file, "\n%*s&__MIDL_ProcFormatString.Format[%u]", len, "", proc_offset );
4992  if (needs_params)
4993  {
4994  fprintf( file, ",\n%*s&__params", len, "" );
4995  }
4996  else if (pointer_size == 8)
4997  {
4998  if (is_object( iface )) fprintf( file, ",\n%*sThis", len, "" );
4999  if (args)
5000  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
5001  fprintf( file, ",\n%*s%s", len, "", arg->name );
5002  }
5003  else
5004  {
5005  if (is_object( iface )) fprintf( file, ",\n%*s&This", len, "" );
5006  else if (args)
5007  {
5008  arg = LIST_ENTRY( list_head(args), const var_t, entry );
5009  fprintf( file, ",\n%*s&%s", len, "", arg->name );
5010  }
5011  }
5012  fprintf( file, " );\n" );
5013  if (has_ret)
5014  {
5015  print_file( file, 1, "return (" );
5016  write_type_decl_left(file, rettype);
5017  fprintf( file, ")%s;\n", pointer_size == 8 ? "_RetVal.Simple" : "*(LONG_PTR *)&_RetVal" );
5018  }
5019  print_file( file, 0, "}\n\n");
5020 }
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:585
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:4778
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
#define FALSE
Definition: types.h:117
__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 4929 of file typegen.c.

4930 {
4931  const struct str_list_entry_t *endpoint;
4932  const char *p;
4933 
4934  /* this should be an array of RPC_PROTSEQ_ENDPOINT but we want const strings */
4935  print_file( f, 0, "static const unsigned char * const %s__RpcProtseqEndpoint[][2] =\n{\n", prefix );
4937  {
4938  print_file( f, 1, "{ (const unsigned char *)\"" );
4939  for (p = endpoint->str; *p && *p != ':'; p++)
4940  {
4941  if (*p == '"' || *p == '\\') fputc( '\\', f );
4942  fputc( *p, f );
4943  }
4944  if (!*p) goto error;
4945  if (p[1] != '[') goto error;
4946 
4947  fprintf( f, "\", (const unsigned char *)\"" );
4948  for (p += 2; *p && *p != ']'; p++)
4949  {
4950  if (*p == '"' || *p == '\\') fputc( '\\', f );
4951  fputc( *p, f );
4952  }
4953  if (*p != ']') goto error;
4954  fprintf( f, "\" },\n" );
4955  }
4956  print_file( f, 0, "};\n\n" );
4957  return;
4958 
4959 error:
4960  error("Invalid endpoint syntax '%s'\n", endpoint->str);
4961 }
_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:291
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 5022 of file typegen.c.

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

4886 {
4887  struct expr_eval_routine *eval;
4888  struct expr_eval_routine *cursor;
4889  unsigned short callback_offset = 0;
4890 
4891  fprintf(file, "static const EXPR_EVAL ExprEvalRoutines[] =\n");
4892  fprintf(file, "{\n");
4893 
4895  {
4896  print_file(file, 1, "%s_%sExprEval_%04u,\n",
4897  eval->iface ? eval->iface->name : iface, eval->name, callback_offset);
4898  callback_offset++;
4899  list_remove(&eval->entry);
4900  free(eval->name);
4901  free(eval);
4902  }
4903 
4904  fprintf(file, "};\n\n");
4905 }
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:419
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 4846 of file typegen.c.

4847 {
4848  static const char *var_name = "pS";
4849  static const char *var_name_expr = "pS->";
4850  int result = 0;
4851  struct expr_eval_routine *eval;
4852  unsigned short callback_offset = 0;
4853 
4855  {
4856  const char *name = eval->name;
4857  result = 1;
4858 
4859  print_file(file, 0, "static void __RPC_USER %s_%sExprEval_%04u(PMIDL_STUB_MESSAGE pStubMsg)\n",
4860  eval->iface ? eval->iface->name : iface, name, callback_offset);
4861  print_file(file, 0, "{\n");
4862  if (type_get_type( eval->cont_type ) == TYPE_FUNCTION)
4863  {
4865  "*pS = (struct _PARAM_STRUCT *)pStubMsg->StackTop", FALSE );
4866  }
4867  else
4868  {
4869  print_file(file, 1, "%s", "");
4871  fprintf(file, " *%s = (", var_name);
4873  fprintf(file, " *)(pStubMsg->StackTop - %u);\n", eval->baseoff);
4874  }
4875  print_file(file, 1, "pStubMsg->Offset = 0;\n"); /* FIXME */
4876  print_file(file, 1, "pStubMsg->MaxCount = (ULONG_PTR)");
4877  write_expr(file, eval->expr, 1, 1, var_name_expr, eval->cont_type, "");
4878  fprintf(file, ";\n");
4879  print_file(file, 0, "}\n\n");
4880  callback_offset++;
4881  }
4882  return result;
4883 }
static struct list expr_eval_routines
Definition: typegen.c:53
const type_t * cont_type
Definition: typegen.c:58
unsigned int baseoff
Definition: typegen.c:60
GLuint64EXT * result
Definition: glext.h:11304
#define TRUE
Definition: types.h:120
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:4778
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define FALSE
Definition: types.h:117
_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:419
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
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:5726
_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:4598
unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:4591
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 4778 of file typegen.c.

4780 {
4781  var_t *retval = type_function_get_retval( func );
4783  const var_t *arg;
4784  int needs_packing;
4785  unsigned int align = 0;
4786 
4787  if (args)
4788  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4789  if (!is_array( arg->type )) type_memsize_and_alignment( arg->type, &align );
4790 
4791  needs_packing = (align > pointer_size);
4792 
4793  if (needs_packing) print_file( file, 0, "#include <pshpack%u.h>\n", pointer_size );
4794  print_file(file, 1, "struct _PARAM_STRUCT\n" );
4795  print_file(file, 1, "{\n" );
4796  if (is_object( iface )) print_file(file, 2, "%s *This;\n", iface->name );
4797 
4798  if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4799  {
4800  print_file(file, 2, "%s", "");
4802  if (needs_space_after( arg->type )) fputc( ' ', file );
4803  if (is_array( arg->type ) && !type_array_is_decl_as_ptr( arg->type )) fputc( '*', file );
4804 
4805  /* FIXME: should check for large args being passed by pointer */
4806  align = 0;
4807  if (is_array( arg->type ) || is_ptr( arg->type )) align = pointer_size;
4808  else type_memsize_and_alignment( arg->type, &align );
4809 
4810  if (align >= pointer_size)
4811  fprintf( file, "%s;\n", arg->name );
4812  else
4813 #ifdef __REACTOS__
4814  fprintf( file, "DECLSPEC_ALIGN(%u) %s;\n", pointer_size, arg->name );
4815 #else
4816  fprintf( file, "%s DECLSPEC_ALIGN(%u);\n", arg->name, pointer_size );
4817 #endif
4818  }
4819  if (add_retval && !is_void( retval->type ))
4820  {
4821  print_file(file, 2, "%s", "");
4822  write_type_decl( file, retval->type, retval->name );
4823  if (is_array( retval->type ) || is_ptr( retval->type ) ||
4824  type_memsize( retval->type ) == pointer_size)
4825  fprintf( file, ";\n" );
4826  else
4827  fprintf( file, " DECLSPEC_ALIGN(%u);\n", pointer_size );
4828  }
4829  print_file(file, 1, "} %s;\n", var_decl );
4830  if (needs_packing) print_file( file, 0, "#include <poppack.h>\n" );
4831  print_file( file, 0, "\n" );
4832 }
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:585
_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
#define TRUE
Definition: types.h:120
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:453
int needs_space_after(type_t *t)
Definition: header.c:282
const char * name
Definition: widltypes.h:419
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:452
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 4118 of file typegen.c.

4120 {
4121  const type_t *type = var->type;
4122  /* get fundamental type for the argument */
4123  for (;;)
4124  {
4126  {
4127  case TGT_ARRAY:
4129  {
4132  {
4133  print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)");
4134  write_expr(file, type_array_get_conformance(type), 1, 1, NULL, NULL, local_var_prefix);
4135  fprintf(file, ";\n\n");
4136  }
4138  {
4139  print_file(file, indent, "__frame->_StubMsg.Offset = 0;\n"); /* FIXME */
4140  if (valid_variance)
4141  {
4142  print_file(file, indent, "__frame->_StubMsg.ActualCount = (ULONG_PTR)");
4143  write_expr(file, type_array_get_variance(type), 1, 1, NULL, NULL, local_var_prefix);
4144  fprintf(file, ";\n\n");
4145  }
4146  else
4147  print_file(file, indent, "__frame->_StubMsg.ActualCount = __frame->_StubMsg.MaxCount;\n\n");
4148  }
4149  }
4150  break;
4151  case TGT_UNION:
4152  if (type_get_type(type) == TYPE_UNION &&
4154  {
4155  print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)");
4156  write_expr(file, get_attrp(var->attrs, ATTR_SWITCHIS), 1, 1, NULL, NULL, local_var_prefix);
4157  fprintf(file, ";\n\n");
4158  }
4159  break;
4160  case TGT_IFACE_POINTER:
4161  {
4162  expr_t *iid;
4163 
4164  if (is_conformance_needed_for_phase(phase) && (iid = get_attrp( var->attrs, ATTR_IIDIS )))
4165  {
4166  print_file( file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR) " );
4167  write_expr( file, iid, 1, 1, NULL, NULL, local_var_prefix );
4168  fprintf( file, ";\n\n" );
4169  }
4170  break;
4171  }
4172  case TGT_POINTER:
4174  continue;
4175  case TGT_INVALID:
4176  case TGT_USER_TYPE:
4177  case TGT_CTXT_HANDLE:
4179  case TGT_STRING:
4180  case TGT_BASIC:
4181  case TGT_ENUM:
4182  case TGT_STRUCT:
4183  case TGT_RANGE:
4184  break;
4185  }
4186  break;
4187  }
4188 }
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:4094
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
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
#define NULL
Definition: types.h:112
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
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:585
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 4834 of file typegen.c.

4835 {
4836  const var_list_t *args = type_get_function_args( func->type );
4837  const var_t *var;
4838 
4839  if (!args) return;
4840 
4841  LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
4842  if (cant_be_null( var ))
4843  print_file( file, indent, "if (!%s) RpcRaiseException(RPC_X_NULL_REF_POINTER);\n", var->name );
4844 }
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:585
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
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
GLintptr offset
Definition: glext.h:5920
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:597
GLenum func
Definition: glext.h:6028
static const WCHAR indent[]
Definition: object.c:1156
var_t * var
Definition: widltypes.h:539
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
const char * name
Definition: widltypes.h:419
const type_t * iface
Definition: typegen.c:57
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151
union _statement_t::@4830 u
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 4548 of file typegen.c.

4550 {
4551  if (phase == PHASE_BUFFERSIZE && pass != PASS_RETURN)
4552  {
4553  unsigned int size = get_function_buffer_size( func, pass );
4554  print_file(file, indent, "__frame->_StubMsg.BufferLength = %u;\n", size);
4555  }
4556 
4557  if (pass == PASS_RETURN)
4558  {
4559  write_remoting_arg( file, indent, func, local_var_prefix, pass, phase,
4560  type_function_get_retval(func->type) );
4561  }
4562  else
4563  {
4564  const var_t *var;
4565  if (!type_get_function_args(func->type))
4566  return;
4568  write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, var );
4569  }
4570 }
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:585
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:4190
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 3750 of file typegen.c.

3751 {
3752  int indent = 0;
3753 
3754  print_file(file, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =\n");
3755  print_file(file, indent, "{\n");
3756  indent++;
3757  print_file(file, indent, "0,\n");
3758  print_file(file, indent, "{\n");
3759  indent++;
3760  print_file(file, indent, "NdrFcShort(0x0),\n");
3761 
3763  process_tfs(file, stmts, pred);
3764 
3765  print_file(file, indent, "0x0\n");
3766  indent--;
3767  print_file(file, indent, "}\n");
3768  indent--;
3769  print_file(file, indent, "};\n");
3770  print_file(file, indent, "\n");
3771 }
static const WCHAR indent[]
Definition: object.c:1156
#define TRUE
Definition: types.h:120
void set_all_tfswrite(int val)
Definition: parser.tab.c:5719
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:3742
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 4907 of file typegen.c.

4908 {
4909  user_type_t *ut;
4910 
4911  if (list_empty(&user_type_list))
4912  return;
4913 
4914  fprintf(file, "static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[] =\n");
4915  fprintf(file, "{\n");
4917  {
4918  const char *sep = &ut->entry == list_tail(&user_type_list) ? "" : ",";
4919  print_file(file, 1, "{\n");
4920  print_file(file, 2, "(USER_MARSHAL_SIZING_ROUTINE)%s_UserSize,\n", ut->name);
4921  print_file(file, 2, "(USER_MARSHAL_MARSHALLING_ROUTINE)%s_UserMarshal,\n", ut->name);
4922  print_file(file, 2, "(USER_MARSHAL_UNMARSHALLING_ROUTINE)%s_UserUnmarshal,\n", ut->name);
4923  print_file(file, 2, "(USER_MARSHAL_FREEING_ROUTINE)%s_UserFree\n", ut->name);
4924  print_file(file, 1, "}%s\n", sep);
4925  }
4926  fprintf(file, "};\n\n");
4927 }
__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:523
struct list entry
Definition: widltypes.h:522
Definition: fci.c:126

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