X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Ftypes%2Fdecl_enum.h;h=69d1ee4be4150a3feab7d3befba9339a2bf02a9d;hp=4a616afc998a764d6a1d0264cddc4c68572ae1cf;hb=2f5af21b263403997e154658635d6b6e6eaab453;hpb=5359ad5c181e5772f350fe1cba060cbed3a05b91 diff --git a/src/types/decl_enum.h b/src/types/decl_enum.h index 4a616af..69d1ee4 100644 --- a/src/types/decl_enum.h +++ b/src/types/decl_enum.h @@ -1,5 +1,33 @@ -#ifndef _PSI_TYPES_DECL_ENUM_H -#define _PSI_TYPES_DECL_ENUM_H +/******************************************************************************* + Copyright (c) 2016, Michael Wallner . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifndef PSI_TYPES_DECL_ENUM_H +#define PSI_TYPES_DECL_ENUM_H + +#include "token.h" +#include "decl_enum_items.h" typedef struct decl_enum { struct psi_token *token; @@ -7,23 +35,12 @@ typedef struct decl_enum { decl_enum_items *items; } decl_enum; -static inline decl_enum *init_decl_enum(const char *name, decl_enum_items *l) { - decl_enum *e = calloc(1, sizeof(*e)); - - e->name = strdup(name); - e->items = l; - return e; -} - -static inline void free_decl_enum(decl_enum *e) { - if (e->token) { - free(e->token); - } - if (e->items) { - free_decl_enum_items(e->items); - } - free(e->name); - free(e); -} +decl_enum *init_decl_enum(const char *name, decl_enum_items *l); +void free_decl_enum(decl_enum *e); +void dump_decl_enum(int fd, decl_enum *e, unsigned level); + +struct psi_data; + +int validate_decl_enum(struct psi_data *data, decl_enum *e); #endif