NativeSampleTurboCxxModuleSpecJSI.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #include "NativeSampleTurboCxxModuleSpecJSI.h"
  8. // NOTE: This entire file should be codegen'ed.
  9. namespace facebook {
  10. namespace react {
  11. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_voidFunc(
  12. jsi::Runtime &rt,
  13. TurboModule &turboModule,
  14. const jsi::Value *args,
  15. size_t count) {
  16. static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)->voidFunc(rt);
  17. return jsi::Value::undefined();
  18. }
  19. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getBool(
  20. jsi::Runtime &rt,
  21. TurboModule &turboModule,
  22. const jsi::Value *args,
  23. size_t count) {
  24. return jsi::Value(
  25. static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  26. ->getBool(rt, args[0].getBool()));
  27. }
  28. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getNumber(
  29. jsi::Runtime &rt,
  30. TurboModule &turboModule,
  31. const jsi::Value *args,
  32. size_t count) {
  33. return jsi::Value(
  34. static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  35. ->getNumber(rt, args[0].getNumber()));
  36. }
  37. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getString(
  38. jsi::Runtime &rt,
  39. TurboModule &turboModule,
  40. const jsi::Value *args,
  41. size_t count) {
  42. return static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  43. ->getString(rt, args[0].getString(rt));
  44. }
  45. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getArray(
  46. jsi::Runtime &rt,
  47. TurboModule &turboModule,
  48. const jsi::Value *args,
  49. size_t count) {
  50. return static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  51. ->getArray(rt, args[0].getObject(rt).getArray(rt));
  52. }
  53. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getObject(
  54. jsi::Runtime &rt,
  55. TurboModule &turboModule,
  56. const jsi::Value *args,
  57. size_t count) {
  58. return static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  59. ->getObject(rt, args[0].getObject(rt));
  60. }
  61. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getValue(
  62. jsi::Runtime &rt,
  63. TurboModule &turboModule,
  64. const jsi::Value *args,
  65. size_t count) {
  66. return static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  67. ->getValue(
  68. rt,
  69. args[0].getNumber(),
  70. args[1].getString(rt),
  71. args[2].getObject(rt));
  72. }
  73. static jsi::Value
  74. __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getValueWithCallback(
  75. jsi::Runtime &rt,
  76. TurboModule &turboModule,
  77. const jsi::Value *args,
  78. size_t count) {
  79. static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  80. ->getValueWithCallback(
  81. rt, std::move(args[0].getObject(rt).getFunction(rt)));
  82. return jsi::Value::undefined();
  83. }
  84. static jsi::Value
  85. __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getValueWithPromise(
  86. jsi::Runtime &rt,
  87. TurboModule &turboModule,
  88. const jsi::Value *args,
  89. size_t count) {
  90. return static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  91. ->getValueWithPromise(rt, args[0].getBool());
  92. }
  93. static jsi::Value __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getConstants(
  94. jsi::Runtime &rt,
  95. TurboModule &turboModule,
  96. const jsi::Value *args,
  97. size_t count) {
  98. return static_cast<NativeSampleTurboCxxModuleSpecJSI *>(&turboModule)
  99. ->getConstants(rt);
  100. }
  101. NativeSampleTurboCxxModuleSpecJSI::NativeSampleTurboCxxModuleSpecJSI(
  102. std::shared_ptr<CallInvoker> jsInvoker)
  103. : TurboModule("SampleTurboCxxModule", jsInvoker) {
  104. methodMap_["voidFunc"] = MethodMetadata{
  105. 0, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_voidFunc};
  106. methodMap_["getBool"] = MethodMetadata{
  107. 1, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getBool};
  108. methodMap_["getNumber"] = MethodMetadata{
  109. 1, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getNumber};
  110. methodMap_["getString"] = MethodMetadata{
  111. 1, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getString};
  112. methodMap_["getArray"] = MethodMetadata{
  113. 1, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getArray};
  114. methodMap_["getObject"] = MethodMetadata{
  115. 1, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getObject};
  116. methodMap_["getValue"] = MethodMetadata{
  117. 3, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getValue};
  118. methodMap_["getValueWithCallback"] = MethodMetadata{
  119. 1, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getValueWithCallback};
  120. methodMap_["getValueWithPromise"] = MethodMetadata{
  121. 1, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getValueWithPromise};
  122. methodMap_["getConstants"] = MethodMetadata{
  123. 0, __hostFunction_NativeSampleTurboCxxModuleSpecJSI_getConstants};
  124. }
  125. } // namespace react
  126. } // namespace facebook