Dmitry Volyntsev [Wed, 21 Mar 2018 14:33:13 +0000 (17:33 +0300)]
http subrequest() method.
Creates an nginx's subrequest with the specified arguments and
registers a finalization callback.
req.subrequest(<uri>[, <options>[, <callback>]]):
uri - string.
options - string | object.
string value - uri arguments.
object value can contain:
args, body, method all are string values.
callback - function with the following argument:
reply - the result object with the following properties:
uri, method, status, contentType, contentLength,
headers, args, body, parent.
Dmitry Volyntsev [Wed, 21 Mar 2018 14:33:12 +0000 (17:33 +0300)]
setTimeout() and clearTimeout() methods.
Public methods are introduced to create and post async events for
a VM instance. njs_vm_add_event() creates an async event for the VM
to wait for. njs_vm_post_event() notifies the VM that the event
occurred. If async events were added njs_vm_run() returns NJS_AGAIN
until there are no remaining pending events.
Dmitry Volyntsev [Tue, 20 Feb 2018 16:12:53 +0000 (19:12 +0300)]
Externals refactored.
Public API is rectified to allow the creation of external objects in
runtime.
1) njs_vm_external_add() is replaced with njs_vm_external_prototype().
The later functions returns a pointer to a prototype object which can
be used to create a value with such a prototype in runtime.
2) njs_vm_external() is split into njs_vm_external_create() and
njs_vm_external_bind(). The former creates a variable with a specified
prototype and associates it with an external pointer. The latter binds
a variable to a name in the global namespace.
Dmitry Volyntsev [Mon, 12 Feb 2018 11:57:24 +0000 (14:57 +0300)]
Fixed using of internal NJS headers in nginx modules.
Public API is rectified to make it easier to work with the private
structure njs_value_t from the outside:
1) njs_vm_retval() is split into njs_vm_retval() which now returns
the njs_value_t * as a return value and njs_vm_value_to_ext_string()
which stringifies an njs_value_t * passed as an argument.
2) njs_value_*_set() methods are added.
3) Similar public methods are grouped together.
Dmitry Volyntsev [Mon, 20 Nov 2017 16:24:58 +0000 (19:24 +0300)]
MemoryError reimplemented without its own prototype.
MemoryError is a special preallocated immutable object. Its value type
is NJS_OBJECT_INTERNAL_ERROR. Initially the object had its own prototype
object. It introduced inconsistency between value types and prototype
types, because some routines (for example, njs_object_prototype_to_string())
expect them to be pairwise aligned.
Dmitry Volyntsev [Fri, 17 Nov 2017 15:55:07 +0000 (18:55 +0300)]
Fixed exception handling.
njs_vm_exception() is removed and combined with njs_vm_retval().
vm->exception is removed either, exceptions are now stored in
vm->retval. It simplifies the client logic, because previously
njs_vm_exception() had to be called if njs_vm_retval() fails.
Additonally, stack traces are now appended to the retval if an exception
happens.
Previously, if libedit was unavailable the default action was to build
libnjs and run tests. However, if it was available the default action
was just building binaries.
This patch makes the two high-level targets which are intended to be
invoked externally. The default one for building all available binaries
and the test target for running all available tests.
Fixed default makefile target is libedit is unavailable.
Previously, if libedit was unavailable, any extra target which could be
added by feature scripts became the first and default target. It breaks
builds without arguments.
Adding the default target in this case to ensure that the proper target
is always selected.
Previously, njs_ext_console_log() passed an uninitialized value to
printf() function in the case of an error. The precison argument was set
to 0 in such a case, so well-behaved implementation was able to handle
it properly.
Setting this value to NULL, just to make sure and to make Coverity Scan
happy.
Sergey Kandaurov [Thu, 31 Aug 2017 17:03:13 +0000 (20:03 +0300)]
Backed out changeset 37adbd4c8036, reimplemented properly.
Changeset 37adbd4c8036 breaks build with bmake by introducing Gnu constructs.
Instead, make CLI compilation dependent on libedit by conditionally extending
the default target.