aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/libghdl
diff options
context:
space:
mode:
Diffstat (limited to 'pyGHDL/libghdl')
-rw-r--r--pyGHDL/libghdl/__init__.py10
-rw-r--r--pyGHDL/libghdl/_decorator.py26
-rw-r--r--pyGHDL/libghdl/files_map_editor.py4
3 files changed, 30 insertions, 10 deletions
diff --git a/pyGHDL/libghdl/__init__.py b/pyGHDL/libghdl/__init__.py
index 525710590..d23ffc0e7 100644
--- a/pyGHDL/libghdl/__init__.py
+++ b/pyGHDL/libghdl/__init__.py
@@ -87,7 +87,7 @@ def _check_libghdl_bindir(bindir: Path, basename: Path) -> Path:
def _get_libghdl_path():
- """
+ """\
Locate the directory where the shared library is installed.
Search order:
@@ -182,7 +182,7 @@ def initialize() -> None:
@export
# @BindToLibGHDL("libghdl__set_option")
def set_option(Opt: str) -> bool:
- """
+ """\
Set option :obj:`opt`.
:param Opt: Option to set.
@@ -195,7 +195,7 @@ def set_option(Opt: str) -> bool:
@export
# @BindToLibGHDL("libghdl__analyze_init")
def analyze_init() -> None:
- """
+ """\
Initialize the analyzer.
.. deprecated:: 1.0.0
@@ -207,7 +207,7 @@ def analyze_init() -> None:
@export
# @BindToLibGHDL("libghdl__analyze_init_status")
def analyze_init_status() -> int:
- """
+ """\
Initialize the analyzer.
:return: Returns 0 in case of success.
@@ -218,7 +218,7 @@ def analyze_init_status() -> int:
@export
# @BindToLibGHDL("libghdl__analyze_file")
def analyze_file(fname: str) -> Iir:
- """
+ """\
Analyze a given filename :obj:`fname`.
:param fname: File name
diff --git a/pyGHDL/libghdl/_decorator.py b/pyGHDL/libghdl/_decorator.py
index a680cc9d1..9c5aefa19 100644
--- a/pyGHDL/libghdl/_decorator.py
+++ b/pyGHDL/libghdl/_decorator.py
@@ -48,7 +48,7 @@ from typing import Callable, List, Dict, Any, TypeVar
from pydecor import export
-from pyGHDL.libghdl import libghdl
+from pyGHDL.libghdl import libghdl, LibGHDLException
@export
@@ -181,14 +181,34 @@ def BindToLibGHDL(subprogramName):
@wraps(func)
def inner(*args):
- return returnType(functionPointer(*args))
+ try:
+ returnValue = functionPointer(*args)
+ except OSError as ex:
+ errors = [str(ex)]
+ raise LibGHDLException(
+ "Caught exception when calling '{func}' in libghdl.".format(
+ func=subprogramName
+ ),
+ errors,
+ ) from ex
+
+ return returnType(returnValue)
return inner
else:
@wraps(func)
def inner(*args):
- return functionPointer(*args)
+ try:
+ return functionPointer(*args)
+ except OSError as ex:
+ errors = [str(ex)]
+ raise LibGHDLException(
+ "Caught exception when calling '{func}' in libghdl.".format(
+ func=subprogramName
+ ),
+ errors,
+ ) from ex
return inner
diff --git a/pyGHDL/libghdl/files_map_editor.py b/pyGHDL/libghdl/files_map_editor.py
index eceb3efe2..2009af882 100644
--- a/pyGHDL/libghdl/files_map_editor.py
+++ b/pyGHDL/libghdl/files_map_editor.py
@@ -32,7 +32,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
-from ctypes import c_int32, c_char_p, c_bool
+from ctypes import c_int32, c_char_p, c_bool, c_uint32
from pydecor import export
@@ -113,7 +113,7 @@ def Fill_Text(File: SourceFileEntry, Text_Pointer, Text_Length: int) -> None:
@export
# @BindToLibGHDL("files_map__editor__check_buffer_content")
def Check_Buffer_Content(
- File: SourceFileEntry, String_Pointer, String_Length: int
+ File: SourceFileEntry, String_Pointer: c_char_p, String_Length: c_uint32
) -> None:
"""
Check that content of :obj:`File` is STR[1 .. STR_LEN].