Commit graph

60 commits

Author SHA1 Message Date
Saúl Ibarra Corretgé
c076339899 Expose JS_GetPropertyInt64 in the public API 2024-03-26 07:59:00 +01:00
Saúl Ibarra Corretgé
b8341ecafa Don't expose JS_{Get,Set}PropertyInternal in the public API 2024-03-26 07:59:00 +01:00
Charlie Gordon
3b50de4848
Improve consistency of JS_NewFloat64 API (#319)
* Improve consistency of JS_NewFloat64 API

- `JS_NewFloat64()` always creates a `JS_TAG_FLOAT64` value
- internal `js_float64()` always creates a `JS_TAG_FLOAT64` value
- add `js_int64` internal function for consistency
- rename `float_is_int32` as `double_is_int32`
- handle `INT32_MIN` in `double_is_int32`, use (somewhat) faster alternative
- add `js_number(d)` to create a `JS_TAG_FLOAT64` or a `JS_TAG_INT` value
  if possible
- add `JS_NewNumber()` API for the same purpose
- use non testing constructor for infinities in `js_atof2`
- always store internal time value as a float64
- merge `JS_NewBigInt64_1` into `JS_NewBigInt64`
- use comparisons instead of `(int32_t)` casts (implementation defined behavior)
2024-03-25 08:29:04 +01:00
Saúl Ibarra Corretgé
1796b36db7 Remove JS_VALUE_GET_STRING from the public API
JSString is not part of the API.
2024-03-24 21:01:15 +01:00
Saúl Ibarra Corretgé
4a66289af4 Add JS_Newsymbol, an API for creating symbols
Example usage:

~~~
JSValue global = JS_GetGlobalObject(ctx);
JSValue sym = JS_NewSymbol(ctx, "my.secret.thing", TRUE);
JSAtom atom = JS_ValueToAtom(ctx, sym);
JS_DefinePropertyValue(ctx, global, atom, JS_NewString(ctx, "qjs!"), JS_PROP_C_W_E);
JS_FreeAtom(ctx, atom);
JS_FreeValue(ctx, sym);
JS_FreeValue(ctx, global);
~~~
2024-03-24 21:00:54 +01:00
Saúl Ibarra Corretgé
5b1d9e4194 Now working on 0.5.0 2024-03-11 11:23:43 +01:00
Saúl Ibarra Corretgé
99a7fbb276 Set version to 0.4.1 2024-03-11 11:16:31 +01:00
Saúl Ibarra Corretgé
125373836d Now working on 0.5.0 2024-03-11 11:01:45 +01:00
Saúl Ibarra Corretgé
434fecda17 Set version to 0.4.0 2024-03-11 11:01:00 +01:00
Tyler Rockwood
ec4f957ca1
Add methods to detect arrays (#282)
I have a use case where a user can hand me many different kinds of
types, array buffer, uint8array, or a string, and I need to be able to
distingush between them.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
2024-02-28 12:17:18 +01:00
Tyler Rockwood
377e6a6c06 Fix JS_INVALID_PROMISE_STATE macro 2024-02-26 18:37:30 +01:00
Tyler Rockwood
d168361207 Add documentation for promise APIs
Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
2024-02-23 19:49:52 +01:00
Tyler Rockwood
33f72491a9
Add method to GetClassID (#275)
* Add method to GetClassID

If you want to extend a built-in class you need it's class ID and there
is no robust way to get that without this accessor.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

* introduce constant for invalid class ID

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>

---------

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
2024-02-20 09:29:08 +01:00
Saúl Ibarra Corretgé
fb03ca24d2 Add WASI support 2024-02-14 08:59:15 +01:00
Saúl Ibarra Corretgé
7ded62c536 Align module export API with upstream
Partially reverts
6868fb9e25
but the same behavior can be implemented in userland by getting the
module ns and querying its properties.

Ref: c6cc6a9a5e
Fixes: https://github.com/quickjs-ng/quickjs/issues/259
2024-02-12 11:00:31 +01:00
Guilherme Bernal
6868fb9e25 feat: Added functions to get access to module exports 2024-01-18 18:42:37 +01:00
Ben Noordhuis
b5d6cea20e
Fix Reflect typed array element conversion (#240) 2023-12-30 10:45:33 +01:00
Saúl Ibarra Corretgé
d1852b5ea2 Remove unnecessary casts
Follow-up to https://github.com/quickjs-ng/quickjs/pull/195
2023-12-20 09:02:28 +01:00
Saúl Ibarra Corretgé
c29ae8d08c Now working on 0.4.0 2023-12-19 22:58:20 +01:00
Saúl Ibarra Corretgé
2d0b6d8ade Set version to 0.3.0 2023-12-19 22:46:31 +01:00
Ben Noordhuis
ba8b80f112
Remove broken JS_READ_OBJ_ROM_DATA flag (#216)
This JS_ReadObject() flag no longer works for bytecode. The IC opcodes
are patched during execution.

Fixes: https://github.com/quickjs-ng/quickjs/issues/206
Refs: https://github.com/quickjs-ng/quickjs/pull/120
2023-12-14 15:25:29 +01:00
Ben Noordhuis
8baafc46bd
Don't throw OOB exception for detached typed array (#208)
`a[42] = 1` where a is a detached typed array should not throw but
`Object.defineProperty()` still should. Add a check and a flag that
distinguishes between the two cases.
2023-12-12 23:14:33 +01:00
Ben Noordhuis
f1b7b6da71
Replace JSValueConst with JSValue (#195)
JSValueConst was only used for the now removed CONFIG_CHECK_JSVALUE
build mode. It is kept around as an alias for JSValue in quickjs.h to
avoid breaking everyone's source builds but remove it everywhere else.
2023-12-10 15:15:42 +01:00
Ben Noordhuis
4d57997ee7
Remove CONFIG_CHECK_JSVALUE build mode (#194)
It doesn't produce a working build and I'm somewhat skeptical that
its purported goal of catching reference counting bugs still works.
2023-12-10 13:50:26 +01:00
Saúl Ibarra Corretgé
2d05150e35 Now working on 0.3.0 2023-12-05 23:27:23 +01:00
Saúl Ibarra Corretgé
a393ebc2f8 Set version to 0.2.0 2023-12-05 23:18:22 +01:00
Ben Noordhuis
087441559e Replace JS_NewFloat64() calls with js_float64() 2023-11-29 23:38:01 +01:00
Ben Noordhuis
a6e73ca73c
Handle serialization endianness transparently (#152)
Change JS_WriteObject() and JS_WriteObject2() to write little-endian
data and update JS_ReadObject() to byte-swap data when running on a
big-endian system.

Obsoletes the JS_WRITE_OBJ_BSWAP flag, it is now a no-op.

Fixes: https://github.com/quickjs-ng/quickjs/issues/125
2023-11-28 22:49:01 +01:00
Saúl Ibarra Corretgé
5c136edbcf Implement WeakRef 2023-11-28 13:26:33 +01:00
Saúl Ibarra Corretgé
fb1b1ced26
Set default visibility to hidden and export the public API (#140) 2023-11-26 01:41:32 +01:00
Saúl Ibarra Corretgé
d74b2e7ec1 Squelch a -Wcast-function-type warnings
Ref: https://github.com/quickjs-ng/quickjs/issues/131
2023-11-26 00:08:48 +01:00
Saúl Ibarra Corretgé
8f2993bd68 Add APIs to build a Uint8Array from binary data directly 2023-11-24 23:05:39 +01:00
Saúl Ibarra Corretgé
268cde8270 Add API to build Date objects 2023-11-24 23:05:27 +01:00
Saúl Ibarra Corretgé
4e73bcf42d
Now working on version 0.2.0 2023-11-23 15:46:00 +01:00
Saúl Ibarra Corretgé
fd3d71b486
Set version 0.1.0 2023-11-23 14:44:54 +01:00
Saúl Ibarra Corretgé
5ce2957e23 Make JS_NewClassID thread aware
It's as thread-safe as JSRuntime, which isn't thread-safe, but multiple
threads can now allocate them on different runtimes without a problem.
2023-11-21 07:02:34 +01:00
Saúl Ibarra Corretgé
a721bda7b5 Drop CONFIG_ALL_UNICODE and enable it by default 2023-11-20 10:52:04 +01:00
Saúl Ibarra Corretgé
ea068d9a70 Add performance.{now,timeOrigin}
Ref: https://github.com/quickjs-ng/quickjs/issues/16
2023-11-18 11:16:35 +01:00
Saúl Ibarra Corretgé
e0170867b4 Set dev as the current version suffix 2023-11-16 09:24:43 +01:00
Saúl Ibarra Corretgé
cc3e062484 Simplify NAN boxing macro setting 2023-11-14 21:57:24 +01:00
Ben Noordhuis
920cfc679a
Add copyright notices (#51)
I believe we made enough substantial changes to have a credible claim to
copyright holdership.
2023-11-12 22:42:07 +01:00
Ben Noordhuis
162a8b7409
Remove trailing whitespace (#46)
Not purely cosmetic because it breaks navigation with { and } in the
One True Editor.
2023-11-12 10:01:40 +01:00
Saúl Ibarra Corretgé
55e845c5dd Add JS_GetVersion 2023-11-10 16:48:49 +01:00
Ole André Vadla Ravnås
3c144fd553 Add JS_GetAnyOpaque() to support polymorphism
To be able to check if the class ID is one of multiple known ones, where
the data has a common structure.
2023-11-10 11:01:22 +01:00
Ben Noordhuis
ae17b8522d
Remove operator overloading (#32)
Part of https://github.com/quickjs-ng/quickjs/issues/17
2023-11-10 10:23:40 +01:00
Ben Noordhuis
e449cb08ef
Remove BigFloat (#31)
Part of https://github.com/quickjs-ng/quickjs/issues/17
2023-11-08 22:23:06 +01:00
Saúl Ibarra Corretgé
c1ed688610 Drop non-standard JSON extension
Ref: https://github.com/quickjs-ng/quickjs/issues/20
2023-11-08 22:14:25 +01:00
Ben Noordhuis
5d5b3cc21f
Remove BigDecimal (#29)
Part of https://github.com/quickjs-ng/quickjs/issues/17
2023-11-08 21:07:16 +01:00
Ben Noordhuis
0068db8a11 Avoid UB when checking if float fits in int32 2023-11-08 19:17:13 +01:00
Saúl Ibarra Corretgé
e2ae8746ca
Drop support for "use strip"
Ref: https://github.com/quickjs-ng/quickjs/issues/20
2023-11-07 00:29:11 +01:00