This extension provides the following facilities:
- registering modules,
- module resolvers, and
- an API for retrieving a module instance given its name.
A module is defined as a global static structure containing a pointer
to a string which is the name of the module, and a pointer to a function
which will be called when an instance of the module is needed.
A module resolver is a function that accepts a string holding the name
of the module and returns a `jerry_value_t` in an out-parameter and
`true` if the module was found, or `false` if it was not. If it returns
`true` and the out-parameter has the error flag set then the API will
pass it through without caching.
This extension provides a built-in module resolver which attempts to
load modules that follow the above module definition.
The API provided by this extension invokes all module resolvers it
receives in sequence to attempt to resolve the name of a single module.
After one resolver returns `true` and a `jerry_value_t` that represents
the module the API stops iterating over the remaining resolvers and
caches the value if its error flag is not set. It then returns the
`jerry_value_t`. The API will return a `jerry_value_t` containing an
error indicating that the module was not found if it reaches the end of
the list of resolvers. The error it returns has an extra property
`"moduleName"` the value of which is a string containing the name of the
module that the API was asked to resolve.
JerryScript-DCO-1.0-Signed-off-by: Gabriel Schulhof gabriel.schulhof@intel.com
- On OSX, `find` is more picky about its arguments than on Linux
and requires the start directory(-ies) to be explicitly mentioned
before the expressions (a.k.a. "primaries"). However, until now,
the `pylint` runner script called `find` without a start dir,
which caused an error on OSX.
- Until now, `find` looked for python scripts in all subdirectories
of the project, causing `pylint` to check scripts under `targets/`
and `tests/test262` (if `test262` was checked out). However, the
files under `targets/` are less strictly controlled while
`test262` is completely beyond the control of the project. This
caused a lot of superfluous lint warnings.
This patch makes the `pylint` runner script call `find` in the
cross-platform way, and also limits the scope of the lint checks to
the `tools/` and `jerry-debugger/` directories.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Markdown files in the docs/ directory can now be annotated to turn
fenced C code blocks into unit tests. The recognized syntax is:
[doctest]: # (name="test.c", test="run")
```c
// unit test code
```
The commit also fixes the issues revealed during the initial
annotation.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Convert debug server port from a compile-time constant to a context
variable. This enables each engine instance (either running in the
same process or in different processes) to listen for connections
at different ports, i.e., multiple engines can be debugged at the
same time on the same machine.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
JerryScript should support external context, heap and lcache,
so that it can have multiple instances and runtime configurable heap
size.
Related issue: 1746
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
We should keep the `jerry_` prefix for public API which is either
declared in jerry-core/include or implemented in jerry-core/api.
Moreover, we should also keep the convention to use short
identifiers for componentization within jerry-core, and use these
identifiers as directory names, file name prefixes, and identifier
prefixes.
Therefore, the tools/gen-unicode.py-generated arrays in
jerry-core/lit are renamed to use `lit_` prefix instead of `jerry_`.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Eases command line option and sub-command definition, usage summary
and detailed help message printing, and argv processing.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
It provides some APIs for binding developers, so that
they can validate the type of the js argument and convert/assign them
to the native argument.
Related Issue: #1716
JerryScript-DCO-1.0-Signed-off-by: Martijn The martijn.the@intel.com
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
There is no need to create error code named subfolders since
every failing tests return with the same code.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit changes the concept of JerryScript port implementations
from a simple directory of C source files (which get injected among
the sources of `jerry-core`) into a proper static library (which
may be linked to an application together with `jerry-core`). As a
consequence, this commit introduces a new library to the
JerryScript component architecture: the sources of the default port
implementation form `jerry-port-default`.
Changes in more detail:
- The sources in `targets/default` are moved to `jerry-port/default`
and are turned into a proper static library.
- Actually, the default port implementation has two library
variants, one that implements the bare minimum only
(`jerry-port-default-minimal`) and one that has some extra
functionalities specific to this implementation (the "full"
`jerry-port-default`).
- The new libraries have an interface header in
`jerry-port/default/include`, which extends the common
`jerryscript-port.h` API with functions specific to these
libraries.
- All non-standard port functions have now the
`jerry_port_default_` prefix (this affects `jobqueue_init` and
`jobqueue_run`).
- The jobqueue implementation functions became config macro
independent: it is now the responsibility of the linker to pick
the needed objects from the library, and omit those (e.g.,
jobqueue-related code) that are not referenced.
- Build of the libraries can be controlled with the new
`JERRY_PORT_DEFAULT` cmake option.
- The cmake option `PORT_DIR` is dropped, and `PORT_DIR/*.c` is not
appended to `jerry-core` sources.
- Instead, the `jerry` tool of `jerry-main` links to
`jerry-port-default`, while `jerry-minimal` links to
`jerry-port-default-minimal`.
- `tests/unit-core` tests are also linked to
`jerry-port-default-minimal`.
- Tools adapted.
- `build.py` has `--jerry-port-default` instead of `--port-dir`.
- `check-*.sh` have paths updated (`jerry-port/default` instead
of `targets/default`).
- Miscellaneous.
- Dropped `#ifndef`s from `jerryscript-port.h`. It is a public
header of the `jerry-core` library, which means that it must
not contain configuration-dependent parts (once the library is
built with some config macros and the archive and the headers
are installed, there is no way for the header to tell what
those config macrose were).
- Added documentation comments to the JobQueue Port API (in
`jerryscript-port.h`) and to several default port
implementation functions (in `jerry-port/default`).
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
The `conversions` and `ranges` files had separate generators, which
shared some functionality through a 3rd python module, and were
quite similar to each other -- but also had some differences.
Moreover, as they were separate scripts, nothing forced to keep the
outputs in sync (to re-generate them at the same time from the same
inputs).
To fix these maintainability issues, this patch
- merges the two python files and part of the 3rd utility module
into a single script while keeping the existing functionality,
- names the new file `gen-unicode.py` to align better with other
generator script in `tools`, and
- adds some extra documentation how to retrieve the input files
(as they are not part of the repository).
The refactoring affected the utility module as well, so this patch
also
- renames `c_source_helper.py` to `gen_c_source.py` (again, for
naming consistency),
- reorganizes some of its functions not to export module-local
helper functions, and
- adapts `js2c.py`, as it also uses this utility module.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
In #1761, not all unit test paths have been updated in check tools.
This triggers no errors as `check-vera` emits a warning only while
`check-cppcheck` signals nothing. Still, this means that some of
the code in the repository that has been quality-assured, is now
avoiding checks. This patch fixes this.
Moreover, `check-cppcheck` has had incorrect paths for a while: it
looked for source files in the root of the repository, but those
files have been in `jerry-main` for almost a year now. This patch
fixes this, too.
Fallout of the above: `main-unix-minimal.c` had to be improved to
make `check-cppcheck` pass.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
The unit tests should follow the component structure, so this patch
moves all `jerry-core` unit tests under `tests/unit-core` and the
`jerry-libm` unit tests under `tests/unit-libm`.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Currently, `lit-magic-strings.inc.h` is manually maintained. This
has several drawbacks:
- keeping the list of magic strings sorted first by length then
alphabetically is error prone,
- it is easy to leave unused magic strings in the list by accident
(e.g., `LIT_MAGIC_STRING_JERRY_UL` is defined as a magic string
but not used anywhere in the code) and,
- it is very hard to add `CONFIG_DISABLE_*_BUILTIN` guards to the
list, even though there are several magic strings, which are used
in some of the configurations only (e.g, "setPrototypeOf" is used
in ES2015 only).
To ease the maintenance of magic strings, this commit moves the
definition of magic strings to a config file
(`lit-magic-strings.ini`), and adds `tools/gen-magic-strings.py` to
generate the `.inc.h` file from this config file and from the use
cases of the strings in the code.
- The magic strings in the config file can appear in any order, the
generator will ensure that they are correctly sorted.
- The generator skips those definitions that are not used anywhere
(and emits a warning to signal that such definitions can be
removed).
- The generator applies the same guards to the definitions in the
`.inc.h` file as found in the code around the use of the strings
to optimize for size.
The commit also changes some builtin-related `.inc.h` files by
adding guards that don't affect functionality but improve the
results of the generator.
To ensure that the invocation of the generator does not get
forgotten, the commit also adds `tools/check-magic-strings.sh` and
binds it into the testing infrastructure.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
First issue was that `diff -u0` was not supported on OSX, thus got
replaced by `-U0`. Then, it turned out that test outcome was
determined based on diff's stdout, which was empty even though the
exit code was non-0 - this got changed, too.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This change is required to fix invalid links in 'See also' sections.
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
The arrays contain the addresses of functions annotated with
constructor or destructor attributes. The support is optional,
requires FEATURE_INIT_FINI cmake option to be set. As of now, the
option is _not_ available in tools/build.py directly, only via
`--cmake-param="-DFEATURE_INIT_FINI=ON"`.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This check is performed in cmake-side too.
The README.md about the profiles is also updated.
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
The `run-tests.py` test execution harness validates the correctness
of JerryScript by building various configurations of jerry and
running various test suites and subsets against it. However, until
now, it always built jerry for each (build configuration, test suite)
pair. This commit improves `run-tests.py` by skipping duplicate
builds, sharing the same-built binaries across multiple test suite
runs.
The patch also improves on the style of how `Option`s are specified
and fixes the name of the `jerry_tests-debug-cpointer_32bit`
option.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Fixed all of the remaining warnings in 'build.py', 'run-tests.py' and 'check-license.py'.
Related issue: #1600
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
On OSX, the traditional GNU `timeout` command is available as
`gtimeout`. So, this commit adds some logic to the test runners to
try and find the right command name on the host.
Moreover, the commit also unifies the timeout mechanism across all
test runners by rewriting occurrences of `ulimit`-based timeouting
to use the `[g]timeout` command.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
Extract the source code generator methods into a separated `unicode_c_source.py` script.
Fix the generator scripts to make them compatible with both Python2 and Python3.
Remove pylint warnings.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
Those tests are related the actual daylight saving adjustment.
Related issue: #1661
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This makes the code more robust and error prone, since certain
messages cannot be received in certain situations, e.g. an eval
command during garbage collection.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
Add `--skip-list` option to tools/run-tests.py.
Additional modifications:
- The test `parser-oom.js` doesn't work when system-allocator is enabled,
hence we skip it in these jobs.
- The sanitizer-tasks become mandatory.
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
* Added 'pylint' to dependencies
* Added pylint config file
* Added to travis CI as an allow failure job
(until all of the warnings are fixed)
* Added to 'run-test.py'
Related issue: #1600
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
The script generates the source file instead of copy the tables and paste these manually.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
The debugger supports setting breakpoints, execution control (step, next, continue)
and getting backtrace. The communication is WebSocket-based, so a browser can
communicate with JerryScript without any intermediate application.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
* Fixed Doxygen issues
* Updated Doxygen config
* Added new script to test whether doxygen generation was successful or not
* Added to Travis CI
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
Added a new 'buildoptions' option to tools/run-tests.py to add
a comma separated list of extra build options to each test.
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com