@ohos-ports/nbind 0.0.0-stage → 0.3.15-beta.1

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.
Files changed (92) hide show
  1. package/.editorconfig +7 -0
  2. package/LICENSE +22 -0
  3. package/README.md +1393 -2
  4. package/autogypi.json +11 -0
  5. package/bin/ci-trigger +40 -0
  6. package/bin/copyasm.js +77 -0
  7. package/bin/emcc +21 -0
  8. package/bin/emcc-path.js +7 -0
  9. package/bin/ndts.js +22 -0
  10. package/config.js +7 -0
  11. package/dist/Type.d.ts +92 -0
  12. package/dist/Type.js +180 -0
  13. package/dist/common.d.ts +9 -0
  14. package/dist/common.js +10 -0
  15. package/dist/em-api.js +2353 -0
  16. package/dist/int64.d.ts +9 -0
  17. package/dist/int64.js +64 -0
  18. package/dist/nbind.d.ts +49 -0
  19. package/dist/nbind.js +154 -0
  20. package/dist/reflect.d.ts +69 -0
  21. package/dist/reflect.js +261 -0
  22. package/dist/shim.d.ts +1 -0
  23. package/dist/shim.js +2 -0
  24. package/dist/todts.d.ts +5 -0
  25. package/dist/todts.js +146 -0
  26. package/include/nbind/ArgStorage.h +67 -0
  27. package/include/nbind/BindClass.h +290 -0
  28. package/include/nbind/BindDefiner.h +295 -0
  29. package/include/nbind/Buffer.h +50 -0
  30. package/include/nbind/FunctionDefiner.h +51 -0
  31. package/include/nbind/MethodDef.h +50 -0
  32. package/include/nbind/Policy.h +255 -0
  33. package/include/nbind/TypeID.h +84 -0
  34. package/include/nbind/TypeStd.h +66 -0
  35. package/include/nbind/TypeTransformer.h +38 -0
  36. package/include/nbind/api.h +100 -0
  37. package/include/nbind/common.h +22 -0
  38. package/include/nbind/em/ArgFromWire.h +31 -0
  39. package/include/nbind/em/BindingStd.h +221 -0
  40. package/include/nbind/em/BindingType.h +204 -0
  41. package/include/nbind/em/Buffer.h +37 -0
  42. package/include/nbind/em/Callback.h +186 -0
  43. package/include/nbind/em/Caller.h +61 -0
  44. package/include/nbind/em/Creator.h +30 -0
  45. package/include/nbind/em/External.h +63 -0
  46. package/include/nbind/em/Int64.h +131 -0
  47. package/include/nbind/em/NBind.h +63 -0
  48. package/include/nbind/em/Pool.h +34 -0
  49. package/include/nbind/em/StdFunction.h +40 -0
  50. package/include/nbind/em/ValueObj.h +54 -0
  51. package/include/nbind/nbind.h +19 -0
  52. package/include/nbind/noconflict.h +91 -0
  53. package/include/nbind/signature/BaseSignature.h +238 -0
  54. package/include/nbind/signature/CallbackSignature.h +59 -0
  55. package/include/nbind/signature/ConstructorSignature.h +76 -0
  56. package/include/nbind/signature/FunctionSignature.h +63 -0
  57. package/include/nbind/signature/GetterSignature.h +62 -0
  58. package/include/nbind/signature/MethodSignature.h +61 -0
  59. package/include/nbind/signature/SetterSignature.h +63 -0
  60. package/include/nbind/signature/SignatureParam.h +39 -0
  61. package/include/nbind/v8/ArgFromWire.h +69 -0
  62. package/include/nbind/v8/BindWrapper.h +295 -0
  63. package/include/nbind/v8/BindingStd.h +180 -0
  64. package/include/nbind/v8/BindingType.h +241 -0
  65. package/include/nbind/v8/Buffer.h +59 -0
  66. package/include/nbind/v8/Callback.h +165 -0
  67. package/include/nbind/v8/Caller.h +140 -0
  68. package/include/nbind/v8/Convert.h +80 -0
  69. package/include/nbind/v8/Creator.h +26 -0
  70. package/include/nbind/v8/External.h +119 -0
  71. package/include/nbind/v8/Int64.h +195 -0
  72. package/include/nbind/v8/NBind.h +63 -0
  73. package/include/nbind/v8/Output.h +36 -0
  74. package/include/nbind/v8/Overloader.h +215 -0
  75. package/include/nbind/v8/StdFunction.h +44 -0
  76. package/include/nbind/v8/ValueObj.h +137 -0
  77. package/include/nbind/wire.h +79 -0
  78. package/package.json +69 -4
  79. package/src/checkver.js +31 -0
  80. package/src/common.cc +129 -0
  81. package/src/em/Binding.cc +313 -0
  82. package/src/em/tsconfig.json +22 -0
  83. package/src/nbind-common.gypi +14 -0
  84. package/src/nbind.gypi +98 -0
  85. package/src/post.js +2 -0
  86. package/src/pre.js +48 -0
  87. package/src/reflect.cc +170 -0
  88. package/src/symbols.txt +1 -0
  89. package/src/tsconfig.json +23 -0
  90. package/src/tslint.json +86 -0
  91. package/src/v8/Binding.cc +391 -0
  92. package/src/v8/Buffer.cc +73 -0
