History

python/lib/gen_{external,code}.py: prepare for double precision

Paul Brossier committed 10 years ago

Commit fbcee4f1 parent c6388f42 files · +7 −5Browse files

Showing the changes to python (2 of 2 files). Show all

Unified · Split

2 files
  1. python/lib/gen_code.py +4 −2
  2. python/lib/gen_external.py +3 −3
python/lib/gen_code.py+4−2
@@ -68,7 +68,7 @@ param_init = { · 67 unmodified lines
68 }68 }
69 69
70pyargparse_chars = {70pyargparse_chars = {
71 'smpl_t': 'f',71 'smpl_t': 'f', # if not usedouble else 'd',
72 'uint_t': 'I',72 'uint_t': 'I',
73 'sint_t': 'I',73 'sint_t': 'I',
74 'char_t*': 's',74 'char_t*': 's',
@@ -153,7 +153,9 @@ def get_params_types_names(proto): · 78 unmodified lines
153 153
154class MappedObject(object):154class MappedObject(object):
155 155
156 def __init__(self, prototypes):156 def __init__(self, prototypes, usedouble = False):
157 if usedouble:
158 pyargparse_chars['smpl_t'] = 'd'
157 self.prototypes = prototypes159 self.prototypes = prototypes
158 160
159 self.shortname = prototypes['shortname']161 self.shortname = prototypes['shortname']
python/lib/gen_external.py+3−3
@@ -66,8 +66,8 @@ def get_cpp_objects(): · 65 unmodified lines
66 66
67 return cpp_output, cpp_objects67 return cpp_output, cpp_objects
68 68
69def generate_external(output_path):69def generate_external(output_path, usedouble = False):
70 os.mkdir(output_path)70 if not os.path.isdir(output_path): os.mkdir(output_path)
71 sources_list = []71 sources_list = []
72 cpp_output, cpp_objects = get_cpp_objects()72 cpp_output, cpp_objects = get_cpp_objects()
73 lib = {}73 lib = {}
@@ -123,7 +123,7 @@ def generate_external(output_path): · 49 unmodified lines
123 from .gen_code import MappedObject123 from .gen_code import MappedObject
124 for o in lib:124 for o in lib:
125 out = header125 out = header
126 mapped = MappedObject(lib[o])126 mapped = MappedObject(lib[o], usedouble = usedouble)
127 out += mapped.gen_code()127 out += mapped.gen_code()
128 output_file = os.path.join(output_path, 'gen-%s.c' % o)128 output_file = os.path.join(output_path, 'gen-%s.c' % o)
129 with open(output_file, 'w') as f:129 with open(output_file, 'w') as f:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t