def helper(value):
            if type_ == 'float':
                return common.format_float(value) + 'f'
            elif type_ == 'bool':
                return str(bool(value)).lower()
            elif type_ == 'char':
                return "'{0}'".format(value.replace("'", "\\'"))
            elif type_ == 'string':
                return '"{0}"'.format(value.replace('"', '\\"'))
            elif ':bitmask:' in type_:
                value = common.make_c_like_bitmask(value)
                cast = java_common.get_java_type(
                    type_.split(':')[0],
                    1,
                    legacy=self.get_device().has_java_legacy_types())

                if cast in ['byte', 'short']:
                    return '({0})({1})'.format(cast, value)
                else:
                    return value
            elif type_.endswith(':constant'):
                return self.get_value_constant(value).get_java_source()
            else:
                cast = java_common.get_java_type(
                    type_, 1, legacy=self.get_device().has_java_legacy_types())

                if cast in ['byte', 'short']:
                    cast = '({0})'.format(cast)
                else:
                    cast = ''

                return cast + str(value)
Example #2
0
 def helper(value):
     if type_ == 'float':
         return common.format_float(value)
     elif type_ == 'bool':
         return str(bool(value))
     elif type_ in ['char', 'string']:
         return '"{0}"'.format(value.replace('"', '\\"'))
     elif ':bitmask:' in type_:
         return common.make_c_like_bitmask(value)
     elif type_.endswith(':constant'):
         return self.get_value_constant(value).get_python_source()
     else:
         return str(value)
Example #3
0
 def helper(value):
     if type_ == 'float':
         return common.format_float(value)
     elif type_ == 'bool':
         return str(bool(value)).lower()
     elif type_ in ['char', 'string']:
         return "'{0}'".format(value.replace("'", "\\'"))
     elif ':bitmask:' in type_:
         return common.make_c_like_bitmask(value)
     elif type_.endswith(':constant'):
         return self.get_value_constant(value).get_javascript_source()
     else:
         return str(value)
Example #4
0
 def helper(value):
     if type_ == 'float':
         return common.format_float(value)
     elif type_ == 'bool':
         return str(bool(value)).lower()
     elif type_ in  ['char', 'string']:
         return global_quote + value.replace(global_quote, '\\' + global_quote) + global_quote
     elif ':bitmask:' in type_:
         return common.make_c_like_bitmask(value, shift='bitshift({0}, {1})', combine='bitor({0}, {1})')
     elif type_.endswith(':constant'):
         return self.get_value_constant(value).get_matlab_source()
     else:
         return str(value)
Example #5
0
 def helper(value):
     if type_ == 'float':
         return common.format_float(value)
     elif type_ == 'bool':
         return str(bool(value)).lower()
     elif type_ == 'char':
         return "'{0}'".format(value.replace("'", "\\'"))
     elif type_ == 'string':
         return '"{0}".to_string()'.format(value.replace('"', '\\"'))
     elif ':bitmask:' in type_:
         return common.make_c_like_bitmask(value)
     elif type_.endswith(':constant'):
         return self.get_value_constant(value).get_rust_source()
     else:
         return str(value)
Example #6
0
 def helper(value):
     if type_ == 'float':
         return common.format_float(value)
     elif type_ == 'bool':
         return str(bool(value)).lower()
     elif type_ in ['char', 'string']:
         return "'{0}'".format(value.replace("'", "''"))
     elif ':bitmask:' in type_:
         return common.make_c_like_bitmask(value,
                                           shift='{0} shl {1}',
                                           combine='({0}) or ({1})')
     elif type_.endswith(':constant'):
         return self.get_value_constant(value).get_delphi_source()
     else:
         return str(value)
Example #7
0
 def helper(value):
     if type_ == 'float':
         return common.format_float(value)
     elif type_ == 'bool':
         return str(bool(value))
     elif type_ == 'char':
         return '"{0}"C'.format(value.replace('"', '""'))
     elif type_ == 'string':
         return '"{0}"'.format(value.replace('"', '""'))
     elif ':bitmask:' in type_:
         return common.make_c_like_bitmask(value,
                                           combine='({0}) or ({1})')
     elif type_.endswith(':constant'):
         return self.get_value_constant(value).get_vbnet_source()
     else:
         return str(value)
Example #8
0
 def get_shell_bitmask_comment(self):
     if ':bitmask:' in self.get_type():
         value = self.get_value()
         return '{0} = {1}'.format(common.make_c_like_bitmask(value), value)
     else:
         return None