add more support for operators + templates
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7807 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d34532e249
commit
e1534a90e0
3 changed files with 48 additions and 10 deletions
|
|
@ -12,6 +12,12 @@
|
||||||
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
template <class C>
|
||||||
|
struct Bar_T
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace test {
|
namespace test {
|
||||||
enum Hello {
|
enum Hello {
|
||||||
|
|
@ -166,6 +172,9 @@ namespace jafar {
|
||||||
template<class T>
|
template<class T>
|
||||||
void operator < (T& x){}
|
void operator < (T& x){}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
operator Bar_T<T> () {}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -173,8 +182,9 @@ namespace jafar {
|
||||||
|
|
||||||
%template(toFrame) jafar::jmath::EulerT3D::toFrame<int,int,int>;
|
%template(toFrame) jafar::jmath::EulerT3D::toFrame<int,int,int>;
|
||||||
%template(callint) jafar::jmath::EulerT3D::operator()<int>;
|
%template(callint) jafar::jmath::EulerT3D::operator()<int>;
|
||||||
%template(lessint) jafar::jmath::EulerT3D::operator< <int>;
|
%template(lessint) jafar::jmath::EulerT3D::operator < <int>;
|
||||||
|
%template(callfooi) jafar::jmath::EulerT3D::operator() <test::hola::FooT<int> >;
|
||||||
|
%template(lessfooi) jafar::jmath::EulerT3D::operator < < test::hola::FooT<int> >;
|
||||||
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
@ -225,3 +235,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
%template(hi) Ala::hi<int>;
|
%template(hi) Ala::hi<int>;
|
||||||
|
|
||||||
|
%extend jafar::jmath::EulerT3D
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ static int num_brace = 0;
|
||||||
static int last_brace = 0;
|
static int last_brace = 0;
|
||||||
static int last_id = 0;
|
static int last_id = 0;
|
||||||
static int rename_active = 0;
|
static int rename_active = 0;
|
||||||
|
static int swigtemplate_active = 0;
|
||||||
int cparse_cplusplus = 0;
|
int cparse_cplusplus = 0;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -527,7 +528,11 @@ int yylook(void) {
|
||||||
|
|
||||||
else if (c == '(') return (LPAREN);
|
else if (c == '(') return (LPAREN);
|
||||||
else if (c == ')') return (RPAREN);
|
else if (c == ')') return (RPAREN);
|
||||||
else if (c == ';') return (SEMI);
|
else if (c == ';') {
|
||||||
|
swigtemplate_active = 0;
|
||||||
|
return (SEMI);
|
||||||
|
}
|
||||||
|
|
||||||
else if (c == ',') return (COMMA);
|
else if (c == ',') return (COMMA);
|
||||||
else if (c == '*') return (STAR);
|
else if (c == '*') return (STAR);
|
||||||
else if (c == '}') {
|
else if (c == '}') {
|
||||||
|
|
@ -1154,8 +1159,16 @@ int yylex(void) {
|
||||||
retract(1);
|
retract(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((c == '<')) start_template = count;
|
if ((c == '<') && !start_template) {
|
||||||
if ((c == '>')) end_template = count;
|
int fcount = 1;
|
||||||
|
char c = nextchar();
|
||||||
|
while (isspace(c)) {c = nextchar(); ++fcount;}
|
||||||
|
if (isalpha(c)|| c == ':') {
|
||||||
|
start_template = count;
|
||||||
|
}
|
||||||
|
retract(fcount);
|
||||||
|
}
|
||||||
|
if ((c == '>') && start_template) end_template = count;
|
||||||
count++;
|
count++;
|
||||||
if (!isspace(c)) {
|
if (!isspace(c)) {
|
||||||
if ((!state) && (isalpha(c))) {
|
if ((!state) && (isalpha(c))) {
|
||||||
|
|
@ -1172,7 +1185,7 @@ int yylex(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Chop(s);
|
Chop(s);
|
||||||
if (start_template && end_template) {
|
if (swigtemplate_active && start_template && end_template) {
|
||||||
/*
|
/*
|
||||||
Manage the case:
|
Manage the case:
|
||||||
|
|
||||||
|
|
@ -1191,6 +1204,8 @@ int yylex(void) {
|
||||||
retract(count - start_template);
|
retract(count - start_template);
|
||||||
Delete(s);
|
Delete(s);
|
||||||
s = ns;
|
s = ns;
|
||||||
|
count = start_template;
|
||||||
|
isconversion = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1324,7 +1339,11 @@ int yylex(void) {
|
||||||
if (strcmp(yytext,"%types") == 0) return(TYPES);
|
if (strcmp(yytext,"%types") == 0) return(TYPES);
|
||||||
if (strcmp(yytext,"%parms") == 0) return(PARMS);
|
if (strcmp(yytext,"%parms") == 0) return(PARMS);
|
||||||
if (strcmp(yytext,"%varargs") == 0) return(VARARGS);
|
if (strcmp(yytext,"%varargs") == 0) return(VARARGS);
|
||||||
if (strcmp(yytext,"%template") == 0) return (SWIGTEMPLATE);
|
if (strcmp(yytext,"%template") == 0) {
|
||||||
|
swigtemplate_active = 1;
|
||||||
|
return (SWIGTEMPLATE);
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(yytext,"%warn") == 0) return(WARN);
|
if (strcmp(yytext,"%warn") == 0) return(WARN);
|
||||||
}
|
}
|
||||||
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */
|
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */
|
||||||
|
|
|
||||||
|
|
@ -3484,7 +3484,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para
|
||||||
/* We also place a fully parameterized version in the symbol table */
|
/* We also place a fully parameterized version in the symbol table */
|
||||||
{
|
{
|
||||||
Parm *p;
|
Parm *p;
|
||||||
String *fname = NewStringf("%s<(",Getattr($$,"name"));
|
String *fname = NewStringf("%s<(", Getattr($$,"name"));
|
||||||
p = $3;
|
p = $3;
|
||||||
while (p) {
|
while (p) {
|
||||||
String *n = Getattr(p,"name");
|
String *n = Getattr(p,"name");
|
||||||
|
|
@ -3523,6 +3523,9 @@ cpp_temp_possible: c_decl {
|
||||||
| cpp_forward_class_decl {
|
| cpp_forward_class_decl {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
| cpp_conversion_operator {
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
template_parms : rawparms {
|
template_parms : rawparms {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue