+%define Array2Queue(asval_meth,typestr) %{ {
+ int size, i;
+ VALUE *o, ary;
+ ary = rb_Array($input);
+ size = RARRAY_LEN(ary);
+ i = 0;
+ o = RARRAY_PTR(ary);
+ for (i = 0; i < size; i++, o++) {
+ int v;
+ int e = asval_meth(*o, &v);
+ if (!SWIG_IsOK(e))
+ SWIG_exception_fail(SWIG_TypeError, "list in argument $argnum must contain only " typestr);
+ queue_push(&$1, v);
+ }
+}
+%}
+%enddef
+
+%define ObjArray2Queue(type, obj2queue) %{ {
+ int size, i;
+ VALUE *o, ary;
+ ary = rb_Array($input);
+ size = RARRAY_LEN(ary);
+ i = 0;
+ o = RARRAY_PTR(ary);
+ for (i = 0; i < size; i++, o++) {
+ type obj;
+ int e = SWIG_ConvertPtr(*o, (void **)&obj, $descriptor(type), 0 | 0);
+ if (!SWIG_IsOK(e))
+ SWIG_exception_fail(SWIG_ArgError(e), "list in argument $argnum must contain only "`type`);
+ obj2queue;
+ }
+}
+%}
+%enddef
+
+#endif /* SWIGRUBY */
+
+#if defined(SWIGTCL)
+%typemap(out) Queue {
+ Tcl_Obj *objvx[$1.count];
+ int i;
+
+ for (i = 0; i < $1.count; i++) {
+ objvx[i] = SWIG_From_int($1.elements[i]);
+ }
+ Tcl_SetObjResult(interp, Tcl_NewListObj($1.count, objvx));
+ queue_free(&$1);
+}
+
+%define Queue2Array(type, step, con) %{
+ { /* scope is needed to make the goto of SWIG_exception_fail work */
+ int i;
+ int cnt = $1.count / step;
+ Id *idp = $1.elements;
+ Tcl_Obj *objvx[cnt];
+
+ for (i = 0; i < cnt; i++, idp += step) {
+ Id id = *idp;
+#define result resultx
+#define Tcl_SetObjResult(i, x) resultobj = x
+ type result = con;
+ Tcl_Obj *resultobj;
+ $typemap(out, type)
+ objvx[i] = resultobj;
+#undef Tcl_SetObjResult
+#undef result
+ }
+ queue_free(&$1);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(cnt, objvx));
+ }
+%}
+%enddef
+
+%define Array2Queue(asval_meth,typestr) %{ {
+ int size = 0;
+ int i = 0;
+ if (TCL_OK != Tcl_ListObjLength(interp, $input, &size))
+ SWIG_exception_fail(SWIG_TypeError, "argument $argnum is not a list");
+ for (i = 0; i < size; i++) {
+ Tcl_Obj *o = NULL;
+ int e, v;
+
+ if (TCL_OK != Tcl_ListObjIndex(interp, $input, i, &o))
+ SWIG_exception_fail(SWIG_IndexError, "failed to retrieve a list member");
+ e = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(o, &v);
+ if (!SWIG_IsOK(e))
+ SWIG_exception_fail(SWIG_ArgError(e), "list in argument $argnum must contain only " typestr);
+ queue_push(&$1, v);
+ }
+}
+%}
+%enddef
+
+%define ObjArray2Queue(type, obj2queue) %{ {
+ int size = 0;
+ int i = 0;
+ if (TCL_OK != Tcl_ListObjLength(interp, $input, &size))
+ SWIG_exception_fail(SWIG_TypeError, "argument $argnum is not a list");
+ for (i = 0; i < size; i++) {
+ Tcl_Obj *o = NULL;
+ type obj;
+ int e;
+ if (TCL_OK != Tcl_ListObjIndex(interp, $input, i, &o))
+ SWIG_exception_fail(SWIG_IndexError, "failed to retrieve a list member");
+ e = SWIG_ConvertPtr(o, (void **)&obj, $descriptor(type), 0 | 0);
+ if (!SWIG_IsOK(e))
+ SWIG_exception_fail(SWIG_ArgError(e), "list in argument $argnum must contain only "`type`);
+ obj2queue;
+ }
+}
+%}
+%enddef
+
+#endif /* SWIGTCL */
+
+%typemap(in) Queue Array2Queue(SWIG_AsVal_int, "integers")
+%typemap(in) Queue solvejobs ObjArray2Queue(Job *, queue_push2(&$1, obj->how, obj->what))