blob: b6540e28c41093727991a366a0f0cfcabd6464cd [file] [log] [blame]
Robert Shearman35d327b2005-12-08 12:52:13 +01001/*
2 * Format String Generator for IDL Compiler
3 *
Eric Kohl15509382006-03-23 10:33:08 +01004 * Copyright 2005-2006 Eric Kohl
Robert Shearman35d327b2005-12-08 12:52:13 +01005 * Copyright 2005 Robert Shearman
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
Jonathan Ernst360a3f92006-05-18 14:49:52 +020019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Robert Shearman35d327b2005-12-08 12:52:13 +010020 */
21
Dan Hipschmane36981e2007-06-14 18:29:33 -070022#include <stdarg.h>
Robert Shearman35d327b2005-12-08 12:52:13 +010023
Robert Shearman7e5cf942005-12-26 13:14:28 +010024enum pass
25{
26 PASS_IN,
27 PASS_OUT,
28 PASS_RETURN
29};
30
Robert Shearman55df46a2006-02-07 12:32:24 +010031enum remoting_phase
32{
33 PHASE_BUFFERSIZE,
34 PHASE_MARSHAL,
35 PHASE_UNMARSHAL,
36 PHASE_FREE
37};
38
Rob Shearman2c6e6112009-02-23 13:48:46 +000039enum typegen_detect_flags
40{
41 TDT_ALL_TYPES = 1 << 0,
42 TDT_IGNORE_STRINGS = 1 << 1,
Rob Shearman8e750b02009-11-12 10:31:25 +000043 TDT_IGNORE_RANGES = 1 << 2,
Rob Shearman2c6e6112009-02-23 13:48:46 +000044};
45
46enum typegen_type
47{
48 TGT_INVALID,
49 TGT_USER_TYPE,
50 TGT_CTXT_HANDLE,
51 TGT_CTXT_HANDLE_POINTER,
52 TGT_STRING,
53 TGT_POINTER,
54 TGT_ARRAY,
55 TGT_IFACE_POINTER,
56 TGT_BASIC,
57 TGT_ENUM,
58 TGT_STRUCT,
59 TGT_UNION,
Rob Shearman2b3659f2009-11-07 15:54:28 +010060 TGT_RANGE,
Rob Shearman2c6e6112009-02-23 13:48:46 +000061};
62
Dan Hipschmanf173add2007-10-15 18:06:33 -070063typedef int (*type_pred_t)(const type_t *);
64
Rob Shearmandf0e38c2008-04-24 19:06:28 +010065void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred);
66void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred);
67void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred);
Alexandre Julliard3593b652010-10-22 20:46:00 +020068void write_procformatstring_offsets( FILE *file, const type_t *iface );
Alexandre Julliardbf011b02008-09-15 16:46:01 +020069void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase,
70 enum pass pass, const var_t *var, const char *varname);
Alexandre Julliard0d76bb72011-07-27 16:04:22 +020071void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char *local_var_prefix,
72 enum remoting_phase phase, const var_t *var, int valid_variance);
Rob Shearman901a42b2009-01-05 23:33:27 +000073void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix,
Alexandre Julliardbf011b02008-09-15 16:46:01 +020074 enum pass pass, enum remoting_phase phase);
Alexandre Julliard11416a22011-06-01 21:06:14 +020075unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func);
Alexandre Julliardef6971d2009-02-06 14:30:38 +010076unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred);
77unsigned int get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred);
Rob Shearman901a42b2009-01-05 23:33:27 +000078void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char *local_var_prefix );
79void declare_stub_args( FILE *file, int indent, const var_t *func );
Alexandre Julliard59171bd2011-06-09 11:42:21 +020080void write_func_param_struct( FILE *file, const type_t *iface, const type_t *func,
81 const char *var_decl, int add_retval );
Alexandre Julliardc1733992011-06-14 12:55:39 +020082void write_pointer_checks( FILE *file, int indent, const var_t *func );
Robert Shearmanb59c9952006-01-27 12:53:32 +010083int write_expr_eval_routines(FILE *file, const char *iface);
84void write_expr_eval_routine_list(FILE *file, const char *iface);
Dan Hipschmanc0982b42007-06-13 16:13:04 -070085void write_user_quad_list(FILE *file);
Alexandre Julliard94ee8e82007-02-07 17:55:09 +010086void write_endpoints( FILE *f, const char *prefix, const str_list_t *list );
Alexandre Julliard9f99d742011-06-09 10:12:48 +020087void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func,
88 const char *prefix, unsigned int proc_offset );
Alexandre Julliard3bdaba22008-09-15 14:05:26 +020089void write_exceptions( FILE *file );
Alexandre Julliardcb6a2252010-04-05 19:48:07 +020090unsigned int type_memsize(const type_t *t);
Dan Hipschmanc0982b42007-06-13 16:13:04 -070091int decl_indirect(const type_t *t);
Alexandre Julliard04861402011-05-28 13:38:25 +020092int is_interpreted_func(const type_t *iface, const var_t *func);
Rob Shearman901a42b2009-01-05 23:33:27 +000093void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix);
Dan Hipschmane36981e2007-06-14 18:29:33 -070094void print(FILE *file, int indent, const char *format, va_list ap);
Dan Hipschmanb0bc8e52007-11-02 15:25:26 -070095expr_t *get_size_is_expr(const type_t *t, const char *name);
Rob Shearman901a42b2009-01-05 23:33:27 +000096int is_full_pointer_function(const var_t *func);
97void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server);
98void write_full_pointer_free(FILE *file, int indent, const var_t *func);
Rob Shearman728a7382009-03-07 23:24:00 +000099unsigned char get_basic_fc(const type_t *type);
Rob Shearman23673ca2009-03-07 23:23:44 +0000100unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param);
Rob Shearmanaf080072009-02-23 13:48:34 +0000101unsigned char get_struct_fc(const type_t *type);
Rob Shearman2c6e6112009-02-23 13:48:46 +0000102enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags);