Back to index

salome-paravis  6.5.0
Functions
vtkParseExtras.h File Reference
#include "vtkParse.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

size_t vtkParse_IdentifierLength (const char *text)
 This file contains extra utilities for parsing and wrapping.
size_t vtkParse_NameLength (const char *text)
 Skip over a name, including any namespace prefixes and any template arguments.
size_t vtkParse_UnscopedNameLength (const char *text)
 Skip over a name, including any template parameters, but stopping if a '::' is encoutered.
size_t vtkParse_LiteralLength (const char *text)
 Skip over a literal, which may be a number, a char in single quotes, a string in double quotes, or a name, or a name followed by arguments in parentheses.
size_t vtkParse_BasicTypeFromString (const char *text, unsigned int *type, const char **classname, size_t *classname_len)
 Get a type from a type name, and return the number of characters used.
void vtkParse_ValueInfoFromString (ValueInfo *val, const char *text)
 Generate a ValueInfo by parsing the type from the provided text.
void vtkParse_ExpandTypedef (ValueInfo *valinfo, ValueInfo *typedefinfo)
 Expand a typedef within a variable, parameter, or typedef declaration.
void vtkParse_ExpandTypedefs (ValueInfo *valinfo, int n, const char *name[], const char *val[], ValueInfo *typedefinfo[])
 Expand any unrecognized types within a variable, parameter, or typedef that match any of the supplied typedefs.
void vtkParse_ExpandValues (ValueInfo *valinfo, int n, const char *name[], const char *val[])
 Wherever one of the specified names exists inside a Value or inside a Dimension size, replace it with the corresponding val string.
const char * vtkParse_StringReplace (const char *str1, int n, const char *name[], const char *val[])
 Search for all occurences of "name" and replace with the corresponding "val", return the initial string if no replacements occurred, otherwise return a new string allocated with malloc.
size_t vtkParse_DecomposeTemplatedType (const char *text, const char **classname, int n, const char ***args, const char *defaults[])
 Extract the class name and template args from a templated class type ID.
void vtkParse_FreeTemplateDecomposition (const char *classname, int n, const char **args)
 Free the list of strings returned by ExtractTemplateArgs.
void vtkParse_InstantiateClassTemplate (ClassInfo *data, int n, const char *args[])
 Instantiate a class template by substituting the provided arguments for the template parameters.
void vtkParse_IntantiateFunctionTemplate (FunctionInfo *data, int n, const char *args)
 Instantiate a function or class method template by substituting the provided arguments for the template parameters.
size_t vtkParse_MangledTypeName (const char *name, char *new_name)
 Generate a mangled name for a type, use gcc ia64 ABI.
size_t vtkParse_MangledLiteral (const char *name, char *new_name)
 Generate a mangled name for a literal.
const char ** vtkParse_GetTemplateMacroTypes ()
 Get a zero-terminated array of the types in vtkTemplateMacro.
const char ** vtkParse_GetArrayTypes ()
 Get a zero-terminated array of the types in vtkArray.

Function Documentation

size_t vtkParse_BasicTypeFromString ( const char *  text,
unsigned int *  type,
const char **  classname,
size_t *  classname_len 
)

Get a type from a type name, and return the number of characters used.

If the "classname" argument is not NULL, then it is used to return the short name for the type, e.g. "long int" becomes "long", while typedef names and class names are returned unchanged. If "const" appears in the type name, then the const bit flag is set for the type, but "const" will not appear in the returned classname.

Definition at line 509 of file vtkParseExtras.c.

{
  /* The various typedefs and types specific to VTK */
  static struct vtk_type_struct vtktypes[] = {
    { 9,  "vtkIdType", VTK_ID_TYPE },
    { 12, "vtkStdString", VTK_STRING },
    { 16, "vtkUnicodeString", VTK_UNICODE_STRING },
    { 11, "vtkTypeInt8", VTK_TYPE_INT8 },
    { 12, "vtkTypeUInt8", VTK_TYPE_UINT8 },
    { 12, "vtkTypeInt16", VTK_TYPE_INT16 },
    { 13, "vtkTypeUInt16", VTK_TYPE_UINT16 },
    { 12, "vtkTypeInt32", VTK_TYPE_INT32 },
    { 13, "vtkTypeUInt32", VTK_TYPE_UINT32 },
    { 12, "vtkTypeInt64", VTK_TYPE_INT64 },
    { 13, "vtkTypeUInt64", VTK_TYPE_UINT64 },
    { 14, "vtkTypeFloat32", VTK_TYPE_FLOAT32 },
    { 14, "vtkTypeFloat64", VTK_TYPE_FLOAT64 },
    { 0, 0, 0 } };

  /* Other typedefs and types */
  static struct vtk_type_struct stdtypes[] = {
    { 6,  "size_t", VTK_PARSE_SIZE_T },
    { 7,  "ssize_t", VTK_PARSE_SSIZE_T },
    { 7,  "ostream", VTK_PARSE_OSTREAM },
    { 7,  "istream", VTK_PARSE_ISTREAM },
    { 8,  "string", VTK_PARSE_STRING },
    { 0, 0, 0 } };

  const char *cp = text;
  const char *tmpcp;
  size_t k, n, m;
  int i;
  unsigned int const_bits = 0;
  unsigned int static_bits = 0;
  unsigned int unsigned_bits = 0;
  unsigned int base_bits = 0;
  const char *classname = NULL;
  size_t len = 0;

  while (*cp == ' ' || *cp == '\t') { cp++; }

  while ((*cp >= 'a' && *cp <= 'z') ||
         (*cp >= 'A' && *cp <= 'Z') ||
         (*cp == '_') || (cp[0] == ':' && cp[1] == ':'))
    {
    /* skip all chars that are part of a name */
    n = vtkParse_NameLength(cp);

    if ((n == 6 && strncmp("static", cp, n) == 0) ||
        (n == 4 && strncmp("auto", cp, n) == 0) ||
        (n == 8 && strncmp("register", cp, n) == 0) ||
        (n == 8 && strncmp("volatile", cp, n) == 0))
      {
      if (strncmp("static", cp, n) == 0)
        {
        static_bits = VTK_PARSE_STATIC;
        }
      }
    else if (n == 5 && strncmp(cp, "const", n) == 0)
      {
      const_bits |= VTK_PARSE_CONST;
      }
    else if (n == 8 && strncmp(cp, "unsigned", n) == 0)
      {
      unsigned_bits |= VTK_PARSE_UNSIGNED;
      if (base_bits == 0)
        {
        classname = "int";
        base_bits = VTK_PARSE_INT;
        }
      }
    else if (n == 6 && strncmp(cp, "signed", n) == 0)
      {
      if (base_bits == VTK_PARSE_CHAR)
        {
        classname = "signed char";
        base_bits = VTK_PARSE_SIGNED_CHAR;
        }
      else
        {
        classname = "int";
        base_bits = VTK_PARSE_INT;
        }
      }
    else if (n == 3 && strncmp(cp, "int", n) == 0)
      {
      if (base_bits == 0)
        {
        classname = "int";
        base_bits = VTK_PARSE_INT;
        }
      }
    else if (n == 4 && strncmp(cp, "long", n) == 0)
      {
      if (base_bits == VTK_PARSE_LONG)
        {
        classname = "long long";
        base_bits = VTK_PARSE_LONG_LONG;
        }
      else
        {
        classname = "long";
        base_bits = VTK_PARSE_LONG;
        }
      }
    else if (n == 5 && strncmp(cp, "short", n) == 0)
      {
      classname = "short";
      base_bits = VTK_PARSE_SHORT;
      }
    else if (n == 4 && strncmp(cp, "char", n) == 0)
      {
      if (base_bits == VTK_PARSE_INT && unsigned_bits != VTK_PARSE_UNSIGNED)
        {
        classname = "signed char";
        base_bits = VTK_PARSE_SIGNED_CHAR;
        }
      else
        {
        classname = "char";
        base_bits = VTK_PARSE_CHAR;
        }
      }
    else if (n == 5 && strncmp(cp, "float", n) == 0)
      {
      classname = "float";
      base_bits = VTK_PARSE_FLOAT;
      }
    else if (n == 6 && strncmp(cp, "double", n) == 0)
      {
      classname = "double";
      base_bits = VTK_PARSE_DOUBLE;
      }
    else if (n == 4 && strncmp(cp, "bool", n) == 0)
      {
      classname = "bool";
      base_bits = VTK_PARSE_BOOL;
      }
    else if (n == 4 && strncmp(cp, "void", n) == 0)
      {
      classname = "void";
      base_bits = VTK_PARSE_VOID;
      }
    else if (n == 7 && strncmp(cp, "__int64", n) == 0)
      {
      classname = "__int64";
      base_bits = VTK_PARSE___INT64;
      }
    else
      {
      /* if type already found, break */
      if (base_bits != 0)
        {
        break;
        }

      /* check vtk typedefs */
      if (strncmp(cp, "vtk", 3) == 0)
        {
        for (i = 0; vtktypes[i].len != 0; i++)
          {
          if (n == vtktypes[i].len && strncmp(cp, vtktypes[i].name, n) == 0)
            {
            classname = vtktypes[i].name;
            base_bits = vtkParse_MapType((int)vtktypes[i].type);
            }
          }
        }

      /* check standard typedefs */
      if (base_bits == 0)
        {
        m = 0;
        if (strncmp(cp, "::", 2) == 0) { m = 2; }
        else if (strncmp(cp, "std::", 5) == 0) { m = 5; }
#ifndef VTK_LEGACY_REMOVE
        else if (strncmp(cp, "vtkstd::", 8) == 0) { m = 8; }
#endif

        /* advance past the namespace */
        tmpcp = cp + m;

        for (i = 0; stdtypes[i].len != 0; i++)
          {
          if (n == stdtypes[i].len && strncmp(tmpcp, stdtypes[i].name, n) == 0)
            {
            classname = stdtypes[i].name;
            base_bits = stdtypes[i].type;
            }
          }

        /* include the namespace if present */
        if (base_bits != 0 && m > 0)
          {
          classname = cp;
          len = n;
          }
        }

      /* anything else is assumed to be a class, enum, or who knows */
      if (base_bits == 0)
        {
        base_bits = VTK_PARSE_UNKNOWN;
        classname = cp;
        len = n;

        /* VTK classes all start with vtk */
        if (strncmp(classname, "vtk", 3) == 0)
          {
          base_bits = VTK_PARSE_OBJECT;
          /* make sure the "vtk" isn't just part of the namespace */
          for (k = 0; k < n; k++)
            {
            if (cp[k] == ':')
              {
              base_bits = VTK_PARSE_UNKNOWN;
              break;
              }
            }
          }
        /* Qt objects and enums */
        else if (classname[0] == 'Q' &&
                 ((classname[1] >= 'A' && classname[2] <= 'Z') ||
                  strncmp(classname, "Qt::", 4) == 0))
          {
          base_bits = VTK_PARSE_QOBJECT;
          }
        }
      }

    cp += n;
    while (*cp == ' ' || *cp == '\t') { cp++; }
    }

  if ((unsigned_bits & VTK_PARSE_UNSIGNED) != 0)
    {
    switch (base_bits)
      {
      case VTK_PARSE_CHAR:
        classname = "unsigned char";
        break;
      case VTK_PARSE_SHORT:
        classname = "unsigned short";
        break;
      case VTK_PARSE_INT:
        classname = "unsigned int";
        break;
      case VTK_PARSE_LONG:
        classname = "unsigned long";
        break;
      case VTK_PARSE_LONG_LONG:
        classname = "unsigned long long";
        break;
      case VTK_PARSE___INT64:
        classname = "unsigned __int64";
        break;
      }
    }

  *type_ptr = (static_bits | const_bits | unsigned_bits | base_bits);

  if (classname_ptr)
    {
    *classname_ptr = classname;
    if (len == 0)
      {
      len = strlen(classname);
      }
    *len_ptr = len;
    }

  return (size_t)(cp - text);
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t vtkParse_DecomposeTemplatedType ( const char *  text,
const char **  classname,
int  n,
const char ***  args,
const char *  defaults[] 
)

Extract the class name and template args from a templated class type ID.

Returns the full number of characters that were consumed during the decomposition.

Definition at line 1013 of file vtkParseExtras.c.

{
  size_t i, j, k, n;
  const char *arg;
  char *new_text;
  const char **template_args = NULL;
  int template_arg_count = 0;

  n = vtkParse_NameLength(text);

  /* is the class templated? */
  for (i = 0; i < n; i++)
    {
    if (text[i] == '<')
      {
      break;
      }
    }

  new_text = (char *)malloc(i + 1);
  strncpy(new_text, text, i);
  new_text[i] = '\0';
  *classname = new_text;

  if (text[i] == '<')
    {
    i++;
    /* extract the template arguments */
    for (;;)
      {
      while (text[i] == ' ' || text[i] == '\t') { i++; }
      j = i;
      while (text[j] != ',' && text[j] != '>' &&
             text[j] != '\n' && text[j] != '\0')
        {
        if (text[j] == '<' || text[j] == '(' ||
            text[j] == '[' || text[j] == '{')
          {
          j += vtkparse_bracket_len(&text[j]);
          }
        else if (text[j] == '\'' || text[j] == '\"')
          {
          j += vtkparse_quote_len(&text[j]);
          }
        else
          {
          j++;
          }
        }

      k = j;
      while (text[k-1] == ' ' || text[k-1] == '\t') { --k; }

      new_text = (char *)malloc(k-i + 1);
      strncpy(new_text, &text[i], k-i);
      new_text[k-i] = '\0';
      vtkParse_AddStringToArray(&template_args, &template_arg_count,
                                new_text);

      assert(template_arg_count <= nargs);

      i = j + 1;

      if (text[j] != ',')
        {
        break;
        }
      }
    }

  while (template_arg_count < nargs)
    {
    assert(defaults != NULL);
    arg = defaults[template_arg_count];
    assert(arg != NULL);
    new_text = (char *)malloc(strlen(arg + 1));
    strcpy(new_text, arg);
    vtkParse_AddStringToArray(&template_args, &template_arg_count, new_text);
    }

  *argp = template_args;

  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vtkParse_ExpandTypedef ( ValueInfo *  valinfo,
ValueInfo *  typedefinfo 
)

Expand a typedef within a variable, parameter, or typedef declaration.

The expansion is done in-place.

Definition at line 383 of file vtkParseExtras.c.

{
  const char *classname;
  unsigned int baseType;
  unsigned int pointers;
  unsigned int refbit;
  unsigned int qualifiers;
  unsigned int tmp1, tmp2;
  int i;

  classname = typedefinfo->Class;
  baseType = (typedefinfo->Type & VTK_PARSE_BASE_TYPE);
  pointers = (typedefinfo->Type & VTK_PARSE_POINTER_MASK);
  refbit = (valinfo->Type & VTK_PARSE_REF);
  qualifiers = (typedefinfo->Type & VTK_PARSE_CONST);

  /* handle const */
  if ((valinfo->Type & VTK_PARSE_CONST) != 0)
    {
    if ((pointers & VTK_PARSE_POINTER_LOWMASK) != 0)
      {
      if ((pointers & VTK_PARSE_POINTER_LOWMASK) != VTK_PARSE_ARRAY)
        {
        /* const turns into const pointer */
        pointers = (pointers & ~VTK_PARSE_POINTER_LOWMASK);
        pointers = (pointers | VTK_PARSE_CONST_POINTER);
        }
      }
    else
      {
      /* const remains as const value */
      qualifiers = (qualifiers | VTK_PARSE_CONST);
      }
    }

  /* make a reversed copy of the pointer bitfield */
  tmp1 = (valinfo->Type & VTK_PARSE_POINTER_MASK);
  tmp2 = 0;
  while (tmp1)
    {
    tmp2 = ((tmp2 << 2) | (tmp1 & VTK_PARSE_POINTER_LOWMASK));
    tmp1 = ((tmp1 >> 2) & VTK_PARSE_POINTER_MASK);
    }

  /* turn pointers into zero-element arrays where necessary */
  if ((pointers & VTK_PARSE_POINTER_LOWMASK) == VTK_PARSE_ARRAY)
    {
    tmp2 = ((tmp2 >> 2) & VTK_PARSE_POINTER_MASK);
    while (tmp2)
      {
      vtkParse_AddStringToArray(
        &valinfo->Dimensions, &valinfo->NumberOfDimensions, "");
      tmp2 = ((tmp2 >> 2) & VTK_PARSE_POINTER_MASK);
      }
    }
  else
    {
    /* combine the pointers */
    while (tmp2)
      {
      pointers = ((pointers << 2) | (tmp2 & VTK_PARSE_POINTER_LOWMASK));
      tmp2 = ((tmp2 >> 2) & VTK_PARSE_POINTER_MASK);
      }
    }

  /* combine the arrays */
  for (i = 0; i < typedefinfo->NumberOfDimensions; i++)
    {
    vtkParse_AddStringToArray(
      &valinfo->Dimensions, &valinfo->NumberOfDimensions,
      typedefinfo->Dimensions[i]);
    }
  if (valinfo->NumberOfDimensions > 1)
    {
    pointers = ((pointers & ~VTK_PARSE_POINTER_LOWMASK) | VTK_PARSE_ARRAY);
    }

  /* put everything together */
  valinfo->Type = (baseType | pointers | refbit | qualifiers);
  valinfo->Class = classname;
  valinfo->Function = typedefinfo->Function;
  valinfo->Count *= typedefinfo->Count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vtkParse_ExpandTypedefs ( ValueInfo *  valinfo,
int  n,
const char *  name[],
const char *  val[],
ValueInfo *  typedefinfo[] 
)

Expand any unrecognized types within a variable, parameter, or typedef that match any of the supplied typedefs.

The expansion is done in-place.

Definition at line 469 of file vtkParseExtras.c.

{
  int i;

  if (((val->Type & VTK_PARSE_BASE_TYPE) == VTK_PARSE_OBJECT ||
       (val->Type & VTK_PARSE_BASE_TYPE) == VTK_PARSE_UNKNOWN) &&
      val->Class != 0)
   {
   for (i = 0; i < n; i++)
     {
     if (typedefinfo[i] && strcmp(val->Class, typedefinfo[i]->Name) == 0)
       {
       vtkParse_ExpandTypedef(val, typedefinfo[i]);
       break;
       }
     }
   if (i == n)
     {
     /* in case type appears as a template arg of another type */
     val->Class = vtkparse_string_replace(val->Class, n, names, values, 1);
     }
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vtkParse_ExpandValues ( ValueInfo *  valinfo,
int  n,
const char *  name[],
const char *  val[] 
)

Wherever one of the specified names exists inside a Value or inside a Dimension size, replace it with the corresponding val string.

This is used to replace constants with their values.

Definition at line 338 of file vtkParseExtras.c.

{
  int j, m, dim, count;
  const char *cp;

  if (valinfo->Value)
    {
    valinfo->Value = vtkparse_string_replace(valinfo->Value, n, name, val, 1);
    }

  m = valinfo->NumberOfDimensions;
  if (m)
    {
    count = 1;
    for (j = 0; j < m; j++)
      {
      cp = valinfo->Dimensions[j];
      if (cp)
        {
        cp = vtkparse_string_replace(cp, n, name, val, 1);
        valinfo->Dimensions[j] = cp;

        /* check whether dimension has become an integer literal */
        if (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X')) { cp += 2; }
        while (*cp >= '0' && *cp <= '9') { cp++; }
        while (*cp == 'u' || *cp == 'l' || *cp == 'U' || *cp == 'L') { cp++; }
        dim = 0;
        if (*cp == '\0')
          {
          dim = (int)strtol(valinfo->Dimensions[j], NULL, 0);
          }
        count *= dim;
        }
      }

    /* update count if all values are integer literals */
    if (count)
      {
      valinfo->Count = count;
      }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vtkParse_FreeTemplateDecomposition ( const char *  classname,
int  n,
const char **  args 
)

Free the list of strings returned by ExtractTemplateArgs.

Definition at line 1101 of file vtkParseExtras.c.

{
  int i;

  if (name)
    {
    free((char *)name);
    }

  if (n > 0)
    {
    for (i = 0; i < n; i++)
      {
      free((char *)args[i]);
      }

    free((char **)args);
    }
}

Here is the caller graph for this function:

const char** vtkParse_GetArrayTypes ( )

Get a zero-terminated array of the types in vtkArray.

Definition at line 1555 of file vtkParseExtras.c.

{
  static const char *types[] = {
    "char", "signed char", "unsigned char", "short", "unsigned short",
    "int", "unsigned int", "long", "unsigned long",
#ifdef VTK_TYPE_USE_LONG_LONG
    "long long", "unsigned long long",
#endif
#ifdef VTK_TYPE_USE___INT64
    "__int64", "unsigned __int64",
#endif
    "float", "double",
    "vtkStdString", "vtkUnicodeString", "vtkVariant", NULL };

  return types;
}

Get a zero-terminated array of the types in vtkTemplateMacro.

Definition at line 1538 of file vtkParseExtras.c.

{
  static const char *types[] = {
    "char", "signed char", "unsigned char", "short", "unsigned short",
    "int", "unsigned int", "long", "unsigned long",
#ifdef VTK_TYPE_USE_LONG_LONG
    "long long", "unsigned long long",
#endif
#ifdef VTK_TYPE_USE___INT64
    "__int64", "unsigned __int64",
#endif
    "float", "double", NULL };

  return types;
}
size_t vtkParse_IdentifierLength ( const char *  text)

This file contains extra utilities for parsing and wrapping.

Skip over a sequence of characters that begin with an alphabetic character or an underscore, and include only alphanumeric characters or underscores. Return the number of characters.

Definition at line 157 of file vtkParseExtras.c.

{
  return vtkparse_id_len(text);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vtkParse_InstantiateClassTemplate ( ClassInfo *  data,
int  n,
const char *  args[] 
)

Instantiate a class template by substituting the provided arguments for the template parameters.

If "n" is less than the number of template parameters, then default parameter values (if present) will be used. If an error occurs, the error will be printed to stderr and NULL will be returned.

Definition at line 1124 of file vtkParseExtras.c.

{
  TemplateArgs *t = data->Template;
  const char **new_args = NULL;
  const char **arg_names = NULL;
  ValueInfo **arg_types = NULL;
  int i, m;
  char *new_name;
  size_t k;

  if (t == NULL)
    {
    fprintf(stderr, "vtkParse_InstantiateClassTemplate: "
            "this class is not templated.\n");
    return;
    }

  m = t->NumberOfArguments;
  if (n > m)
    {
    fprintf(stderr, "vtkParse_InstantiateClassTemplate: "
            "too many template args.\n");
    return;
    }

  for (i = n; i < m; i++)
    {
    if (t->Arguments[i]->Value == NULL ||
        t->Arguments[i]->Value[0] == '\0')
      {
      fprintf(stderr, "vtkParse_InstantiateClassTemplate: "
              "too few template args.\n");
      return;
      }
    }

  if (n < m)
    {
    new_args = (const char **)malloc(m*sizeof(char **));
    for (i = 0; i < n; i++)
      {
      new_args[i] = args[i];
      }
    for (i = n; i < m; i++)
      {
      new_args[i] = t->Arguments[i]->Value;
      }
    args = new_args;
    }

  arg_names = (const char **)malloc(m*sizeof(char **));
  arg_types = (ValueInfo **)malloc(m*sizeof(ValueInfo *));
  for (i = 0; i < m; i++)
    {
    arg_names[i] = t->Arguments[i]->Name;
    arg_types[i] = NULL;
    if (t->Arguments[i]->Type == 0)
      {
      arg_types[i] = (ValueInfo *)malloc(sizeof(ValueInfo));
      vtkParse_InitValue(arg_types[i]);
      vtkParse_ValueInfoFromString(arg_types[i], args[i]);
      arg_types[i]->ItemType = VTK_TYPEDEF_INFO;
      arg_types[i]->Name = arg_names[i];
      }
    }

  /* no longer a template (has been instantiated) */
  if (data->Template)
    {
    vtkParse_FreeTemplateArgs(data->Template);
    }
  data->Template = NULL;

  /* append template args to class name */
  k = strlen(data->Name) + 2;
  for (i = 0; i < m; i++)
    {
    k += strlen(args[i]) + 2;
    }
  new_name = (char *)malloc(k);
  strcpy(new_name, data->Name);
  k = strlen(new_name);
  new_name[k++] = '<';
  for (i = 0; i < m; i++)
    {
    strcpy(&new_name[k], args[i]);
    k += strlen(args[i]);
    if (i+1 < m)
      {
      new_name[k++] = ',';
      new_name[k++] = ' ';
      }
    }
  if (new_name[k-1] == '>')
    {
    new_name[k++] = ' ';
    }
  new_name[k++] = '>';
  new_name[k] = '\0';
  data->Name = vtkParse_DuplicateString(new_name, k);
  free((char *)new_name);

  /* do the template arg substitution */
  class_substitution(data, m, arg_names, args, arg_types);

  /* free all allocated arrays */
  if (new_args)
    {
    free((char **)new_args);
    }

  free((char **)arg_names);

  for (i = 0; i < m; i++)
    {
    if (arg_types[i])
      {
      vtkParse_FreeValue(arg_types[i]);
      }
    }
  free(arg_types);
}

Here is the call graph for this function:

void vtkParse_IntantiateFunctionTemplate ( FunctionInfo *  data,
int  n,
const char *  args 
)

Instantiate a function or class method template by substituting the provided arguments for the template parameters.

If "n" is less than the number of template parameters, then default parameter values (if present) will be used. If an error occurs, the error will be printed to stderr and NULL will be returned.

size_t vtkParse_LiteralLength ( const char *  text)

Skip over a literal, which may be a number, a char in single quotes, a string in double quotes, or a name, or a name followed by arguments in parentheses.

size_t vtkParse_MangledLiteral ( const char *  name,
char *  new_name 
)

Generate a mangled name for a literal.

Only handles decimal integer literals. It guesses type from suffix "u", "ul", "ull", "l", "ll" so only certain types are supported.

Definition at line 1478 of file vtkParseExtras.c.

{
  const char *cp = name;
  size_t i = 0;
  char *tmp;

  /* only decimal integers are supported for now */
  if (*cp >= '0' && *cp <= '9')
    {
    /* reject octal and hexadecimal */
    if (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X' ||
                         (cp[1] >= '0' && cp[1] <= '9')))
      {
      new_name[0] = '\0';
      return 0;
      }

    new_name[i++] = 'L';
    tmp = &new_name[i];
    new_name[i++] = 'i';
    do { new_name[i++] = *cp++; }
    while (*cp >= '0' && *cp <= '9');

    /* reject floats */
    if (*cp == '.' || *cp == 'f' || *cp == 'e' || *cp == 'E')
      {
      new_name[0] = '\0';
      return 0;
      }

    for (;;)
      {
      if (*cp == 'u' || *cp == 'U')
        {
        if (*tmp == 'i') { *tmp = 'j'; }
        else if (*tmp == 'l') { *tmp = 'm'; }
        else if (*tmp == 'x') { *tmp = 'y'; }
        cp++;
        }
      else if (*cp == 'l' || *cp == 'L')
        {
        if (*tmp == 'i') { *tmp = 'l'; }
        else if (*tmp == 'j') { *tmp = 'm'; }
        else if (*tmp == 'l') { *tmp = 'x'; }
        else if (*tmp == 'm') { *tmp = 'y'; }
        cp++;
        }
      else
        {
        break;
        }
      }
    new_name[i++] = 'E';
    }
  new_name[i] = '\0';

  return (size_t)(cp - name);
}

Here is the caller graph for this function:

size_t vtkParse_MangledTypeName ( const char *  name,
char *  new_name 
)

Generate a mangled name for a type, use gcc ia64 ABI.

The result is placed in new_name, which must be large enough to accept the result.

Definition at line 1252 of file vtkParseExtras.c.

{
  int scoped = 0;
  unsigned int ptype = 0;
  size_t j, k, m;
  size_t i = 0;
  const char *cp;
  char basictype;

  m = vtkParse_BasicTypeFromString(name, &ptype, NULL, NULL);

  /* look for pointers */
  cp = &name[m];
  while (*cp == ' ' || *cp == '\t') { cp++; }
  while (*cp == '*')
    {
    do { cp++; } while (*cp == ' ' || *cp == '\t');
    if (*cp == 'c' && strncmp(cp, "const", 5) == 0 &&
        ((cp[5] < 'A' || cp[5] > 'Z') &&
         (cp[5] < 'a' || cp[5] > 'z') &&
         (cp[5] < '0' || cp[5] > '9') &&
         cp[5] != '_'))
      {
      cp += 4;
      do { cp++; } while (*cp == ' ' || *cp == '\t');
      new_name[i++] = 'K';
      }
    new_name[i++] = 'P';
    }

  /* prepend reference if present */
  if (*cp == '&')
    {
    do { cp++; } while (*cp == ' ' || *cp == '\t');
    for (k = i; k > 0; --k)
      {
      new_name[k] = new_name[k-1];
      }
    new_name[0] = 'R';
    i++;
    }

  /* array brackets are not handled */

  /* qualifiers */
  if (ptype & VTK_PARSE_CONST)
    {
    new_name[i++] = 'K';
    }

  /* types: the following are unused
   *  'w' -> wchar_t
   *  'n' -> __int128
   *  'o' -> unsigned __int128
   *  'e' -> __float80
   *  'g' -> __float128
   *  'z' -> ... (varargs)
   */

  basictype = '\0';
  switch (ptype & VTK_PARSE_BASE_TYPE)
    {
    case VTK_PARSE_VOID:
      basictype = 'v';
      break;
    case VTK_PARSE_BOOL:
      basictype = 'b';
      break;
    case VTK_PARSE_CHAR:
      basictype = 'c';
      break;
    case VTK_PARSE_SIGNED_CHAR:
      basictype = 'a';
      break;
    case VTK_PARSE_UNSIGNED_CHAR:
      basictype = 'h';
      break;
    case VTK_PARSE_SHORT:
      basictype = 's';
      break;
    case VTK_PARSE_UNSIGNED_SHORT:
      basictype = 't';
      break;
    case VTK_PARSE_INT:
      basictype = 'i';
      break;
    case VTK_PARSE_UNSIGNED_INT:
      basictype = 'j';
      break;
    case VTK_PARSE_LONG:
      basictype = 'l';
      break;
    case VTK_PARSE_UNSIGNED_LONG:
      basictype = 'm';
      break;
    case VTK_PARSE_LONG_LONG:
    case VTK_PARSE___INT64:
      basictype = 'x';
      break;
    case VTK_PARSE_UNSIGNED_LONG_LONG:
    case VTK_PARSE_UNSIGNED___INT64:
      basictype = 'y';
      break;
    case VTK_PARSE_FLOAT:
      basictype = 'f';
      break;
    case VTK_PARSE_DOUBLE:
      basictype = 'd';
      break;
    }

  if (basictype)
    {
    new_name[i++] = basictype;
    new_name[i] = '\0';
    return (size_t)(cp - name);
    }

  m = 0;
  cp = name;
  do
    {
    cp += m;
    while (*cp == ' ' || *cp == '\t') { cp++; }
    m = vtkParse_UnscopedNameLength(cp);
    }
  while ((m == 5 && strncmp("const", cp, 5) == 0) ||
         (m == 8 && strncmp("volatile", cp, 8) == 0));

  if (cp[m] == ':' && cp[m+1] == ':')
    {
    if (m == 3 && strncmp(cp, "std::", 5) == 0)
      {
      cp += 5;
      m = vtkParse_UnscopedNameLength(cp);
      if (cp[m] == ':' && cp[m+1] == ':')
        {
        new_name[i++] = 'N';
        scoped = 1;
        }
      /* short form for "std::" */
      new_name[i++] = 'S';
      new_name[i++] = 't';
      }
    else
      {
      new_name[i++] = 'N';
      scoped = 1;
      }
    }

  do
    {
    if (cp[0] == ':' && cp[1] == ':')
      {
      cp += 2;
      m = vtkParse_UnscopedNameLength(cp);
      }

    for (j = 0; j < m; j++)
      {
      if (cp[j] == '<')
        {
        break;
        }
      }

    /* write out identifier length */
    if (j >= 100) { new_name[i++] = '0' + (char)(j/100); }
    if (j >= 10) { new_name[i++] = '0' + (char)((j%100)/10); }
    new_name[i++] = '0' + (char)(j%10);

    /* write out the identifier */
    strncpy(&new_name[i], cp, j);
    i += j;
    cp += j;

    /* handle template args */
    if (*cp == '<')
      {
      new_name[i++] = 'I';
      do
        {
        do { cp++; } while (*cp == ' ' || *cp == '\t');
        m = 0;
        if ((*cp >= '0' && *cp <= '9') ||
            (*cp == '.' && cp[1] >= '0' && cp[1] <= '9') ||
            *cp == '\'' || *cp == '\"')
          {
          m = vtkParse_MangledLiteral(cp, &new_name[i]);
          }
        else
          {
          m = vtkParse_MangledTypeName(cp, &new_name[i]);
          }
        if (m == 0)
          {
          return 0;
          }
        cp += m;
        i = strlen(new_name);
        while (*cp == ' ' || *cp == '\t') { cp++; }
        }
      while (*cp == ',');
      new_name[i++] = 'E';
      if (*cp != '>')
        {
        new_name[i] = '\0';
        return 0;
        }
      cp++;
      }
    }
  while (cp[0] == ':' && cp[1] == ':');

  if (scoped)
    {
    new_name[i++] = 'E';
    }

  new_name[i] = '\0';

  return (size_t)(cp - name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t vtkParse_NameLength ( const char *  text)

Skip over a name, including any namespace prefixes and any template arguments.

Return the number of characters.

Definition at line 184 of file vtkParseExtras.c.

{
  size_t i = 0;
  do
    {
    if (text[i] == ':' && text[i+1] == ':') { i += 2; }
    i += vtkParse_UnscopedNameLength(&text[i]);
    }
  while (text[i] == ':' && text[i+1] == ':');
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* vtkParse_StringReplace ( const char *  str1,
int  n,
const char *  name[],
const char *  val[] 
)

Search for all occurences of "name" and replace with the corresponding "val", return the initial string if no replacements occurred, otherwise return a new string allocated with malloc.

Definition at line 1005 of file vtkParseExtras.c.

{
  return vtkparse_string_replace(str1, n, name, val, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t vtkParse_UnscopedNameLength ( const char *  text)

Skip over a name, including any template parameters, but stopping if a '::' is encoutered.

Return the number of characters.

Definition at line 164 of file vtkParseExtras.c.

{
  size_t i = 0;

  i += vtkparse_id_len(text);
  if (text[i] == '<')
    {
    i += vtkparse_bracket_len(&text[i]);
    if (text[i-1] != '>')
      {
      fprintf(stderr, "Bad template args %*.*s\n", (int)i, (int)i, text);
      return 0;
      }
    }

  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vtkParse_ValueInfoFromString ( ValueInfo *  val,
const char *  text 
)

Generate a ValueInfo by parsing the type from the provided text.

Only simple text strings are supported, e.g. "const T **".

Definition at line 786 of file vtkParseExtras.c.

{
  const char *cp = text;
  size_t n;
  int m, count;
  unsigned int base_bits = 0;
  unsigned int pointer_bits = 0;
  unsigned int ref_bits = 0;
  const char *classname = NULL;

  /* get the basic type with qualifiers */
  cp += vtkParse_BasicTypeFromString(cp, &base_bits, &classname, &n);

  data->Class = vtkParse_DuplicateString(classname, n);

  if ((base_bits & VTK_PARSE_STATIC) != 0)
    {
    data->IsStatic = 1;
    }

  /* look for pointers (and const pointers) */
  while (*cp == '*')
    {
    cp++;
    pointer_bits = (pointer_bits << 2);
    while (*cp == ' ' || *cp == '\t') { cp++; }
    if (strncmp(cp, "const", 5) == 0 &&
        (cp[5] < 'a' || cp[5] > 'z') &&
        (cp[5] < 'A' || cp[5] > 'Z') &&
        (cp[5] < '0' || cp[5] > '9') &&
        cp[5] != '_')
      {
      cp += 5;
      while (*cp == ' ' || *cp == '\t') { cp++; }
      pointer_bits = (pointer_bits | VTK_PARSE_CONST_POINTER);
      }
    else
      {
      pointer_bits = (pointer_bits | VTK_PARSE_POINTER);
      }
    pointer_bits = (pointer_bits & VTK_PARSE_POINTER_MASK);
    }

  /* look for ref */
  if (*cp == '&')
    {
    cp++;
    while (*cp == ' ' || *cp == '\t') { cp++; }
    ref_bits = VTK_PARSE_REF;
    }

  /* look for the variable name */
  if ((*cp >= 'a' && *cp <= 'z') ||
      (*cp >= 'A' && *cp <= 'Z') ||
      (*cp == '_'))
    {
    /* skip all chars that are part of a name */
    n = vtkparse_id_len(cp);
    data->Name = vtkParse_DuplicateString(cp, n);
    cp += n;
    while (*cp == ' ' || *cp == '\t') { cp++; }
    }

  /* look for array brackets */
  if (*cp == '[')
    {
    count = 1;
    }

  while (*cp == '[')
    {
    n = vtkparse_bracket_len(cp);
    if (n > 0)
      {
      cp++;
      n--;
      }
    while (*cp == ' ' || *cp == '\t') { cp++; n--; }
    while (n > 0 && (cp[n-1] == ' ' || cp[n-1] == '\t')) { n--; }
    vtkParse_AddStringToArray(&data->Dimensions,
                              &data->NumberOfDimensions,
                              vtkParse_DuplicateString(cp, n));
    m = 0;
    if (*cp >= '0' && *cp <= '9' && vtkparse_number_len(cp) == n)
      {
      m = (int)strtol(cp, NULL, 0);
      }
    count *= m;

    cp += n;
    while (*cp == ' ' || *cp == '\t') { cp++; }
    if (cp[n] == ']') { cp++; }
    while (*cp == ' ' || *cp == '\t') { cp++; }
    }

  /* add pointer indirection to correspond to first array dimension */
  if (data->NumberOfDimensions > 1)
    {
    pointer_bits = ((pointer_bits << 2) | VTK_PARSE_ARRAY);
    }
  else if (data->NumberOfDimensions == 1)
    {
    pointer_bits = ((pointer_bits << 2) | VTK_PARSE_POINTER);
    }
  pointer_bits = (pointer_bits & VTK_PARSE_POINTER_MASK);

  /* (Add code here to look for "=" followed by a value ) */

  data->Type = (pointer_bits | ref_bits | base_bits);
}

Here is the call graph for this function:

Here is the caller graph for this function: