/* ---------------------------------------------------------------------- */

#define ns__aproc0 "::aproc"

#ifndef CRITCL_variadic_int
#define CRITCL_variadic_int

	    /* NOTE: Array 'v' is allocated on the heap. The argument
	    // release code is used to free it after the worker
	    // function returned. Depending on type and what is done
	    // by the worker it may have to make copies of the data.
	    */

	    typedef struct critcl_variadic_int {
		int     c; /* Element count */
		int* v; /* Allocated array of the elements */
	    } critcl_variadic_int;

	    static int
	    _critcl_variadic_int_item (Tcl_Interp* interp, Tcl_Obj* src, int* dst) {
			{
	if (Tcl_GetIntFromObj(interp, src, dst) != TCL_OK) return TCL_ERROR; }
		return TCL_OK;
	    }
	
#endif /* CRITCL_variadic_int _________ */

static void c__aproc0(int has_x, int x, int has_y, int y, critcl_variadic_int args)
{

}

static int
tcl__aproc0(ClientData cd, Tcl_Interp *interp, int oc, Tcl_Obj *CONST ov[])
{
  int _has_x = 0;
  int _x;
  int _has_y = 0;
  int _y;
  critcl_variadic_int _args;
  int idx_;
  int argc_;
  idx_  = 1;
  argc_ = oc - 1;

  /* (int x, optional, default -1) - - -- --- ----- -------- */
  if (argc_ > 1) {
	{
	if (Tcl_GetIntFromObj(interp, ov[idx_], &_x) != TCL_OK) return TCL_ERROR; }
    idx_++;
    argc_--;
    _has_x = 1;
  } else {
    _x = -1;
  }


  /* (int y, optional, default -1) - - -- --- ----- -------- */
  if (argc_ > 1) {
	{
	if (Tcl_GetIntFromObj(interp, ov[idx_], &_y) != TCL_OK) return TCL_ERROR; }
    idx_++;
    argc_--;
    _has_y = 1;
  } else {
    _y = -1;
  }


  /* (int args, ...) - - -- --- ----- -------- */
	{
	int src, dst, leftovers = argc_;
	    _args.c = leftovers;
	    _args.v = (int*) ((!leftovers) ? 0 : ckalloc (leftovers * sizeof (int)));
	    for (src = idx_, dst = 0; leftovers > 0; dst++, src++, leftovers--) {
	       if (_critcl_variadic_int_item (interp, ov[src], &(_args.v[dst])) != TCL_OK) {
		   ckfree ((char*) _args.v); /* Cleanup partial work */
		   return TCL_ERROR;
	       }
	    } }

  /* Call - - -- --- ----- -------- */
  c__aproc0(_has_x, _x, _has_y, _y, _args);

  /* (Release: int args, ...) - - -- --- ----- -------- */
	    if (_args.c) { ckfree ((char*) _args.v); }
	
  /* (void return) - - -- --- ----- -------- */
	return TCL_OK;
}
