Skip to content

Add base for NodeJS async implementation and MetaCall support for Futures. #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e792b7c
Add base for NodeJS async implementation and MetaCall support.
viferga Aug 19, 2019
36762a7
Add portability lib, add future type in reflect, refactored async sig…
viferga Aug 20, 2019
cab0b69
Minor bugs solved from previous commit.
viferga Aug 20, 2019
6751453
Minor changes in tests for future implementation.
viferga Aug 20, 2019
802f96f
Merge branch 'develop' into feature/nodejs_async
viferga Aug 20, 2019
9bebb3c
Serial test working properly with futures.
viferga Aug 20, 2019
da318d6
Create async functions and future implementation in reflect, add base…
viferga Aug 21, 2019
6d4851c
Merge branch 'develop' into feature/nodejs_async
viferga Aug 21, 2019
6decb85
Merge branch 'develop' into feature/nodejs_async
viferga Aug 21, 2019
15f4418
Trying a more simple promise.
viferga Aug 21, 2019
d700903
Update version of NodeJS to 10.16.3, add version detection for thread…
viferga Aug 21, 2019
6442984
Merge branch 'develop' into feature/nodejs_async
viferga Aug 22, 2019
073788c
Add boostrap debugging in test for node loader.
viferga Aug 22, 2019
f5804ed
Add promise return and print in the test, to check if it works.
viferga Aug 22, 2019
b333ebd
Add destruction of the future to avoid any memory leak.
viferga Aug 22, 2019
af45cc7
Add inspect for function in node async test.
viferga Aug 22, 2019
59a66e8
Minor changes done to register method in the test call.
viferga Aug 27, 2019
66cca0d
Await resolve working properly.
viferga Aug 27, 2019
2465529
Add base for trampoline implementation.
viferga Aug 27, 2019
0faba4a
Improve msvc trampoline prject, test and trampoline itself.
viferga Aug 28, 2019
c898813
Solve minor bug in serial test.
viferga Aug 28, 2019
8c4f79c
Solve minor bugs in trampoline and add debug info for bootstrap.
viferga Aug 28, 2019
88a9080
Minor changes in trampoline and node loader doc.
viferga Aug 28, 2019
d9a28f8
Almost done with the trampoline callback to C.
viferga Aug 28, 2019
b150db2
Passing node loader to callback trampoline in node loader.
viferga Aug 28, 2019
590521b
Solve bug in trampoline callback heap, and add test for rejection.
viferga Aug 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ set(MODULE_NAMES
environment
format
log
memory
memory
portability
adt
reflect
dynlink
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ This section describes all programming languages that **METACALL** supports, if
| Language | Runtime | Version | Tag |
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------|:------------------------------:|:----:|
| [Python](https://www.python.org/) | [Python C API](https://docs.python.org/3/c-api/intro.html) | **>= 3.2 <= 3.7** | py |
| [NodeJS](https://nodejs.org/) | [N API](https://nodejs.org/api/n-api.html) | **>= 8.11.1 <= 10.15.3** | node |
| [NodeJS](https://nodejs.org/) | [N API](https://nodejs.org/api/n-api.html) | **>= 8.11.1 <= 10.16.3** | node |
| [JavaScript](https://developer.mozilla.org/bm/docs/Web/JavaScript) | [V8](https://v8.dev/) | **5.1.117** | js |
| [C#](https://dotnet.microsoft.com/) | [NetCore](https://github.com/dotnet/docs/blob/master/docs/core/tutorials/netcore-hosting.md) | **>= 1.0.0-preview2 <= 2.2.6** | cs |
| [Ruby](https://ruby-lang.org/) | [Ruby C API](https://silverhammermba.github.io/emberb/c/) | **>= 2.1 <= 2.3** | rb |
Expand Down
2 changes: 2 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ add_definitions(
-DSERIAL_LIBRARY_INSTALL_PATH=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_SHARED}\"
-DLOADER_LIBRARY_INSTALL_PATH=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_SHARED}\"
-DDETOUR_LIBRARY_INSTALL_PATH=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_SHARED}\"
-DPORT_LIBRARY_INSTALL_PATH=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_SHARED}\"
)

#
Expand All @@ -96,6 +97,7 @@ add_subdirectory(environment)
add_subdirectory(format)
add_subdirectory(log)
add_subdirectory(memory)
add_subdirectory(portability)
add_subdirectory(adt)
add_subdirectory(filesystem)
add_subdirectory(dynlink)
Expand Down
3 changes: 2 additions & 1 deletion source/benchmarks/metacall_py_call_bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ target_link_libraries(${target}
${META_PROJECT_NAME}::environment
${META_PROJECT_NAME}::format
${META_PROJECT_NAME}::log
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::portability
${META_PROJECT_NAME}::adt
${META_PROJECT_NAME}::reflect
${META_PROJECT_NAME}::dynlink
Expand Down
3 changes: 2 additions & 1 deletion source/benchmarks/metacall_py_init_bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ target_link_libraries(${target}
${META_PROJECT_NAME}::environment
${META_PROJECT_NAME}::format
${META_PROJECT_NAME}::log
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::portability
${META_PROJECT_NAME}::adt
${META_PROJECT_NAME}::reflect
${META_PROJECT_NAME}::dynlink
Expand Down
3 changes: 2 additions & 1 deletion source/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ target_link_libraries(${target}
${META_PROJECT_NAME}::environment
${META_PROJECT_NAME}::format
${META_PROJECT_NAME}::log
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::portability
${META_PROJECT_NAME}::adt
${META_PROJECT_NAME}::reflect
${META_PROJECT_NAME}::dynlink
Expand Down
1 change: 1 addition & 0 deletions source/detour/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ target_link_libraries(${target}
${META_PROJECT_NAME}::format
${META_PROJECT_NAME}::log
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::portability
${META_PROJECT_NAME}::adt
${META_PROJECT_NAME}::dynlink

Expand Down
1 change: 1 addition & 0 deletions source/detours/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(DETOUR_MODULE_NAMES
format
log
memory
portability
adt
dynlink
detour
Expand Down
3 changes: 2 additions & 1 deletion source/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ target_link_libraries(${target}
${META_PROJECT_NAME}::environment
${META_PROJECT_NAME}::format
${META_PROJECT_NAME}::log
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::memory
${META_PROJECT_NAME}::portability
${META_PROJECT_NAME}::adt
${META_PROJECT_NAME}::reflect
${META_PROJECT_NAME}::dynlink
Expand Down
1 change: 1 addition & 0 deletions source/loaders/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(LOADER_MODULE_NAMES
format
log
memory
portability
adt
filesystem
reflect
Expand Down
2 changes: 1 addition & 1 deletion source/loaders/node_loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif()
# External dependencies
#

find_package(NodeJS 10.15.3)
find_package(NodeJS 10.16.3)

if(NOT NODEJS_FOUND)
message(STATUS "NodeJS libraries not found")
Expand Down
30 changes: 29 additions & 1 deletion source/loaders/node_loader/bootstrap/lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const trampoline = require('./trampoline.node');

const Module = require('module');
const path = require('path');
const util = require('util');

const cherow = require('./node_modules/cherow');

Expand Down Expand Up @@ -197,8 +198,34 @@ function node_loader_trampoline_discover(handle) {
return discover;
}

function node_loader_trampoline_test() {
function node_loader_trampoline_test(obj) {
console.log('NodeJS Loader Bootstrap Test');

if (obj !== undefined) {
console.log(util.inspect(obj, false, null, true));
}
}

function node_loader_trampoline_await(promise, trampoline_ptr) {
if (!(promise && promise.then && typeof promise.then === 'function')) {
throw new Error('Await only accepts a then-able object as promise');
}

if (typeof trampoline_ptr !== 'object') {
throw new Error('Await trampoline_ptr must be an object, not ' + typeof trampoline_ptr);
}

return new Promise((resolve, reject) => {
setTimeout(() => {
promise.then((x) => {
console.log(`Resolve: ${x}`);
resolve(trampoline.resolve(trampoline_ptr, x));
}, (x) => {
console.log(`Reject: ${x}`);
reject(trampoline.reject(trampoline_ptr, x));
});
}, 0);
});
}

function node_loader_trampoline_destroy() {
Expand Down Expand Up @@ -233,6 +260,7 @@ module.exports = ((impl, ptr) => {
'clear': node_loader_trampoline_clear,
'discover': node_loader_trampoline_discover,
'test': node_loader_trampoline_test,
'await': node_loader_trampoline_await,
'destroy': node_loader_trampoline_destroy,
});
})(process.argv[2], process.argv[3]);
Loading