#!/usr/bin/env python3
#
# VK
#
# Copyright (C) 2014 LunarG, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import argparse
import os
import sys
from source_line_info import sourcelineinfo

# vk_helper.py overview
# This script generates code based on vulkan input header
#  It generate wrappers functions that can be used to display
#  structs in a human-readable txt format, as well as utility functions
#  to print enum values as strings

def handle_args():
    parser = argparse.ArgumentParser(description='Perform analysis of vogl trace.')
    parser.add_argument('input_file', help='The input header file from which code will be generated.')
    parser.add_argument('--rel_out_dir', required=False, default='glave_gen', help='Path relative to exec path to write output files. Will be created if needed.')
    parser.add_argument('--abs_out_dir', required=False, default=None, help='Absolute path to write output files. Will be created if needed.')
    parser.add_argument('--gen_enum_string_helper', required=False, action='store_true', default=False, help='Enable generation of helper header file to print string versions of enums.')
    parser.add_argument('--gen_struct_wrappers', required=False, action='store_true', default=False, help='Enable generation of struct wrapper classes.')
    parser.add_argument('--gen_cmake', required=False, action='store_true', default=False, help='Enable generation of cmake file for generated code.')
    parser.add_argument('--gen_graphviz', required=False, action='store_true', default=False, help='Enable generation of graphviz dot file.')
    #parser.add_argument('--test', action='store_true', default=False, help='Run simple test.')
    return parser.parse_args()

# TODO : Ideally these data structs would be opaque to user and could be wrapped
#   in their own class(es) to make them friendly for data look-up
# Dicts for Data storage
# enum_val_dict[value_name] = dict keys are the string enum value names for all enums
#    |-------->['type'] = the type of enum class into which the value falls
#    |-------->['val'] = the value assigned to this particular value_name
#    '-------->['unique'] = bool designating if this enum 'val' is unique within this enum 'type'
enum_val_dict = {}
# enum_type_dict['type'] = the type or class of of enum
#  '----->['val_name1', 'val_name2'...] = each type references a list of val_names within this type
enum_type_dict = {}
# struct_dict['struct_basename'] = the base (non-typedef'd) name of the struct
#  |->[<member_num>] = members are stored via their integer placement in the struct
#  |    |->['name'] = string name of this struct member
# ...   |->['full_type'] = complete type qualifier for this member
#       |->['type'] = base type for this member
#       |->['ptr'] = bool indicating if this member is ptr
#       |->['const'] = bool indicating if this member is const
#       |->['struct'] = bool indicating if this member is a struct type
#       |->['array'] = bool indicating if this member is an array
#       |->['dyn_array'] = bool indicating if member is a dynamically sized array
#       '->['array_size'] = For dyn_array, member name used to size array, else int size for static array
struct_dict = {}
# typedef_fwd_dict stores mapping from orig_type_name -> new_type_name
typedef_fwd_dict = {}
# typedef_rev_dict stores mapping from new_type_name -> orig_type_name
typedef_rev_dict = {} # store new_name -> orig_name mapping
# types_dict['id_name'] = identifier name will map to it's type
#              '---->'type' = currently either 'struct' or 'enum'
types_dict = {}   # store orig_name -> type mapping


# Class that parses header file and generates data structures that can
#  Then be used for other tasks
class HeaderFileParser:
    def __init__(self, header_file=None):
        self.header_file = header_file
        # store header data in various formats, see above for more info
        self.enum_val_dict = {}
        self.enum_type_dict = {}
        self.struct_dict = {}
        self.typedef_fwd_dict = {}
        self.typedef_rev_dict = {}
        self.types_dict = {}
        self.last_struct_count_name = ''
        
    def setHeaderFile(self, header_file):
        self.header_file = header_file

    def get_enum_val_dict(self):
        return self.enum_val_dict

    def get_enum_type_dict(self):
        return self.enum_type_dict

    def get_struct_dict(self):
        return self.struct_dict

    def get_typedef_fwd_dict(self):
        return self.typedef_fwd_dict

    def get_typedef_rev_dict(self):
        return self.typedef_rev_dict

    def get_types_dict(self):
        return self.types_dict

    # Parse header file into data structures
    def parse(self):
        # parse through the file, identifying different sections
        parse_enum = False
        parse_struct = False
        member_num = 0
        # TODO : Comment parsing is very fragile but handles 2 known files
        block_comment = False
        prev_count_name = ''
        with open(self.header_file) as f:
            for line in f:
                if block_comment:
                    if '*/' in line:
                        block_comment = False
                    continue
                if '/*' in line:
                    block_comment = True
                elif 0 == len(line.split()):
                    #print("Skipping empty line")
                    continue
                elif line.split()[0].strip().startswith("//"):
                    #print("Skipping commented line %s" % line)
                    continue
                elif 'typedef enum' in line:
                    (ty_txt, en_txt, base_type) = line.strip().split(None, 2)
                    #print("Found ENUM type %s" % base_type)
                    parse_enum = True
                    default_enum_val = 0
                    self.types_dict[base_type] = 'enum'
                elif 'typedef struct' in line:
                    (ty_txt, st_txt, base_type) = line.strip().split(None, 2)
                    #print("Found STRUCT type: %s" % base_type)
                    parse_struct = True
                    self.types_dict[base_type] = 'struct'
                elif 'typedef union' in line:
                    (ty_txt, st_txt, base_type) = line.strip().split(None, 2)
                    #print("Found UNION type: %s" % base_type)
                    parse_struct = True
                    self.types_dict[base_type] = 'struct'
                elif '}' in line and (parse_enum or parse_struct):
                    if len(line.split()) > 1: # deals with embedded union in one struct
                        parse_enum = False
                        parse_struct = False
                        self.last_struct_count_name = ''
                        member_num = 0
                        (cur_char, targ_type) = line.strip().split(None, 1)
                        self.typedef_fwd_dict[base_type] = targ_type.strip(';')
                        self.typedef_rev_dict[targ_type.strip(';')] = base_type
                        #print("fwd_dict: %s = %s" % (base_type, targ_type))
                elif parse_enum:
                    #if 'VK_MAX_ENUM' not in line and '{' not in line:
                    if True not in [ens in line for ens in ['{', 'VK_MAX_ENUM', '_RANGE']]:
                        self._add_enum(line, base_type, default_enum_val)
                        default_enum_val += 1
                elif parse_struct:
                    if ';' in line:
                        self._add_struct(line, base_type, member_num)
                        member_num = member_num + 1
    
    # populate enum dicts based on enum lines
    def _add_enum(self, line_txt, enum_type, def_enum_val):
        #print("Parsing enum line %s" % line_txt)
        if '=' in line_txt:
            (enum_name, eq_char, enum_val) = line_txt.split(None, 2)
        else:
            enum_name = line_txt.split(',')[0]
            enum_val = str(def_enum_val)
        self.enum_val_dict[enum_name] = {}
        self.enum_val_dict[enum_name]['type'] = enum_type
        # strip comma and comment, then extra split in case of no comma w/ comments
        enum_val = enum_val.strip().split(',', 1)[0]
        self.enum_val_dict[enum_name]['val'] = enum_val.split()[0]
        # Perform conversion of VK_BIT macro
        if 'VK_BIT' in self.enum_val_dict[enum_name]['val']:
            vk_bit_val = self.enum_val_dict[enum_name]['val']
            bit_shift = int(vk_bit_val[vk_bit_val.find('(')+1:vk_bit_val.find(')')], 0)
            self.enum_val_dict[enum_name]['val'] = str(1 << bit_shift)
        else:
            # account for negative values surrounded by parens
            self.enum_val_dict[enum_name]['val'] = self.enum_val_dict[enum_name]['val'].strip(')').replace('-(', '-')
        # Try to cast to int to determine if enum value is unique
        try:
            #print("ENUM val:", self.enum_val_dict[enum_name]['val'])
            int(self.enum_val_dict[enum_name]['val'], 0)
            self.enum_val_dict[enum_name]['unique'] = True
            #print("ENUM has num value")
        except ValueError:
            self.enum_val_dict[enum_name]['unique'] = False
            #print("ENUM is not a number value")
        # Update enum_type_dict as well
        if not enum_type in self.enum_type_dict:
            self.enum_type_dict[enum_type] = []
        self.enum_type_dict[enum_type].append(enum_name)

    # Return True of struct member is a dynamic array
    # RULES : This is a bit quirky based on the API
    # NOTE : Changes in API spec may cause these rules to change
    #  1. There must be a previous uint var w/ 'count' in the name in the struct
    #  2. Dynam array must have 'const' and '*' qualifiers
    #  3a. Name of dynam array must end in 's' char OR
    #  3b. Name of count var minus 'count' must be contained in name of dynamic array
    def _is_dynamic_array(self, full_type, name):
        if '' != self.last_struct_count_name:
            if 'const' in full_type and '*' in full_type:
                if name.endswith('s') or self.last_struct_count_name.lower().replace('count', '') in name.lower():
                    return True
        return False

    # populate struct dicts based on struct lines
    # TODO : Handle ":" bitfield, "**" ptr->ptr and "const type*const*"
    def _add_struct(self, line_txt, struct_type, num):
        #print("Parsing struct line %s" % line_txt)
        if not struct_type in self.struct_dict:
            self.struct_dict[struct_type] = {}
        members = line_txt.strip().split(';', 1)[0] # first strip semicolon & comments
        # TODO : Handle bitfields more correctly
        members = members.strip().split(':', 1)[0] # strip bitfield element
        (member_type, member_name) = members.rsplit(None, 1)
        # Store counts to help recognize and size dynamic arrays
        if 'count' in member_name.lower() and 'samplecount' != member_name.lower() and 'uint' in member_type:
            self.last_struct_count_name = member_name
        self.struct_dict[struct_type][num] = {}
        self.struct_dict[struct_type][num]['full_type'] = member_type
        self.struct_dict[struct_type][num]['dyn_array'] = False
        if '*' in member_type:
            self.struct_dict[struct_type][num]['ptr'] = True
            # TODO : Need more general purpose way here to reduce down to basic type
            member_type = member_type.replace(' const*', '')
            member_type = member_type.strip('*')
        else:
            self.struct_dict[struct_type][num]['ptr'] = False
        if 'const' in member_type:
            self.struct_dict[struct_type][num]['const'] = True
            member_type = member_type.replace('const', '').strip()
        else:
            self.struct_dict[struct_type][num]['const'] = False
        # TODO : There is a bug here where it seems that at the time we do this check,
        #    the data is not in the types or typedef_rev_dict, so we never pass this if check
        if is_type(member_type, 'struct'):
            self.struct_dict[struct_type][num]['struct'] = True
        else:
            self.struct_dict[struct_type][num]['struct'] = False
        self.struct_dict[struct_type][num]['type'] = member_type
        if '[' in member_name:
            (member_name, array_size) = member_name.split('[', 1)
            if 'char' in member_type:
                self.struct_dict[struct_type][num]['array'] = False
                self.struct_dict[struct_type][num]['array_size'] = 0
                self.struct_dict[struct_type][num]['ptr'] = True
            else:
                self.struct_dict[struct_type][num]['array'] = True
                self.struct_dict[struct_type][num]['array_size'] = array_size.strip(']')
        elif self._is_dynamic_array(self.struct_dict[struct_type][num]['full_type'], member_name):
            #print("Found dynamic array %s of size %s" % (member_name, self.last_struct_count_name))
            self.struct_dict[struct_type][num]['array'] = True
            self.struct_dict[struct_type][num]['dyn_array'] = True
            self.struct_dict[struct_type][num]['array_size'] = self.last_struct_count_name
        elif not 'array' in self.struct_dict[struct_type][num]:
            self.struct_dict[struct_type][num]['array'] = False
            self.struct_dict[struct_type][num]['array_size'] = 0
        self.struct_dict[struct_type][num]['name'] = member_name

# check if given identifier is of specified type_to_check
def is_type(identifier, type_to_check):
    if identifier in types_dict and type_to_check == types_dict[identifier]:
        return True
    if identifier in typedef_rev_dict:
        new_id = typedef_rev_dict[identifier]
        if new_id in types_dict and type_to_check == types_dict[new_id]:
            return True
    return False

# This is a validation function to verify that we can reproduce the original structs
def recreate_structs():
    for struct_name in struct_dict:
        sys.stdout.write("typedef struct %s\n{\n" % struct_name)
        for mem_num in sorted(struct_dict[struct_name]):
            sys.stdout.write("    ")
            if struct_dict[struct_name][mem_num]['const']:
                sys.stdout.write("const ")
            #if struct_dict[struct_name][mem_num]['struct']:
            #    sys.stdout.write("struct ")
            sys.stdout.write (struct_dict[struct_name][mem_num]['type'])
            if struct_dict[struct_name][mem_num]['ptr']:
                sys.stdout.write("*")
            sys.stdout.write(" ")
            sys.stdout.write(struct_dict[struct_name][mem_num]['name'])
            if struct_dict[struct_name][mem_num]['array']:
                sys.stdout.write("[")
                sys.stdout.write(struct_dict[struct_name][mem_num]['array_size'])
                sys.stdout.write("]")
            sys.stdout.write(";\n")
        sys.stdout.write("} ")
        sys.stdout.write(typedef_fwd_dict[struct_name])
        sys.stdout.write(";\n\n")

#
# TODO: Fix construction of struct name
def get_struct_name_from_struct_type(struct_type):
    # Note: All struct types are now camel-case
    caps_struct_name = struct_type.replace("_STRUCTURE_TYPE", "")
    char_idx = 0
    struct_name = ''
    for char in caps_struct_name:
        if (0 == char_idx) or (caps_struct_name[char_idx-1] == '_'):
            struct_name += caps_struct_name[char_idx]
        elif (caps_struct_name[char_idx] == '_'):
            pass
        else:
            struct_name += caps_struct_name[char_idx].lower()
        char_idx += 1
    return struct_name

# class for writing common file elements
# Here's how this class lays out a file:
#  COPYRIGHT
#  HEADER
#  BODY
#  FOOTER
#
# For each of these sections, there's a "set*" function
# The class as a whole has a generate function which will write each section in order
class CommonFileGen:
    def __init__(self, filename=None, copyright_txt="", header_txt="", body_txt="", footer_txt=""):
        self.filename = filename
        self.contents = {'copyright': copyright_txt, 'header': header_txt, 'body': body_txt, 'footer': footer_txt}
        # TODO : Set a default copyright & footer at least
    
    def setFilename(self, filename):
        self.filename = filename
        
    def setCopyright(self, c):
        self.contents['copyright'] = c
        
    def setHeader(self, h):
        self.contents['header'] = h
        
    def setBody(self, b):
        self.contents['body'] = b
        
    def setFooter(self, f):
        self.contents['footer'] = f
        
    def generate(self):
        #print("Generate to file %s" % self.filename)
        with open(self.filename, "w") as f:
            f.write(self.contents['copyright'])
            f.write(self.contents['header'])
            f.write(self.contents['body'])
            f.write(self.contents['footer'])

