Nuitka
The Python compiler
Loading...
Searching...
No Matches
HelpersComparisonDualNe.c
1// Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3/* WARNING, this code is GENERATED. Modify the template HelperOperationComparisonDual.c.j2 instead! */
4
5/* This file is included from another C file, help IDEs to still parse it on its own. */
6#ifdef __IDE_ONLY__
7#include "nuitka/prelude.h"
8#endif
9
10/* C helpers for type specialized "!=" (NE) comparisons */
11
12/* Code referring to "NILONG" corresponds to Nuitka int/long/C long value and "CLONG" to C platform long value. */
13PyObject *RICH_COMPARE_NE_OBJECT_NILONG_CLONG(nuitka_ilong *operand1, long operand2) {
14 CHECK_NILONG_OBJECT(operand1);
15
16 bool left_c_usable = IS_NILONG_C_VALUE_VALID(operand1);
17 bool right_c_usable = true;
18
19 if (left_c_usable && right_c_usable) {
20 bool r = COMPARE_EQ_CBOOL_CLONG_CLONG(operand1->c_value, operand2);
21
22 // Convert to target type.
23 PyObject *result = BOOL_FROM(!r);
24 Py_INCREF_IMMORTAL(result);
25 return result;
26 } else if (!left_c_usable && !right_c_usable) {
27 ENFORCE_NILONG_OBJECT_VALUE(operand1);
28
29 return COMPARE_NE_OBJECT_LONG_CLONG(operand1->python_value, operand2);
30 } else {
31 return COMPARE_NE_OBJECT_LONG_CLONG(operand1->python_value, operand2);
32 }
33}
34
35/* Code referring to "NILONG" corresponds to Nuitka int/long/C long value and "CLONG" to C platform long value. */
36bool RICH_COMPARE_NE_CBOOL_NILONG_CLONG(nuitka_ilong *operand1, long operand2) {
37 CHECK_NILONG_OBJECT(operand1);
38
39 bool left_c_usable = IS_NILONG_C_VALUE_VALID(operand1);
40 bool right_c_usable = true;
41
42 if (left_c_usable && right_c_usable) {
43 bool r = COMPARE_EQ_CBOOL_CLONG_CLONG(operand1->c_value, operand2);
44
45 // Convert to target type.
46 bool result = !r;
47
48 return result;
49 } else if (!left_c_usable && !right_c_usable) {
50 ENFORCE_NILONG_OBJECT_VALUE(operand1);
51
52 return COMPARE_NE_CBOOL_LONG_CLONG(operand1->python_value, operand2);
53 } else {
54 return COMPARE_NE_CBOOL_LONG_CLONG(operand1->python_value, operand2);
55 }
56}
57
58/* Code referring to "NILONG" corresponds to Nuitka int/long/C long value and "DIGIT" to C platform digit value for long
59 * Python objects. */
60PyObject *RICH_COMPARE_NE_OBJECT_NILONG_DIGIT(nuitka_ilong *operand1, long operand2) {
61 CHECK_NILONG_OBJECT(operand1);
62 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
63
64 bool left_c_usable = IS_NILONG_C_VALUE_VALID(operand1);
65 bool right_c_usable = true;
66
67 if (left_c_usable && right_c_usable) {
68 bool r = COMPARE_EQ_CBOOL_CLONG_CLONG(operand1->c_value, operand2);
69
70 // Convert to target type.
71 PyObject *result = BOOL_FROM(!r);
72 Py_INCREF_IMMORTAL(result);
73 return result;
74 } else if (!left_c_usable && !right_c_usable) {
75 ENFORCE_NILONG_OBJECT_VALUE(operand1);
76
77 return COMPARE_NE_OBJECT_LONG_DIGIT(operand1->python_value, operand2);
78 } else {
79 return COMPARE_NE_OBJECT_LONG_DIGIT(operand1->python_value, operand2);
80 }
81}
82
83/* Code referring to "NILONG" corresponds to Nuitka int/long/C long value and "DIGIT" to C platform digit value for long
84 * Python objects. */
85bool RICH_COMPARE_NE_CBOOL_NILONG_DIGIT(nuitka_ilong *operand1, long operand2) {
86 CHECK_NILONG_OBJECT(operand1);
87 assert(Py_ABS(operand2) < (1 << PyLong_SHIFT));
88
89 bool left_c_usable = IS_NILONG_C_VALUE_VALID(operand1);
90 bool right_c_usable = true;
91
92 if (left_c_usable && right_c_usable) {
93 bool r = COMPARE_EQ_CBOOL_CLONG_CLONG(operand1->c_value, operand2);
94
95 // Convert to target type.
96 bool result = !r;
97
98 return result;
99 } else if (!left_c_usable && !right_c_usable) {
100 ENFORCE_NILONG_OBJECT_VALUE(operand1);
101
102 return COMPARE_NE_CBOOL_LONG_DIGIT(operand1->python_value, operand2);
103 } else {
104 return COMPARE_NE_CBOOL_LONG_DIGIT(operand1->python_value, operand2);
105 }
106}
107
108// Part of "Nuitka", an optimizing Python compiler that is compatible and
109// integrates with CPython, but also works on its own.
110//
111// Licensed under the Apache License, Version 2.0 (the "License");
112// you may not use this file except in compliance with the License.
113// You may obtain a copy of the License at
114//
115// http://www.apache.org/licenses/LICENSE-2.0
116//
117// Unless required by applicable law or agreed to in writing, software
118// distributed under the License is distributed on an "AS IS" BASIS,
119// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120// See the License for the specific language governing permissions and
121// limitations under the License.
Definition ints.h:27