#pragma once #include #include #include #include "JsiSkHostObjects.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdocumentation" #include "SkPoint.h" #pragma clang diagnostic pop namespace ABI48_0_0RNSkia { namespace jsi = ABI48_0_0facebook::jsi; class JsiSkPoint : public JsiSkWrappingSharedPtrHostObject { public: JSI_PROPERTY_GET(x) { return static_cast(getObject()->x()); } JSI_PROPERTY_GET(y) { return static_cast(getObject()->y()); } JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPoint, x), JSI_EXPORT_PROP_GET(JsiSkPoint, y)) JsiSkPoint(std::shared_ptr context, const SkPoint &point) : JsiSkWrappingSharedPtrHostObject( std::move(context), std::make_shared(point)) {} /** Returns the underlying object from a host object of this type */ static std::shared_ptr fromValue(jsi::Runtime &runtime, const jsi::Value &obj) { const auto &object = obj.asObject(runtime); if (object.isHostObject(runtime)) { return object.asHostObject(runtime)->getObject(); } else { auto x = object.getProperty(runtime, "x").asNumber(); auto y = object.getProperty(runtime, "y").asNumber(); return std::make_shared(SkPoint::Make(x, y)); } } /** Returns the jsi object from a host object of this type */ static jsi::Value toValue(jsi::Runtime &runtime, std::shared_ptr context, const SkPoint &point) { return jsi::Object::createFromHostObject( runtime, std::make_shared(std::move(context), point)); } /** * Creates the function for construction a new instance of the SkPoint * wrapper * @param context platform context * @return A function for creating a new host object wrapper for the SkPoint * class */ static const jsi::HostFunctionType createCtor(std::shared_ptr context) { return JSI_HOST_FUNCTION_LAMBDA { auto point = SkPoint::Make(arguments[0].asNumber(), arguments[1].asNumber()); // Return the newly constructed object return jsi::Object::createFromHostObject( runtime, std::make_shared(std::move(context), std::move(point))); }; } }; } // namespace ABI48_0_0RNSkia