# class for writing a wrapper class for structures
# The wrapper class wraps the structs and includes utility functions for
#  setting/getting member values and displaying the struct data in various formats
class StructWrapperGen:
    def __init__(self, in_struct_dict, prefix, out_dir):
        self.struct_dict = in_struct_dict
        self.include_headers = []
        self.api = prefix
        if prefix.lower() == "vulkan":
            self.api_prefix = "vk"
        else:
            self.api_prefix = prefix
        self.header_filename = os.path.join(out_dir, self.api_prefix+"_struct_wrappers.h")
        self.class_filename = os.path.join(out_dir, self.api_prefix+"_struct_wrappers.cpp")
        self.string_helper_filename = os.path.join(out_dir, self.api_prefix+"_struct_string_helper.h")
        self.string_helper_no_addr_filename = os.path.join(out_dir, self.api_prefix+"_struct_string_helper_no_addr.h")
        self.string_helper_cpp_filename = os.path.join(out_dir, self.api_prefix+"_struct_string_helper_cpp.h")
        self.string_helper_no_addr_cpp_filename = os.path.join(out_dir, self.api_prefix+"_struct_string_helper_no_addr_cpp.h")
        self.validate_helper_filename = os.path.join(out_dir, self.api_prefix+"_struct_validate_helper.h")
        self.no_addr = False
        self.hfg = CommonFileGen(self.header_filename)
        self.cfg = CommonFileGen(self.class_filename)
        self.shg = CommonFileGen(self.string_helper_filename)
        self.shcppg = CommonFileGen(self.string_helper_cpp_filename)
        self.vhg = CommonFileGen(self.validate_helper_filename)
        self.size_helper_filename = os.path.join(out_dir, self.api_prefix+"_struct_size_helper.h")
        self.size_helper_c_filename = os.path.join(out_dir, self.api_prefix+"_struct_size_helper.c")
        self.size_helper_gen = CommonFileGen(self.size_helper_filename)
        self.size_helper_c_gen = CommonFileGen(self.size_helper_c_filename)
        #print(self.header_filename)
        self.header_txt = ""
        self.definition_txt = ""
        
    def set_include_headers(self, include_headers):
        self.include_headers = include_headers

    def set_no_addr(self, no_addr):
        self.no_addr = no_addr
        if self.no_addr:
            self.shg = CommonFileGen(self.string_helper_no_addr_filename)
            self.shcppg = CommonFileGen(self.string_helper_no_addr_cpp_filename)
        else:
            self.shg = CommonFileGen(self.string_helper_filename)
            self.shcppg = CommonFileGen(self.string_helper_cpp_filename)

    # Return class name for given struct name
    def get_class_name(self, struct_name):
        class_name = struct_name.strip('_').lower() + "_struct_wrapper"
        return class_name
        
    def get_file_list(self):
        return [os.path.basename(self.header_filename), os.path.basename(self.class_filename), os.path.basename(self.string_helper_filename)]

    # Generate class header file        
    def generateHeader(self):
        self.hfg.setCopyright(self._generateCopyright())
        self.hfg.setHeader(self._generateHeader())
        self.hfg.setBody(self._generateClassDeclaration())
        self.hfg.setFooter(self._generateFooter())
        self.hfg.generate()
    
    # Generate class definition
    def generateBody(self):
        self.cfg.setCopyright(self._generateCopyright())
        self.cfg.setHeader(self._generateCppHeader())
        self.cfg.setBody(self._generateClassDefinition())
        self.cfg.setFooter(self._generateFooter())
        self.cfg.generate()

    # Generate c-style .h file that contains functions for printing structs
    def generateStringHelper(self):
        print("Generating struct string helper")
        self.shg.setCopyright(self._generateCopyright())
        self.shg.setHeader(self._generateStringHelperHeader())
        self.shg.setBody(self._generateStringHelperFunctions())
        self.shg.generate()

    # Generate cpp-style .h file that contains functions for printing structs
    def generateStringHelperCpp(self):
        print("Generating struct string helper cpp")
        self.shcppg.setCopyright(self._generateCopyright())
        self.shcppg.setHeader(self._generateStringHelperHeaderCpp())
        self.shcppg.setBody(self._generateStringHelperFunctionsCpp())
        self.shcppg.generate()

    # Generate c-style .h file that contains functions for printing structs
    def generateValidateHelper(self):
        print("Generating struct validate helper")
        self.vhg.setCopyright(self._generateCopyright())
        self.vhg.setHeader(self._generateValidateHelperHeader())
        self.vhg.setBody(self._generateValidateHelperFunctions())
        self.vhg.generate()

    def generateSizeHelper(self):
        print("Generating struct size helper")
        self.size_helper_gen.setCopyright(self._generateCopyright())
        self.size_helper_gen.setHeader(self._generateSizeHelperHeader())
        self.size_helper_gen.setBody(self._generateSizeHelperFunctions())
        self.size_helper_gen.generate()

    def generateSizeHelperC(self):
        print("Generating struct size helper c")
        self.size_helper_c_gen.setCopyright(self._generateCopyright())
        self.size_helper_c_gen.setHeader(self._generateSizeHelperHeaderC())
        self.size_helper_c_gen.setBody(self._generateSizeHelperFunctionsC())
        self.size_helper_c_gen.generate()

    def _generateCopyright(self):
        copyright = []
        copyright.append('/* THIS FILE IS GENERATED.  DO NOT EDIT. */');
        copyright.append('');
        copyright.append('/*');
        copyright.append(' * Vulkan');
        copyright.append(' *');
        copyright.append(' * Copyright (C) 2014 LunarG, Inc.');
        copyright.append(' *');
        copyright.append(' * Permission is hereby granted, free of charge, to any person obtaining a');
        copyright.append(' * copy of this software and associated documentation files (the "Software"),');
        copyright.append(' * to deal in the Software without restriction, including without limitation');
        copyright.append(' * the rights to use, copy, modify, merge, publish, distribute, sublicense,');
        copyright.append(' * and/or sell copies of the Software, and to permit persons to whom the');
        copyright.append(' * Software is furnished to do so, subject to the following conditions:');
        copyright.append(' *');
        copyright.append(' * The above copyright notice and this permission notice shall be included');
        copyright.append(' * in all copies or substantial portions of the Software.');
        copyright.append(' *');
        copyright.append(' * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR');
        copyright.append(' * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,');
        copyright.append(' * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL');
        copyright.append(' * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER');
        copyright.append(' * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING');
        copyright.append(' * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER');
        copyright.append(' * DEALINGS IN THE SOFTWARE.');
        copyright.append(' */');
        copyright.append('');
        return "\n".join(copyright)

    def _generateCppHeader(self):
        header = []
        header.append("//#includes, #defines, globals and such...\n")
        header.append("#include <stdio.h>\n#include <%s>\n#include <%s_enum_string_helper.h>\n" % (os.path.basename(self.header_filename), self.api_prefix))
        return "".join(header)
        
    def _generateClassDefinition(self):
        class_def = []
        if 'vk' == self.api: # Mantle doesn't have pNext to worry about
            class_def.append(self._generateDynamicPrintFunctions())
        for s in sorted(self.struct_dict):
            class_def.append("\n// %s class definition" % self.get_class_name(s))
            class_def.append(self._generateConstructorDefinitions(s))
            class_def.append(self._generateDestructorDefinitions(s))
            class_def.append(self._generateDisplayDefinitions(s))
        return "\n".join(class_def)
        
    def _generateConstructorDefinitions(self, s):
        con_defs = []
        con_defs.append("%s::%s() : m_struct(), m_indent(0), m_dummy_prefix('\\0'), m_origStructAddr(NULL) {}" % (self.get_class_name(s), self.get_class_name(s)))
        # TODO : This is a shallow copy of ptrs
        con_defs.append("%s::%s(%s* pInStruct) : m_indent(0), m_dummy_prefix('\\0')\n{\n    m_struct = *pInStruct;\n    m_origStructAddr = pInStruct;\n}" % (self.get_class_name(s), self.get_class_name(s), typedef_fwd_dict[s]))
        con_defs.append("%s::%s(const %s* pInStruct) : m_indent(0), m_dummy_prefix('\\0')\n{\n    m_struct = *pInStruct;\n    m_origStructAddr = pInStruct;\n}" % (self.get_class_name(s), self.get_class_name(s), typedef_fwd_dict[s]))
        return "\n".join(con_defs)
        
    def _generateDestructorDefinitions(self, s):
        return "%s::~%s() {}" % (self.get_class_name(s), self.get_class_name(s))
        
    def _generateDynamicPrintFunctions(self):
        dp_funcs = []
        dp_funcs.append("\nvoid dynamic_display_full_txt(const void* pStruct, uint32_t indent)\n{\n    // Cast to APP_INFO ptr initially just to pull sType off struct")
        dp_funcs.append("    VkStructureType sType = ((VkApplicationInfo*)pStruct)->sType;\n")
        dp_funcs.append("    switch (sType)\n    {")
        for e in enum_type_dict:
            class_num = 0
            if "StructureType" in e:
                for v in sorted(enum_type_dict[e]):
                    struct_name = get_struct_name_from_struct_type(v)
                    class_name = self.get_class_name(struct_name)
                    instance_name = "swc%i" % class_num
                    dp_funcs.append("        case %s:\n        {" % (v))
                    dp_funcs.append("            %s %s((%s*)pStruct);" % (class_name, instance_name, struct_name))
                    dp_funcs.append("            %s.set_indent(indent);" % (instance_name))
                    dp_funcs.append("            %s.display_full_txt();" % (instance_name))
                    dp_funcs.append("        }")
                    dp_funcs.append("        break;")
                    class_num += 1
                dp_funcs.append("    }")
        dp_funcs.append("}\n")
        return "\n".join(dp_funcs)

    def _get_func_name(self, struct, mid_str):
        return "%s_%s_%s" % (self.api_prefix, mid_str, struct.lower().strip("_"))

    def _get_sh_func_name(self, struct):
        return self._get_func_name(struct, 'print')

    def _get_vh_func_name(self, struct):
        return self._get_func_name(struct, 'validate')

    def _get_size_helper_func_name(self, struct):
        return self._get_func_name(struct, 'size')

    # Return elements to create formatted string for given struct member
    def _get_struct_print_formatted(self, struct_member, pre_var_name="prefix", postfix = "\\n", struct_var_name="pStruct", struct_ptr=True, print_array=False):
        struct_op = "->"
        if not struct_ptr:
            struct_op = "."
        member_name = struct_member['name']
        print_type = "p"
        cast_type = ""
        member_post = ""
        array_index = ""
        member_print_post = ""
        print_delimiter = "%"
        if struct_member['array'] and 'char' in struct_member['type'].lower(): # just print char array as string
            if member_name.startswith('pp'): # TODO : Only printing first element of dynam array of char* for now
                member_post = "[0]"
            print_type = "s"
            print_array = False
        elif struct_member['array'] and not print_array:
            # Just print base address of array when not full print_array
            cast_type = "(void*)"
        elif is_type(struct_member['type'], 'enum'):
            cast_type = "string_%s" % struct_member['type']
            if struct_member['ptr']:
                struct_var_name = "*" + struct_var_name
            print_type = "s"
        elif is_type(struct_member['type'], 'struct'): # print struct address for now
            cast_type = "(void*)"
            if not struct_member['ptr']:
                cast_type = "(void*)&"
        elif 'bool' in struct_member['type']:
            print_type = "s"
            member_post = ' ? "TRUE" : "FALSE"'
        elif 'float' in struct_member['type']:
            print_type = "f"
        elif 'uint64' in struct_member['type'] or 'gpusize' in struct_member['type'].lower():
            print_type = '" PRId64 "'
        elif 'uint8' in struct_member['type']:
            print_type = "hu"
        elif 'size' in struct_member['type'].lower():
            print_type = '" PRINTF_SIZE_T_SPECIFIER "'
            print_delimiter = ""
        elif True in [ui_str.lower() in struct_member['type'].lower() for ui_str in ['uint', 'flags', 'samplemask']]:
            print_type = "u"
        elif 'int' in struct_member['type']:
            print_type = "i"
        elif struct_member['ptr']:
            pass
        else:
            #print("Unhandled struct type: %s" % struct_member['type'])
            cast_type = "(void*)"
        if print_array and struct_member['array']:
            member_print_post = "[%u]"
            array_index = " i,"
            member_post = "[i]"
        print_out = "%%s%s%s = %s%s%s" % (member_name, member_print_post, print_delimiter, print_type, postfix) # section of print that goes inside of quotes
        print_arg = ", %s,%s %s(%s%s%s)%s" % (pre_var_name, array_index, cast_type, struct_var_name, struct_op, member_name, member_post) # section of print passed to portion in quotes
        if self.no_addr and "p" == print_type:
            print_out = "%%s%s%s = addr\\n" % (member_name, member_print_post) # section of print that goes inside of quotes
            print_arg = ", %s" % (pre_var_name)
        return (print_out, print_arg)

    def _generateStringHelperFunctions(self):
        sh_funcs = []
        # We do two passes, first pass just generates prototypes for all the functsions
        for s in sorted(self.struct_dict):
            sh_funcs.append('char* %s(const %s* pStruct, const char* prefix);' % (self._get_sh_func_name(s), typedef_fwd_dict[s]))
        sh_funcs.append('')
        sh_funcs.append('#if defined(_WIN32)')
        sh_funcs.append('// Microsoft did not implement C99 in Visual Studio; but started adding it with')
        sh_funcs.append('// VS2013.  However, VS2013 still did not have snprintf().  The following is a')
        sh_funcs.append('// work-around.')
        sh_funcs.append('#define snprintf _snprintf')
        sh_funcs.append('#endif // _WIN32\n')
        for s in sorted(self.struct_dict):
            p_out = ""
            p_args = ""
            stp_list = [] # stp == "struct to print" a list of structs for this API call that should be printed as structs
            # This pre-pass flags embedded structs and pNext
            for m in sorted(self.struct_dict[s]):
                if 'pNext' == self.struct_dict[s][m]['name'] or is_type(self.struct_dict[s][m]['type'], 'struct'):
                    stp_list.append(self.struct_dict[s][m])
            sh_funcs.append('char* %s(const %s* pStruct, const char* prefix)\n{\n    char* str;' % (self._get_sh_func_name(s), typedef_fwd_dict[s]))
            sh_funcs.append("    size_t len;")
            num_stps = len(stp_list);
            total_strlen_str = ''
            if 0 != num_stps:
                sh_funcs.append("    char* tmpStr;")
                sh_funcs.append('    char* extra_indent = (char*)malloc(strlen(prefix) + 3);')
                sh_funcs.append('    strcpy(extra_indent, "  ");')
                sh_funcs.append('    strncat(extra_indent, prefix, strlen(prefix));')
                sh_funcs.append('    char* stp_strs[%i];' % num_stps)
                for index in range(num_stps):
                    # If it's an array, print all of the elements
                    # If it's a ptr, print thing it's pointing to
                    # Non-ptr struct case. Print the struct using its address
                    struct_deref = '&'
                    if 1 < stp_list[index]['full_type'].count('*'):
                        struct_deref = ''
                    if (stp_list[index]['ptr']):
                        sh_funcs.append('    if (pStruct->%s) {' % stp_list[index]['name'])
                        if 'pNext' == stp_list[index]['name']:
                            sh_funcs.append('        tmpStr = dynamic_display((void*)pStruct->pNext, prefix);')
                            sh_funcs.append('        len = 256+strlen(tmpStr);')
                            sh_funcs.append('        stp_strs[%i] = (char*)malloc(len);' % index)
                            if self.no_addr:
                                sh_funcs.append('        snprintf(stp_strs[%i], len, " %%spNext (addr)\\n%%s", prefix, tmpStr);' % index)
                            else:
                                sh_funcs.append('        snprintf(stp_strs[%i], len, " %%spNext (%%p)\\n%%s", prefix, (void*)pStruct->pNext, tmpStr);' % index)
                            sh_funcs.append('        free(tmpStr);')
                        else:
                            if stp_list[index]['name'] in ['pImageViews', 'pBufferViews']:
                                # TODO : This is a quick hack to handle these arrays of ptrs
                                sh_funcs.append('        tmpStr = %s(&pStruct->%s[0], extra_indent);' % (self._get_sh_func_name(stp_list[index]['type']), stp_list[index]['name']))
                            else:
                                sh_funcs.append('        tmpStr = %s(pStruct->%s, extra_indent);' % (self._get_sh_func_name(stp_list[index]['type']), stp_list[index]['name']))
                            sh_funcs.append('        len = 256+strlen(tmpStr)+strlen(prefix);')
                            sh_funcs.append('        stp_strs[%i] = (char*)malloc(len);' % (index))
                            if self.no_addr:
                                sh_funcs.append('        snprintf(stp_strs[%i], len, " %%s%s (addr)\\n%%s", prefix, tmpStr);' % (index, stp_list[index]['name']))
                            else:
                                sh_funcs.append('        snprintf(stp_strs[%i], len, " %%s%s (%%p)\\n%%s", prefix, (void*)pStruct->%s, tmpStr);' % (index, stp_list[index]['name'], stp_list[index]['name']))
                        sh_funcs.append('    }')
                        sh_funcs.append("    else\n        stp_strs[%i] = \"\";" % (index))
                    elif stp_list[index]['array']:
                        sh_funcs.append('    tmpStr = %s(&pStruct->%s[0], extra_indent);' % (self._get_sh_func_name(stp_list[index]['type']), stp_list[index]['name']))
                        sh_funcs.append('    len = 256+strlen(tmpStr);')
                        sh_funcs.append('    stp_strs[%i] = (char*)malloc(len);' % (index))
                        if self.no_addr:
                            sh_funcs.append('    snprintf(stp_strs[%i], len, " %%s%s[0] (addr)\\n%%s", prefix, tmpStr);' % (index, stp_list[index]['name']))
                        else:
                            sh_funcs.append('    snprintf(stp_strs[%i], len, " %%s%s[0] (%%p)\\n%%s", prefix, (void*)&pStruct->%s[0], tmpStr);' % (index, stp_list[index]['name'], stp_list[index]['name']))
                    else:
                        sh_funcs.append('    tmpStr = %s(&pStruct->%s, extra_indent);' % (self._get_sh_func_name(stp_list[index]['type']), stp_list[index]['name']))
                        sh_funcs.append('    len = 256+strlen(tmpStr);')
                        sh_funcs.append('    stp_strs[%i] = (char*)malloc(len);' % (index))
                        if self.no_addr:
                            sh_funcs.append('    snprintf(stp_strs[%i], len, " %%s%s (addr)\\n%%s", prefix, tmpStr);' % (index, stp_list[index]['name']))
                        else:
                            sh_funcs.append('    snprintf(stp_strs[%i], len, " %%s%s (%%p)\\n%%s", prefix, (void*)&pStruct->%s, tmpStr);' % (index, stp_list[index]['name'], stp_list[index]['name']))
                    total_strlen_str += 'strlen(stp_strs[%i]) + ' % index
            sh_funcs.append('    len = %ssizeof(char)*1024;' % (total_strlen_str))
            sh_funcs.append('    str = (char*)malloc(len);')
            sh_funcs.append('    snprintf(str, len, "')
            for m in sorted(self.struct_dict[s]):
                (p_out1, p_args1) = self._get_struct_print_formatted(self.struct_dict[s][m])
                p_out += p_out1
                p_args += p_args1
            p_out += '"'
            p_args += ");"
            sh_funcs[-1] = '%s%s%s' % (sh_funcs[-1], p_out, p_args)
            if 0 != num_stps:
                sh_funcs.append('    for (int32_t stp_index = %i; stp_index >= 0; stp_index--) {' % (num_stps-1))
                sh_funcs.append('        if (0 < strlen(stp_strs[stp_index])) {')
                sh_funcs.append('            strncat(str, stp_strs[stp_index], strlen(stp_strs[stp_index]));')
                sh_funcs.append('            free(stp_strs[stp_index]);')
                sh_funcs.append('        }')
                sh_funcs.append('    }')
                sh_funcs.append('    free(extra_indent);')
            sh_funcs.append("    return str;\n}")
        # Add function to dynamically print out unknown struct
        sh_funcs.append("char* dynamic_display(const void* pStruct, const char* prefix)\n{")
        sh_funcs.append("    // Cast to APP_INFO ptr initially just to pull sType off struct")
        sh_funcs.append("    if (pStruct == NULL) {")
        sh_funcs.append("        return NULL;")
        sh_funcs.append("    }")
        sh_funcs.append("    VkStructureType sType = ((VkApplicationInfo*)pStruct)->sType;")
        sh_funcs.append('    char indent[100];\n    strcpy(indent, "    ");\n    strcat(indent, prefix);')
        sh_funcs.append("    switch (sType)\n    {")
        for e in enum_type_dict:
            if "StructureType" in e:
                for v in sorted(enum_type_dict[e]):
                    struct_name = get_struct_name_from_struct_type(v)
                    print_func_name = self._get_sh_func_name(struct_name)
                    sh_funcs.append('        case %s:\n        {' % (v))
                    sh_funcs.append('            return %s((%s*)pStruct, indent);' % (print_func_name, struct_name))
                    sh_funcs.append('        }')
                    sh_funcs.append('        break;')
                sh_funcs.append("        default:")
                sh_funcs.append("        return NULL;")
                sh_funcs.append("    }")
        sh_funcs.append("}")
        return "\n".join(sh_funcs)

    def _generateStringHelperFunctionsCpp(self):
        # declare str & tmp str
        # declare array of stringstreams for every struct ptr in current struct
        # declare array of stringstreams for every non-string element in current struct
        # For every struct ptr, if non-Null, then set its string, else set to NULL str
        # For every non-string element, set its string stream
        # create and return final string
        sh_funcs = []
        # First generate prototypes for every struct
        # XXX - REMOVE this comment
        lineinfo = sourcelineinfo()
        sh_funcs.append('%s' % lineinfo.get())
        for s in sorted(self.struct_dict):
            sh_funcs.append('string %s(const %s* pStruct, const string prefix);' % (self._get_sh_func_name(s), typedef_fwd_dict[s]))
        sh_funcs.append('\n')
        sh_funcs.append('%s' % lineinfo.get())
        for s in sorted(self.struct_dict):
            num_non_enum_elems = [(is_type(self.struct_dict[s][elem]['type'], 'enum') and not self.struct_dict[s][elem]['ptr']) for elem in self.struct_dict[s]].count(False)
            stp_list = [] # stp == "struct to print" a list of structs for this API call that should be printed as structs
            # This pre-pass flags embedded structs and pNext
            for m in sorted(self.struct_dict[s]):
                if 'pNext' == self.struct_dict[s][m]['name'] or is_type(self.struct_dict[s][m]['type'], 'struct') or self.struct_dict[s][m]['array']:
                    stp_list.append(self.struct_dict[s][m])
            sh_funcs.append('%s' % lineinfo.get())
            sh_funcs.append('string %s(const %s* pStruct, const string prefix)\n{' % (self._get_sh_func_name(s), typedef_fwd_dict[s]))
            sh_funcs.append('%s' % lineinfo.get())
            indent = '    '
            sh_funcs.append('%susing namespace StreamControl;' % (indent))
            sh_funcs.append('%sstring final_str;' % (indent))
            sh_funcs.append('%sstring tmp_str;' % (indent))
            sh_funcs.append('%sstring extra_indent = "  " + prefix;' % (indent))
            if (0 != num_non_enum_elems):
                sh_funcs.append('%sstringstream ss[%u];' % (indent, num_non_enum_elems))
            num_stps = len(stp_list)
            # First generate code for any embedded structs or arrays
            if 0 < num_stps:
                sh_funcs.append('%sstring stp_strs[%u];' % (indent, num_stps))
                idx_ss_decl = False # Make sure to only decl this once
                for index in range(num_stps):
                    addr_char = '&'
                    if 1 < stp_list[index]['full_type'].count('*'):
                        addr_char = ''
                    if (stp_list[index]['array'] and 'char' not in stp_list[index]['type']):
                        sh_funcs.append('%s' % lineinfo.get())
                        if stp_list[index]['dyn_array']:
                            sh_funcs.append('%s' % lineinfo.get())
                            array_count = 'pStruct->%s' % (stp_list[index]['array_size'])
                        else:
                            sh_funcs.append('%s' % lineinfo.get())
                            array_count = '%s' % (stp_list[index]['array_size'])
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('%sstp_strs[%u] = "";' % (indent, index))
                        if not idx_ss_decl:
                            sh_funcs.append('%sstringstream index_ss;' % (indent))
                            idx_ss_decl = True
                        sh_funcs.append('%sif (pStruct->%s) {' % (indent, stp_list[index]['name']))
                        indent += '    '
                        sh_funcs.append('%sfor (uint32_t i = 0; i < %s; i++) {' % (indent, array_count))
                        indent += '    '
                        sh_funcs.append('%sindex_ss.str("");' % (indent))
                        sh_funcs.append('%sindex_ss << i;' % (indent))
                        if is_type(stp_list[index]['type'], 'enum'):
                            sh_funcs.append('%s' % lineinfo.get())
                            addr_char = ''
                            #value_print = 'string_%s(%spStruct->%s)' % (self.struct_dict[s][m]['type'], deref, self.struct_dict[s][m]['name'])
                            sh_funcs.append('%sss[%u] << string_%s(pStruct->%s[i]);' % (indent, index, stp_list[index]['type'], stp_list[index]['name']))
                            sh_funcs.append('%sstp_strs[%u] += " " + prefix + "%s[" + index_ss.str() + "] = " + ss[%u].str() + "\\n";' % (indent, index, stp_list[index]['name'], index))
                        elif is_type(stp_list[index]['type'], 'struct'):
                            sh_funcs.append('%s' % lineinfo.get())
                            sh_funcs.append('%sss[%u] << %spStruct->%s[i];' % (indent, index, addr_char, stp_list[index]['name']))
                            sh_funcs.append('%stmp_str = %s(%spStruct->%s[i], extra_indent);' % (indent, self._get_sh_func_name(stp_list[index]['type']), addr_char, stp_list[index]['name']))
                            if self.no_addr:
                                sh_funcs.append('%s' % lineinfo.get())
                                sh_funcs.append('%sstp_strs[%u] += " " + prefix + "%s[" + index_ss.str() + "] (addr)\\n" + tmp_str;' % (indent, index, stp_list[index]['name']))
                            else:
                                sh_funcs.append('%s' % lineinfo.get())
                                sh_funcs.append('%sstp_strs[%u] += " " + prefix + "%s[" + index_ss.str() + "] (" + ss[%u].str() + ")\\n" + tmp_str;' % (indent, index, stp_list[index]['name'], index))
                        else:
                            sh_funcs.append('%s' % lineinfo.get())
                            addr_char = ''
                            sh_funcs.append('%sss[%u] << %spStruct->%s[i];' % (indent, index, addr_char, stp_list[index]['name']))
                            sh_funcs.append('%sstp_strs[%u] += " " + prefix + "%s[" + index_ss.str() + "] = " + ss[%u].str() + "\\n";' % (indent, index, stp_list[index]['name'], index))
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('%sss[%u].str("");' % (indent, index))
                        indent = indent[4:]
                        sh_funcs.append('%s}' % (indent))
                        indent = indent[4:]
                        sh_funcs.append('%s}' % (indent))
                    elif (stp_list[index]['ptr']):
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('    if (pStruct->%s) {' % stp_list[index]['name'])
                        if 'pNext' == stp_list[index]['name']:
                            sh_funcs.append('%s' % lineinfo.get())
                            sh_funcs.append('        tmp_str = dynamic_display((void*)pStruct->pNext, prefix);')
                        else:
                            if stp_list[index]['name'] in ['pImageViews', 'pBufferViews']:
                                # TODO : This is a quick hack to handle these arrays of ptrs
                                sh_funcs.append('%s' % lineinfo.get())
                                sh_funcs.append('        tmp_str = %s(&pStruct->%s[0], extra_indent);' % (self._get_sh_func_name(stp_list[index]['type']), stp_list[index]['name']))
                            else:
                                sh_funcs.append('%s' % lineinfo.get())
                                sh_funcs.append('        tmp_str = %s(pStruct->%s, extra_indent);' % (self._get_sh_func_name(stp_list[index]['type']), stp_list[index]['name']))
                        sh_funcs.append('        ss[%u] << %spStruct->%s;' % (index, addr_char, stp_list[index]['name']))
                        if self.no_addr:
                            sh_funcs.append('%s' % lineinfo.get())
                            sh_funcs.append('        stp_strs[%u] = " " + prefix + "%s (addr)\\n" + tmp_str;' % (index, stp_list[index]['name']))
                        else:
                            sh_funcs.append('%s' % lineinfo.get())
                            sh_funcs.append('        stp_strs[%u] = " " + prefix + "%s (" + ss[%u].str() + ")\\n" + tmp_str;' % (index, stp_list[index]['name'], index))
                        sh_funcs.append('        ss[%u].str("");' % (index))
                        sh_funcs.append('    }')
                        sh_funcs.append('    else')
                        sh_funcs.append('        stp_strs[%u] = "";' % index)
                    else:
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('    tmp_str = %s(&pStruct->%s, extra_indent);' % (self._get_sh_func_name(stp_list[index]['type']), stp_list[index]['name']))
                        sh_funcs.append('    ss[%u] << %spStruct->%s;' % (index, addr_char, stp_list[index]['name']))
                        if self.no_addr:
                            sh_funcs.append('    stp_strs[%u] = " " + prefix + "%s (addr)\\n" + tmp_str;' % (index, stp_list[index]['name']))
                            sh_funcs.append('%s' % lineinfo.get())
                        else:
                            sh_funcs.append('    stp_strs[%u] = " " + prefix + "%s (" + ss[%u].str() + ")\\n" + tmp_str;' % (index, stp_list[index]['name'], index))
                            sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('    ss[%u].str("");' % index)
            # Now print one-line info for all data members
            index = 0
            final_str = ''
            for m in sorted(self.struct_dict[s]):
                if not is_type(self.struct_dict[s][m]['type'], 'enum'):
                    if is_type(self.struct_dict[s][m]['type'], 'struct') and not self.struct_dict[s][m]['ptr']:
                        if self.no_addr:
                            sh_funcs.append('%s' % lineinfo.get())
                            sh_funcs.append('    ss[%u].str("addr");' % (index))
                        else:
                            sh_funcs.append('%s' % lineinfo.get())
                            sh_funcs.append('    ss[%u] << &pStruct->%s;' % (index, self.struct_dict[s][m]['name']))
                    elif 'bool' in self.struct_dict[s][m]['type'].lower():
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('    ss[%u].str(pStruct->%s ? "TRUE" : "FALSE");' % (index, self.struct_dict[s][m]['name']))
                    elif 'uint8' in self.struct_dict[s][m]['type'].lower():
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('    ss[%u] << (uint32_t)pStruct->%s;' % (index, self.struct_dict[s][m]['name']))
                    elif 'void' in self.struct_dict[s][m]['type'].lower() and self.struct_dict[s][m]['ptr']:
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('    if (StreamControl::writeAddress)')
                        sh_funcs.append('        ss[%u] << pStruct->%s;' % (index, self.struct_dict[s][m]['name']))
                        sh_funcs.append('    else')
                        sh_funcs.append('        ss[%u].str("address");' % (index))
                    else:
                        sh_funcs.append('%s' % lineinfo.get())
                        (po, pa) = self._get_struct_print_formatted(self.struct_dict[s][m])
                        if "addr" in po: # or self.struct_dict[s][m]['ptr']:
                            sh_funcs.append('    ss[%u].str("addr");' % (index))
                        else:
                            sh_funcs.append('    ss[%u] << pStruct->%s;' % (index, self.struct_dict[s][m]['name']))
                    value_print = 'ss[%u].str()' % index
                    index += 1
                else:
                    # For an non-empty array of enums just print address w/ note that array will be displayed below
                    if self.struct_dict[s][m]['ptr']:
                        sh_funcs.append('%s' % lineinfo.get())
                        sh_funcs.append('    if (pStruct->%s)' % (self.struct_dict[s][m]['name']))
                        sh_funcs.append('        ss[%u] << pStruct->%s << " (See individual array values below)";' % (index, self.struct_dict[s][m]['name']))
                        sh_funcs.append('    else')
                        sh_funcs.append('        ss[%u].str("NULL");' % (index))
                        value_print = 'ss[%u].str()' % index
                        index += 1
                    # For single enum just print the string representation
                    else:
                        value_print = 'string_%s(pStruct->%s)' % (self.struct_dict[s][m]['type'], self.struct_dict[s][m]['name'])
                final_str += ' + prefix + "%s = " + %s + "\\n"' % (self.struct_dict[s][m]['name'], value_print)
            final_str = final_str[3:] # strip off the initial ' + '
            if 0 != num_stps: # Append data for any embedded structs
                final_str += " + %s" % " + ".join(['stp_strs[%u]' % n for n in reversed(range(num_stps))])
            sh_funcs.append('%s' % lineinfo.get())
            sh_funcs.append('    final_str = %s;' % final_str)
            sh_funcs.append('    return final_str;\n}')
        # Add function to return a string value for input void*
        sh_funcs.append('%s' % lineinfo.get())
        sh_funcs.append("string string_convert_helper(const void* toString, const string prefix)\n{")
        sh_funcs.append("    using namespace StreamControl;")
        sh_funcs.append("    stringstream ss;")
        sh_funcs.append('    ss << toString;')
        sh_funcs.append('    string final_str = prefix + ss.str();')
        sh_funcs.append("    return final_str;")
        sh_funcs.append("}")
        sh_funcs.append('%s' % lineinfo.get())
        # Add function to return a string value for input uint32_t
        sh_funcs.append("string string_convert_helper(const uint32_t toString, const string prefix)\n{")
        sh_funcs.append("    using namespace StreamControl;")
        sh_funcs.append("    stringstream ss;")
        sh_funcs.append('    ss << toString;')
        sh_funcs.append('    string final_str = prefix + ss.str();')
        sh_funcs.append("    return final_str;")
        sh_funcs.append("}")
        sh_funcs.append('%s' % lineinfo.get())
        # Add function to dynamically print out unknown struct
        sh_funcs.append("string dynamic_display(const void* pStruct, const string prefix)\n{")
        sh_funcs.append("    // Cast to APP_INFO ptr initially just to pull sType off struct")
        sh_funcs.append("    if (pStruct == NULL) {\n")
        sh_funcs.append("        return NULL;")
        sh_funcs.append("    }\n")
        sh_funcs.append("    VkStructureType sType = ((VkApplicationInfo*)pStruct)->sType;")
        sh_funcs.append('    string indent = "    ";')
        sh_funcs.append('    indent += prefix;')
        sh_funcs.append("    switch (sType)\n    {")
        for e in enum_type_dict:
            if "StructureType" in e:
                for v in sorted(enum_type_dict[e]):
                    struct_name = get_struct_name_from_struct_type(v)
                    print_func_name = self._get_sh_func_name(struct_name)
                    #sh_funcs.append('string %s(const %s* pStruct, const string prefix);' % (self._get_sh_func_name(s), typedef_fwd_dict[s]))
                    sh_funcs.append('        case %s:\n        {' % (v))
                    sh_funcs.append('            return %s((%s*)pStruct, indent);' % (print_func_name, struct_name))
                    sh_funcs.append('        }')
                    sh_funcs.append('        break;')
                sh_funcs.append("        default:")
                sh_funcs.append("        return NULL;")
        sh_funcs.append('%s' % lineinfo.get())
        sh_funcs.append("    }")
        sh_funcs.append("}")
        return "\n".join(sh_funcs)
        
    def _genStructMemberPrint(self, member, s, array, struct_array):
        (p_out, p_arg) = self._get_struct_print_formatted(self.struct_dict[s][member], pre_var_name="&m_dummy_prefix", struct_var_name="m_struct", struct_ptr=False, print_array=True)
        extra_indent = ""
        if array:
            extra_indent = "    "
        if is_type(self.struct_dict[s][member]['type'], 'struct'): # print struct address for now
            struct_array.insert(0, self.struct_dict[s][member])
        elif self.struct_dict[s][member]['ptr']:
            # Special case for void* named "pNext"
            if "void" in self.struct_dict[s][member]['type'] and "pNext" == self.struct_dict[s][member]['name']:
                struct_array.insert(0, self.struct_dict[s][member])
        return ('    %sprintf("%%*s    %s", m_indent, ""%s);' % (extra_indent, p_out, p_arg), struct_array)

    def _generateDisplayDefinitions(self, s):
        disp_def = []
        struct_array = []
        # Single-line struct print function
        disp_def.append("// Output 'structname = struct_address' on a single line")
        disp_def.append("void %s::display_single_txt()\n{" % self.get_class_name(s))
        disp_def.append('    printf(" %%*s%s = %%p", m_indent, "", (void*)m_origStructAddr);' % typedef_fwd_dict[s])
        disp_def.append("}\n")
        # Private helper function to print struct members
        disp_def.append("// Private helper function that displays the members of the wrapped struct")
        disp_def.append("void %s::display_struct_members()\n{" % self.get_class_name(s))
        i_declared = False
        for member in sorted(self.struct_dict[s]):
            # TODO : Need to display each member based on its type
            # TODO : Need to handle pNext which are structs, but of void* type
            #   Can grab struct type off of header of struct pointed to
            # TODO : Handle Arrays
            if self.struct_dict[s][member]['array']:
                # Create for loop to print each element of array
                if not i_declared:
                    disp_def.append('    uint32_t i;')
                    i_declared = True
                disp_def.append('    for (i = 0; i<%s; i++) {' % self.struct_dict[s][member]['array_size'])
                (return_str, struct_array) = self._genStructMemberPrint(member, s, True, struct_array)
                disp_def.append(return_str)
                disp_def.append('    }')
            else:
                (return_str, struct_array) = self._genStructMemberPrint(member, s, False, struct_array)
                disp_def.append(return_str)
        disp_def.append("}\n")
        i_declared = False
        # Basic print function to display struct members
        disp_def.append("// Output all struct elements, each on their own line")
        disp_def.append("void %s::display_txt()\n{" % self.get_class_name(s))
        disp_def.append('    printf("%%*s%s struct contents at %%p:\\n", m_indent, "", (void*)m_origStructAddr);' % typedef_fwd_dict[s])
        disp_def.append('    this->display_struct_members();')
        disp_def.append("}\n")
        # Advanced print function to display current struct and contents of any pointed-to structs
        disp_def.append("// Output all struct elements, and for any structs pointed to, print complete contents")
        disp_def.append("void %s::display_full_txt()\n{" % self.get_class_name(s))
        disp_def.append('    printf("%%*s%s struct contents at %%p:\\n", m_indent, "", (void*)m_origStructAddr);' % typedef_fwd_dict[s])
        disp_def.append('    this->display_struct_members();')
        class_num = 0
        # TODO : Need to handle arrays of structs here
        for ms in struct_array:
            swc_name = "class%s" % str(class_num)
            if ms['array']:
                if not i_declared:
                    disp_def.append('    uint32_t i;')
                    i_declared = True
                disp_def.append('    for (i = 0; i<%s; i++) {' % ms['array_size'])
                #disp_def.append("        if (m_struct.%s[i]) {" % (ms['name']))
                disp_def.append("            %s %s(&(m_struct.%s[i]));" % (self.get_class_name(ms['type']), swc_name, ms['name']))
                disp_def.append("            %s.set_indent(m_indent + 4);" % (swc_name))
                disp_def.append("            %s.display_full_txt();" % (swc_name))
                #disp_def.append('        }')
                disp_def.append('    }')
            elif 'pNext' == ms['name']:
                # Need some code trickery here
                #  I'm thinking have a generated function that takes pNext ptr value
                #  then it checks sType and in large switch statement creates appropriate
                #  wrapper class type and then prints contents
                disp_def.append("    if (m_struct.%s) {" % (ms['name']))
                #disp_def.append('        printf("%*s    This is where we would call dynamic print function\\n", m_indent, "");')
                disp_def.append('        dynamic_display_full_txt(m_struct.%s, m_indent);' % (ms['name']))
                disp_def.append("    }")
            else:
                if ms['ptr']:
                    disp_def.append("    if (m_struct.%s) {" % (ms['name']))
                    disp_def.append("        %s %s(m_struct.%s);" % (self.get_class_name(ms['type']), swc_name, ms['name']))
                else:
                    disp_def.append("    if (&m_struct.%s) {" % (ms['name']))
                    disp_def.append("        %s %s(&m_struct.%s);" % (self.get_class_name(ms['type']), swc_name, ms['name']))
                disp_def.append("        %s.set_indent(m_indent + 4);" % (swc_name))
                disp_def.append("        %s.display_full_txt();\n    }" % (swc_name))
            class_num += 1
        disp_def.append("}\n")
        return "\n".join(disp_def)
        
    def _generateStringHelperHeader(self):
        header = []
        header.append("//#includes, #defines, globals and such...\n")
        for f in self.include_headers:
            if 'vk_enum_string_helper' not in f:
                header.append("#include <%s>\n" % f)
        header.append('#include "vk_enum_string_helper.h"\n\n// Function Prototypes\n')
        header.append("char* dynamic_display(const void* pStruct, const char* prefix);\n")
        return "".join(header)

    def _generateStringHelperHeaderCpp(self):
        header = []
        header.append("//#includes, #defines, globals and such...\n")
        for f in self.include_headers:
            if 'vk_enum_string_helper' not in f:
                header.append("#include <%s>\n" % f)
        header.append('#include "vk_enum_string_helper.h"\n')
        header.append('using namespace std;\n\n// Function Prototypes\n')
        header.append('\n')
        header.append('namespace StreamControl\n')
        header.append('{\n')
        header.append('bool writeAddress = true;\n')
        header.append('template <typename T>\n')
        header.append('std::ostream& operator<< (std::ostream &out, T const* pointer)\n')
        header.append('{\n')
        header.append('    if(writeAddress)\n')
        header.append('    {\n')
        header.append('        out.operator<<(pointer);\n')
        header.append('    }\n')
        header.append('    else\n')
        header.append('    {\n')
        header.append('        std::operator<<(out, "address");\n')
        header.append('    }\n')
        header.append('    return out;\n')
        header.append('}\n')
        header.append('std::ostream& operator<<(std::ostream &out, char const*const s)\n')
        header.append('{\n')
        header.append('    return std::operator<<(out, s);\n')
        header.append('}\n')
        header.append('}\n')
        header.append('\n')
        header.append("string dynamic_display(const void* pStruct, const string prefix);\n")
        return "".join(header)

    def _generateValidateHelperFunctions(self):
        sh_funcs = []
        # We do two passes, first pass just generates prototypes for all the functsions
        for s in sorted(self.struct_dict):
            sh_funcs.append('uint32_t %s(const %s* pStruct);' % (self._get_vh_func_name(s), typedef_fwd_dict[s]))
        sh_funcs.append('\n')
        for s in sorted(self.struct_dict):
            sh_funcs.append('uint32_t %s(const %s* pStruct)\n{' % (self._get_vh_func_name(s), typedef_fwd_dict[s]))
            for m in sorted(self.struct_dict[s]):
                # TODO : Need to handle arrays of enums like in VkRenderPassCreateInfo struct
                if is_type(self.struct_dict[s][m]['type'], 'enum') and not self.struct_dict[s][m]['ptr']:
                    sh_funcs.append('    if (!validate_%s(pStruct->%s))\n        return 0;' % (self.struct_dict[s][m]['type'], self.struct_dict[s][m]['name']))
                # TODO : Need a little refinement to this code to make sure type of struct matches expected input (ptr, const...)
                if is_type(self.struct_dict[s][m]['type'], 'struct'):
                    if (self.struct_dict[s][m]['ptr']):
                        sh_funcs.append('    if (pStruct->%s && !%s((const %s*)pStruct->%s))\n        return 0;' % (self.struct_dict[s][m]['name'], self._get_vh_func_name(self.struct_dict[s][m]['type']), self.struct_dict[s][m]['type'], self.struct_dict[s][m]['name']))
                    else:
                        sh_funcs.append('    if (!%s((const %s*)&pStruct->%s))\n        return 0;' % (self._get_vh_func_name(self.struct_dict[s][m]['type']), self.struct_dict[s][m]['type'], self.struct_dict[s][m]['name']))
            sh_funcs.append("    return 1;\n}")

        return "\n".join(sh_funcs)

    def _generateValidateHelperHeader(self):
        header = []
        header.append("//#includes, #defines, globals and such...\n")
        for f in self.include_headers:
            if 'vk_enum_validate_helper' not in f:
                header.append("#include <%s>\n" % f)
        header.append('#include "vk_enum_validate_helper.h"\n\n// Function Prototypes\n')
        #header.append("char* dynamic_display(const void* pStruct, const char* prefix);\n")
        return "".join(header)

    def _generateSizeHelperFunctions(self):
        sh_funcs = []
        # just generates prototypes for all the functions
        for s in sorted(self.struct_dict):
            sh_funcs.append('size_t %s(const %s* pStruct);' % (self._get_size_helper_func_name(s), typedef_fwd_dict[s]))
        return "\n".join(sh_funcs)


    def _generateSizeHelperFunctionsC(self):
        sh_funcs = []
        # generate function definitions
        for s in sorted(self.struct_dict):
            skip_list = [] # Used when struct elements need to be skipped b/c size already accounted for
            sh_funcs.append('size_t %s(const %s* pStruct)\n{' % (self._get_size_helper_func_name(s), typedef_fwd_dict[s]))
            indent = '    '
            sh_funcs.append('%ssize_t structSize = 0;' % (indent))
            sh_funcs.append('%sif (pStruct) {' % (indent))
            indent = '        '
            sh_funcs.append('%sstructSize = sizeof(%s);' % (indent, typedef_fwd_dict[s]))
            i_decl = False
            for m in sorted(self.struct_dict[s]):
                if m in skip_list:
                    continue
                if self.struct_dict[s][m]['dyn_array']:
                    if self.struct_dict[s][m]['full_type'].count('*') > 1:
                        if not is_type(self.struct_dict[s][m]['type'], 'struct') and not 'char' in self.struct_dict[s][m]['type'].lower():
                            if 'ppMemBarriers' == self.struct_dict[s][m]['name']:
                                # TODO : For now be conservative and consider all memBarrier ptrs as largest possible struct
                                sh_funcs.append('%sstructSize += pStruct->%s*(sizeof(%s*) + sizeof(VkImageMemoryBarrier));' % (indent, self.struct_dict[s][m]['array_size'], self.struct_dict[s][m]['type']))
                            else:
                                sh_funcs.append('%sstructSize += pStruct->%s*(sizeof(%s*) + sizeof(%s));' % (indent, self.struct_dict[s][m]['array_size'], self.struct_dict[s][m]['type'], self.struct_dict[s][m]['type']))
                        else: # This is an array of char* or array of struct ptrs
                            if not i_decl:
                                sh_funcs.append('%suint32_t i = 0;' % (indent))
                                i_decl = True
                            sh_funcs.append('%sfor (i = 0; i < pStruct->%s; i++) {' % (indent, self.struct_dict[s][m]['array_size']))
                            indent = '            '
                            if is_type(self.struct_dict[s][m]['type'], 'struct'):
                                sh_funcs.append('%sstructSize += (sizeof(%s*) + %s(pStruct->%s[i]));' % (indent, self.struct_dict[s][m]['type'], self._get_size_helper_func_name(self.struct_dict[s][m]['type']), self.struct_dict[s][m]['name']))
                            else:
                                sh_funcs.append('%sstructSize += (sizeof(char*) + (sizeof(char) * (1 + strlen(pStruct->%s[i]))));' % (indent, self.struct_dict[s][m]['name']))
                            indent = '        '
                            sh_funcs.append('%s}' % (indent))
                    else:
                        if is_type(self.struct_dict[s][m]['type'], 'struct'):
                            if not i_decl:
                                sh_funcs.append('%suint32_t i = 0;' % (indent))
                                i_decl = True
                            sh_funcs.append('%sfor (i = 0; i < pStruct->%s; i++) {' % (indent, self.struct_dict[s][m]['array_size']))
                            indent = '            '
                            sh_funcs.append('%sstructSize += %s(&pStruct->%s[i]);' % (indent, self._get_size_helper_func_name(self.struct_dict[s][m]['type']), self.struct_dict[s][m]['name']))
                            indent = '        '
                            sh_funcs.append('%s}' % (indent))
                        else:
                            sh_funcs.append('%sstructSize += pStruct->%s*sizeof(%s);' % (indent, self.struct_dict[s][m]['array_size'], self.struct_dict[s][m]['type']))
                elif self.struct_dict[s][m]['ptr'] and 'pNext' != self.struct_dict[s][m]['name']:
                    if 'char' in self.struct_dict[s][m]['type'].lower():
                        sh_funcs.append('%sstructSize += sizeof(%s)*(1+strlen(pStruct->%s));' % (indent, self.struct_dict[s][m]['type'], self.struct_dict[s][m]['name']))
                    elif is_type(self.struct_dict[s][m]['type'], 'struct'):
                        sh_funcs.append('%sstructSize += %s(pStruct->%s);' % (indent, self._get_size_helper_func_name(self.struct_dict[s][m]['type']), self.struct_dict[s][m]['name']))
                    elif 'void' not in self.struct_dict[s][m]['type'].lower():
                        sh_funcs.append('%sstructSize += sizeof(%s);' % (indent, self.struct_dict[s][m]['type']))
                elif 'size_t' == self.struct_dict[s][m]['type'].lower():
                    sh_funcs.append('%sstructSize += pStruct->%s;' % (indent, self.struct_dict[s][m]['name']))
                    skip_list.append(m+1)
            indent = '    '
            sh_funcs.append('%s}' % (indent))
            sh_funcs.append("%sreturn structSize;\n}" % (indent))
        # Now generate generic functions to loop over entire struct chain (or just handle single generic structs)
        for follow_chain in [True, False]:
            if follow_chain:
                sh_funcs.append('size_t get_struct_chain_size(const void* pStruct)\n{')
            else:
                sh_funcs.append('size_t get_dynamic_struct_size(const void* pStruct)\n{')
            indent = '    '
            sh_funcs.append('%s// Just use VkApplicationInfo as struct until actual type is resolved' % (indent))
            sh_funcs.append('%sVkApplicationInfo* pNext = (VkApplicationInfo*)pStruct;' % (indent))
            sh_funcs.append('%ssize_t structSize = 0;' % (indent))
            if follow_chain:
                sh_funcs.append('%swhile (pNext) {' % (indent))
                indent = '        '
            sh_funcs.append('%sswitch (pNext->sType) {' % (indent))
            indent += '    '
            for e in enum_type_dict:
                if 'StructureType' in e:
                    for v in sorted(enum_type_dict[e]):
                        struct_name = get_struct_name_from_struct_type(v)
                        sh_funcs.append('%scase %s:' % (indent, v))
                        sh_funcs.append('%s{' % (indent))
                        indent += '    '
                        sh_funcs.append('%sstructSize += %s((%s*)pNext);' % (indent, self._get_size_helper_func_name(struct_name), struct_name))
                        sh_funcs.append('%sbreak;' % (indent))
                        indent = indent[:-4]
                        sh_funcs.append('%s}' % (indent))
                    sh_funcs.append('%sdefault:' % (indent))
                    indent += '    '
                    sh_funcs.append('%sassert(0);' % (indent))
                    sh_funcs.append('%sstructSize += 0;' % (indent))
                    indent = indent[:-4]
            indent = indent[:-4]
            sh_funcs.append('%s}' % (indent))
            if follow_chain:
                sh_funcs.append('%spNext = (VkApplicationInfo*)pNext->pNext;' % (indent))
                indent = indent[:-4]
                sh_funcs.append('%s}' % (indent))
            sh_funcs.append('%sreturn structSize;\n}' % indent)
        return "\n".join(sh_funcs)

    def _generateSizeHelperHeader(self):
        header = []
        header.append("//#includes, #defines, globals and such...\n")
        for f in self.include_headers:
            header.append("#include <%s>\n" % f)
        header.append('\n// Function Prototypes\n')
        header.append("size_t get_struct_chain_size(const void* pStruct);\n")
        header.append("size_t get_dynamic_struct_size(const void* pStruct);\n")
        return "".join(header)

    def _generateSizeHelperHeaderC(self):
        header = []
        header.append('#include "vk_struct_size_helper.h"')
        header.append('#include <string.h>')
        header.append('#include <assert.h>')
        header.append('\n// Function definitions\n')
        return "\n".join(header)


    def _generateHeader(self):
        header = []
        header.append("//#includes, #defines, globals and such...\n")
        for f in self.include_headers:
            header.append("#include <%s>\n" % f)
        return "".join(header)
    
    # Declarations
    def _generateConstructorDeclarations(self, s):
        constructors = []
        constructors.append("    %s();\n" % self.get_class_name(s))
        constructors.append("    %s(%s* pInStruct);\n" % (self.get_class_name(s), typedef_fwd_dict[s]))
        constructors.append("    %s(const %s* pInStruct);\n" % (self.get_class_name(s), typedef_fwd_dict[s]))
        return "".join(constructors)
    
    def _generateDestructorDeclarations(self, s):
        return "    virtual ~%s();\n" % self.get_class_name(s)
        
    def _generateDisplayDeclarations(self, s):
        return "    void display_txt();\n    void display_single_txt();\n    void display_full_txt();\n"
        
    def _generateGetSetDeclarations(self, s):
        get_set = []
        get_set.append("    void set_indent(uint32_t indent) { m_indent = indent; }\n")
        for member in sorted(self.struct_dict[s]):
            # TODO : Skipping array set/get funcs for now
            if self.struct_dict[s][member]['array']:
                continue
            get_set.append("    %s get_%s() { return m_struct.%s; }\n" % (self.struct_dict[s][member]['full_type'], self.struct_dict[s][member]['name'], self.struct_dict[s][member]['name']))
            if not self.struct_dict[s][member]['const']:
                get_set.append("    void set_%s(%s inValue) { m_struct.%s = inValue; }\n" % (self.struct_dict[s][member]['name'], self.struct_dict[s][member]['full_type'], self.struct_dict[s][member]['name']))
        return "".join(get_set)
    
    def _generatePrivateMembers(self, s):
        priv = []
        priv.append("\nprivate:\n")
        priv.append("    %s m_struct;\n" % typedef_fwd_dict[s])
        priv.append("    const %s* m_origStructAddr;\n" % typedef_fwd_dict[s])
        priv.append("    uint32_t m_indent;\n")
        priv.append("    const char m_dummy_prefix;\n")
        priv.append("    void display_struct_members();\n")
        return "".join(priv)
    
    def _generateClassDeclaration(self):
        class_decl = []
        for s in sorted(self.struct_dict):
            class_decl.append("\n//class declaration")
            class_decl.append("class %s\n{\npublic:" % self.get_class_name(s))
            class_decl.append(self._generateConstructorDeclarations(s))
            class_decl.append(self._generateDestructorDeclarations(s))
            class_decl.append(self._generateDisplayDeclarations(s))
            class_decl.append(self._generateGetSetDeclarations(s))
            class_decl.append(self._generatePrivateMembers(s))
            class_decl.append("};\n")
        return "\n".join(class_decl)
        
    def _generateFooter(self):
        return "\n//any footer info for class\n"

class EnumCodeGen:
    def __init__(self, enum_type_dict=None, enum_val_dict=None, typedef_fwd_dict=None, in_file=None, out_sh_file=None, out_vh_file=None):
        self.et_dict = enum_type_dict
        self.ev_dict = enum_val_dict
        self.tf_dict = typedef_fwd_dict
        self.in_file = in_file
        self.out_sh_file = out_sh_file
        self.eshfg = CommonFileGen(self.out_sh_file)
        self.out_vh_file = out_vh_file
        self.evhfg = CommonFileGen(self.out_vh_file)
        
    def generateStringHelper(self):
        self.eshfg.setHeader(self._generateSHHeader())
        self.eshfg.setBody(self._generateSHBody())
        self.eshfg.generate()

    def generateEnumValidate(self):
        self.evhfg.setHeader(self._generateSHHeader())
        self.evhfg.setBody(self._generateVHBody())
        self.evhfg.generate()

    def _generateVHBody(self):
        body = []
        for bet in sorted(self.et_dict):
            fet = self.tf_dict[bet]
            body.append("static inline uint32_t validate_%s(%s input_value)\n{" % (fet, fet))
            # TODO : This is not ideal, but allows for flag combinations. Need more rigorous validation of realistic flag combinations
            if 'flagbits' in bet.lower():
                body.append('    if (input_value > (%s))' % (' | '.join(self.et_dict[bet])))
                body.append('        return 0;')
                body.append('    return 1;')
                body.append('}\n\n')
            else:
                body.append('    switch ((%s)input_value)\n    {' % (fet))
                for e in sorted(self.et_dict[bet]):
                    if (self.ev_dict[e]['unique']):
                        body.append('        case %s:' % (e))
                body.append('            return 1;\n        default:\n            return 0;\n    }\n}\n\n')
        return "\n".join(body)

    def _generateSHBody(self):
        body = []
