[gjs: 4/43] js: Convert all tabs to spaces
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 4/43] js: Convert all tabs to spaces
- Date: Wed, 14 Aug 2019 17:27:24 +0000 (UTC)
commit 0ee1217b5555009dc48eb6304f3d47047ad174d2
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 3 23:22:34 2019 -0700
js: Convert all tabs to spaces
Use the no-tabs rule in eslint to enforce this in the future.
.eslintrc.yml | 1 +
examples/http-server.js | 4 +-
gi/function.cpp | 1 -
installed-tests/js/testExceptions.js | 4 +-
modules/lang.js | 2 +-
modules/mainloop.js | 4 +-
modules/overrides/GLib.js | 278 +++++++++++++++++------------------
7 files changed, 147 insertions(+), 147 deletions(-)
---
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 50da632d..f107b115 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -50,6 +50,7 @@ rules:
- object: Lang
property: Class
message: Use ES6 classes
+ no-tabs: error
nonblock-statement-body-position:
- error
- below
diff --git a/examples/http-server.js b/examples/http-server.js
index 1137bfe7..cbc6a75a 100644
--- a/examples/http-server.js
+++ b/examples/http-server.js
@@ -10,8 +10,8 @@ function main() {
};
let helloHandler = function(server, msg, path, query) {
if (!query) {
- msg.set_redirect(302, '/');
- return;
+ msg.set_redirect(302, '/');
+ return;
}
msg.status_code = 200;
diff --git a/gi/function.cpp b/gi/function.cpp
index 19b083f7..474904a8 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -126,7 +126,6 @@ set_return_ffi_arg_from_giargument (GITypeInfo *ret_type,
case GI_TYPE_TAG_BOOLEAN:
case GI_TYPE_TAG_UNICHAR:
*(ffi_arg *) result = return_value->v_uint32;
-
break;
case GI_TYPE_TAG_INT64:
*(ffi_sarg *) result = return_value->v_int64;
diff --git a/installed-tests/js/testExceptions.js b/installed-tests/js/testExceptions.js
index a2ce5b04..e1790dd1 100644
--- a/installed-tests/js/testExceptions.js
+++ b/installed-tests/js/testExceptions.js
@@ -6,11 +6,11 @@ const Foo = GObject.registerClass({
},
}, class Foo extends GObject.Object {
set prop(v) {
- throw new Error('set');
+ throw new Error('set');
}
get prop() {
- throw new Error('get');
+ throw new Error('get');
}
});
diff --git a/modules/lang.js b/modules/lang.js
index 49c80611..3cf2c5f5 100644
--- a/modules/lang.js
+++ b/modules/lang.js
@@ -86,7 +86,7 @@ function bind(obj, callback) {
// Use ES5 Function.prototype.bind, but only if not passing any bindArguments,
// because ES5 has them at the beginning, not at the end
if (arguments.length == 2)
- return callback.bind(obj);
+ return callback.bind(obj);
let me = obj;
let bindArguments = Array.prototype.slice.call(arguments, 2);
diff --git a/modules/mainloop.js b/modules/mainloop.js
index 892b61df..590d76d6 100644
--- a/modules/mainloop.js
+++ b/modules/mainloop.js
@@ -38,13 +38,13 @@ function run(name) {
function quit(name) {
if (!_mainLoops[name])
- throw new Error("No main loop with this id");
+ throw new Error("No main loop with this id");
let loop = _mainLoops[name];
_mainLoops[name] = null;
if (!loop.is_running())
- throw new Error("Main loop was stopped already");
+ throw new Error("Main loop was stopped already");
loop.quit();
}
diff --git a/modules/overrides/GLib.js b/modules/overrides/GLib.js
index f4887aee..2dbe50f5 100644
--- a/modules/overrides/GLib.js
+++ b/modules/overrides/GLib.js
@@ -29,39 +29,39 @@ function _read_single_type(signature, forceSimple) {
let isSimple = false;
if (SIMPLE_TYPES.indexOf(char) == -1) {
- if (forceSimple)
- throw new TypeError('Invalid GVariant signature (a simple type was expected)');
+ if (forceSimple)
+ throw new TypeError('Invalid GVariant signature (a simple type was expected)');
} else
- isSimple = true;
+ isSimple = true;
if (char == 'm' || char == 'a')
- return [char].concat(_read_single_type(signature, false));
+ return [char].concat(_read_single_type(signature, false));
if (char == '{') {
- let key = _read_single_type(signature, true);
- let val = _read_single_type(signature, false);
- let close = signature.shift();
- if (close != '}')
- throw new TypeError('Invalid GVariant signature for type DICT_ENTRY (expected "}"');
- return [char].concat(key, val, close);
+ let key = _read_single_type(signature, true);
+ let val = _read_single_type(signature, false);
+ let close = signature.shift();
+ if (close != '}')
+ throw new TypeError('Invalid GVariant signature for type DICT_ENTRY (expected "}"');
+ return [char].concat(key, val, close);
}
if (char == '(') {
- let res = [char];
- while (true) {
- if (signature.length == 0)
- throw new TypeError('Invalid GVariant signature for type TUPLE (expected ")")');
- let next = signature[0];
- if (next == ')') {
- signature.shift();
- return res.concat(next);
- }
- let el = _read_single_type(signature);
- res = res.concat(el);
- }
+ let res = [char];
+ while (true) {
+ if (signature.length == 0)
+ throw new TypeError('Invalid GVariant signature for type TUPLE (expected ")")');
+ let next = signature[0];
+ if (next == ')') {
+ signature.shift();
+ return res.concat(next);
+ }
+ let el = _read_single_type(signature);
+ res = res.concat(el);
+ }
}
// Valid types are simple types, arrays, maybes, tuples, dictionary entries and variants
if (!isSimple && char != 'v')
- throw new TypeError('Invalid GVariant signature (' + char + ' is not a valid type)');
+ throw new TypeError('Invalid GVariant signature (' + char + ' is not a valid type)');
return [char];
}
@@ -75,51 +75,51 @@ function _makeBytes(byteArray) {
function _pack_variant(signature, value) {
if (signature.length == 0)
- throw new TypeError('GVariant signature cannot be empty');
+ throw new TypeError('GVariant signature cannot be empty');
let char = signature.shift();
switch (char) {
case 'b':
- return GLib.Variant.new_boolean(value);
+ return GLib.Variant.new_boolean(value);
case 'y':
- return GLib.Variant.new_byte(value);
+ return GLib.Variant.new_byte(value);
case 'n':
- return GLib.Variant.new_int16(value);
+ return GLib.Variant.new_int16(value);
case 'q':
- return GLib.Variant.new_uint16(value);
+ return GLib.Variant.new_uint16(value);
case 'i':
- return GLib.Variant.new_int32(value);
+ return GLib.Variant.new_int32(value);
case 'u':
- return GLib.Variant.new_uint32(value);
+ return GLib.Variant.new_uint32(value);
case 'x':
- return GLib.Variant.new_int64(value);
+ return GLib.Variant.new_int64(value);
case 't':
- return GLib.Variant.new_uint64(value);
+ return GLib.Variant.new_uint64(value);
case 'h':
- return GLib.Variant.new_handle(value);
+ return GLib.Variant.new_handle(value);
case 'd':
- return GLib.Variant.new_double(value);
+ return GLib.Variant.new_double(value);
case 's':
- return GLib.Variant.new_string(value);
+ return GLib.Variant.new_string(value);
case 'o':
- return GLib.Variant.new_object_path(value);
+ return GLib.Variant.new_object_path(value);
case 'g':
- return GLib.Variant.new_signature(value);
+ return GLib.Variant.new_signature(value);
case 'v':
- return GLib.Variant.new_variant(value);
+ return GLib.Variant.new_variant(value);
case 'm':
- if (value != null)
- return GLib.Variant.new_maybe(null, _pack_variant(signature, value));
- else
- return GLib.Variant.new_maybe(new GLib.VariantType(_read_single_type(signature, false).join('')),
null);
+ if (value != null)
+ return GLib.Variant.new_maybe(null, _pack_variant(signature, value));
+ else
+ return GLib.Variant.new_maybe(new GLib.VariantType(_read_single_type(signature,
false).join('')), null);
case 'a': {
- let arrayType = _read_single_type(signature, false);
- if (arrayType[0] == 's') {
- // special case for array of strings
- return GLib.Variant.new_strv(value);
- }
- if (arrayType[0] == 'y') {
- // special case for array of bytes
+ let arrayType = _read_single_type(signature, false);
+ if (arrayType[0] == 's') {
+ // special case for array of strings
+ return GLib.Variant.new_strv(value);
+ }
+ if (arrayType[0] == 'y') {
+ // special case for array of bytes
let bytes;
if (typeof value === 'string') {
let byteArray = ByteArray.fromString(value);
@@ -129,82 +129,82 @@ function _pack_variant(signature, value) {
} else {
bytes = _makeBytes(value);
}
- return GLib.Variant.new_from_bytes(new GLib.VariantType('ay'),
+ return GLib.Variant.new_from_bytes(new GLib.VariantType('ay'),
bytes, true);
- }
-
- let arrayValue = [];
- if (arrayType[0] == '{') {
- // special case for dictionaries
- for (let key in value) {
- let copy = [].concat(arrayType);
- let child = _pack_variant(copy, [key, value[key]]);
- arrayValue.push(child);
- }
- } else {
- for (let i = 0; i < value.length; i++) {
- let copy = [].concat(arrayType);
- let child = _pack_variant(copy, value[i]);
- arrayValue.push(child);
- }
- }
- return GLib.Variant.new_array(new GLib.VariantType(arrayType.join('')), arrayValue);
+ }
+
+ let arrayValue = [];
+ if (arrayType[0] == '{') {
+ // special case for dictionaries
+ for (let key in value) {
+ let copy = [].concat(arrayType);
+ let child = _pack_variant(copy, [key, value[key]]);
+ arrayValue.push(child);
+ }
+ } else {
+ for (let i = 0; i < value.length; i++) {
+ let copy = [].concat(arrayType);
+ let child = _pack_variant(copy, value[i]);
+ arrayValue.push(child);
+ }
+ }
+ return GLib.Variant.new_array(new GLib.VariantType(arrayType.join('')), arrayValue);
}
case '(':
- let children = [ ];
- for (let i = 0; i < value.length; i++) {
- let next = signature[0];
- if (next == ')')
- break;
- children.push(_pack_variant(signature, value[i]));
- }
-
- if (signature[0] != ')')
- throw new TypeError('Invalid GVariant signature for type TUPLE (expected ")")');
- signature.shift();
- return GLib.Variant.new_tuple(children);
+ let children = [ ];
+ for (let i = 0; i < value.length; i++) {
+ let next = signature[0];
+ if (next == ')')
+ break;
+ children.push(_pack_variant(signature, value[i]));
+ }
+
+ if (signature[0] != ')')
+ throw new TypeError('Invalid GVariant signature for type TUPLE (expected ")")');
+ signature.shift();
+ return GLib.Variant.new_tuple(children);
case '{':
- let key = _pack_variant(signature, value[0]);
- let child = _pack_variant(signature, value[1]);
+ let key = _pack_variant(signature, value[0]);
+ let child = _pack_variant(signature, value[1]);
- if (signature[0] != '}')
- throw new TypeError('Invalid GVariant signature for type DICT_ENTRY (expected "}")');
- signature.shift();
+ if (signature[0] != '}')
+ throw new TypeError('Invalid GVariant signature for type DICT_ENTRY (expected "}")');
+ signature.shift();
- return GLib.Variant.new_dict_entry(key, child);
+ return GLib.Variant.new_dict_entry(key, child);
default:
- throw new TypeError('Invalid GVariant signature (unexpected character ' + char + ')');
+ throw new TypeError('Invalid GVariant signature (unexpected character ' + char + ')');
}
}
function _unpack_variant(variant, deep, recursive = false) {
switch (String.fromCharCode(variant.classify())) {
case 'b':
- return variant.get_boolean();
+ return variant.get_boolean();
case 'y':
- return variant.get_byte();
+ return variant.get_byte();
case 'n':
- return variant.get_int16();
+ return variant.get_int16();
case 'q':
- return variant.get_uint16();
+ return variant.get_uint16();
case 'i':
- return variant.get_int32();
+ return variant.get_int32();
case 'u':
- return variant.get_uint32();
+ return variant.get_uint32();
case 'x':
- return variant.get_int64();
+ return variant.get_int64();
case 't':
- return variant.get_uint64();
+ return variant.get_uint64();
case 'h':
- return variant.get_handle();
+ return variant.get_handle();
case 'd':
- return variant.get_double();
+ return variant.get_double();
case 'o':
case 'g':
case 's':
- // g_variant_get_string has length as out argument
- return variant.get_string()[0];
+ // g_variant_get_string has length as out argument
+ return variant.get_string()[0];
case 'v': {
const ret = variant.get_variant();
if (deep && recursive && ret instanceof GLib.Variant)
@@ -212,48 +212,48 @@ function _unpack_variant(variant, deep, recursive = false) {
return ret;
}
case 'm':
- let val = variant.get_maybe();
- if (deep && val)
+ let val = variant.get_maybe();
+ if (deep && val)
return _unpack_variant(val, deep, recursive);
- else
- return val;
+ else
+ return val;
case 'a':
- if (variant.is_of_type(new GLib.VariantType('a{?*}'))) {
- // special case containers
- let ret = { };
- let nElements = variant.n_children();
- for (let i = 0; i < nElements; i++) {
- // always unpack the dictionary entry, and always unpack
- // the key (or it cannot be added as a key)
+ if (variant.is_of_type(new GLib.VariantType('a{?*}'))) {
+ // special case containers
+ let ret = { };
+ let nElements = variant.n_children();
+ for (let i = 0; i < nElements; i++) {
+ // always unpack the dictionary entry, and always unpack
+ // the key (or it cannot be added as a key)
let val = _unpack_variant(variant.get_child_value(i), deep,
recursive);
- let key;
- if (!deep)
- key = _unpack_variant(val[0], true);
- else
- key = val[0];
- ret[key] = val[1];
- }
- return ret;
- }
+ let key;
+ if (!deep)
+ key = _unpack_variant(val[0], true);
+ else
+ key = val[0];
+ ret[key] = val[1];
+ }
+ return ret;
+ }
if (variant.is_of_type(new GLib.VariantType('ay'))) {
// special case byte arrays
return variant.get_data_as_bytes().toArray();
}
- // fall through
+ // fall through
case '(':
case '{':
- let ret = [ ];
- let nElements = variant.n_children();
- for (let i = 0; i < nElements; i++) {
- let val = variant.get_child_value(i);
- if (deep)
+ let ret = [ ];
+ let nElements = variant.n_children();
+ for (let i = 0; i < nElements; i++) {
+ let val = variant.get_child_value(i);
+ if (deep)
ret.push(_unpack_variant(val, deep, recursive));
- else
- ret.push(val);
- }
- return ret;
+ else
+ ret.push(val);
+ }
+ return ret;
}
throw new Error('Assertion failure: this code should not be reached');
@@ -270,24 +270,24 @@ function _init() {
Error.prototype.matches = function() { return false; };
this.Variant._new_internal = function(sig, value) {
- let signature = Array.prototype.slice.call(sig);
+ let signature = Array.prototype.slice.call(sig);
- let variant = _pack_variant(signature, value);
- if (signature.length != 0)
- throw new TypeError('Invalid GVariant signature (more than one single complete type)');
+ let variant = _pack_variant(signature, value);
+ if (signature.length != 0)
+ throw new TypeError('Invalid GVariant signature (more than one single complete type)');
- return variant;
+ return variant;
};
// Deprecate version of new GLib.Variant()
this.Variant.new = function(sig, value) {
- return new GLib.Variant(sig, value);
+ return new GLib.Variant(sig, value);
};
this.Variant.prototype.unpack = function() {
- return _unpack_variant(this, false);
+ return _unpack_variant(this, false);
};
this.Variant.prototype.deepUnpack = function() {
- return _unpack_variant(this, true);
+ return _unpack_variant(this, true);
};
// backwards compatibility alias
this.Variant.prototype.deep_unpack = this.Variant.prototype.deepUnpack;
@@ -298,11 +298,11 @@ function _init() {
};
this.Variant.prototype.toString = function() {
- return '[object variant of type "' + this.get_type_string() + '"]';
+ return '[object variant of type "' + this.get_type_string() + '"]';
};
this.Bytes.prototype.toArray = function() {
- return imports.byteArray.fromGBytes(this);
+ return imports.byteArray.fromGBytes(this);
};
this.log_structured = function(logDomain, logLevel, stringFields) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]