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, |
| 43 | }; |
| 44 | |
| 45 | enum typegen_type |
| 46 | { |
| 47 | TGT_INVALID, |
| 48 | TGT_USER_TYPE, |
| 49 | TGT_CTXT_HANDLE, |
| 50 | TGT_CTXT_HANDLE_POINTER, |
| 51 | TGT_STRING, |
| 52 | TGT_POINTER, |
| 53 | TGT_ARRAY, |
| 54 | TGT_IFACE_POINTER, |
| 55 | TGT_BASIC, |
| 56 | TGT_ENUM, |
| 57 | TGT_STRUCT, |
| 58 | TGT_UNION, |
| 59 | }; |
| 60 | |
Dan Hipschman | f173add | 2007-10-15 18:06:33 -0700 | [diff] [blame] | 61 | typedef int (*type_pred_t)(const type_t *); |
| 62 | |
Rob Shearman | df0e38c | 2008-04-24 19:06:28 +0100 | [diff] [blame] | 63 | void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred); |
| 64 | void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); |
| 65 | void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); |
Alexandre Julliard | bf011b0 | 2008-09-15 16:46:01 +0200 | [diff] [blame] | 66 | void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase, |
| 67 | enum pass pass, const var_t *var, const char *varname); |
Rob Shearman | 901a42b | 2009-01-05 23:33:27 +0000 | [diff] [blame] | 68 | 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] | 69 | enum pass pass, enum remoting_phase phase); |
Alexandre Julliard | ef6971d | 2009-02-06 14:30:38 +0100 | [diff] [blame] | 70 | unsigned int get_size_procformatstring_type(const char *name, const type_t *type, const attr_list_t *attrs); |
| 71 | unsigned int get_size_procformatstring_func(const var_t *func); |
| 72 | unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred); |
| 73 | 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] | 74 | void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char *local_var_prefix ); |
| 75 | void declare_stub_args( FILE *file, int indent, const var_t *func ); |
Robert Shearman | b59c995 | 2006-01-27 12:53:32 +0100 | [diff] [blame] | 76 | int write_expr_eval_routines(FILE *file, const char *iface); |
| 77 | void write_expr_eval_routine_list(FILE *file, const char *iface); |
Dan Hipschman | c0982b4 | 2007-06-13 16:13:04 -0700 | [diff] [blame] | 78 | void write_user_quad_list(FILE *file); |
Alexandre Julliard | 94ee8e8 | 2007-02-07 17:55:09 +0100 | [diff] [blame] | 79 | void write_endpoints( FILE *f, const char *prefix, const str_list_t *list ); |
Alexandre Julliard | 3bdaba2 | 2008-09-15 14:05:26 +0200 | [diff] [blame] | 80 | void write_exceptions( FILE *file ); |
Alexandre Julliard | ef6971d | 2009-02-06 14:30:38 +0100 | [diff] [blame] | 81 | unsigned int type_memsize(const type_t *t, unsigned int *align); |
Dan Hipschman | c0982b4 | 2007-06-13 16:13:04 -0700 | [diff] [blame] | 82 | int decl_indirect(const type_t *t); |
Rob Shearman | 901a42b | 2009-01-05 23:33:27 +0000 | [diff] [blame] | 83 | 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] | 84 | void print(FILE *file, int indent, const char *format, va_list ap); |
Dan Hipschman | 5e84eb9 | 2007-09-13 18:04:32 -0700 | [diff] [blame] | 85 | int get_padding(const var_list_t *fields); |
Dan Hipschman | 132f06c | 2007-09-18 15:29:59 -0700 | [diff] [blame] | 86 | int is_user_type(const type_t *t); |
Dan Hipschman | b0bc8e5 | 2007-11-02 15:25:26 -0700 | [diff] [blame] | 87 | 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] | 88 | int is_full_pointer_function(const var_t *func); |
| 89 | void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server); |
| 90 | 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^] | 91 | unsigned char get_basic_fc(const type_t *type); |
Rob Shearman | 23673ca | 2009-03-07 23:23:44 +0000 | [diff] [blame] | 92 | 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] | 93 | unsigned char get_struct_fc(const type_t *type); |
Rob Shearman | 2c6e611 | 2009-02-23 13:48:46 +0000 | [diff] [blame] | 94 | enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags); |