-
Notifications
You must be signed in to change notification settings - Fork 1
Description
From https://github.com/nucleus-js/design/blob/master/api/nucleus.md
Guide
Properties should be added in src/nucleus.rs
.
The Duktape API is documented at http://duktape.org/api.html
Functions should be put in src/nucleus_functions.rs
and accessed via nucleus_functions::your_fn
.
Functions should be exposed under this comment in src/nucleus.rs
in the following manner:
duk::push_c_function(ctx, nucleus_functions::/* Your fn name */, /* number of arguments it accepts */);
duk::put_prop_string(ctx, -2, "/* your fn's JS name */");
If new duktape APIs are necessary they should probably be exposed in src/duk_api.rs
for easy use and re-use.
A direct declaration of the duktape C api is required in the extern { }
block.
The new exposed API should then drop the duk_
(it will be accessed via duk::
) and handle the unsafe block and any major type conversions (such as CString
).
New command line options can be added to this code in src/main.rs
.
System
-
nucleus.cmd
-
nucleus.args
-
nucleus.rawArgs
-
nucleus.exit(code)
-
nucleus.getenv(name) -> value
-
nucleus.setenv(name, value)
-
nucleus.unsetenv(name)
-
nucleus.envkeys(showHidden) -> array of keys