summaryrefslogtreecommitdiff
path: root/modules/script
Commit message (Collapse)AuthorAgeFilesLines
* signals: Simulate GObject's connect_after behavior on signalsMarco Trevisan (Treviño)2023-02-191-1/+5
| | | | | | | GObject signals have a connect_after function that we don't have in the gjs core signals, while it can be useful in some situations. So introduce it.
* debugger: Use spread syntax to override style propertyPhilip Chimento2023-02-191-3/+1
| | | | | This was previously done with a slightly circuitous call to Object.assign(); it can be done more readably with spread syntax.
* debugger: Support Symbol valuesPhilip Chimento2023-01-011-1/+5
| | | | | | | | | | | We get this for free already for Symbol primitive values and Symbol property keys and values, due to it being supported in the pretty-printer. For the 'keys' command, we need to start using Object.getOwnPropertySymbols() to get the Symbol property keys. While we are at it, switch from using Object.keys() which only gives enumerable string/number property keys, to Object.getOwnPropertyNames(), in order to be able to debug non-enumerable properties as well.
* print: Format Symbol property keysPhilip Chimento2023-01-011-1/+10
| | | | | Introduce a new property key formatter which formats a Symbol property key in brackets.
* print: Pretty-print formatting for SymbolsPhilip Chimento2023-01-011-0/+22
| | | | | | | This formats Symbols as the source text with which they should be able to be constructed. It makes a distinction between registered symbols (created with Symbol.for()), well-known symbols (always existing), and regular symbols (created with Symbol()).
* print: Refactor check for nonstandard toString in pretty-printPhilip Chimento2023-01-011-11/+15
| | | | | | In the pretty-printer, if an object or a function has has its toString() method overridden, the overridden toString() is preferred. Refactor this check slightly so that we can put more cases in the switch statement.
* integrated the pretty printer to debugger.jsNasah2022-07-231-13/+3
|
* Not PR focus: pretty printing empty objects as {}Nasah2022-07-231-1/+2
|
* pretty print string value with double quotesNasah2022-07-231-2/+4
|
* automatically adding () to the expression to be printedNasah2022-07-231-0/+2
| | | | An expression like {a:2} is ambiguous since it can be an object literal with property a and value 2 or a statement block with label a and one expression inside, 2. Adding () disambiguates {}.
* Add check for GObject introspected objects to pretty-printNasah Kuma2022-06-131-7/+14
|
* Merge branch 'handle-reference-cycles-in-pretty-print-function' into 'master'Philip Chimento2022-03-241-7/+17
|\ | | | | | | | | | | | | Handle reference cycles in pretty print function Closes #469 See merge request GNOME/gjs!739
| * Closes: #469 ;added check for circular referencing when printing out objectsNasah Kuma2022-03-231-7/+17
| |
* | Merge branch 'verbose-object-print-output' into 'master'Philip Chimento2022-03-061-1/+71
|\ \ | |/ | | | | | | | | | | Verbose object print output Closes #107 See merge request GNOME/gjs!587
| * Verbose object print outputNasah Kuma2022-02-251-0/+53
| | | | | | | | Closes: #107
| * print: Connect up prettyPrint() to Console.interact() and log()Philip Chimento2022-02-251-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It makes sense for the prettyPrint() function to be written in JS, but it does need to be called internally in Console.interact() which is written in C++. Therefore, create a slot on the global object in which to store the prettyPrint() function, which can be retrieved when needing to call the function from internal code. Console.interact() no longer needs to use gjs_value_debug_string(), so that code and its dependencies can be removed. Also pass the arguments of log() and logError() through prettyPrint(). This enables the work from #107.
* | package: Reverse order of running-from-source checksPhilip Chimento2022-03-021-14/+14
|/ | | | | | | | | | | | | The "run from source" feature has recently broken, though I'm not sure exactly how recently. My best theory is that this is because Meson may have changed how it organizes its build directory in recent versions, and the new layout unfortunately means that the check in _runningFromSource() succeeds under Meson, where before it did not. Switching the order of _runningFromSource() and _runningFromMesonSource() fixes the problem, since _runningFromMesonSource() relies on Meson-specific environment variables and will definitely not succeed in a non-Meson environment.
* Add TypeError to Error debugger printerEvan Welsh2022-01-161-1/+1
| | | | | | dv.class is no longer Error for subclasses of Error, without this change the debugger will print {} instead of [object TypeError]
* debugger: Handle EOF at debugger prompt correctlyPhilip Chimento2022-01-161-3/+5
| | | | | | | Previously, pressing Ctrl+D at the debugger prompt would log an internal error because repl() would return undefined at EOF. It looks like the code here was actually expecting null for EOF, but we also need to explicitly quit the debugger in the EOF case and not just return.
* Update ESLint to v8ewlsh/eslint-v8Evan Welsh2021-08-181-1/+1
|
* debugger: Add option to ignore caught exceptionsFlorian Müllner2021-08-131-1/+14
| | | | | | | | | | | | | | Right now execution stops whenever an exception is thrown, regardless of whether the exception was handled or not. This gets annoying fast when exceptions are expected, for example when handling EEXISTS after attempted file operations instead of doing (racy) existence checks. Address this by ignoring handled exceptions by default, with the option to restore the old behavior. https://gitlab.gnome.org/GNOME/gjs/-/issues/431
* ByteArray: Implement ByteArray.toGBytes() in JSEvan Welsh2021-08-071-1/+14
| | | | | | | | At least from what I can tell ByteArray.toGBytes() doesn't support ByteArray.ByteArray instances and at some point the GLib.Bytes constructor started working to copy data just fine. So now toGBytes() is just a wrapper around GLib.Bytes and I removed _makeBytes().
* ByteArray: Clarify eslint overrideEvan Welsh2021-07-011-1/+3
| | | | | This exists because we export a property named 'toString' from this module.
* ByteArray: Add jsdoc to ByteArray.fromArray()Evan Welsh2021-07-011-2/+7
|
* Add list command to debuggerNasah Kuma2021-02-181-4/+13
|
* Refactor ARGV handling and add system.programArgs.ewlsh/refactor-argvEvan Welsh2021-02-111-0/+8
| | | | | (Changes from Philip folded in: use native function with reserved slot to store built argv array)
* Add list command to debuggerNasah-Kuma2021-02-111-0/+38
|
* debugger: Handle special return values from Environment.getVariable()Philip Chimento2021-02-081-0/+12
| | | | | | | | | | | | | | | | | | Debugger.Environment.getVariable() may return one of the three sentinel values {missingArguments: true}, {optimizedOut: true}, or {uninitialized: true} if a variable does not have a value for some reason. Handle these special values in debuggeeValueToString(). "missingArguments" means that a function argument was optimized out, "optimizedOut" means that a regular variable was optimized out, and "uninitialized" means that a variable is present in the environment but hasn't been initialized yet, for example when breaking on an exception thrown while initializing it. Also adds a test for the latter case (printing a backtrace with locals, when breaking on an exception that leaves a local variable uninitialized.) https://searchfox.org/mozilla-central/rev/6a6a366031680829746b5d2362610b868fd9571a/js/src/debugger/Debugger.cpp#1412-1435
* format: Add some linter rules and warnings about imports.formatPhilip Chimento2021-02-081-0/+1
| | | | | | | Also pkg.initFormat() which patches the global String.prototype. These are not deprecated as such, because Format.vprintf can still be necessary when interacting with gettext in some cases, but it is definitely discouraged to monkeypatch the global String prototype.
* Display current line of source code when displaying current frame in debuggerNasah Kuma2021-01-271-15/+18
|
* Add backtrace full command to debuggerNasah Kuma2021-01-091-8/+32
| | | | Closes: GNOME/gjs#208
* debugger: Make '$$' mean the last valuePhilip Chimento2020-11-301-1/+5
| | | | | | | | | | | | | | The debugger already stores the result of each printed expression in variables named $1, $2, etc., so you can refer to them later. This change makes the variable '$$' always refer to the last printed value. Adds a bit of documentation explaining how these variables can be printed, and adds a test for $$ as well as $1, $2, etc. Based on a commit from Mozilla's original jorendb: https://hg.mozilla.org/mozilla-central/rev/fe52996292bb6d1acd51a983f9a7ac6faa7724f6 (The GJS debugger was originally based on jorendb and I was looking to see if any new improvements had been made since I had forked it)
* Correct contributor copyright email.Evan Welsh2020-11-302-2/+2
| | | | Future commits will also be made under this email address.
* maint: Add copyright notices based on major file contributorsPhilip Chimento2020-11-306-0/+8
| | | | | | | | | | | | Based on looking at the git logs, add copyright notices to files which were missing them, assuming the copyright belongs to people who made major contributions to each file. Some assumptions were made as to who to assign the copyright to, such as, what copyright assignment did the contributor make in other files added in the same commit? What email address did they use to make the commit? What copyright assignment did they make in other commits using the same email address?
* *: Fix spelling mistakes found by codespellBjörn Daase2020-11-292-6/+6
|
* lint: Switch to eslint-plugin-jsdoc and remove lint-condo.Evan Welsh2020-11-207-5/+26
| | | | | | | | | | | ESLint has deprecated jsdoc and instead recommends eslint-plugin-jsdoc. lint-condo does not have eslint-plugin-jsdoc. We only use lint-condo for eslint currently and it is simpler to instead use yarn to install and manage eslint. Some module files had JSDoc comments which violated the jsdoc plugin's more stringent rules.
* added rule to handle blank lines at the start of blocksNasah-Kuma2020-10-271-2/+0
|
* maint: Add dual MIT/LGPL license to all GJS files that didn't have onePhilip Chimento2020-10-045-0/+7
| | | | | | This adds a SPDX-License-Identifier comment to all files that are part of GJS, part of its unit tests, or auxiliary tools. (Except for some files like the debugger scripts that don't support comments.)
* maint: Convert all existing license/copyright comments to SPDX formatPhilip Chimento2020-10-0412-225/+34
| | | | | | | | The SPDX format is machine-readable, which should make it much easier to avoid mistakes with licensing and copyright using automated tools. This commit does not add any implicit information. It converts exactly what was already specified into SPDX format comments.
* print: Define API writablePhilip Chimento2020-08-301-0/+4
| | | | | | | | In order to match the GJS_MODULE_PROP_FLAGS that they were previously defined with before the split into a separate module, the print functions need to be defined with writable: true on the global object. Without this, `spyOn(globalThis, 'print')` will not work.
* maint: Add more eslint rules for restricted syntaxPhilip Chimento2020-08-301-2/+2
| | | | | | | We do want people to stop using Lang.copyProperties. In addition, 'x instanceof Array' is not correct, use Array.isArray() instead.
* debugger: Remove Debugger.enabled propertyPhilip Chimento2020-08-111-12/+2
| | | | | | | | This was removed in https://bugzilla.mozilla.org/show_bug.cgi?id=1564168 and is no longer needed. Switching off the debugger is replaced by Debugger.removeAllDebuggees(), other uses can just be dropped. See: GNOME/gjs#329
* global: Refactor to support multiple global types.Evan Welsh2020-07-271-2/+2
|
* modules: Split print functions into native module.Evan Welsh2020-07-043-2/+32
|
* js: Replace trimLeft and trimRight with trimStart and trimEndPhilip Chimento2020-05-161-3/+3
| | | | | Starting with SpiderMonkey 68, the standards-compliant trimStart() and trimEnd() replace the old trimLeft() and trimRight().
* JS: migrate from the global `window` to `globalThis`Andy Holmes2020-04-243-6/+6
| | | | | | | | | As of mozjs68 (gjs-1.64) `globalThis` is recommended over `window` and it makes more sense in this context anyways. Migrate the few instances of `window` we use and adjust the eslint configuration. `window` will continue to resolve to `globalThis`, so this won't affect extensions or other downstream users.
* GObject: Allow omitting setters and gettersPhilip Chimento2020-04-191-0/+3
| | | | | | | | | | | | | | | | | | | In the case where you don't need anything special from your GObject property getters and setters, just correct handling of notify signals and default values, it's now possible to leave out the getters and setters, and GJS will just do the right thing. This is convenient for JS code authors as well as avoiding problems caused by missing getters and setters. This only works for read-write properties. If a read-only or write-only property is missing its accessor, then one is generated which throws. If the property name consists of multiple words, then accessors will be generated for all three variants: kebab-case, snake_case, and camelCase. Additionally, if you do provide accessors for one of these, then they will be copied to the other two variants. See: #306
* modules: Reorganize modules to support multiple globals.Evan Welsh2020-02-0216-0/+4457
- Rename and move modules.gresource.xml -> js.gresource.xml This reflects that new environments may require JS resources outside of modules/ - Move the "core" cairo, format, gettext, and signals logic to modules/core/ to allow reuse across environments. - Move the "legacy" (script-based) modules to modules/script/ - Move the script-based bootstrap files to modules/script/ - Move overrides to modules/core/ as they will be reused across environments - Update meson resource compilation. - Update js.gresource.xml for new module paths. - Update resource path references in C++.