Fix parsing of extern "C" and typedef for example:
extern "C" typedef void (*Hook2_t)(int, const char *); extern "C" typedef int Integer; Closes #375
This commit is contained in:
parent
d62aad9de9
commit
fa4223e496
3 changed files with 28 additions and 14 deletions
|
|
@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 3.0.6 (in progress)
|
||||
===========================
|
||||
|
||||
2015-04-07: wsfulton
|
||||
Fix #375 - parsing of extern "C" and typedef for example:
|
||||
extern "C" typedef void (*Hook2_t)(int, const char *);
|
||||
extern "C" typedef int Integer;
|
||||
|
||||
2015-03-12: olly
|
||||
-DSWIG_DIRECTOR_STATIC is now supported for all languages with
|
||||
director support, not only Python and PHP.
|
||||
|
|
|
|||
|
|
@ -14,3 +14,18 @@ typedef int Integer2;
|
|||
void RealFunction(int value) {}
|
||||
%}
|
||||
|
||||
|
||||
%inline %{
|
||||
extern "C" {
|
||||
typedef void (*Hook1_t)(int, const char *);
|
||||
}
|
||||
extern "C" typedef void (*Hook2_t)(int, const char *);
|
||||
void funcy1(Hook1_t) {}
|
||||
void funcy2(Hook2_t) {}
|
||||
Hook1_t hook1;
|
||||
Hook2_t hook2;
|
||||
|
||||
extern "C" typedef int Integer;
|
||||
Integer int1;
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -1414,7 +1414,7 @@ static void mark_nodes_as_extend(Node *n) {
|
|||
/* Misc */
|
||||
%type <id> identifier;
|
||||
%type <dtype> initializer cpp_const exception_specification;
|
||||
%type <id> storage_class;
|
||||
%type <id> storage_class extern_string;
|
||||
%type <pl> parms ptail rawparms varargs_parms ;
|
||||
%type <pl> templateparameters templateparameterstail;
|
||||
%type <p> parm valparm rawvalparms valparms valptail ;
|
||||
|
|
@ -4652,9 +4652,7 @@ anon_bitfield_type : primitive_type { $$ = $1;
|
|||
/* ======================================================================
|
||||
* PRIMITIVES
|
||||
* ====================================================================== */
|
||||
|
||||
storage_class : EXTERN { $$ = "extern"; }
|
||||
| EXTERN string {
|
||||
extern_string : EXTERN string {
|
||||
if (strcmp($2,"C") == 0) {
|
||||
$$ = "externc";
|
||||
} else if (strcmp($2,"C++") == 0) {
|
||||
|
|
@ -4664,16 +4662,12 @@ storage_class : EXTERN { $$ = "extern"; }
|
|||
$$ = 0;
|
||||
}
|
||||
}
|
||||
| EXTERN string THREAD_LOCAL {
|
||||
if (strcmp($2,"C") == 0) {
|
||||
$$ = "externc thread_local";
|
||||
} else if (strcmp($2,"C++") == 0) {
|
||||
$$ = "extern thread_local";
|
||||
} else {
|
||||
Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,"Unrecognized extern type \"%s\".\n", $2);
|
||||
$$ = 0;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
storage_class : EXTERN { $$ = "extern"; }
|
||||
| extern_string { $$ = $1; }
|
||||
| extern_string THREAD_LOCAL { $$ = "thread_local"; }
|
||||
| extern_string TYPEDEF { $$ = "typedef"; }
|
||||
| STATIC { $$ = "static"; }
|
||||
| TYPEDEF { $$ = "typedef"; }
|
||||
| VIRTUAL { $$ = "virtual"; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue