Skip to content

Commit 0fbdb80

Browse files
author
Release Manager
committed
sagemathgh-39530: Improvement to flint_autogen reader See sagemath#39413 (comment) In flint latest master, there's this thing ``` .. function:: void n_mulmod_and_precomp_shoup(ulong * ab, ulong * ab_precomp, \ ulong a, ulong b, \ ulong a_pr_quo, ulong a_pr_rem, ulong b_precomp, \ ulong n) ``` In order to parse this (trailing backslash), it is necessary to modify `flint_autogen.py`. Now I only handled it for function so far. Also some minor unrelated changes. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. (no change) ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39530 Reported by: user202729 Reviewer(s): Frédéric Chapoton
2 parents ea062a9 + a787dec commit 0fbdb80

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/sage_setup/autogen/flint/reader.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,16 @@ def process_line(self):
176176
line = self.lines[self.i]
177177
if line.startswith('.. function::'):
178178
self.add_declaration()
179-
if line[13] != ' ':
179+
line_rest = line.removeprefix('.. function::')
180+
if not line_rest.startswith(' '):
180181
print('Warning: no space {}'.format(line))
181-
self.signatures.append(line[13:].strip())
182182
self.state = self.FUNCTION_DECLARATION
183183
self.i += 1
184+
signature = line_rest.strip()
185+
while signature.endswith('\\'):
186+
signature = signature.removesuffix('\\').strip() + ' ' + self.lines[self.i].strip()
187+
self.i += 1
188+
self.signatures.append(signature)
184189
elif line.startswith('.. macro::'):
185190
self.add_declaration()
186191
if line[10] != ' ':

src/sage_setup/autogen/flint/templates/flint_sage.pyx.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Import this module::
1212

1313
sage: import sage.libs.flint.flint_sage
1414

15-
We verify that :trac:`6919` is correctly fixed::
15+
We verify that :issue:`6919` is correctly fixed::
1616

1717
sage: R.<x> = PolynomialRing(ZZ)
1818
sage: A = 2^(2^17+2^15)

src/sage_setup/autogen/flint/templates/types.pxd.template

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ ctypedef mp_limb_t ulong
2424
ctypedef mp_limb_signed_t slong
2525
ctypedef mp_limb_t flint_bitcnt_t
2626

27+
# New in flint 3.2.0-rc1
28+
ctypedef mp_ptr nn_ptr
29+
ctypedef mp_srcptr nn_srcptr
2730

2831
cdef extern from "flint_wrap.h":
2932
# flint/fmpz.h
@@ -269,6 +272,16 @@ cdef extern from "flint_wrap.h":
269272
ctypedef struct flint_rand_s:
270273
pass
271274
ctypedef flint_rand_s flint_rand_t[1]
275+
ctypedef enum flint_err_t:
276+
# flint_autogen.py does not support parsing .. enum:: yet
277+
FLINT_ERROR
278+
FLINT_OVERFLOW
279+
FLINT_IMPINV
280+
FLINT_DOMERR
281+
FLINT_DIVZERO
282+
FLINT_EXPOF
283+
FLINT_INEXACT
284+
FLINT_TEST_FAIL
272285

273286
cdef long FLINT_BITS
274287
cdef long FLINT_D_BITS

0 commit comments

Comments
 (0)