diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2014-10-21 07:32:45 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2014-10-21 07:34:51 +0100 |
commit | bfde14888745fb3f8d83bd7e8d8f1b8df1826db8 (patch) | |
tree | b085b9f3cc67fc409223a3931c8675de2159d2bb /Source | |
parent | b57a675d00a7e42bd145e62fd2e035400cc76873 (diff) | |
download | swig-bfde14888745fb3f8d83bd7e8d8f1b8df1826db8.tar.gz |
The kwargs feature no longer turns on compactdefaultargs for languages that don't support kwargs.
Affects all languages except Python and Ruby.
Closes #242
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CParse/parser.y | 3 | ||||
-rw-r--r-- | Source/Modules/lang.cxx | 8 | ||||
-rw-r--r-- | Source/Modules/main.cxx | 3 | ||||
-rw-r--r-- | Source/Modules/python.cxx | 7 | ||||
-rw-r--r-- | Source/Modules/ruby.cxx | 8 | ||||
-rw-r--r-- | Source/Modules/swigmod.h | 3 |
6 files changed, 31 insertions, 1 deletions
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index b334ace76..61b0462b5 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -59,6 +59,7 @@ static int compact_default_args = 0; static int template_reduce = 0; static int cparse_externc = 0; int ignore_nested_classes = 0; +int kwargs_supported = 0; /* ----------------------------------------------------------------------------- * Assist Functions * ----------------------------------------------------------------------------- */ @@ -1177,7 +1178,7 @@ static void default_arguments(Node *n) { if (compact_default_args || is_cfunction(function) || GetFlag(function,"feature:compactdefaultargs") - || GetFlag(function,"feature:kwargs")) { + || (GetFlag(function,"feature:kwargs") && kwargs_supported)) { ParmList *p = Getattr(function,"parms"); if (p) Setattr(p,"compactdefargs", "1"); /* mark parameters for special handling */ diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 9fa52cd2c..5b1547487 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3526,6 +3526,14 @@ Language::NestedClassSupport Language::nestedClassesSupport() const { } /* ----------------------------------------------------------------------------- + * Language::kwargsSupport() + * ----------------------------------------------------------------------------- */ + +bool Language::kwargsSupport() const { + return false; +} + +/* ----------------------------------------------------------------------------- * Language::is_wrapping_class() * ----------------------------------------------------------------------------- */ diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 47d0d374b..f41844d34 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -50,6 +50,7 @@ int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime extern "C" { extern String *ModuleName; extern int ignore_nested_classes; + extern int kwargs_supported; } /* usage string split into multiple parts otherwise string is too big for some compilers */ @@ -904,6 +905,8 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0; + kwargs_supported = l->kwargsSupport() ? 1 : 0; + // Create Library search directories // Check for SWIG_LIB environment variable diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index c5e4b63f6..b14f0903d 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4785,6 +4785,13 @@ public: return NewString("swigpyrun.h"); } + /*---------------------------------------------------------------------- + * kwargsSupport() + *--------------------------------------------------------------------*/ + + bool kwargsSupport() const { + return true; + } }; /* --------------------------------------------------------------- diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 6aeaae5a1..310e89b82 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -3426,6 +3426,14 @@ public: String *defaultExternalRuntimeFilename() { return NewString("swigrubyrun.h"); } + + /*---------------------------------------------------------------------- + * kwargsSupport() + *--------------------------------------------------------------------*/ + + bool kwargsSupport() const { + return true; + } }; /* class RUBY */ /* ----------------------------------------------------------------------------- diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 63b91bae5..33fecbcc7 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -315,6 +315,9 @@ public: */ virtual NestedClassSupport nestedClassesSupport() const; + /* Returns true if the target language supports key word arguments (kwargs) */ + virtual bool kwargsSupport() const; + protected: /* Identifies if a protected members that are generated when the allprotected option is used. This does not include protected virtual methods as they are turned on with the dirprot option. */ |