Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
8922bba
deps: update npm to 5.5.1
MylesBorins Oct 27, 2017
0ea8ff3
deps: backport 4ca695819 from npm upstream
MylesBorins Oct 27, 2017
237067d
deps: manually add 9.x support to npm
MylesBorins Oct 26, 2017
4fdd76d
http2: fix stream reading resumption
apapirovski Oct 29, 2017
ef238fb
v8: migrate setFlagsFromString to internal/errors
jasnell Oct 26, 2017
07d71c9
async_hooks: enable runtime checks by default
AndreasMadsen Oct 19, 2017
decb9e7
doc: add license information for remark-cli
MylesBorins Oct 31, 2017
ed92e0c
doc: add Gibson Fahnestock to Release team
gibfahn Oct 30, 2017
45873d2
module: revert #3384 DEP0019 EOL
MylesBorins Oct 31, 2017
daa286a
2017-10-31, Version 8.9.0 'Carbon' (LTS) Release
gibfahn Oct 31, 2017
fa9990f
2017-10-31, Version 9.0.0 (Current)
jasnell Sep 1, 2017
a933179
implement intialize(), tear_down(), process_events() for shared lib API
justus-hildebrand Dec 13, 2017
1906ddd
forgot to remove the node_lib include
justus-hildebrand Dec 18, 2017
f685a03
update ReadMe
justus-hildebrand Dec 18, 2017
8b01e1e
Update README.md
justus-hildebrand Dec 18, 2017
819c0f6
added nodelib interface v0.3
Dec 18, 2017
0280f31
Build on Travis (#6)
cmfcmf Dec 18, 2017
42a0104
revert changes made to node.cc and node.h
justus-hildebrand Jan 4, 2018
f4a5f64
Merge branch 'node_lib' of github.com:hpicgs/node into node_lib
justus-hildebrand Jan 4, 2018
d88e1d5
WIP: added more calling convenience
Jan 4, 2018
c9949a5
Renamed nodelib to node_lib
Jan 4, 2018
02493bb
Added Linux build commands to README
luminosuslight Jan 4, 2018
aa2c043
implement Terminate(), RequestTerminate(), RunEventLoop()
justus-hildebrand Jan 5, 2018
6ed7163
Short comments on what the Start() funcs do
justus-hildebrand Jan 5, 2018
2fae0db
Implemented Initialize(), Run() and Evaluate()
cmfcmf Jan 7, 2018
c01f4e5
Replace argc agrv in Initialize() with std::string
luminosuslight Jan 8, 2018
6acebd9
wip
msoechting Jan 8, 2018
4ad8cce
Cleaned code style (no indent for namespaces, left-lean asteriks, uni…
luminosuslight Jan 9, 2018
cc91ae3
Refactored cmd arg generation
luminosuslight Jan 9, 2018
4812646
Fixed cmd args
luminosuslight Jan 9, 2018
9a264ce
Moved code from Initialize() to new functions
luminosuslight Jan 9, 2018
ef6b4e5
Removed unused v8 argc argv
luminosuslight Jan 10, 2018
53f74b8
Implement remaining Call() methods
cmfcmf Jan 10, 2018
d5bb393
Re-add missing node.h include
cmfcmf Jan 14, 2018
d7d4b2b
Make RegisterModule work. Sadly, we can't use std::function|s, becaus…
cmfcmf Jan 14, 2018
f3e7a6d
fix issues from comments on PR #16
justus-hildebrand Jan 15, 2018
7a59273
Fix pointer to stack variable in register module
luminosuslight Jan 15, 2018
9175443
Use UV_RUN_NOWAIT, @justus-hildebrand
cmfcmf Jan 16, 2018
75f39b0
Merge branch 'interface-implementation' of github.com:hpicgs/node int…
cmfcmf Jan 16, 2018
674c0ee
add comments and TODOs for investigation
justus-hildebrand Jan 17, 2018
4e32b91
Implement `Deinitialize()` and `StopEventLoop()`
Jan 19, 2018
734d0d6
Don't read from stdin
cmfcmf Jan 19, 2018
0c575d5
Merge pull request #16 from hpicgs/interface-implementation
Jan 22, 2018
b945ac7
WIP usage
msoechting Jan 22, 2018
78329e0
Update usage documentation
msoechting Jan 22, 2018
6ea63e2
added code docu
Jan 22, 2018
a323279
refactored internals
Jan 24, 2018
6126411
Option to auto-call process.binding() when calling RegisterModule() (…
justus-hildebrand Jan 24, 2018
0ee4348
Rename getters to match style guide
cmfcmf Jan 29, 2018
200c1a9
added error handling via MaybeLocal (#40)
Jan 29, 2018
ee01950
Add support for cmd args (#39)
luminosuslight Jan 29, 2018
d7c8a33
Merge branch 'node_lib' into expose_internals
cmfcmf Jan 29, 2018
22a3107
Update README.md
EmberFlare Jan 29, 2018
5e7adc7
Merge branch 'node_lib' into expose_internals
EmberFlare Jan 29, 2018
e582066
early check for uv_loop_alive(), small refactoring
justus-hildebrand Jan 29, 2018
25211e6
Merge pull request #41 from hpicgs/expose_internals
Jan 30, 2018
6854d8f
changed the way internals are exposed.
Jan 30, 2018
807709d
included feedback from PR
Jan 30, 2018
c51f3f6
Fix method names
luminosuslight Jan 30, 2018
c5c73ff
fix nits
justus-hildebrand Jan 30, 2018
2bb42fb
Merge branch 'node_lib' into tick-event-loop-early-exit
justus-hildebrand Jan 30, 2018
ecee92a
Merge pull request #46 from hpicgs/tick-event-loop-early-exit
luminosuslight Jan 30, 2018
588ab28
moved 'EventLoopIsRunning' back to node::lib
Jan 30, 2018
b607c9f
Merge branch 'node_lib' into expose_internals
justus-hildebrand Jan 30, 2018
5539564
Merge pull request #47 from hpicgs/expose_internals
Jan 31, 2018
40baf2c
Merge branch 'node_lib' into lib-usage-documentation
EmberFlare Jan 31, 2018
e693ecf
added code docu
Jan 22, 2018
0ed0c77
included feedback from PR
Jan 30, 2018
2e6b1ff
fixed merge problems, added more docu for new methods
Jan 31, 2018
c913d75
Merge remote-tracking branch 'origin/interface_docu' into interface_docu
Jan 31, 2018
9c6bf17
Merge pull request #37 from hpicgs/interface_docu
EmberFlare Jan 31, 2018
cac4d43
Merge branch 'node_lib' into lib-usage-documentation
EmberFlare Jan 31, 2018
fd520a7
Merge pull request #35 from hpicgs/lib-usage-documentation
EmberFlare Jan 31, 2018
fe6a38a
Start fixing code style
luminosuslight Feb 1, 2018
334c3a6
Fix more code style, left leaning asterisks
luminosuslight Feb 1, 2018
f45be81
Fix C style cast
luminosuslight Feb 1, 2018
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
Prev Previous commit
Next Next commit
added nodelib interface v0.3
  • Loading branch information
Johannes Schneider committed Dec 18, 2017
commit 819c0f69b9425a2cc2eeb744de595162d4fd683a
117 changes: 117 additions & 0 deletions src/nodelib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#pragma once
#include <string>
#include <vector>
#include <map>
#include <functional>
#include "v8.h"

namespace node::lib {
/*********************************************************
* Function types
*********************************************************/

using std::function<void()> = RunUserLoop;

using std::function<void(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
void * private_data)> = RegisterModule;

using std::function<void(v8::FunctionCallbackInfo<v8::Value> & info)> = ModuleFunction;


/*********************************************************
* Start Node.js engine
*********************************************************/

/*
Starts the Node.js engine without a concrete script file to execute.
*Important*: This requires the C++ developer to call `process_events()` periodically.
*/
bool Initialize();

/*
Starts the Node.js engine with a given JavaScript file. Additionally, the Node.js engine will be kept alive
calling the `processEventsFunction` periodically.
*Important*: This method will not return until the Node.js is stopped (e.g. by calling `terminate`).
*/
bool LoadAndRunScript(const std::string & path, const RunUserLoop & callback);


/*********************************************************
* Handle JavaScript events
*********************************************************/

/*
Processes the pending event queue of a *running* Node.js engine once.
*/
bool ProcessEvents();

/*
Starts the execution of the Node.js main loop, which processes any events in JavaScript.
Additionally, the given callback will be executed once per main loop run.
*Important*: Call `initialize()` before using this method.
*/
bool Run(const RunUserLoop & callback);


/*********************************************************
* Stop Node.js engine
*********************************************************/

/*
Stops the *running* Node.js engine.
*/
bool Terminate();


/*********************************************************
* Basic operations
*********************************************************/

/*
Executes a given piece of JavaScript code, using the *running* Node.js engine.
*/
bool Evaluate(const std::string & java_script_code);

/*
Returns the JavaScript root object for the running application
*/
v8::MaybeLocal<v8::Object> GetRootObject();

/*
Registers a C++ module in the *running* Node.js engine.
*/
bool RegisterModule(const std::string & name, const RegisterModule & callback);

/*
Registers a C++ module in the *running* Node.js engine exporting the given set of functions.
*/
bool RegisterModule(const std::string & name,
const std::map<std::string, ModuleFunction> & module_functions);


/*********************************************************
* Convenience operations
*********************************************************/

/*
Adds a new JavaScript module to the *running* Node.js engine.
*/
v8::MaybeLocal<v8::Object> IncludeModule(const std::string & modul_name);

/*
Returns the local value (specified by its name) of the module (defined in the `exports`-object).
*/
v8::MaybeLocal<v8::Value> GetValue(v8::MaybeLocal<v8::Object> object, const std::string & value_name);

/*
Calls a function (specified by its name) on a given object passing the given arguments.
*Important*: Throws an exception if the receiver does not define the specified function.
*/
v8::Local<v8::Value> Call(v8::MaybeLocal<v8::Object> object, const std::string & function_name, const std::vector<v8::MaybeLocal<v8::Value>> & args = {});

/*
Calls a given function on a given receiver passing the given arguments.
*/
v8::Local<v8::Value> Call(v8::MaybeLocal<v8::Object> receiver, v8::MaybeLocal<v8::Function> function, const std::vector<v8::MaybeLocal<v8::Value>> & args = {});
}