mirror of https://github.com/swig/swig
Fix comments and newlines within operator definitions
Fix handling of conversion operators where the operator is split over multiple lines or has comments within the operator type. Also fix similar problem with normal operators which gave a syntax error if split over multiple lines or had a comment within the operator declaration. Closes #401
This commit is contained in:
parent
0fad8a3728
commit
cf29b90a2b
|
@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.6 (in progress)
|
Version 3.0.6 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2015-05-01: wsfulton
|
||||||
|
Fix handling of conversion operators where the operator is split over multiple
|
||||||
|
lines or has comments within the operator type. Fixes #401.
|
||||||
|
|
||||||
|
Also fix similar problem with normal operators which gave a syntax error if split over
|
||||||
|
multiple lines or had a comment within the operator declaration.
|
||||||
|
|
||||||
2015-04-30: olly
|
2015-04-30: olly
|
||||||
Ignore unknown preprocessor directives which are inside an inactive
|
Ignore unknown preprocessor directives which are inside an inactive
|
||||||
conditional (github issue #394, reported by Dan Wilcox).
|
conditional (github issue #394, reported by Dan Wilcox).
|
||||||
|
|
|
@ -156,6 +156,7 @@ CPP_TEST_CASES += \
|
||||||
conversion \
|
conversion \
|
||||||
conversion_namespace \
|
conversion_namespace \
|
||||||
conversion_ns_template \
|
conversion_ns_template \
|
||||||
|
conversion_operators \
|
||||||
cplusplus_throw \
|
cplusplus_throw \
|
||||||
cpp_basic \
|
cpp_basic \
|
||||||
cpp_enum \
|
cpp_enum \
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
%module conversion_operators
|
||||||
|
|
||||||
|
// Test bug #401 where the conversion operator name incorrectly included the newline character
|
||||||
|
// Also test comments around conversion operators due to special handling in the scanner for conversion operators
|
||||||
|
|
||||||
|
// These one line ignores should match the conversion operator names to suppress Warning 503 - SWIGWARN_LANG_IDENTIFIER
|
||||||
|
%ignore operator const EcReal;
|
||||||
|
%ignore operator EcImaginary const;
|
||||||
|
%ignore operator EcComplex const;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
|
||||||
|
struct EcReal {};
|
||||||
|
struct EcImaginary {};
|
||||||
|
struct EcComplex {};
|
||||||
|
|
||||||
|
struct EcAngle {
|
||||||
|
operator const EcReal
|
||||||
|
(
|
||||||
|
) const;
|
||||||
|
operator EcImaginary
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
operator
|
||||||
|
EcComplex
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EcAngle2 {
|
||||||
|
operator const EcReal/* C comment */
|
||||||
|
(
|
||||||
|
) const;
|
||||||
|
operator EcImaginary/* C comment */
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
operator/* C comment */
|
||||||
|
EcComplex
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EcAngle3 {
|
||||||
|
operator const EcReal // C++ comment
|
||||||
|
(
|
||||||
|
) const;
|
||||||
|
operator EcImaginary // C++ comment
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
operator // C++ comment
|
||||||
|
EcComplex
|
||||||
|
const (
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
%}
|
|
@ -12,6 +12,10 @@
|
||||||
%rename(PlusPlusPostfix) operator++(int);
|
%rename(PlusPlusPostfix) operator++(int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
%ignore operator new (size_t);
|
||||||
|
%ignore operator delete (void *);
|
||||||
|
%ignore operator delete[] (void *);
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -58,6 +62,11 @@ public:
|
||||||
void PrintK() {std::cerr << k << std::endl;}
|
void PrintK() {std::cerr << k << std::endl;}
|
||||||
|
|
||||||
int k;
|
int k;
|
||||||
|
void *operator new
|
||||||
|
(size_t); // definition split over two lines was giving syntax error
|
||||||
|
void operator delete /* comment here did not work */ (void *);
|
||||||
|
void operator
|
||||||
|
delete[] (void *);
|
||||||
};
|
};
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -610,7 +610,10 @@ int yylex(void) {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nexttok = Scanner_token(scan);
|
do {
|
||||||
|
nexttok = Scanner_token(scan);
|
||||||
|
} while (nexttok == SWIG_TOKEN_ENDLINE || nexttok == SWIG_TOKEN_COMMENT);
|
||||||
|
|
||||||
if (Scanner_isoperator(nexttok)) {
|
if (Scanner_isoperator(nexttok)) {
|
||||||
/* One of the standard C/C++ symbolic operators */
|
/* One of the standard C/C++ symbolic operators */
|
||||||
Append(s,Scanner_text(scan));
|
Append(s,Scanner_text(scan));
|
||||||
|
@ -681,6 +684,8 @@ int yylex(void) {
|
||||||
Append(s," ");
|
Append(s," ");
|
||||||
}
|
}
|
||||||
Append(s,Scanner_text(scan));
|
Append(s,Scanner_text(scan));
|
||||||
|
} else if (nexttok == SWIG_TOKEN_ENDLINE) {
|
||||||
|
} else if (nexttok == SWIG_TOKEN_COMMENT) {
|
||||||
} else {
|
} else {
|
||||||
Append(s,Scanner_text(scan));
|
Append(s,Scanner_text(scan));
|
||||||
needspace = 0;
|
needspace = 0;
|
||||||
|
|
Loading…
Reference in New Issue