@@ -0,0 +1,215 @@
1
+ // This file is part of nbind, copyright (C) 2014-2016 BusFaster Ltd.
2
+ // Released under the MIT license, see LICENSE.
3
+
4
+ /*
5
+ This should contain a vector of overloaded methods.
6
+ Each method is defined by a vector of method signatures.
7
+ The v8 engine is then given a pointer to the call function here and a reference number.
8
+ The most significant bits (>> overloadShift)
9
+ of the reference number contain an index to the vector of overloaded methods.
10
+ When a call is made to the overloader, the correct signature is found based on the number of arguments to the call.
11
+ The signature's caller is then called, and it extracts the correct method among those with an identical signature,
12
+ based on the least significant bits (& signatureMemberMask) of the reference number.
13
+ */
14
+
15
+
16
+
17
+ #pragma once
18
+
19
+ namespace nbind {
20
+
21
+ // It would be possible to add the bound C++ class as a template argument,
22
+ // allowing unlimited classes and a per-class instead of a global limit of overloaded methods,
23
+ // but that would compile to several completely identical duplicate copies of code.
24
+
25
+ class Overloader {
26
+
27
+ public:
28
+
29
+ typedef Nan::FunctionCallback jsMethod;
30
+ typedef void (*createValueHandler)(ArgStorage &storage, const Nan::FunctionCallbackInfo<v8::Value> &args);
31
+
32
+ struct OverloadDef {
33
+ std::vector<funcPtr> methodVect;
34
+
35
+ // Constructor called by JavaScript's "new" operator.
36
+ Nan::Callback *constructorJS = nullptr;
37
+
38
+ jsMethod wrapPtr = nullptr;
39
+ };
40
+
41
+ static void call(const Nan::FunctionCallbackInfo<v8::Value> &args) {
42
+ // Fetch overloads of the requested function.
43
+ OverloadDef &def = getDef(SignatureParam::get(args)->overloadNum);
44
+
45
+ unsigned int argc = args.Length();
46
+
47
+ // If the only argument is a pointer, assume we just want to wrap
48
+ // an already instantiated object.
49
+
50
+ if(argc == 2 && args[0]->IsExternal()) {
51
+ def.wrapPtr(args);
52
+ return;
53
+ }
54
+
55
+ std::vector<funcPtr> &methodVect = def.methodVect;
56
+ signed int maxArity = methodVect.size() - 1;
57
+
58
+ // Check that the method wasn't called with more than
59
+ // its maximum number of arguments.
60
+
61
+ if(signed(argc) <= maxArity) {
62
+ // Get caller for requested arity.
63
+ jsMethod specializedCall = reinterpret_cast<jsMethod>(methodVect[argc]);
64
+
65
+ if(specializedCall != nullptr) {
66
+ specializedCall(args);
67
+ return;
68
+ }
69
+ }
70
+
71
+ Nan::ThrowError("Wrong number of arguments");
72
+ }
73
+
74
+ static void callConstructor(const Nan::FunctionCallbackInfo<v8::Value> &args) {
75
+ Status::clearError();
76
+
77
+ // Call C++ constructor and bind the resulting object
78
+ // to the new JavaScript object being created.
79
+
80
+ try {
81
+ call(args);
82
+
83
+ const char *message = Status::getError();
84
+
85
+ if(message) {
86
+ Nan::ThrowError(message);
87
+ return;
88
+ }
89
+
90
+ args.GetReturnValue().Set(args.This());
91
+ } catch(const cbException &ex) {
92
+ // A JavaScript exception is already heading up the stack.
93
+ } catch(const std::exception &ex) {
94
+ const char *message = Status::getError();
95
+
96
+ if(message == nullptr) message = ex.what();
97
+
98
+ Nan::ThrowError(message);
99
+ }
100
+ }
101
+
102
+ static void callNew(const Nan::FunctionCallbackInfo<v8::Value> &args) {
103
+ OverloadDef &def = getDef(SignatureParam::get(args)->overloadNum);
104
+
105
+ unsigned int argc = args.Length();
106
+ std::vector<v8::Local<v8::Value>> argv(argc);
107
+
108
+ // Copy arguments to a vector because the arguments object type
109
+ // cannot be passed to another function call as-is.
110
+
111
+ for(unsigned int argNum = 0; argNum < argc; argNum++) {
112
+ argv[argNum] = args[argNum];
113
+ }
114
+
115
+ v8::Local<v8::Function> constructor = def.constructorJS->GetFunction();
116
+
117
+ // Call the JavaScript constructor with the new operator.
118
+ auto result = Nan::NewInstance(constructor, argc, (argc)?(&argv[0]):(nullptr));
119
+
120
+ if(result.IsEmpty()) args.GetReturnValue().Set(Nan::Undefined());
121
+ else args.GetReturnValue().Set(result.ToLocalChecked());
122
+ }
123
+
124
+ static void create(const Nan::FunctionCallbackInfo<v8::Value> &args) {
125
+ if(args.IsConstructCall()) {
126
+ // Constructor was called like new Bound(...)
127
+ callConstructor(args);
128
+ } else {
129
+ // Constructor was called like Bound(...), add the "new" operator.
130
+ callNew(args);
131
+ }
132
+ }
133
+
134
+ static void createValue(const Nan::FunctionCallbackInfo<v8::Value> &args) {
135
+ ArgStorage &storage = *static_cast<ArgStorage *>(Nan::GetInternalFieldPointer(args.Holder(), 0));
136
+ static std::vector<OverloadDef> &overloadVect = overloadVectStore();
137
+ OverloadDef &def = overloadVect[storage.getOverloadNum()];
138
+
139
+ std::vector<funcPtr> &methodVect = def.methodVect;
140
+ unsigned int argc = args.Length();
141
+ signed int maxArity = methodVect.size() - 1;
142
+
143
+ // Check if method was called with more than the maximum number
144
+ // of arguments it can accept.
145
+ if(signed(argc) <= maxArity) {
146
+ auto specializedCall = reinterpret_cast<createValueHandler>(methodVect[argc]);
147
+
148
+ if(specializedCall != nullptr) {
149
+ specializedCall(storage, args);
150
+ args.GetReturnValue().Set(Nan::Undefined());
151
+ return;
152
+ }
153
+ }
154
+
155
+ // Can't use throw here because there's V8 code
156
+ // (lacking C++ exception support) on the stack
157
+ // above the catch statement.
158
+
159
+ NBIND_ERR("Wrong number of arguments in value binding");
160
+ args.GetReturnValue().Set(Nan::Undefined());
161
+ }
162
+
163
+ static unsigned int addGroup() {
164
+ std::vector<OverloadDef> &overloadVect = overloadVectStore();
165
+ unsigned int num = overloadVect.size();
166
+
167
+ // Add a new group of overloaded methods.
168
+ overloadVect.resize(num + 1);
169
+
170
+ return(num);
171
+ }
172
+
173
+ static void addMethod(unsigned int num, unsigned int arity, funcPtr method) {
174
+ OverloadDef &def = getDef(num);
175
+
176
+ // Get methods in overloaded group.
177
+ std::vector<funcPtr> &methodVect = def.methodVect;
178
+
179
+ signed int oldArity = methodVect.size() - 1;
180
+
181
+ // Grow list of methods if new arity doesn't fit.
182
+ if(signed(arity) > oldArity) methodVect.resize(arity + 1);
183
+
184
+ methodVect[arity] = method;
185
+ }
186
+
187
+ static void setConstructorJS(unsigned int num, v8::Local<v8::Function> func) {
188
+ OverloadDef &def = getDef(num);
189
+
190
+ if(def.constructorJS == nullptr) {
191
+ def.constructorJS = new Nan::Callback(func);
192
+ } else {
193
+ def.constructorJS->SetFunction(func);
194
+ }
195
+ }
196
+
197
+ static void setPtrWrapper(unsigned int num, jsMethod wrapPtr) {
198
+ getDef(num).wrapPtr = wrapPtr;
199
+ }
200
+
201
+ static inline OverloadDef &getDef(unsigned int num) {
202
+ return(overloadVectStore()[num]);
203
+ }
204
+
205
+ // Linkage for a table of overloaded methods
206
+ // (overloads must have different arities).
207
+
208
+ static std::vector<OverloadDef> &overloadVectStore() {
209
+ static std::vector<OverloadDef> overloadVect;
210
+ return(overloadVect);
211
+ }
212
+
213
+ };
214
+
215
+ } // namespace
@@ -0,0 +1,44 @@
1
+ // This file is part of nbind, copyright (C) 2016 BusFaster Ltd.
2
+ // Released under the MIT license, see LICENSE.
3
+
4
+ // This file handles type conversion of C++ standard library types
5
+ // to / from JavaScript.
6
+
7
+ #pragma once
8
+
9
+ #include <functional>
10
+
11
+ namespace nbind {
12
+
13
+ #define NBIND_DEFINE_CALLBACK_TYPE(ArgType) \
14
+ template <typename ReturnType, typename... Args> \
15
+ struct BindingType<ArgType> { \
16
+ \
17
+ typedef ArgType Type; \
18
+ \
19
+ static inline bool checkType(WireType arg) { \
20
+ return(arg->IsFunction()); \
21
+ } \
22
+ \
23
+ }; \
24
+ \
25
+ template<typename PolicyList, size_t Index, typename ReturnType, typename... Args> \
26
+ struct ArgFromWire<PolicyList, Index, ArgType> { \
27
+ \
28
+ template <typename NanArgs> \
29
+ ArgFromWire(const NanArgs &args) : val(cbWrapper<ReturnType>(args[Index].template As<v8::Function>())) {} \
30
+ \
31
+ template <typename NanArgs> \
32
+ inline ArgType get(const NanArgs &args) { \
33
+ return(val); \
34
+ } \
35
+ \
36
+ std::function<ReturnType (Args...)> val; \
37
+ \
38
+ }
39
+
40
+ NBIND_DEFINE_CALLBACK_TYPE(std::function<ReturnType (Args...)>);
41
+ NBIND_DEFINE_CALLBACK_TYPE(std::function<ReturnType (Args...)> &);
42
+ NBIND_DEFINE_CALLBACK_TYPE(std::function<ReturnType (Args...)> const &);
43
+
44
+ } // namespace
@@ -0,0 +1,137 @@
1
+ // This file is part of nbind, copyright (C) 2014-2015 BusFaster Ltd.
2
+ // Released under the MIT license, see LICENSE.
3
+
4
+ // This file handles value objects, which are represented by equivalent C++ and
5
+ // JavaScript classes, with toJS and fromJS methods calling each others'
6
+ // constructors to marshal the class between languages and providing a similar
7
+ // API in both.
8
+
9
+ #pragma once
10
+
11
+ namespace nbind {
12
+
13
+ template <typename BaseType, typename ArgType>
14
+ struct ExternalPtr;
15
+
16
+ template <typename BaseType, typename ArgType>
17
+ struct ExternalPtr<BaseType, ArgType *> {
18
+ static void *make(ArgType *arg) {
19
+ return(const_cast<BaseType *>(arg));
20
+ }
21
+ };
22
+
23
+ template <typename BaseType, typename ArgType>
24
+ struct ExternalPtr<BaseType, std::shared_ptr<ArgType>> {
25
+ static void *make(std::shared_ptr<ArgType> &&ptr) {
26
+ return(new std::shared_ptr<ArgType>(std::move(ptr)));
27
+ }
28
+ };
29
+
30
+ template <typename BaseType, typename ArgType>
31
+ struct ExternalPtr<BaseType, std::unique_ptr<ArgType>> {
32
+ static void *make(std::shared_ptr<ArgType> &&ptr) {
33
+ return(new std::shared_ptr<ArgType>(std::move(ptr)));
34
+ }
35
+ };
36
+
37
+ template <typename BaseType, typename TargetType, typename ArgType>
38
+ static inline WireType makeExternal(TypeFlags flags, TargetType *ptr, ArgType &&arg) {
39
+ if(std::is_const<TargetType>::value) flags = flags | TypeFlags::isConst;
40
+
41
+ #ifndef NBIND_DUPLICATE_POINTERS
42
+
43
+ auto ref = BindWrapper<BaseType>::findInstance(ptr, flags);
44
+
45
+ if(!ref->IsEmpty()) {
46
+ return(Nan::New<v8::Object>(*ref));
47
+ }
48
+
49
+ #endif // NBIND_DUPLICATE_POINTERS
50
+
51
+ unsigned int constructorNum = BindClass<BaseType>::getInstance().wrapperConstructorNum;
52
+ Nan::Callback *constructorJS = Overloader::getDef(constructorNum).constructorJS;
53
+
54
+ if(constructorJS == nullptr) {
55
+ Nan::ThrowError("Unbound type");
56
+ return(Nan::Undefined());
57
+ }
58
+
59
+ v8::Local<v8::Function> constructor = constructorJS->GetFunction();
60
+
61
+ // TODO: first argument should be a unique marker of some kind.
62
+
63
+ const unsigned int argc = 2;
64
+ v8::Local<v8::Value> argv[] = {
65
+ Nan::New<v8::External>(ExternalPtr<BaseType, ArgType>::make(std::move(arg))),
66
+ Nan::New<v8::Uint32>(static_cast<uint32_t>(flags))
67
+ };
68
+
69
+ // This will try to call the C++ constructor, so Overloader or Creator
70
+ // needs to detect the argument is a v8::External and just wrap it instead.
71
+
72
+ return(Nan::NewInstance(constructor, argc, argv).ToLocalChecked());
73
+ }
74
+
75
+ template <typename ArgType>
76
+ inline WireType BindingType<ArgType *>::toWireType(ArgType *arg) {
77
+ if(arg == nullptr) return(Nan::Null());
78
+
79
+ return(makeExternal<BaseType>(TypeFlags::none, arg, std::move(arg)));
80
+ }
81
+
82
+ template <typename ArgType>
83
+ inline WireType BindingType<std::shared_ptr<ArgType>>::toWireType(
84
+ std::shared_ptr<ArgType> &&arg
85
+ ) {
86
+ if(arg == nullptr || !arg.use_count()) return(Nan::Null());
87
+
88
+ return(makeExternal<BaseType>(TypeFlags::isSharedPtr, arg.get(), std::move(arg)));
89
+ }
90
+
91
+ template <typename ArgType>
92
+ inline WireType BindingType<std::unique_ptr<ArgType>>::toWireType(
93
+ std::unique_ptr<ArgType> &&arg
94
+ ) {
95
+ if(arg == nullptr) return(Nan::Null());
96
+
97
+ return(makeExternal<BaseType>(TypeFlags::isSharedPtr, arg.get(), std::move(arg)));
98
+ }
99
+
100
+ // Allow passing internal wrapped value object storage pointers.
101
+
102
+ template <> struct BindingType<v8::Local<v8::Object>> {
103
+
104
+ typedef v8::Local<v8::Object> Type;
105
+
106
+ static inline WireType toWireType(v8::Local<v8::Object> arg) {
107
+ return(arg);
108
+ }
109
+
110
+ };
111
+
112
+ template <typename ArgType>
113
+ inline ArgType BindingType<ValueType<ArgType>>::fromWireType(WireType arg) noexcept(false) {
114
+ auto target = Nan::To<v8::Object>(arg).ToLocalChecked();
115
+ auto fromJS = Nan::Get(target, Nan::New<v8::String>("fromJS").ToLocalChecked()).ToLocalChecked();
116
+
117
+ if(!fromJS->IsFunction()) throw(std::runtime_error("Type mismatch"));
118
+
119
+ BindClassBase &bindClass = BindClass<ArgType>::getInstance();
120
+
121
+ TemplatedArgStorage<ArgType> storage(bindClass.valueConstructorNum);
122
+
123
+ auto instance = Nan::NewInstance(Nan::New(bindClass.storageTemplate)).ToLocalChecked();
124
+ // Data specifically for createValue function.
125
+ Nan::SetInternalFieldPointer(instance, 0, &storage);
126
+
127
+ // TODO: cache this for a speedup.
128
+ cbFunction converter(v8::Local<v8::Function>::Cast(fromJS));
129
+ converter.callMethod<void>(target, instance);
130
+
131
+ const char *message = Status::getError();
132
+ if(message) throw(std::runtime_error(message));
133
+
134
+ return(storage.getBound());
135
+ }
136
+
137
+ } // namespace
@@ -0,0 +1,79 @@
1
+ /*
2
+ Copyright (c) 2010-2014 Emscripten authors, see EMSCRIPTEN-AUTHORS file.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+ */
22
+
23
+ #pragma once
24
+
25
+ namespace emscripten {
26
+ namespace internal {
27
+
28
+ // TypeList<>
29
+
30
+ template<typename...>
31
+ struct TypeList {};
32
+
33
+ // Cons :: T, TypeList<types...> -> Cons<T, types...>
34
+
35
+ template<typename First, typename TypeList>
36
+ struct Cons;
37
+
38
+ template<typename First, typename... Rest>
39
+ struct Cons<First, TypeList<Rest...>> {
40
+ typedef TypeList<First, Rest...> type;
41
+ };
42
+
43
+ // Apply :: T, TypeList<types...> -> T<types...>
44
+
45
+ template<template<typename...> class Output, typename TypeList>
46
+ struct Apply;
47
+
48
+ template<template<typename...> class Output, typename... Types>
49
+ struct Apply<Output, TypeList<Types...>> {
50
+ typedef Output<Types...> type;
51
+ };
52
+
53
+ // MapWithIndex_
54
+
55
+ template<typename PolicyList, template<typename, size_t, typename> class Mapper, size_t CurrentIndex, typename... Args>
56
+ struct MapWithIndex_;
57
+
58
+ template<typename PolicyList, template<typename, size_t, typename> class Mapper, size_t CurrentIndex, typename First, typename... Rest>
59
+ struct MapWithIndex_<PolicyList, Mapper, CurrentIndex, First, Rest...> {
60
+ typedef typename Cons<
61
+ Mapper<PolicyList, CurrentIndex, First>,
62
+ typename MapWithIndex_<PolicyList, Mapper, CurrentIndex + 1, Rest...>::type
63
+ >::type type;
64
+ };
65
+
66
+ template<typename PolicyList, template<typename, size_t, typename> class Mapper, size_t CurrentIndex>
67
+ struct MapWithIndex_<PolicyList, Mapper, CurrentIndex> {
68
+ typedef TypeList<> type;
69
+ };
70
+
71
+ template<typename PolicyList, template<typename...> class Output, template<typename, size_t, typename> class Mapper, typename... Args>
72
+ struct MapWithIndex {
73
+ typedef typename internal::Apply<
74
+ Output,
75
+ typename MapWithIndex_<PolicyList, Mapper, 0, Args...>::type
76
+ >::type type;
77
+ };
78
+ }
79
+ }
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@ohos-ports/nbind",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.15-beta.1",
4
+ "description": "Magical headers that make your C++ library accessible from JavaScript",
5
+ "main": "dist/nbind.js",
6
+ "typings": "dist/nbind.d.ts",
7
+ "bin": {
8
+ "copyasm": "bin/copyasm.js",
9
+ "emcc-path": "bin/emcc-path.js",
10
+ "ndts": "bin/ndts.js"
11
+ },
12
+ "scripts": {
13
+ "autogypi": "autogypi",
14
+ "node-gyp": "node-gyp",
15
+ "emcc-path": "node bin/emcc-path.js",
16
+ "copyasm": "copyasm",
17
+ "tsc": "tsc",
18
+ "tslint": "tslint",
19
+ "cbuild": "cbuild",
20
+ "dump-lib": "dump-em-lib dist/em-api.js",
21
+ "lint": "node src/checkver.js lt 4.1.2 || (tslint --type-check -c src/tslint.json -p src/tsconfig.json && tslint --type-check -c src/tslint.json -p src/em/tsconfig.json)",
22
+ "prepublish": "npm run lint && tsc -p src/em && tsc -p src && (node src/checkver.js lt 0.12.0 || cbuild -x -v -s dist/bundle/em/em-api.js -o dist/em-api.js)",
23
+ "clean-asm": "cd test/em && node-gyp clean",
24
+ "config-test": "autogypi -c test/autogypi.json",
25
+ "test-asm": "npm run config-test && cd test/em && node-gyp configure build --asmjs=1 && node ../../bin/ndts --no-shim . > ../testlib.d.ts && tsc -p .. && tap ../test.js",
26
+ "test": "npm run config-test && cd test/v8 && node-gyp configure build && node ../../bin/ndts --no-shim . > ../testlib.d.ts && tsc -p .. && tap ../test.js --gc && tap ../test-v8.js"
27
+ },
28
+ "author": "Juha Järvi",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/ohos-ports/ohos-ports.git",
33
+ "directory": "ports/nbind/0.3.15"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/ohos-ports/ohos-ports/issues"
37
+ },
38
+ "homepage": "https://github.com/ohos-ports/ohos-ports/tree/main/ports/nbind/0.3.15",
39
+ "keywords": [
40
+ "asm.js",
41
+ "bindings",
42
+ "build",
43
+ "c++",
44
+ "electron",
45
+ "emscripten",
46
+ "nan",
47
+ "native",
48
+ "node-gyp"
49
+ ],
50
+ "os": [
51
+ "android",
52
+ "darwin",
53
+ "linux",
54
+ "openharmony",
55
+ "win32"
56
+ ],
57
+ "dependencies": {
58
+ "emscripten-library-decorator": "~0.2.2",
59
+ "mkdirp": "~0.5.1",
60
+ "nan": "^2.9.2"
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^8.0.51",
64
+ "autogypi": "~0.2.2",
65
+ "cbuild": "~0.1.8",
66
+ "node-gyp": "^3.6.2",
67
+ "tap": "^10.7.3",
68
+ "tslint": "^5.9.1",
69
+ "typescript": "~2.3.4"
70
+ }
71
+ }
@@ -0,0 +1,31 @@
1
+
2
+ var op = process.argv[2].match(/^([gl])([te])$/);
3
+ var wanted = (process.argv[3] || '').split('.');
4
+ var version = process.versions.node.split('.');
5
+
6
+ if(!op || wanted.length != 3) {
7
+ console.log([
8
+ 'usage:',
9
+ process.argv[0].replace(/.*\//, ''),
10
+ process.argv[1].replace(/.*\//, ''),
11
+ 'op',
12
+ 'x.y.z'
13
+ ].join(' '));
14
+
15
+ console.log('\nCompare Node.js version.');
16
+ console.log('Following op codes determine whether it must be:\n');
17
+
18
+ console.log('\tgt\tGreater than x.y.z.');
19
+ console.log('\tge\tGreater than or equal to x.y.z.');
20
+ console.log('\tlt\tLess than x.y.z.');
21
+ console.log('\tle\tLess than or equal to x.y.z.');
22
+
23
+ process.exit(1);
24
+ }
25
+
26
+ for(var i = 0; i < 3; ++i) {
27
+ if(+version[i] > +wanted[i]) process.exit(+(op[1] != 'g'));
28
+ if(+version[i] < +wanted[i]) process.exit(+(op[1] == 'g'));
29
+ }
30
+
31
+ process.exit(+(op[2] != 'e'));