Coverage for pyTooling/CallByRef/__init__.py: 91%

269 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-07 00:00 +0000

1# ==================================================================================================================== # 

2# _____ _ _ ____ _ _ ____ ____ __ # 

3# _ __ _ |_ _|__ ___ | (_)_ __ __ _ / ___|__ _| | | __ ) _ _| _ \ ___ / _| # 

4# | '_ \| | | || |/ _ \ / _ \| | | '_ \ / _` || | / _` | | | _ \| | | | |_) / _ \ |_ # 

5# | |_) | |_| || | (_) | (_) | | | | | | (_| || |__| (_| | | | |_) | |_| | _ < __/ _| # 

6# | .__/ \__, ||_|\___/ \___/|_|_|_| |_|\__, (_)____\__,_|_|_|____/ \__, |_| \_\___|_| # 

7# |_| |___/ |___/ |___/ # 

8# ==================================================================================================================== # 

9# Authors: # 

10# Patrick Lehmann # 

11# # 

12# License: # 

13# ==================================================================================================================== # 

14# Copyright 2017-2026 Patrick Lehmann - Bötzingen, Germany # 

15# # 

16# Licensed under the Apache License, Version 2.0 (the "License"); # 

17# you may not use this file except in compliance with the License. # 

18# You may obtain a copy of the License at # 

19# # 

20# http://www.apache.org/licenses/LICENSE-2.0 # 

21# # 

22# Unless required by applicable law or agreed to in writing, software # 

23# distributed under the License is distributed on an "AS IS" BASIS, # 

24# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

25# See the License for the specific language governing permissions and # 

26# limitations under the License. # 

27# # 

28# SPDX-License-Identifier: Apache-2.0 # 

29# ==================================================================================================================== # 

30# 

31""" 

32Auxiliary classes to implement call-by-reference. 

33 

34.. hint:: 

35 

36 See :ref:`high-level help <COMMON/CallByRef>` for explanations and usage examples. 

37 

38.. seealso:: 

39 

40 :mod:`pyTooling.Common` 

41 |rarr| Helper functions for the data types passed around this way. 

42""" 

43from __future__ import annotations 

44 

45from decimal import Decimal 

46from typing import Any, Generic, Self, TypeVar, Optional as Nullable 

47 

48from pyTooling.Common import getFullyQualifiedName 

49from pyTooling.Decorators import export 

50from pyTooling.MetaClasses import ExtendedType 

51 

52 

53T = TypeVar("T") 

54 

55 

56@export 

57class CallByRefParam(Generic[T], metaclass=ExtendedType, slots=True): 

58 """ 

59 Implements a *call-by-reference* parameter. 

60 

61 .. seealso:: 

62 

63 :class:`CallByRefBoolParam` 

64 |rarr| A special *call-by-reference* implementation for boolean reference types. 

65 :class:`CallByRefIntParam` 

66 |rarr| A special *call-by-reference* implementation for integer reference types. 

67 """ 

68 

69 Value: T #: internal value 

70 

71 def __init__(self, value: Nullable[T] = None) -> None: 

72 """Constructs a *call-by-reference* object for any type. 

73 

74 :param value: Optional, the value to be set as an initial value. 

75 """ 

76 self.Value = value 

77 

78 def __ilshift__(self, other: T) -> Self: 

79 """Assigns a value to the *call-by-reference* object. 

80 

81 :param other: The value to be assigned to this *call-by-reference* object. 

82 :returns: Itself. 

83 """ 

84 self.Value = other 

85 return self 

86 

87 # binary operators - comparison 

88 def __eq__(self, other: Any) -> bool: 

89 """ 

90 Compare a CallByRefParam wrapped value with another instances (CallbyRefParam) or non-wrapped value for equality. 

91 

92 :param other: Parameter to compare against. 

93 :returns: ``True``, if both values are equal. 

94 """ 

95 if isinstance(other, CallByRefParam): 95 ↛ 96line 95 didn't jump to line 96 because the condition on line 95 was never true

96 return self.Value == other.Value 

97 else: 

98 return self.Value == other 

99 

100 def __ne__(self, other: Any) -> bool: 

101 """ 

102 Compare a CallByRefParam wrapped value with another instances (CallbyRefParam) or non-wrapped value for inequality. 

103 

104 :param other: Parameter to compare against. 

105 :returns: ``True``, if both values are unequal. 

106 """ 

107 if isinstance(other, CallByRefParam): 107 ↛ 108line 107 didn't jump to line 108 because the condition on line 107 was never true

