Commit 69c874a7 authored by Simon McVittie's avatar Simon McVittie

New upstream version 1.54.1

parents 8efdd760 f9fc622d
EXTRA_DIST += \
installed-tests/debugger.test.in \
installed-tests/minijasmine.test.in \
installed-tests/script.test.in \
installed-tests/js/jsunit.gresources.xml \
......@@ -55,4 +56,6 @@ pkglib_LTLIBRARIES += libregress.la libwarnlib.la libgimarshallingtests.la
< $(srcdir)/installed-tests/script.test.in > $@.tmp && \
mv $@.tmp $@
CLEANFILES += $(installedtestmeta_DATA)
endif BUILDOPT_INSTALL_TESTS
......@@ -201,7 +201,7 @@ EXTRA_DIST += \
TAG_PREFIX=GJS_
COMPRESSION=.bz2
DISTCLEANFILES=gjs-*.syscap installed-tests/scripts/*.test installed-tests/js/*.test
DISTCLEANFILES=gjs-*.syscap
PACKAGE=@PACKAGE@
VERSION=@VERSION@
......
......@@ -138,6 +138,7 @@ gjsinsttest_PROGRAMS = $(am__EXEEXT_1)
@BUILDOPT_INSTALL_TESTS_TRUE@am__append_24 = $(simple_tests)
@BUILDOPT_INSTALL_TESTS_TRUE@am__append_25 = $(debugger_tests)
@BUILDOPT_INSTALL_TESTS_TRUE@am__append_26 = libregress.la libwarnlib.la libgimarshallingtests.la
@BUILDOPT_INSTALL_TESTS_TRUE@am__append_27 = $(installedtestmeta_DATA)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
......@@ -278,10 +279,11 @@ am__libgjs_la_SOURCES_DIST = gi/arg.cpp gi/arg.h gi/boxed.cpp \
gi/repo.cpp gi/repo.h gi/toggle.cpp gi/toggle.h gi/union.cpp \
gi/union.h gi/value.cpp gi/value.h gjs/byteArray.cpp \
gjs/byteArray.h gjs/context.cpp gjs/context-private.h \
gjs/coverage.cpp gjs/debugger.cpp gjs/engine.cpp gjs/engine.h \
gjs/global.cpp gjs/global.h gjs/importer.cpp gjs/importer.h \
gjs/jsapi-class.h gjs/jsapi-dynamic-class.cpp \
gjs/jsapi-util.cpp gjs/jsapi-util.h gjs/jsapi-util-args.h \
gjs/coverage.cpp gjs/debugger.cpp gjs/deprecation.cpp \
gjs/deprecation.h gjs/engine.cpp gjs/engine.h gjs/global.cpp \
gjs/global.h gjs/importer.cpp gjs/importer.h gjs/jsapi-class.h \
gjs/jsapi-dynamic-class.cpp gjs/jsapi-util.cpp \
gjs/jsapi-util.h gjs/jsapi-util-args.h \
gjs/jsapi-util-error.cpp gjs/jsapi-util-root.h \
gjs/jsapi-util-string.cpp gjs/jsapi-wrapper.h gjs/mem.h \
gjs/mem.cpp gjs/module.h gjs/module.cpp gjs/native.cpp \
......@@ -306,8 +308,9 @@ am__objects_3 = gi/libgjs_la-arg.lo gi/libgjs_la-boxed.lo \
gi/libgjs_la-union.lo gi/libgjs_la-value.lo \
gjs/libgjs_la-byteArray.lo gjs/libgjs_la-context.lo \
gjs/libgjs_la-coverage.lo gjs/libgjs_la-debugger.lo \
gjs/libgjs_la-engine.lo gjs/libgjs_la-global.lo \
gjs/libgjs_la-importer.lo gjs/libgjs_la-jsapi-dynamic-class.lo \
gjs/libgjs_la-deprecation.lo gjs/libgjs_la-engine.lo \
gjs/libgjs_la-global.lo gjs/libgjs_la-importer.lo \
gjs/libgjs_la-jsapi-dynamic-class.lo \
gjs/libgjs_la-jsapi-util.lo gjs/libgjs_la-jsapi-util-error.lo \
gjs/libgjs_la-jsapi-util-string.lo gjs/libgjs_la-mem.lo \
gjs/libgjs_la-module.lo gjs/libgjs_la-native.lo \
......@@ -423,6 +426,7 @@ am__depfiles_remade = \
gjs/$(DEPDIR)/libgjs_la-context.Plo \
gjs/$(DEPDIR)/libgjs_la-coverage.Plo \
gjs/$(DEPDIR)/libgjs_la-debugger.Plo \
gjs/$(DEPDIR)/libgjs_la-deprecation.Plo \
gjs/$(DEPDIR)/libgjs_la-engine.Plo \
gjs/$(DEPDIR)/libgjs_la-global.Plo \
gjs/$(DEPDIR)/libgjs_la-importer.Plo \
......@@ -1003,7 +1007,8 @@ BUILT_SOURCES = $(am__append_7) mock-js-resources.c jsunit-resources.h \
CLEANFILES = $(nodist_libmodules_resources_la_SOURCES) \
$(INTROSPECTION_GIRS) $(typelib_DATA) mock-js-resources.c \
jsunit-resources.c jsunit-resources.h $(NULL) \
$(TEST_INTROSPECTION_GIRS) $(TEST_INTROSPECTION_TYPELIBS)
$(TEST_INTROSPECTION_GIRS) $(TEST_INTROSPECTION_TYPELIBS) \
$(am__append_27)
EXTRA_DIST = gjs-1.0.pc.in gi/gjs_gi_probes.d $(tapset_in_files) \
$(modules_resource_files) \
$(srcdir)/modules/modules.gresource.xml examples/clutter.js \
......@@ -1020,6 +1025,7 @@ EXTRA_DIST = gjs-1.0.pc.in gi/gjs_gi_probes.d $(tapset_in_files) \
$(NULL) $(simple_tests) $(debugger_tests) \
$(debugger_tests:%=%.js) $(debugger_tests:%=%.output) $(NULL) \
installed-tests/debugger-test.sh \
installed-tests/debugger.test.in \
installed-tests/minijasmine.test.in \
installed-tests/script.test.in \
installed-tests/js/jsunit.gresources.xml $(NULL) autogen.sh \
......@@ -1110,6 +1116,8 @@ gjs_srcs = \
gjs/context-private.h \
gjs/coverage.cpp \
gjs/debugger.cpp \
gjs/deprecation.cpp \
gjs/deprecation.h \
gjs/engine.cpp \
gjs/engine.h \
gjs/global.cpp \
......@@ -1551,7 +1559,7 @@ pkglib_LTLIBRARIES = $(am__append_26)
# Customize to taste
TAG_PREFIX = GJS_
COMPRESSION = .bz2
DISTCLEANFILES = gjs-*.syscap installed-tests/scripts/*.test installed-tests/js/*.test
DISTCLEANFILES = gjs-*.syscap
DISTNAME = $(PACKAGE)-$(VERSION).tar$(COMPRESSION)
TAG_VERSION := $(shell echo $(VERSION) | $(SED) s/\\\./_/g)
CPPCHECK = cppcheck
......@@ -1920,6 +1928,8 @@ gjs/libgjs_la-coverage.lo: gjs/$(am__dirstamp) \
gjs/$(DEPDIR)/$(am__dirstamp)
gjs/libgjs_la-debugger.lo: gjs/$(am__dirstamp) \
gjs/$(DEPDIR)/$(am__dirstamp)
gjs/libgjs_la-deprecation.lo: gjs/$(am__dirstamp) \
gjs/$(DEPDIR)/$(am__dirstamp)
gjs/libgjs_la-engine.lo: gjs/$(am__dirstamp) \
gjs/$(DEPDIR)/$(am__dirstamp)
gjs/libgjs_la-global.lo: gjs/$(am__dirstamp) \
......@@ -2115,6 +2125,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@gjs/$(DEPDIR)/libgjs_la-context.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@gjs/$(DEPDIR)/libgjs_la-coverage.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@gjs/$(DEPDIR)/libgjs_la-debugger.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@gjs/$(DEPDIR)/libgjs_la-deprecation.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@gjs/$(DEPDIR)/libgjs_la-engine.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@gjs/$(DEPDIR)/libgjs_la-global.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@gjs/$(DEPDIR)/libgjs_la-importer.Plo@am__quote@ # am--include-marker
......@@ -2567,6 +2578,13 @@ gjs/libgjs_la-debugger.lo: gjs/debugger.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgjs_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gjs/libgjs_la-debugger.lo `test -f 'gjs/debugger.cpp' || echo '$(srcdir)/'`gjs/debugger.cpp
gjs/libgjs_la-deprecation.lo: gjs/deprecation.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgjs_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT gjs/libgjs_la-deprecation.lo -MD -MP -MF gjs/$(DEPDIR)/libgjs_la-deprecation.Tpo -c -o gjs/libgjs_la-deprecation.lo `test -f 'gjs/deprecation.cpp' || echo '$(srcdir)/'`gjs/deprecation.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) gjs/$(DEPDIR)/libgjs_la-deprecation.Tpo gjs/$(DEPDIR)/libgjs_la-deprecation.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gjs/deprecation.cpp' object='gjs/libgjs_la-deprecation.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgjs_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gjs/libgjs_la-deprecation.lo `test -f 'gjs/deprecation.cpp' || echo '$(srcdir)/'`gjs/deprecation.cpp
gjs/libgjs_la-engine.lo: gjs/engine.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgjs_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT gjs/libgjs_la-engine.lo -MD -MP -MF gjs/$(DEPDIR)/libgjs_la-engine.Tpo -c -o gjs/libgjs_la-engine.lo `test -f 'gjs/engine.cpp' || echo '$(srcdir)/'`gjs/engine.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) gjs/$(DEPDIR)/libgjs_la-engine.Tpo gjs/$(DEPDIR)/libgjs_la-engine.Plo
......@@ -3624,6 +3642,7 @@ distclean: distclean-am
-rm -f gjs/$(DEPDIR)/libgjs_la-context.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-coverage.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-debugger.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-deprecation.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-engine.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-global.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-importer.Plo
......@@ -3754,6 +3773,7 @@ maintainer-clean: maintainer-clean-am
-rm -f gjs/$(DEPDIR)/libgjs_la-context.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-coverage.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-debugger.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-deprecation.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-engine.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-global.Plo
-rm -f gjs/$(DEPDIR)/libgjs_la-importer.Plo
......
Version 1.54.1
--------------
- Closed bugs and merge requests:
* legacy: Ensure generated GType names are valid [!229, Florian Müllner]
* Fix GJS profiler with MozJS 60 [!230, Georges Basile Stavracas Neto]
* Regression with DBus proxies [#202, !231, Philip Chimento]
Version 1.54.0
--------------
- Compatibility fix for byte arrays: the legacy toString() behaviour of byte
arrays returned from GObject-introspected functions is now restored. If you
use the functionality, a warning will be logged asking you to upgrade your
code.
- Closed bugs and merge requests:
* byteArray: Add compatibility toString property [Philip Chimento, !227]
Version 1.53.92
---------------
- Technology preview of a GNOME 3.32 feature: native Promises for GIO-style
asynchronous operations. This is the result of Avi Zajac's summer internship.
To use it, you can opt in once for each specific asynchronous method, by
including code such as the following:
Gio._promisify(Gio.InputStream.prototype, 'read_bytes_async',
'read_bytes_finish');
After executing this, you will be able to use native Promises with the
Gio.InputStream.prototype.read_async() method, simply by not passing a
callback to it:
try {
let bytes = await stream.read_bytes_async(count, priority, cancel);
} catch (e) {
logError(e, 'Failed to read bytes');
}
Note that any "success" boolean return values are deleted from the array of
return values from the async method. That is,
let [contents, etag] = file.load_contents_async(cancel);
whereas the callback version still returns a useless [ok, contents, etag]
that can never be false, since on false an exception would be thrown. In the
callback version, we must keep this for compatibility reasons.
Note that due to a bug in GJS (https://gitlab.gnome.org/GNOME/gjs/issues/189),
promisifying methods on Gio.File.prototype and other interface prototypes will
not work. We provide the API Gio._LocalFilePrototype on which you can
promisify methods that will work on Gio.File instances on the local disk only:
Gio._promisify(Gio._LocalFilePrototype, 'load_contents_async',
'load_contents_finish');
We estimate this will cover many common use cases.
Since this is a technology preview, we do not guarantee API stability with
the version coming in GNOME 3.32. These APIs are marked with underscores to
emphasize that they are not stable yet. Use them at your own risk.
- Closed bugs and merge requests:
* Added promisify to GJS GIO overrides [!225, Avi Zajac]
* Temporary fix for Gio.File.prototype [!226, Avi Zajac]
Version 1.53.91
---------------
- Closed bugs and merge requests:
* CI: add webkit and gtk-app tests [!222, Claudio André]
* Fix example eslint errors [!207, Claudio André, Philip Chimento]
* Fix more "lost" GInterface properties [!223, Florian Müllner]
* Fix --enable-installed-tests when built from a tarball [!224, Simon
McVittie]
Version 1.53.90
---------------
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for gjs 1.53.90.
# Generated by GNU Autoconf 2.69 for gjs 1.54.1.
#
# Report bugs to <http://bugzilla.gnome.org/enter_bug.cgi?product=gjs>.
#
......@@ -591,8 +591,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='gjs'
PACKAGE_TARNAME='gjs'
PACKAGE_VERSION='1.53.90'
PACKAGE_STRING='gjs 1.53.90'
PACKAGE_VERSION='1.54.1'
PACKAGE_STRING='gjs 1.54.1'
PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=gjs'
PACKAGE_URL='https://wiki.gnome.org/Projects/Gjs'
......@@ -1453,7 +1453,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures gjs 1.53.90 to adapt to many kinds of systems.
\`configure' configures gjs 1.54.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1523,7 +1523,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of gjs 1.53.90:";;
short | recursive ) echo "Configuration of gjs 1.54.1:";;
esac
cat <<\_ACEOF
......@@ -1705,7 +1705,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
gjs configure 1.53.90
gjs configure 1.54.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2256,7 +2256,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gjs $as_me 1.53.90, which was
It was created by gjs $as_me 1.54.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -3119,7 +3119,7 @@ fi
# Define the identity of the package.
PACKAGE='gjs'
VERSION='1.53.90'
VERSION='1.54.1'
cat >>confdefs.h <<_ACEOF
......@@ -3346,10 +3346,10 @@ ac_config_headers="$ac_config_headers config.h"
GJS_VERSION=15390
GJS_VERSION=15401
$as_echo "#define GJS_VERSION (1 * 100 + 53) * 100 + 90" >>confdefs.h
$as_echo "#define GJS_VERSION (1 * 100 + 54) * 100 + 1" >>confdefs.h
GETTEXT_PACKAGE=gjs
......@@ -23916,7 +23916,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by gjs $as_me 1.53.90, which was
This file was extended by gjs $as_me 1.54.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -23987,7 +23987,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
gjs config.status 1.53.90
gjs config.status 1.54.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
m4_define(pkg_major_version, 1)
m4_define(pkg_minor_version, 53)
m4_define(pkg_micro_version, 90)
m4_define(pkg_minor_version, 54)
m4_define(pkg_micro_version, 1)
m4_define(pkg_version, pkg_major_version.pkg_minor_version.pkg_micro_version)
m4_define(pkg_int_version, (pkg_major_version * 100 + pkg_minor_version) * 100 + pkg_micro_version)
......
......@@ -4,14 +4,15 @@ Clutter.init(null);
let stage = new Clutter.Stage();
let texture = new Clutter.Texture({ filename: 'test.jpg',
reactive: true });
texture.connect('button-press-event',
function(o, event) {
log('Clicked!');
return true;
});
let texture = new Clutter.Texture({
filename: 'test.jpg',
reactive: true,
});
texture.connect('button-press-event', () => {
log('Clicked!');
return Clutter.EVENT_STOP;
});
let color = new Clutter.Color();
color.from_string('Black');
......
......@@ -11,7 +11,7 @@ function cat(filename) {
try {
contents = f.load_contents_finish(res)[1];
} catch (e) {
log("*** ERROR: " + e.message);
logError(e);
loop.quit();
return;
}
......@@ -23,7 +23,7 @@ function cat(filename) {
}
if (ARGV.length != 1) {
printerr("Usage: gio-cat.js filename");
printerr('Usage: gio-cat.js filename');
} else {
cat(ARGV[0]);
}
// Include this in case both GTK3 and GTK4 installed, otherwise an exception
// will be thrown
imports.gi.versions.Gtk = "3.0";
imports.gi.versions.Gtk = '3.0';
const Gtk = imports.gi.Gtk;
// Initialize Gtk before you start calling anything from the import
......@@ -9,7 +9,7 @@ Gtk.init(null);
// Construct a top-level window
let window = new Gtk.Window ({
type: Gtk.WindowType.TOPLEVEL,
title: "A default title",
title: 'A default title',
default_width: 300,
default_height: 250,
// A decent example of how constants are mapped:
......@@ -20,11 +20,11 @@ let window = new Gtk.Window ({
// Object properties can also be set or changed after construction, unless they
// are marked construct-only.
window.title = "Hello World!";
window.title = 'Hello World!';
// This is a callback function
function onDeleteEvent(widget, event) {
log("delete-event emitted");
function onDeleteEvent() {
log('delete-event emitted');
// If you return false in the "delete_event" signal handler, Gtk will emit
// the "destroy" signal.
//
......@@ -36,20 +36,20 @@ function onDeleteEvent(widget, event) {
// When the window is given the "delete_event" signal (this is given by the
// window manager, usually by the "close" option, or on the titlebar), we ask
// it to call the onDeleteEvent() function as defined above.
window.connect("delete-event", onDeleteEvent);
window.connect('delete-event', onDeleteEvent);
// GJS will warn when calling a C function with unexpected arguments...
//
// window.connect("destroy", Gtk.main_quit);
//
// ...so use arrow functions for inline callbacks with arguments to adjust
window.connect("destroy", () => {
window.connect('destroy', () => {
Gtk.main_quit();
});
// Create a button to close the window
let button = new Gtk.Button({
label: "Close the Window",
label: 'Close the Window',
// Set visible to 'true' if you don't want to call button.show() later
visible: true,
// Another example of constant mapping:
......@@ -60,7 +60,7 @@ let button = new Gtk.Button({
});
// Connect to the 'clicked' signal, using another way to call an arrow function
button.connect("clicked", () => window.destroy());
button.connect('clicked', () => window.destroy());
// Add the button to the window
window.add(button);
......
......@@ -4,22 +4,22 @@ const Soup = imports.gi.Soup;
function main() {
let handler = function(server, msg, path, query, client) {
msg.status_code = 200;
msg.response_headers.set_content_type('text/html', {});
msg.response_body.append('<html><body>Greetings, visitor from ' + client.get_host() + '<br>What is your name?<form action="/hello"><input name="myname"></form></body></html>\n');
msg.status_code = 200;
msg.response_headers.set_content_type('text/html', {});
msg.response_body.append(`<html><body>Greetings, visitor from ${client.get_host()}<br>What is your name?<form action="/hello"><input name="myname"></form></body></html>\n`);
};
let helloHandler = function(server, msg, path, query, client) {
if (!query) {
let helloHandler = function(server, msg, path, query) {
if (!query) {
msg.set_redirect(302, '/');
return;
}
}
msg.status_code = 200;
msg.response_headers.set_content_type('text/html', { charset: 'UTF-8' });
msg.response_body.append('<html><body>Hello, ' + query.myname + '! \u263A<br><a href="/">Go back</a></body></html>');
msg.status_code = 200;
msg.response_headers.set_content_type('text/html', {charset: 'UTF-8'});
msg.response_body.append(`<html><body>Hello, ${query.myname}! ☺<br><a href="/">Go back</a></body></html>`);
};
let server = new Soup.Server({ port: 1080 });
let server = new Soup.Server({port: 1080});
server.add_handler('/', handler);
server.add_handler('/hello', helloHandler);
server.run();
......
......@@ -789,6 +789,7 @@ is_gobject_property_name(GIObjectInfo *info,
const char *name)
{
int n_props = g_object_info_get_n_properties(info);
int n_ifaces = g_object_info_get_n_interfaces(info);
int ix;
GjsAutoInfo<GIPropertyInfo> prop_info;
......@@ -802,6 +803,17 @@ is_gobject_property_name(GIObjectInfo *info,
prop_info.reset();
}
if (!prop_info) {
for (ix = 0; ix < n_ifaces; ix++) {
GjsAutoInfo<GIInterfaceInfo> iface_info =
g_object_info_get_interface(info, ix);
if (is_ginterface_property_name(iface_info, canonical_name)) {
g_free(canonical_name);
return true;
}
}
}
g_free(canonical_name);
if (!prop_info)
......
......@@ -59,6 +59,8 @@ gjs_srcs = \
gjs/context-private.h \
gjs/coverage.cpp \
gjs/debugger.cpp \
gjs/deprecation.cpp \
gjs/deprecation.h \
gjs/engine.cpp \
gjs/engine.h \
gjs/global.cpp \
......
......@@ -25,6 +25,7 @@
#include "byteArray.h"
#include "gi/boxed.h"
#include "gjs/deprecation.h"
#include "jsapi-util-args.h"
#include "jsapi-wrapper.h"
......@@ -45,22 +46,11 @@ static void bytes_unref_arraybuffer(void* contents, void* user_data) {
}
/* implement toString() with an optional encoding arg */
static bool
to_string_func(JSContext *context,
unsigned argc,
JS::Value *vp)
{
JS::CallArgs argv = JS::CallArgsFromVp(argc, vp);
GjsAutoJSChar encoding;
JS::RootedObject byte_array(context);
static bool to_string_impl(JSContext* context, JS::HandleObject byte_array,
const char* encoding, JS::MutableHandleValue rval) {
bool encoding_is_utf8;
uint8_t* data;
if (!gjs_parse_call_args(context, "toString", argv, "o|s",
"byteArray", &byte_array,
"encoding", &encoding))
return false;
if (encoding) {
/* maybe we should be smarter about utf8 synonyms here.
* doesn't matter much though. encoding_is_utf8 is
......@@ -80,7 +70,7 @@ to_string_func(JSContext *context,
* libmozjs hardwired utf8-to-utf16
*/
return gjs_string_from_utf8_n(context, reinterpret_cast<char*>(data),
len, argv.rval());
len, rval);
} else {
bool ok = false;
gsize bytes_written;
......@@ -109,7 +99,7 @@ to_string_func(JSContext *context,
s = JS_NewUCStringCopyN(context, u16_out, bytes_written / 2);
if (s != NULL) {
ok = true;
argv.rval().setString(s);
rval.setString(s);
}
g_free(u16_str);
......@@ -118,6 +108,35 @@ to_string_func(JSContext *context,
}
}
static bool to_string_func(JSContext* cx, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
GjsAutoJSChar encoding;
JS::RootedObject byte_array(cx);
if (!gjs_parse_call_args(cx, "toString", args, "o|s", "byteArray",
&byte_array, "encoding", &encoding))
return false;
return to_string_impl(cx, byte_array, encoding, args.rval());
}
/* Workaround to keep existing code compatible. This function is tacked onto
* any Uint8Array instances created in situations where previously a ByteArray
* would have been created. It logs a compatibility warning. */
static bool instance_to_string_func(JSContext* cx, unsigned argc,
JS::Value* vp) {
GJS_GET_THIS(cx, argc, vp, args, this_obj);
GjsAutoJSChar encoding;
_gjs_warn_deprecated_once_per_callsite(
cx, GjsDeprecationMessageId::ByteArrayInstanceToString);
if (!gjs_parse_call_args(cx, "toString", args, "|s", "encoding", &encoding))
return false;
return to_string_impl(cx, this_obj, encoding, args.rval());
}
static bool
to_gbytes_func(JSContext *context,
unsigned argc,
......@@ -227,6 +246,7 @@ from_string_func(JSContext *context,
if (!array_buffer)
return false;
obj = JS_NewUint8ArrayWithBuffer(context, array_buffer, 0, -1);
JS_DefineFunction(context, obj, "toString", instance_to_string_func, 1, 0);
argv.rval().setObject(*obj);
return true;
}
......@@ -264,6 +284,7 @@ from_gbytes_func(JSContext *context,
context, JS_NewUint8ArrayWithBuffer(context, array_buffer, 0, -1));
if (!obj)
return false;
JS_DefineFunction(context, obj, "toString", instance_to_string_func, 1, 0);
argv.rval().setObject(*obj);
return true;
......@@ -275,7 +296,10 @@ JSObject* gjs_byte_array_from_data(JSContext* cx, size_t nbytes, void* data) {
if (!array_buffer)
return nullptr;
return JS_NewUint8ArrayWithBuffer(cx, array_buffer, 0, -1);
JS::RootedObject array(cx,
JS_NewUint8ArrayWithBuffer(cx, array_buffer, 0, -1));
JS_DefineFunction(cx, array, "toString", instance_to_string_func, 1, 0);
return array;
}
JSObject* gjs_byte_array_from_byte_array(JSContext* cx, GByteArray* array) {
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/*
* Copyright (c) 2018 Philip Chimento <philip.chimento@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <string>
#include <unordered_set>
#include "gjs/context-private.h"
#include "gjs/deprecation.h"
#include "gjs/jsapi-util.h"
#include "gjs/jsapi-wrapper.h"
const char* messages[] = {
// None:
"(invalid message)",
// ByteArrayInstanceToString:
"Some code called array.toString() on a Uint8Array instance. Previously "
"this would have interpreted the bytes of the array as a string, but that "
"is nonstandard. In the future this will return the bytes as "
"comma-separated digits. For the time being, the old behavior has been "
"preserved, but please fix your code anyway to explicitly call ByteArray"
".toString(array).\n"
"(Note that array.toString() may have been called implicitly.)",
};
struct DeprecationEntry {
GjsDeprecationMessageId id;
std::string loc;
DeprecationEntry(GjsDeprecationMessageId an_id, const char* a_loc)
: id(an_id), loc(a_loc) {}
bool operator==(const DeprecationEntry& other) const {
return id == other.id && loc == other.loc;
}
};
namespace std {
template <>
struct hash<DeprecationEntry> {
size_t operator()(const DeprecationEntry& key) const {
return hash<int>()(key.id) ^ hash<std::string>()(key.loc);
}
};
}; // namespace std
static std::unordered_set<DeprecationEntry> logged_messages;
static char* get_callsite(JSContext* cx) {
JS::RootedObject stack_frame(cx);
if (!JS::CaptureCurrentStack(cx, &stack_frame,
JS::StackCapture(JS::MaxFrames(1))) ||
!stack_frame)
return nullptr;
JS::RootedValue v_frame(cx, JS::ObjectValue(*stack_frame));
JS::RootedString frame_string(cx, JS::ToString(cx, v_frame));
if (!frame_string)
return nullptr;
GjsAutoJSChar frame_utf8;
if (!gjs_string_to_utf8(cx, JS::StringValue(frame_string), &frame_utf8))
return nullptr;
return frame_utf8.release();
}
/* Note, this can only be called from the JS thread because it uses the full
* stack dump API and not the "safe" gjs_dumpstack() which can only print to
* stdout or stderr. Do not use this function during GC, for example. */
void _gjs_warn_deprecated_once_per_callsite(JSContext* cx,
const GjsDeprecationMessageId id) {
GjsAutoJSChar callsite = get_callsite(cx);
DeprecationEntry entry(id, callsite);
if (!logged_messages.count(entry)) {
JS::UniqueChars stack_dump = JS::FormatStackDump(cx, nullptr, false,
false, false);
g_warning("%s\n%s", messages[id], stack_dump.get());
logged_messages.insert(std::move(entry));
}
}
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/*
* Copyright (c) 2018 Philip Chimento <philip.chimento@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef GJS_DEPRECATION_H_
#define GJS_DEPRECATION_H_
#include "gjs/jsapi-wrapper.h"
enum GjsDeprecationMessageId {
None,
ByteArrayInstanceToString,
};
void _gjs_warn_deprecated_once_per_callsite(JSContext* cx,