Made it so language modules can specify a file to process before anything else (for typemaps). Also fixed line-numbering problem in main.cxx

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@709 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-08-29 01:46:54 +00:00
commit b2e1d63628
6 changed files with 32 additions and 8 deletions

View file

@ -92,6 +92,7 @@ TCL8::parse_args(int argc, char *argv[]) {
Preprocessor_define((void *) "SWIGTCL 1",0);
Preprocessor_define((void *) "SWIGTCL8 1", 0);
typemap_lang = (char*)"tcl8";
SWIG_config_file("tcl8.swg");
}
/* -----------------------------------------------------------------------------

View file

@ -126,6 +126,13 @@ FILE *swig_log;
char *SwigLib;
static int freeze = 0;
static String *lang_config = 0;
/* This function sets the name of the configuration file */
void SWIG_config_file(String_or_char *filename) {
lang_config = NewString(filename);
}
int SWIG_main(int argc, char *argv[], Language *l) {
int i;
char *c;
@ -386,16 +393,24 @@ int SWIG_main(int argc, char *argv[], Language *l) {
{
DOH *cpps;
int i;
DOH *fs = NewString("");
DOH *ds = Swig_include(input_file);
String *path;
String *fs = NewString("");
String *ds = Swig_include(input_file);
if (!ds) {
Printf(stderr,"Unable to find '%s'\n", input_file);
SWIG_exit(1);
}
path = Copy(Swig_last_file());
if (lang_config) {
Printf(fs,"\n%%include \"%s\"\n", lang_config);
}
for (i = 0; i < Len(libfiles); i++) {
Printf(fs,"\n%%include \"%s\"\n", Getitem(libfiles,i));
}
Printf(fs,"\n%%includefile \"%s\" {\n", path);
Append(fs, ds);
Append(fs,"\n}\n");
Delete(path);
Delete(ds);
Seek(fs,0,SEEK_SET);
cpps = Preprocessor_parse(fs);

View file

@ -475,7 +475,7 @@ static void dump_nested(char *parent) {
};
%token <id> ID
%token <id> HBLOCK WRAPPER POUND
%token <id> HBLOCK WRAPPER POUND RUNTIME
%token <id> STRING
%token <loc> INCLUDE IMPORT WEXTERN SWIGMACRO
%token <id> NUM_INT NUM_FLOAT CHARCONST NUM_UNSIGNED NUM_LONG NUM_ULONG
@ -858,6 +858,13 @@ statement : INCLUDE STRING LBRACE {
}
}
| RUNTIME HBLOCK {
if (!WrapExtern) {
$2[strlen($2) - 1] = 0;
Printf(f_runtime,"%s\n", $2);
}
}
/* Initialization code */
| INIT HBLOCK {

View file

@ -396,6 +396,10 @@ static void get_escape() {
yytext[yylen-1] = '\"';
return;
}
if (c == '\n') {
yylen--;
return;
}
if (c == '0') {
state = 10;
}
@ -1026,6 +1030,7 @@ extern "C" int yylex(void) {
if (strcmp(yytext,"%module") == 0) return(MODULE);
if (strcmp(yytext,"%init") == 0) return(INIT);
if (strcmp(yytext,"%wrapper") == 0) return(WRAPPER);
if (strcmp(yytext,"%runtime") == 0) return(RUNTIME);
if (strcmp(yytext,"%readonly") == 0) return(READONLY);
if (strcmp(yytext,"%readwrite") == 0) return(READWRITE);
if (strcmp(yytext,"%name") == 0) return(NAME);

View file

@ -264,4 +264,5 @@ extern int emit_args(SwigType *, ParmList *, Wrapper *f);
extern void emit_func_call(char *, SwigType *, ParmList *, Wrapper *f);
extern void SWIG_exit(int);
extern int check_numopt(ParmList *);
extern void SWIG_config_file(String_or_char *);

View file

@ -44,11 +44,6 @@ Swig_banner(File *f) {
* This file was automatically generated by SWIG (http://www.swig.org).\n\
* Version %s %s\n\
* \n\
* Portions Copyright (c) 1995-2000\n\
* The University of Utah, The Regents of the University of California, and\n\
* The University of Chicago. Permission is hereby granted to use, modify, \n\
* and distribute this file in any manner provided this notice remains intact.\n\
* \n\
* This file is not intended to be easily readable and contains a number of \n\
* coding conventions designed to improve portability and efficiency. Do not make\n\
* changes to this file unless you know what you are doing--modify the SWIG \n\