#        with open(self.out_file, "a") as hf:
            # bet == base_enum_type, fet == final_enum_type
        for bet in sorted(self.et_dict):
            fet = self.tf_dict[bet]
            body.append("static inline const char* string_%s(%s input_value)\n{\n    switch ((%s)input_value)\n    {" % (fet, fet, fet))
            for e in sorted(self.et_dict[bet]):
                if (self.ev_dict[e]['unique']):
                    body.append('        case %s:\n            return "%s";' % (e, e))
            body.append('        default:\n            return "Unhandled %s";\n    }\n}\n\n' % (fet))
        return "\n".join(body)
    
    def _generateSHHeader(self):
        header = []
        header.append('#pragma once\n')
        header.append('#ifdef _WIN32\n')
        header.append('#pragma warning( disable : 4065 )\n')
        header.append('#endif\n')
        header.append('#include <%s>\n\n\n' % self.in_file)
        return "\n".join(header)
        

class CMakeGen:
    def __init__(self, struct_wrapper=None, out_dir=None):
        self.sw = struct_wrapper
        self.include_headers = []
        self.add_lib_file_list = self.sw.get_file_list()
        self.out_dir = out_dir
        self.out_file = os.path.join(self.out_dir, "CMakeLists.txt")
        self.cmg = CommonFileGen(self.out_file)
        
    def generate(self):
        self.cmg.setBody(self._generateBody())
        self.cmg.generate()
        
    def _generateBody(self):
        body = []
        body.append("project(%s)" % os.path.basename(self.out_dir))
        body.append("cmake_minimum_required(VERSION 2.8)\n")
        body.append("add_library(${PROJECT_NAME} %s)\n" % " ".join(self.add_lib_file_list))
        body.append('set(COMPILE_FLAGS "-fpermissive")')
        body.append('set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS}")\n')
        body.append("include_directories(${SRC_DIR}/thirdparty/${GEN_API}/inc/)\n")
        body.append("target_include_directories (%s PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})\n" % os.path.basename(self.out_dir))
        return "\n".join(body)

