printrun-src/printrun/gcoder_line.pyx

changeset 46
cce0af6351f0
parent 15
0bbb006204fc
--- a/printrun-src/printrun/gcoder_line.pyx	Tue Jan 19 20:45:09 2021 +0100
+++ b/printrun-src/printrun/gcoder_line.pyx	Wed Jan 20 10:15:13 2021 +0100
@@ -1,11 +1,13 @@
-# This file is copied from GCoder.
+#cython: language_level=3
 #
-# GCoder is free software: you can redistribute it and/or modify
+# This file is part of the Printrun suite.
+#
+# Printrun is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
-# GCoder is distributed in the hope that it will be useful,
+# Printrun is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
@@ -18,6 +20,7 @@
 from libc.string cimport strlen, strncpy
 
 cdef char* copy_string(object value):
+    value = value.encode('utf-8')
     cdef char* orig = value
     str_len = len(orig)
     cdef char* array = <char *>malloc(str_len + 1)
@@ -192,7 +195,7 @@
             self._status = set_has_var(self._status, pos_gcview_end_vertex)
     property raw:
         def __get__(self):
-            if has_var(self._status, pos_raw): return self._raw
+            if has_var(self._status, pos_raw): return self._raw.decode('utf-8')
             else: return None
         def __set__(self, value):
             # WARNING: memory leak could happen here, as we don't do the following :
@@ -201,7 +204,7 @@
             self._status = set_has_var(self._status, pos_raw)
     property command:
         def __get__(self):
-            if has_var(self._status, pos_command): return self._command
+            if has_var(self._status, pos_command): return self._command.decode('utf-8')
             else: return None
         def __set__(self, value):
             # WARNING: memory leak could happen here, as we don't do the following :
@@ -231,7 +234,7 @@
 
     property raw:
         def __get__(self):
-            if has_var(self._status, pos_raw): return self._raw
+            if has_var(self._status, pos_raw): return self._raw.decode('utf-8')
             else: return None
         def __set__(self, value):
             # WARNING: memory leak could happen here, as we don't do the following :
@@ -240,7 +243,7 @@
             self._status = set_has_var(self._status, pos_raw)
     property command:
         def __get__(self):
-            if has_var(self._status, pos_command): return self._command
+            if has_var(self._status, pos_command): return self._command.decode('utf-8')
             else: return None
         def __set__(self, value):
             # WARNING: memory leak could happen here, as we don't do the following :

mercurial