Converting to the target type, provide temporary object value name only if necessary.
(
to_name, value_name, needs_conversion_check, emit, context
)
| 244 | |
| 245 | @contextmanager |
| 246 | def withObjectCodeTemporaryAssignment2( |
| 247 | to_name, value_name, needs_conversion_check, emit, context |
| 248 | ): |
| 249 | """Converting to the target type, provide temporary object value name only if necessary.""" |
| 250 | |
| 251 | if to_name.c_type == "PyObject *": |
| 252 | value_name = to_name |
| 253 | else: |
| 254 | value_name = context.allocateTempName(value_name) |
| 255 | |
| 256 | yield value_name |
| 257 | |
| 258 | if to_name is not value_name: |
| 259 | # This is also tasked to release value_name. |
| 260 | to_name.getCType().emitAssignConversionCode( |
| 261 | to_name=to_name, |
| 262 | value_name=value_name, |
| 263 | needs_check=needs_conversion_check, |
| 264 | emit=emit, |
| 265 | context=context, |
| 266 | ) |
| 267 | |
| 268 | |
| 269 | @contextmanager |
no test coverage detected
searching dependent graphs…