summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Revert "arg-cache: Save space by not caching GType"wip/verdre/cache-gtypeJonas Dreßler2020-10-223-21/+22
| | | | | | | | | | | | | | As found in https://gitlab.gnome.org/GNOME/gjs/-/issues/361, getting the GType using g_registered_type_info_get_g_type() is very expensive and can make up for a significant part of the overhead when calling into a C function. Since the argument cache seems to be fairly small in a typical gnome-shell session (about 1300 entries), the total increased memory usage of about 10kB seems very reasonable given the benefits of the caching. This reverts commit adfb7dc3ba79b17b0cefa47f5249e9da917217ad.
* Merge branch 'issue-238' into 'master'Philip Chimento2020-10-152-1/+12
|\ | | | | | | | | | | | | Fixed error in _init() that prevented GType objects from being created Closes #238 See merge request GNOME/gjs!508
| * Fixed error in _init() that prevented GType objects from being created.Nina Pypchenko2020-10-152-1/+12
|/ | | | | | Improved the regression test, implementing Marco T's feedback. Closes #238.
* Merge branch 'gvalue-pass-object' into 'master'Philip Chimento2020-10-147-8/+149
|\ | | | | | | | | | | | | Support passing GValue as an actual pointer Closes #74 See merge request GNOME/gjs!507
| * test: Increase the timeout for the API tests testMarco Trevisan (Treviño)2020-10-141-1/+1
| |
| * arg-cache: Support passing GValue objects, not only generated-gvaluesMarco Trevisan (Treviño)2020-10-144-6/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we create a GValue using the actual constructor we're holding internally a boxed type, and in such case we don't have to try to convert it to another GValue to pass around, but we should just use it as our argument. However, this can't be computed when parsing the argument, but depends case-by-case, as per this when we've a GValue and this is an object containing an actual GValue, pass it around and remember that we've not to free the returned argument, as that will be handled by the boxed wrapper. This allows to finally use some Gtk functions to get GValue parameters as "in/out" parameters, and the gvalue copy function. Add tests checking that this is the case. Fixes #74
| * boxed: Also unset the GValue if allocated directlyMarco Trevisan (Treviño)2020-10-141-0/+2
| | | | | | | | | | | | | | | | In case we've an allocated-directly GValue, freeing its pointer is not enough, as it may contain a string or a more complex type that actual need further actions. So, in such case also unset the GValue.
| * arg-cache: Use simple boxed marshaller if we're handling a GValue methodMarco Trevisan (Treviño)2020-10-143-1/+81
|/ | | | | | | If our argument is a GValue and it's marked as the instance parameter, then it means we're calling a g_value_* function, and as per this we should not pass a temporary value but we can just pass the object we've initialized locally.
* arg: Improve debugging of numeric marshal conversionsMarco Trevisan (Treviño)2020-10-122-1/+16
|
* arg: Use template function to convert JS Array to G(S)ListMarco Trevisan (Treviño)2020-10-121-98/+61
| | | | (Philip: changed to use size_t index to iterate through array)
* arg: Use an unique template function to free G(S)ListMarco Trevisan (Treviño)2020-10-121-53/+42
|
* arg: Use a template function to generate Array from GList and GSListMarco Trevisan (Treviño)2020-10-121-56/+21
| | | | We can easily use different codepaths, choosing statically
* value: Use Gjs::js_value_to_c[_checked] to transform valuesMarco Trevisan (Treviño)2020-10-121-11/+18
|
* arg-cache: Use only one marshaller for all the numeric typesMarco Trevisan (Treviño)2020-10-121-30/+5
| | | | | | Now that we rely on static compiler checks for type safety and conversions, we can use just one function to handle the conversion of all the numerc types as the compiler will do the job for us.
* arg: Handle out-of-range error as part of the hashtable int key creationMarco Trevisan (Treviño)2020-10-121-16/+14
| | | | | No need to do this in other cases, so let's just throw early and retu false if this happens.
* gi: Use static argument type names instead of getting them from tagMarco Trevisan (Treviño)2020-10-121-22/+22
| | | | | | When using a template-typed function we already have the static type string available, so we don't need to call another function and use an extra parameter.
* arg: Don't create temporary values when array types have direct conversionMarco Trevisan (Treviño)2020-10-121-4/+16
| | | | | | | | So far when associating JS arrays to C ones we were always creating a temporary variable to store the value, before casting it to the final type, but in case we're handling arrays of types for which we've a direct conversion function, we don't need to do this, so in such case let's just call the conversion function on the array element.
* arg: Implement gjs_array_to_strv using the auto-arrayMarco Trevisan (Treviño)2020-10-123-30/+39
| | | | | | | | | | Even in this case we can just implement this using a specialized implementaiton of js_value_to_c. However, since the array contains new strings we also need to templatize the array allocation and free functions, so that we memzero it and we deeply free it in case we handle a GStrv. As per this, only set the last element to NULL on non-string arrays
* arg: Convert GValue arrays using auto functionMarco Trevisan (Treviño)2020-10-123-37/+15
| | | | | | GValue arrays are parsed as the other kinds of arrays, once we set up a proper js_value_to_c() for it, we can just rely on the default implementation.
* arg: Use only one single template-based function to create simple types arrayMarco Trevisan (Treviño)2020-10-123-234/+125
| | | | | | | | | | | | | | | | | | | | | | When creating arrays for simple types we can just reuse a single function with typed parameters and reuse functions to fetch the value from JS, storing it in the proper container. Added a specialization for boolean types and GType. However, since we need to make sure it's not confused with the same typedef'ed original type, we need to use the type tag as well. As per this, convert the js-value-inl utility functions to template functions with implicit values, and specialize the ones we need to. In particular we need a js_value_to_c() specialization for the GType tag that gets an object and fetches the gtype from it. We can just return in case of errors, as the generic function will take care of throwing, in case. All this permits a nice code cleanup and more type-safety. (Philip: Added char32_t specializations)
* release: Add NEWS from stable version 1.66.1Philip Chimento2020-10-081-0/+17
|
* Merge branch 'ewlsh/fix-fundamental-parameters' into 'master'Philip Chimento2020-10-081-2/+76
|\ | | | | | | | | | | | | Fix fundamental parameters. Closes #353 See merge request GNOME/gjs!506
| * arg-cache: Add fundamental marshaller.ewlsh/fix-fundamental-parametersEvan Welsh2020-10-081-2/+76
|/ | | | | | Addresses regression where fundamental objects cannot be passed into functions. Fixes #353
* Merge branch 'ewlsh/fix-null-pointers' into 'master'Philip Chimento2020-10-062-3/+10
|\ | | | | | | | | Prevent passing null pointers when not nullable. See merge request GNOME/gjs!503
| * Add test for not-nullable gpointer parameters.ewlsh/fix-null-pointersEvan Welsh2020-10-011-0/+8
| | | | | | | | Use GLib.str_hash until Regress has a suitable test case.
| * Prevent passing null pointers when not nullable.Evan Welsh2020-10-011-3/+2
| | | | | | | | The arg-cache marshaller for null (pointers) doesn't check if the argument is nullable. This is a regression introduced by the arg-cache that can cause segfaults in functions such as GLib.str_hash.
* | Merge branch 'september-maintenance' into 'master'Philip Chimento2020-10-05290-3130/+627
|\ \ | | | | | | | | | | | | September maintenance See merge request GNOME/gjs!502
| * | CI: Add workaround for IWYU bugPhilip Chimento2020-10-041-0/+3
| | | | | | | | | | | | | | | For details see https://github.com/include-what-you-use/include-what-you-use/issues/226
| * | profiler: More specific struct initializer expressionsPhilip Chimento2020-10-041-4/+4
| | | | | | | | | | | | This is for compiling warning-free on Clang.
| * | tests: Remove constexpr from get_random_numberPhilip Chimento2020-10-041-1/+2
| | | | | | | | | | | | | | | | | | GCC accepts this, but when compiling with Clang we get an error that the random number generator cannot be instantiated in a constant expression. That makes sense.
| * | jsapi-util: Change upper limit of RSS trigger to uint32 maxPhilip Chimento2020-10-041-1/+1
| | | | | | | | | | | | | | | Rationale: this code was likely written on a 32-bit system in 2011 in which G_MAXULONG would have been 4294967295, not 18446744073709551615.
| * | jsapi-util: Remove unused value read from /proc/self/statPhilip Chimento2020-10-041-18/+18
| | | | | | | | | | | | | | | | | | | | | The vm_size that was read out of /proc/self/stat was not actually used anywhere, so don't read it. According to 'man proc', the correct sscanf specifier to read rss_size is %ld, meaning that it's a signed long int, so change that while we're here.
| * | maint: Mark parameters maybe_unused if only used in assertsPhilip Chimento2020-10-044-11/+14
| | | | | | | | | | | | This is in order to support compilation with G_DISABLE_ASSERT.
| * | CI: Make clang jobs actually use clangPhilip Chimento2020-10-041-0/+2
| | | | | | | | | | | | | | | Previously, these jobs were only using clang for compiling the few C files in the project.
| * | maint: Add dual MIT/LGPL license to all GJS files that didn't have onePhilip Chimento2020-10-04127-1/+200
| | | | | | | | | | | | | | | | | | 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: Replace clutter example image with a known license-free onePhilip Chimento2020-10-042-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | The provenance of this image wasn't known, so replace it with a new image that is known to be in the public domain. Downloaded from https://www.flickr.com/photos/135396164@N05/30127978380 Dedicated to the public domain, CC0-1.0.
| * | maint: Add GPL license and copyright to example copied from SeedPhilip Chimento2020-10-041-0/+2
| | | | | | | | | | | | | | | This example was originally copied from Seed's examples, so it gets the copyright and license information from Seed.
| * | maint: Add license to files that were copied from GLibPhilip Chimento2020-10-045-0/+11
| | | | | | | | | | | | | | | | | | | | | I copied the lcovrc and GLib's dependencies' wrap files from the GLib repository, so they need to get GLib's license. Except for zlib.wrap, which was copied from the Meson wrapdb, so it gets the license from https://github.com/mesonbuild/zlib/blob/master/LICENSE.build
| * | maint: Add MIT license to clang-format hooksPhilip Chimento2020-10-042-0/+2
| | | | | | | | | | | | Ref: https://github.com/barisione/clang-format-hooks/blob/master/COPYING
| * | maint: Convert all existing license/copyright comments to SPDX formatPhilip Chimento2020-10-04154-3037/+356
| | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | maint: Remove Mozilla license from stack.cppPhilip Chimento2020-10-042-42/+2
| | | | | | | | | | | | | | | The stack printer code that was copied from Mozilla was removed quite some time ago, we use js::DumpBacktrace now.
| * | examples: Fix Clutter examplePhilip Chimento2020-10-041-7/+4
| | | | | | | | | | | | I noticed it was broken while testing it with a new test.jpg image.
| * | maint: Remove weird indentation from Meson subproject filePhilip Chimento2020-10-041-5/+4
| | | | | | | | | | | | Probably a copy-paste error.
| * | maint: Remove obsolete unittest.gdbPhilip Chimento2020-10-041-4/+0
|/ / | | | | | | | | This script was used in a now-deleted Makefile rule. It's not used any more.
* | arg-cache: Use gjs_arg_set_from_js_value to set arguments from JSMarco Trevisan (Treviño)2020-10-011-69/+45
| | | | | | | | | | | | | | | | | | | | | | We already have a function to set a GArgument from the JS value, taking care of number conversions and out of bound errors, that is used in arg in the same way, so let's use this function to be consistent, ensuring that we can save each type in a container type big enough and that, in case we go out of bounds we can handle this correctly. Only use a simple function override, so that we can handle the out of bound errors the same way we used to do.
* | arg: Add a templated static type name functionMarco Trevisan (Treviño)2020-10-011-0/+90
| | | | | | | | | | | | This allows compile-time computation of the type name as a string. (Philip: split out from another commit)
* | js-value-inl: Add Support for GType and 64 bit integerMarco Trevisan (Treviño)2020-10-011-1/+28
| |
* | arg: Automatically set all the numeric values to GIArgumentsMarco Trevisan (Treviño)2020-10-013-77/+111
| | | | | | | | | | | | | | | | | | | | | | | | Use a template-function to convert all the JS Values to the proper c++ type and ensure they're within the valid ranges. As per this we need to use a more relaxed conversion to unsigned types using doubles not to have implicit conversion of negative types. Use a function override in order to keep a more generic version as inline implementation, while we specialize the out-of-range error handling per type
* | arg: Automatically figure out the proper container type for a JS valueMarco Trevisan (Treviño)2020-10-012-50/+101
|/ | | | | | | | | | | | Add template functions to get the JS value to a variable that is big enough to fit the requested type, doing also checks in case the resulting value is out of bounding for the requested type. This allows to redefine hashtable_int_key() so that there's no type checks and will allow to get values per type. Move the functions to a different header not to bother arg with such stuff that might be re-used also by other code paths
* Merge branch 'trampoline-cleanups' into 'master'Philip Chimento2020-09-207-255/+283
|\ | | | | | | | | Trampoline cleanups See merge request GNOME/gjs!491