paul@28 | 1 | /* |
paul@28 | 2 | * Parser definitions. |
paul@28 | 3 | * |
paul@214 | 4 | * Copyright (C) 2019, 2022 Paul Boddie <paul@boddie.org.uk> |
paul@28 | 5 | * |
paul@28 | 6 | * This program is free software; you can redistribute it and/or |
paul@28 | 7 | * modify it under the terms of the GNU General Public License as |
paul@28 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@28 | 9 | * the License, or (at your option) any later version. |
paul@28 | 10 | * |
paul@28 | 11 | * This program is distributed in the hope that it will be useful, |
paul@28 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@28 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@28 | 14 | * GNU General Public License for more details. |
paul@28 | 15 | * |
paul@28 | 16 | * You should have received a copy of the GNU General Public License |
paul@28 | 17 | * along with this program; if not, write to the Free Software |
paul@28 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@28 | 19 | * Boston, MA 02110-1301, USA |
paul@28 | 20 | */ |
paul@28 | 21 | |
paul@15 | 22 | #pragma once |
paul@15 | 23 | |
paul@15 | 24 | #include "types.h" |
paul@15 | 25 | |
paul@15 | 26 | /* Value copying, avoiding problems with retaining values in structures. */ |
paul@15 | 27 | |
paul@15 | 28 | void *copy(void *value); |
paul@21 | 29 | |
paul@21 | 30 | /* Specialised copying. */ |
paul@21 | 31 | |
paul@51 | 32 | #define copy_attribute(in) (struct attribute *) copy(&in); |
paul@51 | 33 | #define copy_identifier(in) (struct identifier *) copy(&in); |
paul@214 | 34 | #define copy_import(in) (struct import *) copy(&in); |
paul@51 | 35 | #define copy_include(in) (struct include *) copy(&in); |
paul@33 | 36 | #define copy_interface(in) (struct interface *) copy(&in); |
paul@214 | 37 | #define copy_interface_ref(in) (struct interface_ref *) copy(&in); |
paul@51 | 38 | #define copy_parameter(in) (struct parameter *) copy(&in); |
paul@51 | 39 | #define copy_signature(in) (struct signature *) copy(&in); |
paul@21 | 40 | |
paul@51 | 41 | /* Generalised copying to structures with tail members. */ |
paul@21 | 42 | |
paul@15 | 43 | #define copy_tail(type, out, in) out.tail = (struct type *) copy(&in) |