smartptr feature support - factor out common code

This commit is contained in:
William S Fulton 2015-09-17 19:36:48 +01:00
commit faeaacf112
8 changed files with 103 additions and 132 deletions

View file

@ -57,6 +57,7 @@ extern "C" {
/* util.c */
extern void Swig_cparse_replace_descriptor(String *s);
extern SwigType *Swig_cparse_smartptr(Node *n);
extern void cparse_normalize_void(Node *);
extern Parm *Swig_cparse_parm(String *s);
extern ParmList *Swig_cparse_parms(String *s, Node *file_line_node);

View file

@ -70,6 +70,28 @@ void Swig_cparse_replace_descriptor(String *s) {
}
}
/* -----------------------------------------------------------------------------
* Swig_cparse_smartptr()
*
* Parse the type in smartptr feature and convert into a SwigType.
* Error out if the parsing fails as this is like a parser syntax error.
* ----------------------------------------------------------------------------- */
SwigType *Swig_cparse_smartptr(Node *n) {
SwigType *smart = 0;
String *smartptr = Getattr(n, "feature:smartptr");
if (smartptr) {
SwigType *cpt = Swig_cparse_type(smartptr);
if (cpt) {
smart = SwigType_typedef_resolve_all(cpt);
Delete(cpt);
} else {
Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, SwigType_namestr(Getattr(n, "name")));
}
}
return smart;
}
/* -----------------------------------------------------------------------------
* cparse_normalize_void()
*