108 return self.Value != other.Value 

109 else: 

110 return self.Value != other 

111 

112 # Type conversion operators 

113 def __repr__(self) -> str: 

114 """ 

115 Returns the wrapped object's string representation. 

116 

117 :returns: The string representation of the wrapped value. 

118 """ 

119 return repr(self.Value) 

120 

121 def __str__(self) -> str: 

122 """ 

123 Returns the wrapped object's string equivalent. 

124 

125 :returns: The string equivalent of the wrapped value. 

126 """ 

127 return str(self.Value) 

128 

129 

130@export 

131class CallByRefBoolParam(CallByRefParam[bool]): 

132 """A special *call-by-reference* implementation for boolean reference types.""" 

133 

134 # Binary operators - comparison 

135 def __eq__(self, other: Any) -> bool: 

136 """ 

137 Compare a CallByRefBoolParam wrapped boolean value with another instances (CallByRefBoolParam) or non-wrapped boolean value for equality. 

138 

139 :param other: Parameter to compare against. 

140 :returns: ``True``, if both values are equal. 

141 :raises TypeError: If parameter ``other`` is not of type boolean or :class:`CallByRefBoolParam`. 

142 """ 

143 if isinstance(other, bool): 

144 return self.Value == other 

145 elif isinstance(other, CallByRefBoolParam): 145 ↛ 146line 145 didn't jump to line 146 because the condition on line 145 was never true

146 return self.Value == other.Value 

147 else: 

148 ex = TypeError("Second operand is not supported by == operator.") 

149 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

150 ex.add_note("Supported types for second operand: bool, CallByRefBoolParam") 

151 raise ex 

152 

153 def __ne__(self, other: Any) -> bool: 

154 """ 

155 Compare a CallByRefBoolParam wrapped boolean value with another instances (CallByRefBoolParam) or non-wrapped boolean value for inequality. 

156 

157 :param other: Parameter to compare against. 

158 :returns: ``True``, if both values are unequal. 

159 :raises TypeError: If parameter ``other`` is not of type boolean or :class:`CallByRefBoolParam`. 

160 """ 

161 if isinstance(other, bool): 

162 return self.Value != other 

163 elif isinstance(other, CallByRefBoolParam): 163 ↛ 164line 163 didn't jump to line 164 because the condition on line 163 was never true

164 return self.Value != other.Value 

165 else: 

166 ex = TypeError("Second operand is not supported by != operator.") 

167 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

168 ex.add_note("Supported types for second operand: bool, CallByRefBoolParam") 

169 raise ex 

170 

171 # Type conversion operators 

172 def __bool__(self) -> bool: 

173 """ 

174 Type conversion to :class:`bool`. 

175 

176 :returns: The wrapped value. 

177 """ 

178 return self.Value 

179 

180 def __int__(self) -> int: 

181 """ 

182 Type conversion to :class:`int`. 

183 

184 :returns: The integer representation of the wrapped boolean value. 

185 """ 

186 return int(self.Value) 

187 

188 

189@export 

190class CallByRefIntParam(CallByRefParam[int]): 

191 """A special *call-by-reference* implementation for integer reference types.""" 

192 

193 # Unary operators 

194 def __neg__(self) -> int: 

195 """ 

196 Negate: :pycode:`-self`. 

197 

198 :returns: The negated value. 

199 """ 

200 return -self.Value 

201 

202 def __pos__(self) -> int: 

203 """ 

204 Positive: :pycode:`+self`. 

205 

206 :returns: The value with a positive sign. 

207 """ 

208 return +self.Value 

209 

210 def __invert__(self) -> int: 

211 """ 

212 Invert: :pycode:`~self`. 

213 

214 :returns: The bitwise inverted value. 

215 """ 

216 return ~self.Value 

217 

218 # Binary operators - logical 

219 def __and__(self, other: Any) -> int: 

220 """ 

221 And: :pycode:`self & other`. 

222 

223 :param other: Second operand, which has to be of type integer. 

224 :returns: Result of the bitwise *and* operation. 

225 :raises TypeError: If the second operand is not of type integer. 

226 """ 

227 if isinstance(other, int): 

228 return self.Value & other 

229 else: 

230 ex = TypeError("Second operand is not supported by and operator.") 

231 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

232 ex.add_note("Supported types for second operand: int") 

233 raise ex 

234 

235 def __or__(self, other: Any) -> int: 

236 """ 

237 Or: :pycode:`self | other`. 

238 

239 :param other: Second operand, which has to be of type integer. 

240 :returns: Result of the bitwise *or* operation. 

241 :raises TypeError: If the second operand is not of type integer. 

242 """ 

243 if isinstance(other, int): 

244 return self.Value | other 

245 else: 

246 ex = TypeError("Second operand is not supported by or operator.") 

247 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

248 ex.add_note("Supported types for second operand: int") 

249 raise ex 

250 

251 def __xor__(self, other: Any) -> int: 

252 """ 

253 Xor: :pycode:`self ^ other`. 

254 

255 :param other: Second operand, which has to be of type integer. 

256 :returns: Result of the bitwise *exclusive or* operation. 

257 :raises TypeError: If the second operand is not of type integer. 

258 """ 

259 if isinstance(other, int): 

260 return self.Value ^ other 

261 else: 

262 ex = TypeError("Second operand is not supported by xor operator.") 

263 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

264 ex.add_note("Supported types for second operand: int") 

265 raise ex 

266 

267 # Binary inplace operators 

268 def __iand__(self, other: Any) -> Self: 

269 """ 

270 In-place and: :pycode:`self &= other`. 

271 

272 :param other: Second operand, which has to be of type integer. 

273 :returns: The same *call-by-reference* object, with its value updated. 

274 :raises TypeError: If the second operand is not of type integer. 

275 """ 

276 if isinstance(other, int): 

277 self.Value &= other 

278 return self 

279 else: 

280 ex = TypeError("Second operand is not supported by &= operator.") 

281 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

282 ex.add_note("Supported types for second operand: int") 

283 raise ex 

284 

285 def __ior__(self, other: Any) -> Self: 

286 r""" 

287 In-place or: :pycode:`self |= other`. 

288 

289 :param other: Second operand, which has to be of type integer. 

290 :returns: The same *call-by-reference* object, with its value updated. 

291 :raises TypeError: If the second operand is not of type integer. 

292 """ 

293 if isinstance(other, int): 

294 self.Value |= other 

295 return self 

296 else: 

297 ex = TypeError("Second operand is not supported by |= operator.") 

298 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

299 ex.add_note("Supported types for second operand: int") 

300 raise ex 

301 

302 def __ixor__(self, other: Any) -> Self: 

303 """ 

304 In-place xor: :pycode:`self ^= other`. 

305 

306 :param other: Second operand, which has to be of type integer. 

307 :returns: The same *call-by-reference* object, with its value updated. 

308 :raises TypeError: If the second operand is not of type integer. 

309 """ 

310 if isinstance(other, int): 

311 self.Value ^= other 

312 return self 

313 else: 

314 ex = TypeError("Second operand is not supported by ^= operator.") 

315 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

316 ex.add_note("Supported types for second operand: int") 

317 raise ex 

318 

319 # Binary operators - arithmetic 

320 def __add__(self, other: Any) -> int: 

321 """ 

322 Addition: :pycode:`self + other`. 

323 

324 :param other: Second operand, which has to be of type integer. 

325 :returns: Sum of both operands. 

326 :raises TypeError: If the second operand is not of type integer. 

327 """ 

328 if isinstance(other, int): 

329 return self.Value + other 

330 else: 

331 ex = TypeError("Second operand is not supported by + operator.") 

332 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

333 ex.add_note("Supported types for second operand: int") 

334 raise ex 

335 

336 def __sub__(self, other: Any) -> int: 

337 """ 

338 Subtraction: :pycode:`self - other`. 

339 

340 :param other: Second operand, which has to be of type integer. 

341 :returns: Difference of both operands. 

342 :raises TypeError: If the second operand is not of type integer. 

343 """ 

344 if isinstance(other, int): 

345 return self.Value - other 

346 else: 

347 ex = TypeError("Second operand is not supported by - operator.") 

348 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

349 ex.add_note("Supported types for second operand: int") 

350 raise ex 

351 

352 def __truediv__(self, other: Any) -> int: 

353 """ 

354 Division: :pycode:`self / other`. 

355 

356 :param other: Second operand, which has to be of type integer. 

357 :returns: Quotient of both operands. 

358 :raises TypeError: If the second operand is not of type integer. 

359 """ 

360 if isinstance(other, int): 

361 return self.Value / other 

362 else: 

363 ex = TypeError("Second operand is not supported by / operator.") 

364 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

365 ex.add_note("Supported types for second operand: int") 

366 raise ex 

367 

368 def __floordiv__(self, other: Any) -> int: 

369 """ 

370 Floor division: :pycode:`self // other`. 

371 

372 :param other: Second operand, which has to be of type integer. 

373 :returns: Floor of the quotient of both operands. 

374 :raises TypeError: If the second operand is not of type integer. 

375 """ 

376 if isinstance(other, int): 

377 return self.Value // other 

378 else: 

379 ex = TypeError("Second operand is not supported by // operator.") 

380 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

381 ex.add_note("Supported types for second operand: int") 

382 raise ex 

383 

384 def __mul__(self, other: Any) -> int: 

385 """ 

386 Multiplication: :pycode:`self * other`. 

387 

388 :param other: Second operand, which has to be of type integer. 

389 :returns: Product of both operands. 

390 :raises TypeError: If the second operand is not of type integer. 

391 """ 

392 if isinstance(other, int): 

393 return self.Value * other 

394 else: 

395 ex = TypeError("Second operand is not supported by * operator.") 

396 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

397 ex.add_note("Supported types for second operand: int") 

398 raise ex 

399 

400 def __mod__(self, other: Any) -> int: 

401 """ 

402 Modulo: :pycode:`self % other`. 

403 

404 :param other: Second operand, which has to be of type integer. 

405 :returns: Remainder of the division. 

406 :raises TypeError: If the second operand is not of type integer. 

407 """ 

408 if isinstance(other, int): 

409 return self.Value % other 

410 else: 

411 ex = TypeError("Second operand is not supported by % operator.") 

412 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

413 ex.add_note("Supported types for second operand: int") 

414 raise ex 

415 

416 def __pow__(self, other: Any) -> int: 

417 """ 

418 Power: :pycode:`self ** other`. 

419 

420 :param other: Second operand, which has to be of type integer. 

421 :returns: The value raised to the power of the second operand. 

422 :raises TypeError: If the second operand is not of type integer. 

423 """ 

424 if isinstance(other, int): 

425 return self.Value ** other 

426 else: 

427 ex = TypeError("Second operand is not supported by ** operator.") 

428 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

429 ex.add_note("Supported types for second operand: int") 

430 raise ex 

431 

432 # Binary inplace operators - arithmetic 

433 def __iadd__(self, other: Any) -> CallByRefIntParam: 

434 """ 

435 In-place addition: :pycode:`self += other`. 

436 

437 :param other: Second operand, which has to be of type integer. 

438 :returns: The same *call-by-reference* object, with its value updated. 

439 :raises TypeError: If the second operand is not of type integer. 

440 """ 

441 if isinstance(other, int): 

442 self.Value += other 

443 return self 

444 else: 

445 ex = TypeError("Second operand is not supported by xor operator.") 

446 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

447 ex.add_note("Supported types for second operand: int") 

448 raise ex 

449 

450 def __isub__(self, other: Any) -> CallByRefIntParam: 

451 """ 

452 In-place subtraction: :pycode:`self -= other`. 

453 

454 :param other: Second operand, which has to be of type integer. 

455 :returns: The same *call-by-reference* object, with its value updated. 

456 :raises TypeError: If the second operand is not of type integer. 

457 """ 

458 if isinstance(other, int): 

459 self.Value -= other 

460 return self 

461 else: 

462 ex = TypeError("Second operand is not supported by xor operator.") 

463 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

464 ex.add_note("Supported types for second operand: int") 

465 raise ex 

466 

467 def __idiv__(self, other: Any) -> CallByRefIntParam: 

468 """ 

469 In-place division: :pycode:`self /= other`. 

470 

471 :param other: Second operand, which has to be of type integer. 

472 :returns: The same *call-by-reference* object, with its value updated. 

473 :raises TypeError: If the second operand is not of type integer. 

474 """ 

475 if isinstance(other, int): 

476 self.Value /= other 

477 return self 

478 else: 

479 ex = TypeError("Second operand is not supported by xor operator.") 

480 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

481 ex.add_note("Supported types for second operand: int") 

482 raise ex 

483 

484 def __ifloordiv__(self, other: Any) -> CallByRefIntParam: 

485 """ 

486 In-place floor division: :pycode:`self //= other`. 

487 

488 :param other: Second operand, which has to be of type integer. 

489 :returns: The same *call-by-reference* object, with its value updated. 

490 :raises TypeError: If the second operand is not of type integer. 

491 """ 

492 if isinstance(other, int): 

493 self.Value //= other 

494 return self 

495 else: 

496 ex = TypeError("Second operand is not supported by xor operator.") 

497 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

498 ex.add_note("Supported types for second operand: int") 

499 raise ex 

500 

501 def __imul__(self, other: Any) -> CallByRefIntParam: 

502 r""" 

503 In-place multiplication: :pycode:`self *= other`. 

504 

505 :param other: Second operand, which has to be of type integer. 

506 :returns: The same *call-by-reference* object, with its value updated. 

507 :raises TypeError: If the second operand is not of type integer. 

508 """ 

509 if isinstance(other, int): 

510 self.Value *= other 

511 return self 

512 else: 

513 ex = TypeError("Second operand is not supported by xor operator.") 

514 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

515 ex.add_note("Supported types for second operand: int") 

516 raise ex 

517 

518 def __imod__(self, other: Any) -> CallByRefIntParam: 

519 """ 

520 In-place modulo: :pycode:`self %= other`. 

521 

522 :param other: Second operand, which has to be of type integer. 

523 :returns: The same *call-by-reference* object, with its value updated. 

524 :raises TypeError: If the second operand is not of type integer. 

525 """ 

526 if isinstance(other, int): 

527 self.Value %= other 

528 return self 

529 else: 

530 ex = TypeError("Second operand is not supported by xor operator.") 

531 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

532 ex.add_note("Supported types for second operand: int") 

533 raise ex 

534 

535 def __ipow__(self, other: Any) -> CallByRefIntParam: 

536 r""" 

537 In-place power: :pycode:`self **= other`. 

538 

539 :param other: Second operand, which has to be of type integer. 

540 :returns: The same *call-by-reference* object, with its value updated. 

541 :raises TypeError: If the second operand is not of type integer. 

542 """ 

543 if isinstance(other, int): 

544 self.Value **= other 

545 return self 

546 else: 

547 ex = TypeError("Second operand is not supported by xor operator.") 

548 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

549 ex.add_note("Supported types for second operand: int") 

550 raise ex 

551 

552 # Binary operators - comparison 

553 def __eq__(self, other: Any) -> bool: 

554 """ 

555 Compare a CallByRefIntParam wrapped integer value with another instances (CallByRefIntParam) or non-wrapped integer value for equality. 

556 

557 :param other: Parameter to compare against. 

558 :returns: ``True``, if both values are equal. 

559 :raises TypeError:If parameter ``other`` is not of type integer, float, complex number, :class:`Decimal` or 

560 :class:`CallByRefParam`. 

561 """ 

562 if isinstance(other, (int, float, complex, Decimal)) and not isinstance(other, bool): 

563 return self.Value == other 

564 elif isinstance(other, CallByRefIntParam): 564 ↛ 565line 564 didn't jump to line 565 because the condition on line 564 was never true

565 return self.Value == other.Value 

566 else: 

567 ex = TypeError("Second operand is not supported by == operator.") 

568 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

569 ex.add_note("Supported types for second operand: int, float, complex, Decimal, CallByRefIntParam") 

570 raise ex 

571 

572 def __ne__(self, other: Any) -> bool: 

573 """ 

574 Compare a CallByRefIntParam wrapped integer value with another instances (CallByRefIntParam) or non-wrapped integer value for inequality. 

575 

576 :param other: Parameter to compare against. 

577 :returns: ``True``, if both values are unequal. 

578 :raises TypeError:If parameter ``other`` is not of type integer, float, complex number, :class:`Decimal` or 

579 :class:`CallByRefParam`. 

580 """ 

581 if isinstance(other, (int, float, complex, Decimal)) and not isinstance(other, bool): 

582 return self.Value != other 

583 elif isinstance(other, CallByRefIntParam): 583 ↛ 584line 583 didn't jump to line 584 because the condition on line 583 was never true

584 return self.Value != other.Value 

585 else: 

586 ex = TypeError("Second operand is not supported by != operator.") 

587 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

588 ex.add_note("Supported types for second operand: int, float, complex, Decimal, CallByRefIntParam") 

589 raise ex 

590 

591 def __lt__(self, other: Any) -> bool: 

592 """ 

593 Compare a CallByRefIntParam wrapped integer value with another instances (CallByRefIntParam) or non-wrapped integer value for less-than. 

594 

595 :param other: Parameter to compare against. 

596 :returns: ``True``, if the wrapped value is less than the other value. 

597 :raises TypeError:If parameter ``other`` is not of type integer, float, complex number, :class:`Decimal` or 

598 :class:`CallByRefParam`. 

599 """ 

600 if isinstance(other, (int, float, complex, Decimal)) and not isinstance(other, bool): 

601 return self.Value < other 

602 elif isinstance(other, CallByRefIntParam): 602 ↛ 603line 602 didn't jump to line 603 because the condition on line 602 was never true

603 return self.Value < other.Value 

604 else: 

605 ex = TypeError("Second operand is not supported by < operator.") 

606 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

607 ex.add_note("Supported types for second operand: int, float, complex, Decimal, CallByRefIntParam") 

608 raise ex 

609 

610 def __le__(self, other: Any) -> bool: 

611 """ 

612 Compare a CallByRefIntParam wrapped integer value with another instances (CallByRefIntParam) or non-wrapped integer value for less-than-or-equal. 

613 

614 :param other: Parameter to compare against. 

615 :returns: ``True``, if the wrapped value is less than or equal the other value. 

616 :raises TypeError:If parameter ``other`` is not of type integer, float, complex number, :class:`Decimal` or 

617 :class:`CallByRefParam`. 

618 """ 

619 if isinstance(other, (int, float, complex, Decimal)) and not isinstance(other, bool): 

620 return self.Value <= other 

621 elif isinstance(other, CallByRefIntParam): 621 ↛ 622line 621 didn't jump to line 622 because the condition on line 621 was never true

622 return self.Value <= other.Value 

623 else: 

624 ex = TypeError("Second operand is not supported by <= operator.") 

625 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

626 ex.add_note("Supported types for second operand: int, float, complex, Decimal, CallByRefIntParam") 

627 raise ex 

628 

629 def __gt__(self, other: Any) -> bool: 

630 """ 

631 Compare a CallByRefIntParam wrapped integer value with another instances (CallByRefIntParam) or non-wrapped integer value for geater-than. 

632 

633 :param other: Parameter to compare against. 

634 :returns: ``True``, if the wrapped value is greater than the other value. 

635 :raises TypeError:If parameter ``other`` is not of type integer, float, complex number, :class:`Decimal` or 

636 :class:`CallByRefParam`. 

637 """ 

638 if isinstance(other, (int, float, complex, Decimal)) and not isinstance(other, bool): 

639 return self.Value > other 

640 elif isinstance(other, CallByRefIntParam): 640 ↛ 641line 640 didn't jump to line 641 because the condition on line 640 was never true

641 return self.Value > other.Value 

642 else: 

643 ex = TypeError("Second operand is not supported by > operator.") 

644 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

645 ex.add_note("Supported types for second operand: int, float, complex, Decimal, CallByRefIntParam") 

646 raise ex 

647 

648 def __ge__(self, other: Any) -> bool: 

649 """ 

650 Compare a CallByRefIntParam wrapped integer value with another instances (CallByRefIntParam) or non-wrapped integer value for greater-than-or-equal. 

651 

652 :param other: Parameter to compare against. 

653 :returns: ``True``, if the wrapped value is greater than or equal the other value. 

654 :raises TypeError:If parameter ``other`` is not of type integer, float, complex number, :class:`Decimal` or 

655 :class:`CallByRefParam`. 

656 """ 

657 if isinstance(other, (int, float, complex, Decimal)) and not isinstance(other, bool): 

658 return self.Value >= other 

659 elif isinstance(other, CallByRefIntParam): 659 ↛ 660line 659 didn't jump to line 660 because the condition on line 659 was never true

660 return self.Value >= other.Value 

661 else: 

662 ex = TypeError("Second operand is not supported by >= operator.") 

663 ex.add_note(f"Got type '{getFullyQualifiedName(other)}'.") 

664 ex.add_note("Supported types for second operand: int, float, complex, Decimal, CallByRefIntParam") 

665 raise ex 

666 

667 # Type conversion operators 

668 def __bool__(self) -> bool: 

669 """ 

670 Type conversion to :class:`bool`. 

671 

672 :returns: The boolean representation of the wrapped integer value. 

673 """ 

674 return bool(self.Value) 

675 

676 def __int__(self) -> int: 

677 """ 

678 Type conversion to :class:`int`. 

679 

680 :returns: The wrapped value.""" 

681 return self.Value 

682 

683 def __float__(self) -> float: 

684 """ 

685 Type conversion to :class:`float`. 

686 

687 :returns: The float representation of the wrapped integer value. 

688 """ 

689 return float(self.Value)