@@ -1001,22 +1001,32 @@ namespace attributes {
10011001 return os;
10021002 }
10031003
1004- // Argument operator <<
1005- std::ostream& operator <<(std::ostream& os, const Argument& argument) {
1004+ // Print argument
1005+ void printArgument (std::ostream& os,
1006+ const Argument& argument,
1007+ bool printDefault = true ) {
10061008 if (!argument.empty ()) {
10071009 os << argument.type ();
10081010 if (!argument.name ().empty ()) {
10091011 os << " " ;
10101012 os << argument.name ();
1011- if (!argument.defaultValue ().empty ())
1013+ if (printDefault && !argument.defaultValue ().empty ())
10121014 os << " = " << argument.defaultValue ();
10131015 }
10141016 }
1017+ }
1018+
1019+ // Argument operator <<
1020+ std::ostream& operator <<(std::ostream& os, const Argument& argument) {
1021+ printArgument (os, argument);
10151022 return os;
10161023 }
10171024
1018- // Function operator <<
1019- std::ostream& operator <<(std::ostream& os, const Function& function) {
1025+ // Print function
1026+ void printFunction (std::ostream& os,
1027+ const Function& function,
1028+ bool printArgDefaults = true ) {
1029+
10201030 if (!function.empty ()) {
10211031 if (!function.type ().empty ()) {
10221032 os << function.type ();
@@ -1026,12 +1036,17 @@ namespace attributes {
10261036 os << " (" ;
10271037 const std::vector<Argument>& arguments = function.arguments ();
10281038 for (std::size_t i = 0 ; i<arguments.size (); i++) {
1029- os << arguments[i];
1039+ printArgument (os, arguments[i], printArgDefaults) ;
10301040 if (i != (arguments.size ()-1 ))
10311041 os << " , " ;
10321042 }
10331043 os << " )" ;
10341044 }
1045+ }
1046+
1047+ // Function operator <<
1048+ std::ostream& operator <<(std::ostream& os, const Function& function) {
1049+ printFunction (os, function);
10351050 return os;
10361051 }
10371052
@@ -2484,7 +2499,8 @@ namespace attributes {
24842499 // include prototype if requested
24852500 if (includePrototype) {
24862501 ostr << " // " << function.name () << std::endl;
2487- ostr << function << " ;" ;
2502+ printFunction (ostr, function, false );
2503+ ostr << " ;" ;
24882504 }
24892505
24902506 // write the C++ callable SEXP-based function (this version
0 commit comments