summaryrefslogtreecommitdiffstats
path: root/src/arguments.cpp
blob: 87d043845b3aac14ad4407101b544a1180a7bc4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "arguments.h"
#include "marshal.h"
#include <assert.h>

/*! the argument list is documented if one of its
 *  arguments is documented 
 */
bool ArgumentList::hasDocumentation() const
{
  bool hasDocs=FALSE;
  ArgumentListIterator ali(*this);
  Argument *a;
  for (ali.toFirst();!hasDocs && (a=ali.current());++ali)
  {
    hasDocs = a->hasDocumentation(); 
  }
  return hasDocs;
}

ArgumentList *ArgumentList::deepCopy() const
{
  ArgumentList *argList = new ArgumentList;
  argList->setAutoDelete(TRUE);

  QListIterator<Argument> ali(*this);
  Argument *a;
  for (;(a=ali.current());++ali)
  {
    argList->append(new Argument(*a));
  }
  argList->constSpecifier     = constSpecifier;
  argList->volatileSpecifier  = volatileSpecifier;
  argList->pureSpecifier      = pureSpecifier;
  argList->trailingReturnType = trailingReturnType;

  return argList;
}

ArgumentList *ArgumentList::unmarshal(StorageIntf *s)
{
  uint i;
  uint count = unmarshalUInt(s);
  if (count==NULL_LIST) return 0; // null list
  ArgumentList *result = new ArgumentList;
  assert(count<1000000);
  //printf("unmarshalArgumentList: %d\n",count);
  for (i=0;i<count;i++)
  {
    Argument *a = new Argument;
    a->attrib  = unmarshalQCString(s);
    a->type    = unmarshalQCString(s);
    a->canType = unmarshalQCString(s);
    a->name    = unmarshalQCString(s);
    a->array   = unmarshalQCString(s);
    a->defval  = unmarshalQCString(s);
    a->docs    = unmarshalQCString(s);
    a->typeConstraint = unmarshalQCString(s);
    result->append(a);
  }
  result->constSpecifier     = unmarshalBool(s);
  result->volatileSpecifier  = unmarshalBool(s);
  result->pureSpecifier      = unmarshalBool(s);
  result->trailingReturnType = unmarshalQCString(s);
  return result;
}

void ArgumentList::marshal(StorageIntf *s,ArgumentList *argList)
{
  if (argList==0)
  {
    marshalUInt(s,NULL_LIST); // null pointer representation
  }
  else
  {
    marshalUInt(s,argList->count());
    if (argList->count()>0)
    {
      ArgumentListIterator ali(*argList);
      Argument *a;
      for (ali.toFirst();(a=ali.current());++ali)
      {
        marshalQCString(s,a->attrib);    
        marshalQCString(s,a->type);    
        marshalQCString(s,a->canType);    
        marshalQCString(s,a->name);    
        marshalQCString(s,a->array);    
        marshalQCString(s,a->defval);    
        marshalQCString(s,a->docs);    
        marshalQCString(s,a->typeConstraint);
      }
    }
    marshalBool(s,argList->constSpecifier);
    marshalBool(s,argList->volatileSpecifier);
    marshalBool(s,argList->pureSpecifier);
    marshalQCString(s,argList->trailingReturnType);
  }
}