python/lib/gen_{external,code}.py: prepare for double precision
authorPaul Brossier <piem@piem.org>
Sun, 24 Apr 2016 22:35:53 +0000 (00:35 +0200)
committerPaul Brossier <piem@piem.org>
Sun, 24 Apr 2016 22:35:53 +0000 (00:35 +0200)
python/lib/gen_code.py
python/lib/gen_external.py

index 7c8bc06..d2107a9 100644 (file)
@@ -68,7 +68,7 @@ param_init = {
         }
 
 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 @@ def get_params_types_names(proto):
 
 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']
index ce7f11b..5110092 100644 (file)
@@ -66,8 +66,8 @@ def get_cpp_objects():
 
     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 @@ def generate_external(output_path):
     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: