]> git.ipfire.org Git - thirdparty/ccache.git/commit
Add an Args class with backward compatibility for the old args API (#575)
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 7 Apr 2020 19:54:30 +0000 (21:54 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Apr 2020 19:54:30 +0000 (21:54 +0200)
commitad52c60067ca1d9d7f70442ffe2bde23716377b1
treeb2f752e48eca78c671708d086cbc4374056c7b36
parent058754ba3eb09ed474fbd234c4ef886ffa836e23
Add an Args class with backward compatibility for the old args API (#575)

The idea of this is to make a proper C++ API while at the same time
implementing most of the old legacy args API. This makes it possible to
refactor call sites gradually instead of in a series of large
refactoring steps.

Given that “struct args* args” is replaced with “Args args”, the
following types of legacy API usage can be kept without source changes:

1. The args_* functions can be used as is.
2. args->argv[i] still works for read access.

Things that aren’t emulated:

1. args->argc (use args.size() instead).
2. args->argv to access the underlying char* array (use
   args.to_argv().data() instead).
3. Mutating the args->argv[i] string in place (don’t do that).

In other words, code that uses args_foo(args, ...) and args->argv[i] can
easily be converted to args.bar(...) and args[i] (with std::string
arguments instead of char*) at will and in arbitrarily small steps.
19 files changed:
Makefile.in
configure.ac
src/Args.cpp [new file with mode: 0644]
src/Args.hpp [new file with mode: 0644]
src/ArgsInfo.cpp
src/ArgsInfo.hpp
src/Context.cpp
src/Context.hpp
src/args.cpp [deleted file]
src/args.hpp [deleted file]
src/ccache.cpp
src/ccache.hpp
src/hashutil.cpp
unittest/framework.cpp
unittest/framework.hpp
unittest/test_Args.cpp [new file with mode: 0644]
unittest/test_args.cpp [deleted file]
unittest/test_argument_processing.cpp
unittest/test_legacy_args.cpp [new file with mode: 0644]