types refactoring
[m6w6/ext-psi] / src / types / decl_type.h
index 8cbb2fcbcffac1f9a99770e2ad0ccefa2d705867..d7c01fb31eac36f5d029e6367bd476c80900e2ab 100644 (file)
@@ -1,7 +1,32 @@
-#ifndef _PSI_TYPES_DECL_TYPE_H
-#define _PSI_TYPES_DECL_TYPE_H
+/*******************************************************************************
+ Copyright (c) 2016, Michael Wallner <mike@php.net>.
+ All rights reserved.
 
-#include "parser_proc.h"
+ 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_TYPE_H
+#define PSI_TYPES_DECL_TYPE_H
+
+#include "token.h"
 
 typedef struct decl_type {
        struct psi_token *token;
@@ -16,24 +41,33 @@ typedef struct decl_type {
        } real;
 } decl_type;
 
-static inline decl_type *init_decl_type(token_t type, const char *name) {
-       decl_type *t = calloc(1, sizeof(*t));
-       t->type = type;
-       t->name = strdup(name);
-       return t;
-}
-
-static inline void free_decl(struct decl *decl);
-static inline void free_decl_type(decl_type *type) {
-       if (type->token) {
-               free(type->token);
-       }
-       if (type->type == PSI_T_FUNCTION) {
-               free_decl(type->real.func);
-       }
-       free(type->name);
-       free(type);
-}
+#include <string.h>
+#define is_anon_type(name, type) !strncmp(name, type "@", sizeof(type))
+
+decl_type *init_decl_type(token_t type, const char *name);
+void free_decl_type(decl_type *type);
+void dump_decl_type(int fd, decl_type *t, unsigned level);
+
+struct decl_args *extract_decl_type_args(decl_type *dtyp, decl_type** real_typ_ptr);
+int weak_decl_type(decl_type *type);
+decl_type *real_decl_type(decl_type *type);
+
+struct decl_typedefs;
+struct decl_structs;
+struct decl_unions;
+struct decl_enums;
+struct decls;
+
+int locate_decl_type_alias(struct decl_typedefs *defs, decl_type *type);
+int locate_decl_type_struct(struct decl_structs *structs, decl_type *type);
+int locate_decl_type_union(struct decl_unions *unions, decl_type *type);
+int locate_decl_type_enum(struct decl_enums *enums, decl_type *type);
+int locate_decl_type_decl(struct decls *decls, decl_type *type);
+
+struct psi_data;
+
+int validate_decl_type(struct psi_data *data, decl_type *type, struct decl_arg *def);
 
+size_t alignof_decl_type(decl_type *t);
 
 #endif