printrun-src/printrun/gcoder_line.pyx

Wed, 20 Jan 2021 10:15:13 +0100

author
mdd
date
Wed, 20 Jan 2021 10:15:13 +0100
changeset 46
cce0af6351f0
parent 15
0bbb006204fc
permissions
-rw-r--r--

updated and added new files for printrun

46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
1 #cython: language_level=3
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
2 #
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
3 # This file is part of the Printrun suite.
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
4 #
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
5 # Printrun is free software: you can redistribute it and/or modify
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
7 # the Free Software Foundation, either version 3 of the License, or
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
8 # (at your option) any later version.
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
9 #
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
10 # Printrun is distributed in the hope that it will be useful,
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
13 # GNU General Public License for more details.
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
14 #
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
16 # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
17
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
18 from libc.stdlib cimport malloc, free
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
19 from libc.stdint cimport uint8_t, uint32_t
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
20 from libc.string cimport strlen, strncpy
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
21
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
22 cdef char* copy_string(object value):
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
23 value = value.encode('utf-8')
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
24 cdef char* orig = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
25 str_len = len(orig)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
26 cdef char* array = <char *>malloc(str_len + 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
27 strncpy(array, orig, str_len)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
28 array[str_len] = 0;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
29 return array
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
30
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
31 cdef enum BitPos:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
32 pos_raw = 1 << 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
33 pos_command = 1 << 1
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
34 pos_is_move = 1 << 2
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
35 pos_x = 1 << 3
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
36 pos_y = 1 << 4
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
37 pos_z = 1 << 5
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
38 pos_e = 1 << 6
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
39 pos_f = 1 << 7
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
40 pos_i = 1 << 8
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
41 pos_j = 1 << 9
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
42 pos_relative = 1 << 10
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
43 pos_relative_e = 1 << 11
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
44 pos_extruding = 1 << 12
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
45 pos_current_x = 1 << 13
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
46 pos_current_y = 1 << 14
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
47 pos_current_z = 1 << 15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
48 pos_current_tool = 1 << 16
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
49 pos_gcview_end_vertex = 1 << 17
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
50 # WARNING: don't use bits 24 to 31 as we store current_tool there
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
51
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
52 cdef inline uint32_t has_var(uint32_t status, uint32_t pos):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
53 return status & pos
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
54
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
55 cdef inline uint32_t set_has_var(uint32_t status, uint32_t pos):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
56 return status | pos
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
57
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
58 cdef inline uint32_t unset_has_var(uint32_t status, uint32_t pos):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
59 return status & ~pos
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
60
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
61 cdef class GLine:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
62
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
63 cdef char* _raw
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
64 cdef char* _command
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
65 cdef float _x, _y, _z, _e, _f, _i, _j
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
66 cdef float _current_x, _current_y, _current_z
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
67 cdef uint32_t _gcview_end_vertex
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
68 cdef uint32_t _status
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
69
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
70 __slots__ = ()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
71
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
72 def __cinit__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
73 self._status = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
74 self._raw = NULL
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
75 self._command = NULL
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
76
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
77 def __init__(self, line):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
78 self.raw = line
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
79
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
80 def __dealloc__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
81 if self._raw != NULL: free(self._raw)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
82 if self._command != NULL: free(self._command)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
83
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
84 property x:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
85 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
86 if has_var(self._status, pos_x): return self._x
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
87 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
88 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
89 self._x = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
90 self._status = set_has_var(self._status, pos_x)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
91 property y:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
92 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
93 if has_var(self._status, pos_y): return self._y
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
94 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
95 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
96 self._y = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
97 self._status = set_has_var(self._status, pos_y)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
98 property z:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
99 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
100 if has_var(self._status, pos_z): return self._z
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
101 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
102 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
103 self._z = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
104 self._status = set_has_var(self._status, pos_z)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
105 property e:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
106 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
107 if has_var(self._status, pos_e): return self._e
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
108 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
109 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
110 self._e = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
111 self._status = set_has_var(self._status, pos_e)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
112 property f:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
113 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
114 if has_var(self._status, pos_f): return self._f
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
115 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
116 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
117 self._f = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
118 self._status = set_has_var(self._status, pos_f)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
119 property i:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
120 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
121 if has_var(self._status, pos_i): return self._i
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
122 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
123 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
124 self._i = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
125 self._status = set_has_var(self._status, pos_i)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
126 property j:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
127 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
128 if has_var(self._status, pos_j): return self._j
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
129 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
130 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
131 self._j = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
132 self._status = set_has_var(self._status, pos_j)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
133 property is_move:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
134 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
135 if has_var(self._status, pos_is_move): return True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
136 else: return False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
137 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
138 if value: self._status = set_has_var(self._status, pos_is_move)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
139 else: self._status = unset_has_var(self._status, pos_is_move)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
140 property relative:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
141 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
142 if has_var(self._status, pos_relative): return True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
143 else: return False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
144 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
145 if value: self._status = set_has_var(self._status, pos_relative)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
146 else: self._status = unset_has_var(self._status, pos_relative)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
147 property relative_e:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
148 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
149 if has_var(self._status, pos_relative_e): return True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
150 else: return False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
151 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
152 if value: self._status = set_has_var(self._status, pos_relative_e)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
153 else: self._status = unset_has_var(self._status, pos_relative_e)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
154 property extruding:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
155 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
156 if has_var(self._status, pos_extruding): return True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
157 else: return False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
158 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
159 if value: self._status = set_has_var(self._status, pos_extruding)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
160 else: self._status = unset_has_var(self._status, pos_extruding)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
161 property current_x:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
162 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
163 if has_var(self._status, pos_current_x): return self._current_x
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
164 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
165 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
166 self._current_x = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
167 self._status = set_has_var(self._status, pos_current_x)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
168 property current_y:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
169 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
170 if has_var(self._status, pos_current_y): return self._current_y
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
171 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
172 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
173 self._current_y = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
174 self._status = set_has_var(self._status, pos_current_y)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
175 property current_z:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
176 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
177 if has_var(self._status, pos_current_z): return self._current_z
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
178 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
179 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
180 self._current_z = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
181 self._status = set_has_var(self._status, pos_current_z)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
182 property current_tool:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
183 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
184 if has_var(self._status, pos_current_tool): return self._status >> 24
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
185 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
186 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
187 self._status = (self._status & ((1 << 24) - 1)) | (value << 24)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
188 self._status = set_has_var(self._status, pos_current_tool)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
189 property gcview_end_vertex:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
190 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
191 if has_var(self._status, pos_gcview_end_vertex): return self._gcview_end_vertex
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
192 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
193 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
194 self._gcview_end_vertex = value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
195 self._status = set_has_var(self._status, pos_gcview_end_vertex)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
196 property raw:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
197 def __get__(self):
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
198 if has_var(self._status, pos_raw): return self._raw.decode('utf-8')
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
199 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
200 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
201 # WARNING: memory leak could happen here, as we don't do the following :
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
202 # if self._raw != NULL: free(self._raw)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
203 self._raw = copy_string(value)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
204 self._status = set_has_var(self._status, pos_raw)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
205 property command:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
206 def __get__(self):
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
207 if has_var(self._status, pos_command): return self._command.decode('utf-8')
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
208 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
209 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
210 # WARNING: memory leak could happen here, as we don't do the following :
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
211 # if self._command != NULL: free(self._command)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
212 self._command = copy_string(value)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
213 self._status = set_has_var(self._status, pos_command)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
214
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
215 cdef class GLightLine:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
216
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
217 cdef char* _raw
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
218 cdef char* _command
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
219 cdef uint8_t _status
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
220
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
221 __slots__ = ()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
222
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
223 def __cinit__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
224 self._status = 0
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
225 self._raw = NULL
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
226 self._command = NULL
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
227
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
228 def __init__(self, line):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
229 self.raw = line
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
230
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
231 def __dealloc__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
232 if self._raw != NULL: free(self._raw)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
233 if self._command != NULL: free(self._command)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
234
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
235 property raw:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
236 def __get__(self):
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
237 if has_var(self._status, pos_raw): return self._raw.decode('utf-8')
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
238 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
239 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
240 # WARNING: memory leak could happen here, as we don't do the following :
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
241 # if self._raw != NULL: free(self._raw)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
242 self._raw = copy_string(value)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
243 self._status = set_has_var(self._status, pos_raw)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
244 property command:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
245 def __get__(self):
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
246 if has_var(self._status, pos_command): return self._command.decode('utf-8')
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
247 else: return None
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
248 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
249 # WARNING: memory leak could happen here, as we don't do the following :
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
250 # if self._command != NULL: free(self._command)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
251 self._command = copy_string(value)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
252 self._status = set_has_var(self._status, pos_command)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
253 property is_move:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
254 def __get__(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
255 if has_var(self._status, pos_is_move): return True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
256 else: return False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
257 def __set__(self, value):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
258 if value: self._status = set_has_var(self._status, pos_is_move)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
259 else: self._status = unset_has_var(self._status, pos_is_move)

mercurial