aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/libghdl/errorout_memory.py
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-17 13:49:20 +0200
committerUnai Martinez-Corral <38422348+umarcor@users.noreply.github.com>2021-06-17 22:53:27 +0100
commitf65fff4d5e3a33e83c633eb20fd367e349f3dc92 (patch)
tree66e3fb6afc69738b28bcaaf908a09c13143615e7 /pyGHDL/libghdl/errorout_memory.py
parent56f8ca47465a7cc052e80c0ed4bab6fc55eeacba (diff)
downloadghdl-f65fff4d5e3a33e83c633eb20fd367e349f3dc92.tar.gz
ghdl-f65fff4d5e3a33e83c633eb20fd367e349f3dc92.tar.bz2
ghdl-f65fff4d5e3a33e83c633eb20fd367e349f3dc92.zip
Using a decorator to bind libghdl to Python.
Diffstat (limited to 'pyGHDL/libghdl/errorout_memory.py')
-rw-r--r--pyGHDL/libghdl/errorout_memory.py33
1 files changed, 15 insertions, 18 deletions
diff --git a/pyGHDL/libghdl/errorout_memory.py b/pyGHDL/libghdl/errorout_memory.py
index d4cbaeed9..5187d5e3c 100644
--- a/pyGHDL/libghdl/errorout_memory.py
+++ b/pyGHDL/libghdl/errorout_memory.py
@@ -6,9 +6,9 @@
# | .__/ \__, |\____|_| |_|____/|_____(_)_|_|_.__/ \__, |_| |_|\__,_|_|
# |_| |___/ |___/
# =============================================================================
-# Authors:
-# Tristan Gingold
-# Patrick Lehmann
+# Authors:
+# Tristan Gingold
+# Patrick Lehmann
#
# Package package: Python binding and low-level API for shared library 'libghdl'.
#
@@ -36,8 +36,8 @@ 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
+from pyGHDL.libghdl._decorator import BindToLibGHDL
@export
@@ -81,22 +81,23 @@ Msg_Last = 3
@export
+@BindToLibGHDL("errorout__memory__install_handler")
def Install_Handler() -> None:
"""Install the handlers for reporting errors."""
- libghdl.errorout__memory__install_handler()
@export
+@BindToLibGHDL("errorout__memory__get_nbr_messages")
def Get_Nbr_Messages() -> ErrorIndex:
"""
Get number of error messages available.
:return: Number of messages available.
"""
- return libghdl.errorout__memory__get_nbr_messages()
@export
+@BindToLibGHDL("errorout__memory__get_error_record")
def Get_Error_Record(Idx: ErrorIndex) -> Error_Message:
"""
Get error messages by index :obj:`Idy` as structure :class:`Error_Message`.
@@ -104,29 +105,25 @@ def Get_Error_Record(Idx: ErrorIndex) -> Error_Message:
:param Idx: Index from 1 to ``Nbr_Messages`` See :func:`Get_Nbr_Messages`.
:return: Type: ``Error_Message``
"""
- func = libghdl.errorout__memory__get_error_record
- func.argstypes = [c_int32]
- func.restype = Error_Message
- return func(Idx)
+#@export
+@BindToLibGHDL("errorout__memory__get_error_message_addr")
+def _Get_Error_Message(Idx: ErrorIndex) -> c_char_p:
+ pass
@export
def Get_Error_Message(Idx: ErrorIndex) -> str:
"""
- Get error messages by index :obj:`Idy` as string.
+ Get error messages by index :obj:`Idx` as string.
:param Idx: Index from 1 to ``Nbr_Messages`` See :func:`Get_Nbr_Messages`.
- :return: Type: ``Error_Message``
+ :return: Error message.
"""
- func = libghdl.errorout__memory__get_error_message_addr
- func.argstype = [c_int32]
- func.restype = c_char_p
-
- return func(Idx).decode("utf-8")
+ return _Get_Error_Message(Idx).decode("utf-8")
@export
+@BindToLibGHDL("errorout__memory__clear_errors")
def Clear_Errors() -> None:
"""Remove all error messages."""
- libghdl.errorout__memory__clear_errors()