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 %{
|
||||
template <class C>
|
||||
struct Bar_T
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
|
||||
namespace test {
|
||||
enum Hello {
|
||||
|
|
@ -165,6 +171,9 @@ namespace jafar {
|
|||
|
||||
template<class T>
|
||||
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(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 %{
|
||||
|
|
@ -225,3 +235,9 @@ public:
|
|||
};
|
||||
|
||||
%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_id = 0;
|
||||
static int rename_active = 0;
|
||||
static int swigtemplate_active = 0;
|
||||
int cparse_cplusplus = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -527,7 +528,11 @@ int yylook(void) {
|
|||
|
||||
else if (c == '(') return (LPAREN);
|
||||
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 (STAR);
|
||||
else if (c == '}') {
|
||||
|
|
@ -1154,8 +1159,16 @@ int yylex(void) {
|
|||
retract(1);
|
||||
break;
|
||||
}
|
||||
if ((c == '<')) start_template = count;
|
||||
if ((c == '>')) end_template = count;
|
||||
if ((c == '<') && !start_template) {
|
||||
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++;
|
||||
if (!isspace(c)) {
|
||||
if ((!state) && (isalpha(c))) {
|
||||
|
|
@ -1172,7 +1185,7 @@ int yylex(void) {
|
|||
}
|
||||
}
|
||||
Chop(s);
|
||||
if (start_template && end_template) {
|
||||
if (swigtemplate_active && start_template && end_template) {
|
||||
/*
|
||||
Manage the case:
|
||||
|
||||
|
|
@ -1191,6 +1204,8 @@ int yylex(void) {
|
|||
retract(count - start_template);
|
||||
Delete(s);
|
||||
s = ns;
|
||||
count = start_template;
|
||||
isconversion = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1324,7 +1339,11 @@ int yylex(void) {
|
|||
if (strcmp(yytext,"%types") == 0) return(TYPES);
|
||||
if (strcmp(yytext,"%parms") == 0) return(PARMS);
|
||||
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);
|
||||
}
|
||||
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */
|
||||
|
|
|
|||
|
|
@ -835,7 +835,7 @@ static Node *nscope_inner = 0;
|
|||
static String *resolve_node_scope(String *cname) {
|
||||
Symtab *gscope = 0;
|
||||
nscope = 0;
|
||||
nscope_inner = 0;
|
||||
nscope_inner = 0;
|
||||
if (Swig_scopename_check(cname)) {
|
||||
Node *ns;
|
||||
String *prefix = Swig_scopename_prefix(cname);
|
||||
|
|
@ -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 */
|
||||
{
|
||||
Parm *p;
|
||||
String *fname = NewStringf("%s<(",Getattr($$,"name"));
|
||||
String *fname = NewStringf("%s<(", Getattr($$,"name"));
|
||||
p = $3;
|
||||
while (p) {
|
||||
String *n = Getattr(p,"name");
|
||||
|
|
@ -3522,7 +3522,10 @@ cpp_temp_possible: c_decl {
|
|||
}
|
||||
| cpp_forward_class_decl {
|
||||
$$ = $1;
|
||||
}
|
||||
}
|
||||
| cpp_conversion_operator {
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
template_parms : rawparms {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue