Exemplo n.º 1
0
SwigType *SwigType_del_reference(SwigType *t) {
  char *c = Char(t);
  int check = strncmp(c, "r.", 2);
  assert(check == 0);
  Delslice(t, 0, 2);
  return t;
}
Exemplo n.º 2
0
SwigType *SwigType_del_array(SwigType *t) {
  char *c = Char(t);
  int check = strncmp(c, "a(", 2);
  assert(check == 0);
  Delslice(t, 0, element_size(c));
  return t;
}
Exemplo n.º 3
0
SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
  String *newq;
  int sz, added = 0;
  char *q, *cqual;

  char *c = Char(t);
  cqual = Char(qual);

  if (!(strncmp(c, "q(", 2) == 0)) {
    String *temp = NewStringf("q(%s).", cqual);
    Insert(t, 0, temp);
    Delete(temp);
    return t;
  }

  /* The type already has a qualifier on it.  In this case, we first check to
     see if the qualifier is already specified.  In that case do nothing.
     If it is a new qualifier, we add it to the qualifier list in alphabetical
     order */

  sz = element_size(c);

  if (strstr(c, cqual)) {
    /* Qualifier already added */
    return t;
  }

  /* Add the qualifier to the existing list. */

  newq = NewString("q(");
  q = c + 2;
  q = strtok(q, " ).");
  while (q) {
    if (strcmp(cqual, q) < 0) {
      /* New qualifier is less that current qualifier.  We need to insert it */
      Append(newq, cqual);
      Append(newq, " ");
      Append(newq, q);
      added = 1;
    } else {
      Append(newq, q);
    }
    q = strtok(NULL, " ).");
    if (q) {
      Append(newq, " ");
    }
  }
  if (!added) {
    Append(newq, " ");
    Append(newq, cqual);
  }
  Append(newq, ").");
  Delslice(t, 0, sz);
  Insert(t, 0, newq);
  Delete(newq);
  return t;
}
Exemplo n.º 4
0
SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
  char temp[256], newq[256];
  int sz, added = 0;
  char *q, *cqual;

  char *c = Char(t);
  cqual = Char(qual);

  if (!(strncmp(c, "q(", 2) == 0)) {
    sprintf(temp, "q(%s).", cqual);
    Insert(t, 0, temp);
    return t;
  }

  /* The type already has a qualifier on it.  In this case, we first check to
     see if the qualifier is already specified.  In that case do nothing.
     If it is a new qualifier, we add it to the qualifier list in alphabetical
     order */

  sz = element_size(c);
  strncpy(temp, c, (sz < 256) ? sz : 256);

  if (strstr(temp, cqual)) {
    /* Qualifier already added */
    return t;
  }

  /* Add the qualifier to the existing list. */

  strcpy(newq, "q(");
  q = temp + 2;
  q = strtok(q, " ).");
  while (q) {
    if (strcmp(cqual, q) < 0) {
      /* New qualifier is less that current qualifier.  We need to insert it */
      strcat(newq, cqual);
      strcat(newq, " ");
      strcat(newq, q);
      added = 1;
    } else {
      strcat(newq, q);
    }
    q = strtok(NULL, " ).");
    if (q) {
      strcat(newq, " ");
    }
  }
  if (!added) {
    strcat(newq, " ");
    strcat(newq, cqual);
  }
  strcat(newq, ").");
  Delslice(t, 0, sz);
  Insert(t, 0, newq);
  return t;
}
Exemplo n.º 5
0
SwigType *SwigType_del_pointer(SwigType *t) {
  char *c, *s;
  c = Char(t);
  s = c;
  /* Skip qualifiers, if any */
  if (strncmp(c, "q(", 2) == 0) {
    c = strchr(c, '.');
    assert(c);
    c++;
  }
  if (strncmp(c, "p.", 2)) {
    printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
    abort();
  }
  Delslice(t, 0, (c - s) + 2);
  return t;
}
Exemplo n.º 6
0
SwigType *SwigType_pop(SwigType *t) {
  SwigType *result;
  char *c;
  int sz;

  c = Char(t);
  if (!*c)
    return 0;

  sz = element_size(c);
  result = NewStringWithSize(c, sz);
  Delslice(t, 0, sz);
  c = Char(t);
  if (*c == '.') {
    Delitem(t, 0);
  }
  return result;
}
Exemplo n.º 7
0
SwigType *SwigType_del_element(SwigType *t) {
  int sz = element_size(Char(t));
  Delslice(t, 0, sz);
  return t;
}
Exemplo n.º 8
0
void
SwigType_del_array(SwigType *t) {
  char *c = Char(t);
  assert(strncmp(c,"a(",2) == 0);
  Delslice(t,0,element_size(c));
}
Exemplo n.º 9
0
void
SwigType_del_memberpointer(SwigType *t) {
  char *c = Char(t);
  assert(strncmp(c,"m(",2) == 0);
  Delslice(t,0,element_size(c));
}
Exemplo n.º 10
0
void
SwigType_del_qualifier(SwigType *t) {
  char *c = Char(t);
  assert(strncmp(c,"q(",2) == 0);
  Delslice(t,0,element_size(t));
}
Exemplo n.º 11
0
void
SwigType_del_reference(SwigType *t) {
  char *c = Char(t);
  assert(strncmp(c,"r.",2) == 0);
  Delslice(t,0,2);
}