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 * The functions in this file are SWIG core functions that are deprecated
8 * or which do not fit in nicely with everything else. Generally this means
9 * that the function and/or API needs to be changed in some future release.
10 * ----------------------------------------------------------------------------- */
12 char cvsroot_deprecate_c[] = "$Id: parms.c 9630 2007-01-02 21:17:19Z beazley $";
16 /* ---------------------------------------------------------------------
17 * ParmList_is_compactdefargs()
19 * Returns 1 if the parameter list passed in is marked for compact argument
20 * handling (by the "compactdefargs" attribute). Otherwise returns 0.
21 * ---------------------------------------------------------------------- */
25 "compactdefargs" is a property set by the Parser to indicate special
26 handling of default arguments. This property seems to be something that
27 is associated with functions and methods rather than low-level ParmList
28 objects. Therefore, I don't like the fact that this special purpose
29 feature is bolted onto the side of ParmList objects.
33 1. "compactdefargs" should be a feature set on function/method nodes
34 instead of ParmList objects. For example, if you have a function,
35 you would check the function node to see if the parameters are
36 to be handled in this way.
41 1. This is used by functions in cwrap.c and emit.cxx, none of which
42 are passed information about the function/method node. We might
43 have to change the API of those functions to make this work correctly.
46 int emit_num_required(ParmList *parms)
50 int emit_num_required(ParmList *parms, int compactargs)
54 int ParmList_is_compactdefargs(ParmList *p) {
55 int compactdefargs = 0;
58 compactdefargs = Getattr(p, "compactdefargs") ? 1 : 0;
60 /* The "compactdefargs" attribute should only be set on the first parameter in the list.
61 * However, sometimes an extra parameter is inserted at the beginning of the parameter list,
62 * so we check the 2nd parameter too. */
63 if (!compactdefargs) {
64 Parm *nextparm = nextSibling(p);
65 compactdefargs = (nextparm && Getattr(nextparm, "compactdefargs")) ? 1 : 0;
69 return compactdefargs;
72 /* ---------------------------------------------------------------------
75 * Generate a prototype string suitable for use in error/warning messages.
76 * This function is aware of hidden parameters.
77 * ---------------------------------------------------------------------- */
79 /* Discussion. This function is used to generate error messages, but take
80 into account that there might be a hidden parameter. Although this involves
81 parameter lists, it really isn't a core feature of swigparm.h or parms.c.
82 This is because the "hidden" attribute of parameters is added elsewhere (cwrap.c).
84 For now, this function is placed here because it doesn't really seem to fit in
85 with the parms.c interface.
89 String *ParmList_errorstr(ParmList *p) {
90 String *out = NewStringEmpty();
92 if (Getattr(p,"hidden")) {
95 String *pstr = SwigType_str(Getattr(p, "type"), 0);