Commit Graph

38 Commits

Author SHA1 Message Date
Tor Andersson
0e611cdc0c 1.3.2 patch release for UAF bug fix. 2022-11-07 16:24:56 +01:00
Tor Andersson
69e2767d0a Make a patch release for important iterator bug fix. 2022-10-20 18:19:41 +02:00
Tor Andersson
ebf235bfea Bump version number. 2022-10-11 18:18:55 +02:00
Tor Andersson
88f6d86b6c Add js_isbooleanobject and js_isdateobject functions. 2022-05-25 16:33:53 +02:00
Tor Andersson
dd0a0972b4 Add JS_VERSION_MAJOR/MINOR/PATCH defines to mujs.h
A macro JS_CHECKVERSION(major, minor, patch) can be used to test the
version if your code depends on API features added in a given version.

#if JS_CHECKVERSION(1, 2, 0)
    ... use new API ...
#else
    ... don't use new API ...
#endif
2021-12-08 12:56:12 +01:00
Tor Andersson
fe8cac61e3 Add user data to C functions with extended constructor.
Accessible from C with js_currentfunctiondata(J).
2021-11-04 13:08:51 +01:00
Tor Andersson
3d29cd2f2f Issue #135: Expose type of value as an enum with js_type().
This matches the values used by the 'typeof' operator.
2021-03-26 15:47:35 +01:00
Tor Andersson
457f87b17b Issue 128: Support property list as replacer argument in JSON.stringify.
Also adds helper functions js_isstringobject and js_isnumberobject.
2020-01-02 14:22:00 +01:00
Tor Andersson
6e62eb0923 Issue 113: Add a js_delglobal function. 2019-11-19 12:56:22 +01:00
Tor Andersson
603977ae5b Add repr() function to shell, and use it in the REPL. 2019-03-22 14:00:20 +01:00
Tor Andersson
ffe0ca7d7f Issue 95: Improve error message when trying to call a non-callable. 2019-03-18 14:11:34 +01:00
Tor Andersson
2c24e194d4 Issue #92: Remove unimplemented function. 2019-03-08 14:09:10 +01:00
Tor Andersson
49271d3cf2 Add js_iserror function. 2018-07-03 12:00:57 +02:00
Tor Andersson
b46ee8d829 Add more js_tryxxx conversion functions. 2018-04-27 16:59:35 +02:00
Tor Andersson
fb32b5c893 Add a js_setreport callback function to report warnings.
Don't print error and warning messages directly to stderr.
2017-05-16 12:03:38 +02:00
Tor Andersson
d2c8e710b9 Fix public header so it can be used with C++. 2017-05-12 11:42:06 +02:00
Tor Andersson
134134e899 Don't do unprotected js_tostring calls in js_dostring/file.
Since js_tostring can invoke a toString method, we should guard against
uncaught exceptions when trying to convert the error object to a string.

Add a public function, js_trystring that does a "safe" conversion
to a string.
2017-05-09 14:47:19 +02:00
Tor Andersson
24b1997368 Add setjmp.h to public header (since js_try is a macro over setjmp). 2017-04-20 15:12:28 +02:00
Tor Andersson
805e0f0f59 Add js_newobjectx to create an object with a specific prototype object. 2016-09-09 19:56:35 +02:00
Tor Andersson
4b68d52351 Add js_iscoercible function. 2016-04-28 12:48:09 +02:00
Tor Andersson
3e3c382a0c Avoid using 'unsigned int'.
Mixing signed and unsigned ints is just a plain headache.
2016-04-27 16:26:00 +02:00
Tor Andersson
aba6644234 Add delete callback to userdata objects. 2016-03-01 21:52:00 +01:00
Tor Andersson
0fd82b60cf Make js_try, js_savetry and js_endtry public functions/macros. 2016-01-18 13:34:00 +01:00
Tor Andersson
f5b3d15f0c Make convenience stack manipulation functions public. 2016-01-12 16:42:40 +01:00
Tor Andersson
4e6c74b551 Add userdata has/put callbacks for custom properties.
This goes beyond defining accessors, and allows capturing all property
accesses. With these callbacks, things like typed arrays can be
implemented.
2016-01-11 17:02:43 +01:00
Tor Andersson
0b9d3be3d0 Remove 'report' argument from js_dostring. 2015-12-16 11:49:52 +01:00
Tor Andersson
8f790df9e5 Add strict mode flag to constructor. 2015-01-14 13:04:46 +01:00
Tor Andersson
c6d17c7f00 Add finalize callback to userdata objects.
When a userdata object is garbage collected, we should invoke a callback
to client code to let it know that the associated userdata pointer is no
longer in use.
2015-01-14 13:04:15 +01:00
Tor Andersson
40dd4a252f Add eval op-code to implement proper 'this' binding for eval code. 2015-01-08 15:55:57 +01:00
Tor Andersson
031513b25b Add stack traces to error objects.
Revert 'add context and flag argument to js_newstate' commit.

The context argument just adds clutter. The flag which was intended
for JS_DEBUG and/or JS_STRICT shouldn't be necessary.

js_newcfunction and js_newcconstructor need an extra argument, the
name of the function to use in stack traces.
2014-12-03 01:18:21 +01:00
Tor Andersson
84faaff8ff Add user context pointer and flag argument to js_State constructor. 2014-11-29 16:12:30 +01:00
Tor Andersson
6538308087 Add short strings (with data embedded in js_Value).
Allows js_tostring to avoid either interning strings converted from
numbers or creating lots of garbage collected strings.
2014-11-29 16:01:36 +01:00
Tor Andersson
0cbd5326f2 Garbage collect (some) strings.
Separate literal/interned and garbage collected string types in js_Value.

js_pushintern/js_tointern are convenience functions to push/pop strings and
automatically intern them (so that the string pointers are guaranteed to be
stable).

js_pushliteral should push stable strings (either interned or actual literals).

js_pushstring will copy the string into garbage collected memory.

The pointer returned by js_tostring is guaranteed to be stable only for as long as
the stack slot it came from remains untouched.

Some uses will always cause a string to be interned:

 * Using it as a property name.
 * Wrapping it in a new String() object.
 * Strings returned by toString().
	ToPrimitive must not clobber the stack, so the result has to be unrooted.
 * Numbers converted to strings (by js_tostring)
	Likewise, we have nowhere to store the temporary string here.
	Passing in a scratch buffer to js_tostring could help this problem.
	Mostly an issue with array accesses (OP_GETPROP, etc) so an auxiliary
	function and we don't have to clutter the API needlessly.
2014-11-28 17:10:08 +01:00
Tor Andersson
95e5aebc2f Remove duplicate js_newerror prototype. 2014-11-17 15:26:16 +01:00
Tor Andersson
790103815f Add public property iterator function. 2014-10-16 13:50:44 +02:00
Tor Andersson
7bab97a7d8 Tweak argument order in js_is/touserdata. 2014-06-12 13:46:50 +02:00
Tor Andersson
8f7c649985 Move ToPrimitive hint flags into jsvalue.h 2014-06-11 12:58:40 +02:00
Tor Andersson
48aed4bbb6 Name the library: MuJS! 2014-03-19 23:07:33 +01:00