mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
880e889380
Summary: using namespace in header file is a bad practice due to many reasons as well as discouraged by -Wheader-hygiene compiler flag which is default for many apps https://stackoverflow.com/questions/5849457/using-namespace-in-c-headers https://stackoverflow.com/questions/223021/whats-the-scope-of-the-using-declaration-in-c Changelog: [Internal] Drop `using namespace` in .h files. Reviewed By: christophpurrer Differential Revision: D40628064 fbshipit-source-id: 8a032f3ab0321a531e26bd88656ad9a65b6d5154
80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include <folly/dynamic.h>
|
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
#include <react/renderer/components/view/ViewProps.h>
|
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
#include <react/renderer/core/PropsParserContext.h>
|
|
#include <react/renderer/core/RawProps.h>
|
|
#include <react/renderer/core/ShadowNode.h>
|
|
|
|
/**
|
|
* This defines a set of TestComponent classes: Props, ShadowNode,
|
|
* ComponentDescriptor. To be used for testing purpose.
|
|
*/
|
|
|
|
namespace facebook::react {
|
|
|
|
class TestState {
|
|
public:
|
|
int number;
|
|
};
|
|
|
|
static const char TestComponentName[] = "Test";
|
|
|
|
class TestProps : public ViewProps {
|
|
public:
|
|
TestProps() = default;
|
|
|
|
TestProps(
|
|
const PropsParserContext &context,
|
|
const TestProps &sourceProps,
|
|
const RawProps &rawProps)
|
|
: ViewProps(context, sourceProps, rawProps) {}
|
|
};
|
|
|
|
using SharedTestProps = std::shared_ptr<const TestProps>;
|
|
|
|
class TestShadowNode;
|
|
|
|
using SharedTestShadowNode = std::shared_ptr<const TestShadowNode>;
|
|
|
|
class TestShadowNode final : public ConcreteViewShadowNode<
|
|
TestComponentName,
|
|
TestProps,
|
|
ViewEventEmitter,
|
|
TestState> {
|
|
public:
|
|
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
|
|
Transform _transform{Transform::Identity()};
|
|
|
|
Transform getTransform() const override {
|
|
return _transform;
|
|
}
|
|
|
|
facebook::react::Point _contentOriginOffset{};
|
|
|
|
facebook::react::Point getContentOriginOffset() const override {
|
|
return _contentOriginOffset;
|
|
}
|
|
};
|
|
|
|
class TestComponentDescriptor
|
|
: public ConcreteComponentDescriptor<TestShadowNode> {
|
|
public:
|
|
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
|
};
|
|
|
|
} // namespace facebook::react
|