1 /* 2 * Common routines. 3 * 4 * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <stdio.h> 25 #include "types.h" 26 27 /* Error message generation. */ 28 29 void open_error(const char *dir, const char *name); 30 31 /* Filename manipulation. */ 32 33 char *make_basename(const char *path); 34 char *make_dirname(const char *path); 35 36 /* File opening. */ 37 38 FILE *get_output_file(const char *filename_template, const char *dir, const char *name); 39 40 /* Interface attribute access. */ 41 42 char *get_attribute_value(struct attribute *attr, const char *name); 43 char *get_opcode(struct attribute *attr); 44 char *get_protocol(struct attribute *attr); 45 char *get_operation_wrapper_prefix(struct attribute *attr); 46 int have_attribute(struct attribute *attr, const char *name); 47 int have_attribute_value(struct attribute *attr, const char *name, const char *value); 48 int have_identifier(struct identifier *ident, const char *value); 49 50 /* Dispatcher object conversion (from compound to individual interfaces). */ 51 52 char *get_object_conversion(struct interface *iface, int compound); 53 54 /* Interface and operation naming. */ 55 56 char *get_interface_class_name(struct interface *iface, 57 enum component_role component); 58 59 char *get_signature_operation_name(struct interface *iface, 60 struct signature *sig, 61 enum component_role component, 62 enum signature_role role, 63 enum language lang); 64 65 char *get_operation_name(struct interface *iface, struct signature *sig); 66 char *get_opcode_identifier(char *protocol, char *opname); 67 68 const char *get_parameter_decoration(struct parameter *param, 69 enum parameter_role role, 70 enum function_role function); 71 72 char *get_parameter_name(struct identifier *ident); 73 char *get_signature_terminator(enum signature_role role); 74 75 void count_parameters(struct parameter *param, int *input_words, 76 int *input_items, int *output_words, int *output_items); 77 78 int get_max_input_items(struct signature *sig); 79 80 /* Message access details. */ 81 82 char *access_name(struct parameter *param, enum component_role component); 83 char *item_type_name(struct parameter *param); 84 char *reference_message(enum component_role component, enum function_role function); 85 char *structure_prefix(enum specifier direction); 86 int writing_to_message(enum component_role component, enum specifier direction);