Defines | Functions

translate.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define COPY_A_TO_B(TYPEA, TYPEB, size, a, b)

Functions

void debug_print (char *)
void print_array (int, int, double *)
int trunc_fname (char *)
int convert_idl (gs_problem_t *, IDL_VPTR *)
int postproc_argv_c (gs_problem_t *, IDL_VPTR *)
int assign_arg (gs_argument_t *, IDL_VPTR)
int analyze_arg_pass_mode (gs_argument_t *)
int copy_scalar_input (gs_argument_t *, IDL_VPTR)
int copy_ptr_input (gs_argument_t *, IDL_VPTR)
int check_ptr_inout (gs_argument_t *, IDL_VPTR)
int copy_ptr_output (gs_argument_t *, IDL_VPTR)
int translate_array_input (gs_argument_t *, IDL_VPTR)
int translate_string_input (gs_argument_t *, IDL_VPTR)
int translate_scalar_input (IDL_VPTR, void *, int)
int translate_array_output (gs_argument_t *, IDL_VPTR)
int is_input_upcasted (IDL_VPTR, int, int)

Define Documentation

#define COPY_A_TO_B ( TYPEA,
TYPEB,
size,
a,
 ) 
Value:
{int ss = 0; \
TYPEA* ss_a = (TYPEA*) a; TYPEB* ss_b = (TYPEB*) b; \
for (ss = 0; ss < size; ss++) *((ss_b)++) = (TYPEB) *((ss_a)++);}

Definition at line 29 of file translate.h.


Function Documentation

int analyze_arg_pass_mode ( gs_argument_t *   ) 
int assign_arg ( gs_argument_t *  ,
IDL_VPTR   
)
int check_ptr_inout ( gs_argument_t *  ,
IDL_VPTR   
)
int convert_idl ( gs_problem_t *  pd,
IDL_VPTR *  argv_idl 
)

Converts the entire argument list from the IDL call to a GridSolve compatible argument list.

Parameters:
pd -- the GridSolve problem description
argv_idl -- array of IDL arguments
Returns:
0 on success, -1 on failure.

Definition at line 104 of file translate.c.

{
  gs_argument_t *argp;
  int i;

  for(i=0, argp = pd->arglist; argp != NULL; argp = argp->next) {
    if(argp->inout != GS_WORKSPACE) {
      assign_arg(argp, argv_idl[i]);
      i++;
    }
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int copy_ptr_input ( gs_argument_t *  ,
IDL_VPTR   
)
int copy_ptr_output ( gs_argument_t *  ,
IDL_VPTR   
)
int copy_scalar_input ( gs_argument_t *  ,
IDL_VPTR   
)
void debug_print ( char *   ) 

Translate and copy the argvs from IDL to GridSolve C client.

This is part of the IDL Client for GridSolve.

int is_input_upcasted ( IDL_VPTR  idl,
int  gs_data_type,
int  gs_object_type 
)

Determines whether there had to be a type conversion when the input was passed from IDL to GridSolve.

Parameters:
idl -- the IDL argument
gs_data_type -- the data type expected by GridSolve
Returns:
TRUE if the cast was necessary, FALSE otherwise

Definition at line 1209 of file translate.c.

{
  int idl_type;
  int ret;

  ret = 0;
  idl_type = idl->type;

  switch(gs_data_type) {
    case GS_CHAR:
      if(gs_object_type == GS_MATRIX)
        ret = 1;
      break;
    case GS_INT:
      if(idl->type == IDL_TYP_INT || idl_type == IDL_TYP_BYTE)
        ret = 1;
      break;
    case GS_FLOAT:
      if(idl_type == IDL_TYP_BYTE || idl_type == IDL_TYP_INT
         || idl_type == IDL_TYP_LONG)
        ret = 1;
      break;
    case GS_DOUBLE:
      if(idl_type == IDL_TYP_BYTE || idl_type == IDL_TYP_INT
         || idl_type == IDL_TYP_LONG || idl_type == IDL_TYP_FLOAT)
        ret = 1;
      break;
    case GS_DCOMPLEX: 
      if(idl_type == IDL_TYP_COMPLEX || idl_type == IDL_TYP_BYTE 
         || idl_type == IDL_TYP_INT  || idl_type == IDL_TYP_LONG 
         || idl_type == IDL_TYP_FLOAT|| idl_type == IDL_TYP_DOUBLE)
        ret = 1;
      break;
    case GS_SCOMPLEX: 
      if(idl_type == IDL_TYP_BYTE || idl_type == IDL_TYP_INT  
         || idl_type == IDL_TYP_LONG || idl_type == IDL_TYP_FLOAT
         || idl_type == IDL_TYP_DOUBLE)
        ret = 1;
      break;
  }

  return ret;
}

Here is the caller graph for this function:

int postproc_argv_c ( gs_problem_t *  pd,
IDL_VPTR *  argv_idl 
)

After the call has completed, this is called to convert the GridSolve results back to IDL compatible arguments.

Parameters:
pd -- the GridSolve problem description
argv_idl -- array of IDL arguments
Returns:
0 on success, -1 on failure.

Definition at line 1126 of file translate.c.

{
  gs_argument_t*   argp;
  int i;

  for(i=0, argp = pd->arglist; argp != NULL; argp = argp->next) {
    if(argp->inout == GS_WORKSPACE)
      continue;

    if((argp->inout == GS_IN) && (argp->objecttype == GS_SCALAR)) {
      ; /* no upcasting for args passed by value */
    }
    else if(argp->objecttype == GS_FILE) {
      ; /* nothing needs to be done here */
    }
    else if(argp->objecttype == GS_PACKEDFILE) {
      if(argp->data != NULL)
        free(argp->data);
    }
    else if(argp->inout == GS_VAROUT) {
      copy_varout(pd, argp, argv_idl[i]);
    }
    else if(argp->inout == GS_IN) {
      /* This is an input-only object type, so if any space
       * was allocated for it, free that here.
       */

      if(is_input_upcasted(argv_idl[i], argp->datatype, argp->objecttype)) {
        if(argp->data != NULL)
          free(argp->data);
      }
    }
    else {
      /* Either in/out or output object type.  We only care about
       * doing conversions on scalar types.
       */

      if(argp->datatype == GS_CHAR) {
        if(argp->objecttype == GS_MATRIX) {
          if(argp->data != NULL) {
            copy_char_matrix_output(argv_idl[i], argp);
            free(argp->data);
          }
        }
        else if(argp->objecttype == GS_VECTOR) {
          if(argp->data != NULL) {
            copy_char_vector_output(argv_idl[i], argp);
            free(argp->data);
          }
        }
      }

      if(argp->objecttype == GS_SCALAR) {
        store_scalar_to_idl(argv_idl[i], argp);

        if(argp->inout == GS_OUT) {
          /* output only scalar */
          if(gs_idl_types[argp->datatype] != argv_idl[i]->type)
            copy_scalar_output(argv_idl[i], argp);
        }
      }
    }

    /* don't move this increment into the for loop stmt since we don't
     * want it to be incremented for workspace args
     */
    i++;
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void print_array ( int  m,
int  n,
double *  A 
)

Prints the matrix. Used for debugging purposes.

Parameters:
m -- number of rows
n -- number of cols
A -- matrix data

Definition at line 37 of file translate.c.

{
  int i, j;
  for(i = 0; i < m; i++) {
    for(j = 0; j < n; j++) {
      printf("%f ", *(A+i*n+j));
    }
    printf("\n");
  }
}

int translate_array_input ( gs_argument_t *  ,
IDL_VPTR   
)
int translate_array_output ( gs_argument_t *  ,
IDL_VPTR   
)
int translate_scalar_input ( IDL_VPTR  ,
void *  ,
int   
)
int translate_string_input ( gs_argument_t *  ,
IDL_VPTR   
)
int trunc_fname ( char *  fname  ) 

Truncates "()" from the function name if necessary.

Parameters:
fname -- the function name to be truncated
Returns:
0 on success, -1 on failure.

Definition at line 57 of file translate.c.

{
  char *p;

  p = strchr(fname, '(');

  if(p)
    *p = 0;

  return 0;
}

Here is the caller graph for this function: