Robert Shearman | 35d327b | 2005-12-08 12:52:13 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Format String Generator for IDL Compiler |
| 3 | * |
Eric Kohl | 1550938 | 2006-03-23 10:33:08 +0100 | [diff] [blame] | 4 | * Copyright 2005-2006 Eric Kohl |
Robert Shearman | 35d327b | 2005-12-08 12:52:13 +0100 | [diff] [blame] | 5 | * 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 Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Robert Shearman | 35d327b | 2005-12-08 12:52:13 +0100 | [diff] [blame] | 20 | */ |
| 21 | |
Dan Hipschman | e36981e | 2007-06-14 18:29:33 -0700 | [diff] [blame] | 22 | #include <stdarg.h> |
Robert Shearman | 35d327b | 2005-12-08 12:52:13 +0100 | [diff] [blame] | 23 | |
Robert Shearman | 7e5cf94 | 2005-12-26 13:14:28 +0100 | [diff] [blame] | 24 | enum pass |
| 25 | { |
| 26 | PASS_IN, |
| 27 | PASS_OUT, |
| 28 | PASS_RETURN |
| 29 | }; |
| 30 | |
Robert Shearman | 55df46a | 2006-02-07 12:32:24 +0100 | [diff] [blame] | 31 | enum remoting_phase |
| 32 | { |
| 33 | PHASE_BUFFERSIZE, |
| 34 | PHASE_MARSHAL, |
| 35 | PHASE_UNMARSHAL, |
| 36 | PHASE_FREE |
| 37 | }; |
| 38 | |
Rob Shearman | 2c6e611 | 2009-02-23 13:48:46 +0000 | [diff] [blame] | 39 | enum typegen_detect_flags |
| 40 | { |
| 41 | TDT_ALL_TYPES = 1 << 0, |
| 42 | TDT_IGNORE_STRINGS = 1 << 1, |
Rob Shearman | 8e750b0 | 2009-11-12 10:31:25 +0000 | [diff] [blame] | 43 | TDT_IGNORE_RANGES = 1 << 2, |
Rob Shearman | 2c6e611 | 2009-02-23 13:48:46 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | enum 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 Shearman | 2b3659f | 2009-11-07 15:54:28 +0100 | [diff] [blame] | 60 | TGT_RANGE, |
Rob Shearman | 2c6e611 | 2009-02-23 13:48:46 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
Dan Hipschman | f173add | 2007-10-15 18:06:33 -0700 | [diff] [blame] | 63 | typedef int (*type_pred_t)(const type_t *); |
| 64 | |
Rob Shearman | df0e38c | 2008-04-24 19:06:28 +0100 | [diff] [blame] | 65 | void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred); |
| 66 | void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); |
| 67 | void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); |
Alexandre Julliard | 3593b65 | 2010-10-22 20:46:00 +0200 | [diff] [blame] | 68 | void write_procformatstring_offsets( FILE *file, const type_t *iface ); |
Alexandre Julliard | bf011b0 | 2008-09-15 16:46:01 +0200 | [diff] [blame] | 69 | void 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 Julliard | 0d76bb7 | 2011-07-27 16:04:22 +0200 | [diff] [blame] | 71 | void 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 Shearman | 901a42b | 2009-01-05 23:33:27 +0000 | [diff] [blame] | 73 | void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix, |
Alexandre Julliard | bf011b0 | 2008-09-15 16:46:01 +0200 | [diff] [blame] | 74 | enum pass pass, enum remoting_phase phase); |
Alexandre Julliard | 11416a2 | 2011-06-01 21:06:14 +0200 | [diff] [blame] | 75 | unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func); |
Alexandre Julliard | ef6971d | 2009-02-06 14:30:38 +0100 | [diff] [blame] | 76 | unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred); |
| 77 | unsigned int get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred); |
Rob Shearman | 901a42b | 2009-01-05 23:33:27 +0000 | [diff] [blame] | 78 | void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char *local_var_prefix ); |
| 79 | void declare_stub_args( FILE *file, int indent, const var_t *func ); |
Alexandre Julliard | 59171bd | 2011-06-09 11:42:21 +0200 | [diff] [blame] | 80 | void write_func_param_struct( FILE *file, const type_t *iface, const type_t *func, |
| 81 | const char *var_decl, int add_retval ); |
Alexandre Julliard | c173399 | 2011-06-14 12:55:39 +0200 | [diff] [blame] | 82 | void write_pointer_checks( FILE *file, int indent, const var_t *func ); |
Robert Shearman | b59c995 | 2006-01-27 12:53:32 +0100 | [diff] [blame] | 83 | int write_expr_eval_routines(FILE *file, const char *iface); |
| 84 | void write_expr_eval_routine_list(FILE *file, const char *iface); |
Dan Hipschman | c0982b4 | 2007-06-13 16:13:04 -0700 | [diff] [blame] | 85 | void write_user_quad_list(FILE *file); |
Alexandre Julliard | 94ee8e8 | 2007-02-07 17:55:09 +0100 | [diff] [blame] | 86 | void write_endpoints( FILE *f, const char *prefix, const str_list_t *list ); |
Alexandre Julliard | 9f99d74 | 2011-06-09 10:12:48 +0200 | [diff] [blame] | 87 | void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func, |
| 88 | const char *prefix, unsigned int proc_offset ); |
Alexandre Julliard | 3bdaba2 | 2008-09-15 14:05:26 +0200 | [diff] [blame] | 89 | void write_exceptions( FILE *file ); |
Alexandre Julliard | cb6a225 | 2010-04-05 19:48:07 +0200 | [diff] [blame] | 90 | unsigned int type_memsize(const type_t *t); |
Dan Hipschman | c0982b4 | 2007-06-13 16:13:04 -0700 | [diff] [blame] | 91 | int decl_indirect(const type_t *t); |
Alexandre Julliard | 0486140 | 2011-05-28 13:38:25 +0200 | [diff] [blame] | 92 | int is_interpreted_func(const type_t *iface, const var_t *func); |
Rob Shearman | 901a42b | 2009-01-05 23:33:27 +0000 | [diff] [blame] | 93 | void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix); |
Dan Hipschman | e36981e | 2007-06-14 18:29:33 -0700 | [diff] [blame] | 94 | void print(FILE *file, int indent, const char *format, va_list ap); |
Dan Hipschman | b0bc8e5 | 2007-11-02 15:25:26 -0700 | [diff] [blame] | 95 | expr_t *get_size_is_expr(const type_t *t, const char *name); |
Rob Shearman | 901a42b | 2009-01-05 23:33:27 +0000 | [diff] [blame] | 96 | int is_full_pointer_function(const var_t *func); |
| 97 | void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server); |
| 98 | void write_full_pointer_free(FILE *file, int indent, const var_t *func); |
Rob Shearman | 728a738 | 2009-03-07 23:24:00 +0000 | [diff] [blame] | 99 | unsigned char get_basic_fc(const type_t *type); |
Rob Shearman | 23673ca | 2009-03-07 23:23:44 +0000 | [diff] [blame] | 100 | unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param); |
Rob Shearman | af08007 | 2009-02-23 13:48:34 +0000 | [diff] [blame] | 101 | unsigned char get_struct_fc(const type_t *type); |
Rob Shearman | 2c6e611 | 2009-02-23 13:48:46 +0000 | [diff] [blame] | 102 | enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags); |