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

Go to the source code of this file.

Classes

struct  expr_eval_routine
 

Macros

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

Enumerations

enum  type_context { TYPE_CONTEXT_TOPLEVELPARAM, TYPE_CONTEXT_PARAM, TYPE_CONTEXT_CONTAINER, TYPE_CONTEXT_CONTAINER_NO_POINTERS }
 

Functions

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

Variables

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

Macro Definition Documentation

◆ ROUND_SIZE

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

Definition at line 45 of file typegen.c.

◆ ROUNDING

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

Definition at line 47 of file typegen.c.

◆ WRITE_FCTYPE

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

Definition at line 862 of file typegen.c.

Enumeration Type Documentation

◆ type_context

Enumerator
TYPE_CONTEXT_TOPLEVELPARAM 
TYPE_CONTEXT_PARAM 
TYPE_CONTEXT_CONTAINER 
TYPE_CONTEXT_CONTAINER_NO_POINTERS 

Definition at line 64 of file typegen.c.

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

◆ cant_be_null()

static int cant_be_null ( const var_t v)
static

Definition at line 379 of file typegen.c.

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

Referenced by write_pointer_checks().

◆ clamp_align()

static unsigned int clamp_align ( unsigned int  align)
inlinestatic

Definition at line 251 of file typegen.c.

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

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

◆ decl_indirect()

int decl_indirect ( const type_t t)

Definition at line 948 of file typegen.c.

949 {
950  if (is_user_type(t))
951  return TRUE;
952  return (type_get_type(t) != TYPE_BASIC &&
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:36
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().

◆ field_memsize()

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

Definition at line 1803 of file typegen.c.

1804 {
1805  unsigned int align = 0;
1806  unsigned int size = type_memsize_and_alignment( type, &align );
1807 
1808  *offset = ROUND_SIZE( *offset, align );
1809  return size;
1810 }
unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
Definition: typegen.c:1855
GLintptr offset
Definition: glext.h:5920
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int align(int length, int align)
Definition: dsound8.c:36
GLsizeiptr size
Definition: glext.h:5919
#define ROUND_SIZE(size, alignment)
Definition: typegen.c:45

Referenced by write_conf_or_var_desc(), and write_descriptors().

◆ fields_memsize()

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

Definition at line 1812 of file typegen.c.

1813 {
1814  unsigned int size = 0;
1815  unsigned int max_align;
1816  const var_t *v;
1817 
1818  if (!fields) return 0;
1819  LIST_FOR_EACH_ENTRY( v, fields, const var_t, entry )
1820  {
1821  unsigned int falign = 0;
1822  unsigned int fsize = type_memsize_and_alignment(v->type, &falign);
1823  if (*align < falign) *align = falign;
1824  falign = clamp_align(falign);
1825  size = ROUND_SIZE(size, falign);
1826  size += fsize;
1827  }
1828 
1829  max_align = clamp_align(*align);
1830  size = ROUND_SIZE(size, max_align);
1831 
1832  return size;
1833 }
unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
Definition: typegen.c:1855
int align(int length, int align)
Definition: dsound8.c:36
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLsizeiptr size
Definition: glext.h:5919
uint32_t entry
Definition: isohybrid.c:63
static unsigned int clamp_align(unsigned int align)
Definition: typegen.c:251
const GLdouble * v
Definition: gl.h:2040
#define ROUND_SIZE(size, alignment)
Definition: typegen.c:45
GLint fsize
Definition: glext.h:9408

Referenced by get_required_buffer_size_type(), and type_memsize_and_alignment().

◆ find_array_or_string_in_struct()

static const var_t * find_array_or_string_in_struct ( const type_t type)
static

Definition at line 3041 of file typegen.c.

3042 {
3043  const var_list_t *fields = type_struct_get_fields(type);
3044  const var_t *last_field;
3045  const type_t *ft;
3046 
3047  if (!fields || list_empty(fields))
3048  return NULL;
3049 
3050  last_field = LIST_ENTRY( list_tail(fields), const var_t, entry );
3051  ft = last_field->type;
3052 
3054  return last_field;
3055 
3056  if (type_get_type(ft) == TYPE_STRUCT)
3057  return find_array_or_string_in_struct(ft);
3058  else
3059  return NULL;
3060 }
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:87
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:137
static const var_t * find_array_or_string_in_struct(const type_t *type)
Definition: typegen.c:3041
smooth NULL
Definition: ftsmooth.c:416
static int is_conformant_array(const type_t *t)
Definition: header.h:79
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
type_t * type
Definition: widltypes.h:452
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by write_pointer_description(), and write_struct_tfs().

◆ for_each_iface()

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

Definition at line 1469 of file typegen.c.

1472 {
1473  const statement_t *stmt;
1474  type_t *iface;
1475 
1476  if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
1477  {
1478  if (stmt->type != STMT_TYPE || type_get_type(stmt->u.type) != TYPE_INTERFACE)
1479  continue;
1480  iface = stmt->u.type;
1481  if (!pred(iface)) continue;
1482  proc(iface, file, indent, offset);
1483  if (iface->details.iface->async_iface)
1484  proc(iface->details.iface->async_iface, file, indent, offset);
1485  }
1486 }
static const WCHAR indent[]
Definition: object.c:1156
GLintptr offset
Definition: glext.h:5920
static HANDLE proc()
Definition: pdb.c:32
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
statement_type_t type
Definition: parser.h:124
union _statement_t::@4054 u
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
union _type_t::@4053 details
struct iface_details * iface
Definition: widltypes.h:427
uint32_t entry
Definition: isohybrid.c:63
Definition: fci.c:126

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

◆ get_aliaschain_attrp()

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

Definition at line 191 of file typegen.c.

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

Referenced by write_remoting_arg(), and write_type_tfs().

◆ get_array_fc()

static unsigned char get_array_fc ( const type_t type)
static

Definition at line 617 of file typegen.c.

618 {
619  unsigned char fc;
620  const expr_t *size_is;
621  const type_t *elem_type;
622 
623  elem_type = type_array_get_element(type);
624  size_is = type_array_get_conformance(type);
625 
626  if (!size_is)
627  {
628  unsigned int size = type_memsize(elem_type);
629  if (size * type_array_get_dim(type) > 0xffffuL)
630  fc = FC_LGFARRAY;
631  else
632  fc = FC_SMFARRAY;
633  }
634  else
635  fc = FC_CARRAY;
636 
638  {
639  if (fc == FC_SMFARRAY)
640  fc = FC_SMVARRAY;
641  else if (fc == FC_LGFARRAY)
642  fc = FC_LGVARRAY;
643  else if (fc == FC_CARRAY)
644  fc = FC_CVARRAY;
645  }
646 
647  switch (typegen_detect_type(elem_type, NULL, TDT_IGNORE_STRINGS))
648  {
649  case TGT_USER_TYPE:
650  fc = FC_BOGUS_ARRAY;
651  break;
652  case TGT_BASIC:
653  if (type_basic_get_type(elem_type) == TYPE_BASIC_INT3264 &&
654  pointer_size != 4)
655  fc = FC_BOGUS_ARRAY;
656  break;
657  case TGT_STRUCT:
658  switch (get_struct_fc(elem_type))
659  {
660  case FC_BOGUS_STRUCT:
661  fc = FC_BOGUS_ARRAY;
662  break;
663  }
664  break;
665  case TGT_ENUM:
666  /* is 16-bit enum - if so, wire size differs from mem size and so
667  * the array cannot be block copied, which means the array is complex */
668  if (get_enum_fc(elem_type) == FC_ENUM16)
669  fc = FC_BOGUS_ARRAY;
670  break;
671  case TGT_UNION:
672  case TGT_IFACE_POINTER:
673  fc = FC_BOGUS_ARRAY;
674  break;
675  case TGT_POINTER:
676  /* ref pointers cannot just be block copied. unique pointers to
677  * interfaces need special treatment. either case means the array is
678  * complex */
679  if (get_pointer_fc(elem_type, NULL, FALSE) == FC_RP || pointer_size != 4)
680  fc = FC_BOGUS_ARRAY;
681  break;
682  case TGT_RANGE:
683  fc = FC_BOGUS_ARRAY;
684  break;
685  case TGT_CTXT_HANDLE:
687  case TGT_STRING:
688  case TGT_INVALID:
689  case TGT_ARRAY:
690  /* nothing to do for everything else */
691  break;
692  }
693 
694  return fc;
695 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:232
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:258
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 enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
LPFOR_CONTEXT fc
Definition: for.c:53
unsigned char get_struct_fc(const type_t *type)
Definition: typegen.c:478
unsigned int pointer_size
Definition: widl.c:158
unsigned int type_memsize(const type_t *t)
Definition: typegen.c:1964
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
static expr_t * type_array_get_conformance(const type_t *type)
Definition: typetree.h:239

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

◆ get_basic_fc()

unsigned char get_basic_fc ( const type_t type)

Definition at line 204 of file typegen.c.

205 {
207  switch (type_basic_get_type(type))
208  {
209  case TYPE_BASIC_INT8: return (sign <= 0 ? FC_SMALL : FC_USMALL);
210  case TYPE_BASIC_INT16: return (sign <= 0 ? FC_SHORT : FC_USHORT);
211  case TYPE_BASIC_INT32:
212  case TYPE_BASIC_LONG: return (sign <= 0 ? FC_LONG : FC_ULONG);
213  case TYPE_BASIC_INT64: return FC_HYPER;
214  case TYPE_BASIC_INT: return (sign <= 0 ? FC_LONG : FC_ULONG);
215  case TYPE_BASIC_INT3264: return (sign <= 0 ? FC_INT3264 : FC_UINT3264);
216  case TYPE_BASIC_BYTE: return FC_BYTE;
217  case TYPE_BASIC_CHAR: return FC_CHAR;
218  case TYPE_BASIC_WCHAR: return FC_WCHAR;
219  case TYPE_BASIC_HYPER: return FC_HYPER;
220  case TYPE_BASIC_FLOAT: return FC_FLOAT;
221  case TYPE_BASIC_DOUBLE: return FC_DOUBLE;
224  }
225  return 0;
226 }
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_basic_fc_signed()

static unsigned char get_basic_fc_signed ( const type_t type)
static

Definition at line 228 of file typegen.c.

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

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

◆ get_context_handle_type_name()

static const char* get_context_handle_type_name ( const type_t type)
static

Definition at line 850 of file typegen.c.

851 {
852  const type_t *t;
853  for (t = type;
854  is_ptr(t) || type_is_alias(t);
856  if (is_attr(t->attrs, ATTR_CONTEXTHANDLE))
857  return t->name;
858  assert(0);
859  return NULL;
860 }
return
Definition: dirsup.c:529
GLdouble GLdouble t
Definition: gl.h:2047
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
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
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
static type_t * type_alias_get_aliasee(const type_t *type)
Definition: typetree.h:279
Definition: name.c:36
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99

Referenced by write_remoting_arg().

◆ get_contexthandle_flags()

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

Definition at line 444 of file typegen.c.

446 {
447  unsigned char flags = 0;
448 
450 
451  if (is_ptr(type) &&
452  !is_attr( type->attrs, ATTR_CONTEXTHANDLE ) &&
453  !is_attr( attrs, ATTR_CONTEXTHANDLE ))
454  flags |= 0x80;
455 
456  if (is_attr(attrs, ATTR_IN))
457  {
458  flags |= 0x40;
460  }
461  if (is_attr(attrs, ATTR_OUT)) flags |= 0x20;
462 
463  return flags;
464 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define NDR_CONTEXT_HANDLE_CANNOT_BE_NULL
Definition: ndrtypes.h:288
static int is_ptr(const type_t *t)
Definition: header.h:59
#define NDR_STRICT_CONTEXT_HANDLE
Definition: ndrtypes.h:285
attr_list_t * attrs
Definition: widltypes.h:421
GLbitfield flags
Definition: glext.h:7161
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99

Referenced by write_contexthandle_tfs(), and write_proc_func_header().

◆ get_enum_fc()

static unsigned char get_enum_fc ( const type_t type)
static

Definition at line 296 of file typegen.c.

297 {
300  return FC_ENUM32;
301  else
302  return FC_ENUM16;
303 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
int is_aliaschain_attr(const type_t *type, enum attr_type attr)
Definition: header.c:86
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68

Referenced by get_array_fc(), get_parameter_fc(), get_required_buffer_size_type(), get_struct_fc(), print_phase_basetype(), type_buffer_alignment(), type_memsize_and_alignment(), write_base_type(), write_branch_type(), write_conf_or_var_desc(), write_old_procformatstring_type(), write_range_tfs(), write_simple_pointer(), write_union_tfs(), and write_user_tfs().

◆ get_func_oi2_flags()

static unsigned char get_func_oi2_flags ( const var_t func)
static

Definition at line 1115 of file typegen.c.

1116 {
1117  const var_t *var;
1119  var_t *retval = type_function_get_retval( func->type );
1120  unsigned char oi2_flags = 0x40; /* HasExtensions */
1121  unsigned short flags;
1122  unsigned int stack_size, typestring_offset;
1123 
1124  if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
1125  {
1126  get_parameter_fc( var, 0, &flags, &stack_size, &typestring_offset );
1127  if (flags & MustSize)
1128  {
1129  if (flags & IsIn) oi2_flags |= 0x02; /* ClientMustSize */
1130  if (flags & IsOut) oi2_flags |= 0x01; /* ServerMustSize */
1131  }
1132  }
1133 
1134  if (!is_void( retval->type ))
1135  {
1136  oi2_flags |= 0x04; /* HasRet */
1137  get_parameter_fc( retval, 1, &flags, &stack_size, &typestring_offset );
1138  if (flags & MustSize) oi2_flags |= 0x01; /* ServerMustSize */
1139  }
1140  return oi2_flags;
1141 }
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 unsigned short IsOut
Definition: typegen.c:77
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101
Definition: match.c:390
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static const unsigned short MustSize
Definition: typegen.c:73
static unsigned char get_parameter_fc(const var_t *var, int is_return, unsigned short *flags, unsigned int *stack_size, unsigned int *typestring_offset)
Definition: typegen.c:958
type_t * type
Definition: widltypes.h:452
GLbitfield flags
Definition: glext.h:7161
static const unsigned short IsIn
Definition: typegen.c:76
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static int is_void(const type_t *t)
Definition: header.h:69

Referenced by write_proc_func_header().

◆ get_function_buffer_size() [1/2]

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

◆ get_function_buffer_size() [2/2]

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

Definition at line 3903 of file typegen.c.

3904 {
3905  const var_t *var;
3906  unsigned int total_size = 0, alignment;
3907 
3908  if (type_get_function_args(func->type))
3909  {
3911  {
3912  total_size += get_required_buffer_size(var, &alignment, pass);
3913  total_size += alignment;
3914  }
3915  }
3916 
3917  if (pass == PASS_OUT && !is_void(type_function_get_rettype(func->type)))
3918  {
3919  var_t v = *func;
3920  v.type = type_function_get_rettype(func->type);
3921  total_size += get_required_buffer_size(&v, &alignment, PASS_RETURN);
3922  total_size += alignment;
3923  }
3924  return total_size;
3925 }
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
pass
Definition: typegen.h:24
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass)
Definition: typegen.c:3877
uint32_t entry
Definition: isohybrid.c:63
const GLdouble * v
Definition: gl.h:2040
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

◆ get_padding()

static int get_padding ( const var_list_t fields)
static

Definition at line 396 of file typegen.c.

397 {
398  unsigned short offset = 0;
399  unsigned int salign = 1;
400  const var_t *f;
401 
402  if (!fields)
403  return 0;
404 
405  LIST_FOR_EACH_ENTRY(f, fields, const var_t, entry)
406  {
407  type_t *ft = f->type;
408  unsigned int align = 0;
409  unsigned int size = type_memsize_and_alignment(ft, &align);
411  if (align > salign) salign = align;
413  offset += size;
414  }
415 
416  return ROUNDING(offset, salign);
417 }
#define ROUNDING(size, alignment)
Definition: typegen.c:47
unsigned int type_memsize_and_alignment(const type_t *t, unsigned int *align)
Definition: typegen.c:1855
GLintptr offset
Definition: glext.h:5920
int align(int length, int align)
Definition: dsound8.c:36
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLfloat f
Definition: glext.h:7540
GLsizeiptr size
Definition: glext.h:5919
uint32_t entry
Definition: isohybrid.c:63
static unsigned int clamp_align(unsigned int align)
Definition: typegen.c:251
#define ROUND_SIZE(size, alignment)
Definition: typegen.c:45
#define f
Definition: ke_i.h:83

Referenced by get_struct_fc().

◆ get_parameter_fc()

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

Definition at line 958 of file typegen.c.

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

Referenced by get_func_oi2_flags(), and write_new_procformatstring_type().

◆ get_pointer_fc()

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

Definition at line 258 of file typegen.c.

259 {
260  const type_t *t;
261  int pointer_type;
262 
264 
265  pointer_type = get_attrv(attrs, ATTR_POINTERTYPE);
266  if (pointer_type)
267  return pointer_type;
268 
270  {
271  pointer_type = get_attrv(t->attrs, ATTR_POINTERTYPE);
272  if (pointer_type)
273  return pointer_type;
274  }
275 
276  if (toplevel_param)
277  return FC_RP;
278  else if (is_ptr(type))
280  else
282 }
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_pointer_fc_context()

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

Definition at line 284 of file typegen.c.

286 {
287  int pointer_fc = get_pointer_fc(type, attrs, context == TYPE_CONTEXT_TOPLEVELPARAM);
288 
289  if (pointer_fc == FC_UP && is_attr( attrs, ATTR_OUT ) &&
291  pointer_fc = FC_OP;
292 
293  return pointer_fc;
294 }
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:258
Definition: http.c:6587
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int is_object(const type_t *iface)
Definition: header.c:928
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99
static const type_t * current_iface
Definition: typegen.c:51

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

◆ get_required_buffer_size()

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

Definition at line 3877 of file typegen.c.

3878 {
3879  int in_attr = is_attr(var->attrs, ATTR_IN);
3880  int out_attr = is_attr(var->attrs, ATTR_OUT);
3881 
3882  if (!in_attr && !out_attr)
3883  in_attr = 1;
3884 
3885  *alignment = 0;
3886 
3887  if ((pass == PASS_IN && in_attr) || (pass == PASS_OUT && out_attr) ||
3888  pass == PASS_RETURN)
3889  {
3891  {
3892  *alignment = 4;
3893  return 20;
3894  }
3895 
3896  if (!is_string_type(var->attrs, var->type))
3897  return get_required_buffer_size_type(var->type, var->name,
3898  var->attrs, TRUE, alignment);
3899  }
3900  return 0;
3901 }
#define TRUE
Definition: types.h:120
static unsigned int get_required_buffer_size_type(const type_t *type, const char *name, const attr_list_t *attrs, int toplevel_param, unsigned int *alignment)
Definition: typegen.c:3765
pass
Definition: typegen.h:24
int is_ptrchain_attr(const var_t *var, enum attr_type t)
Definition: header.c:66
static int is_string_type(const attr_list_t *attrs, const type_t *type)
Definition: header.h:94
type_t * type
Definition: widltypes.h:452
attr_list_t * attrs
Definition: widltypes.h:453
char * name
Definition: widltypes.h:451
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99

Referenced by get_function_buffer_size(), and write_remoting_arg().

◆ get_required_buffer_size_type()

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

Definition at line 3765 of file typegen.c.

3767 {
3768  *alignment = 0;
3770  {
3771  case TGT_USER_TYPE:
3772  {
3773  const char *uname = NULL;
3774  const type_t *utype = get_user_type(type, &uname);
3775  return get_required_buffer_size_type(utype, uname, NULL, FALSE, alignment);
3776  }
3777  case TGT_BASIC:
3778  switch (get_basic_fc(type))
3779  {
3780  case FC_BYTE:
3781  case FC_CHAR:
3782  case FC_USMALL:
3783  case FC_SMALL:
3784  *alignment = 4;
3785  return 1;
3786 
3787  case FC_WCHAR:
3788  case FC_USHORT:
3789  case FC_SHORT:
3790  *alignment = 4;
3791  return 2;
3792 
3793  case FC_ULONG:
3794  case FC_LONG:
3795  case FC_FLOAT:
3796  case FC_ERROR_STATUS_T:
3797  *alignment = 4;
3798  return 4;
3799 
3800  case FC_HYPER:
3801  case FC_DOUBLE:
3802  *alignment = 8;
3803  return 8;
3804 
3805  case FC_INT3264:
3806  case FC_UINT3264:
3807  assert( pointer_size );
3808  *alignment = pointer_size;
3809  return pointer_size;
3810 
3811  case FC_IGNORE:
3812  case FC_BIND_PRIMITIVE:
3813  return 0;
3814 
3815  default:
3816  error("get_required_buffer_size: unknown basic type 0x%02x\n",
3817  get_basic_fc(type));
3818  return 0;
3819  }
3820  break;
3821 
3822  case TGT_ENUM:
3823  switch (get_enum_fc(type))
3824  {
3825  case FC_ENUM32:
3826  *alignment = 4;
3827  return 4;
3828  case FC_ENUM16:
3829  *alignment = 4;
3830  return 2;
3831  }
3832  break;
3833 
3834  case TGT_STRUCT:
3835  if (get_struct_fc(type) == FC_STRUCT)
3836  {
3837  if (!type_struct_get_fields(type)) return 0;
3838  return fields_memsize(type_struct_get_fields(type), alignment);
3839  }
3840  break;
3841 
3842  case TGT_POINTER:
3843  {
3844  unsigned int size, align;
3845  const type_t *ref = type_pointer_get_ref(type);
3846  if (is_string_type( attrs, ref )) break;
3847  if (!(size = get_required_buffer_size_type( ref, name, NULL, FALSE, &align ))) break;
3848  if (get_pointer_fc(type, attrs, toplevel_param) != FC_RP)
3849  {
3850  size += 4 + align;
3851  align = 4;
3852  }
3853  *alignment = align;
3854  return size;
3855  }
3856 
3857  case TGT_ARRAY:
3858  if (get_pointer_fc(type, attrs, toplevel_param) == FC_RP)
3859  {
3860  switch (get_array_fc(type))
3861  {
3862  case FC_SMFARRAY:
3863  case FC_LGFARRAY:
3864  return type_array_get_dim(type) *
3866  NULL, FALSE, alignment);
3867  }
3868  }
3869  break;
3870 
3871  default:
3872  break;
3873  }
3874  return 0;
3875 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:232
static type_t * get_user_type(const type_t *t, const char **pname)
Definition: typegen.c:305
static unsigned int get_required_buffer_size_type(const type_t *type, const char *name, const attr_list_t *attrs, int toplevel_param, unsigned int *alignment)
Definition: typegen.c:3765
unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:258
#define error(str)
Definition: mkdosfs.c:1605
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
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
int align(int length, int align)
Definition: dsound8.c:36
Definition: send.c:47
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
static int is_string_type(const attr_list_t *attrs, const type_t *type)
Definition: header.h:94
unsigned char get_basic_fc(const type_t *type)
Definition: typegen.c:204
unsigned char get_struct_fc(const type_t *type)
Definition: typegen.c:478
unsigned int pointer_size
Definition: widl.c:158
static unsigned char get_array_fc(const type_t *type)
Definition: typegen.c:617
static unsigned char get_enum_fc(const type_t *type)
Definition: typegen.c:296
Definition: name.c:36

Referenced by get_parameter_fc(), and get_required_buffer_size().

◆ get_rpc_flags()

static unsigned int get_rpc_flags ( const attr_list_t attrs)
static

Definition at line 466 of file typegen.c.

467 {
468  unsigned int flags = 0;
469 
470  if (is_attr( attrs, ATTR_IDEMPOTENT )) flags |= 0x0001;
471  if (is_attr( attrs, ATTR_BROADCAST )) flags |= 0x0002;
472  if (is_attr( attrs, ATTR_MAYBE )) flags |= 0x0004;
473  if (is_attr( attrs, ATTR_MESSAGE )) flags |= 0x0100;
474  if (is_attr( attrs, ATTR_ASYNC )) flags |= 0x4000;
475  return flags;
476 }
GLbitfield flags
Definition: glext.h:7161
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99

Referenced by write_proc_func_header().

◆ get_size_is_expr()

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

Definition at line 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:36
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;
4568  write_procformatstring_func( NULL, 0, iface, func, &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

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

◆ get_size_procformatstring_iface()

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

Definition at line 4572 of file typegen.c.

4573 {
4574  const statement_t *stmt;
4576  {
4577  const var_t *func = stmt->u.var;
4578  if (!is_local(func->attrs))
4580  }
4581 }
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:596
GLenum func
Definition: glext.h:6028
var_t * var
Definition: widltypes.h:538
int is_local(const attr_list_t *a)
Definition: header.c:938
union _statement_t::@4054 u
unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func)
Definition: typegen.c:4565
GLsizeiptr size
Definition: glext.h:5919
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151

Referenced by get_size_procformatstring().

◆ get_size_typeformatstring()

unsigned int get_size_typeformatstring ( const statement_list_t stmts,
type_pred_t  pred 
)

Definition at line 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_stack_size()

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

Definition at line 419 of file typegen.c.

420 {
421  unsigned int stack_size;
422  int by_val;
423 
424  switch (typegen_detect_type( var->type, var->attrs, TDT_ALL_TYPES ))
425  {
426  case TGT_BASIC:
427  case TGT_ENUM:
428  case TGT_RANGE:
429  case TGT_STRUCT:
430  case TGT_UNION:
431  case TGT_USER_TYPE:
432  stack_size = type_memsize( var->type );
433  by_val = (pointer_size < 8 || stack_size <= pointer_size); /* FIXME: should be platform-specific */
434  break;
435  default:
436  by_val = 0;
437  break;
438  }
439  if (!by_val) stack_size = pointer_size;
440  if (by_value) *by_value = by_val;
441  return ROUND_SIZE( stack_size, pointer_size );
442 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
type_t * type
Definition: widltypes.h:452
attr_list_t * attrs
Definition: widltypes.h:453
unsigned int pointer_size
Definition: widl.c:158
unsigned int type_memsize(const type_t *t)
Definition: typegen.c:1964
#define ROUND_SIZE(size, alignment)
Definition: typegen.c:45

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

◆ get_struct_fc()

unsigned char get_struct_fc ( const type_t type)

Definition at line 478 of file typegen.c.

479 {
480  int has_pointer = 0;
481  int has_conformance = 0;
482  int has_variance = 0;
483  var_t *field;
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().

◆ get_user_type()

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

Definition at line 305 of file typegen.c.

306 {
307  for (;;)
308  {
309  type_t *ut = get_attrp(t->attrs, ATTR_WIREMARSHAL);
310  if (ut)
311  {
312  if (pname)
313  *pname = t->name;
314  return ut;
315  }
316 
317  if (type_is_alias(t))
319  else
320  return NULL;
321  }
322 }
void * get_attrp(const attr_list_t *list, enum attr_type t)
Definition: header.c:107
GLdouble GLdouble t
Definition: gl.h:2047
GLenum pname
Definition: glext.h:5645
static int type_is_alias(const type_t *type)
Definition: typetree.h:274
smooth NULL
Definition: ftsmooth.c:416
static type_t * type_alias_get_aliasee(const type_t *type)
Definition: typetree.h:279

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

◆ guard_rec()

static void guard_rec ( type_t type)
static

Definition at line 824 of file typegen.c.

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

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

◆ is_conformance_needed_for_phase()

static int is_conformance_needed_for_phase ( enum remoting_phase  phase)
inlinestatic

Definition at line 4086 of file typegen.c.

4087 {
4088  return (phase != PHASE_UNMARSHAL);
4089 }

Referenced by write_parameter_conf_or_var_exprs().

◆ is_embedded_complex()

static int is_embedded_complex ( const type_t type)
static

Definition at line 835 of file typegen.c.

836 {
838  {
839  case TGT_USER_TYPE:
840  case TGT_STRUCT:
841  case TGT_UNION:
842  case TGT_ARRAY:
843  case TGT_IFACE_POINTER:
844  return TRUE;
845  default:
846  return FALSE;
847  }
848 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
smooth NULL
Definition: ftsmooth.c:416

Referenced by write_array_element_type(), and write_member_type().

◆ is_full_pointer_function()

int is_full_pointer_function ( const var_t func)

Definition at line 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
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().

◆ is_non_complex_struct()

static int is_non_complex_struct ( const type_t type)
static

Definition at line 697 of file typegen.c.

698 {
699  return (type_get_type(type) == TYPE_STRUCT &&
701 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
unsigned char get_struct_fc(const type_t *type)
Definition: typegen.c:478

Referenced by write_no_repeat_pointer_descriptions(), and write_pointer_description_offsets().

◆ is_user_type()

static int is_user_type ( const type_t t)
static

Definition at line 324 of file typegen.c.

325 {
326  return get_user_type(t, NULL) != NULL;
327 }
static type_t * get_user_type(const type_t *t, const char **pname)
Definition: typegen.c:305
GLdouble GLdouble t
Definition: gl.h:2047
smooth NULL
Definition: ftsmooth.c:416

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

◆ print()

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

Definition at line 879 of file typegen.c.

880 {
881  if (file)
882  {
883  if (format[0] != '\n')
884  while (0 < indent--)
885  fprintf(file, " ");
886  vfprintf(file, format, va);
887  }
888 }
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_file()

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

Definition at line 871 of file typegen.c.

872 {
873  va_list va;
874  va_start(va, format);
875  print(file, indent, format, va);
876  va_end(va);
877 }
static const WCHAR indent[]
Definition: object.c:1156
void print(FILE *file, int indent, const char *format, va_list va)
Definition: typegen.c:879
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: fci.c:126

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

◆ print_phase_basetype()

void print_phase_basetype ( FILE file,
int  indent,
const char local_var_prefix,
enum remoting_phase  phase,
enum pass pass  ,
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().

◆ print_phase_function()

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

Definition at line 3927 of file typegen.c.

3930 {
3931  const char *function;
3932  switch (phase)
3933  {
3934  case PHASE_BUFFERSIZE:
3935  function = "BufferSize";
3936  break;
3937  case PHASE_MARSHAL:
3938  function = "Marshall";
3939  break;
3940  case PHASE_UNMARSHAL:
3941  function = "Unmarshall";
3942  break;
3943  case PHASE_FREE:
3944  function = "Free";
3945  break;
3946  default:
3947  assert(0);
3948  return;
3949  }
3950 
3951  print_file(file, indent, "Ndr%s%s(\n", type, function);
3952  indent++;
3953  print_file(file, indent, "&__frame->_StubMsg,\n");
3954  print_file(file, indent, "%s%s%s%s%s,\n",
3955  (phase == PHASE_UNMARSHAL) ? "(unsigned char **)" : "(unsigned char *)",
3956  (phase == PHASE_UNMARSHAL || decl_indirect(var->type)) ? "&" : "",
3957  local_var_prefix,
3958  (phase == PHASE_UNMARSHAL && decl_indirect(var->type)) ? "_p_" : "",
3959  var->name);
3960  print_file(file, indent, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]%s\n",
3961  type_offset, (phase == PHASE_UNMARSHAL) ? "," : ");");
3962  if (phase == PHASE_UNMARSHAL)
3963  print_file(file, indent, "0);\n");
3964  indent--;
3965 }
static const WCHAR indent[]
Definition: object.c:1156
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
static void print_file(FILE *file, int indent, const char *format,...) __attribute__((format(printf
Definition: typegen.c:871
int decl_indirect(const type_t *t)
Definition: typegen.c:948
type_t * type
Definition: widltypes.h:452
char * name
Definition: widltypes.h:451
Definition: fci.c:126

Referenced by write_remoting_arg().

◆ print_start_tfs_comment()

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

Definition at line 2203 of file typegen.c.

2204 {
2205  print_file(file, 0, "/* %u (", tfsoff);
2207  print_file(file, 0, ") */\n");
2208 }
GLdouble GLdouble t
Definition: gl.h:2047
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
Definition: fci.c:126

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

◆ process_tfs()

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

Definition at line 3734 of file typegen.c.

3735 {
3736  unsigned int typeformat_offset = 2;
3737  for_each_iface(stmts, process_tfs_iface, pred, file, 0, &typeformat_offset);
3738  return typeformat_offset + 1;
3739 }
static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned int *offset)
Definition: typegen.c:3681
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
Definition: fci.c:126

Referenced by get_size_typeformatstring(), and write_typeformatstring().

◆ process_tfs_iface()

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

Definition at line 3681 of file typegen.c.

3682 {
3683  const statement_list_t *stmts = type_iface_get_stmts(iface);
3684  const statement_t *stmt;
3685  var_t *var;
3686 
3687  current_iface = iface;
3688  if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry )
3689  {
3690  switch(stmt->type)
3691  {
3692  case STMT_DECLARATION:
3693  {
3694  const var_t *func = stmt->u.var;
3695 
3696  if(stmt->u.var->stgclass != STG_NONE
3698  continue;
3699 
3700  current_func = func;
3701  if (is_local(func->attrs)) continue;
3702 
3703  var = type_function_get_retval(func->type);
3704  if (!is_void(var->type))
3705  var->typestring_offset = write_type_tfs( file, 2, func->attrs, var->type, func->name,
3707 
3708  if (type_get_function_args(func->type))
3710  var->typestring_offset = write_type_tfs( file, 2, var->attrs, var->type, var->name,
3712  break;
3713 
3714  }
3715  case STMT_TYPEDEF:
3716  {
3717  const type_list_t *type_entry;
3718  for (type_entry = stmt->u.type_list; type_entry; type_entry = type_entry->next)
3719  {
3720  if (is_attr(type_entry->type->attrs, ATTR_ENCODE)
3721  || is_attr(type_entry->type->attrs, ATTR_DECODE))
3722  type_entry->type->typestring_offset = write_type_tfs( file, 2,
3723  type_entry->type->attrs, type_entry->type, type_entry->type->name,
3725  }
3726  break;
3727  }
3728  default:
3729  break;
3730  }
3731  }
3732 }
GLenum func
Definition: glext.h:6028
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:584
var_t * var
Definition: widltypes.h:538
int is_local(const attr_list_t *a)
Definition: header.c:938
GLintptr offset
Definition: glext.h:5920
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101
unsigned int typestring_offset
Definition: widltypes.h:457
enum storage_class stgclass
Definition: widltypes.h:455
unsigned int typestring_offset
Definition: widltypes.h:437
static unsigned int write_type_tfs(FILE *file, int indent, const attr_list_t *attrs, type_t *type, const char *name, enum type_context context, unsigned int *typeformat_offset)
Definition: typegen.c:3571
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
type_t * type
Definition: widltypes.h:526
statement_type_t type
Definition: parser.h:124
union _statement_t::@4054 u
type_t * type
Definition: widltypes.h:452
attr_list_t * attrs
Definition: widltypes.h:421
attr_list_t * attrs
Definition: widltypes.h:453
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:589
const char * name
Definition: widltypes.h:418
uint32_t entry
Definition: isohybrid.c:63
char * name
Definition: widltypes.h:451
type_list_t * type_list
Definition: widltypes.h:540
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
struct _type_list_t * next
Definition: widltypes.h:527
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151
static const var_t * current_func
Definition: typegen.c:50
static const type_t * current_iface
Definition: typegen.c:51
Definition: fci.c:126

Referenced by process_tfs().

◆ processed()

◆ string_of_type()

static const char* string_of_type ( unsigned char  type)
static

Definition at line 101 of file typegen.c.

102 {
103  switch (type)
104  {
105  case FC_BYTE: return "FC_BYTE";
106  case FC_CHAR: return "FC_CHAR";
107  case FC_SMALL: return "FC_SMALL";
108  case FC_USMALL: return "FC_USMALL";
109  case FC_WCHAR: return "FC_WCHAR";
110  case FC_SHORT: return "FC_SHORT";
111  case FC_USHORT: return "FC_USHORT";
112  case FC_LONG: return "FC_LONG";
113  case FC_ULONG: return "FC_ULONG";
114  case FC_FLOAT: return "FC_FLOAT";
115  case FC_HYPER: return "FC_HYPER";
116  case FC_DOUBLE: return "FC_DOUBLE";
117  case FC_ENUM16: return "FC_ENUM16";
118  case FC_ENUM32: return "FC_ENUM32";
119  case FC_IGNORE: return "FC_IGNORE";
120  case FC_ERROR_STATUS_T: return "FC_ERROR_STATUS_T";
121  case FC_RP: return "FC_RP";
122  case FC_UP: return "FC_UP";
123  case FC_OP: return "FC_OP";
124  case FC_FP: return "FC_FP";
125  case FC_ENCAPSULATED_UNION: return "FC_ENCAPSULATED_UNION";
126  case FC_NON_ENCAPSULATED_UNION: return "FC_NON_ENCAPSULATED_UNION";
127  case FC_STRUCT: return "FC_STRUCT";
128  case FC_PSTRUCT: return "FC_PSTRUCT";
129  case FC_CSTRUCT: return "FC_CSTRUCT";
130  case FC_CPSTRUCT: return "FC_CPSTRUCT";
131  case FC_CVSTRUCT: return "FC_CVSTRUCT";
132  case FC_BOGUS_STRUCT: return "FC_BOGUS_STRUCT";
133  case FC_SMFARRAY: return "FC_SMFARRAY";
134  case FC_LGFARRAY: return "FC_LGFARRAY";
135  case FC_SMVARRAY: return "FC_SMVARRAY";
136  case FC_LGVARRAY: return "FC_LGVARRAY";
137  case FC_CARRAY: return "FC_CARRAY";
138  case FC_CVARRAY: return "FC_CVARRAY";
139  case FC_BOGUS_ARRAY: return "FC_BOGUS_ARRAY";
140  case FC_ALIGNM2: return "FC_ALIGNM2";
141  case FC_ALIGNM4: return "FC_ALIGNM4";
142  case FC_ALIGNM8: return "FC_ALIGNM8";
143  case FC_POINTER: return "FC_POINTER";
144  case FC_C_CSTRING: return "FC_C_CSTRING";
145  case FC_C_WSTRING: return "FC_C_WSTRING";
146  case FC_CSTRING: return "FC_CSTRING";
147  case FC_WSTRING: return "FC_WSTRING";
148  case FC_BYTE_COUNT_POINTER: return "FC_BYTE_COUNT_POINTER";
149  case FC_TRANSMIT_AS: return "FC_TRANSMIT_AS";
150  case FC_REPRESENT_AS: return "FC_REPRESENT_AS";
151  case FC_IP: return "FC_IP";
152  case FC_BIND_CONTEXT: return "FC_BIND_CONTEXT";
153  case FC_BIND_GENERIC: return "FC_BIND_GENERIC";
154  case FC_BIND_PRIMITIVE: return "FC_BIND_PRIMITIVE";
155  case FC_AUTO_HANDLE: return "FC_AUTO_HANDLE";
156  case FC_CALLBACK_HANDLE: return "FC_CALLBACK_HANDLE";
157  case FC_STRUCTPAD1: return "FC_STRUCTPAD1";
158  case FC_STRUCTPAD2: return "FC_STRUCTPAD2";
159  case FC_STRUCTPAD3: return "FC_STRUCTPAD3";
160  case FC_STRUCTPAD4: return "FC_STRUCTPAD4";
161  case FC_STRUCTPAD5: return "FC_STRUCTPAD5";
162  case FC_STRUCTPAD6: return "FC_STRUCTPAD6";
163  case FC_STRUCTPAD7: return "FC_STRUCTPAD7";
164  case FC_STRING_SIZED: return "FC_STRING_SIZED";
165  case FC_NO_REPEAT: return "FC_NO_REPEAT";
166  case FC_FIXED_REPEAT: return "FC_FIXED_REPEAT";
167  case FC_VARIABLE_REPEAT: return "FC_VARIABLE_REPEAT";
168  case FC_FIXED_OFFSET: return "FC_FIXED_OFFSET";
169  case FC_VARIABLE_OFFSET: return "FC_VARIABLE_OFFSET";
170  case FC_PP: return "FC_PP";
171  case FC_EMBEDDED_COMPLEX: return "FC_EMBEDDED_COMPLEX";
172  case FC_DEREFERENCE: return "FC_DEREFERENCE";
173  case FC_DIV_2: return "FC_DIV_2";
174  case FC_MULT_2: return "FC_MULT_2";
175  case FC_ADD_1: return "FC_ADD_1";
176  case FC_SUB_1: return "FC_SUB_1";
177  case FC_CALLBACK: return "FC_CALLBACK";
178  case FC_CONSTANT_IID: return "FC_CONSTANT_IID";
179  case FC_END: return "FC_END";
180  case FC_PAD: return "FC_PAD";
181  case FC_USER_MARSHAL: return "FC_USER_MARSHAL";
182  case FC_RANGE: return "FC_RANGE";
183  case FC_INT3264: return "FC_INT3264";
184  case FC_UINT3264: return "FC_UINT3264";
185  default:
186  error("string_of_type: unknown type 0x%02x\n", type);
187  return NULL;
188  }
189 }
#define error(str)
Definition: mkdosfs.c:1605
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
smooth NULL
Definition: ftsmooth.c:416

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

◆ type_buffer_alignment()

static unsigned int type_buffer_alignment ( const type_t t)
static

Definition at line 1970 of file typegen.c.

1971 {
1972  const var_list_t *fields;
1973  const var_t *var;
1974  unsigned int max = 0, align;
1975 
1976  switch (type_get_type(t))
1977  {
1978  case TYPE_BASIC:
1979  switch (get_basic_fc(t))
1980  {
1981  case FC_BYTE:
1982  case FC_CHAR:
1983  case FC_USMALL:
1984  case FC_SMALL:
1985  return 1;
1986  case FC_WCHAR:
1987  case FC_USHORT:
1988  case FC_SHORT:
1989  return 2;
1990  case FC_ULONG:
1991  case FC_LONG:
1992  case FC_ERROR_STATUS_T:
1993  case FC_FLOAT:
1994  case FC_INT3264:
1995  case FC_UINT3264:
1996  return 4;
1997  case FC_HYPER:
1998  case FC_DOUBLE:
1999  return 8;
2000  default:
2001  error("type_buffer_alignment: Unknown type 0x%x\n", get_basic_fc(t));
2002  }
2003  break;
2004  case TYPE_ENUM:
2005  switch (get_enum_fc(t))
2006  {
2007  case FC_ENUM16:
2008  return 2;
2009  case FC_ENUM32:
2010  return 4;
2011  default:
2012  error("type_buffer_alignment: Unknown enum type\n");
2013  }
2014  break;
2015  case TYPE_STRUCT:
2016  if (!(fields = type_struct_get_fields(t))) break;
2017  LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry )
2018  {
2019  if (!var->type) continue;
2020  align = type_buffer_alignment( var->type );
2021  if (max < align) max = align;
2022  }
2023  break;
2025  if (!(fields = type_encapsulated_union_get_fields(t))) break;
2026  LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry )
2027  {
2028  if (!var->type) continue;
2029  align = type_buffer_alignment( var->type );
2030  if (max < align) max = align;
2031  }
2032  break;
2033  case TYPE_UNION:
2034  if (!(fields = type_union_get_cases(t))) break;
2035  LIST_FOR_EACH_ENTRY( var, fields, const var_t, entry )
2036  {
2037  if (!var->type) continue;
2038  align = type_buffer_alignment( var->type );
2039  if (max < align) max = align;
2040  }
2041  break;
2042  case TYPE_ARRAY:
2045  /* else fall through */
2046  case TYPE_POINTER:
2047  return 4;
2048  case TYPE_INTERFACE:
2049  case TYPE_ALIAS:
2050  case TYPE_VOID:
2051  case TYPE_COCLASS:
2052  case TYPE_MODULE:
2053  case TYPE_FUNCTION:
2054  case TYPE_BITFIELD:
2055  /* these types should not be encountered here due to language
2056  * restrictions (interface, void, coclass, module), logical
2057  * restrictions (alias - due to type_get_type call above) or
2058  * checking restrictions (function, bitfield). */
2059  assert(0);
2060  }
2061  return max;
2062 }
#define max(a, b)
Definition: svc.c:63
#define error(str)
Definition: mkdosfs.c:1605
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 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
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
static var_list_t * type_encapsulated_union_get_fields(const type_t *type)
Definition: typetree.h:127
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
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static unsigned int type_buffer_alignment(const type_t *t)
Definition: typegen.c:1970
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 write_array_tfs(), write_struct_tfs(), and write_user_tfs().

◆ type_has_full_pointer()

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

Definition at line 750 of file typegen.c.

752 {
754  {
755  case TGT_USER_TYPE:
756  return FALSE;
757  case TGT_POINTER:
758  if (get_pointer_fc(type, attrs, toplevel_param) == FC_FP)
759  return TRUE;
760  else
761  return FALSE;
762  case TGT_ARRAY:
763  if (get_pointer_fc(type, attrs, toplevel_param) == FC_FP)
764  return TRUE;
765  else
767  case TGT_STRUCT:
768  {
770  const var_t *field;
771  if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
772  {
773  if (type_has_full_pointer(field->type, field->attrs, FALSE))
774  return TRUE;
775  }
776  break;
777  }
778  case TGT_UNION:
779  {
780  var_list_t *fields;
781  const var_t *field;
782  fields = type_union_get_cases(type);
783  if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
784  {
785  if (field->type && type_has_full_pointer(field->type, field->attrs, FALSE))
786  return TRUE;
787  }
788  break;
789  }
790  case TGT_CTXT_HANDLE:
792  case TGT_STRING:
793  case TGT_IFACE_POINTER:
794  case TGT_BASIC:
795  case TGT_ENUM:
796  case TGT_RANGE:
797  case TGT_INVALID:
798  break;
799  }
800 
801  return FALSE;
802 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
#define TRUE
Definition: types.h:120
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
static var_list_t * type_union_get_cases(const type_t *type)
Definition: typetree.h:134
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:43
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs, int toplevel_param)
Definition: typegen.c:750

Referenced by is_full_pointer_function().

◆ type_has_pointers()

static int type_has_pointers ( const type_t type)
static

Definition at line 703 of file typegen.c.

704 {
706  {
707  case TGT_USER_TYPE:
708  return FALSE;
709  case TGT_POINTER:
710  return TRUE;
711  case TGT_ARRAY:
713  case TGT_STRUCT:
714  {
716  const var_t *field;
717  if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
718  {
720  return TRUE;
721  }
722  break;
723  }
724  case TGT_UNION:
725  {
726  var_list_t *fields;
727  const var_t *field;
728  fields = type_union_get_cases(type);
729  if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
730  {
732  return TRUE;
733  }
734  break;
735  }
736  case TGT_CTXT_HANDLE:
738  case TGT_STRING:
739  case TGT_IFACE_POINTER:
740  case TGT_BASIC:
741  case TGT_ENUM:
742  case TGT_RANGE:
743  case TGT_INVALID:
744  break;
745  }
746 
747  return FALSE;
748 }
enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags)
Definition: typegen.c:329
#define TRUE
Definition: types.h:120
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 var_list_t * type_union_get_cases(const type_t *type)
Definition: typetree.h:134
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: typegen.h:57</