MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / dict2string

Method dict2string

dev/scripts/examples/example_generator.py:897–930  ·  view source on GitHub ↗
(self, d)

Source from the content-addressed store, hash-verified

895 return out
896
897 def dict2string(self, d):
898 if d['type'] == 'comment':
899 l = '// ' + d['comment']
900 elif d['type'] == 'print':
901 l = 'System.out.println(' + ' + " " + '.join(self.parse_arguments(d['arguments'])) + ')'
902 elif d['type'] == 'function':
903 l = self.map_function(d['function']) + '(' + ', '.join(self.parse_arguments(d['arguments'])) + ')'
904 elif d['type'] == 'vector':
905 l = '{' + ', '.join(self.parse_arguments(d['arguments'])) + '}'
906 elif d['type'] == 'enum':
907 l = self.enum_name_mapping[d['enum']] + '.' + d['key']
908 elif d['type'] == 'class_dereference':
909 l = d['name'] + '.' + self.dict2string(d['RHS'])
910 elif d['type'] == 'custom_assignment':
911 type_name = self.type_name_mapping[d['variable_type']]
912 if type_name:
913 LHS = type_name + ' ' + d['variable_name']
914 else:
915 LHS = d['variable_name']
916
917 if d['RHS']['type'] != 'vector':
918 RHS = self.dict2string(d['RHS'])
919 else: # Custom processing for vector assignment
920 pushes = [d['variable_name'] + '.add(' + arg + ');' for arg in d['RHS']['arguments']]
921 RHS = 'new DoubleVector(); ' + ' '.join(pushes)
922
923 l = ' '.join([LHS, '=', RHS])
924 else:
925 raise ValueError
926
927 if 'EOL' in d and d['EOL']:
928 l += ';'
929
930 return l
931
932 def header(self):
933 return 'public class Example {\n static {\n System.loadLibrary("CoolPropJava");\n }\n\n public static void main(String argv[]){\n'

Callers 1

parse_argumentsMethod · 0.95

Calls 2

parse_argumentsMethod · 0.95
map_functionMethod · 0.80

Tested by

no test coverage detected