class GraphVizGen:
    def __init__(self, struct_dict, prefix, out_dir):
        self.struct_dict = struct_dict
        self.api = prefix
        if prefix == "vulkan":
            self.api_prefix = "vk"
        else:
            self.api_prefix = prefix
        self.out_file = os.path.join(out_dir, self.api_prefix+"_struct_graphviz_helper.h")
        self.gvg = CommonFileGen(self.out_file)

    def generate(self):
        self.gvg.setCopyright("//This is the copyright\n")
        self.gvg.setHeader(self._generateHeader())
        self.gvg.setBody(self._generateBody())
        #self.gvg.setFooter('}')
        self.gvg.generate()

    def set_include_headers(self, include_headers):
        self.include_headers = include_headers

    def _generateHeader(self):
        header = []
        header.append("//#includes, #defines, globals and such...\n")
        for f in self.include_headers:
            if 'vk_enum_string_helper' not in f:
                header.append("#include <%s>\n" % f)
        #header.append('#include "vk_enum_string_helper.h"\n\n// Function Prototypes\n')
        header.append("\nchar* dynamic_gv_display(const void* pStruct, const char* prefix);\n")
        return "".join(header)

    def _get_gv_func_name(self, struct):
        return "%s_gv_print_%s" % (self.api_prefix, struct.lower().strip("_"))

    # Return elements to create formatted string for given struct member
    def _get_struct_gv_print_formatted(self, struct_member, pre_var_name="", postfix = "\\n", struct_var_name="pStruct", struct_ptr=True, print_array=False, port_label=""):
        struct_op = "->"
        pre_var_name = '"%s "' % struct_member['full_type']
        if not struct_ptr:
            struct_op = "."
        member_name = struct_member['name']
        print_type = "p"
        cast_type = ""
        member_post = ""
        array_index = ""
        member_print_post = ""
        print_delimiter = "%"
        if struct_member['array'] and 'char' in struct_member['type'].lower(): # just print char array as string
            print_type = "p"
            print_array = False
        elif struct_member['array'] and not print_array:
            # Just print base address of array when not full print_array
            cast_type = "(void*)"
        elif is_type(struct_member['type'], 'enum'):
            if struct_member['ptr']:
                struct_var_name = "*" + struct_var_name
            cast_type = "string_%s" % struct_member['type']
            print_type = "s"
        elif is_type(struct_member['type'], 'struct'): # print struct address for now
            cast_type = "(void*)"
            if not struct_member['ptr']:
                cast_type = "(void*)&"
        elif 'bool' in struct_member['type']:
            print_type = "s"
            member_post = ' ? "TRUE" : "FALSE"'
        elif 'float' in struct_member['type']:
            print_type = "f"
        elif 'uint64' in struct_member['type'] or 'gpusize' in struct_member['type'].lower():
            print_type = '" PRId64 "'
        elif 'uint8' in struct_member['type']:
            print_type = "hu"
        elif 'size' in struct_member['type'].lower():
            print_type = '" PRINTF_SIZE_T_SPECIFIER "'
            print_delimiter = ""
        elif True in [ui_str.lower() in struct_member['type'].lower() for ui_str in ['uint', 'flags', 'samplemask']]:
            print_type = "u"
        elif 'int' in struct_member['type']:
            print_type = "i"
        elif struct_member['ptr']:
            pass
        else:
            #print("Unhandled struct type: %s" % struct_member['type'])
            cast_type = "(void*)"
        if print_array and struct_member['array']:
            member_print_post = "[%u]"
            array_index = " i,"
            member_post = "[i]"
        print_out = "<TR><TD>%%s%s%s</TD><TD%s>%s%s%s</TD></TR>" % (member_name, member_print_post, port_label, print_delimiter, print_type, postfix) # section of print that goes inside of quotes
        print_arg = ", %s,%s %s(%s%s%s)%s\n" % (pre_var_name, array_index, cast_type, struct_var_name, struct_op, member_name, member_post) # section of print passed to portion in quotes
        return (print_out, print_arg)

    def _generateBody(self):
        gv_funcs = []
        array_func_list = [] # structs for which we'll generate an array version of their print function
        array_func_list.append('vkbufferviewattachinfo')
        array_func_list.append('vkimageviewattachinfo')
        array_func_list.append('vksamplerimageviewinfo')
        array_func_list.append('vkdescriptortypecount')
        # For first pass, generate prototype
        for s in sorted(self.struct_dict):
            gv_funcs.append('char* %s(const %s* pStruct, const char* myNodeName);\n' % (self._get_gv_func_name(s), typedef_fwd_dict[s]))
            if s.lower().strip("_") in array_func_list:
                if s.lower().strip("_") in ['vkbufferviewattachinfo', 'vkimageviewattachinfo']:
                    gv_funcs.append('char* %s_array(uint32_t count, const %s* const* pStruct, const char* myNodeName);\n' % (self._get_gv_func_name(s), typedef_fwd_dict[s]))
                else:
                    gv_funcs.append('char* %s_array(uint32_t count, const %s* pStruct, const char* myNodeName);\n' % (self._get_gv_func_name(s), typedef_fwd_dict[s]))
        gv_funcs.append('\n')
        for s in sorted(self.struct_dict):
            p_out = ""
            p_args = ""
            stp_list = [] # stp == "struct to print" a list of structs for this API call that should be printed as structs
            # the fields below are a super-hacky way for now to get port labels into GV output, TODO : Clean this up!            
            pl_dict = {}
            struct_num = 0
            # This isn't great but this pre-pass flags structs w/ pNext and other struct ptrs
            for m in sorted(self.struct_dict[s]):
                if 'pNext' == self.struct_dict[s][m]['name'] or is_type(self.struct_dict[s][m]['type'], 'struct'):
                    stp_list.append(self.struct_dict[s][m])
                    if 'pNext' == self.struct_dict[s][m]['name']:
                        pl_dict[m] = ' PORT=\\"pNext\\"'
                    else:
                        pl_dict[m] = ' PORT=\\"struct%i\\"' % struct_num
                    struct_num += 1
            gv_funcs.append('char* %s(const %s* pStruct, const char* myNodeName)\n{\n    char* str;\n' % (self._get_gv_func_name(s), typedef_fwd_dict[s]))
            num_stps = len(stp_list);
            total_strlen_str = ''
            if 0 != num_stps:
                gv_funcs.append("    char* tmpStr;\n")
                gv_funcs.append("    char nodeName[100];\n")
                gv_funcs.append('    char* stp_strs[%i];\n' % num_stps)
                for index in range(num_stps):
                    if (stp_list[index]['ptr']):
                        if 'pDescriptorInfo' == stp_list[index]['name']:
                            gv_funcs.append('    if (pStruct->pDescriptorInfo && (0 != pStruct->descriptorCount)) {\n')
                        else:
                            gv_funcs.append('    if (pStruct->%s) {\n' % stp_list[index]['name'])
                        if 'pNext' == stp_list[index]['name']:
                            gv_funcs.append('        sprintf(nodeName, "pNext_%p", (void*)pStruct->pNext);\n')
                            gv_funcs.append('        tmpStr = dynamic_gv_display((void*)pStruct->pNext, nodeName);\n')
                            gv_funcs.append('        stp_strs[%i] = (char*)malloc(256+strlen(tmpStr)+strlen(nodeName)+strlen(myNodeName));\n' % index)
                            gv_funcs.append('        sprintf(stp_strs[%i], "%%s\\n\\"%%s\\":pNext -> \\"%%s\\" [];\\n", tmpStr, myNodeName, nodeName);\n' % index)
                            gv_funcs.append('        free(tmpStr);\n')
                        else:
                            gv_funcs.append('        sprintf(nodeName, "%s_%%p", (void*)pStruct->%s);\n' % (stp_list[index]['name'], stp_list[index]['name']))
                            if stp_list[index]['name'] in ['pTypeCount', 'pSamplerImageViews']:
                                gv_funcs.append('        tmpStr = %s_array(pStruct->count, pStruct->%s, nodeName);\n' % (self._get_gv_func_name(stp_list[index]['type']), stp_list[index]['name']))
                            else:
                                gv_funcs.append('        tmpStr = %s(pStruct->%s, nodeName);\n' % (self._get_gv_func_name(stp_list[index]['type']), stp_list[index]['name']))
                            gv_funcs.append('        stp_strs[%i] = (char*)malloc(256+strlen(tmpStr)+strlen(nodeName)+strlen(myNodeName));\n' % (index))
                            gv_funcs.append('        sprintf(stp_strs[%i], "%%s\\n\\"%%s\\":struct%i -> \\"%%s\\" [];\\n", tmpStr, myNodeName, nodeName);\n' % (index, index))
                        gv_funcs.append('    }\n')
                        gv_funcs.append("    else\n        stp_strs[%i] = \"\";\n" % (index))
                    elif stp_list[index]['array']: # TODO : For now just printing first element of array
                        gv_funcs.append('    sprintf(nodeName, "%s_%%p", (void*)&pStruct->%s[0]);\n' % (stp_list[index]['name'], stp_list[index]['name']))
                        gv_funcs.append('    tmpStr = %s(&pStruct->%s[0], nodeName);\n' % (self._get_gv_func_name(stp_list[index]['type']), stp_list[index]['name']))
                        gv_funcs.append('    stp_strs[%i] = (char*)malloc(256+strlen(tmpStr)+strlen(nodeName)+strlen(myNodeName));\n' % (index))
                        gv_funcs.append('    sprintf(stp_strs[%i], "%%s\\n\\"%%s\\":struct%i -> \\"%%s\\" [];\\n", tmpStr, myNodeName, nodeName);\n' % (index, index))
                    else:
                        gv_funcs.append('    sprintf(nodeName, "%s_%%p", (void*)&pStruct->%s);\n' % (stp_list[index]['name'], stp_list[index]['name']))
                        gv_funcs.append('    tmpStr = %s(&pStruct->%s, nodeName);\n' % (self._get_gv_func_name(stp_list[index]['type']), stp_list[index]['name']))
                        gv_funcs.append('    stp_strs[%i] = (char*)malloc(256+strlen(tmpStr)+strlen(nodeName)+strlen(myNodeName));\n' % (index))
                        gv_funcs.append('    sprintf(stp_strs[%i], "%%s\\n\\"%%s\\":struct%i -> \\"%%s\\" [];\\n", tmpStr, myNodeName, nodeName);\n' % (index, index))
                    total_strlen_str += 'strlen(stp_strs[%i]) + ' % index
            gv_funcs.append('    str = (char*)malloc(%ssizeof(char)*2048);\n' % (total_strlen_str))
            gv_funcs.append('    sprintf(str, "\\"%s\\" [\\nlabel = <<TABLE BORDER=\\"0\\" CELLBORDER=\\"1\\" CELLSPACING=\\"0\\"><TR><TD COLSPAN=\\"2\\">%s (%p)</TD></TR>')
            p_args = ", myNodeName, myNodeName, pStruct"
            for m in sorted(self.struct_dict[s]):
                plabel = ""
                if m in pl_dict:
                    plabel = pl_dict[m]
                (p_out1, p_args1) = self._get_struct_gv_print_formatted(self.struct_dict[s][m], port_label=plabel)
                p_out += p_out1
                p_args += p_args1
            p_out += '</TABLE>>\\n];\\n\\n"'
            p_args += ");\n"
            gv_funcs.append(p_out)
            gv_funcs.append(p_args)
            if 0 != num_stps:
                gv_funcs.append('    for (int32_t stp_index = %i; stp_index >= 0; stp_index--) {\n' % (num_stps-1))
                gv_funcs.append('        if (0 < strlen(stp_strs[stp_index])) {\n')
                gv_funcs.append('            strncat(str, stp_strs[stp_index], strlen(stp_strs[stp_index]));\n')
                gv_funcs.append('            free(stp_strs[stp_index]);\n')
                gv_funcs.append('        }\n')
                gv_funcs.append('    }\n')
            gv_funcs.append("    return str;\n}\n")
            if s.lower().strip("_") in array_func_list:
                ptr_array = False
                if s.lower().strip("_") in ['vkbufferviewattachinfo', 'vkimageviewattachinfo']:
                    ptr_array = True
                    gv_funcs.append('char* %s_array(uint32_t count, const %s* const* pStruct, const char* myNodeName)\n{\n    char* str;\n    char tmpStr[1024];\n' % (self._get_gv_func_name(s), typedef_fwd_dict[s]))
                else:
                    gv_funcs.append('char* %s_array(uint32_t count, const %s* pStruct, const char* myNodeName)\n{\n    char* str;\n    char tmpStr[1024];\n' % (self._get_gv_func_name(s), typedef_fwd_dict[s]))
                gv_funcs.append('    str = (char*)malloc(sizeof(char)*1024*count);\n')
                gv_funcs.append('    sprintf(str, "\\"%s\\" [\\nlabel = <<TABLE BORDER=\\"0\\" CELLBORDER=\\"1\\" CELLSPACING=\\"0\\"><TR><TD COLSPAN=\\"3\\">%s (%p)</TD></TR>", myNodeName, myNodeName, pStruct);\n')
                gv_funcs.append('    for (uint32_t i=0; i < count; i++) {\n')
                gv_funcs.append('        sprintf(tmpStr, "');
                p_args = ""
                p_out = ""
                for m in sorted(self.struct_dict[s]):
                    plabel = ""
                    (p_out1, p_args1) = self._get_struct_gv_print_formatted(self.struct_dict[s][m], port_label=plabel)
                    if 0 == m: # Add array index notation at end of first row
                        p_out1 = '%s<TD ROWSPAN=\\"%i\\" PORT=\\"slot%%u\\">%%u</TD></TR>' % (p_out1[:-5], len(self.struct_dict[s]))
                        p_args1 += ', i, i'
                    p_out += p_out1
                    p_args += p_args1
                p_out += '"'
                p_args += ");\n"
                if ptr_array:
                    p_args = p_args.replace('->', '[i]->')
                else:
                    p_args = p_args.replace('->', '[i].')
                gv_funcs.append(p_out);
                gv_funcs.append(p_args);
                gv_funcs.append('        strncat(str, tmpStr, strlen(tmpStr));\n')
                gv_funcs.append('    }\n')
                gv_funcs.append('    strncat(str, "</TABLE>>\\n];\\n\\n", 20);\n')
                gv_funcs.append('    return str;\n}\n')
        # Add function to dynamically print out unknown struct
        gv_funcs.append("char* dynamic_gv_display(const void* pStruct, const char* nodeName)\n{\n")
        gv_funcs.append("    // Cast to APP_INFO ptr initially just to pull sType off struct\n")
        gv_funcs.append("    VkStructureType sType = ((VkApplicationInfo*)pStruct)->sType;\n")
        gv_funcs.append("    switch (sType)\n    {\n")
        for e in enum_type_dict:
            if "StructureType" in e:
                for v in sorted(enum_type_dict[e]):
                    struct_name = get_struct_name_from_struct_type(v)
                    print_func_name = self._get_gv_func_name(struct_name)
                    # TODO : Hand-coded fixes for some exceptions
                    #if 'VkPipelineCbStateCreateInfo' in struct_name:
                    #    struct_name = 'VK_PIPELINE_CB_STATE'
                    if 'VkSemaphoreCreateInfo' in struct_name:
                        struct_name = 'VkSemaphoreCreateInfo'
                        print_func_name = self._get_gv_func_name(struct_name)
                    elif 'VkSemaphoreOpenInfo' in struct_name:
                        struct_name = 'VkSemaphoreOpenInfo'
                        print_func_name = self._get_gv_func_name(struct_name)
                    gv_funcs.append('        case %s:\n' % (v))
                    gv_funcs.append('            return %s((%s*)pStruct, nodeName);\n' % (print_func_name, struct_name))
                    #gv_funcs.append('        }\n')
                    #gv_funcs.append('        break;\n')
                gv_funcs.append("        default:\n")
                gv_funcs.append("        return NULL;\n")
                gv_funcs.append("    }\n")
        gv_funcs.append("}")
        return "".join(gv_funcs)





