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