String to int conversion. Closes #362.

pull/373/head
Jussi Pakkanen 9 years ago
parent 8d8d696966
commit 0c96dbff3a
  1. 5
      mesonbuild/interpreter.py
  2. 2
      test cases/common/42 string formatting/meson.build
  3. 3
      test cases/failing/25 int conversion/meson.build

@ -2019,6 +2019,11 @@ class Interpreter():
if method_name == 'startswith':
return obj.startswith(s)
return obj.endswith(s)
elif method_name == 'to_int':
try:
return int(obj)
except Exception:
raise InterpreterException('String can not be converted to int: ' + obj)
raise InterpreterException('Unknown method "%s" for a string.' % method_name)
def to_native(self, arg):

@ -40,3 +40,5 @@ endif
if long.endswith(prefix)
error('Not suffix.')
endif
assert('3'.to_int() == 3, 'String int conversion does not work.')

@ -0,0 +1,3 @@
project('int conversion', 'c')
'notanumber'.to_int()
Loading…
Cancel
Save