-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmyprint.cpp
34 lines (29 loc) · 858 Bytes
/
myprint.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* This is free and unencumbered software released into the public domain.
* For more information, please refer to the LICENSE file in the root directory
* or at <http://unlicense.org/>
*/
#include "registerNatives.h"
#include <iostream>
using namespace facebook;
/// Print all arguments separated by spaces.
static jsi::Value hostMyPrint(
jsi::Runtime &rt,
const jsi::Value &,
const jsi::Value *args,
size_t count) {
for (size_t i = 0; i < count; ++i) {
if (i)
std::cout << ' ';
std::cout << args[i].toString(rt).utf8(rt);
}
std::cout << std::endl;
return jsi::Value::undefined();
}
extern "C" void registerNatives(jsi::Runtime &rt) {
rt.global().setProperty(
rt,
"myPrint",
jsi::Function::createFromHostFunction(
rt, jsi::PropNameID::forAscii(rt, "print"), 0, hostMyPrint));
}