/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
EXPORTCH void setFunction5_chdl(void *varg) {
  ChVaList_t ap;

  data_type1 arg1;
  funcHandle  handle_ch = NULL, handle_c = NULL;

  /* get arguments passed from the Ch function */
  Ch_VaStart(interp, ap, varg);
  arg1 = Ch_VaArg(interp, ap, data_type1);   /* get 1st argument  */
  /* get function handle of Ch space  */
  handle_ch = Ch_VaArg(interp, ap, funcHandle);

  if(handle_ch == NULL)  {
    handle_c = NULL;
  }

  else if(handlePairs.handle_ch == handle_ch) {
    handle_c = handlePairs.handle_c;
  }

  else {
    setFunction5_chdl_funptr = (void *)handle_ch;
    handlePairs.handle_ch = handle_ch;
    handle_c = handlePairs.handle_c = setFunction5_chdl_funarg;
  }

  setFunction5(arg1, handle_c);

  Ch_VaEnd(interp, ap);
}

/* C function to replace the Ch function pointer */
static return_type setFunction5_chdl_funarg(data_type2 arg2) {
  return_type retval;
  Ch_CallFuncByAddr(interp, setFunction5_chdl_funptr, &retval, arg2);
  return retval;
}

