Eric Ehlers
2015-09-06 17:08:34 UTC
Hello,
Suppose my interface file says:
void f(std::vector<int>);
How in my Language class would I parse the above
and isolate the token "int"?
Here is my attempt:
int functionHandler(Node *n) {
ParmList *parms = Getattr(n, "parms");
for (Parm *p = parms; p; p = nextSibling(p)) {
SwigType *t1 = Getattr(p, "type");
// prints "t1 = std::vector< int >"
printf("t1 = %s\n", Char(SwigType_str(t1, 0)));
// prints "is_template=1"
printf("is_template=%d\n", SwigType_istemplate(t1));
// This doesn't compile :(
//SwigType *t2 = SwigType_pop_template(t1);
}
return Language::functionHandler(n);
}
So far the only solution I can find is to take
t1 ("std::vector< int >"),
convert it into a char*, parse it,
and extract everything between the <>s.
Is there a better way?
Many Thanks,
Eric
------------------------------------------------------------------------------
Suppose my interface file says:
void f(std::vector<int>);
How in my Language class would I parse the above
and isolate the token "int"?
Here is my attempt:
int functionHandler(Node *n) {
ParmList *parms = Getattr(n, "parms");
for (Parm *p = parms; p; p = nextSibling(p)) {
SwigType *t1 = Getattr(p, "type");
// prints "t1 = std::vector< int >"
printf("t1 = %s\n", Char(SwigType_str(t1, 0)));
// prints "is_template=1"
printf("is_template=%d\n", SwigType_istemplate(t1));
// This doesn't compile :(
//SwigType *t2 = SwigType_pop_template(t1);
}
return Language::functionHandler(n);
}
So far the only solution I can find is to take
t1 ("std::vector< int >"),
convert it into a char*, parse it,
and extract everything between the <>s.
Is there a better way?
Many Thanks,
Eric
------------------------------------------------------------------------------