| 172 | #endif // NAPI_VERSION > 5 |
| 173 | |
| 174 | static Napi::Object Init(Napi::Env env, Napi::Object exports) { |
| 175 | napi_value no_arg_function, one_arg_function, two_arg_function, |
| 176 | three_arg_function, four_arg_function; |
| 177 | napi_status status; |
| 178 | |
| 179 | status = napi_create_function(env, |
| 180 | "noArgFunction", |
| 181 | NAPI_AUTO_LENGTH, |
| 182 | NoArgFunction_Core, |
| 183 | nullptr, |
| 184 | &no_arg_function); |
| 185 | NAPI_THROW_IF_FAILED(env, status, Napi::Object()); |
| 186 | |
| 187 | status = napi_create_function(env, |
| 188 | "oneArgFunction", |
| 189 | NAPI_AUTO_LENGTH, |
| 190 | OneArgFunction_Core, |
| 191 | nullptr, |
| 192 | &one_arg_function); |
| 193 | NAPI_THROW_IF_FAILED(env, status, Napi::Object()); |
| 194 | |
| 195 | status = napi_create_function(env, |
| 196 | "twoArgFunction", |
| 197 | NAPI_AUTO_LENGTH, |
| 198 | TwoArgFunction_Core, |
| 199 | nullptr, |
| 200 | &two_arg_function); |
| 201 | NAPI_THROW_IF_FAILED(env, status, Napi::Object()); |
| 202 | |
| 203 | status = napi_create_function(env, |
| 204 | "threeArgFunction", |
| 205 | NAPI_AUTO_LENGTH, |
| 206 | ThreeArgFunction_Core, |
| 207 | nullptr, |
| 208 | &three_arg_function); |
| 209 | NAPI_THROW_IF_FAILED(env, status, Napi::Object()); |
| 210 | |
| 211 | status = napi_create_function(env, |
| 212 | "fourArgFunction", |
| 213 | NAPI_AUTO_LENGTH, |
| 214 | FourArgFunction_Core, |
| 215 | nullptr, |
| 216 | &four_arg_function); |
| 217 | NAPI_THROW_IF_FAILED(env, status, Napi::Object()); |
| 218 | |
| 219 | Napi::Object core = Napi::Object::New(env); |
| 220 | core["noArgFunction"] = Napi::Value(env, no_arg_function); |
| 221 | core["oneArgFunction"] = Napi::Value(env, one_arg_function); |
| 222 | core["twoArgFunction"] = Napi::Value(env, two_arg_function); |
| 223 | core["threeArgFunction"] = Napi::Value(env, three_arg_function); |
| 224 | core["fourArgFunction"] = Napi::Value(env, four_arg_function); |
| 225 | exports["core"] = core; |
| 226 | |
| 227 | Napi::Object cplusplus = Napi::Object::New(env); |
| 228 | cplusplus["noArgFunction"] = Napi::Function::New(env, NoArgFunction); |
| 229 | cplusplus["oneArgFunction"] = Napi::Function::New(env, OneArgFunction); |
| 230 | cplusplus["twoArgFunction"] = Napi::Function::New(env, TwoArgFunction); |
| 231 | cplusplus["threeArgFunction"] = Napi::Function::New(env, ThreeArgFunction); |