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

Method dict2string

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

Source from the content-addressed store, hash-verified

961 return out
962
963 def dict2string(self, d):
964 if d['type'] == 'comment':
965 l = '// ' + d['comment']
966 elif d['type'] == 'print':
967 l = 'Console.Write(' + ' + " " + '.join(self.parse_arguments(d['arguments'])) + ' + "\\n")'
968 elif d['type'] == 'function':
969 l = self.map_function(d['function']) + '(' + ', '.join(self.parse_arguments(d['arguments'])) + ')'
970 elif d['type'] == 'vector':
971 l = 'new DoubleVector(new double[]{' + ', '.join(self.parse_arguments(d['arguments'])) + '})'
972 elif d['type'] == 'enum':
973 l = self.enum_name_mapping[d['enum']] + '.' + d['key']
974 elif d['type'] == 'class_dereference':
975 l = d['name'] + '.' + self.dict2string(d['RHS'])
976 elif d['type'] == 'custom_assignment':
977 type_name = self.type_name_mapping[d['variable_type']]
978 if type_name:
979 LHS = type_name + ' ' + d['variable_name']
980 else:
981 LHS = d['variable_name']
982 l = ' '.join([LHS, '=', self.dict2string(d['RHS'])])
983 else:
984 raise ValueError
985
986 if 'EOL' in d and d['EOL']:
987 l += ';'
988
989 return l
990
991 def header(self):
992 return 'using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n {\n'

Callers 1

parse_argumentsMethod · 0.95

Calls 2

parse_argumentsMethod · 0.95
map_functionMethod · 0.80

Tested by

no test coverage detected