1. 23 Apr, 2019 4 commits
  2. 22 Apr, 2019 5 commits
    • Cosimo Cecchi's avatar
      Merge branch 'cairo-conversion-bugs' into 'master' · 0bdae390
      Cosimo Cecchi authored
      Cairo conversion bugs
      See merge request !286
    • Cosimo Cecchi's avatar
      Merge branch '240-fix-boxed-pointer-ownership' into 'master' · 1bedcf89
      Cosimo Cecchi authored
      boxed: Track ownership of boxed pointer better
      Closes #240
      See merge request !285
    • Philip Chimento's avatar
      cairo: Don't free unowned Cairo structs · 0038bf9a
      Philip Chimento authored
      It seems that in all other release functions, we don't free the
      GIArgument's data in the transfer-none case. That would end up freeing
      a passed-in argument that was owned by the caller, or a return value
      that was owned by the callee.
      This bug was spotted by compiling with -Wunused-parameter.
    • Philip Chimento's avatar
      cairo: Take may_be_null into account in foreign struct conversion · 17021714
      Philip Chimento authored
      Previously, when converting from a Cairo struct to a GIArgument, the
      "may_be_null" parameter would be ignored and a null pointer was always
      accepted (and then would probably crash, although this seems to be an
      unlikely case as we never got any bug reports of it.)
      Instead, we do a null check, and throw a JS exception if needed, in the
      foreign struct conversion callbacks in the various Cairo types.
      Requires exposing a previously static function in arg.cpp so that the
      thrown exceptions can have more useful messages.
      This bug was found with -Wunused-parameter.
    • Philip Chimento's avatar
      boxed: Track ownership of boxed pointer better · caa79be3
      Philip Chimento authored
      This is the second bug of this type that I've fixed since refactoring
      this code, so clearly we need to do something differently. We rename
      m_not_owning_ptr to m_owning_ptr and make sure it starts out false (so
      that we never try to free a pointer if it wasn't assigned yet.) Then we
      introduce two methods for setting the m_ptr field: own_ptr() which sets
      m_owning_ptr, and share_ptr() which does not. We use these methods
      consistently everywhere that we previously set m_ptr directly.
      Closes: #240
  3. 16 Apr, 2019 5 commits
  4. 14 Apr, 2019 23 commits
    • Cosimo Cecchi's avatar
      Merge branch 'march-maintenance' into 'master' · cebddb1a
      Cosimo Cecchi authored
      March maintenance
      See merge request !279
    • Philip Chimento's avatar
      wrapperutils: Move TypecheckNoThrow type out of template · a0e59bce
      Philip Chimento authored
      Due to the TypecheckNoThrow type being defined inside the GIWrapper
      template, the compiler would consider e.g. ObjectBase::TypecheckNoThrow
      to be a different type than BoxedBase::TypecheckNoThrow. It's not
      really necessary to differentiate those types, so we move the type
      outside of the template.
    • Philip Chimento's avatar
      CI: Discard stdout of cpplint · 1d167cc8
      Philip Chimento authored
      It turns out that mixing stderr and stdout of cpplint is not a good idea
      as it will occasionally intermix "Done processing foo.cpp" lines on
      stdout, with linter error lines on stderr. When one such linter error is
      eliminated, the stdout line will be intermixed with a different stderr
      line, causing a spurious "new" error to appear.
      We redirect stdout to /dev/null to just avoid the "Done processing" and
      "Total errors found" lines altogether.
    • Philip Chimento's avatar
      jsapi-util-args: Remove unused argument · 318d2acb
      Philip Chimento authored
      ignore_trailing_args isn't needed once we check the number of arguments,
      so there's no need to pass it into parse_call_args_helper.
    • Philip Chimento's avatar
      context: Change EnvironmentPreparer to protected inheritance · 821557e7
      Philip Chimento authored
      This avoids a compiler warning due to js::ScriptEnvironmentPreparer
      having virtual methods but not a virtual destructor. Since we are not
      intending to use this class polymorphically, the virtual destructor
      should not matter.
    • Philip Chimento's avatar
      atoms: Remove unused argument · ea9b5412
      Philip Chimento authored
      The constructor of GjsAtoms doesn't need a JSContext argument. Any
      fallible initialization is done in GjsAtoms::init_atoms().
    • Philip Chimento's avatar
      wrapperutils: Remove unnecessary semicolon · 8553b435
      Philip Chimento authored
      This is a compiler warning on some compilers.
    • Philip Chimento's avatar
      arg: Remove unused argument · 94c95433
      Philip Chimento authored
      Rename gjs_g_argument_init_default() to gjs_gi_argument_... since the
      GArgument type was also renamed to GIArgument, and remove the unused
      JSContext argument from it.
    • Philip Chimento's avatar
      tests: Don't remove log handler during test · 40a5a964
      Philip Chimento authored
      I'm not sure why this was here, but it seems to be no longer necessary.
      If it becomes necessary in the future, then we should use
      g_test_expect_message() instead.
    • Philip Chimento's avatar
      tests: Don't output generated coverage data · ceacc92e
      Philip Chimento authored
      This was quite useful, but because it contains newlines, sadly, it makes
      the output invalid according to the TAP protocol (each line would have
      to be prefixed with '#'.) The Autotools TAP harness ignores this, but
      other TAP harnesses such as Meson's don't.
    • Philip Chimento's avatar
      build: Build modules into libgjs · e80ff833
      Philip Chimento authored
      The built-in modules (imports.system, imports.console, imports.cairo)
      were previously built as convenience libraries, and then linked into
      libgjs. There is really no reason to do this, we can just treat their
      source files as libgjs source files and build them directly into the
    • Philip Chimento's avatar
      build: Remove unused defines · d8c766c4
      Philip Chimento authored
      These no longer seem to be used.
    • Philip Chimento's avatar
      build: Remove GETTEXT_PACKAGE variable · beea06eb
      Philip Chimento authored
      GJS doesn't use gettext for translations, so we don't need to have this
      variable defined.
    • Philip Chimento's avatar
      build: Move locale choosing into separate script · 94933c9c
      Philip Chimento authored
      In order to port to Meson in the future, we'll need to have this
      functionality in a separate script. Splitting it out now and using the
      script in the Autotools build will be handy if we decide to keep the two
      build systems in parallel for a while.
    • Philip Chimento's avatar
      function: Add more marshalling debug logs · be687283
      Philip Chimento authored
      Add some debug log statements explaining a bit more about what is
      happening when arguments are converted to and from introspected
      There should be no performance concern about adding these logging
      statements, because they are ifdef'd out unless you build with
    • Philip Chimento's avatar
      arg: Factor interface case out of gjs_value_to_g_argument() · 2f37bb3c
      Philip Chimento authored
      gjs_value_to_g_argument() is an extremely long function, long enough
      that the style checker complains every time lines are added to or
      removed from it. It consists of a very long switch statement. This
      extracts the longest case of that switch statement into its own
      function, so we now have a function of less than 500 lines and the
      checker will stop complaining.
      That is advantageous in its own right, because now we can return on
      success or failure. In the larger surrounding switch statement, for
      failure you had to set "wrong = true" and then fall through. The code is
      really confusing to read, but in this function it's now slightly less
    • Philip Chimento's avatar
      object: Port object_init_list to GCVector · c5c8d9f5
      Philip Chimento authored
      Previously we used a std::stack with individual instances of
      JS::PersistentRootedObject in it, to hold a list of JSObjects in between
      the time of their creation and the time their GObject instance init
      function runs. This is wasteful because each individual PersistentRooted
      is part of a linked list of permanently rooted objects. Instead, we can
      put them in a GCVector and persistently root the whole thing once.
      We also move that storage from a static variable to a member of the
      GjsContext class.
    • Philip Chimento's avatar
      context: Use tracing for promise job queue · ad90c931
      Philip Chimento authored
      Previously we used PersistentRooted to prevent the promise job queue
      from being garbage collected. This is how it was done in SpiderMonkey's
      demo interactive interpreter. However, PersistentRooted can be wasteful
      of resources since it links everything into a big linked list. We
      already have a trace() callback for GjsContextPrivate, so we can just
      trace the promise job objects in there.
    • Philip Chimento's avatar
      object: Move to C++-style API · 615f4eb2
      Philip Chimento authored
      This allows cleaning up the public API in object.h a bit, creating some
      new methods that can be used rather than the C-style APIs, changing some
      methods to be private, and adding missing error checks in calling code.
      The idea is to gradually provide more typesafe, C++-style APIs for all
      of the GI wrapper classes, and change calling code to use them rather
      than the old C-style APIs.
    • Philip Chimento's avatar
      gerror: Move to C++-style API · 91434941
      Philip Chimento authored
      This allows cleaning up the public API in gerror.h a bit, adding missing
      error checks in calling code, removing C API that only called C++ API,
      and creating an ErrorInstance::object_for_c_ptr() method.
      The idea is to gradually provide more typesafe, C++-style APIs for all
      of the GI wrapper classes, and change calling code to use them rather
      than the old C-style APIs.
    • Philip Chimento's avatar
      boxed: Move to C++-style API · 14f1253c
      Philip Chimento authored
      This allows cleaning up the public API in boxed.h a bit, changing some
      methods to be private, adding missing error checks in calling code, and
      creating a BoxedInstance::new_for_c_struct() method with a
      BoxedInstance::NoCopy overload.
      The idea is to gradually provide more typesafe, C++-style APIs for all
      of the GI wrapper classes, and change calling code to use them rather
      than the old C-style APIs.
    • Philip Chimento's avatar
      wrapperutils: Use GIWrapperBase::typecheck() directly in calling code · ec595f81
      Philip Chimento authored
      This removes the gjs_typecheck_foo() methods (which by now only call
      GIWrapperBase::typecheck() anyway) in favour of calling typecheck()
    • Philip Chimento's avatar
      wrapperutils: Factor out to_c_ptr() and transfer_to_gi_argument() · bd80e62d
      Philip Chimento authored
      This adds two methods to GIWrapperBase:
      - to_c_ptr() takes the place of the gjs_g_foo_from_foo() functions (e.g.
      - transfer_to_gi_argument() implements the most common use case of
        to_c_ptr(), used in arg.cpp and function.cpp to transfer values from
        JS to GIArgument in order to pass into an introspected function, or
        to return from a callback implemented in JS.
      (In object.cpp we have to provide slightly modified versions of those
      methods, since we have to deal with the case where the JS wrapper is
      still alive but the GObject has been disposed.)
      This is part of the plan to gradually provide more typesafe, C++-style
      APIs for all of the GI wrapper classes. It also moves code out of the
      long confusing switch statements in arg.cpp and function.cpp.
  5. 13 Apr, 2019 3 commits
    • Philip Chimento's avatar
    • Philip Chimento's avatar
      value: Support marshalling custom fundamental types · 067e7d75
      Philip Chimento authored
      Previously, passing a custom fundamental type to a function with a
      GValue argument would throw a JS exception.
      Fundamental types in g-i have a "set_value_function" which tells how to
      convert them to a GValue. We were already storing a pointer to this
      function in FundamentalPrototype, but never used it anywhere. This adds
      API to FundamentalBase and a code path in gjs_value_to_g_value() which
      calls the set_value_function.
      Arguably this should be tried before the last-resort transform-to-int
      code in gjs_value_to_g_value_internal(), but it's not clear that that
      would preserve existing behaviour.
    • Philip Chimento's avatar
      gtype: Port weak pointer hash table to WeakCache · c7e38343
      Philip Chimento authored
      As in a previous change in fundamental.cpp, JS::WeakCache allows us to
      get rid of the weak pointer callback, as that is all implemented
      internally. The hash table is automatically swept when the GType wrapper
      objects are garbage collected.
      We move the table to GjsContextPrivate instead of using a static
      variable. Although there is probably little difference in practice, that
      is a more accurate place to store it, in case there is more than one
      GjsContext in use.