1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
|
# =============================================================================
# ____ _ _ ____ _ _ _ _ _ _ _
# _ __ _ _ / ___| | | | _ \| | | (_) |__ __ _| |__ __| | |
# | '_ \| | | | | _| |_| | | | | | | | | '_ \ / _` | '_ \ / _` | |
# | |_) | |_| | |_| | _ | |_| | |___ _| | | |_) | (_| | | | | (_| | |
# | .__/ \__, |\____|_| |_|____/|_____(_)_|_|_.__/ \__, |_| |_|\__,_|_|
# |_| |___/ |___/
# =============================================================================
# Authors:
# Tristan Gingold
# Patrick Lehmann
#
# Package package: Python binding and low-level API for shared library 'libghdl'.
#
# License:
# ============================================================================
# Copyright (C) 2019-2021 Tristan Gingold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <gnu.org/licenses>.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
from pyTooling.Decorators import export
from pyGHDL.libghdl._decorator import BindToLibGHDL
from pyGHDL.libghdl._types import NameId, SourceFileEntry, LocationType
__all__ = [
"EOT",
"No_Source_File_Entry",
"No_Location",
]
EOT = b"\x04"
No_Source_File_Entry = 0
No_Location = 0
@export
@BindToLibGHDL("files_map__location_to_file")
def Location_To_File(Location: LocationType) -> SourceFileEntry:
"""
Convert :obj:`Location` to a source file.
:param Location: Location
:return: Source file. Return ``No_Source_File_Entry`` if location is incorrect.
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__location_file_to_pos")
def Location_File_To_Pos(Location: LocationType, File: SourceFileEntry) -> int:
"""
Convert :obj:`Location` and :obj:`File` to a position (offset) into the source file.
:param Location: Location
:param File: Source file
:return: Offset
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__location_file_to_line")
def Location_File_To_Line(Location: LocationType, File: SourceFileEntry) -> int:
"""
Convert :obj:`Location` and :obj:`File` to a line number.
:param Location: Location
:param File: Source file
:return: Line number
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__location_file_line_to_offset")
def Location_File_Line_To_Offset(Location: LocationType, File: SourceFileEntry, Line: int) -> int:
"""
Get the offset in :obj:`Line` of :obj:`Location`.
:param Location: Location
:param File: Source file
:param Line: Line number
:return: Offset
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__location_file_line_to_col")
def Location_File_Line_To_Col(Location: LocationType, File: SourceFileEntry, Line: int) -> int:
"""
Get logical column (with HT expanded) from :obj:`Location`, :obj:`File` and
:obj:`Line`.
:param Location: Location
:param File: Source file
:param Line: Line number
:return: logical column (horizontal tabs are expanded)
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__file_to_location")
def File_To_Location(File: SourceFileEntry) -> LocationType:
"""Convert a :obj:`File` into a location.
:param File: Source file
:return: Location.
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__file_pos_to_location")
def File_Pos_To_Location(File: SourceFileEntry, Pos: int) -> LocationType:
"""
Convert a :obj:`File` and an offset :obj:`Pos` in the file into a location.
:param File: Source file
:param Pos: Offset in the file
:return: Location.
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__file_line_to_position")
def File_Line_To_Position(File: SourceFileEntry, Line: int) -> int:
"""
Convert a :obj:`File` and :obj:`Line` into a position.
:param File: Source file
:param Line: Line number
:return: Return ``Source_Ptr_Bad`` in case of error (:obj:`Line` out of bounds).
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__get_file_name")
def Get_File_Name(File: SourceFileEntry) -> NameId:
"""
Return the name of the file.
:param File: Source file to get the filename from.
:return: NameId for the filename.
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__get_directory_name")
def Get_Directory_Name(File: SourceFileEntry) -> NameId:
"""
Return the directory of the file.
:param File: Source file to get the directory name from.
:return: NameId for the directory.
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__get_file_buffer")
def Get_File_Buffer(File: SourceFileEntry) -> bytes:
"""
Return a buffer (access to the contents of the file) for a file entry.
:param File: Source file to get the buffer from.
:return: Type: ``File_Buffer_Ptr``
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__get_file_length")
def Get_File_Length(File: SourceFileEntry) -> int:
"""
Get the position of the first EOT character.
:param File: Source file
:return: Type: ``Source_Ptr``
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__set_file_length")
def Set_File_Length(File: SourceFileEntry, Length: int) -> None:
"""
Set the length of the file (which is less than the size of the file buffer).
Set also append two EOT at the end of the file.
:param File: Source file
:param Length: Length for the file. Type: ``Source_Ptr``
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__get_buffer_length")
def Get_Buffer_Length(File: SourceFileEntry) -> int:
"""
Get the length of the buffer, including the gap and the two EOT.
:param File: Source file
:return: Type: ``Source_Ptr``
"""
@export
@BindToLibGHDL("files_map__get_buffer_length")
def Get_Buffer_Length(File: SourceFileEntry) -> int:
"""
Get the length of the buffer, including the gap and the two EOT.
:param File: Source file
:return: Type: ``Source_Ptr``
"""
@export
@BindToLibGHDL("files_map__find_source_file")
def Find_Source_File(Directory: NameId, Name: NameId) -> SourceFileEntry:
"""
Return an existing entry for a filename.
:param Directory: ``Null_Identifier`` for :obj:`DirectoryId` means current directory.
:param Name: File name
:return: Return ``No_Source_File_Entry``, if the file is not already open.
"""
return 0
@export
@BindToLibGHDL("files_map__read_source_file")
def Read_Source_File(Directory: NameId, Name: NameId) -> SourceFileEntry:
"""
Return an entry for a filename.
Load the filename if necessary.
:param Directory: ``Null_Identifier`` for :obj:`DirectoryId` means current directory.
:param Name: File name
:return: Return ``No_Source_File_Entry``, if the file does not exist.
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__reserve_source_file")
def Reserve_Source_File(Directory: NameId, Name: NameId, Length: int) -> SourceFileEntry:
"""
Reserve an entry, but do not read any file.
The length should includes the two terminal EOT.
:param Directory: Directory name
:param Name: File name
:param Length: Length to reserve. Type: ``Source_Ptr``
:return: SourceFile
"""
return 0 # pragma: no cover
@export
@BindToLibGHDL("files_map__discard_source_file")
def Discard_Source_File(File: SourceFileEntry) -> None:
"""
Mark :obj:`File` as unavailable: clear the name and directory.
.. hint:: This is needed before creating a new source file with the same name.
:param File: Source file to discard.
"""
@export
@BindToLibGHDL("files_map__free_source_file")
def Free_Source_File(File: SourceFileEntry) -> None:
"""
Free resources used by :obj:`File`, but keep the entry.
.. note:: It could be recycled for files that could fit - not implemented.
:param File: Source file to free.
"""
@export
@BindToLibGHDL("files_map__get_last_source_file_entry")
def Get_Last_Source_File_Entry() -> SourceFileEntry:
"""
Returns the entry of the last known file.
.. hint:: This allows creating a table of ``SourceFileEntry``.
:return: Last SourceFileEntry. Type: ``SourceFileEntry``
"""
return 0 # pragma: no cover
|