1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
7 * Parameter list class.
8 * ----------------------------------------------------------------------------- */
10 char cvsroot_parms_c[] = "$Id: parms.c 11080 2009-01-24 13:15:51Z bhy $";
14 /* ------------------------------------------------------------------------
17 * Create a new parameter from datatype 'type' and name 'name'.
18 * ------------------------------------------------------------------------ */
20 Parm *NewParm(SwigType *type, const_String_or_char_ptr name) {
22 set_nodeType(p, "parm");
24 SwigType *ntype = Copy(type);
25 Setattr(p, "type", ntype);
28 Setattr(p, "name", name);
32 /* ------------------------------------------------------------------------
34 * ------------------------------------------------------------------------ */
36 Parm *CopyParm(Parm *p) {
39 for (ki = First(p); ki.key; ki = Next(ki)) {
40 if (DohIsString(ki.item)) {
41 DOH *c = Copy(ki.item);
46 Setfile(np, Getfile(p));
47 Setline(np, Getline(p));
51 /* ------------------------------------------------------------------
54 * ------------------------------------------------------------------ */
56 ParmList *CopyParmListMax(ParmList *p, int count) {
65 if (count == 0) break;
68 set_nextSibling(pp, np);
80 ParmList *CopyParmList(ParmList *p) {
81 return CopyParmListMax(p,-1);
84 /* -----------------------------------------------------------------------------
85 * int ParmList_numrequired(). Return number of required arguments
86 * ----------------------------------------------------------------------------- */
88 int ParmList_numrequired(ParmList *p) {
91 SwigType *t = Getattr(p, "type");
92 String *value = Getattr(p, "value");
95 if (!(SwigType_type(t) == T_VOID))
104 /* -----------------------------------------------------------------------------
106 * ----------------------------------------------------------------------------- */
108 int ParmList_len(ParmList *p) {
117 /* ---------------------------------------------------------------------
120 * Generates a string of parameters
121 * ---------------------------------------------------------------------- */
123 String *ParmList_str(ParmList *p) {
124 String *out = NewStringEmpty();
126 String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name"));
137 /* ---------------------------------------------------------------------
138 * ParmList_str_defaultargs()
140 * Generates a string of parameters including default arguments
141 * ---------------------------------------------------------------------- */
143 String *ParmList_str_defaultargs(ParmList *p) {
144 String *out = NewStringEmpty();
146 String *value = Getattr(p, "value");
147 String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name"));
150 Printf(out, "=%s", value);
161 /* ---------------------------------------------------------------------
162 * ParmList_protostr()
164 * Generate a prototype string.
165 * ---------------------------------------------------------------------- */
167 String *ParmList_protostr(ParmList *p) {
168 String *out = NewStringEmpty();
170 String *pstr = SwigType_str(Getattr(p, "type"), 0);
181 /* ---------------------------------------------------------------------
182 * ParmList_has_defaultargs()
184 * Returns 1 if the parameter list passed in is has one or more default
185 * arguments. Otherwise returns 0.
186 * ---------------------------------------------------------------------- */
188 int ParmList_has_defaultargs(ParmList *p) {
190 if (Getattr(p, "value")) {