| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
By avoiding using import.meta.importSync() and imports.gi at the top level
of modules that we import during the bootstrap process, we speed up the
execution of a blank file by 15%, because we don't need to go into any of
the GI typelib machinery.
Now, the only modules imported at startup are _print, _encoding, _timers,
and console, in order to provide public global APIs.
I measured the 15% speedup with `perf stat -r 10 -B`. I also used Meson's
measurements of the test suite to see a noticeable effect: for example,
running the CommandLine test (which starts many instances of GJS) goes
goes from 5.4 to 4.9 seconds.
The cost of importing these modules is instead paid at the first time
they're used. This assumes that it's nearly zero cost to import the
modules a second time, because they're cached.
In addition, this should make debugging easier because you don't get a big
log spew of importing GLib if your script doesn't import GLib.
|
|
|
|
|
| |
If something like gi.require('GLib', '1.75') fails, then we don't want the
faulty version number remaining on the imports.gi.versions object.
|
|
|
|
|
| |
ByteArray.fromString() is already defined by _byteArrayNative and
re-exported; while ByteArray.toGBytes() just calls new GLib.Bytes anyway.
|
|
|
|
| |
Gio.DEFAULT_PRIORITY is undefined given that's exposed by GLib instead.
|
|
|
|
|
|
|
|
|
| |
Add a newAsync() static method to DBus proxy wrappers, that returns a
promise that allows to initialize a proxy object asynchronously,
keeping around all the wrappers as expected, and allowing to use nicer
try/catch syntax.
(Edited from Gio.makeProxyPromise to a static method by Philip)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All modules are promises. If Gtk.Application.run() or
GLib.MainLoop.run() is called within a module it will block all other
promises as run() is a synchronous, blocking function. To work around
this there is now a setMainLoopHook function exposed which runs a
callback after module resolution is complete. This allows APIs to
"install" a mainloop asynchronously.
For Gio.Application and GLib.MainLoop there are now runAsync() versions
of their run() functions. runAsync() returns a Promise which will
resolve once the mainloop has exited.
Fixes #468
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
This was previously done with a slightly circuitous call to
Object.assign(); it can be done more readably with spread syntax.
|
|
|
|
|
|
| |
This is a modernization of the console module. (I'm a bit surprised that
the methods still work when transferred as own properties to the global
console object, but apparently they do.)
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Introduce a new property key formatter which formats a Symbol property
key in brackets.
|
|
|
|
|
|
|
| |
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()).
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
closes #515
|
| |
|
| |
|
|
|
|
|
|
| |
Having the connection name in both objects we can be faster at
disconnecting the connections as we can just remove the id from the
target array.
|
|
|
|
|
|
|
|
| |
Use dicts and array lookups to emit signals instead of iterating through
them.
Using native Map() and Set() would have been better, but performances
are worse.
|
|
|
|
|
|
|
|
|
| |
We often reference connection IDs, so now we can use a more optimized
native way to handle connections without having to iterate them all the
times.
This could have been implemented using the newer Map() object, but sadly
it's still way slower than using normal objects.
|
| |
|
| |
|
|
|
|
| |
Use some more modern JS features to get the same quickly.
|
|
|
|
|
| |
In case the log is severe enough it's better to fill such information by
default.
|
|
|
|
|
|
| |
Just fetch the error trace at printer function so that we can just use
this at lower level without requiring explicitly using the printer when
using trace()
|
|
|
|
|
| |
This is what GLib does all the times for C code, in JS we can easily do
it as well as we have traces, for now do it only for console.trace().
|
|
|
|
| |
Also ensure this in a test
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
When a D-Bus implementation returns a value from a getter, check if
it is variant matching the expected property signature. If it is,
skip packing a new variant and just return the value.
|
|
|
|
|
|
| |
We don't require GLib 2.72 for anything else, so it makes sense to
conditionally define the override for GObject.BindingGroup.bind_full().
If GLib is too old then the override (and its tests) are skipped.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
These variables now generate warnings that they "might be clobbered by
'longjmp' or 'vfork'". Declaring them volatile prevents this.
As per https://stackoverflow.com/a/2105840/172999, the C99 standard says
"the values of objects of automatic storage duration that are local to the
function containing the invocation of the corresponding setjmp macro that
do not have volatile-qualified type and have been changed between the
setjmp invocation and longjmp call are indeterminate."
|
|\
| |
| |
| |
| |
| |
| | |
Gio: Promisify GDBusProxy.init_async by default
Closes #494
See merge request GNOME/gjs!790
|
| |
| |
| |
| |
| | |
The function is defined as a so we can just rely on promise syntax to
handle the results.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Some code may promisify it after that it has been overridden, this means
that when called we may not use the original method correctly as the
function won't have the arguments set anymore and thus its length will
be 0, causing the assumption included in commit 58840261 not to be true
anymore.
Since the function is already a wrapper, we can safely override it to be
a promise and then override it again. Allowing code simplifications and
being more future-proof, when all the async functions will be promises
by default.
Fixes: #494
|
| |
| |
| |
| | |
It makes sense to be able to use a static method even from a subtype
|
|/
|
|
|
| |
These are almost entirely unusable from GJS and the few functions that
don't crash outright shouldn't be called by user code.
|
|
|
|
|
|
|
|
|
| |
These functions can crash if used from JS, because they take a raw
pointer. Add an override that calls the appropriate type-safe method
instead, on a best-effort basis; not all of these exist. In any case, the
crashes should be prevented.
Closes: #496
|
|
|
|
|
| |
Since more functions will move out of jsapi.h in the future, it'll be
useful to know why exactly we are including it.
|
|
|
|
|
|
| |
This function was necessary in SpiderMonkey 91, but now the same
functionality is part of the SpiderMonkey API. There is no longer any need
to define our own.
|
|
|
|
| |
In particular, in finalize operations.
|
|
|
|
|
|
|
|
|
|
|
| |
- js/CallAndConstruct.h: Now contains JS::Call, JS::Construct, and
related
- js/Debug.h: Already existed, but now contains JS_DefineDebuggerObject
- js/GlobalObject.h: Now contains JS::CurrentGlobalOrNull
- js/PropertyAndElement.h: Now contains APIs for getting, setting, and
defining properties, as well as array elements
- js/ScriptPrivate.h: Now contains JS::GetScriptPrivate/SetScriptPrivate
- js/Stack.h: Now contains APIs that have to do with the call stack
|
|\
| |
| |
| |
| | |
Make GFileEnumerator iterable and async iterable
See merge request GNOME/gjs!784
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
JS::GetPrivate() and JS::SetPrivate() are going away in SpiderMonkey
102. The replacement is to stuff the pointer into a JS::PrivateValue and
store it in an object's reserved slot. This is a change we can make prior
to the switch.
With SpiderMonkey 102, we are intended to use
JS::GetMaybePtrFromReservedSlot() to retrieve the pointer. This function
doesn't exist in SpiderMonkey 91, but it is a small inline function that
we can open-code in jsapi-util.h.
In most of the cases, we can encapsulate this access into three methods
of CWrapperPointerOps: has_private(), init_private(), and unset_private().
(Retrieving the pointer was already encapsulated by the various for_js()
methods.) This provides better safety anyway, because in init_private()
we can enforce that there was no pointer already set. We define that
reserved slot 0 is always the private pointer.
BoxedInstance already used slot 0 for something else, so that moves to
slot 1.
Based on Evan's commit from the mozjs102 branch.
Co-authored-by: Evan Welsh <contact@evanwelsh.com>
|
| |
| |
| |
| |
| |
| | |
Access to the wrapper object's cairo_t* is currently not encapsulated,
but it will be if we move from JS::SetPrivate to reserved slots. So, this
method needs to be part of the class.
|