| 183 | return self |
| 184 | |
| 185 | def method(self, type, name, args, docs='', static=False, pyname=None, self_ref=True, getter=False): |
| 186 | # we use the "Universal function call syntax" |
| 187 | # Type::method(&mut self, arg1, arg2) |
| 188 | # which is equivalent to: |
| 189 | # self.method(arg1, arg2) |
| 190 | original = f'{self.module}::{self.name}::{name}' |
| 191 | if static: |
| 192 | actual_args = args |
| 193 | else: |
| 194 | if self_ref: |
| 195 | actual_args = [Var(self.type.mut_ref(), 'this')] + args |
| 196 | else: |
| 197 | actual_args = [Var(self.type, 'this')] + args |
| 198 | |
| 199 | if pyname is None: |
| 200 | pyname = name |
| 201 | |
| 202 | self.methods.append(Method(type, self.c_name, name, actual_args, |
| 203 | make_safe_call(type, original, actual_args), docs=docs |
| 204 | , pyname=pyname, static=static, getter=getter)) |
| 205 | return self |
| 206 | |
| 207 | def to_c(self): |
| 208 | definition = doxygen(self.docs) |