add initial C99 complex support + long double

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6384 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-10 08:18:14 +00:00
commit 2459ec99d1
5 changed files with 36 additions and 3 deletions

View file

@ -1200,6 +1200,10 @@ int yylex(void) {
if (strcmp(yytext,"class") == 0) {
Swig_warning(WARN_PARSE_CLASS_KEYWORD,cparse_file,cparse_line, "class keyword used, but not in C++ mode.\n");
}
if (strcmp(yytext,"complex") == 0) {
yylval.type = NewSwigType(T_COMPLEX);
return(TYPE_COMPLEX);
}
}
/* Objective-C keywords */

View file

@ -1014,7 +1014,7 @@ static void default_arguments(Node *n) {
%token <str> CHARCONST
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG
%token <ivalue> TYPEDEF
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_TYPEDEF TYPE_RAW
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
%token CONST_QUAL VOLATILE STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
%token ILLEGAL CONSTANT
@ -4351,7 +4351,7 @@ primitive_type_list : type_specifier {
else {
int err = 0;
if ((Cmp($1.type,"long") == 0)) {
if ((Cmp($2.type,"long") == 0) || (Cmp($2.type,"double") == 0)) {
if ((Cmp($2.type,"long") == 0) || (Strncmp($2.type,"double",6) == 0)) {
$$.type = NewStringf("long %s", $2.type);
} else if (Cmp($2.type,"int") == 0) {
$$.type = $1.type;
@ -4369,9 +4369,21 @@ primitive_type_list : type_specifier {
} else if (Cmp($1.type,"double") == 0) {
if (Cmp($2.type,"long") == 0) {
$$.type = NewString("long double");
} else if (Cmp($2.type,"complex") == 0) {
$$.type = NewString("double complex");
} else {
err = 1;
}
} else if (Cmp($1.type,"float") == 0) {
if (Cmp($2.type,"complex") == 0) {
$$.type = NewString("float complex");
} else {
err = 1;
}
} else if (Cmp($1.type,"complex") == 0) {
$$.type = NewStringf("%s complex", $2.type);
} else {
err = 1;
}
if (err) {
Swig_error(cparse_file, cparse_line, "Extra %s specifier.\n", $1.type);
@ -4414,6 +4426,10 @@ type_specifier : TYPE_INT {
$$.us = NewString("unsigned");
$$.type = 0;
}
| TYPE_COMPLEX {
$$.type = NewString("complex");
$$.us = 0;
}
;
definetype : { /* scanner_check_typedef(); */ } expr {

View file

@ -115,6 +115,9 @@ SwigType *NewSwigType(int t) {
case T_DOUBLE:
return NewString("double");
break;
case T_COMPLEX:
return NewString("complex");
break;
case T_CHAR:
return NewString("char");
break;

View file

@ -72,7 +72,12 @@ typedef DOH SwigType;
#define T_ULONGLONG 12
#define T_FLOAT 20
#define T_DOUBLE 21
#define T_NUMERIC 22
#define T_LONGDOUBLE 22
#define T_FLTCPLX 23
#define T_DBLCPLX 24
#define T_NUMERIC 25
#define T_COMPLEX T_DBLCPLX
/* non-numeric */

View file

@ -15,6 +15,7 @@
char cvsroot_typesys_c[] = "$Header$";
#include "swig.h"
#include "cparse.h"
/* -----------------------------------------------------------------------------
* Synopsis
@ -1171,6 +1172,10 @@ int SwigType_type(SwigType *t)
if (strcmp(c,"unsigned char") == 0) return T_UCHAR;
if (strcmp(c,"float") == 0) return T_FLOAT;
if (strcmp(c,"double") == 0) return T_DOUBLE;
if (strcmp(c,"long double") == 0) return T_LONGDOUBLE;
if (!cparse_cplusplus && (strcmp(c,"float complex") == 0)) return T_FLTCPLX;
if (!cparse_cplusplus && (strcmp(c,"double complex") == 0)) return T_DBLCPLX;
if (!cparse_cplusplus && (strcmp(c,"complex") == 0)) return T_COMPLEX;
if (strcmp(c,"void") == 0) return T_VOID;
if (strcmp(c,"bool") == 0) return T_BOOL;
if (strcmp(c,"long long") == 0) return T_LONGLONG;