diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-01-06 11:27:59 +0100 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-01-10 10:14:16 +0100 |
commit | 0de91f9313a4c76445ada1617fff69d97fe12217 (patch) | |
tree | 1e5074682a4996db4d54ac9b6c92e8745f05d753 /pyGHDL/lsp | |
parent | 015adfc69e63e46c7823524032636faa99106c1f (diff) | |
download | ghdl-0de91f9313a4c76445ada1617fff69d97fe12217.tar.gz ghdl-0de91f9313a4c76445ada1617fff69d97fe12217.tar.bz2 ghdl-0de91f9313a4c76445ada1617fff69d97fe12217.zip |
Make API more pythonic be replacing C-like byte arrays with str. Abstracted utf-8 encoding/decoding.
Diffstat (limited to 'pyGHDL/lsp')
-rw-r--r-- | pyGHDL/lsp/document.py | 4 | ||||
-rw-r--r-- | pyGHDL/lsp/references.py | 2 | ||||
-rw-r--r-- | pyGHDL/lsp/workspace.py | 8 |
3 files changed, 7 insertions, 7 deletions
diff --git a/pyGHDL/lsp/document.py b/pyGHDL/lsp/document.py index 1b988220c..1ef510d52 100644 --- a/pyGHDL/lsp/document.py +++ b/pyGHDL/lsp/document.py @@ -40,11 +40,11 @@ class Document(object): src_bytes = source.encode(Document.encoding, "replace") src_len = len(src_bytes) buf_len = src_len + Document.initial_gap_size - fileid = name_table.Get_Identifier(filename.encode("utf-8")) + fileid = name_table.Get_Identifier(filename) if os.path.isabs(filename): dirid = name_table.Null_Identifier else: - dirid = name_table.Get_Identifier(dirname.encode("utf-8")) + dirid = name_table.Get_Identifier(dirname) sfe = files_map.Reserve_Source_File(dirid, fileid, buf_len) files_map_editor.Fill_Text(sfe, ctypes.c_char_p(src_bytes), src_len) return sfe diff --git a/pyGHDL/lsp/references.py b/pyGHDL/lsp/references.py index 2725f40f2..c7d0f730d 100644 --- a/pyGHDL/lsp/references.py +++ b/pyGHDL/lsp/references.py @@ -94,7 +94,7 @@ def goto_definition(n, loc): log.debug( "for loc %u id=%s", loc, - name_table.Get_Name_Ptr(nodes.Get_Identifier(ref)).decode("utf-8"), + name_table.Get_Name_Ptr(nodes.Get_Identifier(ref)), ) ent = nodes.Get_Named_Entity(ref) return None if ent == nodes.Null_Iir else ent diff --git a/pyGHDL/lsp/workspace.py b/pyGHDL/lsp/workspace.py index 8c60edab9..980289806 100644 --- a/pyGHDL/lsp/workspace.py +++ b/pyGHDL/lsp/workspace.py @@ -194,7 +194,7 @@ class Workspace(object): return log.info("Using options: %s", ghdl_opts) for opt in ghdl_opts: - if not libghdl.set_option(opt.encode("utf-8")): + if not libghdl.set_option(opt): self._server.show_message( lsp.MessageType.Error, "error with option: {}".format(opt) ) @@ -234,7 +234,7 @@ class Workspace(object): diag = {} for i in range(nbr_msgs): hdr = errorout_memory.Get_Error_Record(i + 1) - msg = errorout_memory.Get_Error_Message(i + 1).decode("utf-8") + msg = errorout_memory.Get_Error_Message(i + 1) if hdr.file == 0: # Possible for error limit reached. continue @@ -452,12 +452,12 @@ class Workspace(object): return res # Find library - lib_id = name_table.Get_Identifier(library.encode("utf-8")) + lib_id = name_table.Get_Identifier(library) lib = libraries.Get_Library_No_Create(lib_id) if lib == name_table.Null_Identifier: return None # Find entity - ent_id = name_table.Get_Identifier(name.encode("utf-8")) + ent_id = name_table.Get_Identifier(name) unit = libraries.Find_Primary_Unit(lib, ent_id) if unit == nodes.Null_Iir: return None |