[cfe-commits] [PATCH] libclang python bindings: CompileCommand.arguments should return python strings

Arnaud de Grandmaison arnaud.adegm at gmail.com
Mon Jul 9 17:03:53 PDT 2012


Commited with r159970.

Cheers,
--
Arnaud de Grandmaison

On Sunday 08 July 2012 22:55:34 Arnaud ALLARD DE GRANDMAISON wrote:
> Looks good to me.
> 
> Cheers,
> --
> Arnaud de Grandmaison
> ________________________________________
> From: David Rothlisberger [drothlis at gmail.com] On Behalf Of David
> Röthlisberger [david at rothlis.net] Sent: Sunday, July 08, 2012 5:55 PM
> To: Arnaud ALLARD DE GRANDMAISON; Gregory Szorc; cfe-commits at cs.uiuc.edu
> Subject: [PATCH] libclang python bindings: CompileCommand.arguments should
> return python strings
> 
> With this change, CompileCommand.arguments is consistent with
> CompileCommand.directory (and with the rest of our python bindings).
> 
> Note that setting the ctypes errcheck attribute to achieve this
> (instead of manually calling _CXString.spelling, as
> CompileCommand.directory used to do) is also consistent with the
> rest of our python bindings.
> ---
>  bindings/python/clang/cindex.py          | 4 +++-
>  bindings/python/tests/cindex/test_cdb.py | 4 ++--
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/bindings/python/clang/cindex.py
> b/bindings/python/clang/cindex.py index afbfe3d..295f1a7 100644
> --- a/bindings/python/clang/cindex.py
> +++ b/bindings/python/clang/cindex.py
> @@ -2132,7 +2132,7 @@ class CompileCommand(object):
>      @property
>      def directory(self):
>          """Get the working directory for this CompileCommand"""
> -        return CompileCommand_getDirectory(self.cmd).spelling
> +        return CompileCommand_getDirectory(self.cmd)
> 
>      @property
>      def arguments(self):
> @@ -2603,6 +2603,7 @@ CompileCommands_getCommand.restype = c_object_p
>  CompileCommand_getDirectory = lib.clang_CompileCommand_getDirectory
>  CompileCommand_getDirectory.argtypes = [c_object_p]
>  CompileCommand_getDirectory.restype = _CXString
> +CompileCommand_getDirectory.errcheck = _CXString.from_result
> 
>  CompileCommand_getNumArgs = lib.clang_CompileCommand_getNumArgs
>  CompileCommand_getNumArgs.argtypes = [c_object_p]
> @@ -2611,6 +2612,7 @@ CompileCommand_getNumArgs.restype = c_uint
>  CompileCommand_getArg = lib.clang_CompileCommand_getArg
>  CompileCommand_getArg.argtypes = [c_object_p, c_uint]
>  CompileCommand_getArg.restype = _CXString
> +CompileCommand_getArg.errcheck = _CXString.from_result
> 
>  __all__ = [
>      'CodeCompletionResults',
> diff --git a/bindings/python/tests/cindex/test_cdb.py
> b/bindings/python/tests/cindex/test_cdb.py index 38de4b1..c59c439 100644
> --- a/bindings/python/tests/cindex/test_cdb.py
> +++ b/bindings/python/tests/cindex/test_cdb.py
> @@ -41,7 +41,7 @@ def test_1_compilecommand():
>      expected = [ 'clang++', '-o', 'project.o', '-c',
>                   '/home/john.doe/MyProject/project.cpp']
>      for arg, exp in zip(cmds[0].arguments, expected):
> -        assert arg.spelling == exp
> +        assert arg == exp
> 
>  def test_2_compilecommand():
>      """Check file with 2 compile commands"""
> @@ -59,7 +59,7 @@ def test_2_compilecommand():
>      for i in range(len(cmds)):
>          assert cmds[i].directory == expected[i]['wd']
>          for arg, exp in zip(cmds[i].arguments, expected[i]['line']):
> -            assert arg.spelling == exp
> +            assert arg == exp
> 
>  def test_compilationDB_references():
>      """Ensure CompilationsCommands are independent of the database"""
> --
> 1.7.11.1
> 
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list