SampleTurboCxxModule.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #pragma once
  8. #import <memory>
  9. #import "NativeSampleTurboCxxModuleSpecJSI.h"
  10. namespace facebook {
  11. namespace react {
  12. /**
  13. * A sample implementation of the C++ spec. In practice, this class can just
  14. * extend jsi::HostObject directly, but using the spec provides build-time
  15. * type-safety.
  16. */
  17. class SampleTurboCxxModule : public NativeSampleTurboCxxModuleSpecJSI {
  18. public:
  19. SampleTurboCxxModule(std::shared_ptr<CallInvoker> jsInvoker);
  20. void voidFunc(jsi::Runtime &rt) override;
  21. bool getBool(jsi::Runtime &rt, bool arg) override;
  22. double getNumber(jsi::Runtime &rt, double arg) override;
  23. jsi::String getString(jsi::Runtime &rt, const jsi::String &arg) override;
  24. jsi::Array getArray(jsi::Runtime &rt, const jsi::Array &arg) override;
  25. jsi::Object getObject(jsi::Runtime &rt, const jsi::Object &arg) override;
  26. jsi::Object getValue(
  27. jsi::Runtime &rt,
  28. double x,
  29. const jsi::String &y,
  30. const jsi::Object &z) override;
  31. void getValueWithCallback(jsi::Runtime &rt, const jsi::Function &callback)
  32. override;
  33. jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) override;
  34. jsi::Object getConstants(jsi::Runtime &rt) override;
  35. };
  36. } // namespace react
  37. } // namespace facebook