compact default arguments feature (original default argument wrapping mode)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6449 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2128e98a15
commit
97c2eeaf90
9 changed files with 68 additions and 17 deletions
|
|
@ -220,22 +220,26 @@ int emit_num_arguments(ParmList *parms) {
|
|||
*
|
||||
* Computes the number of required arguments. This function is safe for
|
||||
* use with multi-valued typemaps and knows how to skip over everything
|
||||
* properly. Note that it does count parameters which have a default value.
|
||||
* properly. Note that parameters with default values are counted unless
|
||||
* the compact default args option is on.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int emit_num_required(ParmList *parms) {
|
||||
Parm *p = parms;
|
||||
int nargs = 0;
|
||||
Parm *first_default_arg = 0;
|
||||
int compactdefargs = ParmList_is_compactdefargs(p);
|
||||
|
||||
while (p) {
|
||||
if (Getattr(p,"tmap:in") && checkAttribute(p,"tmap:in:numinputs","0")) {
|
||||
p = Getattr(p,"tmap:in:next");
|
||||
} else {
|
||||
if (Getattr(p,"tmap:default")) break;
|
||||
if (Getattr(p,"value"))
|
||||
if (Getattr(p,"value")) {
|
||||
if (!first_default_arg)
|
||||
first_default_arg = p;
|
||||
if (compactdefargs) break;
|
||||
}
|
||||
nargs+= GetInt(p,"tmap:in:numinputs");
|
||||
if (Getattr(p,"tmap:in")) {
|
||||
p = Getattr(p,"tmap:in:next");
|
||||
|
|
|
|||
|
|
@ -1089,7 +1089,8 @@ Language::staticmemberfunctionHandler(Node *n) {
|
|||
if (!defaultargs && code) {
|
||||
/* Hmmm. An added static member. We have to create a little wrapper for this */
|
||||
String *body;
|
||||
String *tmp = NewStringf("%s(%s)", cname, ParmList_str_defaultargs(parms));
|
||||
String *parmstring = CPlusPlus ? ParmList_str_defaultargs(parms) : ParmList_str(parms);
|
||||
String *tmp = NewStringf("%s(%s)", cname, parmstring);
|
||||
body = SwigType_str(type,tmp);
|
||||
Printv(body,code,"\n",NIL);
|
||||
Setattr(n,"wrap:code",body);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
char cvsroot_python_cxx[] = "$Header$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
|
|
@ -131,6 +132,7 @@ public:
|
|||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-keyword") == 0) {
|
||||
use_kw = 1;
|
||||
SWIG_cparse_set_compact_default_args(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-classic") == 0) {
|
||||
classic = 1;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@ private:
|
|||
File *f_wrappers;
|
||||
File *f_init;
|
||||
|
||||
bool use_kw;
|
||||
bool useGlobalModule;
|
||||
bool multipleInheritance;
|
||||
|
||||
|
|
@ -186,7 +185,6 @@ public:
|
|||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
f_init = 0;
|
||||
use_kw = false;
|
||||
useGlobalModule = false;
|
||||
multipleInheritance = false;
|
||||
}
|
||||
|
|
@ -996,7 +994,7 @@ public:
|
|||
int numarg = emit_num_arguments(l);
|
||||
int numreq = emit_num_required(l);
|
||||
int varargs = emit_isvarargs(l);
|
||||
bool allow_kwargs = use_kw || Getattr(n,"feature:kwargs");
|
||||
bool allow_kwargs = Getattr(n,"feature:kwargs");
|
||||
|
||||
bool use_director = (current == CONSTRUCTOR_INITIALIZE && Swig_directorclass(n));
|
||||
int start = (current == MEMBER_FUNC || current == MEMBER_VAR || use_director) ? 1 : 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue