// 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_MACROS_INTERNAL_H_ #define UI_BASE_METADATA_METADATA_MACROS_INTERNAL_H_ #include <string> #include <utility> #include "ui/base/metadata/metadata_types.h" #include "ui/base/metadata/property_metadata.h" // Internal Metadata Generation Helpers --------------------------------------- #define METADATA_CLASS_NAME_INTERNAL(class_name) … // TODO(kylixrd@): Remove kViewClassName[] from macros once all references to it // have been eradicated and IsViewClass<T> is being used instead. // Metadata Accessors --------------------------------------------------------- #define METADATA_ACCESSORS_INTERNAL(class_name) … #define METADATA_ACCESSORS_INTERNAL_TEMPLATE(class_name) … // A version of METADATA_ACCESSORS_INTERNAL for View, the root of the metadata // hierarchy; here GetClassName() is not declared as an override. // // This also introduces the ReinterpretToBaseClass(), which should exist at the // root of the hierarchy on which the metadata will be attached. This will take // the given void*, which should be some instance of a subclass of this base // class, and return a properly typed class_name*. The body of this function // does a reinterpret_cast<> of the void* to obtain a class_name*. Doing a // direct static_cast<> from the void* may result in an incorrect // pointer-to-instance, which may cause a crash. Using this intermediate step of // reinterpret_cast<> provides more information to the compiler in order to // obtain the proper result from the static_cast<>. See |AsClass(void* obj)| // in property_metadata.h for additional info. #define METADATA_ACCESSORS_INTERNAL_BASE(class_name) … // Metadata Class ------------------------------------------------------------- #define METADATA_CLASS_INTERNAL(class_name, file, line) … #define METADATA_CLASS_INTERNAL_TEMPLATE(class_name, file, line) … #define METADATA_PROPERTY_TYPE_INTERNAL(property_type, property_name, ...) … #define METADATA_READONLY_PROPERTY_TYPE_INTERNAL(property_type, property_name, \ ...) … #define METADATA_CLASS_PROPERTY_TYPE_INTERNAL(property_type, property_key, \ ...) … #define BEGIN_METADATA_INTERNAL(qualified_class_name, metadata_class_name, \ parent_class_name) … #define BEGIN_TEMPLATE_METADATA_INTERNAL(qualified_class_name, \ metadata_class_name) … #define BEGIN_METADATA_INTERNAL_BASE(qualified_class_name, \ metadata_class_name, parent_class_name) … // See the comment above on the METADATA_ACCESSORS_INTERNAL_BASE macro for more // information. NOTE: This function should not be modified to access |this|, // directly or indirectly. It should only do what is necessary to convert |obj| // to a properly typed pointer. #define METADATA_REINTERPRET_BASE_CLASS_INTERNAL(qualified_class_name, \ metadata_class_name) … #define METADATA_PARENT_CLASS_INTERNAL(parent_class_name) … #define DECLARE_TEMPLATE_METADATA_INTERNAL(qualified_class_name, \ metadata_class_name) … #endif // UI_BASE_METADATA_METADATA_MACROS_INTERNAL_H_