File: metadata_header_macros.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (61 lines) | stat: -rw-r--r-- 3,286 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_BASE_METADATA_METADATA_HEADER_MACROS_H_
#define UI_BASE_METADATA_METADATA_HEADER_MACROS_H_

#include "ui/base/metadata/metadata_macros_internal.h"
#include "ui/base/metadata/metadata_utils.h"

// Generate Metadata's accessor functions and internal class declaration.
// This should be used in a header file of the View class or its subclasses.
#define _METADATA_HEADER1(class_name)     \
  METADATA_ACCESSORS_INTERNAL(class_name) \
  METADATA_CLASS_INTERNAL(class_name, __FILE__, __LINE__)

#define _METADATA_HEADER2(new_class_name, ancestor_class_name)        \
  static_assert(ui::metadata::kHasClassMetadata<ancestor_class_name>, \
                #ancestor_class_name                                  \
                " doesn't implement metadata. Make "                  \
                "sure class publicly calls METADATA_HEADER in the "   \
                "declaration.");                                      \
                                                                      \
 public:                                                              \
  using kAncestorClass = ancestor_class_name;                         \
  _METADATA_HEADER1(new_class_name);                                  \
                                                                      \
 private:  // NOLINTNEXTLINE

#define METADATA_HEADER(class_name, ancestor_class_name) \
  _METADATA_HEADER2(class_name, ancestor_class_name)

// When adding metadata to a templated class, use this macro. `class_name` is
// the base name of the template class. If the `ancestor_class_name` is also a
// templated class, define a type alias with a `using foo = bar<baz>'`
// statement. Then use that alias for the parameter.
#define METADATA_TEMPLATE_HEADER(class_name, ancestor_class_name)     \
  static_assert(ui::metadata::kHasClassMetadata<ancestor_class_name>, \
                #ancestor_class_name                                  \
                " doesn't implement metadata. Make "                  \
                "sure class publicly calls METADATA_HEADER in the "   \
                "declaration.");                                      \
                                                                      \
 public:                                                              \
  using kAncestorClass = ancestor_class_name;                         \
  METADATA_ACCESSORS_INTERNAL_TEMPLATE(class_name)                    \
  METADATA_CLASS_INTERNAL_TEMPLATE(class_name, __FILE__, __LINE__);   \
                                                                      \
 private:

// A version of METADATA_HEADER for View, the root of the metadata hierarchy.
// Here METADATA_ACCESSORS_INTERNAL_BASE is called.
#define METADATA_HEADER_BASE(class_name)       \
  METADATA_ACCESSORS_INTERNAL_BASE(class_name) \
  METADATA_CLASS_INTERNAL(class_name, __FILE__, __LINE__)

#define DECLARE_TEMPLATE_METADATA(class_name_alias, template_name) \
  DECLARE_TEMPLATE_METADATA_INTERNAL(                              \
      class_name_alias, METADATA_CLASS_NAME_INTERNAL(template_name))

#endif  // UI_BASE_METADATA_METADATA_HEADER_MACROS_H_