ref: fbcee4fde322612474a48791b3b7f00dcb6d4888
parent: c6388f4affa69eb201fa5de663dd8d27fef12b74
author: Paul Brossier <piem@piem.org>
date: Sun Apr 24 20:35:53 EDT 2016
python/lib/gen_{external,code}.py: prepare for double precision
--- a/python/lib/gen_code.py
+++ b/python/lib/gen_code.py
@@ -68,7 +68,7 @@
}
pyargparse_chars = {
- 'smpl_t': 'f',
+ 'smpl_t': 'f', # if not usedouble else 'd',
'uint_t': 'I',
'sint_t': 'I',
'char_t*': 's',
@@ -153,7 +153,9 @@
class MappedObject(object):
- def __init__(self, prototypes):
+ def __init__(self, prototypes, usedouble = False):
+ if usedouble:
+ pyargparse_chars['smpl_t'] = 'd'
self.prototypes = prototypes
self.shortname = prototypes['shortname']
--- a/python/lib/gen_external.py
+++ b/python/lib/gen_external.py
@@ -66,8 +66,8 @@
return cpp_output, cpp_objects
-def generate_external(output_path):
- os.mkdir(output_path)
+def generate_external(output_path, usedouble = False):
+ if not os.path.isdir(output_path): os.mkdir(output_path)
sources_list = []
cpp_output, cpp_objects = get_cpp_objects()
lib = {}
@@ -123,7 +123,7 @@
from .gen_code import MappedObject
for o in lib:
out = header
- mapped = MappedObject(lib[o])
+ mapped = MappedObject(lib[o], usedouble = usedouble)
out += mapped.gen_code()
output_file = os.path.join(output_path, 'gen-%s.c' % o)
with open(output_file, 'w') as f: