Skip to content

Commit

Permalink
Implement WHATWG Encoding specification.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlsh committed Nov 23, 2020
1 parent 1d6c70a commit c19f330
Show file tree
Hide file tree
Showing 19 changed files with 2,224 additions and 280 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -2,4 +2,6 @@

installed-tests/js/jasmine.js
installed-tests/js/modules/badOverrides/WarnLib.js
# Until ESLint merges class fields.
modules/core/_text.js
modules/script/jsUnit.js
3 changes: 2 additions & 1 deletion .eslintrc.yml
Expand Up @@ -70,7 +70,6 @@ rules:
jsdoc/newline-after-description: error
jsdoc/require-jsdoc: error
jsdoc/require-param: error
jsdoc/require-param-description: error
jsdoc/require-param-name: error
jsdoc/require-param-type: error
key-spacing:
Expand Down Expand Up @@ -243,5 +242,7 @@ globals:
logError: readonly
print: readonly
printerr: readonly
TextEncoder: readonly
TextDecoder: readonly
parserOptions:
ecmaVersion: 2020
9 changes: 8 additions & 1 deletion COPYING
Expand Up @@ -20,7 +20,14 @@ 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.


The following files contain code from Mozilla which
is triple licensed under MPL1.1/LGPLv2+/GPLv2+:
The console module (modules/console.c)

The following files contain code from Node.js which
is licensed under MIT:
The _encodings core module (modules/core/_encodings.js)

The following files contain code from Deno which
is licensed under MIT:
The encoding test suite (installed-tests/js/testEncoding.js)
38 changes: 20 additions & 18 deletions gi/value.cpp
Expand Up @@ -70,12 +70,12 @@ static bool gjs_value_from_g_value_internal(JSContext *context,

info_type = g_base_info_get_type (obj);
if (info_type == GI_INFO_TYPE_OBJECT)
signal_info = g_object_info_find_signal((GIObjectInfo*)obj,
signal_query->signal_name);
signal_info = g_object_info_find_signal(
reinterpret_cast<GIObjectInfo*>(obj), signal_query->signal_name);
else if (info_type == GI_INFO_TYPE_INTERFACE)
signal_info = g_interface_info_find_signal((GIInterfaceInfo*)obj,
signal_query->signal_name);
g_base_info_unref((GIBaseInfo*)obj);
signal_info = g_interface_info_find_signal(
reinterpret_cast<GIInterfaceInfo*>(obj), signal_query->signal_name);
g_base_info_unref(obj);

return signal_info;
}
Expand Down Expand Up @@ -140,7 +140,8 @@ closure_marshal(GClosure *closure,
context = gjs_closure_get_context(closure);
GjsContextPrivate* gjs = GjsContextPrivate::from_cx(context);
if (G_UNLIKELY(gjs->sweeping())) {
GSignalInvocationHint *hint = (GSignalInvocationHint*) invocation_hint;
GSignalInvocationHint* hint =
reinterpret_cast<GSignalInvocationHint*>(invocation_hint);

g_critical("Attempting to call back into JSAPI during the sweeping phase of GC. "
"This is most likely caused by not destroying a Clutter actor or Gtk+ "
Expand Down Expand Up @@ -211,10 +212,10 @@ closure_marshal(GClosure *closure,
array_len_indices_for[i] = array_len_pos + 1;
}

g_base_info_unref((GIBaseInfo *)arg_info);
g_base_info_unref(reinterpret_cast<GIBaseInfo*>(arg_info));
}

g_base_info_unref((GIBaseInfo *)signal_info);
g_base_info_unref(reinterpret_cast<GIBaseInfo*>(signal_info));
}

JS::RootedValueVector argv(context);
Expand Down Expand Up @@ -266,7 +267,7 @@ closure_marshal(GClosure *closure,

for (i = 1; i < n_param_values; i++)
if (type_info_for[i])
g_base_info_unref((GIBaseInfo *)type_info_for[i]);
g_base_info_unref(reinterpret_cast<GIBaseInfo*>(type_info_for[i]));

JS::RootedValue rval(context);
mozilla::Unused << gjs_closure_invoke(closure, nullptr, argv, &rval, false);
Expand Down Expand Up @@ -500,7 +501,7 @@ gjs_value_to_g_value_internal(JSContext *context,
length, &result))
return false;
/* cast to strv in a separate step to avoid type-punning */
strv = (char**) result;
strv = reinterpret_cast<char**>(result);
g_value_take_boxed (gvalue, strv);
}
} else {
Expand Down Expand Up @@ -561,7 +562,8 @@ gjs_value_to_g_value_internal(JSContext *context,
GIInfoType info_type = g_base_info_get_type (registered);

if (info_type == GI_INFO_TYPE_STRUCT &&
g_struct_info_is_foreign ((GIStructInfo*)registered)) {
g_struct_info_is_foreign(
reinterpret_cast<GIStructInfo*>(registered))) {
GArgument arg;

if (!gjs_struct_foreign_convert_to_g_argument(
Expand Down Expand Up @@ -671,7 +673,7 @@ gjs_value_to_g_value_internal(JSContext *context,
return throw_expect_type(context, value, "param type", gtype);
}

g_value_set_param(gvalue, (GParamSpec*) gparam);
g_value_set_param(gvalue, reinterpret_cast<GParamSpec*>(gparam));
} else if (g_type_is_a(gtype, G_TYPE_GTYPE)) {
GType type;

Expand Down Expand Up @@ -822,7 +824,7 @@ gjs_value_from_g_value_internal(JSContext *context,
} else if (g_type_is_a(gtype, G_TYPE_OBJECT) || g_type_is_a(gtype, G_TYPE_INTERFACE)) {
GObject *gobj;

gobj = (GObject*) g_value_get_object(gvalue);
gobj = reinterpret_cast<GObject*>(g_value_get_object(gvalue));

if (gobj) {
JSObject* obj = ObjectInstance::wrapper_from_gobject(context, gobj);
Expand All @@ -833,9 +835,9 @@ gjs_value_from_g_value_internal(JSContext *context,
value_p.setNull();
}
} else if (gtype == G_TYPE_STRV) {
if (!gjs_array_from_strv (context,
value_p,
(const char**) g_value_get_boxed (gvalue))) {
if (!gjs_array_from_strv(
context, value_p,
reinterpret_cast<const char**>(g_value_get_boxed(gvalue)))) {
gjs_throw(context, "Failed to convert strv to array");
return false;
}
Expand Down Expand Up @@ -947,8 +949,8 @@ gjs_value_from_g_value_internal(JSContext *context,

res = gjs_value_from_g_argument(context, value_p, &type_info, &arg, true);

g_base_info_unref((GIBaseInfo*)arg_info);
g_base_info_unref((GIBaseInfo*)signal_info);
g_base_info_unref(reinterpret_cast<GIBaseInfo*>(arg_info));
g_base_info_unref(reinterpret_cast<GIBaseInfo*>(signal_info));
return res;
} else if (g_type_is_a(gtype, G_TYPE_POINTER)) {
gpointer pointer;
Expand Down

0 comments on commit c19f330

Please sign in to comment.