Example #1
0
 def reload(self, source):
     """Reload the source of a document."""
     src_bytes = source.encode(Document.encoding, "replace")
     l = len(src_bytes)
     if l >= files_map.Get_Buffer_Length(self._fe):
         self.__extend_source_buffer(l)
     files_map_editor.Fill_Text(self._fe, ctypes.c_char_p(src_bytes), l)
Example #2
0
    def __loadFromString(self, sourceCode: str):
        sourcesBytes = sourceCode.encode("utf-8")
        sourceLength = len(sourcesBytes)
        bufferLength = sourceLength + 128
        self.__ghdlFileID = name_table.Get_Identifier(str(self._filename))
        dirId = name_table.Null_Identifier
        self.__ghdlSourceFileEntry = files_map.Reserve_Source_File(
            dirId, self.__ghdlFileID, bufferLength)
        files_map_editor.Fill_Text(self.__ghdlSourceFileEntry,
                                   ctypes.c_char_p(sourcesBytes), sourceLength)

        CheckForErrors()
Example #3
0
 def load(source, dirname, filename):
     # Write text to file buffer.
     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"))
     if os.path.isabs(filename):
         dirid = name_table.Null_Identifier
     else:
         dirid = name_table.Get_Identifier(dirname.encode("utf-8"))
     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
Example #4
0
 def reload(self, source):
     """Reload the source of a document.  """
     src_bytes = source.encode(Document.encoding, "replace")
     files_map_editor.Fill_Text(self._fe, ctypes.c_char_p(src_bytes), len(src_bytes))