Index: test/js/testEverythingBasic.js
===================================================================
--- test/js/testEverythingBasic.js	(revision 100)
+++ test/js/testEverythingBasic.js	(working copy)
@@ -100,4 +100,9 @@ function testFilename() {
     assertEquals('/etc/fstab', filenames[1]);
 }
 
+function testInt() {
+    assertEquals(1, Everything.test_int_in(1, [42]));
+    assertEquals(2, Everything.test_int_in(2, [42, 1138]));
+}
+
 gjstestRun();
Index: gi/arg.c
===================================================================
--- gi/arg.c	(revision 100)
+++ gi/arg.c	(working copy)
@@ -34,6 +34,7 @@
 
 static JSBool gjs_value_to_g_arg_with_type_info(JSContext  *context,
                                                 jsval       value,
+                                                GITypeTag   type_tag,
                                                 GITypeInfo *type_info,
                                                 const char *arg_name,
                                                 gboolean    is_return_value,
@@ -138,6 +139,7 @@ gjs_array_to_g_list(JSContext   *context
          */
         if (!gjs_value_to_g_arg_with_type_info(context,
                                                elem,
+                                               param_tag,
                                                param_info,
                                                "list element",
                                                FALSE,
@@ -165,85 +167,85 @@ gjs_array_to_g_list(JSContext   *context
 }
 
 JSBool
-gjs_array_to_strv(JSContext   *context,
-                  jsval        array_value,
-                  unsigned int length,
-                  void       **arr_p)
+gjs_array_to_array(JSContext    *context,
+                   jsval         array_value,
+                   unsigned int  length,
+                   GITypeTag     param_type_tag,
+                   GITypeInfo   *param_info,
+                   GArgument   **arguments)
 {
-    char **result;
-    guint32 i;
-
-    result = g_new0(char *, length+1);
+    guint32 i, j;
+    jsval elem;
+    GITypeTag element_type;
+    GArgument *tmp;
+    gboolean failed = FALSE;
+    
+    tmp = g_new0(GArgument, length+1);
 
     for (i = 0; i < length; ++i) {
         jsval elem;
-
+        
         elem = JSVAL_VOID;
         if (!JS_GetElement(context, JSVAL_TO_OBJECT(array_value),
                            i, &elem)) {
-            g_free(result);
-            gjs_throw(context,
-                      "Missing array element %u",
-                      i);
-            return JS_FALSE;
+            gjs_throw(context, "Missing array element %u", i);
+            failed = TRUE;
+            break;
         }
 
-        if (!JSVAL_IS_STRING(elem)) {
-            gjs_throw(context,
-                      "Invalid element in string array");
-            g_strfreev(result);
-            return JS_FALSE;
-        }
-        if (!gjs_string_to_utf8(context, elem, (char **)&(result[i]))) {
-            g_strfreev(result);
-            return JS_FALSE;
+        if (!gjs_value_to_g_arg_with_type_info(context, elem, param_type_tag,
+                                               param_info,
+                                               "element argument", FALSE,
+                                               TRUE, &tmp[i])) {
+            /* exception already set */
+            failed = TRUE;
+            break;
         }
     }
 
-    *arr_p = result;
-
-    return JS_TRUE;
-}
-
-static JSBool
-gjs_array_to_array(JSContext   *context,
-                   jsval        array_value,
-                   unsigned int length,
-                   GITypeInfo  *param_info,
-                   void       **arr_p)
-{
-    guint32 i;
-    jsval elem;
-    GITypeTag element_type;
-
-    element_type = g_type_info_get_tag(param_info);
-
-    if (element_type == GI_TYPE_TAG_UTF8) {
-        return gjs_array_to_strv (context, array_value, length, arr_p);
-    } else {
-        gjs_throw(context,
-                  "Unhandled array element type %d", element_type);
+    if (failed) {
+        for (j = 0; j < i; ++j)
+            gjs_g_arg_release(context,
+                              GI_TRANSFER_EVERYTHING,
+                              param_info,
+                              &tmp[i]);
+        g_free(tmp);
         return JS_FALSE;
     }
+        
+    *arguments = tmp;
+    
+    return JS_TRUE;
 }
 
+/**
+ * gjs_value_to_g_arg_with_type_info:
+ *
+ * @context: the context we are executed in
+ * @value: value to convert
+ * @type_tag: the type of argument
+ * @type_info: type info for the argument, can be NULL for basic types
+ * @arg_name: what kind of argument we send, used in exception messages
+ * @is_return_value: is the argument a return value?
+ * @may_be_null: is null allowed?
+ * @arg: where the argument should be stored, should be initialized before
+ *       calling this function.
+ */
 static JSBool
 gjs_value_to_g_arg_with_type_info(JSContext  *context,
                                   jsval       value,
+                                  GITypeTag   type_tag,
                                   GITypeInfo *type_info,
                                   const char *arg_name,
                                   gboolean    is_return_value,
                                   gboolean    may_be_null,
                                   GArgument  *arg)
 {
-    GITypeTag type_tag;
     gboolean wrong;
     gboolean out_of_range;
     gboolean report_type_mismatch;
     gboolean nullable_type;
 
-    type_tag = g_type_info_get_tag( (GITypeInfo*) type_info);
-
     gjs_debug_marshal(GJS_DEBUG_GFUNCTION,
                       "Converting jsval to GArgument %s",
                       g_type_tag_to_string(type_tag));
@@ -402,6 +404,7 @@ gjs_value_to_g_arg_with_type_info(JSCont
             GIBaseInfo* symbol_info;
             GType gtype;
 
+            g_assert(type_info != NULL);
             symbol_info = g_type_info_get_interface(type_info);
             g_assert(symbol_info != NULL);
 
@@ -530,6 +533,7 @@ gjs_value_to_g_arg_with_type_info(JSCont
                 GSList *slist;
                 GITypeInfo *param_info;
 
+                g_assert(type_info != NULL);
                 param_info = g_type_info_get_param_type(type_info, 0);
                 g_assert(param_info != NULL);
 
@@ -576,11 +580,14 @@ gjs_value_to_g_arg_with_type_info(JSCont
                 wrong = TRUE;
             } else {
                 GITypeInfo *param_info;
-
+                GITypeTag param_type;
+                
+                g_assert(type_info != NULL);
                 param_info = g_type_info_get_param_type(type_info, 0);
                 g_assert(param_info != NULL);
-
-                if (!gjs_array_to_array (context, value, length, param_info, &arg->v_pointer))
+                param_type = g_type_info_get_tag( (GITypeInfo*) param_info);
+                if (!gjs_array_to_array (context, value, length, param_type,
+                                         param_info, (GArgument**)&arg->v_pointer))
                     wrong = TRUE;
 
                 g_base_info_unref((GIBaseInfo*) param_info);
@@ -644,6 +651,7 @@ gjs_value_to_g_arg(JSContext  *context,
 
     result =
         gjs_value_to_g_arg_with_type_info(context, value,
+                                          g_type_info_get_tag( (GITypeInfo*) type_info),
                                           type_info,
                                           g_base_info_get_name( (GIBaseInfo*) arg_info),
                                           g_arg_info_is_return_value(arg_info),
@@ -1042,16 +1050,29 @@ gjs_g_arg_release_internal(JSContext  *c
             /* OK */
         } else {
             GITypeInfo *param_info;
-
+            GITypeTag param_type_tag;
+            int i;
+            GArgument *arguments = (GArgument*)arg->v_pointer;
+            
             param_info = g_type_info_get_param_type(type_info, 0);
+            param_type_tag = g_type_info_get_tag( (GITypeInfo*) param_info);
 
-            if (g_type_info_get_tag (param_info) == GI_TYPE_TAG_UTF8 ||
-                g_type_info_get_tag (param_info) == GI_TYPE_TAG_FILENAME)
-                g_strfreev (arg->v_pointer);
-            else
-                g_assert_not_reached ();
+            for (i = 0; i < g_type_info_get_array_length (type_info); i++) {
+                if (!gjs_g_arg_release_internal(context,
+                                                transfer,
+                                                param_info,
+                                                param_type_tag,
+                                                &arguments[i])) {
+                    /* no way to recover here, and errors should
+                     * not be possible.
+                     */
+                    g_error("Failed to release list element");
+                    break;
+                }
+            }
 
             g_base_info_unref((GIBaseInfo*) param_info);
+            g_free(arguments);
         }
         break;
 
Index: gi/value.c
===================================================================
--- gi/value.c	(revision 100)
+++ gi/value.c	(working copy)
@@ -302,10 +302,12 @@ gjs_value_to_g_value(JSContext    *conte
                 return JS_FALSE;
             } else {
                 char **strv;
-
-                if (!gjs_array_to_strv (context,
-                                        value,
-                                        length, (void**)&strv))
+                if (!gjs_array_to_array (context,
+                                         value,
+                                         length,
+                                         GI_TYPE_TAG_UTF8,
+                                         NULL,
+                                         (GArgument**)&strv))
                     return JS_FALSE;
                 g_value_take_boxed (gvalue, strv);
             }
Index: gi/arg.h
===================================================================
--- gi/arg.h	(revision 100)
+++ gi/arg.h	(working copy)
@@ -53,11 +53,12 @@ JSBool _gjs_flags_value_is_valid (JSCont
                                   GFlagsClass *klass,
                                   guint        value);
 
-
-JSBool gjs_array_to_strv (JSContext   *context,
-                          jsval        array_value,
-                          unsigned int length,
-                          void       **arr_p);
+JSBool gjs_array_to_array (JSContext    *context,
+                           jsval         array_value,
+                           unsigned int  length,
+                           GITypeTag     param_type,
+                           GITypeInfo   *param_info,
+                           GArgument   **arguments);
 
 G_END_DECLS
 
