| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3260,3 +3260,108 @@ exit: | |||
| 3260 | 3260 | static PyObject * | |
| 3261 | 3261 | test_keyword_only_parameter_impl(PyObject *module, PyBytesObject *co_lnotab) | |
| 3262 | 3262 | /*[clinic end generated code: output=f25914b402039493 input=303df5046c7e37a3]*/ | |
| 3263 | + | ||
| 3264 | + | ||
| 3265 | + /*[clinic input] | ||
| 3266 | + output push | ||
| 3267 | + output preset buffer | ||
| 3268 | + [clinic start generated code]*/ | ||
| 3269 | + /*[clinic end generated code: output=da39a3ee5e6b4b0d input=5bff3376ee0df0b5]*/ | ||
| 3270 | + | ||
| 3271 | + #ifdef CONDITION_A | ||
| 3272 | + /*[clinic input] | ||
| 3273 | + test_preprocessor_guarded_condition_a | ||
| 3274 | + [clinic start generated code]*/ | ||
| 3275 | + | ||
| 3276 | + static PyObject * | ||
| 3277 | + test_preprocessor_guarded_condition_a_impl(PyObject *module) | ||
| 3278 | + /*[clinic end generated code: output=ad012af18085add6 input=8edb8706a98cda7e]*/ | ||
| 3279 | + #elif CONDITION_B | ||
| 3280 | + /*[clinic input] | ||
| 3281 | + test_preprocessor_guarded_elif_condition_b | ||
| 3282 | + [clinic start generated code]*/ | ||
| 3283 | + | ||
| 3284 | + static PyObject * | ||
| 3285 | + test_preprocessor_guarded_elif_condition_b_impl(PyObject *module) | ||
| 3286 | + /*[clinic end generated code: output=615f2dee82b138d1 input=53777cebbf7fee32]*/ | ||
| 3287 | + #else | ||
| 3288 | + /*[clinic input] | ||
| 3289 | + test_preprocessor_guarded_else | ||
| 3290 | + [clinic start generated code]*/ | ||
| 3291 | + | ||
| 3292 | + static PyObject * | ||
| 3293 | + test_preprocessor_guarded_else_impl(PyObject *module) | ||
| 3294 | + /*[clinic end generated code: output=13af7670aac51b12 input=6657ab31d74c29fc]*/ | ||
| 3295 | + #endif | ||
| 3296 | + | ||
| 3297 | + /*[clinic input] | ||
| 3298 | + dump buffer | ||
| 3299 | + output pop | ||
| 3300 | + [clinic start generated code]*/ | ||
| 3301 | + | ||
| 3302 | + #if defined(CONDITION_A) | ||
| 3303 | + | ||
| 3304 | + PyDoc_STRVAR(test_preprocessor_guarded_condition_a__doc__, | ||
| 3305 | + "test_preprocessor_guarded_condition_a($module, /)\n" | ||
| 3306 | + "--\n" | ||
| 3307 | + "\n"); | ||
| 3308 | + | ||
| 3309 | + #define TEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF \ | ||
| 3310 | + {"test_preprocessor_guarded_condition_a", (PyCFunction)test_preprocessor_guarded_condition_a, METH_NOARGS, test_preprocessor_guarded_condition_a__doc__}, | ||
| 3311 | + | ||
| 3312 | + static PyObject * | ||
| 3313 | + test_preprocessor_guarded_condition_a(PyObject *module, PyObject *Py_UNUSED(ignored)) | ||
| 3314 | + { | ||
| 3315 | + return test_preprocessor_guarded_condition_a_impl(module); | ||
| 3316 | + } | ||
| 3317 | + | ||
| 3318 | + #endif /* defined(CONDITION_A) */ | ||
| 3319 | + | ||
| 3320 | + #if !defined(CONDITION_A) && (CONDITION_B) | ||
| 3321 | + | ||
| 3322 | + PyDoc_STRVAR(test_preprocessor_guarded_elif_condition_b__doc__, | ||
| 3323 | + "test_preprocessor_guarded_elif_condition_b($module, /)\n" | ||
| 3324 | + "--\n" | ||
| 3325 | + "\n"); | ||
| 3326 | + | ||
| 3327 | + #define TEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF \ | ||
| 3328 | + {"test_preprocessor_guarded_elif_condition_b", (PyCFunction)test_preprocessor_guarded_elif_condition_b, METH_NOARGS, test_preprocessor_guarded_elif_condition_b__doc__}, | ||
| 3329 | + | ||
| 3330 | + static PyObject * | ||
| 3331 | + test_preprocessor_guarded_elif_condition_b(PyObject *module, PyObject *Py_UNUSED(ignored)) | ||
| 3332 | + { | ||
| 3333 | + return test_preprocessor_guarded_elif_condition_b_impl(module); | ||
| 3334 | + } | ||
| 3335 | + | ||
| 3336 | + #endif /* !defined(CONDITION_A) && (CONDITION_B) */ | ||
| 3337 | + | ||
| 3338 | + #if !defined(CONDITION_A) && !(CONDITION_B) | ||
| 3339 | + | ||
| 3340 | + PyDoc_STRVAR(test_preprocessor_guarded_else__doc__, | ||
| 3341 | + "test_preprocessor_guarded_else($module, /)\n" | ||
| 3342 | + "--\n" | ||
| 3343 | + "\n"); | ||
| 3344 | + | ||
| 3345 | + #define TEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF \ | ||
| 3346 | + {"test_preprocessor_guarded_else", (PyCFunction)test_preprocessor_guarded_else, METH_NOARGS, test_preprocessor_guarded_else__doc__}, | ||
| 3347 | + | ||
| 3348 | + static PyObject * | ||
| 3349 | + test_preprocessor_guarded_else(PyObject *module, PyObject *Py_UNUSED(ignored)) | ||
| 3350 | + { | ||
| 3351 | + return test_preprocessor_guarded_else_impl(module); | ||
| 3352 | + } | ||
| 3353 | + | ||
| 3354 | + #endif /* !defined(CONDITION_A) && !(CONDITION_B) */ | ||
| 3355 | + | ||
| 3356 | + #ifndef TEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF | ||
| 3357 | + #define TEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF | ||
| 3358 | + #endif /* !defined(TEST_PREPROCESSOR_GUARDED_CONDITION_A_METHODDEF) */ | ||
| 3359 | + | ||
| 3360 | + #ifndef TEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF | ||
| 3361 | + #define TEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF | ||
| 3362 | + #endif /* !defined(TEST_PREPROCESSOR_GUARDED_ELIF_CONDITION_B_METHODDEF) */ | ||
| 3363 | + | ||
| 3364 | + #ifndef TEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF | ||
| 3365 | + #define TEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF | ||
| 3366 | + #endif /* !defined(TEST_PREPROCESSOR_GUARDED_ELSE_METHODDEF) */ | ||
| 3367 | + /*[clinic end generated code: output=3804bb18d454038c input=3fc80c9989d2f2e1]*/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fixed translation of ``#elif`` in Argument Clinic. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,23 +141,15 @@ def pop_stack(): | |||
| 141 | 141 | token = fields[0].lower() | |
| 142 | 142 | condition = ' '.join(fields[1:]).strip() | |
| 143 | 143 | ||
| 144 | - if_tokens = {'if', 'ifdef', 'ifndef'} | ||
| 145 | - all_tokens = if_tokens | {'elif', 'else', 'endif'} | ||
| 146 | - | ||
| 147 | - if token not in all_tokens: | ||
| 148 | - return | ||
| 149 | - | ||
| 150 | - # cheat a little here, to reuse the implementation of if | ||
| 151 | - if token == 'elif': | ||
| 152 | - pop_stack() | ||
| 153 | - token = 'if' | ||
| 154 | - | ||
| 155 | - if token in if_tokens: | ||
| 144 | + if token in {'if', 'ifdef', 'ifndef', 'elif'}: | ||
| 156 | 145 | if not condition: | |
| 157 | 146 | self.fail("Invalid format for #" + token + " line: no argument!") | |
| 158 | - if token == 'if': | ||
| 147 | + if token in {'if', 'elif'}: | ||
| 159 | 148 | if not self.is_a_simple_defined(condition): | |
| 160 | 149 | condition = "(" + condition + ")" | |
| 150 | + if token == 'elif': | ||
| 151 | + previous_token, previous_condition = pop_stack() | ||
| 152 | + self.stack.append((previous_token, negate(previous_condition))) | ||
| 161 | 153 | else: | |
| 162 | 154 | fields = condition.split() | |
| 163 | 155 | if len(fields) != 1: | |
@@ -166,18 +158,21 @@ def pop_stack(): | |||
| 166 | 158 | condition = 'defined(' + symbol + ')' | |
| 167 | 159 | if token == 'ifndef': | |
| 168 | 160 | condition = '!' + condition | |
| 161 | + token = 'if' | ||
| 169 | 162 | ||
| 170 | - self.stack.append(("if", condition)) | ||
| 171 | - if self.verbose: | ||
| 172 | - print(self.status()) | ||
| 173 | - return | ||
| 163 | + self.stack.append((token, condition)) | ||
| 174 | 164 | ||
| 175 | - previous_token, previous_condition = pop_stack() | ||
| 165 | + elif token == 'else': | ||
| 166 | + previous_token, previous_condition = pop_stack() | ||
| 167 | + self.stack.append((previous_token, negate(previous_condition))) | ||
| 176 | 168 | ||
| 177 | - if token == 'else': | ||
| 178 | - self.stack.append(('else', negate(previous_condition))) | ||
| 179 | 169 | elif token == 'endif': | |
| 180 | - pass | ||
| 170 | + while pop_stack()[0] != 'if': | ||
| 171 | + pass | ||
| 172 | + | ||
| 173 | + else: | ||
| 174 | + return | ||
| 175 | + | ||
| 181 | 176 | if self.verbose: | |
| 182 | 177 | print(self.status()) | |
| 183 | 178 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments