Slash, burn, crash, crumble. Don't mind me.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@279 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4ea673bb03
commit
77cb823ab6
13 changed files with 88 additions and 317 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
/* SWIG version information */
|
/* SWIG version information */
|
||||||
|
|
||||||
#define SWIG_MAJOR_VERSION 1
|
#define SWIG_VERSION "1.3u-20000226-1923"
|
||||||
#define SWIG_MINOR_VERSION 3
|
|
||||||
#define SWIG_SPIN "(Alpha 1)"
|
#define SWIG_SPIN "(Alpha 1)"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ GUILE::headers (void)
|
||||||
// Write out hex conversion functions
|
// Write out hex conversion functions
|
||||||
|
|
||||||
if (!NoInclude) {
|
if (!NoInclude) {
|
||||||
if (insert_file ("guile.swg", f_header) == -1) {
|
if (Swig_insert_file ("guile.swg", f_header) == -1) {
|
||||||
fprintf (stderr, "SWIG : Fatal error. ");
|
fprintf (stderr, "SWIG : Fatal error. ");
|
||||||
fprintf (stderr, "Unable to locate 'guile.swg' in SWIG library.\n");
|
fprintf (stderr, "Unable to locate 'guile.swg' in SWIG library.\n");
|
||||||
SWIG_exit (1);
|
SWIG_exit (1);
|
||||||
|
|
|
||||||
|
|
@ -404,7 +404,7 @@ void JAVA::headers(void)
|
||||||
|
|
||||||
// Include header file code fragment into the output
|
// Include header file code fragment into the output
|
||||||
// if (file::include("java.swg",f_header) == -1) {
|
// if (file::include("java.swg",f_header) == -1) {
|
||||||
if (insert_file("java.swg",f_header) == -1) {
|
if (Swig_insert_file("java.swg",f_header) == -1) {
|
||||||
fprintf(stderr,"Fatal Error. Unable to locate 'java.swg'.\n");
|
fprintf(stderr,"Fatal Error. Unable to locate 'java.swg'.\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -295,12 +295,12 @@ void PERL5::headers(void)
|
||||||
emit_banner(f_header);
|
emit_banner(f_header);
|
||||||
|
|
||||||
if (!alt_header) {
|
if (!alt_header) {
|
||||||
if (insert_file("headers.swg", f_header) == -1) {
|
if (Swig_insert_file("headers.swg", f_header) == -1) {
|
||||||
fprintf(stderr,"Perl5 : Fatal error. Unable to locate headers.swg. Possible installation problem.\n");
|
fprintf(stderr,"Perl5 : Fatal error. Unable to locate headers.swg. Possible installation problem.\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (insert_file(alt_header, f_header) == -1) {
|
if (Swig_insert_file(alt_header, f_header) == -1) {
|
||||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate %s.\n",alt_header);
|
fprintf(stderr,"SWIG : Fatal error. Unable to locate %s.\n",alt_header);
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -311,13 +311,13 @@ void PERL5::headers(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get special SWIG related declarations
|
// Get special SWIG related declarations
|
||||||
if (insert_file("perl5.swg", f_header) == -1) {
|
if (Swig_insert_file("perl5.swg", f_header) == -1) {
|
||||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5.swg' in SWIG library.\n");
|
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5.swg' in SWIG library.\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get special SWIG related declarations
|
// Get special SWIG related declarations
|
||||||
if (insert_file("perl5mg.swg", f_header) == -1) {
|
if (Swig_insert_file("perl5mg.swg", f_header) == -1) {
|
||||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5mg.swg' in SWIG library.\n");
|
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5mg.swg' in SWIG library.\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -2225,8 +2225,14 @@ void PERL5::pragma(char *lang, char *code, char *value) {
|
||||||
} else if (strcmp(code,"include") == 0) {
|
} else if (strcmp(code,"include") == 0) {
|
||||||
// Include a file into the .pm file
|
// Include a file into the .pm file
|
||||||
if (value) {
|
if (value) {
|
||||||
if (get_file(value,pragma_include) == -1) {
|
FILE *f = Swig_open(value);
|
||||||
|
if (!f) {
|
||||||
fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value);
|
fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value);
|
||||||
|
} else {
|
||||||
|
char buffer[4096];
|
||||||
|
while (fgets(buffer,4095,f)) {
|
||||||
|
pragma_include << buffer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ void PYTHON::headers(void)
|
||||||
if (NoInclude)
|
if (NoInclude)
|
||||||
fprintf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
fprintf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
||||||
|
|
||||||
if (insert_file("python.swg", f_runtime) == -1) {
|
if (Swig_insert_file("python.swg", f_runtime) == -1) {
|
||||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate python.swg. (Possible installation problem).\n");
|
fprintf(stderr,"SWIG : Fatal error. Unable to locate python.swg. (Possible installation problem).\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -1455,8 +1455,14 @@ void PYTHON::pragma(char *lang, char *cmd, char *value) {
|
||||||
} else if (strcmp(cmd,"include") == 0) {
|
} else if (strcmp(cmd,"include") == 0) {
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
if (value) {
|
if (value) {
|
||||||
if (get_file(value,pragma_include) == -1) {
|
FILE *f = Swig_open(value);
|
||||||
fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number, value);
|
if (!f) {
|
||||||
|
fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value);
|
||||||
|
} else {
|
||||||
|
char buffer[4096];
|
||||||
|
while (fgets(buffer,4095,f)) {
|
||||||
|
pragma_include << buffer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ void TCL8::headers(void)
|
||||||
fprintf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
fprintf(f_runtime,"#define SWIG_NOINCLUDE\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insert_file("swigtcl8.swg",f_runtime) == -1) {
|
if (Swig_insert_file("swigtcl8.swg",f_runtime) == -1) {
|
||||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'swigtcl8.swg' in SWIG library.\n");
|
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'swigtcl8.swg' in SWIG library.\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -1224,7 +1224,7 @@ void TCL8::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
static int included_object = 0;
|
static int included_object = 0;
|
||||||
if (!included_object) {
|
if (!included_object) {
|
||||||
if (insert_file("object.swg",f_header) == -1) {
|
if (Swig_insert_file("object.swg",f_header) == -1) {
|
||||||
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'object.swg' in SWIG library.\n");
|
fprintf(stderr,"SWIG : Fatal error. Unable to locate 'object.swg' in SWIG library.\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ RANLIB = @RANLIB@
|
||||||
|
|
||||||
TARGET = libswig11.a
|
TARGET = libswig11.a
|
||||||
|
|
||||||
OBJS = parser.o main.o scanner.o symbol.o types.o include.o parms.o \
|
OBJS = parser.o main.o scanner.o symbol.o types.o parms.o \
|
||||||
emit.o cplus.o lang.o hash.o sstring.o wrapfunc.o \
|
emit.o cplus.o lang.o hash.o sstring.o wrapfunc.o \
|
||||||
typemap.o naming.o
|
typemap.o naming.o
|
||||||
|
|
||||||
SRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx \
|
SRCS = main.cxx scanner.cxx symbol.cxx types.cxx parms.cxx \
|
||||||
emit.cxx cplus.cxx lang.cxx hash.cxx \
|
emit.cxx cplus.cxx lang.cxx hash.cxx \
|
||||||
sstring.cxx wrapfunc.cxx typemap.cxx naming.cxx
|
sstring.cxx wrapfunc.cxx typemap.cxx naming.cxx
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,93 +205,6 @@ char *emit_local(int i) {
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// int emit_args(char *d, DataType *rt, ParmList *l, FILE *f)
|
|
||||||
//
|
|
||||||
// Creates a list of variable declarations for both the return value
|
|
||||||
// and function parameters.
|
|
||||||
//
|
|
||||||
// The return value is always called _result and arguments label as
|
|
||||||
// _arg0, _arg1, _arg2, etc...
|
|
||||||
//
|
|
||||||
// Returns the number of parameters associated with a function.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int emit_args(DataType *rt, ParmList *l, FILE *f) {
|
|
||||||
|
|
||||||
Parm *p;
|
|
||||||
int i;
|
|
||||||
char temp[64];
|
|
||||||
String def;
|
|
||||||
char *tm;
|
|
||||||
|
|
||||||
// Declare the return variable
|
|
||||||
|
|
||||||
if ((rt->type != T_VOID) || (rt->is_pointer)) {
|
|
||||||
if ((rt->type == T_USER) && (!rt->is_pointer)) {
|
|
||||||
|
|
||||||
// Special case for return by "value"
|
|
||||||
|
|
||||||
rt->is_pointer++;
|
|
||||||
fprintf(f,"\t %s _result;\n", rt->print_type());
|
|
||||||
rt->is_pointer--;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Normal return value
|
|
||||||
|
|
||||||
fprintf(f,"\t %s _result;\n", rt->print_type());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit function arguments
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
p = l->get_first();
|
|
||||||
while (p != 0) {
|
|
||||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)) {
|
|
||||||
sprintf(temp,"_arg%d", i);
|
|
||||||
if (p->defvalue) {
|
|
||||||
if ((p->t->is_reference) || ((p->t->type == T_USER) && (p->call_type == CALL_REFERENCE)))
|
|
||||||
fprintf(f,"\t %s _arg%d = &%s;\n", p->t->print_type(),i, p->defvalue);
|
|
||||||
else
|
|
||||||
fprintf(f,"\t %s _arg%d = %s;\n", p->t->print_type(),i, p->defvalue);
|
|
||||||
} else {
|
|
||||||
fprintf(f,"\t %s _arg%d;\n", p->t->print_type(),i);
|
|
||||||
tm = typemap_lookup("arginit", typemap_lang, p->t, p->name,"",temp);
|
|
||||||
if (tm) {
|
|
||||||
def << tm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for ignore or default typemaps
|
|
||||||
|
|
||||||
tm = typemap_lookup("default",typemap_lang,p->t,p->name,"",temp);
|
|
||||||
if (tm)
|
|
||||||
def << tm;
|
|
||||||
tm = typemap_lookup("ignore",typemap_lang,p->t,p->name,"",temp);
|
|
||||||
|
|
||||||
if (tm) {
|
|
||||||
def << tm;
|
|
||||||
p->ignore = 1;
|
|
||||||
}
|
|
||||||
tm = typemap_check("build",typemap_lang,p->t,p->name);
|
|
||||||
if (tm) {
|
|
||||||
p->ignore = 1;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
p = l->get_next();
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f,"%s",def.get());
|
|
||||||
|
|
||||||
// i now contains number of parameters
|
|
||||||
|
|
||||||
return(i);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// int emit_args(char *d, DataType *rt, ParmList *l, WrapperFunction &f)
|
// int emit_args(char *d, DataType *rt, ParmList *l, WrapperFunction &f)
|
||||||
//
|
//
|
||||||
|
|
@ -375,86 +288,6 @@ int emit_args(DataType *rt, ParmList *l, WrapperFunction &f) {
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// int emit_func_call(char *decl, DataType *t, ParmList *l, FILE *f)
|
|
||||||
//
|
|
||||||
// Emits code for a function call.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void emit_func_call(char *decl, DataType *t, ParmList *l, FILE *f) {
|
|
||||||
|
|
||||||
int i;
|
|
||||||
Parm *p;
|
|
||||||
|
|
||||||
// fprintf(f,"#line %d \"%s\"\n", line_number, input_file);
|
|
||||||
fprintf(f,"\t ");
|
|
||||||
|
|
||||||
// First check if there is a return value
|
|
||||||
|
|
||||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
|
||||||
|
|
||||||
// Special case for return by "value"
|
|
||||||
// Caution : This *will* cause a memory leak if not
|
|
||||||
// used properly.
|
|
||||||
|
|
||||||
if (CPlusPlus) {
|
|
||||||
fprintf(f,"_result = new %s(", t->print_type());
|
|
||||||
} else {
|
|
||||||
t->is_pointer++;
|
|
||||||
fprintf(f,"_result = %s malloc(sizeof(", t->print_cast());
|
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"%s));\n", t->print_type());
|
|
||||||
fprintf(f,"\t*(_result) = ");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Check if this is a C++ reference
|
|
||||||
if (t->is_reference) {
|
|
||||||
t->is_pointer--;
|
|
||||||
fprintf(f,"%s& _result_ref = ", t->print_full());
|
|
||||||
t->is_pointer++;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Normal return values
|
|
||||||
fprintf(f,"_result = %s", t->print_cast());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now print out function call
|
|
||||||
|
|
||||||
fprintf(f,"%s(",decl);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
p = l->get_first();
|
|
||||||
while(p != 0) {
|
|
||||||
if ((p->t->type != T_VOID) || (p->t->is_pointer)){
|
|
||||||
fprintf(f,"%s",p->t->print_arraycast());
|
|
||||||
if ((!p->t->is_reference) && (p->call_type & CALL_VALUE)) fprintf(f,"&");
|
|
||||||
if ((!(p->call_type & CALL_VALUE)) &&
|
|
||||||
((p->t->is_reference) || (p->call_type & CALL_REFERENCE)))
|
|
||||||
fprintf(f,"*");
|
|
||||||
fprintf(f,"_arg%d",i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
p = l->get_next();
|
|
||||||
if (p != 0)
|
|
||||||
fprintf(f,",");
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f,")");
|
|
||||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
|
||||||
if (CPlusPlus) {
|
|
||||||
fprintf(f,")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(f,";\n");
|
|
||||||
if (t->is_reference) {
|
|
||||||
fprintf(f,"\t _result = %s &_result_ref;\n", t->print_cast());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// int emit_func_call(char *decl, DataType *t, ParmList *l, WrapperFunction &f)
|
// int emit_func_call(char *decl, DataType *t, ParmList *l, WrapperFunction &f)
|
||||||
|
|
@ -562,27 +395,6 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, WrapperFunction &f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void emit_hex(FILE *f)
|
|
||||||
//
|
|
||||||
// Emits the default C-code to handle pointers. This is normally contained
|
|
||||||
// in the SWIG library file 'swigptr.swg'
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void emit_hex(FILE *f) {
|
|
||||||
|
|
||||||
int stat;
|
|
||||||
|
|
||||||
// Look for a pointer configuration file
|
|
||||||
|
|
||||||
stat = insert_file("swigptr.swg", f);
|
|
||||||
|
|
||||||
if (stat == -1) {
|
|
||||||
fprintf(stderr,"** Fatal error. Unable to locate 'swigptr.swg'\n");
|
|
||||||
SWIG_exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// void emit_set_get(char *name, char *iname, DataType *type)
|
// void emit_set_get(char *name, char *iname, DataType *type)
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* include.cxx
|
|
||||||
*
|
|
||||||
* File inclusion functions. This file is deprecated. These are only a
|
|
||||||
* thin wrapper over the functions in Swig/include.c.
|
|
||||||
*
|
|
||||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
|
||||||
*
|
|
||||||
* Copyright (C) 1998-2000. The University of Chicago
|
|
||||||
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
|
||||||
* University of California.
|
|
||||||
*
|
|
||||||
* See the file LICENSE for information on usage and redistribution.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static char cvsroot[] = "$Header$";
|
|
||||||
|
|
||||||
#include "internal.h"
|
|
||||||
|
|
||||||
extern "C" FILE *Swig_open(void *);
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// check_suffix(char *name)
|
|
||||||
//
|
|
||||||
// Checks the suffix of a file to see if we should emit extern declarations.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int
|
|
||||||
check_suffix(char *name) {
|
|
||||||
char *c;
|
|
||||||
if (!name) return 0;
|
|
||||||
if (strlen(name) == 0) return 0;
|
|
||||||
c = name+strlen(name)-1;
|
|
||||||
while (c != name) {
|
|
||||||
if (*c == '.') break;
|
|
||||||
c--;
|
|
||||||
}
|
|
||||||
if (c == name) return 0;
|
|
||||||
if ((strcmp(c,".c") == 0) ||
|
|
||||||
(strcmp(c,".C") == 0) ||
|
|
||||||
(strcmp(c,".cc") == 0) ||
|
|
||||||
(strcmp(c,".cxx") == 0) ||
|
|
||||||
(strcmp(c,".c++") == 0) ||
|
|
||||||
(strcmp(c,".cpp") == 0)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// int insert_file(char *filename, FILE *f)
|
|
||||||
//
|
|
||||||
// Appends the contents of filename to stream f.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
int insert_file(char *filename, FILE *f) {
|
|
||||||
FILE *in_file;
|
|
||||||
char buffer[1024];
|
|
||||||
if ((in_file = Swig_open((void *) filename)) == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
while (fgets(buffer,1023,in_file)) {
|
|
||||||
fputs(buffer, f);
|
|
||||||
}
|
|
||||||
fclose(in_file);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// int get_file(char *name, String &str)
|
|
||||||
//
|
|
||||||
// Looks for a file and converts it into a String.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
int get_file(char *name, String &str) {
|
|
||||||
FILE *f;
|
|
||||||
char buffer[1024];
|
|
||||||
f = Swig_open((void *) name);
|
|
||||||
if (!f) {
|
|
||||||
fprintf(stderr,"SWIG Error. Unable to find %s. Possible installation problem.\n",name);
|
|
||||||
FatalError();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
while (fgets(buffer,1023,f)) {
|
|
||||||
str << buffer;
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -77,6 +77,34 @@ static char *usage = "\
|
||||||
-version - Print SWIG version number\n\
|
-version - Print SWIG version number\n\
|
||||||
-help - This output.\n\n";
|
-help - This output.\n\n";
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// check_suffix(char *name)
|
||||||
|
//
|
||||||
|
// Checks the suffix of a file to see if we should emit extern declarations.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int
|
||||||
|
check_suffix(char *name) {
|
||||||
|
char *c;
|
||||||
|
if (!name) return 0;
|
||||||
|
if (strlen(name) == 0) return 0;
|
||||||
|
c = name+strlen(name)-1;
|
||||||
|
while (c != name) {
|
||||||
|
if (*c == '.') break;
|
||||||
|
c--;
|
||||||
|
}
|
||||||
|
if (c == name) return 0;
|
||||||
|
if ((strcmp(c,".c") == 0) ||
|
||||||
|
(strcmp(c,".C") == 0) ||
|
||||||
|
(strcmp(c,".cc") == 0) ||
|
||||||
|
(strcmp(c,".cxx") == 0) ||
|
||||||
|
(strcmp(c,".c++") == 0) ||
|
||||||
|
(strcmp(c,".cpp") == 0)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
// main()
|
// main()
|
||||||
//
|
//
|
||||||
|
|
@ -342,10 +370,10 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
sprintf(fn_wrapper,"%s%s_wrap.wrap",output_dir,infile);
|
sprintf(fn_wrapper,"%s%s_wrap.wrap",output_dir,infile);
|
||||||
sprintf(fn_init,"%s%s_wrap.init",output_dir,infile);
|
sprintf(fn_init,"%s%s_wrap.init",output_dir,infile);
|
||||||
|
|
||||||
printf("%s\n", input_file);
|
// printf("%s\n", input_file);
|
||||||
printf("%s\n", fn_cpp);
|
// printf("%s\n", fn_cpp);
|
||||||
printf("%s\n", fn_wrapper);
|
// printf("%s\n", fn_wrapper);
|
||||||
printf("%s\n", fn_init);
|
// printf("%s\n", fn_init);
|
||||||
|
|
||||||
// Define the __cplusplus symbol
|
// Define the __cplusplus symbol
|
||||||
if (CPlusPlus)
|
if (CPlusPlus)
|
||||||
|
|
@ -440,9 +468,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
fclose(f_wrappers);
|
fclose(f_wrappers);
|
||||||
fclose(f_init);
|
fclose(f_init);
|
||||||
|
|
||||||
insert_file(fn_header, f_runtime);
|
Swig_insert_file(fn_header, f_runtime);
|
||||||
insert_file(fn_wrapper,f_runtime);
|
Swig_insert_file(fn_wrapper,f_runtime);
|
||||||
insert_file(fn_init,f_runtime);
|
Swig_insert_file(fn_init,f_runtime);
|
||||||
|
|
||||||
fclose(f_runtime);
|
fclose(f_runtime);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -459,11 +459,6 @@ extern void cplus_emit_variable_set(char *classname, char *classtype, char *clas
|
||||||
|
|
||||||
extern char *cplus_base_class(char *name);
|
extern char *cplus_base_class(char *name);
|
||||||
|
|
||||||
/* Function for building search directories */
|
|
||||||
|
|
||||||
extern int insert_file(char *, FILE *);
|
|
||||||
extern int get_file(char *filename, String &str);
|
|
||||||
|
|
||||||
/* These are in the new core */
|
/* These are in the new core */
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -473,6 +468,8 @@ extern "C" {
|
||||||
extern void Swig_check_options();
|
extern void Swig_check_options();
|
||||||
extern void Swig_arg_error();
|
extern void Swig_arg_error();
|
||||||
extern void *Preprocessor_define(void *, int);
|
extern void *Preprocessor_define(void *, int);
|
||||||
|
extern int Swig_insert_file(const void *filename, void *outfile);
|
||||||
|
extern FILE *Swig_open(const void *filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ static int bytes_read = 0; /* Bytes read */
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void
|
||||||
Swig_add_directory(DOH *dirname) {
|
Swig_add_directory(const DOH *dirname) {
|
||||||
if (!directories) directories = NewList();
|
if (!directories) directories = NewList();
|
||||||
assert(directories);
|
assert(directories);
|
||||||
if (!String_check(dirname)) {
|
if (!String_check(dirname)) {
|
||||||
|
|
@ -86,7 +86,7 @@ Swig_search_path() {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
Swig_open(DOH *name) {
|
Swig_open(const DOH *name) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
DOH *filename;
|
DOH *filename;
|
||||||
DOH *spath = 0;
|
DOH *spath = 0;
|
||||||
|
|
@ -143,7 +143,7 @@ Swig_read_file(FILE *f) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *
|
||||||
Swig_include(DOH *name) {
|
Swig_include(const DOH *name) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
DOH *str;
|
DOH *str;
|
||||||
f = Swig_open(name);
|
f = Swig_open(name);
|
||||||
|
|
@ -157,7 +157,23 @@ Swig_include(DOH *name) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Swig_insert_file()
|
||||||
|
*
|
||||||
|
* Copies the contents of a file into another file
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int
|
||||||
|
Swig_insert_file(const DOH *filename, DOH *outfile) {
|
||||||
|
char buffer[4096];
|
||||||
|
int nbytes;
|
||||||
|
FILE *f = Swig_open(filename);
|
||||||
|
if (!f) return -1;
|
||||||
|
while ((nbytes = Read(f,buffer,4096)) > 0) {
|
||||||
|
Write(outfile,buffer,nbytes);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,13 @@ extern "C" {
|
||||||
|
|
||||||
/* --- File interface --- */
|
/* --- File interface --- */
|
||||||
|
|
||||||
extern void Swig_add_directory(DOH *dirname);
|
extern void Swig_add_directory(const DOH *dirname);
|
||||||
extern DOH *Swig_last_file();
|
extern DOH *Swig_last_file();
|
||||||
extern DOH *Swig_search_path();
|
extern DOH *Swig_search_path();
|
||||||
extern FILE *Swig_open(DOH *name);
|
extern FILE *Swig_open(const DOH *name);
|
||||||
extern DOH *Swig_read_file(FILE *f);
|
extern DOH *Swig_read_file(FILE *f);
|
||||||
extern DOH *Swig_include(DOH *name);
|
extern DOH *Swig_include(const DOH *name);
|
||||||
|
extern int Swig_insert_file(const DOH *name, DOH *outfile);
|
||||||
|
|
||||||
#define SWIG_FILE_DELIMETER "/"
|
#define SWIG_FILE_DELIMETER "/"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue