cc_macros.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_VECTOR_ICONS_CC_MACROS_H_
  5. #define COMPONENTS_VECTOR_ICONS_CC_MACROS_H_
  6. #include <iterator>
  7. // This file holds macros that are common to each vector icon target's
  8. // vector_icons.cc.template file.
  9. // The prefix is used to help make sure the string IDs are unique. Typically,
  10. // matching the namespace of the icons should ensure that is the case. If the
  11. // vector_icons.cc.template file doesn't define a prefix, we'll go without one.
  12. #ifndef VECTOR_ICON_ID_PREFIX
  13. #define VECTOR_ICON_ID_PREFIX ""
  14. #endif
  15. // This define may be specified by a vector icon target, allowing a compiler
  16. // visibility attribute to be set on the icon symbol.
  17. #ifndef VECTOR_ICON_EXPORT
  18. #define VECTOR_ICON_EXPORT
  19. #endif
  20. #define VECTOR_ICON_REP_TEMPLATE(path_name, ...) \
  21. static constexpr gfx::PathElement path_name[] = {__VA_ARGS__};
  22. #define VECTOR_ICON_TEMPLATE_CC(rep_list_name, icon_name, ...) \
  23. constexpr char icon_name##Id[] = VECTOR_ICON_ID_PREFIX #icon_name; \
  24. static constexpr gfx::VectorIconRep rep_list_name[] = {__VA_ARGS__}; \
  25. VECTOR_ICON_EXPORT constexpr gfx::VectorIcon icon_name = { \
  26. rep_list_name, std::size(rep_list_name), icon_name##Id};
  27. #else // !COMPONENTS_VECTOR_ICONS_CC_MACROS_H_
  28. #error This file should only be included once.
  29. #endif // COMPONENTS_VECTOR_ICONS_CC_MACROS_H_