1. 22 Oct, 2018 1 commit
    • Philip Chimento's avatar
      console: Refactor AutoReportException for non-object exceptions · 0decd7ed
      Philip Chimento authored
      Previously, in the interactive interpreter, throwing a non-object
      exception (for example, `throw 'foo';`) would crash when trying to print
      the exception value in the console.
      This changes AutoReportException so that exceptions are handled better
      when they are not objects.
  2. 13 Sep, 2018 2 commits
    • Philip Chimento's avatar
      GLib: Fix regression in GVariant packing · 15cf7c29
      Philip Chimento authored
      This was a use of the old ByteArray API that hadn't been updated.
      Closes: #202
    • Florian Müllner's avatar
      GObject: Ensure generated GType names are valid · cacdb796
      Florian Müllner authored
      JS classes accept names that aren't valid GType names. Usually this
      is something the programmer can take into account, however sometimes
      a parent class isn't under their control and can therefore change
      unexpectedly (gnome-shell extensions are a primary example).
      Handle this case gracefully by replacing any invalid characters with
  3. 19 Aug, 2018 2 commits
    • Avi's avatar
      Added _promisify to GJS GIO overrides · decae6d1
      Avi authored
      The _promisify function is a new internal feature for GJS, providing
      developers the option to write asynchronous operations with either
      the original callbacks from GNOME's original C (using GObject)
      libraries or to write them using async/await, a new modern way to
      write asynchronous code in JavaScript. This feature hides all of the
      original callbacks from developers in a Promise, allowing one to call
      the _async function like a variable by calling it with await in an async
      function. This is a backwards compatible feature, thus it will not
      impact already existing code using callbacks.
      Please note that if you use this feature, to be ready for the official
      API version coming out in 3.32 where slight changes to your code will
      be necessary (in a good way, you can remove an extra line or two of
      your code)!
      To use this feature, instead of nesting your _async and _finish function
      in your code (e.g. load_contents_async, load_contents_finish), you can
      update your program to an "async function", and call the _async function
      with an await leading it. You will also need to call the feature in your
      program, too, until the 3.32 release.
      Gio._promisify(..., 'load_contents_async', 'load_contents_finish');
      let [raw_content] = file.load_contents_async(cancellable);
    • Avi's avatar
      Temporary fix for Gio.File.prototype · 42be3ff2
      Avi authored
      Issue #189 details the current dilemma of being unable to add or
      monkeypatch methods on a GObject interface. At this time developers
      must add an additional line of code to their applications to use
      Gio.File.prototype. This is a temporary fix faking it until such a
      fix has been made for that issue.
      promisify(Gio._LocalFilePrototype, load_contents_async, load_contents_finish);
  4. 29 Jul, 2018 4 commits
    • Philip Chimento's avatar
      release: Document SpiderMonkey 60 changes · 34de292e
      Philip Chimento authored
      Includes a change to a comment that previously advocated using a
      nonstandard extension, which is now removed.
      See: #161
    • Philip Chimento's avatar
      byteArray: Add backwards-compatible ByteArray class · 2b6d0fbf
      Philip Chimento authored
      This should make it easier to keep old code working. It adds a legacy
      ByteArray.ByteArray class that works just like the old ByteArray class
      but uses Uint8Array internally. It isn't zero-copy, so it will regress
      the performance of old code, but it should keep almost all code at least
      working. To recover the performance, clients can use Uint8Array instead.
      See: #5
    • Philip Chimento's avatar
      byteArray: Replace with native Uint8Array · 942252dd
      Philip Chimento authored
      It's possible to replace ByteArray with Uint8Array and have almost the
      same functionality, making GJS code closer to standard Javascript, and
      removing a large amount of code.
      This is necessary because getProperty/setProperty hooks are removed from
      JSClass, which the old ByteArray relied on for its array access.
      Closes #5.
    • Philip Chimento's avatar
      js: Replace JS_FS with JS_FN · cda7624f
      Philip Chimento authored
      The macro simply changed its name.
      See: #161
  5. 23 Jul, 2018 4 commits
    • Florian Müllner's avatar
      overrides: Add convenience g_object_set() replacement · 337c3154
      Florian Müllner authored
      Object.assign() can be used to set multiple properties at once, similar
      to g_object_set() in C code. It doesn't looks quite as nice though, so
      add a small wrapper that replaces the non-introspectable g_object_set().
      There's no g_object_get() replacement, first because it is harder, but
      also not least because it is hard to beat the following anyway:
        let { someProp, notherProp } = obj;
    • Philip Chimento's avatar
      debugger: Refactor throw and return commands · 7c8ae639
      Philip Chimento authored
      They are very similar, so they can share almost all of their code. At the
      same time, use early returns in the refactored function to avoid some
    • Philip Chimento's avatar
      debugger: Break on first frame · 71bba979
      Philip Chimento authored
      ...instead of inserting a 'debugger;' statement at the start of every
      program. This is cleaner because it doesn't mess up the client program.
    • Philip Chimento's avatar
      debugger: GJS Debugger · ee89551e
      Philip Chimento authored
      This adds a simple debugger, adapted from the "jorendb" program in the
      SpiderMonkey source. It has basic stepping, breaking, and printing
      commands, that work like GDB. Activate it by running the GJS console
      interpreter with the -d or --debugger flag _before_ the name of the JS
      program on the command line.
      To integrate it into programs that embed the GJS interpreter, call
      gjs_context_setup_debugger_console() before executing the JS program.
      It will print when Promises are launched and resolved, although it's not
      yet possible to break at those points.
      Closes: #110
  6. 20 Jul, 2018 3 commits
  7. 12 Jun, 2018 1 commit
    • Philip Chimento's avatar
      object: Move imports._gi.hook_up_vfunc() to be a method · 8fb7b4e1
      Philip Chimento authored
      Since we're required to pass in a GObject prototype to
      imports._gi.hook_up_vfunc(), it makes sense to make it a method of the
      prototype. It's still only accessible by importing _gi, as we give it a
      symbol name which is exposed as imports._gi.hook_up_vfunc_symbol.
  8. 01 May, 2018 1 commit
  9. 21 Apr, 2018 1 commit
    • Andy Holmes's avatar
      overrides: support Gtk template callbacks · bcfa6ce7
      Andy Holmes authored
      * Throw an error if template signal uses the 'object' attribute since we don't support GObject.signal_connect_object()
      * Throw an error if template signal sets the 'swapped' attribute to 'true' since we don't support GObject.signal_connect_swapped() or @user_data
      * Respect the flag for GObject.signal_connect_after()
      * Throw an error if template signal uses the 'object' attribute
      * Amend error messages to make it clearer they are template errors
      * call set_connect_func() on the constructor object
  10. 29 Mar, 2018 1 commit
  11. 24 Mar, 2018 4 commits
  12. 20 Mar, 2018 2 commits
    • Philip Chimento's avatar
      linter: Allow _init in modules/overrides · 54714417
      Philip Chimento authored
      This adds a linter rule specifically to the modules/overrides directory
      that treats the name _init as exported. That is, the linter will not
      complain if an _init is defined and not used.
      [skip eslint] because this doesn't just remove linter warnings, it
      changes the messages a bit. The linter job isn't smart enough to deal
      with that.
    • Philip Chimento's avatar
      overrides: Add override for Cairo that merges in imports.cairo · 38f1b73f
      Philip Chimento authored
      It's confusing to have two incompatible ways to import Cairo. This makes
      sure that when you use imports.gi.cairo, it merges in imports.cairo as
      well. (imports.gi.cairo is only needed in a few cases, so I'm not going
      to worry about the reverse right now.)
      Closes #126.
  13. 03 Mar, 2018 1 commit
    • Florian Müllner's avatar
      overrides/Gio: Add D-Bus convenience to more proxy methods · 90a9ab40
      Florian Müllner authored
      Currently it's only added to GDBusProxy's g_initable_init() and
      g_async_initable_async() methods used by makeProxyWrapper(). But
      there are use cases for not using the wrapper, for example to pass
      a custom g-flags property; GDBusProxy's convenience constructors
      may be more convenient than g_object_new()+g_initable_init(), so
      monkey-patch them as well.
  14. 23 Feb, 2018 2 commits
  15. 29 Jan, 2018 1 commit
    • Giovanni Campagna's avatar
      Allow using GObject.signal_* functions in place of Object methods · 75478411
      Giovanni Campagna authored
      GObject.Object.connect() and friends might be unavailable because
      shadowed by another method in the prototype chain (such as
      In that case, it is nice to use the C equivalents, which are
      GObject.signal_connect(), GObject.signal_handler_disconnect() and
      (Philip Chimento: Rebased, ported test to Jasmine, and fixed coding
      Closes #65.
  16. 22 Jan, 2018 1 commit
    • Philip Chimento's avatar
      js: Remove context from GjsAutoJSChar · 93551813
      Philip Chimento authored
      SpiderMonkey now clarifies in the comments in their header file, that
      it's OK to pass a null JSContext to JS_free(cx, ptr). This allows us to
      stop tracking the JSContext in GjsAutoJSChar, which was a big pain.
  17. 29 Dec, 2017 1 commit
  18. 20 Nov, 2017 1 commit
    • Philip Chimento's avatar
      jsapi-util-string: Use mozjs UTF8-to-JSString conversion · 6fa31261
      Philip Chimento authored
      There are two paths for decoding UTF8 strings directly to JSString:
      JS_NewStringCopyUTF8N() and JS_NewStringCopyUTF8Z(). Mostly we have a
      zero-terminated string in GJS, so we shorten gjs_string_from_utf8() to
      remove its string length argument and use JS_NewStringCopyUTF8Z().
      There are a few places where we have a non-zero-terminated string, so we
      introduce gjs_string_from_utf8_n() to handle that path.
      A few places we were doing a UTF8 conversion where it was not necessary.
  19. 30 Oct, 2017 1 commit
    • Florian Müllner's avatar
      legacy: Allow ES6 classes to inherit from abstract Lang.Class class · cf551d9d
      Florian Müllner authored
      Currently Lang.Class uses a distinct constructor for abstract classes,
      which just throws when instantiated. This works as Lang.Class classes
      chain up to _init rather than the real constructor, which isn't the
      case for ES6 classes. In order to allow ES6 classes to directly inherit
      from an abstract Lang.Class class, check whether an abstract class
      has been instantiated directly inside the regular constructor.
  20. 29 Oct, 2017 1 commit
  21. 05 Oct, 2017 1 commit
    • Philip Chimento's avatar
      coverage: Use LCOV data from SpiderMonkey · b7c93435
      Philip Chimento authored
      SpiderMonkey now provides its own coverage data conveniently already
      formatted as LCOV output. It does have a few quirks and so requires a bit
      of adjustment in the tests, but it allows us to drop a few thousand lines
      of custom code.
      Differences between the old LCOV data and the new:
       - There is always a function named "top-level" in each file.
       - Anything on line 1 seems to be ignored.
       - Branches can appear in different order.
       - There's no difference between not-taken and not-executed branches.
         They always appear as not-executed.
  22. 04 Oct, 2017 1 commit
    • Philip Chimento's avatar
      jsapi-util: Remove jsapi-private · e23b19ef
      Philip Chimento authored
      Ever since removing the gjs-module API, there has not really been a
      distinction between "public" and "private" jsapi-util functions. Just
      remove the private files and incorporate everything declared or defined
      there into the other jsapi-util files.
  23. 29 Sep, 2017 1 commit
  24. 27 Sep, 2017 2 commits