PageRenderTime 164ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Doc/Devel/parm.html

#
HTML | 102 lines | 73 code | 29 blank | 0 comment | 0 complexity | 9b752fc84028337f15d17385b1013a56 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. <html>
  2. <head>
  3. <title>SWIG Parameter Handling</title>
  4. </head>
  5. <body>
  6. <center>
  7. <h1>SWIG Parameter Handling</h1>
  8. <p>
  9. David M. Beazley <br>
  10. dave-swig@dabeaz.com<br>
  11. January 9, 2007<br>
  12. </b>
  13. </center>
  14. <h2>Introduction</h2>
  15. This document describes the functions related to management of function parameters and parameter lists in the SWIG core. These functions are declared in <tt>Source/Swig/swigparm.h</tt>. This API is considered to be stable.
  16. <h2>Parameters</h2>
  17. The following utility functions are used to create and copy individual parameters. In their most basic form, a parameter merely contains a type, a name, and an optional default value.
  18. <p>
  19. <b><tt>Parm *NewParm(SwigType *type, const String_or_char *name)</tt></b>
  20. <blockquote>
  21. Creates a new parameter object with type <tt>type</tt> and name <tt>name</tt>. The type is stored in the attribute "type" and the name is stored in the attribute "name".
  22. </blockquote>
  23. <p>
  24. <b><tt>Parm *CopyParm(Parm *p)</tt></b>
  25. <blockquote>
  26. Copies a parameter object. All string attributes are copied in the
  27. process of making the copy. However, no complex attributes (lists,
  28. hashes, etc.) are copied.
  29. </blockquote>
  30. <h2>Parameter Lists</h2>
  31. <p>
  32. <b><tt>ParmList *CopyParmList(ParmList *p)</tt></b>
  33. <blockquote>
  34. Creates a copy of a parameter list. A parameter list is merely a linked list of parameters created by NewParm().
  35. </blockquote>
  36. <p>
  37. <b><tt>ParmList *CopyParmListMax(ParmList *p, int count)</tt></b>
  38. <blockquote>
  39. Copies at most <tt>count</tt> parameters from the parameter list <tt>p</tt>.
  40. </blockquote>
  41. <p>
  42. <b><tt>int ParmList_len(ParmList *p)</tt></b>
  43. <blockquote>
  44. Returns the total number of parameters in a parameter list.
  45. </blockquote>
  46. <p>
  47. <b><tt>int ParmList_numrequired(ParmList *p)</tt></b>
  48. <blockquote>
  49. Returns the number of required parameters in a parameter list. This pertains to invoking a function/method in C/C++.
  50. </blockquote>
  51. <p>
  52. <b><tt>int ParmList_has_defaultargs(ParmList *p)</tt></b>
  53. <blockquote>
  54. Returns 1 if the parameter list has any default arguments. Otherwise returns 0.
  55. </blockquote>
  56. <h2>Code Generation Functions</h2>
  57. <p>
  58. <b><tt>String *ParmList_str(ParmList *p)</tt></b>
  59. <blockquote>
  60. Creates a C prototype string of the parameters, but without any default values.
  61. </blockquote>
  62. <p>
  63. <b><tt>String *ParmList_str_defaultargs(ParmList *p)</tt></b>
  64. <blockquote>
  65. Creates a C prototype string of the parameters and includes the default values (if any).
  66. </blockquote>
  67. <p>
  68. <b><tt>String *ParmList_protostr(ParmList *p)</tt></b>
  69. <blockquote>
  70. Creates a C prototype string of the parameters.
  71. </blockquote>
  72. </body>
  73. </html>