@@ -136,7 +136,7 @@ def can_handle_function(self, function, cname="", **kwds):
136
136
return False
137
137
return True
138
138
139
- def handle_pari_function (self , function , cname = "" , prototype = "" , help = "" , obsolete = None , ** kwds ):
139
+ def handle_pari_function (self , function , cname , prototype = "" , help = "" , obsolete = None , ** kwds ):
140
140
r"""
141
141
Handle one PARI function: decide whether or not to add the
142
142
function, in which file (as method of :class:`Gen` or
@@ -155,6 +155,7 @@ def handle_pari_function(self, function, cname="", prototype="", help="", obsole
155
155
... cname="bnfinit0", prototype="GD0,L,DGp",
156
156
... help=r"bnfinit(P,{flag=0},{tech=[]}): compute...",
157
157
... **{"class":"basic", "section":"number_fields"})
158
+ GEN bnfinit0(GEN, long, GEN, long)
158
159
def bnfinit(P, long flag=0, tech=None, long precision=0):
159
160
...
160
161
cdef GEN _P = P.g
@@ -172,7 +173,7 @@ def bnfinit(P, long flag=0, tech=None, long precision=0):
172
173
... cname="ellmodulareqn", prototype="LDnDn",
173
174
... help=r"ellmodulareqn(N,{x},{y}): return...",
174
175
... **{"class":"basic", "section":"elliptic_curves"})
175
- GEN ellmodulareqn(long N , long x , long y )
176
+ GEN ellmodulareqn(long, long, long)
176
177
def ellmodulareqn(self, long N, x=None, y=None):
177
178
...
178
179
cdef long _x = -1
@@ -190,6 +191,7 @@ def ellmodulareqn(self, long N, x=None, y=None):
190
191
... help=r"setrand(n): reset the seed...",
191
192
... doc=r"reseeds the random number generator...",
192
193
... **{"class":"basic", "section":"programming/specific"})
194
+ void setrand(GEN)
193
195
def setrand(n):
194
196
r'''
195
197
Reseeds the random number generator using the seed :math:`n`. No value is
@@ -209,7 +211,7 @@ def setrand(n):
209
211
... help="bernvec(x): this routine is obsolete, use bernfrac repeatedly.",
210
212
... obsolete="2007-03-30",
211
213
... **{"class":"basic", "section":"transcendental"})
212
- GEN bernvec(long x )
214
+ GEN bernvec(long)
213
215
def bernvec(self, long x):
214
216
r'''
215
217
This routine is obsolete, kept for backward compatibility only.
@@ -221,32 +223,43 @@ def bernvec(self, long x):
221
223
return new_gen(_ret)
222
224
<BLANKLINE>
223
225
"""
224
- if not cname :
225
- raise ValueError ('function {} has no associated C name' .format (function ))
226
226
try :
227
227
args , ret = parse_prototype (prototype , help )
228
228
except NotImplementedError :
229
229
return # Skip unsupported prototype codes
230
230
231
231
doc = get_rest_doc (function )
232
232
233
+ self .write_declaration (cname , args , ret , self .decl_file )
234
+
233
235
if len (args ) > 0 and isinstance (args [0 ], PariArgumentGEN ):
234
236
# If the first argument is a GEN, write a method of the
235
237
# Gen class.
236
238
self .write_method (function , cname , args , ret , args ,
237
239
self .gen_file , doc , obsolete )
238
240
239
- # In any case, write a declaration and a method of the Pari class.
240
- self .write_header (cname , args , ret , self .decl_file )
241
-
241
+ # In any case, write a method of the Pari class.
242
242
# Parse again with an extra "self" argument.
243
243
args , ret = parse_prototype (prototype , help , [PariInstanceArgument ()])
244
244
self .write_method (function , cname , args , ret , args [1 :],
245
245
self .instance_file , doc , obsolete )
246
246
247
- def write_header (self , cname , args , ret , file ):
248
- args = ", " .join ('{} {}' .format (a .ctype (), a .name ) for a in args )
249
- print (' {ret} {function}({args})' .format (ret = ret .ctype (), function = cname , args = args ), file = file )
247
+ def write_declaration (self , cname , args , ret , file ):
248
+ """
249
+ Write a .pxd declaration of a PARI library function.
250
+
251
+ INPUT:
252
+
253
+ - ``cname`` -- name of the PARI C library call
254
+
255
+ - ``args``, ``ret`` -- output from ``parse_prototype``
256
+
257
+ - ``file`` -- a file object where the declaration should be
258
+ written to
259
+ """
260
+ args = ", " .join (a .ctype () for a in args )
261
+ s = ' {ret} {function}({args})' .format (ret = ret .ctype (), function = cname , args = args )
262
+ print (s , file = file )
250
263
251
264
def write_method (self , function , cname , args , ret , cargs , file , doc , obsolete ):
252
265
"""
0 commit comments