SWIG no longer generates temporary files.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@644 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-08-11 16:34:31 +00:00
commit ef5e8a5b09
9 changed files with 264 additions and 421 deletions

View file

@ -237,7 +237,7 @@ void RUBY::set_module(char *mod_name, char **mod_list) {
}
static void insert_file(char *filename, FILE *file) {
static void insert_file(char *filename, DOHFile *file) {
if (Swig_insert_file(filename, file) == -1) {
Printf(stderr,
"SWIG : Fatal error. "

View file

@ -792,7 +792,7 @@ void cplus_set_class(char *name) {
current_class = c;
localtypes = c->local;
} else {
fprintf(stderr,"%s:%d: Warning class %s undefined.\n",input_file,line_number,name);
Printf(stderr,"%s:%d: Warning class %s undefined.\n",input_file,line_number,name);
current_class = new CPP_class(name,0);
localtypes = current_class->local;
}
@ -987,7 +987,7 @@ void cplus_generate_types(char **baseclass) {
"}\n",
0);
fprintf(f_wrappers,"%s\n",Char(cfunc));
Printf(f_wrappers,"%s\n",Char(cfunc));
}
} else {
Clear(temp3);
@ -1082,7 +1082,7 @@ void cplus_inherit_members(char *baseclass, int mode) {
if (bc) {
bc->inherit_decls(mode);
} else {
fprintf(stderr,"%s:%d: Warning. Base class %s undefined (ignored).\n", input_file, current_class->line, baseclass);
Printf(stderr,"%s:%d: Warning. Base class %s undefined (ignored).\n", input_file, current_class->line, baseclass);
}
}

View file

@ -40,8 +40,8 @@ void Language::set_init(char *iname) {
* ----------------------------------------------------------------- */
void Language::create_command(char *, char *) {
fprintf(stderr,"SWIG Warning. No command creation procedure defined.\n");
fprintf(stderr,"C++ inheritance may not work correctly.\n");
Printf(stderr,"SWIG Warning. No command creation procedure defined.\n");
Printf(stderr,"C++ inheritance may not work correctly.\n");
}
/* -----------------------------------------------------------------
@ -53,7 +53,7 @@ void Language::create_command(char *, char *) {
void
Language::add_native(char *, char *iname, DataType *, ParmList *) {
fprintf(stderr,"%s : Line %d. Adding native function %s not supported (ignored).\n", input_file, line_number, iname);
Printf(stderr,"%s : Line %d. Adding native function %s not supported (ignored).\n", input_file, line_number, iname);
}
static char *ClassName = 0; /* This is the real name of the current class */
@ -172,7 +172,7 @@ void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l
/* Now do a symbol table lookup on it : */
if (add_symbol(new_name)) {
fprintf(stderr,"%s : Line %d. Function %s (member %s) multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. Function %s (member %s) multiply defined (2nd definition ignored).\n",
input_file, line_number, cname, name);
return;
}
@ -195,7 +195,7 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
char *prefix, *cname;
if ((strcmp(name,ClassName)) && (!ObjCClass)) {
fprintf(stderr,"%s : Line %d. Function %s must have a return type.\n",
Printf(stderr,"%s : Line %d. Function %s must have a return type.\n",
input_file, line_number, name);
return;
}
@ -215,7 +215,7 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
/* Add this function to the SWIG symbol table */
if (add_symbol(cname)) {
fprintf(stderr,"%s : Line %d. Constructor %s multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. Constructor %s multiply defined (2nd definition ignored).\n",
input_file, line_number, cname);
return;
}
@ -249,7 +249,7 @@ void Language::cpp_destructor(char *name, char *iname) {
/* Add this function to the SWIG symbol table */
if (add_symbol(cname)) {
fprintf(stderr,"%s : Line %d. Destructor %s multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. Destructor %s multiply defined (2nd definition ignored).\n",
input_file, line_number, cname);
return;
}
@ -327,7 +327,7 @@ void Language::cpp_variable(char *name, char *iname, DataType *t) {
/* Check the symbol table */
if (add_symbol(cname)) {
fprintf(stderr,"%s : Line %d. Variable %s multiply defined (2nd definition ignored).\n", input_file, line_number, cname);
Printf(stderr,"%s : Line %d. Variable %s multiply defined (2nd definition ignored).\n", input_file, line_number, cname);
return;
}
@ -381,10 +381,10 @@ void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l
if (add_symbol(cname)) {
if (ObjCClass)
fprintf(stderr,"%s : Line %d. class function %s multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. class function %s multiply defined (2nd definition ignored).\n",
input_file, line_number, cname);
else
fprintf(stderr,"%s : Line %d. static function %s multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. static function %s multiply defined (2nd definition ignored).\n",
input_file, line_number, cname);
return;
}
@ -431,7 +431,7 @@ void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *
/* Now do a symbol table lookup on it : */
if (add_symbol(cname)) {
fprintf(stderr,"%s : Line %d. Constant %s (member %s) multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. Constant %s (member %s) multiply defined (2nd definition ignored).\n",
input_file, line_number, cname, name);
return;
}
@ -491,7 +491,7 @@ void Language::cpp_static_var(char *name, char *iname, DataType *t) {
/* Now do a symbol table lookup on it : */
if (add_symbol(cname)) {
fprintf(stderr,"%s : Line %d. Variable %s (member %s) multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. Variable %s (member %s) multiply defined (2nd definition ignored).\n",
input_file, line_number, cname, name);
return;
}

View file

@ -36,9 +36,9 @@ extern "C" {
// Global variables
FILE *f_runtime;
FILE *f_header; // Some commonly used
FILE *f_wrappers; // FILE pointers
FILE *f_init;
DOH *f_header; // Some commonly used
DOH *f_wrappers; // FILE pointers
DOH *f_init;
FILE *f_input;
char InitName[256];
char LibDir[512]; // Library directory
@ -116,10 +116,6 @@ check_suffix(char *name) {
char infilename[256];
char filename[256];
char fn_cpp[256];
char fn_header[256];
char fn_wrapper[256];
char fn_init[256];
char output_dir[512];
char fn_runtime[256];
@ -146,7 +142,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
char *includefiles[256];
int includecount = 0;
extern int check_suffix(char *);
extern void scanner_file(FILE *);
extern void scanner_file(DOHFile *);
extern void typemap_initialize(void);
extern void parser_init(void);
@ -378,16 +374,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
strcpy(infile,cc);
}
sprintf(fn_cpp,"%s%s_wrap.ii", output_dir, infile);
sprintf(fn_header,"%s%s_wrap.head", output_dir,infile);
sprintf(fn_wrapper,"%s%s_wrap.wrap",output_dir,infile);
sprintf(fn_init,"%s%s_wrap.init",output_dir,infile);
// printf("%s\n", input_file);
// printf("%s\n", fn_cpp);
// printf("%s\n", fn_wrapper);
// printf("%s\n", fn_init);
// Define the __cplusplus symbol
if (CPlusPlus)
Preprocessor_define((DOH *) "__cplusplus 1", 0);
@ -397,7 +383,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
printf ("Preprocessing...\n");
{
DOH *cpps;
FILE *f;
int i;
DOH *ds = Swig_include(input_file);
if (!ds) {
@ -415,43 +400,18 @@ int SWIG_main(int argc, char *argv[], Language *l) {
while (freeze);
SWIG_exit(0);
}
f = fopen(fn_cpp,"w");
fwrite(Char(cpps),1, Len(cpps), f);
fclose(f);
// Initialize the scanner
Seek(cpps, 0, SEEK_SET);
scanner_file(cpps);
}
if ((f_input = fopen(fn_cpp,"r")) == 0) {
fprintf(stderr,"Unable to open %s\n", fn_cpp);
SWIG_exit(0);
}
// Initialize the scanner
if (Verbose)
printf ("Scanning...\n");
LEX_in = f_input;
scanner_file(LEX_in);
//printf("fn_cpp = %s\n", fn_cpp);
//printf("fn_header = %s\n", fn_header);
//printf("fn_wrapper = %s\n", fn_wrapper);
//printf("fn_init = %s\n", fn_init);
if ((f_runtime = fopen(fn_runtime,"w")) == 0) {
fprintf(stderr,"Unable to open %s\n", fn_runtime);
exit(0);
}
if((f_header = fopen(fn_header,"w")) == 0) {
fprintf(stderr,"Unable to open %s\n", fn_header);
exit(0);
}
if((f_wrappers = fopen(fn_wrapper,"w")) == 0) {
fprintf(stderr,"Unable to open %s\n",fn_wrapper);
exit(0);
}
if ((f_init = fopen(fn_init,"w")) == 0) {
fprintf(stderr,"Unable to open %s\n",fn_init);
exit(0);
}
f_header = NewString("");
f_wrappers = NewString("");
f_init = NewString("");
// Set up the typemap for handling new return strings
{
@ -490,25 +450,10 @@ int SWIG_main(int argc, char *argv[], Language *l) {
fflush (stdout);
}
fclose(f_header);
fclose(f_wrappers);
fclose(f_init);
Swig_insert_file(fn_header, f_runtime);
Swig_insert_file(fn_wrapper,f_runtime);
Swig_insert_file(fn_init,f_runtime);
Dump(f_header,f_runtime);
Dump(f_wrappers, f_runtime);
Dump(f_init, f_runtime);
fclose(f_runtime);
// Remove temporary files
if (Verbose)
printf ("Cleaning up...\n");
remove(fn_cpp);
remove(fn_header);
remove(fn_wrapper);
remove(fn_init);
if (checkout) {
// File was checked out from the SWIG library. Remove it now
remove(input_file);
@ -525,24 +470,10 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// --------------------------------------------------------------------------
void SWIG_exit(int) {
if (f_wrappers) {
fclose(f_wrappers);
remove(fn_wrapper);
}
if (f_header) {
fclose(f_header);
remove(fn_header);
}
if (f_init) {
fclose(f_init);
remove(fn_init);
}
if (f_runtime) {
fclose(f_runtime);
remove(fn_runtime);
}
remove (fn_cpp);
while (freeze);
exit(1);
}

View file

@ -201,25 +201,25 @@ static void format_string(char *str) {
// Emit an external function declaration
static void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, FILE *f) {
static void emit_extern_func(char *decl, DataType *t, ParmList *L, int extern_type, DOHFile *f) {
switch(extern_type) {
case 0:
fprintf(f,"%s", DataType_str(t,0));
fprintf(f,"%s(%s);\n", decl, ParmList_protostr(L));
Printf(f,"%s", DataType_str(t,0));
Printf(f,"%s(%s);\n", decl, ParmList_protostr(L));
break;
case 1:
fprintf(f,"extern %s", DataType_str(t,0));
fprintf(f,"%s(%s);\n", decl, ParmList_protostr(L));
Printf(f,"extern %s", DataType_str(t,0));
Printf(f,"%s(%s);\n", decl, ParmList_protostr(L));
break;
case 2:
/* A C++ --- > C Extern */
fprintf(f,"extern \"C\" %s", DataType_str(t,0));
fprintf(f,"%s(%s);\n", decl, ParmList_protostr(L));
Printf(f,"extern \"C\" %s", DataType_str(t,0));
Printf(f,"%s(%s);\n", decl, ParmList_protostr(L));
break;
case 3:
fprintf(f,"%s", DataType_str(t,0));
fprintf(f,"%s(%s)\n", decl, ParmList_str(L));
Printf(f,"%s", DataType_str(t,0));
Printf(f,"%s(%s)\n", decl, ParmList_str(L));
break;
default:
break;
@ -267,7 +267,7 @@ int promote(int t1, int t2) {
if ((t1 == T_SHORT) || (t2 == T_SHORT)) return T_SHORT;
if ((t1 == T_UCHAR) || (t2 == T_UCHAR)) return T_UCHAR;
if (t1 != t2) {
fprintf(stderr,"%s : Line %d. Type mismatch in constant expression\n",
Printf(stderr,"%s : Line %d. Type mismatch in constant expression\n",
input_file, line_number);
FatalError();
}
@ -320,7 +320,7 @@ void create_function(int ext, char *name, DataType *t, ParmList *l) {
// Check if symbol already exists
if (add_symbol(iname)) {
fprintf(stderr,"%s : Line %d. Function %s multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. Function %s multiply defined (2nd definition ignored).\n",
input_file, line_number, iname);
} else {
@ -355,7 +355,7 @@ void create_variable(int ext, char *name, DataType *t) {
char *iname = make_name(name);
if (add_symbol(iname)) {
fprintf(stderr,"%s : Line %d. Variable %s multiply defined (2nd definition ignored).\n",
Printf(stderr,"%s : Line %d. Variable %s multiply defined (2nd definition ignored).\n",
input_file, line_number, iname);
} else {
@ -388,7 +388,7 @@ void create_constant(char *name, DataType *type, char *value) {
init_language();
if (Rename_true) {
fprintf(stderr,"%s : Line %d. %%name directive ignored with #define\n",
Printf(stderr,"%s : Line %d. %%name directive ignored with #define\n",
input_file, line_number);
Rename_true = 0;
}
@ -399,7 +399,7 @@ void create_constant(char *name, DataType *type, char *value) {
if (!value) value = Swig_copy_string(name);
sprintf(temp_name,"const:%s", name);
if (add_symbol(temp_name)) {
fprintf(stderr,"%s : Line %d. Constant %s multiply defined. (2nd definition ignored)\n",
Printf(stderr,"%s : Line %d. Constant %s multiply defined. (2nd definition ignored)\n",
input_file, line_number, name);
} else {
if (!WrapExtern) { // Only wrap the constant if not in %extern mode
@ -414,7 +414,7 @@ void create_constant(char *name, DataType *type, char *value) {
void print_array() {
int i;
for (i = 0; i < InArray; i++)
fprintf(stderr,"[]");
Printf(stderr,"[]");
}
// Structures for handling code fragments built for nested classes
@ -467,7 +467,7 @@ static void dump_nested(char *parent) {
// Dump the code to the scanner
fprintf(f_header,"\n%s\n", Char(n->code));
Printf(f_header,"\n%s\n", Char(n->code));
start_inline(Char(n->code),n->line);
n1 = n->next;
@ -662,7 +662,7 @@ statement : INCLUDE STRING LBRACE {
DataType_set_arraystr($2,Char(ArrayString));
}
if ($3.is_reference) {
fprintf(stderr,"%s : Line %d. Error. Linkage to C++ reference not allowed.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Error. Linkage to C++ reference not allowed.\n", input_file, line_number);
FatalError();
} else {
if (DataType_qualifier($2)) {
@ -683,7 +683,7 @@ statement : INCLUDE STRING LBRACE {
| extern strict_type LPAREN STAR {
skip_decl();
fprintf(stderr,"%s : Line %d. Function pointers not currently supported.\n",
Printf(stderr,"%s : Line %d. Function pointers not currently supported.\n",
input_file, line_number);
}
@ -700,7 +700,7 @@ statement : INCLUDE STRING LBRACE {
| STATIC strict_type LPAREN STAR {
skip_decl();
fprintf(stderr,"%s : Line %d. Function pointers not currently supported.\n",
Printf(stderr,"%s : Line %d. Function pointers not currently supported.\n",
input_file, line_number);
}
@ -763,13 +763,13 @@ statement : INCLUDE STRING LBRACE {
add_pointers($2,$3.is_pointer);
if ($3.is_reference) DataType_add_reference($2);
if (Inline) {
fprintf(stderr,"%s : Line %d. Repeated %%inline directive.\n",input_file,line_number);
Printf(stderr,"%s : Line %d. Repeated %%inline directive.\n",input_file,line_number);
FatalError();
} else {
if (strlen(Char(CCode))) {
fprintf(f_header,"static ");
Printf(f_header,"static ");
emit_extern_func($3.id,$2,$5,3,f_header);
fprintf(f_header,"%s\n",Char(CCode));
Printf(f_header,"%s\n",Char(CCode));
}
create_function(0, $3.id, $2, $5);
}
@ -822,7 +822,7 @@ statement : INCLUDE STRING LBRACE {
/* Empty name directive. No longer allowed */
| NAME LPAREN RPAREN {
fprintf(stderr,"%s : Lind %d. Empty %%name() is no longer supported.\n",
Printf(stderr,"%s : Lind %d. Empty %%name() is no longer supported.\n",
input_file, line_number);
FatalError();
} cpp {
@ -835,7 +835,7 @@ statement : INCLUDE STRING LBRACE {
if (!WrapExtern) {
init_language();
if (add_symbol($3)) {
fprintf(stderr,"%s : Line %d. Name of native function %s conflicts with previous declaration (ignored)\n",
Printf(stderr,"%s : Line %d. Name of native function %s conflicts with previous declaration (ignored)\n",
input_file, line_number, $3);
} else {
lang->add_native($3,$6,0,0);
@ -847,7 +847,7 @@ statement : INCLUDE STRING LBRACE {
init_language();
add_pointers($6,$7.is_pointer);
if (add_symbol($3)) {
fprintf(stderr,"%s : Line %d. Name of native function %s conflicts with previous declaration (ignored)\n",
Printf(stderr,"%s : Line %d. Name of native function %s conflicts with previous declaration (ignored)\n",
input_file, line_number, $3);
} else {
if ($5) {
@ -895,8 +895,8 @@ statement : INCLUDE STRING LBRACE {
if (!WrapExtern) {
init_language();
$1[strlen($1) - 1] = 0;
// fprintf(f_header,"#line %d \"%s\"\n", start_line, input_file);
fprintf(f_header, "%s\n", $1);
// Printf(f_header,"#line %d \"%s\"\n", start_line, input_file);
Printf(f_header, "%s\n", $1);
}
}
@ -906,7 +906,7 @@ statement : INCLUDE STRING LBRACE {
if (!WrapExtern) {
init_language();
$2[strlen($2) - 1] = 0;
fprintf(f_wrappers,"%s\n",$2);
Printf(f_wrappers,"%s\n",$2);
}
}
@ -916,7 +916,7 @@ statement : INCLUDE STRING LBRACE {
if (!WrapExtern) {
init_language();
$2[strlen($2) -1] = 0;
fprintf(f_init,"%s\n", $2);
Printf(f_init,"%s\n", $2);
}
}
@ -925,7 +925,7 @@ statement : INCLUDE STRING LBRACE {
if (!WrapExtern) {
init_language();
$2[strlen($2) - 1] = 0;
fprintf(f_header, "%s\n", $2);
Printf(f_header, "%s\n", $2);
{
/* Need to run through the preprocessor */
DOH *cpps;
@ -944,13 +944,13 @@ statement : INCLUDE STRING LBRACE {
/* Echo mode */
| ECHO HBLOCK {
if (!WrapExtern) {
fprintf(stderr,"%s\n", $2);
Printf(stderr,"%s\n", $2);
}
}
| ECHO STRING {
if (!WrapExtern) {
fprintf(stderr,"%s\n", $2);
Printf(stderr,"%s\n", $2);
}
}
@ -967,7 +967,7 @@ statement : INCLUDE STRING LBRACE {
init_language();
}
if ($3.count > 0) {
fprintf(stderr,"%s : Line %d. Warning. Init list no longer supported.\n",
Printf(stderr,"%s : Line %d. Warning. Init list no longer supported.\n",
input_file,line_number);
}
for (i = 0; i < $3.count; i++)
@ -999,7 +999,7 @@ statement : INCLUDE STRING LBRACE {
} else if ($3.type == T_SYMBOL) {
// Add a symbol to the SWIG symbol table
if (add_symbol($2)) {
fprintf(stderr,"%s : Line %d. Warning. Symbol %s already defined.\n",
Printf(stderr,"%s : Line %d. Warning. Symbol %s already defined.\n",
input_file,line_number, $2);
}
}
@ -1051,8 +1051,8 @@ statement : INCLUDE STRING LBRACE {
/* Create a new typemap in current language */
| TYPEMAP LPAREN tm_method RPAREN tm_list LBRACE {
if (!typemap_lang) {
fprintf(stderr,"SWIG internal error. No typemap_lang specified.\n");
fprintf(stderr,"typemap on %s : Line %d. will be ignored.\n",input_file,line_number);
Printf(stderr,"SWIG internal error. No typemap_lang specified.\n");
Printf(stderr,"typemap on %s : Line %d. will be ignored.\n",input_file,line_number);
FatalError();
} else {
TMParm *p;
@ -1082,8 +1082,8 @@ statement : INCLUDE STRING LBRACE {
| TYPEMAP LPAREN tm_method RPAREN tm_list SEMI {
if (!typemap_lang) {
fprintf(stderr,"SWIG internal error. No typemap_lang specified.\n");
fprintf(stderr,"typemap on %s : Line %d. will be ignored.\n",input_file,line_number);
Printf(stderr,"SWIG internal error. No typemap_lang specified.\n");
Printf(stderr,"typemap on %s : Line %d. will be ignored.\n",input_file,line_number);
FatalError();
} else {
TMParm *p;
@ -1115,8 +1115,8 @@ statement : INCLUDE STRING LBRACE {
| TYPEMAP LPAREN tm_method RPAREN tm_list EQUAL typemap_parm SEMI {
if (!typemap_lang) {
fprintf(stderr,"SWIG internal error. No typemap_lang specified.\n");
fprintf(stderr,"typemap on %s : Line %d. will be ignored.\n",input_file,line_number);
Printf(stderr,"SWIG internal error. No typemap_lang specified.\n");
Printf(stderr,"typemap on %s : Line %d. will be ignored.\n",input_file,line_number);
FatalError();
} else {
TMParm *p;
@ -1195,7 +1195,7 @@ statement : INCLUDE STRING LBRACE {
{
static int last_error_line = -1;
if (last_error_line != line_number) {
fprintf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
FatalError();
last_error_line = line_number;
// Try to make some kind of recovery.
@ -1250,7 +1250,7 @@ typedef_decl : TYPEDEF type declaration {
lang->add_typedef($2,$3.id);
/* If this is %typedef, add it to the header */
if ($1)
fprintf(f_header,"typedef %s;\n", DataType_str($2,$3.id));
Printf(f_header,"typedef %s;\n", DataType_str($2,$3.id));
cplus_register_type($3.id);
} typedeflist { };
@ -1261,7 +1261,7 @@ typedef_decl : TYPEDEF type declaration {
/* Typedef'd pointer */
if ($1) {
sprintf(temp_name,"(*%s)",$5);
fprintf(f_header,"typedef ");
Printf(f_header,"typedef ");
emit_extern_func(temp_name, $2,$8,0,f_header);
}
DataType_Setname($2,"<function ptr>");
@ -1282,7 +1282,7 @@ typedef_decl : TYPEDEF type declaration {
if ($1) {
add_pointers($2,$3);
sprintf(temp_name,"(*%s)",$6);
fprintf(f_header,"typedef ");
Printf(f_header,"typedef ");
emit_extern_func(temp_name, $2,$9,0,f_header);
}
@ -1311,7 +1311,7 @@ typedef_decl : TYPEDEF type declaration {
DataType_set_arraystr($2,Char(ArrayString));
DataType_typedef_add($2,$3.id,0);
lang->add_typedef($2,$3.id);
fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap\n",input_file,line_number, $3.id);
Printf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap\n",input_file,line_number, $3.id);
cplus_register_type($3.id);
} typedeflist { }
@ -1348,7 +1348,7 @@ typedeflist : COMMA declaration typedeflist {
lang->add_typedef(t,$2.id);
cplus_register_type($2.id);
DelDataType(t);
fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap.\n",input_file,line_number, $2.id);
Printf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap.\n",input_file,line_number, $2.id);
}
| empty { }
;
@ -1356,9 +1356,9 @@ typedeflist : COMMA declaration typedeflist {
pragma : PRAGMA LPAREN ID COMMA ID stylearg RPAREN {
if (!WrapExtern)
lang->pragma($3,$5,$6);
fprintf(stderr,"%s : Line %d. Warning. '%%pragma(lang,opt=value)' syntax is obsolete.\n",
Printf(stderr,"%s : Line %d. Warning. '%%pragma(lang,opt=value)' syntax is obsolete.\n",
input_file,line_number);
fprintf(stderr," Use '%%pragma(lang) opt=value' instead.\n");
Printf(stderr," Use '%%pragma(lang) opt=value' instead.\n");
}
| PRAGMA ID stylearg {
@ -1384,7 +1384,7 @@ stail : SEMI { }
DataType_set_arraystr(temp_typeptr,Char(ArrayString));
}
if ($2.is_reference) {
fprintf(stderr,"%s : Line %d. Error. Linkage to C++ reference not allowed.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Error. Linkage to C++ reference not allowed.\n", input_file, line_number);
FatalError();
} else {
if (DataType_qualifier(temp_typeptr)) {
@ -1416,7 +1416,7 @@ extern : EXTERN { $$ = 1; }
if (strcmp($2,"C") == 0) {
$$ = 2;
} else {
fprintf(stderr,"%s : Line %d. Unrecognized extern type \"%s\" (ignored).\n", input_file, line_number, $2);
Printf(stderr,"%s : Line %d. Unrecognized extern type \"%s\" (ignored).\n", input_file, line_number, $2);
FatalError();
}
}
@ -1490,13 +1490,13 @@ parm_type : type pname {
DataType_add_pointer(pt);
Setvalue($$,DefArg);
if (!CPlusPlus) {
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
}
DelDataType($1);
free($3);
}
| type LPAREN stars pname RPAREN LPAREN parms RPAREN {
fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
FatalError();
$$ = NewParm($1,$4);
DataType *pt = Gettype($$);
@ -1508,7 +1508,7 @@ parm_type : type pname {
Delete($7);
}
| PERIOD PERIOD PERIOD {
fprintf(stderr,"%s : Line %d. Variable length arguments not supported (ignored).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Variable length arguments not supported (ignored).\n", input_file, line_number);
$$ = NewParm(NewDataType(T_INT),(char *) "varargs");
DataType *pt = Gettype($$);
DataType_Settypecode(pt,T_ERROR);
@ -1577,7 +1577,7 @@ declaration : ID { $$.id = $1;
$$.is_pointer = 1;
$$.is_reference = 1;
if (!CPlusPlus) {
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
}
}
;
@ -1645,7 +1645,7 @@ type : TYPE_INT {
$$ = $1;
if (strlen($2) > 0) {
if ((strlen($2) + strlen(DataType_Getname($$))) >= MAX_NAME) {
fprintf(stderr,"%s : Line %d. Fatal error. Type-name is too long!\n",
Printf(stderr,"%s : Line %d. Fatal error. Type-name is too long!\n",
input_file, line_number);
} else {
char temp[256];
@ -1661,7 +1661,7 @@ type : TYPE_INT {
DataType_typedef_resolve($$,0);
if (strlen($2) > 0) {
if ((strlen($2) + strlen(DataType_Getname($$))) >= MAX_NAME) {
fprintf(stderr,"%s : Line %d. Fatal error. Type-name is too long!\n",
Printf(stderr,"%s : Line %d. Fatal error. Type-name is too long!\n",
input_file, line_number);
} else {
char temp[256];
@ -1898,7 +1898,7 @@ etype : expr {
($$.type != T_LONG) && ($$.type != T_ULONG) &&
($$.type != T_SHORT) && ($$.type != T_USHORT) &&
($$.type != T_SCHAR) && ($$.type != T_UCHAR)) {
fprintf(stderr,"%s : Lind %d. Type error. Expecting an int\n",
Printf(stderr,"%s : Lind %d. Type error. Expecting an int\n",
input_file, line_number);
FatalError();
}
@ -1986,7 +1986,7 @@ expr : NUM_INT {
E_BINARY($$.id,$1.id,$3.id,"&");
$$.type = promote($1.type,$3.type);
if (($1.type == T_DOUBLE) || ($3.type == T_DOUBLE)) {
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
FatalError();
}
free($1.id);
@ -1997,7 +1997,7 @@ expr : NUM_INT {
E_BINARY($$.id,$1.id,$3.id,"|");
$$.type = promote($1.type,$3.type);
if (($1.type == T_DOUBLE) || ($3.type == T_DOUBLE)) {
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
FatalError();
}
$$.type = T_INT;
@ -2009,7 +2009,7 @@ expr : NUM_INT {
E_BINARY($$.id,$1.id,$3.id,"^");
$$.type = promote($1.type,$3.type);
if (($1.type == T_DOUBLE) || ($3.type == T_DOUBLE)) {
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
FatalError();
}
$$.type = T_INT;
@ -2021,7 +2021,7 @@ expr : NUM_INT {
E_BINARY($$.id,$1.id,$3.id,"<<");
$$.type = promote($1.type,$3.type);
if (($1.type == T_DOUBLE) || ($3.type == T_DOUBLE)) {
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
FatalError();
}
$$.type = T_INT;
@ -2033,7 +2033,7 @@ expr : NUM_INT {
E_BINARY($$.id,$1.id,$3.id,">>");
$$.type = promote($1.type,$3.type);
if (($1.type == T_DOUBLE) || ($3.type == T_DOUBLE)) {
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
FatalError();
}
$$.type = T_INT;
@ -2052,7 +2052,7 @@ expr : NUM_INT {
$$.id = (char *) malloc(strlen($2.id)+2);
sprintf($$.id,"~%s",$2.id);
if ($2.type == T_DOUBLE) {
fprintf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Type error in constant expression (expecting integers).\n", input_file, line_number);
FatalError();
}
$$.type = $2.type;
@ -2083,11 +2083,11 @@ cpp_class :
sprintf(temp_name,"CPP_CLASS:%s\n",$3);
if (add_symbol(temp_name)) {
fprintf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3);
Printf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3);
FatalError();
}
if ((!CPlusPlus) && (strcmp($2,"class") == 0))
fprintf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
iname = make_name($3);
if (iname == $3)
@ -2107,7 +2107,7 @@ cpp_class :
if (strcmp($2,"union") != 0)
cplus_inherit($4.count, $4.names);
else {
fprintf(stderr,"%s : Line %d. Inheritance not allowed for unions.\n",input_file, line_number);
Printf(stderr,"%s : Line %d. Inheritance not allowed for unions.\n",input_file, line_number);
FatalError();
}
}
@ -2138,11 +2138,11 @@ cpp_class :
sprintf(temp_name,"CPP_CLASS:%s\n",$3);
if (add_symbol(temp_name)) {
fprintf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3);
Printf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3);
FatalError();
}
if ((!CPlusPlus) && (strcmp($2,"class") == 0))
fprintf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
iname = make_name($3);
if ($3 == iname)
@ -2164,7 +2164,7 @@ cpp_class :
if (strcmp($2,"union") != 0)
cplus_inherit($4.count, $4.names);
else {
fprintf(stderr,"%s : Line %d. Inheritance not allowed for unions.\n",input_file, line_number);
Printf(stderr,"%s : Line %d. Inheritance not allowed for unions.\n",input_file, line_number);
FatalError();
}
}
@ -2184,7 +2184,7 @@ cpp_class :
}
if ($9.is_pointer > 0) {
fprintf(stderr,"%s : Line %d. typedef struct { } *id not supported properly. Winging it...\n", input_file, line_number);
Printf(stderr,"%s : Line %d. typedef struct { } *id not supported properly. Winging it...\n", input_file, line_number);
}
// Create dump nested class code
@ -2224,7 +2224,7 @@ cpp_class :
init_language();
DataType_new_scope(0);
if ((!CPlusPlus) && (strcmp($2,"class") == 0))
fprintf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
iname = make_name((char*)"");
if (strlen(iname))
@ -2239,12 +2239,12 @@ cpp_class :
nested_list = 0;
} cpp_members RBRACE declaration {
if ($7.is_pointer > 0) {
fprintf(stderr,"%s : Line %d. typedef %s {} *%s not supported correctly. Will be ignored.\n", input_file, line_number, $2, $7.id);
Printf(stderr,"%s : Line %d. typedef %s {} *%s not supported correctly. Will be ignored.\n", input_file, line_number, $2, $7.id);
cplus_abort();
} else {
sprintf(temp_name,"CPP_CLASS:%s\n",$7.id);
if (add_symbol(temp_name)) {
fprintf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $7.id);
Printf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $7.id);
FatalError();
}
}
@ -2279,7 +2279,7 @@ cpp_other :/* A dummy class name */
| extern type declaration DCOLON ID LPAREN parms RPAREN SEMI {
init_language();
if (!CPlusPlus)
fprintf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
add_pointers($2,$3.is_pointer);
if ($3.is_reference) DataType_add_reference($2);
@ -2298,7 +2298,7 @@ cpp_other :/* A dummy class name */
| extern type declaration DCOLON ID SEMI {
init_language();
if (!CPlusPlus)
fprintf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number);
add_pointers($2,$3.is_pointer);
// Fix up the function name
@ -2314,7 +2314,7 @@ cpp_other :/* A dummy class name */
/* Operator overloading catch */
| extern type declaration DCOLON OPERATOR {
fprintf(stderr,"%s : Line %d. Operator overloading not supported (ignored).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Operator overloading not supported (ignored).\n", input_file, line_number);
skip_decl();
DelDataType($2);
}
@ -2322,7 +2322,7 @@ cpp_other :/* A dummy class name */
/* Template catch */
| TEMPLATE {
fprintf(stderr,"%s : Line %d. Templates not currently supported (ignored).\n",
Printf(stderr,"%s : Line %d. Templates not currently supported (ignored).\n",
input_file, line_number);
skip_decl();
}
@ -2356,7 +2356,7 @@ cpp_members : cpp_member cpp_members {}
{
static int last_error_line = -1;
if (last_error_line != line_number) {
fprintf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
FatalError();
last_error_line = line_number;
}
@ -2503,7 +2503,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
cplus_variable($2.id,iname,$1);
Status = oldstatus;
if (!tm)
fprintf(stderr,"%s : Line %d. Warning. Array member will be read-only.\n",input_file,line_number);
Printf(stderr,"%s : Line %d. Warning. Array member will be read-only.\n",input_file,line_number);
}
scanner_clear_start();
DelDataType($1);
@ -2602,14 +2602,14 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
}
/* A friend : Illegal */
| FRIEND {
fprintf(stderr,"%s : Line %d. Friends are not allowed--members only! (ignored)\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Friends are not allowed--members only! (ignored)\n", input_file, line_number);
skip_decl();
scanner_clear_start();
}
/* An operator: Illegal */
| type type_extra OPERATOR {
fprintf(stderr,"%s : Line %d. Operator overloading not supported (ignored).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Operator overloading not supported (ignored).\n", input_file, line_number);
skip_decl();
scanner_clear_start();
}
@ -2657,7 +2657,7 @@ cpp_pragma : PRAGMA ID stylearg {
cplus_register_type($2);
if ($5.id) {
if (strcmp($1,"class") == 0) {
fprintf(stderr,"%s : Line %d. Warning. Nested classes not currently supported (ignored).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Warning. Nested classes not currently supported (ignored).\n", input_file, line_number);
/* Generate some code for a new class */
} else {
Nested *n = (Nested *) malloc(sizeof(Nested));
@ -2680,7 +2680,7 @@ cpp_pragma : PRAGMA ID stylearg {
} declaration SEMI {
if (cplus_mode == CPLUS_PUBLIC) {
if (strcmp($1,"class") == 0) {
fprintf(stderr,"%s : Line %d. Warning. Nested classes not currently supported (ignored)\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Warning. Nested classes not currently supported (ignored)\n", input_file, line_number);
/* Generate some code for a new class */
} else {
/* Generate some code for a new class */
@ -2710,17 +2710,17 @@ cpp_pragma : PRAGMA ID stylearg {
/* Other miscellaneous errors */
| type stars LPAREN {
skip_decl();
fprintf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number);
}
| strict_type LPAREN STAR {
skip_decl();
fprintf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number);
}
| ID LPAREN STAR {
skip_decl();
fprintf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number);
}
| doc_enable { }
@ -2769,7 +2769,7 @@ cpp_tail : SEMI { }
cplus_variable($2.id,(char *) 0,temp_typeptr);
Status = oldstatus;
if (!tm)
fprintf(stderr,"%s : Line %d. Warning. Array member will be read-only.\n",input_file,line_number);
Printf(stderr,"%s : Line %d. Warning. Array member will be read-only.\n",input_file,line_number);
DelDataType(temp_typeptr);
}
scanner_clear_start();
@ -2860,12 +2860,12 @@ base_list : base_specifier {
;
base_specifier : ID {
fprintf(stderr,"%s : Line %d. No access specifier given for base class %s (ignored).\n",
Printf(stderr,"%s : Line %d. No access specifier given for base class %s (ignored).\n",
input_file,line_number,$1);
$$ = (char *) 0;
}
| VIRTUAL ID {
fprintf(stderr,"%s : Line %d. No access specifier given for base class %s (ignored).\n",
Printf(stderr,"%s : Line %d. No access specifier given for base class %s (ignored).\n",
input_file,line_number,$2);
$$ = (char *) 0;
}
@ -2873,7 +2873,7 @@ base_specifier : ID {
if (strcmp($2,"public") == 0) {
$$ = $3;
} else {
fprintf(stderr,"%s : Line %d. %s inheritance not supported (ignored).\n",
Printf(stderr,"%s : Line %d. %s inheritance not supported (ignored).\n",
input_file,line_number,$2);
$$ = (char *) 0;
}
@ -2882,7 +2882,7 @@ base_specifier : ID {
if (strcmp($1,"public") == 0) {
$$ = $2;
} else {
fprintf(stderr,"%s : Line %d. %s inheritance not supported (ignored).\n",
Printf(stderr,"%s : Line %d. %s inheritance not supported (ignored).\n",
input_file,line_number,$1);
$$ = (char *) 0;
}
@ -2891,7 +2891,7 @@ base_specifier : ID {
if (strcmp($1,"public") == 0) {
$$ = $3;
} else {
fprintf(stderr,"%s : Line %d. %s inheritance not supported (ignored).\n",
Printf(stderr,"%s : Line %d. %s inheritance not supported (ignored).\n",
input_file,line_number,$1);
$$ = (char *) 0;
}
@ -2949,7 +2949,7 @@ objective_c : OC_INTERFACE ID objc_inherit {
cplus_mode = CPLUS_PROTECTED;
sprintf(temp_name,"CPP_CLASS:%s\n",$2);
if (add_symbol(temp_name)) {
fprintf(stderr,"%s : Line %d. @interface %s is multiple defined.\n",
Printf(stderr,"%s : Line %d. @interface %s is multiple defined.\n",
input_file,line_number,$2);
FatalError();
}
@ -3026,7 +3026,7 @@ objc_data : objc_vars objc_data { }
{
static int last_error_line = -1;
if (last_error_line != line_number) {
fprintf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
FatalError();
last_error_line = line_number;
}
@ -3150,7 +3150,7 @@ objc_methods : objc_method objc_methods { };
{
static int last_error_line = -1;
if (last_error_line != line_number) {
fprintf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Syntax error in input.\n", input_file, line_number);
FatalError();
last_error_line = line_number;
}
@ -3356,14 +3356,14 @@ typemap_parm : type typemap_name {
DataType_add_reference(pt);
DataType_add_pointer(pt);
if (!CPlusPlus) {
fprintf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Warning. Use of C++ Reference detected. Use the -c++ option.\n", input_file, line_number);
}
$$->args = tm_parm;
DelDataType($1);
free($3);
}
| type LPAREN stars typemap_name RPAREN LPAREN parms RPAREN {
fprintf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
Printf(stderr,"%s : Line %d. Error. Function pointer not allowed (remap with typedef).\n", input_file, line_number);
FatalError();
$$ = NewTMParm();
$$->p = NewParm($1,$4);
@ -3468,7 +3468,7 @@ void error_recover() {
/* Called by the parser (yyparse) when an error is found.*/
void yyerror (char *) {
// Fprintf(stderr,"%s : Line %d. Syntax error.\n", input_file, line_number);
// Printf(stderr,"%s : Line %d. Syntax error.\n", input_file, line_number);
// error_recover();
}

View file

@ -20,52 +20,34 @@ static char cvsroot[] = "$Header$";
#include <ctype.h>
extern "C" {
#include "doh.h"
#include "swig.h"
}
#define YYBSIZE 8192
struct InFile {
FILE *f;
int line_number;
char *in_file;
int extern_mode;
int force_extern;
DOHFile *f;
int line_number;
char *in_file;
int extern_mode;
int force_extern;
int inline_mode;
struct InFile *prev;
};
// This structure is used for managing code fragments as
// might be used by the %inline directive and handling of
// nested structures.
struct CodeFragment {
char *text;
int line_number;
CodeFragment *next;
};
InFile *in_head;
FILE *LEX_in = NULL;
DOHFile *LEX_in = 0;
static DOHString *header = 0;
static DOHString *comment = 0;
DOHString *CCode = 0; // String containing C code
static char *yybuffer;
static char *yybuffer = 0;
static int lex_pos = 0;
static int lex_len = 0;
static char *inline_yybuffer = 0;
static int inline_lex_pos = 0;
static int inline_lex_len = 0;
static int inline_line_number = 0;
static CodeFragment *fragments = 0; // Code fragments
static
char yytext[YYBSIZE];
static char yytext[YYBSIZE];
static int yylen = 0;
int line_number = 1;
int column = 1;
int column_start = 1;
char *input_file;
int start_line = 0;
static int comment_start;
@ -82,7 +64,6 @@ extern int Error;
**************************************************************/
void scanner_init() {
yybuffer = (char *) malloc(YYBSIZE);
scan_init = 1;
header = NewString("");
@ -95,7 +76,7 @@ void scanner_init() {
*
* Start reading from new file
**************************************************************/
void scanner_file(FILE *f) {
void scanner_file(DOHFile *f) {
InFile *in;
in = (InFile *) malloc(sizeof(InFile));
@ -103,7 +84,7 @@ void scanner_file(FILE *f) {
in->in_file = input_file;
in->extern_mode = WrapExtern;
in->force_extern = ForceExtern;
if (in_head) in_head->line_number = line_number+1;
in->inline_mode = 0;
if (!in_head) in->prev = 0;
else in->prev = in_head;
in_head = in;
@ -118,10 +99,11 @@ void scanner_file(FILE *f) {
**************************************************************/
void scanner_close() {
InFile *p;
fclose(LEX_in);
if (!in_head) return;
if (in_head->inline_mode) {
Delete(LEX_in);
}
p = in_head->prev;
if (p != 0) {
LEX_in = p->f;
@ -129,8 +111,9 @@ void scanner_close() {
input_file = p->in_file;
WrapExtern = p->extern_mode;
ForceExtern = p->force_extern;
Inline = p->inline_mode;
} else {
LEX_in = NULL;
LEX_in = 0;
}
free(in_head);
in_head = p;
@ -145,92 +128,37 @@ void scanner_close() {
**************************************************************/
char nextchar() {
char c = 0;
if (Inline) {
if (inline_lex_pos >= inline_lex_len) {
// Done with inlined code. Check to see if we have any
// new code fragments. If so, switch to them.
free(inline_yybuffer);
if (fragments) {
CodeFragment *f;
inline_yybuffer = fragments->text;
inline_lex_pos = 1;
inline_lex_len = strlen(fragments->text);
line_number = fragments->line_number;
f = fragments->next;
free(fragments);
fragments = f;
c = inline_yybuffer[0];
} else {
c = 0;
Inline = 0;
line_number = inline_line_number; // Restore old line number
}
int c = 0;
while (LEX_in) {
c = Getc(LEX_in);
if (c == EOF) {
scanner_close();
} else {
inline_lex_pos++;
c = inline_yybuffer[inline_lex_pos-1];
break;
}
}
if (!Inline) {
if (lex_pos >= lex_len) {
if (!LEX_in) {
SWIG_exit(1);
}
while(fgets(yybuffer, YYBSIZE, LEX_in) == NULL) {
scanner_close(); // Close current input file
if (!LEX_in) return 0; // No more, we're outta here
}
lex_len = strlen(yybuffer);
lex_pos = 0;
}
lex_pos++;
c = yybuffer[lex_pos-1];
}
if (!LEX_in) return 0;
if (yylen >= YYBSIZE) {
fprintf(stderr,"** FATAL ERROR. Buffer overflow in scanner.cxx.\nReport this to swig@cs.utah.edu.\n");
Printf(stderr,"** FATAL ERROR. Buffer overflow in scanner.cxx.\nReport this to swig-dev@cs.uchicago.edu.\n");
SWIG_exit(1);
}
yytext[yylen] = c;
yylen++;
if (c == '\n') {
line_number++;
column = 1;
} else {
column++;
}
return(c);
}
void retract(int n) {
int i, j, c;
int i;
for (i = 0; i < n; i++) {
if (Inline) {
inline_lex_pos--;
if (inline_lex_pos < 0) {
fprintf(stderr,"Internal scanner error. inline_lex_pos < 0\n");
SWIG_exit(1);
}
}
else lex_pos--;
yylen--;
column--;
if (yylen >= 0) {
Ungetc(yytext[yylen],LEX_in);
if (yytext[yylen] == '\n') {
line_number--;
// Figure out what column we're in
c = yylen-1;
j = 1;
while (c >= 0){
if (yytext[c] == '\n') break;
j++;
c--;
}
column = j;
}
}
}
@ -249,37 +177,21 @@ void retract(int n) {
**************************************************************/
void start_inline(char *text, int line) {
InFile *in;
if (Inline) {
// Already processing a code fragment, simply hang on
// to this one for later.
CodeFragment *f,*f1;
// Add a new code fragment to our list
f = (CodeFragment *) malloc(sizeof(CodeFragment));
f->text = Swig_copy_string(text);
f->line_number = line;
f->next = 0;
if (!fragments) fragments = f;
else {
f1 = fragments;
while (f1->next) f1 = f1->next;
f1->next = f;
}
} else {
// Switch our scanner over to process text from a string.
// Save current line number and other information however.
inline_yybuffer = Swig_copy_string(text);
inline_lex_len = strlen(text);
inline_lex_pos = 0;
inline_line_number = line_number; // Make copy of old line number
line_number = line;
Inline = 1;
}
in = (InFile *) malloc(sizeof(InFile));
in->f = NewString(text);
Seek(in->f,0,SEEK_SET);
in->in_file = Swig_copy_string(input_file);
in->line_number = line;
in->extern_mode = WrapExtern;
in->force_extern = ForceExtern;
in->inline_mode = 1;
in->prev = in_head;
in_head = in;
LEX_in = in->f;
line_number = line;
Inline = 1;
}
/**************************************************************
@ -308,7 +220,7 @@ void skip_brace(void) {
Putc('{',CCode);
while (num_brace > last_brace) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing '}'. Reached end of input.\n",
Printf(stderr,"%s : Line %d. Missing '}'. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
@ -339,7 +251,7 @@ void skip_template(void) {
int num_lt = 1;
while (num_lt > 0) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing '>'. Reached end of input.\n",
Printf(stderr,"%s : Line %d. Missing '>'. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
@ -380,7 +292,7 @@ void skip_to_end(void) {
break;
}
}
fprintf(stderr,"%s : EOF. Missing @end. Reached end of input.\n",
Printf(stderr,"%s : EOF. Missing @end. Reached end of input.\n",
input_file);
FatalError();
return;
@ -403,7 +315,7 @@ void skip_decl(void) {
int done = 0;
while (!done) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing semicolon. Reached end of input.\n",
Printf(stderr,"%s : Line %d. Missing semicolon. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
@ -419,7 +331,7 @@ void skip_decl(void) {
if (!done) {
while (num_brace > last_brace) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing '}'. Reached end of input.\n",
Printf(stderr,"%s : Line %d. Missing '}'. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
@ -473,7 +385,7 @@ int yylook(void) {
else if (c == '}') {
num_brace--;
if (num_brace < 0) {
fprintf(stderr,"%s : Line %d. Error. Extraneous '}' (Ignored)\n",
Printf(stderr,"%s : Line %d. Error. Extraneous '}' (Ignored)\n",
input_file, line_number);
state = 0;
num_brace = 0;
@ -521,13 +433,11 @@ int yylook(void) {
if ((c = nextchar()) == 0) return(0);
if (c == '/') {
comment_start = line_number;
column_start = column;
Clear(comment);
Printf(comment," ");
state = 10; // C++ style comment
} else if (c == '*') {
comment_start = line_number;
column_start = column;
Clear(comment);
Printf(comment," ");
state = 11; // C style comment
@ -538,14 +448,14 @@ int yylook(void) {
break;
case 10: /* C++ style comment */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated comment detected.\n",input_file);
Printf(stderr,"%s : EOF. Unterminated comment detected.\n",input_file);
FatalError();
return 0;
}
if (c == '\n') {
Putc(c,comment);
// Add the comment to documentation
yycomment(Char(comment),comment_start, column_start);
// yycomment(Char(comment),comment_start, column_start);
yylen = 0;
state = 0;
} else {
@ -556,7 +466,7 @@ int yylook(void) {
break;
case 11: /* C style comment block */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated comment detected.\n", input_file);
Printf(stderr,"%s : EOF. Unterminated comment detected.\n", input_file);
FatalError();
return 0;
}
@ -570,7 +480,7 @@ int yylook(void) {
break;
case 12: /* Still in C style comment */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated comment detected.\n", input_file);
Printf(stderr,"%s : EOF. Unterminated comment detected.\n", input_file);
FatalError();
return 0;
}
@ -579,7 +489,7 @@ int yylook(void) {
state = 12;
} else if (c == '/') {
Printf(comment," \n");
yycomment(Char(comment),comment_start,column_start);
// yycomment(Char(comment),comment_start,column_start);
yylen = 0;
state = 0;
} else {
@ -592,7 +502,7 @@ int yylook(void) {
case 2: /* Processing a string */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated string detected.\n", input_file);
Printf(stderr,"%s : EOF. Unterminated string detected.\n", input_file);
FatalError();
return 0;
}
@ -638,7 +548,7 @@ int yylook(void) {
case 40: /* Process an include block */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated include block detected.\n", input_file);
Printf(stderr,"%s : EOF. Unterminated include block detected.\n", input_file);
FatalError();
return 0;
}
@ -652,7 +562,7 @@ int yylook(void) {
break;
case 41: /* Still processing include block */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated include block detected.\n", input_file);
Printf(stderr,"%s : EOF. Unterminated include block detected.\n", input_file);
FatalError();
return 0;
}
@ -871,7 +781,7 @@ int yylook(void) {
break;
default:
if (!Error) {
fprintf(stderr,"%s : Line %d ::Illegal character '%c'=%d.\n",input_file, line_number,c,c);
Printf(stderr,"%s : Line %d ::Illegal character '%c'=%d.\n",input_file, line_number,c,c);
FatalError();
}
state = 0;
@ -986,7 +896,7 @@ extern "C" int yylex(void) {
}
// Objective-C keywords
if (ObjC) {
if ((ObjC) && (yytext[0] == '@')) {
if (strcmp(yytext,"@interface") == 0) return (OC_INTERFACE);
if (strcmp(yytext,"@end") == 0) return (OC_END);
if (strcmp(yytext,"@public") == 0) return (OC_PUBLIC);
@ -1007,79 +917,81 @@ extern "C" int yylex(void) {
if (strcmp(yytext,"enum") == 0) return(ENUM);
if (strcmp(yytext,"sizeof") == 0) return(SIZEOF);
if (strcmp(yytext,"typedef") == 0) {
yylval.ivalue = 0;
return(TYPEDEF);
}
// Ignored keywords
if (strcmp(yytext,"volatile") == 0) return(yylex());
// SWIG directives
if (strcmp(yytext,"%module") == 0) return(MODULE);
if (strcmp(yytext,"%init") == 0) return(INIT);
if (strcmp(yytext,"%wrapper") == 0) return(WRAPPER);
if (strcmp(yytext,"%readonly") == 0) return(READONLY);
if (strcmp(yytext,"%readwrite") == 0) return(READWRITE);
if (strcmp(yytext,"%name") == 0) return(NAME);
if (strcmp(yytext,"%rename") == 0) return(RENAME);
if (strcmp(yytext,"%includefile") == 0) return(INCLUDE);
if (strcmp(yytext,"%externfile") == 0) return(WEXTERN);
if (strcmp(yytext,"%val") == 0) {
fprintf(stderr,"%s:%d %%val directive deprecated (ignored).\n", input_file, line_number);
return (yylex());
if (yytext[0] == '%') {
if (strcmp(yytext,"%module") == 0) return(MODULE);
if (strcmp(yytext,"%init") == 0) return(INIT);
if (strcmp(yytext,"%wrapper") == 0) return(WRAPPER);
if (strcmp(yytext,"%readonly") == 0) return(READONLY);
if (strcmp(yytext,"%readwrite") == 0) return(READWRITE);
if (strcmp(yytext,"%name") == 0) return(NAME);
if (strcmp(yytext,"%rename") == 0) return(RENAME);
if (strcmp(yytext,"%includefile") == 0) return(INCLUDE);
if (strcmp(yytext,"%externfile") == 0) return(WEXTERN);
if (strcmp(yytext,"%val") == 0) {
Printf(stderr,"%s:%d %%val directive deprecated (ignored).\n", input_file, line_number);
return (yylex());
}
if (strcmp(yytext,"%out") == 0) {
Printf(stderr,"%s:%d %%out directive deprecated (ignored).\n", input_file, line_number);
return(yylex());
}
if (strcmp(yytext,"%constant") == 0) return(CONSTANT);
if (strcmp(yytext,"%macro") == 0) return(SWIGMACRO);
if (strcmp(yytext,"%section") == 0) {
yylval.ivalue = line_number;
return(SECTION);
}
if (strcmp(yytext,"%subsection") == 0) {
yylval.ivalue = line_number;
return(SUBSECTION);
}
if (strcmp(yytext,"%subsubsection") == 0) {
yylval.ivalue = line_number;
return (SUBSUBSECTION);
}
if (strcmp(yytext,"%title") == 0) {
yylval.ivalue = line_number;
return(TITLE);
}
if (strcmp(yytext,"%style") == 0) return(STYLE);
if (strcmp(yytext,"%localstyle") == 0) return(LOCALSTYLE);
if (strcmp(yytext,"%typedef") == 0) {
yylval.ivalue = 1;
return(TYPEDEF);
}
if (strcmp(yytext,"%alpha") == 0) return(ALPHA_MODE);
if (strcmp(yytext,"%raw") == 0) return(RAW_MODE);
if (strcmp(yytext,"%text") == 0) return(TEXT);
if (strcmp(yytext,"%native") == 0) return(NATIVE);
if (strcmp(yytext,"%disabledoc") == 0) return(DOC_DISABLE);
if (strcmp(yytext,"%enabledoc") == 0) return(DOC_ENABLE);
if (strcmp(yytext,"%pragma") == 0) return(PRAGMA);
if (strcmp(yytext,"%addmethods") == 0) return(ADDMETHODS);
if (strcmp(yytext,"%inline") == 0) return(INLINE);
if (strcmp(yytext,"%typemap") == 0) return(TYPEMAP);
if (strcmp(yytext,"%except") == 0) return(EXCEPT);
if (strcmp(yytext,"%importfile") == 0) return(IMPORT);
if (strcmp(yytext,"%echo") == 0) return(ECHO);
if (strcmp(yytext,"%new") == 0) return(NEW);
if (strcmp(yytext,"%apply") == 0) return(APPLY);
if (strcmp(yytext,"%clear") == 0) return(CLEAR);
if (strcmp(yytext,"%doconly") == 0) return(DOCONLY);
}
if (strcmp(yytext,"%out") == 0) {
fprintf(stderr,"%s:%d %%out directive deprecated (ignored).\n", input_file, line_number);
return(yylex());
}
if (strcmp(yytext,"%constant") == 0) return(CONSTANT);
if (strcmp(yytext,"%macro") == 0) return(SWIGMACRO);
if (strcmp(yytext,"%section") == 0) {
yylval.ivalue = line_number;
return(SECTION);
}
if (strcmp(yytext,"%subsection") == 0) {
yylval.ivalue = line_number;
return(SUBSECTION);
}
if (strcmp(yytext,"%subsubsection") == 0) {
yylval.ivalue = line_number;
return (SUBSUBSECTION);
}
if (strcmp(yytext,"%title") == 0) {
yylval.ivalue = line_number;
return(TITLE);
}
if (strcmp(yytext,"%style") == 0) return(STYLE);
if (strcmp(yytext,"%localstyle") == 0) return(LOCALSTYLE);
if (strcmp(yytext,"%typedef") == 0) {
yylval.ivalue = 1;
return(TYPEDEF);
}
if (strcmp(yytext,"typedef") == 0) {
yylval.ivalue = 0;
return(TYPEDEF);
}
if (strcmp(yytext,"%alpha") == 0) return(ALPHA_MODE);
if (strcmp(yytext,"%raw") == 0) return(RAW_MODE);
if (strcmp(yytext,"%text") == 0) return(TEXT);
if (strcmp(yytext,"%native") == 0) return(NATIVE);
if (strcmp(yytext,"%disabledoc") == 0) return(DOC_DISABLE);
if (strcmp(yytext,"%enabledoc") == 0) return(DOC_ENABLE);
if (strcmp(yytext,"%pragma") == 0) return(PRAGMA);
if (strcmp(yytext,"%addmethods") == 0) return(ADDMETHODS);
if (strcmp(yytext,"%inline") == 0) return(INLINE);
if (strcmp(yytext,"%typemap") == 0) return(TYPEMAP);
if (strcmp(yytext,"%except") == 0) return(EXCEPT);
if (strcmp(yytext,"%importfile") == 0) return(IMPORT);
if (strcmp(yytext,"%echo") == 0) return(ECHO);
if (strcmp(yytext,"%new") == 0) return(NEW);
if (strcmp(yytext,"%apply") == 0) return(APPLY);
if (strcmp(yytext,"%clear") == 0) return(CLEAR);
if (strcmp(yytext,"%doconly") == 0) return(DOCONLY);
// Have an unknown identifier, as a last step, we'll
// Have an unknown identifier, as a last step, we'll
// do a typedef lookup on it.
if (check_typedef) {
if (DataType_is_typedef(yytext)) {
yylval.type = NewDataType(T_USER);
@ -1088,7 +1000,7 @@ extern "C" int yylex(void) {
return(TYPE_TYPEDEF);
}
}
yylval.id = Swig_copy_string(yytext);
return(ID);
default:

View file

@ -34,9 +34,9 @@ extern FILE *swig_log;
#endif
extern FILE *f_runtime; // Runtime code
extern FILE *f_header; // Headers
extern FILE *f_wrappers; // Wrappers
extern FILE *f_init; // Initialization code
extern DOH *f_header; // Headers
extern DOH *f_wrappers; // Wrappers
extern DOH *f_init; // Initialization code
extern FILE *f_input;
extern char InitName[256];
extern char LibDir[512]; // Library directory

View file

@ -171,7 +171,7 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
/* Check to see if an array typemap has been applied to a non-array type */
if ((DataType_arraystr(tm_type)) && (!DataType_arraystr(type))) {
fprintf(stderr,"%s:%d: Warning. Array typemap has been applied to a non-array type.\n",
Printf(stderr,"%s:%d: Warning. Array typemap has been applied to a non-array type.\n",
input_file,line_number);
}
@ -180,7 +180,7 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
if ((DataType_arraystr(tm_type)) && (DataType_arraystr(type))) {
char s[128],*t;
if (DataType_array_dimensions(tm_type) != DataType_array_dimensions(type)) {
fprintf(stderr,"%s:%d: Warning. Array types have different number of dimensions.\n",
Printf(stderr,"%s:%d: Warning. Array types have different number of dimensions.\n",
input_file,line_number);
} else {
for (int i = 0; i < DataType_array_dimensions(tm_type); i++) {
@ -188,7 +188,7 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
t = DataType_get_dimension(type,i);
if (strcmp(s,"ANY") != 0) {
if (strcmp(s,t))
fprintf(stderr,"%s:%d: Warning. Array typemap applied to an array of different size.\n",
Printf(stderr,"%s:%d: Warning. Array typemap applied to an array of different size.\n",
input_file, line_number);
}
}
@ -314,7 +314,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
if (pn) {
/* printf(" %s %s\n", pt,pn); */
} else {
fprintf(stderr,"%s:%d: Typemap error. Local variables must have a name\n",
Printf(stderr,"%s:%d: Typemap error. Local variables must have a name\n",
input_file, line_number);
}
p = Getnext(p);
@ -648,7 +648,7 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
/* If there were locals and no wrapper function, print a warning */
/* if ((tm->args) && !f) {
if (!pname) pname = (char*)"";
fprintf(stderr,"%s:%d: Warning. '%%typemap(%s,%s) %s %s' being applied with ignored locals.\n",
Printf(stderr,"%s:%d: Warning. '%%typemap(%s,%s) %s %s' being applied with ignored locals.\n",
input_file, line_number, lang,op, DataType_str(type,0), pname);
}
*/
@ -1139,7 +1139,7 @@ int check_numopt(ParmList *p) {
n++;
} else {
if (state) {
fprintf(stderr,"%s : Line %d. Argument %d must have a default value!\n", input_file,line_number,i+1);
Printf(stderr,"%s : Line %d. Argument %d must have a default value!\n", input_file,line_number,i+1);
}
}
}

View file

@ -130,7 +130,6 @@ extern Parm *CopyParm(Parm *p);
typedef DOH ParmList;
extern ParmList *NewParmList();
extern ParmList *CopyParmList(ParmList *);
extern int ParmList_len(ParmList *);
@ -262,6 +261,7 @@ extern DOHString *SwigType_array_getdim(DOHString_or_char *t, int n);
extern void SwigType_array_setdim(DOHString_or_char *t, int n, DOHString_or_char *rep);
extern DOHString *SwigType_default(DOHString_or_char *t);
/* --- Parse tree support --- */
typedef struct {