X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Fdecl_enum_item.h;h=c465ed1cab46dce6db2b5c070fa40214975606bd;hb=09529efcde471127419e141807b83b37077003a0;hp=3b976dea2c0d33c94e83a17807a22d83313ed457;hpb=5359ad5c181e5772f350fe1cba060cbed3a05b91;p=m6w6%2Fext-psi diff --git a/src/types/decl_enum_item.h b/src/types/decl_enum_item.h index 3b976de..c465ed1 100644 --- a/src/types/decl_enum_item.h +++ b/src/types/decl_enum_item.h @@ -1,31 +1,48 @@ -#ifndef _PSI_TYPES_DECL_ENUM_ITEM_H -#define _PSI_TYPES_DECL_ENUM_ITEM_H +/******************************************************************************* + Copyright (c) 2016, Michael Wallner . + All rights reserved. -typedef struct decl_enum_item { + 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_ITEM_H +#define PSI_TYPES_DECL_ENUM_ITEM_H + +struct psi_data; +struct psi_token; +struct psi_num_exp; +struct psi_decl_enum; + +struct psi_decl_enum_item { struct psi_token *token; - char *name; - num_exp *num; - num_exp inc; - struct decl_enum_item *prev; -} decl_enum_item; - -static inline decl_enum_item *init_decl_enum_item(const char *name, num_exp *num) { - decl_enum_item *i = calloc(1, sizeof(*i)); - - i->name = strdup(name); - i->num = num; - return i; -} - -static inline void free_decl_enum_item(decl_enum_item *i) { - if (i->token) { - free(i->token); - } - if (i->num && i->num != &i->inc) { - free_num_exp(i->num); - } - free(i->name); - free(i); -} + zend_string *name; + int64_t val; + struct psi_num_exp inc; + struct psi_num_exp *num; + struct psi_decl_enum_item *prev; +}; + +struct psi_decl_enum_item *psi_decl_enum_item_init(zend_string *name, struct psi_num_exp *num); +void psi_decl_enum_item_free(struct psi_decl_enum_item **i_ptr); +void psi_decl_enum_item_dump(int fd, struct psi_decl_enum_item *item); +bool psi_decl_enum_item_validate(struct psi_data *data, struct psi_decl_enum *enm, struct psi_decl_enum_item *item, size_t seq); #endif