diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-01-06 01:41:32 +0100 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-01-10 10:14:16 +0100 |
commit | c633188e24e35aeb540b89ab142efabef0801f13 (patch) | |
tree | 36564458f3901bb826545afea56a7b3c9c0c94d8 /pyGHDL/libghdl/errorout_memory.py | |
parent | 4a55232c3461a370c08b6c8a05a42011655c22a0 (diff) | |
download | ghdl-c633188e24e35aeb540b89ab142efabef0801f13.tar.gz ghdl-c633188e24e35aeb540b89ab142efabef0801f13.tar.bz2 ghdl-c633188e24e35aeb540b89ab142efabef0801f13.zip |
Adding types and docstrings to libghdl.
Diffstat (limited to 'pyGHDL/libghdl/errorout_memory.py')
-rw-r--r-- | pyGHDL/libghdl/errorout_memory.py | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/pyGHDL/libghdl/errorout_memory.py b/pyGHDL/libghdl/errorout_memory.py index c7295c113..f9977ec27 100644 --- a/pyGHDL/libghdl/errorout_memory.py +++ b/pyGHDL/libghdl/errorout_memory.py @@ -7,12 +7,13 @@ # |_| |___/ |___/ # ============================================================================= # Authors: Tristan Gingold +# Patrick Lehmann # # Package package: Python binding and low-level API for shared library 'libghdl'. # # License: # ============================================================================ -# Copyright (C) 2019-2020 Tristan Gingold +# Copyright (C) 2019-2021 Tristan Gingold # # GHDL 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 @@ -37,6 +38,7 @@ from ctypes import c_int8, c_int32, c_char_p, Structure from pydecor import export from pyGHDL.libghdl import libghdl +from pyGHDL.libghdl._types import ErrorIndex @export @@ -57,16 +59,35 @@ Msg_Main = 1 Msg_Related = 2 Msg_Last = 3 -Install_Handler = libghdl.errorout__memory__install_handler -Get_Nbr_Messages = libghdl.errorout__memory__get_nbr_messages +@export +def Install_Handler() -> None: + libghdl.errorout__memory__install_handler() + + +@export +def Get_Nbr_Messages() -> ErrorIndex: + return 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 = Error_Message +@export +def Get_Error_Record(Idx: ErrorIndex): # FIXME: returns Error_Message + func = libghdl.errorout__memory__get_error_record + func.argstypes = [c_int32] + func.restype = Error_Message + return func(Idx) -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 +@export +def Get_Error_Message(Idx: ErrorIndex) -> str: # FIXME: check '*_addr' vs string return value + func = libghdl.errorout__memory__get_error_message_addr + func.argstype = [c_int32] + func.restype = c_char_p + + # FIXME: don't we need to encode to utf-8? + return func(Idx) + + +@export +def Clear_Errors() -> None: + libghdl.errorout__memory__clear_errors() |