@crossbind/core-embind-jsi 2.0.0-beta.60 → 2.0.0-beta.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +76 -0
- package/README.md +1 -1
- package/cpp/src/crossbind/direct_reads.h +30 -0
- package/cpp/src/emscripten/bind.cpp +133 -175
- package/cpp/src/emscripten/bind.h +57 -77
- package/cpp/src/emscripten/val.h +57 -146
- package/cpp/src/emscripten/wire.h +169 -47
- package/js/embind.js +128 -774
- package/package.json +9 -1
package/LICENSE
CHANGED
|
@@ -19,3 +19,79 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
==============================================================================
|
|
24
|
+
|
|
25
|
+
The embind sources in cpp/src/emscripten and js/embind.js are adapted from
|
|
26
|
+
Emscripten (https://github.com/emscripten-core/emscripten), whose license
|
|
27
|
+
follows. The notes on Node.js, musl and third_party/ that end the original file
|
|
28
|
+
concern parts of Emscripten this package does not include.
|
|
29
|
+
|
|
30
|
+
Emscripten is available under 2 licenses, the MIT license and the
|
|
31
|
+
University of Illinois/NCSA Open Source License.
|
|
32
|
+
|
|
33
|
+
Both are permissive open source licenses, with little if any
|
|
34
|
+
practical difference between them.
|
|
35
|
+
|
|
36
|
+
The reason for offering both is that (1) the MIT license is
|
|
37
|
+
well-known, while (2) the University of Illinois/NCSA Open Source
|
|
38
|
+
License allows Emscripten's code to be integrated upstream into
|
|
39
|
+
LLVM, which uses that license, should the opportunity arise.
|
|
40
|
+
|
|
41
|
+
The full text of both licenses follows.
|
|
42
|
+
|
|
43
|
+
==============================================================================
|
|
44
|
+
|
|
45
|
+
Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
|
|
46
|
+
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
48
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
49
|
+
in the Software without restriction, including without limitation the rights
|
|
50
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
51
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
52
|
+
furnished to do so, subject to the following conditions:
|
|
53
|
+
|
|
54
|
+
The above copyright notice and this permission notice shall be included in
|
|
55
|
+
all copies or substantial portions of the Software.
|
|
56
|
+
|
|
57
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
58
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
59
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
60
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
61
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
62
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
63
|
+
THE SOFTWARE.
|
|
64
|
+
|
|
65
|
+
==============================================================================
|
|
66
|
+
|
|
67
|
+
Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
|
|
68
|
+
All rights reserved.
|
|
69
|
+
|
|
70
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
71
|
+
copy of this software and associated documentation files (the
|
|
72
|
+
"Software"), to deal with the Software without restriction, including
|
|
73
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
74
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
75
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
76
|
+
the following conditions:
|
|
77
|
+
|
|
78
|
+
Redistributions of source code must retain the above copyright
|
|
79
|
+
notice, this list of conditions and the following disclaimers.
|
|
80
|
+
|
|
81
|
+
Redistributions in binary form must reproduce the above
|
|
82
|
+
copyright notice, this list of conditions and the following disclaimers
|
|
83
|
+
in the documentation and/or other materials provided with the
|
|
84
|
+
distribution.
|
|
85
|
+
|
|
86
|
+
Neither the names of Mozilla,
|
|
87
|
+
nor the names of its contributors may be used to endorse
|
|
88
|
+
or promote products derived from this Software without specific prior
|
|
89
|
+
written permission.
|
|
90
|
+
|
|
91
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
92
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
93
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
94
|
+
IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
95
|
+
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
96
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
97
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The Embind JSI integration tool enables seamless C++ integration with React Native and Expo.
|
|
4
4
|
|
|
5
5
|
<a href="https://www.npmjs.com/package/@crossbind/core-embind-jsi">
|
|
6
|
-
<img alt="NPM version" src="https://img.shields.io/npm/v/@crossbind/core-embind-jsi?style=for-the-badge" />
|
|
6
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@crossbind/core-embind-jsi/beta?style=for-the-badge" />
|
|
7
7
|
</a>
|
|
8
8
|
<a href="https://github.com/crossbind/crossbind/blob/main/LICENSE">
|
|
9
9
|
<img alt="License" src="https://img.shields.io/github/license/crossbind/crossbind?style=for-the-badge" />
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// An optional JSI runtime interface: reads an argument's contents straight from the engine value,
|
|
2
|
+
// without reading a typed array's buffer, byteOffset and length or cloning a BigInt first. The
|
|
3
|
+
// Node-API runtime implements it; a runtime that does not (Hermes) answers castInterface with null,
|
|
4
|
+
// and callers take the JSI path.
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <jsi/jsi.h>
|
|
8
|
+
#include <cstddef>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
|
|
11
|
+
namespace crossbind {
|
|
12
|
+
|
|
13
|
+
struct IDirectReads : facebook::jsi::ICast {
|
|
14
|
+
static constexpr facebook::jsi::UUID uuid{0xdf916ba1, 0xbbee, 0x46ac, 0x9251, 0xf0fcdcdb3697};
|
|
15
|
+
|
|
16
|
+
// False when `value` is not a typed array; `length` counts elements, not bytes.
|
|
17
|
+
virtual bool typedArrayElements(const facebook::jsi::Value& value, void*& data, size_t& length) = 0;
|
|
18
|
+
|
|
19
|
+
// False when `value` is not a BigInt. `bits` are its low 64 bits, as jsi::BigInt::getUint64
|
|
20
|
+
// gives; `lossless` says whether it fits, which jsi::BigInt::asUint64 requires.
|
|
21
|
+
virtual bool bigIntToUint64(const facebook::jsi::Value& value, uint64_t& bits, bool& lossless) = 0;
|
|
22
|
+
|
|
23
|
+
// The same for int64_t, as jsi::BigInt::getInt64 and asInt64 read it.
|
|
24
|
+
virtual bool bigIntToInt64(const facebook::jsi::Value& value, int64_t& bits, bool& lossless) = 0;
|
|
25
|
+
|
|
26
|
+
protected:
|
|
27
|
+
~IDirectReads() = default;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
}
|