aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/libghdl/files_map_editor.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyGHDL/libghdl/files_map_editor.py')
-rw-r--r--pyGHDL/libghdl/files_map_editor.py51
1 files changed, 26 insertions, 25 deletions
diff --git a/pyGHDL/libghdl/files_map_editor.py b/pyGHDL/libghdl/files_map_editor.py
index 4cf991ecd..1b1f86a01 100644
--- a/pyGHDL/libghdl/files_map_editor.py
+++ b/pyGHDL/libghdl/files_map_editor.py
@@ -6,9 +6,9 @@
# | .__/ \__, |\____|_| |_|____/|_____(_)_|_|_.__/ \__, |_| |_|\__,_|_|
# |_| |___/ |___/
# =============================================================================
-# Authors:
-# Tristan Gingold
-# Patrick Lehmann
+# Authors:
+# Tristan Gingold
+# Patrick Lehmann
#
# Package module: Python binding and low-level API for shared library 'libghdl'.
#
@@ -37,23 +37,15 @@ from ctypes import c_int32, c_char_p, c_bool
from pydecor import export
from pyGHDL.libghdl import libghdl
+from pyGHDL.libghdl._decorator import BindToLibGHDL
from pyGHDL.libghdl._types import SourceFileEntry
-@export
-def Replace_Text(
- File: SourceFileEntry,
- Start_Line: int,
- Start_Offset: int,
- End_Line: int,
- End_Offset: int,
- Text_Pointer,
- Text_Length: int,
-) -> bool:
+#@export
+@BindToLibGHDL("files_map__editor__replace_text_ptr")
+def _Replace_Text(File: SourceFileEntry, Start_Line: int, Start_Offset: int, End_Line: int, End_Offset: int, Text_Pointer: c_char_p, Text_Length: int) -> bool:
"""Replace [START; END) by TEXT.
- .. todo:: Replace ``Text_Pointer`` and ``Text_Length`` with Python string
-
:param File: File where to replace a text section.
:param Start_Line:
:param Start_Offset:
@@ -63,16 +55,26 @@ def Replace_Text(
:param Text_Length: Type: ``Source_Ptr``
:return: Return True in case of success, False in case of failure (the gap is too small).
"""
- func = libghdl.files_map__editor__replace_text_ptr
- func.argstype = [c_int32, c_int32, c_int32, c_int32, c_char_p, c_int32]
- func.restype = c_bool
- return func(
- File, Start_Line, Start_Offset, End_Line, End_Offset, Text_Pointer, Text_Length
- )
+
+@export
+def Replace_Text(File: SourceFileEntry, Start_Line: int, Start_Offset: int, End_Line: int, End_Offset: int, Text: str) -> bool:
+ """ Replace [START; END) by TEXT.
+
+ :param File: File where to replace a text section.
+ :param Start_Line: undocumented
+ :param Start_Offset: undocumented
+ :param End_Line: undocumented
+ :param End_Offset: undocumented
+ :param Text: undocumented
+ :return: Return True in case of success, False in case of failure (the gap is too small).
+ """
+ buffer = Text.encode("utf-8")
+ return _Replace_Text(File, Start_Line, Start_Offset, End_Line, End_Offset, c_char_p(buffer), len(buffer))
@export
+#@BindToLibGHDL("files_map__editor__fill_text_ptr")
def Fill_Text(File: SourceFileEntry, Text_Pointer, Text_Length: int) -> None:
"""Replace the content of :obj:`File` with TEXT.
@@ -86,9 +88,8 @@ def Fill_Text(File: SourceFileEntry, Text_Pointer, Text_Length: int) -> None:
@export
-def Check_Buffer_Content(
- File: SourceFileEntry, String_Pointer, String_Length: int
-) -> None:
+#@BindToLibGHDL("files_map__editor__check_buffer_content")
+def Check_Buffer_Content(File: SourceFileEntry, String_Pointer, String_Length: int) -> None:
"""
Check that content of :obj:`File` is STR[1 .. STR_LEN].
@@ -102,6 +103,7 @@ def Check_Buffer_Content(
@export
+@BindToLibGHDL("files_map__editor__copy_source_file")
def Copy_Source_File(Dest: SourceFileEntry, Src: SourceFileEntry) -> None:
"""
Copy content of :obj:`Src` to :obj:`Dest`.
@@ -110,4 +112,3 @@ def Copy_Source_File(Dest: SourceFileEntry, Src: SourceFileEntry) -> None:
Clear lines table of :obj:`Dest`.
"""
- return libghdl.files_map__editor__copy_source_file(Dest, Src)