#    def _generateHeader(self):
#        hdr = []
#        hdr.append('digraph g {\ngraph [\nrankdir = "LR"\n];')
#        hdr.append('node [\nfontsize = "16"\nshape = "plaintext"\n];')
#        hdr.append('edge [\n];\n')
#        return "\n".join(hdr)
#        
#    def _generateBody(self):
#        body = []
#        for s in sorted(self.struc_dict):
#            field_num = 1
#            body.append('"%s" [\nlabel = <<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"> <TR><TD COLSPAN="2" PORT="f0">%s</TD></TR>' % (s, typedef_fwd_dict[s]))
#            for m in sorted(self.struc_dict[s]):
#                body.append('<TR><TD PORT="f%i">%s</TD><TD PORT="f%i">%s</TD></TR>' % (field_num, self.struc_dict[s][m]['full_type'], field_num+1, self.struc_dict[s][m]['name']))
#                field_num += 2
#            body.append('</TABLE>>\n];\n')
#        return "".join(body)

def main(argv=None):
    opts = handle_args()
    # Parse input file and fill out global dicts
    hfp = HeaderFileParser(opts.input_file)
    hfp.parse()
    # TODO : Don't want these to be global, see note at top about wrapper classes
    global enum_val_dict
    global enum_type_dict
    global struct_dict
    global typedef_fwd_dict
    global typedef_rev_dict
    global types_dict
    enum_val_dict = hfp.get_enum_val_dict()
    enum_type_dict = hfp.get_enum_type_dict()
    struct_dict = hfp.get_struct_dict()
    # TODO : Would like to validate struct data here to verify that all of the bools for struct members are correct at this point
    typedef_fwd_dict = hfp.get_typedef_fwd_dict()
    typedef_rev_dict = hfp.get_typedef_rev_dict()
    types_dict = hfp.get_types_dict()
    #print(enum_val_dict)
    #print(typedef_dict)
    #print(struct_dict)
    prefix = os.path.basename(opts.input_file).strip(".h")
    if prefix == "vulkan":
        prefix = "vk"
    if (opts.abs_out_dir is not None):
        enum_sh_filename = os.path.join(opts.abs_out_dir, prefix+"_enum_string_helper.h")
    else:
        enum_sh_filename = os.path.join(os.getcwd(), opts.rel_out_dir, prefix+"_enum_string_helper.h")
    enum_sh_filename = os.path.abspath(enum_sh_filename)
    if not os.path.exists(os.path.dirname(enum_sh_filename)):
        print("Creating output dir %s" % os.path.dirname(enum_sh_filename))
        os.mkdir(os.path.dirname(enum_sh_filename))
    if opts.gen_enum_string_helper:
        print("Generating enum string helper to %s" % enum_sh_filename)
        enum_vh_filename = os.path.join(os.path.dirname(enum_sh_filename), prefix+"_enum_validate_helper.h")
        print("Generating enum validate helper to %s" % enum_vh_filename)
        eg = EnumCodeGen(enum_type_dict, enum_val_dict, typedef_fwd_dict, os.path.basename(opts.input_file), enum_sh_filename, enum_vh_filename)
        eg.generateStringHelper()
        eg.generateEnumValidate()
    #for struct in struct_dict:
    #print(struct)
    if opts.gen_struct_wrappers:
        sw = StructWrapperGen(struct_dict, os.path.basename(opts.input_file).strip(".h"), os.path.dirname(enum_sh_filename))
        #print(sw.get_class_name(struct))
        sw.set_include_headers([os.path.basename(opts.input_file),os.path.basename(enum_sh_filename),"stdint.h","inttypes.h", "stdio.h","stdlib.h"])
        print("Generating struct wrapper header to %s" % sw.header_filename)
        sw.generateHeader()
        print("Generating struct wrapper class to %s" % sw.class_filename)
        sw.generateBody()
        sw.generateStringHelper()
        sw.generateValidateHelper()
        # Generate a 2nd helper file that excludes addrs
        sw.set_no_addr(True)
        sw.generateStringHelper()
        sw.set_no_addr(False)
        sw.set_include_headers([os.path.basename(opts.input_file),os.path.basename(enum_sh_filename),"stdint.h","stdio.h","stdlib.h","iostream","sstream","string"])
        sw.set_no_addr(True)
        sw.generateStringHelperCpp()
        sw.set_no_addr(False)
        sw.generateStringHelperCpp()
        sw.set_include_headers(["stdio.h", "stdlib.h", "vulkan.h"])
        sw.generateSizeHelper()
        sw.generateSizeHelperC()
    if opts.gen_cmake:
        cmg = CMakeGen(sw, os.path.dirname(enum_sh_filename))
        cmg.generate()
    if opts.gen_graphviz:
        gv = GraphVizGen(struct_dict, os.path.basename(opts.input_file).strip(".h"), os.path.dirname(enum_sh_filename))
        gv.set_include_headers([os.path.basename(opts.input_file),os.path.basename(enum_sh_filename),"stdint.h","stdio.h","stdlib.h", "inttypes.h"])
        gv.generate()
    print("DONE!")
    #print(typedef_rev_dict)
    #print(types_dict)
    #recreate_structs()

if __name__ == "__main__":
    sys.exit(main())
