From 5ec4adc52ffacb8407d17dc728e45f7ac8f66261 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 14 May 2019 18:26:25 +0200 Subject: python/libghdl: refactoring --- src/vhdl/python/libghdl/thin.py | 303 ---------------------------------------- 1 file changed, 303 deletions(-) delete mode 100644 src/vhdl/python/libghdl/thin.py (limited to 'src/vhdl/python/libghdl/thin.py') diff --git a/src/vhdl/python/libghdl/thin.py b/src/vhdl/python/libghdl/thin.py deleted file mode 100644 index 5ff197175..000000000 --- a/src/vhdl/python/libghdl/thin.py +++ /dev/null @@ -1,303 +0,0 @@ -from libghdl import libghdl -from ctypes import (c_char_p, c_int32, c_int, c_int8, c_bool, sizeof, c_void_p, - POINTER, Structure) -import libghdl.iirs as iirs -import libghdl.nodes_meta as nodes_meta -from libghdl.nodes_meta import (Attr, types) -# from libghdl_defs import (fields, Iir_Kind, types, Attr) - -assert sizeof(c_bool) == 1 - -# libghdl - -_set_option = libghdl.libghdl__set_option -_analyze_file = libghdl.libghdl__analyze_file - - -def set_option(opt): - return _set_option(c_char_p(opt), len(opt)) - - -def analyze_init(): - return libghdl.libghdl__analyze_init() - - -def analyze_file(filename): - return _analyze_file(c_char_p(filename), len(filename)) - -EOT = b'\x04' - -No_Source_File_Entry = 0 - -No_Location = 0 - -Null_Iir = 0 -Null_Iir_List = 0 -Iir_List_All = 1 - -Null_Iir_Flist = 0 -Iir_Flist_Others = 1 -Iir_Flist_All = 2 - -# Lists - -class Lists: - List_Type = c_int32 - - class Iterator(Structure): - _fields_ = [("chunk", c_int32), - ("chunk_idx", c_int32), - ("remain", c_int32)] - - Iterate = libghdl.vhdl__lists__iterate - Iterate.argstype = [List_Type] - Iterate.restype = Iterator - - Is_Valid = libghdl.vhdl__lists__is_valid - Is_Valid.argstype = [POINTER(Iterator)] - Is_Valid.restype = c_bool - - Next = libghdl.vhdl__lists__next - Next.argstype = [POINTER(Iterator)] - Next.restype = None - - Get_Element = libghdl.vhdl__lists__get_element - Get_Element.argstype = [POINTER(Iterator)] - Get_Element.restype = c_int32 - - Get_Nbr_Elements = libghdl.vhdl__lists__get_nbr_elements - Get_Nbr_Elements.argtype = [List_Type] - Get_Nbr_Elements.restype = c_int32 - - Create_Iir_List = libghdl.vhdl__lists__create_list - - Destroy_Iir_List = libghdl.vhdl__lists__destroy_list - - -class Flists: - Flist_Type = c_int32 - - Ffirst = 0 - Flast = libghdl.vhdl__flists__flast - - Length = libghdl.vhdl__flists__length - - Get_Nth_Element = libghdl.vhdl__flists__get_nth_element - - -# Files -class Files_Map: - Location_To_File = libghdl.files_map__location_to_file - - Location_File_To_Pos = libghdl.files_map__location_file_to_pos - - Location_File_To_Line = libghdl.files_map__location_file_to_line - - Location_File_Line_To_Offset = \ - libghdl.files_map__location_file_line_to_offset - - Location_File_Line_To_Col = libghdl.files_map__location_file_line_to_col - - File_To_Location = libghdl.files_map__file_to_location - - File_Pos_To_Location = libghdl.files_map__file_pos_to_location - - File_Line_To_Position = libghdl.files_map__file_line_to_position - - Get_File_Name = libghdl.files_map__get_file_name - - Get_Directory_Name = libghdl.files_map__get_directory_name - - Get_File_Buffer = libghdl.files_map__get_file_buffer - Get_File_Buffer.restype = c_void_p - - Get_File_Length = libghdl.files_map__get_file_length - Set_File_Length = libghdl.files_map__set_file_length - - Read_Source_File = libghdl.files_map__read_source_file - - Reserve_Source_File = libghdl.files_map__reserve_source_file - - Get_Last_Source_File_Entry = libghdl.files_map__get_last_source_file_entry - - -class Files_Map_Editor: - Set_Gap = libghdl.files_map__editor__set_gap - Replace_Text = libghdl.files_map__editor__replace_text_ptr - - Check_Buffer_Content = libghdl.files_map__editor__check_buffer_content - -# Names - -Get_Name_Length = libghdl.name_table__get_name_length - -Get_Name_Ptr = libghdl.name_table__get_name_ptr -Get_Name_Ptr.restype = c_char_p - -_Get_Identifier_With_Len = libghdl.name_table__get_identifier_with_len - -def Get_Identifier(s): - return _Get_Identifier_With_Len(c_char_p(s), len(s)) - -Null_Identifier = 0 - -# Ieee - -class Ieee: - Std_Logic_1164_Pkg = c_int.in_dll( - libghdl, "vhdl__ieee__std_logic_1164__std_logic_1164_pkg") - - # Get value - Std_Logic_Type = c_int.in_dll( - libghdl, "vhdl__ieee__std_logic_1164__std_logic_type") - - # Get value - Std_Logic_Vector_Type = c_int.in_dll( - libghdl, "vhdl__ieee__std_logic_1164__std_logic_vector_type") - - # Get value - Rising_Edge = c_int.in_dll( - libghdl, "vhdl__ieee__std_logic_1164__rising_edge") - - # Get value - Falling_Edge = c_int.in_dll( - libghdl, "vhdl__ieee__std_logic_1164__falling_edge") - - -# Flags -class Flags: - Flag_Elocations = c_bool.in_dll(libghdl, "flags__flag_elocations") - - Verbose = c_bool.in_dll(libghdl, "flags__verbose") - - Flag_Elaborate_With_Outdated = c_bool.in_dll( - libghdl, "flags__flag_elaborate_with_outdated") - - -# Scanner -class Scanner: - Set_File = libghdl.vhdl__scanner__set_file - - Close_File = libghdl.vhdl__scanner__close_file - - Scan = libghdl.vhdl__scanner__scan - - # This is a c_int, so you want to use its .value - Current_Token = c_int.in_dll(libghdl, "vhdl__scanner__current_token") - - Flag_Comment = c_bool.in_dll(libghdl, "vhdl__scanner__flag_comment") - - Get_Current_Line = libghdl.vhdl__scanner__get_current_line - - Get_Token_Offset = libghdl.vhdl__scanner__get_token_offset - - Get_Token_Position = libghdl.vhdl__scanner__get_token_position - - Get_Position = libghdl.vhdl__scanner__get_position - - Current_Identifier = libghdl.vhdl__scanner__current_identifier - - -class Parse: - Parse_Design_File = libghdl.vhdl__parse__parse_design_file - - Flag_Parse_Parenthesis = c_bool.in_dll( - libghdl, "vhdl__parse__flag_parse_parenthesis") - - -class Canon: - Flag_Concurrent_Stmts = c_bool.in_dll( - libghdl, "vhdl__canon__canon_flag_concurrent_stmts") - - Flag_Configurations = c_bool.in_dll( - libghdl, "vhdl__canon__canon_flag_configurations") - - Flag_Associations = c_bool.in_dll( - libghdl, "vhdl__canon__canon_flag_associations") - - Extract_Sequential_Statement_Chain_Sensitivity = \ - libghdl.vhdl__canon__canon_extract_sequential_statement_chain_sensitivity - - -class Sem_Lib: - Load_File = libghdl.vhdl__sem_lib__load_file - - Finish_Compilation = libghdl.vhdl__sem_lib__finish_compilation - - -class Std_Package: - # Use .value - Std_Location = c_int32.in_dll(libghdl, "vhdl__std_package__std_location") - - # Use .value - Standard_Package = c_int32.in_dll( - libghdl, "vhdl__std_package__standard_package") - - # Use .value - Character_Type_Definition = c_int32.in_dll( - libghdl, "vhdl__std_package__character_type_definition") - -class Libraries: - Get_Libraries_Chain = libghdl.libraries__get_libraries_chain - - Add_Design_Unit_Into_Library = \ - libghdl.libraries__add_design_unit_into_library - - # Use .value - Library_Location = c_int32.in_dll(libghdl, "libraries__library_location") - - # Use .value - Work_Library = c_int32.in_dll(libghdl, "libraries__work_library") - - Purge_Design_File = libghdl.libraries__purge_design_file - - Find_Entity_For_Component = libghdl.libraries__find_entity_for_component - - -# Disp_Tree - -Disp_Iir = libghdl.vhdl__disp_tree__disp_iir - -# Iirs_Utils - -class Iirs_Utils: - Strip_Denoting_Name = libghdl.vhdl__utils__strip_denoting_name - - Get_Entity = libghdl.vhdl__utils__get_entity - - Is_Second_Subprogram_Specification = \ - libghdl.vhdl__utils__is_second_subprogram_specification - - Get_Entity_From_Entity_Aspect = \ - libghdl.vhdl__utils__get_entity_from_entity_aspect - - Get_Interface_Of_Formal = \ - libghdl.vhdl__utils__get_interface_of_formal - -# Errorout - -class Errorout: - class Error_Record(Structure): - _fields_ = [("origin", c_int8), - ("id", c_int8), - ("cont", c_int8), - ("file", c_int32), - ("line", c_int32), - ("offset", c_int32), - ("length", c_int32)] - - -class Errorout_Memory: - Install_Handler = libghdl.errorout__memory__install_handler - - Get_Nbr_Messages = libghdl.errorout__memory__get_nbr_messages - - Get_Error_Record = libghdl.errorout__memory__get_error_record - Get_Error_Record.argstypes = [c_int32] - Get_Error_Record.restype = Errorout.Error_Record - - Get_Error_Message = libghdl.errorout__memory__get_error_message_addr - Get_Error_Message.argstype = [c_int32] - Get_Error_Message.restype = c_char_p - - Clear_Errors = libghdl.errorout__memory__clear_errors -- cgit v1.2.3