88script_path = os .path .relpath (script_realpath , root_dir )
99file_path = "src/common/math/Constant.h"
1010file_realpath = os .path .join (root_dir , file_path )
11+ file_handle = open (file_realpath , "w" )
1112
1213header = "// Generated with {}\n " .format (script_path )
1314header += "// Do not modify!"
@@ -264,6 +265,16 @@ class _long_double:
264265
265266# types.append(_long_double)
266267
268+ def beautify (v ):
269+ value = str (v );
270+ if value .startswith ("0." ):
271+ value = value [1 :]
272+ return value
273+
274+ def output (string = "" ):
275+ print (string )
276+ print (string , file = file_handle )
277+
267278keyword = "constexpr"
268279value = "0"
269280
@@ -281,12 +292,6 @@ class _long_double:
281292operation_pad = len (operation_head )
282293gnu_pad = len (gnu_head )
283294
284- file_handle = open (file_realpath , "w" )
285-
286- def output (string = "" ):
287- print (string )
288- print (string , file = file_handle )
289-
290295output (header )
291296output ()
292297output ("#ifndef {}" .format (header_id ))
@@ -330,9 +335,7 @@ def output(string=""):
330335 else :
331336 std = ""
332337
333- value = str (c .compute ()) + t .suffix
334- if value .startswith ("0." ):
335- value = value [1 :]
338+ value = beautify (c .compute ()) + t .suffix
336339
337340 l = len (value )
338341 if l > value_pad :
@@ -358,9 +361,7 @@ def output(string=""):
358361 else :
359362 std = ""
360363
361- value = str (c .compute ()) + t .suffix
362- if value .startswith ("0." ):
363- value = value [1 :]
364+ value = beautify (c .compute ()) + t .suffix
364365
365366 fields = keyword , t .name , name , "=" , value , ";" , "//" , c .operation , gnu , std
366367 output (string .format (* fields ).rstrip ())
0 commit comments