5dc18c15cd
Copy from home:dimstar:branches:GNOME:Factory/gjs via accept of submit request 43393 revision 4. Request was accepted with message: thanks, see minor tweak OBS-URL: https://build.opensuse.org/request/show/43393 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gjs?expand=0&rev=14
292 lines
10 KiB
Diff
292 lines
10 KiB
Diff
From 324a06ee4bfc68ba13b4781d94f6f1d687c8b05c Mon Sep 17 00:00:00 2001
|
|
From: Colin Walters <walters@verbum.org>
|
|
Date: Wed, 07 Jul 2010 18:49:38 +0000
|
|
Subject: Adjust for g-i change to remove machine-independent type tags
|
|
|
|
See bug 623774.
|
|
|
|
https://bugzilla.gnome.org/show_bug.cgi?id=623775
|
|
---
|
|
Index: gjs-0.7/gi/arg.c
|
|
===================================================================
|
|
--- gjs-0.7.orig/gi/arg.c
|
|
+++ gjs-0.7/gi/arg.c
|
|
@@ -101,43 +101,23 @@ _gjs_enum_value_is_valid(JSContext *con
|
|
return found;
|
|
}
|
|
|
|
-/* Return the proper GI int type for the size and signedness. */
|
|
+/* The typelib used to have machine-independent types like
|
|
+ * GI_TYPE_TAG_LONG that had to be converted; now we only
|
|
+ * handle GType specially here.
|
|
+ */
|
|
static inline GITypeTag
|
|
-type_tag_from_size(int intsize, gboolean is_signed)
|
|
-{
|
|
- /* Constant folding should be able to reduce this to a single constant,
|
|
- * given constant inputs. */
|
|
- switch (intsize) {
|
|
- case 1: return (is_signed) ? GI_TYPE_TAG_INT8 : GI_TYPE_TAG_UINT8;
|
|
- case 2: return (is_signed) ? GI_TYPE_TAG_INT16 : GI_TYPE_TAG_UINT16;
|
|
- case 4: return (is_signed) ? GI_TYPE_TAG_INT32 : GI_TYPE_TAG_UINT32;
|
|
- case 8: return (is_signed) ? GI_TYPE_TAG_INT64 : GI_TYPE_TAG_UINT64;
|
|
- default: g_assert_not_reached ();
|
|
- }
|
|
-}
|
|
-
|
|
-/** Convert machine-specific integer type tags such as 'int' and 'long'
|
|
- * into machine-independent explicitly-sized type tags such as 'int32'. */
|
|
-static GITypeTag
|
|
-normalize_int_types(GITypeTag type) {
|
|
- enum { UNSIGNED=FALSE, SIGNED=TRUE };
|
|
- switch (type) {
|
|
-#define INT_TYPE(tag, ty, sign) \
|
|
- case GI_TYPE_TAG_##tag: return type_tag_from_size(sizeof(ty), (sign));
|
|
- INT_TYPE(SHORT, short, SIGNED);
|
|
- INT_TYPE(USHORT, unsigned short, UNSIGNED);
|
|
- INT_TYPE(INT, int, SIGNED);
|
|
- INT_TYPE(UINT, unsigned int, UNSIGNED);
|
|
- INT_TYPE(LONG, long, SIGNED);
|
|
- INT_TYPE(ULONG, unsigned long, UNSIGNED);
|
|
- INT_TYPE(SSIZE, ssize_t, SIGNED);
|
|
- INT_TYPE(SIZE, size_t, UNSIGNED);
|
|
- INT_TYPE(TIME_T, time_t, SIGNED); /* time_t is signed */
|
|
- INT_TYPE(GTYPE, GType, UNSIGNED);
|
|
-#undef INT_TYPE
|
|
- default:
|
|
- return type; /* not a weird int type, return untouched */
|
|
+replace_gtype(GITypeTag type) {
|
|
+ if (type == GI_TYPE_TAG_GTYPE) {
|
|
+ /* Constant folding should handle this hopefully */
|
|
+ switch (sizeof(GType)) {
|
|
+ case 1: GI_TYPE_TAG_UINT8;
|
|
+ case 2: GI_TYPE_TAG_UINT16;
|
|
+ case 4: GI_TYPE_TAG_UINT32;
|
|
+ case 8: GI_TYPE_TAG_UINT64;
|
|
+ default: g_assert_not_reached ();
|
|
+ }
|
|
}
|
|
+ return type;
|
|
}
|
|
|
|
/* Check if an argument of the given needs to be released if we created it
|
|
@@ -425,7 +405,7 @@ gjs_string_to_intarray(JSContext *cont
|
|
gsize length;
|
|
|
|
element_type = g_type_info_get_tag(param_info);
|
|
- element_type = normalize_int_types(element_type);
|
|
+ element_type = replace_gtype(element_type);
|
|
|
|
switch (element_type) {
|
|
case GI_TYPE_TAG_INT8:
|
|
@@ -521,7 +501,7 @@ gjs_array_to_array(JSContext *context,
|
|
GITypeTag element_type;
|
|
|
|
element_type = g_type_info_get_tag(param_info);
|
|
- element_type = normalize_int_types(element_type);
|
|
+ element_type = replace_gtype(element_type);
|
|
|
|
switch (element_type) {
|
|
case GI_TYPE_TAG_UTF8:
|
|
@@ -588,8 +568,7 @@ gjs_value_to_g_argument(JSContext *
|
|
gboolean nullable_type;
|
|
|
|
type_tag = g_type_info_get_tag( (GITypeInfo*) type_info);
|
|
- if (type_tag != GI_TYPE_TAG_TIME_T) // we handle time_t as a non-int type
|
|
- type_tag = normalize_int_types(type_tag);
|
|
+ type_tag = replace_gtype(type_tag);
|
|
|
|
gjs_debug_marshal(GJS_DEBUG_GFUNCTION,
|
|
"Converting jsval to GArgument %s",
|
|
@@ -680,14 +659,6 @@ gjs_value_to_g_argument(JSContext *
|
|
}
|
|
break;
|
|
|
|
- case GI_TYPE_TAG_TIME_T: {
|
|
- double v;
|
|
- if (!JS_ValueToNumber(context, value, &v))
|
|
- wrong = TRUE;
|
|
- arg->v_ulong = (unsigned long) (v/1000);
|
|
- }
|
|
- break;
|
|
-
|
|
case GI_TYPE_TAG_BOOLEAN:
|
|
if (!JS_ValueToBoolean(context, value, &arg->v_boolean))
|
|
wrong = TRUE;
|
|
@@ -1063,18 +1034,6 @@ gjs_value_to_g_argument(JSContext *
|
|
}
|
|
break;
|
|
|
|
- case GI_TYPE_TAG_SHORT:
|
|
- case GI_TYPE_TAG_USHORT:
|
|
- case GI_TYPE_TAG_INT:
|
|
- case GI_TYPE_TAG_UINT:
|
|
- case GI_TYPE_TAG_LONG:
|
|
- case GI_TYPE_TAG_ULONG:
|
|
- case GI_TYPE_TAG_SIZE:
|
|
- case GI_TYPE_TAG_SSIZE:
|
|
- case GI_TYPE_TAG_GTYPE:
|
|
- /* these types are converted by normalize_int_types */
|
|
- g_assert_not_reached();
|
|
-
|
|
default:
|
|
gjs_debug(GJS_DEBUG_ERROR,
|
|
"Unhandled type %s for JavaScript to GArgument conversion",
|
|
@@ -1134,8 +1093,7 @@ gjs_g_argument_init_default(JSContext
|
|
GITypeTag type_tag;
|
|
|
|
type_tag = g_type_info_get_tag( (GITypeInfo*) type_info);
|
|
- if (type_tag != GI_TYPE_TAG_TIME_T) // we handle time_t as a non-int type
|
|
- type_tag = normalize_int_types(type_tag);
|
|
+ type_tag = replace_gtype(type_tag);
|
|
|
|
switch (type_tag) {
|
|
case GI_TYPE_TAG_VOID:
|
|
@@ -1173,10 +1131,6 @@ gjs_g_argument_init_default(JSContext
|
|
case GI_TYPE_TAG_UINT64:
|
|
arg->v_uint64 = 0;
|
|
|
|
- case GI_TYPE_TAG_TIME_T:
|
|
- arg->v_ulong = 0;
|
|
- break;
|
|
-
|
|
case GI_TYPE_TAG_BOOLEAN:
|
|
arg->v_boolean = FALSE;
|
|
break;
|
|
@@ -1233,18 +1187,6 @@ gjs_g_argument_init_default(JSContext
|
|
arg->v_pointer = NULL;
|
|
break;
|
|
|
|
- case GI_TYPE_TAG_SHORT:
|
|
- case GI_TYPE_TAG_USHORT:
|
|
- case GI_TYPE_TAG_INT:
|
|
- case GI_TYPE_TAG_UINT:
|
|
- case GI_TYPE_TAG_LONG:
|
|
- case GI_TYPE_TAG_ULONG:
|
|
- case GI_TYPE_TAG_SIZE:
|
|
- case GI_TYPE_TAG_SSIZE:
|
|
- case GI_TYPE_TAG_GTYPE:
|
|
- /* these types are converted by normalize_int_types */
|
|
- g_assert_not_reached();
|
|
-
|
|
default:
|
|
gjs_debug(GJS_DEBUG_ERROR,
|
|
"Unhandled type %s for default GArgument initialization",
|
|
@@ -1429,8 +1371,7 @@ gjs_value_from_g_argument (JSContext *c
|
|
GITypeTag type_tag;
|
|
|
|
type_tag = g_type_info_get_tag( (GITypeInfo*) type_info);
|
|
- if (type_tag != GI_TYPE_TAG_TIME_T) // we handle time_t as a non-int type
|
|
- type_tag = normalize_int_types(type_tag);
|
|
+ type_tag = replace_gtype(type_tag);
|
|
|
|
gjs_debug_marshal(GJS_DEBUG_GFUNCTION,
|
|
"Converting GArgument %s to jsval",
|
|
@@ -1477,11 +1418,6 @@ gjs_value_from_g_argument (JSContext *c
|
|
case GI_TYPE_TAG_DOUBLE:
|
|
return JS_NewDoubleValue(context, arg->v_double, value_p);
|
|
|
|
- case GI_TYPE_TAG_TIME_T:
|
|
- *value_p = gjs_date_from_time_t(context,
|
|
- (time_t) arg->v_long);
|
|
- return JS_TRUE;
|
|
-
|
|
case GI_TYPE_TAG_FILENAME:
|
|
if (arg->v_pointer)
|
|
return gjs_string_from_filename(context, arg->v_pointer, -1, value_p);
|
|
@@ -1701,18 +1637,6 @@ gjs_value_from_g_argument (JSContext *c
|
|
}
|
|
break;
|
|
|
|
- case GI_TYPE_TAG_SHORT:
|
|
- case GI_TYPE_TAG_USHORT:
|
|
- case GI_TYPE_TAG_INT:
|
|
- case GI_TYPE_TAG_UINT:
|
|
- case GI_TYPE_TAG_LONG:
|
|
- case GI_TYPE_TAG_ULONG:
|
|
- case GI_TYPE_TAG_SIZE:
|
|
- case GI_TYPE_TAG_SSIZE:
|
|
- case GI_TYPE_TAG_GTYPE:
|
|
- /* these types are converted by normalize_int_types */
|
|
- g_assert_not_reached();
|
|
-
|
|
default:
|
|
gjs_debug(GJS_DEBUG_ERROR,
|
|
"Unhandled type %s converting GArgument to JavaScript",
|
|
@@ -1782,21 +1706,12 @@ gjs_g_arg_release_internal(JSContext *c
|
|
case GI_TYPE_TAG_UINT8:
|
|
case GI_TYPE_TAG_INT16:
|
|
case GI_TYPE_TAG_UINT16:
|
|
- case GI_TYPE_TAG_SHORT:
|
|
- case GI_TYPE_TAG_USHORT:
|
|
- case GI_TYPE_TAG_INT:
|
|
case GI_TYPE_TAG_INT32:
|
|
- case GI_TYPE_TAG_UINT:
|
|
case GI_TYPE_TAG_UINT32:
|
|
case GI_TYPE_TAG_INT64:
|
|
case GI_TYPE_TAG_UINT64:
|
|
- case GI_TYPE_TAG_LONG:
|
|
- case GI_TYPE_TAG_ULONG:
|
|
case GI_TYPE_TAG_FLOAT:
|
|
case GI_TYPE_TAG_DOUBLE:
|
|
- case GI_TYPE_TAG_SSIZE:
|
|
- case GI_TYPE_TAG_SIZE:
|
|
- case GI_TYPE_TAG_TIME_T:
|
|
break;
|
|
|
|
case GI_TYPE_TAG_FILENAME:
|
|
@@ -1902,7 +1817,7 @@ gjs_g_arg_release_internal(JSContext *c
|
|
|
|
param_info = g_type_info_get_param_type(type_info, 0);
|
|
element_type = g_type_info_get_tag(param_info);
|
|
- element_type = normalize_int_types(element_type);
|
|
+ element_type = replace_gtype(element_type);
|
|
|
|
switch (element_type) {
|
|
case GI_TYPE_TAG_UTF8:
|
|
Index: gjs-0.7/gi/boxed.c
|
|
===================================================================
|
|
--- gjs-0.7.orig/gi/boxed.c
|
|
+++ gjs-0.7/gi/boxed.c
|
|
@@ -1043,19 +1043,10 @@ struct_is_simple(GIStructInfo *info)
|
|
case GI_TYPE_TAG_UINT16:
|
|
case GI_TYPE_TAG_INT32:
|
|
case GI_TYPE_TAG_UINT32:
|
|
- case GI_TYPE_TAG_SHORT:
|
|
- case GI_TYPE_TAG_USHORT:
|
|
- case GI_TYPE_TAG_INT:
|
|
- case GI_TYPE_TAG_UINT:
|
|
case GI_TYPE_TAG_INT64:
|
|
case GI_TYPE_TAG_UINT64:
|
|
- case GI_TYPE_TAG_LONG:
|
|
- case GI_TYPE_TAG_ULONG:
|
|
- case GI_TYPE_TAG_SSIZE:
|
|
- case GI_TYPE_TAG_SIZE:
|
|
case GI_TYPE_TAG_FLOAT:
|
|
case GI_TYPE_TAG_DOUBLE:
|
|
- case GI_TYPE_TAG_TIME_T:
|
|
break;
|
|
case GI_TYPE_TAG_VOID:
|
|
case GI_TYPE_TAG_GTYPE:
|
|
Index: gjs-0.7/test/js/testEverythingBasic.js
|
|
===================================================================
|
|
--- gjs-0.7.orig/test/js/testEverythingBasic.js
|
|
+++ gjs-0.7/test/js/testEverythingBasic.js
|
|
@@ -73,13 +73,9 @@ function testLifeUniverseAndEverything()
|
|
assertEquals(42, Everything.test_double(42));
|
|
assertEquals(-42, Everything.test_double(-42));
|
|
|
|
- let now = new Date();
|
|
- let bounced = Everything.test_timet(now);
|
|
- assertEquals(now.getFullYear(), bounced.getFullYear());
|
|
- assertEquals(now.getMonth(), bounced.getMonth());
|
|
- assertEquals(now.getDay(), bounced.getDay());
|
|
- assertEquals(now.getHours(), bounced.getHours());
|
|
- assertEquals(now.getSeconds(), bounced.getSeconds());
|
|
+ let now = Math.floor(new Date().getTime() / 1000);
|
|
+ let bounced = Math.floor(Everything.test_timet(now));
|
|
+ assertEquals(bounced, now);
|
|
}
|
|
|
|
function testLimits() {
|