diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-07-30 21:44:40 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-07-30 21:44:40 +0300 |
commit | 658a82651897676ab036d922b9603e81a5ba7333 (patch) | |
tree | 696223805ae020bb20e0fb80b1852972079fd969 /interpreter.py | |
parent | 08d18671aeefda22325375909f3bc960d29a6c52 (diff) | |
download | meson-658a82651897676ab036d922b9603e81a5ba7333.zip meson-658a82651897676ab036d922b9603e81a5ba7333.tar.gz meson-658a82651897676ab036d922b9603e81a5ba7333.tar.bz2 |
Can check if headers have functions of a given name.
Diffstat (limited to 'interpreter.py')
-rw-r--r-- | interpreter.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/interpreter.py b/interpreter.py index 318f7b3..0025ec0 100644 --- a/interpreter.py +++ b/interpreter.py @@ -650,6 +650,7 @@ class CompilerHolder(InterpreterObject): 'sizeof': self.sizeof_method, 'has_header': self.has_header_method, 'run' : self.run_method, + 'has_function' : self.has_function_method, }) def run_method(self, args, kwargs): @@ -665,7 +666,25 @@ class CompilerHolder(InterpreterObject): def get_id_method(self, args, kwargs): return self.compiler.get_id() - + + + def has_function_method(self, args, kwargs): + if len(args) != 1: + raise InterpreterException('Has_function takes exactly one argument.') + funcname = args[0] + if not isinstance(funcname, str): + raise InterpreterException('Argument to has_function must be a string.') + prefix = kwargs.get('prefix', '') + if not isinstance(prefix, str): + raise InterpreterException('Prefix argument of has_function must be a string.') + had = self.compiler.has_function(funcname, prefix) + if had: + hadtxt = mlog.green('YES') + else: + hadtxt = mlog.red('NO') + mlog.log('Checking for function "', mlog.bold(funcname), '": ', hadtxt, sep='') + return had + def sizeof_method(self, args, kwargs): if len(args) != 1: raise InterpreterException('Sizeof takes exactly one argument.') @@ -688,7 +707,7 @@ class CompilerHolder(InterpreterObject): if not isinstance(string, str): raise InterpreterException('Argument to compiles() must be a string') return self.compiler.compiles(string) - + def has_header_method(self, args, kwargs): if len(args) != 1: raise InterpreterException('has_header method takes exactly one argument.') |