ReactOS  0.4.14-dev-608-gd495a4f
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 4657 of file typegen.c.

4658 {
4659  int in_attr, out_attr;
4660  int i = 0, sep = 0;
4661  const var_t *var;
4662  type_t *ref;
4663 
4664  if (!type_get_function_args(func->type))
4665  return;
4666 
4668  {
4669  in_attr = is_attr(var->attrs, ATTR_IN);
4670  out_attr = is_attr(var->attrs, ATTR_OUT);
4671  if (!out_attr && !in_attr)
4672  in_attr = 1;
4673 
4674  if (!in_attr)
4675  {
4676  print_file(file, indent, "%s%s", local_var_prefix, var->name);
4677 
4678  switch (typegen_detect_type(var->type, var->attrs, TDT_IGNORE_STRINGS))
4679  {
4681  fprintf(file, " = NdrContextHandleInitialize(\n");
4682  print_file(file, indent + 1, "&__frame->_StubMsg,\n");
4683  print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n",
4684  var->typestring_offset);
4685  break;
4686  case TGT_ARRAY:
4687  if (type_array_has_conformance(var->type))
4688  {
4689  unsigned int size;
4690  type_t *type;
4691 
4692  fprintf(file, " = NdrAllocate(&__frame->_StubMsg, ");
4693  for (type = var->type;
4696  {
4698  TRUE, NULL, NULL, local_var_prefix);
4699  fprintf(file, " * ");
4700  }
4701  size = type_memsize(type);
4702  fprintf(file, "%u);\n", size);
4703 
4704  print_file(file, indent, "memset(%s%s, 0, ", local_var_prefix, var->name);
4705  for (type = var->type;
4708  {
4710  TRUE, NULL, NULL, local_var_prefix);
4711  fprintf(file, " * ");
4712  }
4713  size = type_memsize(type);
4714  fprintf(file, "%u);\n", size);
4715  }
4716  else
4717  fprintf(file, " = &%s_W%u;\n", local_var_prefix, i++);
4718  break;
4719  case TGT_POINTER:
4720  fprintf(file, " = &%s_W%u;\n", local_var_prefix, i);
4721  ref = type_pointer_get_ref(var->type);
4723  {
4724  case TGT_BASIC:
4725  case TGT_ENUM:
4726  case TGT_POINTER:
4727  case TGT_RANGE:
4728  case TGT_IFACE_POINTER:
4729  print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4730  break;
4731  case TGT_USER_TYPE:
4732  print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4733  local_var_prefix, i, local_var_prefix, i);
4734  break;
4735  case TGT_ARRAY:
4737  {
4738  print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
4739  break;
4740  }
4742  /* fall through */
4743  case TGT_STRUCT:
4744  case TGT_UNION:
4745  if (type_has_pointers(ref))
4746  print_file(file, indent, "memset(&%s_W%u, 0, sizeof(%s_W%u));\n",
4747  local_var_prefix, i, local_var_prefix, i);
4748  break;
4749  case TGT_CTXT_HANDLE:
4751  case TGT_INVALID:
4752  case TGT_STRING:
4753  /* not initialised */
4754  break;
4755  }
4756  i++;
4757  break;
4758  default:
4759  break;
4760  }
4761 
4762  sep = 1;
4763  }
4764  }
4765  if (sep)
4766  fprintf(file, "\n");
4767 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
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
unsigned int typestring_offset
Definition: widltypes.h:457
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
type_t * type
Definition: widltypes.h:452
attr_list_t * attrs
Definition: widltypes.h:453
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
char * name
Definition: widltypes.h:451
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 4596 of file typegen.c.

4597 {
4598  int in_attr, out_attr;
4599  int i = 0;
4600  const var_t *var = type_function_get_retval(func->type);
4601 
4602  /* declare return value */
4603  if (!is_void(var->type))
4604  {
4605  print_file(file, indent, "%s", "");
4606  write_type_decl(file, var->type, var->name);
4607  fprintf(file, ";\n");
4608  }
4609 
4610  if (!type_get_function_args(func->type))
4611  return;
4612 
4614  {
4615  in_attr = is_attr(var->attrs, ATTR_IN);
4616  out_attr = is_attr(var->attrs, ATTR_OUT);
4617  if (!out_attr && !in_attr)
4618  in_attr = 1;
4619 
4620  if (is_context_handle(var->type))
4621  print_file(file, indent, "NDR_SCONTEXT %s;\n", var->name);
4622  else
4623  {
4624  if (!in_attr && !is_conformant_array(var->type))
4625  {
4626  type_t *type_to_print;
4627  char name[16];
4628  print_file(file, indent, "%s", "");
4629  if (type_get_type(var->type) == TYPE_ARRAY &&
4631  type_to_print = var->type;
4632  else
4633  type_to_print = type_pointer_get_ref(var->type);
4634  sprintf(name, "_W%u", i++);
4635  write_type_decl(file, type_to_print, name);
4636  fprintf(file, ";\n");
4637  }
4638 
4639  print_file(file, indent, "%s", "");
4641  fprintf(file, " ");
4642  if (type_get_type(var->type) == TYPE_ARRAY &&
4644  fprintf(file, "(*%s)", var->name);
4645  } else
4646  fprintf(file, "%s", var->name);
4647  write_type_right(file, var->type, FALSE);
4648  fprintf(file, ";\n");
4649 
4650  if (decl_indirect(var->type))
4651  print_file(file, indent, "void *_p_%s;\n", var->name);
4652  }
4653  }
4654 }
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
type_t * type
Definition: widltypes.h:452
void write_type_decl_left(FILE *f, type_t *t)
Definition: header.c:566
attr_list_t * attrs
Definition: widltypes.h:453
void write_type_right(FILE *h, type_t *t, int is_field)
Definition: header.c:437
uint32_t entry
Definition: isohybrid.c:63
char * name
Definition: widltypes.h:451
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 4091 of file typegen.c.

4092 {
4093  expr_t *x = NULL;
4094 
4095  for ( ; is_array(t); t = type_array_get_element(t))
4098  {
4099  if (!x)
4101  else
4102  error("%s: multidimensional conformant"
4103  " arrays not supported at the top level\n",
4104  name);
4105  }
4106 
4107  return x;
4108 }
#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 4583 of file typegen.c.

4584 {
4585  unsigned int size = 1;
4587  return size;
4588 }
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:4572

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

4566 {
4567  unsigned int offset = 0;
4569  return offset;
4570 }
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 4590 of file typegen.c.

4591 {
4593  return process_tfs(NULL, stmts, pred);
4594 }
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:3734

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 }
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
type_t * type
Definition: widltypes.h:452
attr_list_t * attrs
Definition: widltypes.h:421
attr_list_t * attrs
Definition: widltypes.h:453
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 }
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
type_t * type
Definition: widltypes.h:452
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 3967 of file typegen.c.

3970 {
3971  type_t *type = var->type;
3972  unsigned int alignment = 0;
3973 
3974  /* no work to do for other phases, buffer sizing is done elsewhere */
3975  if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL)
3976  return;
3977 
3978  if (type_get_type(type) == TYPE_ENUM ||
3979  (type_get_type(type) == TYPE_BASIC &&
3981  pointer_size != 4))
3982  {
3983  unsigned char fc;
3984 
3985  if (type_get_type(type) == TYPE_ENUM)
3986  fc = get_enum_fc(type);
3987  else
3988  fc = get_basic_fc(type);
3989 
3990  if (phase == PHASE_MARSHAL)
3991  print_file(file, indent, "NdrSimpleTypeMarshall(\n");
3992  else
3993  print_file(file, indent, "NdrSimpleTypeUnmarshall(\n");
3994  print_file(file, indent+1, "&__frame->_StubMsg,\n");
3995  print_file(file, indent+1, "(unsigned char *)&%s%s,\n",
3996  local_var_prefix,
3997  var->name);
3998  print_file(file, indent+1, "0x%02x /* %s */);\n", fc, string_of_type(fc));
3999  }
4000  else
4001  {
4003  switch (get_basic_fc(ref))
4004  {
4005  case FC_BYTE:
4006  case FC_CHAR:
4007  case FC_SMALL:
4008  case FC_USMALL:
4009  alignment = 1;
4010  break;
4011 
4012  case FC_WCHAR:
4013  case FC_USHORT:
4014  case FC_SHORT:
4015  alignment = 2;
4016  break;
4017 
4018  case FC_ULONG:
4019  case FC_LONG:
4020  case FC_FLOAT:
4021  case FC_ERROR_STATUS_T:
4022  /* pointer_size must be 4 if we got here in these two cases */
4023  case FC_INT3264:
4024  case FC_UINT3264:
4025  alignment = 4;
4026  break;
4027 
4028  case FC_HYPER:
4029  case FC_DOUBLE:
4030  alignment = 8;
4031  break;
4032 
4033  case FC_IGNORE:
4034  case FC_BIND_PRIMITIVE:
4035  /* no marshalling needed */
4036  return;
4037 
4038  default:
4039  error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n",
4040  var->name, get_basic_fc(ref));
4041  }
4042 
4043  if (phase == PHASE_MARSHAL && alignment > 1)
4044  print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1);
4045  print_file(file, indent, "__frame->_StubMsg.Buffer = (unsigned char *)(((ULONG_PTR)__frame->_StubMsg.Buffer + %u) & ~0x%x);\n",
4046  alignment - 1, alignment - 1);
4047 
4048  if (phase == PHASE_MARSHAL)
4049  {
4050  print_file(file, indent, "*(");
4052  if (is_ptr(type))
4053  fprintf(file, " *)__frame->_StubMsg.Buffer = *");
4054  else
4055  fprintf(file, " *)__frame->_StubMsg.Buffer = ");
4056  fprintf(file, "%s%s", local_var_prefix, varname);
4057  fprintf(file, ";\n");
4058  }
4059  else if (phase == PHASE_UNMARSHAL)
4060  {
4061  print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof(");
4063  fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n");
4064  print_file(file, indent, "{\n");
4065  print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
4066  print_file(file, indent, "}\n");
4067  print_file(file, indent, "%s%s%s",
4068  (pass == PASS_IN || pass == PASS_RETURN) ? "" : "*",
4069  local_var_prefix, varname);
4070  if (pass == PASS_IN && is_ptr(type))
4071  fprintf(file, " = (");
4072  else
4073  fprintf(file, " = *(");
4075  fprintf(file, " *)__frame->_StubMsg.Buffer;\n");
4076  }
4077 
4078  print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof(");
4080  fprintf(file, ");\n");
4081  }
4082 }
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
type_t * type
Definition: widltypes.h:452
LPFOR_CONTEXT fc
Definition: for.c:53
unsigned int pointer_size
Definition: widl.c:158
char * name
Definition: widltypes.h:451
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 4955 of file typegen.c.

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

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

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

4878 {
4879  struct expr_eval_routine *eval;
4880  struct expr_eval_routine *cursor;
4881  unsigned short callback_offset = 0;
4882 
4883  fprintf(file, "static const EXPR_EVAL ExprEvalRoutines[] =\n");
4884  fprintf(file, "{\n");
4885 
4887  {
4888  print_file(file, 1, "%s_%sExprEval_%04u,\n",
4889  eval->iface ? eval->iface->name : iface, eval->name, callback_offset);
4890  callback_offset++;
4891  list_remove(&eval->entry);
4892  free(eval->name);
4893  free(eval);
4894  }
4895 
4896  fprintf(file, "};\n\n");
4897 }
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 4838 of file typegen.c.

4839 {
4840  static const char *var_name = "pS";
4841  static const char *var_name_expr = "pS->";
4842  int result = 0;
4843  struct expr_eval_routine *eval;
4844  unsigned short callback_offset = 0;
4845 
4847  {
4848  const char *name = eval->name;
4849  result = 1;
4850 
4851  print_file(file, 0, "static void __RPC_USER %s_%sExprEval_%04u(PMIDL_STUB_MESSAGE pStubMsg)\n",
4852  eval->iface ? eval->iface->name : iface, name, callback_offset);
4853  print_file(file, 0, "{\n");
4854  if (type_get_type( eval->cont_type ) == TYPE_FUNCTION)
4855  {
4857  "*pS = (struct _PARAM_STRUCT *)pStubMsg->StackTop", FALSE );
4858  }
4859  else
4860  {
4861  print_file(file, 1, "%s", "");
4863  fprintf(file, " *%s = (", var_name);
4865  fprintf(file, " *)(pStubMsg->StackTop - %u);\n", eval->baseoff);
4866  }
4867  print_file(file, 1, "pStubMsg->Offset = 0;\n"); /* FIXME */
4868  print_file(file, 1, "pStubMsg->MaxCount = (ULONG_PTR)");
4869  write_expr(file, eval->expr, 1, 1, var_name_expr, eval->cont_type, "");
4870  fprintf(file, ";\n");
4871  print_file(file, 0, "}\n\n");
4872  callback_offset++;
4873  }
4874  return result;
4875 }
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:4770
#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:4590
unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred)
Definition: typegen.c:4583
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 4770 of file typegen.c.

4772 {
4773  var_t *retval = type_function_get_retval( func );
4775  const var_t *arg;
4776  int needs_packing;
4777  unsigned int align = 0;
4778 
4779  if (args)
4780  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4781  if (!is_array( arg->type )) type_memsize_and_alignment( arg->type, &align );
4782 
4783  needs_packing = (align > pointer_size);
4784 
4785  if (needs_packing) print_file( file, 0, "#include <pshpack%u.h>\n", pointer_size );
4786  print_file(file, 1, "struct _PARAM_STRUCT\n" );
4787  print_file(file, 1, "{\n" );
4788  if (is_object( iface )) print_file(file, 2, "%s *This;\n", iface->name );
4789 
4790  if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
4791  {
4792  print_file(file, 2, "%s", "");
4794  if (needs_space_after( arg->type )) fputc( ' ', file );
4795  if (is_array( arg->type ) && !type_array_is_decl_as_ptr( arg->type )) fputc( '*', file );
4796 
4797  /* FIXME: should check for large args being passed by pointer */
4798  align = 0;
4799  if (is_array( arg->type ) || is_ptr( arg->type )) align = pointer_size;
4800  else type_memsize_and_alignment( arg->type, &align );
4801 
4802  if (align >= pointer_size)
4803  fprintf( file, "%s;\n", arg->name );
4804  else
4805 #ifdef __REACTOS__
4806  fprintf( file, "DECLSPEC_ALIGN(%u) %s;\n", pointer_size, arg->name );
4807 #else
4808  fprintf( file, "%s DECLSPEC_ALIGN(%u);\n", arg->name, pointer_size );
4809 #endif
4810  }
4811  if (add_retval && !is_void( retval->type ))
4812  {
4813  print_file(file, 2, "%s", "");
4814  write_type_decl( file, retval->type, retval->name );
4815  if (is_array( retval->type ) || is_ptr( retval->type ) ||
4816  type_memsize( retval->type ) == pointer_size)
4817  fprintf( file, ";\n" );
4818  else
4819  fprintf( file, " DECLSPEC_ALIGN(%u);\n", pointer_size );
4820  }
4821  print_file(file, 1, "} %s;\n", var_decl );
4822  if (needs_packing) print_file( file, 0, "#include <poppack.h>\n" );
4823  print_file( file, 0, "\n" );
4824 }
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 4110 of file typegen.c.

4112 {
4113  const type_t *type = var->type;
4114  /* get fundamental type for the argument */
4115  for (;;)
4116  {
4118  {
4119  case TGT_ARRAY:
4121  {
4124  {
4125  print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)");
4126  write_expr(file, type_array_get_conformance(type), 1, 1, NULL, NULL, local_var_prefix);
4127  fprintf(file, ";\n\n");
4128  }
4130  {
4131  print_file(file, indent, "__frame->_StubMsg.Offset = 0;\n"); /* FIXME */
4132  if (valid_variance)
4133  {
4134  print_file(file, indent, "__frame->_StubMsg.ActualCount = (ULONG_PTR)");
4135  write_expr(file, type_array_get_variance(type), 1, 1, NULL, NULL, local_var_prefix);
4136  fprintf(file, ";\n\n");
4137  }
4138  else
4139  print_file(file, indent, "__frame->_StubMsg.ActualCount = __frame->_StubMsg.MaxCount;\n\n");
4140  }
4141  }
4142  break;
4143  case TGT_UNION:
4144  if (type_get_type(type) == TYPE_UNION &&
4146  {
4147  print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)");
4148  write_expr(file, get_attrp(var->attrs, ATTR_SWITCHIS), 1, 1, NULL, NULL, local_var_prefix);
4149  fprintf(file, ";\n\n");
4150  }
4151  break;
4152  case TGT_IFACE_POINTER:
4153  {
4154  expr_t *iid;
4155 
4156  if (is_conformance_needed_for_phase(phase) && (iid = get_attrp( var->attrs, ATTR_IIDIS )))
4157  {
4158  print_file( file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR) " );
4159  write_expr( file, iid, 1, 1, NULL, NULL, local_var_prefix );
4160  fprintf( file, ";\n\n" );
4161  }
4162  break;
4163  }
4164  case TGT_POINTER:
4166  continue;
4167  case TGT_INVALID:
4168  case TGT_USER_TYPE:
4169  case TGT_CTXT_HANDLE:
4171  case TGT_STRING:
4172  case TGT_BASIC:
4173  case TGT_ENUM:
4174  case TGT_STRUCT:
4175  case TGT_RANGE:
4176  break;
4177  }
4178  break;
4179  }
4180 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
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:4086
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
type_t * type
Definition: widltypes.h:452
attr_list_t * attrs
Definition: widltypes.h:453
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 }
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,...)
type_t * type
Definition: widltypes.h:452
uint32_t entry
Definition: isohybrid.c:63
char * name
Definition: widltypes.h:451
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 4826 of file typegen.c.

4827 {
4828  const var_list_t *args = type_get_function_args( func->type );
4829  const var_t *var;
4830 
4831  if (!args) return;
4832 
4833  LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
4834  if (cant_be_null( var ))
4835  print_file( file, indent, "if (!%s) RpcRaiseException(RPC_X_NULL_REF_POINTER);\n", var->name );
4836 }
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
char * name
Definition: widltypes.h:451
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::@4054 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 4540 of file typegen.c.

4542 {
4543  if (phase == PHASE_BUFFERSIZE && pass != PASS_RETURN)
4544  {
4545  unsigned int size = get_function_buffer_size( func, pass );
4546  print_file(file, indent, "__frame->_StubMsg.BufferLength = %u;\n", size);
4547  }
4548 
4549  if (pass == PASS_RETURN)
4550  {
4551  write_remoting_arg( file, indent, func, local_var_prefix, pass, phase,
4552  type_function_get_retval(func->type) );
4553  }
4554  else
4555  {
4556  const var_t *var;
4557  if (!type_get_function_args(func->type))
4558  return;
4560  write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, var );
4561  }
4562 }
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:4182
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 3742 of file typegen.c.

3743 {
3744  int indent = 0;
3745 
3746  print_file(file, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =\n");
3747  print_file(file, indent, "{\n");
3748  indent++;
3749  print_file(file, indent, "0,\n");
3750  print_file(file, indent, "{\n");
3751  indent++;
3752  print_file(file, indent, "NdrFcShort(0x0),\n");
3753 
3755  process_tfs(file, stmts, pred);
3756 
3757  print_file(file, indent, "0x0\n");
3758  indent--;
3759  print_file(file, indent, "}\n");
3760  indent--;
3761  print_file(file, indent, "};\n");
3762  print_file(file, indent, "\n");
3763 }
#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:3734
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 4899 of file typegen.c.

4900 {
4901  user_type_t *ut;
4902 
4903  if (list_empty(&user_type_list))
4904  return;
4905 
4906  fprintf(file, "static const USER_MARSHAL_ROUTINE_QUADRUPLE UserMarshalRoutines[] =\n");
4907  fprintf(file, "{\n");
4909  {
4910  const char *sep = &ut->entry == list_tail(&user_type_list) ? "" : ",";
4911  print_file(file, 1, "{\n");
4912  print_file(file, 2, "(USER_MARSHAL_SIZING_ROUTINE)%s_UserSize,\n", ut->name);
4913  print_file(file, 2, "(USER_MARSHAL_MARSHALLING_ROUTINE)%s_UserMarshal,\n", ut->name);
4914  print_file(file, 2, "(USER_MARSHAL_UNMARSHALLING_ROUTINE)%s_UserUnmarshal,\n", ut->name);
4915  print_file(file, 2, "(USER_MARSHAL_FREEING_ROUTINE)%s_UserFree\n", ut->name);
4916  print_file(file, 1, "}%s\n", sep);
4917  }
4918  fprintf(file, "};\n\n");
4919 }
__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().