Added Java

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@64 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-01-12 17:33:21 +00:00
commit 99b646f6b3
28 changed files with 1664 additions and 1160 deletions

View file

@ -1,29 +1,5 @@
#######################################################################
# $Header$
# Simplified Wrapper and Interface Generator (SWIG)
#
# Makefile for version 1.0 Final
# Dave Beazley
# August 1, 1996
#
# This makefile is now mostly constructed by ./configure.
#
# $Log$
# Revision 1.2 2000/01/12 04:56:27 beazley
# Removed latex
#
# Revision 1.1 2000/01/11 20:08:16 beazley
# First checkin
#
# Revision 1.2 1999/11/14 02:42:56 beazley
# Initial 1.3 checkin
#
# Revision 1.1.1.1 1999/02/28 02:00:51 beazley
# Swig1.1
#
# Revision 1.1 1996/08/12 01:55:02 dmb
# Initial revision
#
#######################################################################
#.KEEP_STATE:
@ -63,13 +39,13 @@ AR = @AR@
# Normally, you shouldn't have to change anything below this point #
########################################################################
LIBOBJS = main.o scanner.o symbol.o include.o types.o parms.o emit.o newdoc.o ascii.o \
html.o cplus.o lang.o hash.o sstring.o wrapfunc.o getopt.o comment.o \
LIBOBJS = main.o scanner.o symbol.o types.o include.o parms.o emit.o newdoc.o \
cplus.o lang.o hash.o sstring.o wrapfunc.o comment.o \
typemap.o naming.o
LIBSRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx emit.cxx \
newdoc.cxx ascii.cxx html.cxx cplus.cxx lang.cxx hash.cxx \
sstring.cxx wrapfunc.cxx getopt.cxx comment.cxx typemap.cxx naming.cxx
newdoc.cxx cplus.cxx lang.cxx hash.cxx \
sstring.cxx wrapfunc.cxx comment.cxx typemap.cxx naming.cxx
PARSER = parser.y
INCLUDE = -I../Include -I. -I../Core -I../Preprocessor -I../DOH/Include

View file

@ -1,376 +0,0 @@
/*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
*
* Author : David Beazley
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
*
* Please read the file LICENSE for the copyright and terms by which SWIG
* can be used and distributed.
*******************************************************************************/
#include "swig.h"
#include "ascii.h"
#include <ctype.h>
/*******************************************************************************
* $Header$
*
* File : ascii.cxx
*
* Module for producing ASCII documentation.
*
*******************************************************************************/
static char cvstag[] = "$Header$";
// -----------------------------------------------------------------------------
// ASCII::ASCII()
// -----------------------------------------------------------------------------
ASCII::ASCII() {
sect_count = 0;
indent = 8;
columns = 70;
}
// -----------------------------------------------------------------------------
// void ASCII::print_string(char *s, int margin, int mode)
//
// Prints a string to the documentation file. Performs line wrapping and
// other formatting.
// -----------------------------------------------------------------------------
void ASCII::print_string(char *s, int margin, int mode) {
char *c;
int i;
int lbreak = 0;
int col;
c = s;
if (!s) return;
// Apply indentation
for (i = 0; i < margin; i++)
fputc(' ',f_doc);
col = margin;
if (mode) {
// Dump out text in formatted mode
// Strip leading white-space
while ((*c) && (isspace(*c))) {
c++;
}
while (*c) {
switch(*c) {
case '\n':
case '\\':
if (lbreak) {
col = margin;
fputc('\n',f_doc);
for (i = 0; i < margin; i++)
fputc(' ',f_doc);
lbreak = 0;
} else {
if ((*c) == '\n') {
col++;
}
lbreak++;
}
break;
case ' ':
case '\t':
case '\r':
case '\f':
if (col > columns) {
fputc('\n',f_doc);
for (i = 0; i < margin; i++)
fputc(' ',f_doc);
col = margin;
} else {
fputc(' ',f_doc);
col++;
}
// Skip over rest of white space found
while ((*c) && isspace(*c)) c++;
c--;
lbreak = 0;
break;
default :
if (lbreak) fputc(' ',f_doc);
lbreak = 0;
fputc(*c,f_doc);
col++;
break;
}
c++;
}
} else {
// Dump out text in pre-formatted mode
while (*c) {
switch(*c) {
case '\n':
fputc('\n',f_doc);
for (i = 0; i < margin; i++)
fputc(' ',f_doc);
break;
default :
fputc(*c,f_doc);
col++;
break;
}
c++;
}
}
}
// -----------------------------------------------------------------------------
// void ASCII::print_decl(DocEntry *de)
//
// Prints the documentation entry corresponding to a declaration
// -----------------------------------------------------------------------------
void ASCII::print_decl(DocEntry *de) {
int i;
char *c;
c = de->usage.get();
fprintf(f_doc,"%s\n",c);
// If there is any C annotation, print that
if (de->print_info) {
c = de->cinfo.get();
if (strlen(c) > 0) {
for (i = 0; i < indent; i++)
fputc(' ',f_doc);
fprintf(f_doc,"[ ");
print_string(c,0,1);
fprintf(f_doc," ]\n");
}
}
c = de->text.get();
if (strlen(c) > 0) {
print_string(c,indent,de->format);
fprintf(f_doc,"\n");
if (de->format) fputc('\n',f_doc);
} else {
fprintf(f_doc,"\n");
}
}
// -----------------------------------------------------------------------------
// void ASCII::print_text(DocEntry *de)
//
// Prints the documentation for a block of text. Will strip any leading white
// space from the text block.
// -----------------------------------------------------------------------------
void ASCII::print_text(DocEntry *de) {
char *c;
c = de->text.get();
if (strlen(c) > 0) {
while ((*c == '\n')) c++;
print_string(c,0,de->format);
fprintf(f_doc,"\n\n");
}
}
// -----------------------------------------------------------------------------
// void ASCII::title(DocEntry *de)
//
// Sets the title of the documentation file.
// -----------------------------------------------------------------------------
void ASCII::title(DocEntry *de) {
char *c;
c = de->usage.get();
if (strlen(c) > 0) {
fprintf(f_doc,"%s\n\n",c);
}
// If there is any C annotation, print that
if (de->print_info) {
c = de->cinfo.get();
if (strlen(c) > 0) {
fprintf(f_doc,"[ ");
print_string(c,0,1);
fprintf(f_doc," ]\n");
}
}
c = de->text.get();
if (strlen(c)) {
print_string(c,0,de->format);
}
fprintf(f_doc,"\n\n");
}
// -----------------------------------------------------------------------------
// void ASCII::newsection(DocEntry *de, int sectnum)
//
// Starts a new section. Will underline major sections and subsections, but
// not minor subsections.
// -----------------------------------------------------------------------------
void ASCII::newsection(DocEntry *de,int sectnum) {
int i,len = 0;
char temp[256];
char *c;
sect_num[sect_count] = sectnum;
sect_count++;
for (i = 0; i < sect_count; i++) {
sprintf(temp,"%d.",sect_num[i]);
fprintf(f_doc,"%s",temp);
len += strlen(temp);
}
c = de->usage.get();
fprintf(f_doc," %s\n", c);
len += strlen(c) + 2;
// Print an underline if this is a major category
if (sect_count <= 1) {
for (i = 0; i < len; i++)
fputc('=',f_doc);
fputc('\n',f_doc);
} else if (sect_count == 2) {
for (i = 0; i < len; i++)
fputc('-',f_doc);
fputc('\n',f_doc);
} else {
fputc('\n',f_doc);
}
// If there is any C annotation, print that
if (de->print_info) {
c = de->cinfo.get();
if (strlen(c) > 0) {
fprintf(f_doc,"[ ");
print_string(c,0,1);
fprintf(f_doc," ]\n\n");
}
}
// If there is a description text. Print it
c = de->text.get();
if (strlen(c) > 0) {
print_string(c,0,de->format);
fprintf(f_doc,"\n");
}
fprintf(f_doc,"\n");
}
// -----------------------------------------------------------------------------
// void ASCII::endsection()
//
// Ends the current section. It is an error to call this without having first
// called newsection().
// -----------------------------------------------------------------------------
void ASCII::endsection() {
if (sect_count > 0) sect_count--;
}
// -----------------------------------------------------------------------------
// void ASCII::separator()
//
// Prints a small dashed line that is used to designate the end of C++ class
// subsections.
// -----------------------------------------------------------------------------
void ASCII::separator() {
int i;
for (i = 0; i < 10; i++)
fputc('-',f_doc);
fprintf(f_doc,"\n\n");
}
// -----------------------------------------------------------------------------
// void ASCII::init(char *filename)
//
// Initializes the documentation module and opens up the documentation file.
// -----------------------------------------------------------------------------
void ASCII::init(char *filename) {
char f[256];
sprintf(f,"%s.txt",filename);
sprintf(fn,"%s",filename);
f_doc = fopen(f,"w");
if (f_doc == NULL) {
fprintf(stderr, "Unable to open %s\n", fn);
SWIG_exit(1);
}
}
// -----------------------------------------------------------------------------
// void ASCII::close()
//
// Closes the documentation module. This function should only be called once
// -----------------------------------------------------------------------------
void ASCII::close(void) {
fclose(f_doc);
if (Verbose)
fprintf(stderr,"Documentation written to %s.txt\n", fn);
}
// -----------------------------------------------------------------------------
// void ASCII::style(char *name, char *value)
//
// Looks for style parameters that the user might have supplied using the
// %style directive. Unrecognized options are simply ignored.
// -----------------------------------------------------------------------------
void ASCII::style(char *name, char *value) {
if (strcmp(name,"ascii_indent") == 0) {
if (value) {
indent = atoi(value);
}
} else if (strcmp(name,"ascii_columns") == 0) {
if (value) {
columns = atoi(value);
}
}
}
// -----------------------------------------------------------------------------
// void ASCII::parse_args(int argc, char **argv)
//
// Function for processing options supplied on the SWIG command line.
// -----------------------------------------------------------------------------
static char *ascii_usage = "\
ASCII Documentation Options (available with -dascii)\n\
None available.\n\n";
void ASCII::parse_args(int argc, char **argv) {
int i;
for (i = 0; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i],"-help") == 0) {
fputs(ascii_usage,stderr);
}
}
}
}

View file

@ -1,64 +0,0 @@
/*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
*
* Author : David Beazley
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
*
* Please read the file LICENSE for the copyright and terms by which SWIG
* can be used and distributed.
*******************************************************************************/
/***********************************************************************
* $Header$
*
* ascii.h
*
* ASCII specific functions for producing documentation. Basically
* prints things out as 80 column ASCII.
***********************************************************************/
class ASCII : public Documentation {
private:
FILE *f_doc;
char fn[256];
void print_string(char *s,int indent,int mode);
int indent; // Indentation (for formatting)
int columns; // Number of columns (for formatting)
int sect_count; // Section counter
int sect_num[20]; // Section numbers
// Style parameters
public:
ASCII();
void parse_args(int argc, char **argv);
void title(DocEntry *de);
void newsection(DocEntry *de, int sectnum);
void endsection();
void print_decl(DocEntry *de);
void print_text(DocEntry *de);
void separator();
void init(char *filename);
void close(void);
void style(char *name, char *value);
};

View file

@ -583,61 +583,61 @@ void CommentHandler::parse_args(int argc, char **argv) {
if (argv[i]) {
if (strcmp(argv[i],"-Sbefore") == 0) {
this->style("before",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Safter") == 0) {
this->style("after",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Schop_top") == 0) {
if (argv[i+1]) {
this->style("chop_top",argv[i+1]);
mark_arg(i);
mark_arg(i+1);
SWIG_mark_arg(i);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-Schop_bottom") == 0) {
if (argv[i+1]) {
this->style("chop_bottom",argv[i+1]);
mark_arg(i);
mark_arg(i+1);
SWIG_mark_arg(i);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-Schop_left") == 0) {
if (argv[i+1]) {
this->style("chop_left",argv[i+1]);
mark_arg(i);
mark_arg(i+1);
SWIG_mark_arg(i);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-Schop_right") == 0) {
if (argv[i+1]) {
this->style("chop_right",argv[i+1]);
mark_arg(i);
mark_arg(i+1);
SWIG_mark_arg(i);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-Sskip") == 0) {
if (argv[i+1]) {
this->style("skip",argv[i+1]);
mark_arg(i);
mark_arg(i+1);
SWIG_mark_arg(i);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-Suntabify") == 0) {
this->style("untabify",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Stabify") == 0) {
this->style("tabify",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Signore") == 0) {
this->style("ignore",0);
} else if (strcmp(argv[i],"-help") == 0) {

View file

@ -1,143 +0,0 @@
/*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
*
* Author : David Beazley
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
*
* Please read the file LICENSE for the copyright and terms by which SWIG
* can be used and distributed.
*******************************************************************************/
#include "internal.h"
static char cvsroot[] = "$Header$";
/*******************************************************************************
* $Header$
*
* File : getopt.cxx
*
* This file defines a few functions for handling command line arguments.
* C++ makes this really funky---especially since each language module
* may want to extract it's own command line arguments.
*
* My own special version of getopt. This is a bit weird, because we
* don't know what the options are in advance (they could be determined
* by a language module).
*******************************************************************************/
static char **args;
static int numargs;
static int *marked;
// -----------------------------------------------------------------------------
// void init_args(int argc, char **argv)
//
// Initializes the argument list.
//
// Inputs :
// argc = Argument count
// argv = Argument array
//
// Output : None
//
// Side Effects : Saves local copy of argc and argv
// -----------------------------------------------------------------------------
void
init_args(int argc, char **argv)
{
int i;
numargs = argc;
args = argv;
marked = new int[numargs];
for (i = 0; i < argc; i++) {
marked[i] = 0;
}
marked[0] = 1;
}
// -----------------------------------------------------------------------------
// void mark_arg(int n)
//
// Marks an argument as being parsed. All modules should do this whenever they
// parse a command line option.
//
// Inputs : n = Argument number
//
// Output : None
//
// Side Effects : Sets a status bit internally
// -----------------------------------------------------------------------------
void
mark_arg(int n) {
if (marked)
marked[n] = 1;
}
// -----------------------------------------------------------------------------
// void check_options()
//
// Checks for unparsed command line options. If so, issues an error and exits.
//
// Inputs : None
//
// Output : None
//
// Side Effects : exits if there are unparsed options
// -----------------------------------------------------------------------------
void check_options() {
int error = 0;
int i;
if (!marked) {
fprintf(stderr,"Must specify an input file. Use -help for available options.\n");
SWIG_exit(1);
}
for (i = 1; i < numargs-1; i++) {
if (!marked[i]) {
fprintf(stderr,"swig error : Unrecognized option %s\n", args[i]);
error=1;
}
}
if (error) {
fprintf(stderr,"Use 'swig -help' for available options.\n");
SWIG_exit(1);
}
if (marked[numargs-1]) {
fprintf(stderr,"Must specify an input file. Use -help for available options.\n");
SWIG_exit(1);
}
}
// -----------------------------------------------------------------------------
// void arg_error()
//
// Generates a generic error message and exits.
//
// Inputs : None
//
// Output : None
//
// Side Effects : Exits
// -----------------------------------------------------------------------------
void arg_error() {
fprintf(stderr,"SWIG : Unable to parse command line options.\n");
fprintf(stderr,"Use 'swig -help' for available options.\n");
SWIG_exit(1);
}

View file

@ -1,505 +0,0 @@
/*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
*
* Author : David Beazley
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
*
* Please read the file LICENSE for the copyright and terms by which SWIG
* can be used and distributed.
*******************************************************************************/
static char cvsroot[] = "$Header$";
#include "swig.h"
#include "html.h"
/*******************************************************************************
* $Header$
*
* File : html.cxx
*
* HTML specific functions for producing documentation.
*******************************************************************************/
#define PRE 0
#define FORMAT 1
// -----------------------------------------------------------------------------
// HTML::HTML()
// -----------------------------------------------------------------------------
HTML::HTML() {
sect_count = 0;
last_section = 0;
// Initialize default tags for various parts of the documentation
tag_body = "<BODY BGCOLOR=\"#ffffff\">:</BODY>";
tag_title = "<H1>:</H1>";
tag_contents = "<HR><H1>:</H1>";
tag_section = "<HR><H2>:</H2>";
tag_subsection = "<H3>:</H3>";
tag_subsubsection = "<H4>:</H4>";
tag_usage = "<P><TT><B>:</B></TT>";
tag_descrip = "<BLOCKQUOTE>:</BLOCKQUOTE>";
tag_text = "<P>";
tag_cinfo = "";
tag_preformat = "<PRE>:</PRE>";
}
// -----------------------------------------------------------------------------
// char *HTML::start_tag(char *tag)
//
// Utility function for returning the first part of an HTML tag variable.
// A tag must look like this :
//
// "<b>:</b>"
//
// The start tag for this would be "<b>"
// -----------------------------------------------------------------------------
char *HTML::start_tag(char *tag) {
static String stag;
char *c;
stag = "";
c = tag;
while ((*c) && (*c != ':')) {
stag << *c;
c++;
}
return stag.get();
}
// -----------------------------------------------------------------------------
// char *HTML::end_tag(char *tag)
//
// Utility for returning an end-tag. The counterpart to start_tag().
// -----------------------------------------------------------------------------
char *HTML::end_tag(char *tag) {
static String etag;
char *c;
etag = "";
c = tag;
while ((*c) && (*c != ':')) {
c++;
}
if (*c) {
c++;
while (*c) {
etag << *c;
c++;
}
}
return etag.get();
}
// -----------------------------------------------------------------------------
// void HTML::print_string(char *s, String &str, int mode)
//
// Outputs the contents of string s into String str. If mode is 1, we
// will reformat the text and apply a few common HTML character
// substitutions.
// -----------------------------------------------------------------------------
void HTML::print_string(char *s, String &str,int mode) {
char *c;
c = s;
while (*c) {
switch(*c) {
case '\"':
str << "&quot;";
break;
case '&':
str << "&amp;";
break;
case '<':
if (mode == PRE)
str << "&lt;";
else
str << (char) *c;
break;
case '>':
if (mode == PRE)
str << "&gt;";
else
str << (char) *c;
break;
default :
str << (char ) *c;
break;
}
c++;
}
}
// -----------------------------------------------------------------------------
// void HTML::print_decl(DocEntry *de)
//
// Generates documentation for a declaration.
// -----------------------------------------------------------------------------
void HTML::print_decl(DocEntry *de) {
char *c;
c = de->usage.get();
while ((*c) && ((*c == ' ') || (*c == '\t') || (*c == '\n'))) c++;
if (c) {
s_doc << start_tag(tag_usage);
print_string(c,s_doc,PRE);
s_doc << end_tag(tag_usage) << "\n";
} else return;
// Only print this if there is information
if ((strlen(de->cinfo.get()) && de->print_info) || strlen(de->text.get())) {
s_doc << start_tag(tag_descrip);
if (!de->format)
s_doc << start_tag(tag_preformat);
}
// If there is any C annotation, print that
if (de->print_info) {
c = de->cinfo.get();
if (strlen(c) > 0) {
s_doc << start_tag(tag_cinfo);
s_doc << "[ ";
print_string(c,s_doc,PRE);
s_doc << " ]" << end_tag(tag_cinfo) << "\n";
if (de->format) s_doc << "<BR>";
}
}
c = de->text.get();
if (strlen(c) > 0) {
print_string(c,s_doc,de->format);
}
if ((strlen(de->cinfo.get()) && de->print_info) || strlen(de->text.get())) {
if (!de->format) s_doc << end_tag(tag_preformat);
s_doc << end_tag(tag_descrip) << "\n";
}
s_doc << "\n";
}
// -----------------------------------------------------------------------------
// void HTML::print_text(DocEntry *de)
//
// Generates documentation for a text-block. Strips any leading whitespace.
// -----------------------------------------------------------------------------
void HTML::print_text(DocEntry *de) {
char *c;
c = de->text.get();
if (strlen(c) > 0) {
s_doc << start_tag(tag_text);
if (!de->format)
s_doc << start_tag(tag_preformat);
print_string(c,s_doc,de->format);
if (!de->format)
s_doc << end_tag(tag_preformat) << "\n";
s_doc << end_tag(tag_text) << "\n";
}
}
// -----------------------------------------------------------------------------
// void HTML::title(DocEntry *de)
//
// Generates the title for an HTML document.
// -----------------------------------------------------------------------------
void HTML::title(DocEntry *de) {
char *c;
c = de->usage.get();
if (strlen(c) > 0) {
s_title << "<HEAD>\n"
<< "<TITLE>\n";
print_string(c,s_title,PRE);
s_title << "</TITLE>\n"
<< start_tag(tag_body) << "\n";
s_title << start_tag(tag_title);
print_string(c,s_title,PRE);
s_title << end_tag(tag_title) << "\n";
}
if (!de->format)
s_title << start_tag(tag_preformat);
// If there is any C annotation, print that
if (de->print_info) {
c = de->cinfo.get();
if (strlen(c) > 0) {
s_title << start_tag(tag_cinfo) << "[ ";
print_string(c,s_title,de->format);
s_title << " ]" << end_tag(tag_cinfo);
if (de->format)
s_title << "<BR>\n";
else
s_title << "\n";
}
}
c = de->text.get();
if (strlen(c)) {
print_string(c,s_title,de->format);
}
if (!de->format)
s_title << end_tag(tag_preformat) << "\n";
}
// -----------------------------------------------------------------------------
// void HTML::newsection(DocEntry *de, int sectnum)
//
// Creates a new section. sect_count is used to determine the formatting of
// the header. Also fills in a table of contents
// -----------------------------------------------------------------------------
void HTML::newsection(DocEntry *de,int sectnum) {
int i,f;
char *c;
char *tag;
sect_num[sect_count] = sectnum;
sect_count++;
f = sect_count + 1;
if (f > 5) f = 5;
// Form table of contents
// if sect_count > last_section. We need to indent
// if sect_count < last_section. We need to pop out
if (sect_count > last_section) {
for (i = 0; i < sect_count - last_section; i++)
contents << "<UL>";
} else if (sect_count < last_section) {
for (i = 0; i < last_section - sect_count; i++)
contents << "</UL>";
}
last_section = sect_count;
contents << "<LI> <A HREF=\"#s";
s_doc << "<A name=\"s";
for (i = 0; i < sect_count; i++) {
s_doc << sect_num[i] << "_";
contents << sect_num[i] << "_";
}
contents << "\">";
// Figure out the tag fields
switch(f) {
case 1:
tag = tag_title;
break;
case 2:
tag = tag_section;
break;
case 3:
tag = tag_subsection;
break;
case 4:
tag = tag_subsubsection;
break;
default:
tag = tag_subsubsection;
}
s_doc << "\">\n"
<< start_tag(tag);
for (i = 0; i < sect_count; i++) {
s_doc << sect_num[i] << ".";
contents << sect_num[i] << ".";
}
c = de->usage.get();
s_doc << " ";
contents << " ";
print_string(c,s_doc,PRE);
print_string(c,contents,PRE);
s_doc << end_tag(tag) << "</A>\n";
contents << "</A>\n";
if (!de->format)
s_doc << start_tag(tag_preformat);
// If there is any C annotation, print that
if (de->print_info) {
c = de->cinfo.get();
if (strlen(c) > 0) {
s_doc << start_tag(tag_cinfo) << "[ ";
print_string(c,s_doc,de->format);
s_doc << " ]" << end_tag(tag_cinfo);
if (de->format)
s_doc << "<BR>\n";
else
s_doc << "\n";
}
}
// If there is a description text. Print it
c = de->text.get();
if (strlen(c) > 0) {
print_string(c,s_doc,de->format);
s_doc << "\n";
}
if (!de->format)
s_doc << end_tag(tag_preformat) << "\n";
}
// -----------------------------------------------------------------------------
// void HTML::endsection()
//
// Ends a subsection. It is an error to call this without first calling
// newsection previously.
// -----------------------------------------------------------------------------
void HTML::endsection() {
if (sect_count > 0) sect_count--;
}
// -----------------------------------------------------------------------------
// void HTML::separator()
//
// Prints a separator after the declaration of a C++ class. Currently
// does nothing in HTML mode.
// -----------------------------------------------------------------------------
void HTML::separator() {
}
// -----------------------------------------------------------------------------
// void HTML::init(char *filename)
//
// Initializes the HTML module and opens up the documentation file.
// -----------------------------------------------------------------------------
void HTML::init(char *filename) {
char f[256];
sprintf(f,"%s.html",filename);
f_doc = fopen(f,"w");
if (f_doc == NULL) {
fprintf(stderr,"Unable to open %s\n",f);
SWIG_exit(1);
}
/* Print a HTML banner */
fprintf(f_doc,"<HTML>\n");
}
// -----------------------------------------------------------------------------
// void HTML::close(void)
//
// Dumps the table of contents and forms the final documentation file. Closes
// the documentation file upon completion.
// -----------------------------------------------------------------------------
void HTML::close(void) {
int i;
for (i = 0; i < last_section; i++)
contents << "</UL>\n";
fprintf(f_doc,"%s\n",s_title.get());
if (last_section) {
fprintf(f_doc,"%s Contents %s\n",start_tag(tag_contents),end_tag(tag_contents));
fprintf(f_doc,"%s\n",contents.get());
}
fprintf(f_doc,"%s\n",s_doc.get());
fprintf(f_doc,"%s\n", end_tag(tag_body));
fprintf(f_doc,"</HTML>\n");
fclose(f_doc);
}
// -----------------------------------------------------------------------------
// void HTML::style(char *name, char *value)
//
// Process parameters given with the %style directive. Does nothing if an
// unrecognized parameter is given.
// -----------------------------------------------------------------------------
void HTML::style(char *name, char *value) {
if (strcmp(name,"html_title") == 0) {
if (value)
tag_title = copy_string(value);
} else if (strcmp(name,"html_contents") == 0) {
if (value)
tag_contents = copy_string(value);
} else if (strcmp(name,"html_section") == 0) {
if (value)
tag_section = copy_string(value);
} else if (strcmp(name,"html_subsection") == 0) {
if (value)
tag_subsection = copy_string(value);
} else if (strcmp(name,"html_subsubsection") == 0) {
if (value)
tag_subsubsection = copy_string(value);
} else if (strcmp(name,"html_usage") == 0) {
if (value)
tag_usage = copy_string(value);
} else if (strcmp(name,"html_descrip") == 0) {
if (value)
tag_descrip = copy_string(value);
} else if (strcmp(name,"html_text") == 0) {
if (value)
tag_text = copy_string(value);
} else if (strcmp(name,"html_cinfo") == 0) {
if (value)
tag_cinfo = copy_string(value);
} else if (strcmp(name,"html_preformat") == 0) {
if (value)
tag_preformat = copy_string(value);
} else if (strcmp(name,"html_body") == 0) {
if (value)
tag_body = copy_string(value);
}
}
// -----------------------------------------------------------------------------
// void HTML::parse_args(int argc, char **argv)
//
// Parse command line options given on the SWIG command line.
// -----------------------------------------------------------------------------
static char *html_usage = "\
HTML Documentation Options (available with -dhtml)\n\
None available.\n\n";
void HTML::parse_args(int argc, char **argv) {
int i;
for (i = 0; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i],"-help") == 0) {
fputs(html_usage,stderr);
}
}
}
}

View file

@ -1,76 +0,0 @@
/*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
*
* Author : David Beazley
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
*
* Please read the file LICENSE for the copyright and terms by which SWIG
* can be used and distributed.
*******************************************************************************/
/***********************************************************************
* $Header$
*
* html.h
*
* HTML specific functions for producing documentation.
***********************************************************************/
class HTML : public Documentation {
private:
FILE *f_doc;
void print_string(char *s, String &str, int mode);
char *start_tag(char *);
char *end_tag(char *);
int sect_count;
int sect_num[20];
int last_section;
String s_doc;
String s_title;
String contents;
char *tag_body;
char *tag_title;
char *tag_contents;
char *tag_section;
char *tag_subsection;
char *tag_subsubsection;
char *tag_usage;
char *tag_descrip;
char *tag_text;
char *tag_cinfo;
char *tag_preformat;
public:
HTML();
void parse_args(int argc, char **argv);
void title(DocEntry *de);
void newsection(DocEntry *de, int sectnum);
void endsection();
void print_decl(DocEntry *de);
void print_text(DocEntry *de);
void separator();
void init(char *filename);
void close(void);
void style(char *name, char *value);
};

View file

@ -20,6 +20,8 @@ static char cvsroot[] = "$Header$";
#include <stdio.h>
#include <ctype.h>
extern "C" FILE *SWIG_open(void *);
/*******************************************************************************
* $Header$
*
@ -28,87 +30,6 @@ static char cvsroot[] = "$Header$";
* Code for including files into a wrapper file.
*******************************************************************************/
/* Delimeter used in accessing files and directories */
#ifdef MACSWIG
#define DELIMETER ':'
#else
#define DELIMETER '/'
#endif
/* Linked list containing search directories */
struct Dnode {
char *dirname;
Dnode *next;
};
Dnode ihead, iz;
int include_init = 0;
/* Linked list containing included files */
struct Inode {
char *name;
Inode *next;
};
Inode *include_list = 0;
// -----------------------------------------------------------------------------
// void add_directory(char *dirname)
//
// Adds a directory to the SWIG search path.
// -----------------------------------------------------------------------------
void add_directory(char *dirname) {
Dnode *d;
if (!include_init) {
ihead.next = &iz;
iz.next = &iz;
iz.dirname = new char[2];
iz.dirname[0] = 0;
include_init = 1;
}
d = new Dnode;
d->dirname = new char[strlen(dirname)+1];
strcpy(d->dirname,dirname);
d->next = ihead.next;
ihead.next = d;
}
// -----------------------------------------------------------------------------
// int add_iname(char *name)
//
// Adds an include file to the list of processed files. If already present,
// returns 1.
// -----------------------------------------------------------------------------
int add_iname(char *name) {
Inode *newi, *i;
// if (WrapExtern) return 0; // Still thinking about this patch.
if (include_list) {
/* Search list */
i = include_list;
while (i) {
if (strcmp(i->name, name) == 0) return 1;
i = i->next;
}
}
newi = new Inode;
newi->name = new char[strlen(name)+1];
strcpy(newi->name, name);
newi->next = include_list;
include_list = newi;
return 0;
}
// -----------------------------------------------------------------------------
// void check_suffix(char *name)
//
@ -146,73 +67,6 @@ void check_suffix(char *name) {
ForceExtern = 0;
}
}
// -----------------------------------------------------------------------------
// int include_file(char *name)
//
// Includes a new SWIG wrapper file. Returns -1 if file not found.
// -----------------------------------------------------------------------------
int include_file(char *name) {
FILE *f;
char filename[256];
int found = 0;
Dnode *d;
extern void scanner_file(FILE *);
if (!include_init) return -1; // Not initialized yet
if (add_iname(name)) {
if (Verbose) fprintf(stderr,"file %s already included.\n", name);
return -1; // Already included this file
}
if (Verbose) {
fprintf(stderr,"Wrapping %s...\n", name);
fprintf(stderr,"Looking for ./%s\n", name);
}
if ((f = fopen(name,"r")) != NULL) {
input_file = new char[strlen(name)+1];
strcpy(input_file,name);
scanner_file(f);
check_suffix(name);
return 0;
}
// Now start searching libraries
d = ihead.next; // Start of search list
while (d != &iz) {
// Look for the wrap file in language directory
sprintf(filename,"%s%c%s%c%s", d->dirname,DELIMETER,LibDir,DELIMETER,name);
if (Verbose) fprintf(stderr,"Looking for %s\n", filename);
if((f = fopen(filename,"r")) != NULL) {
found = 1;
} else {
sprintf(filename,"%s%c%s", d->dirname, DELIMETER,name);
if (Verbose) fprintf(stderr,"Looking for %s\n", filename);
if ((f = fopen(filename,"r")) != NULL) {
found = 1;
}
}
if (found) {
// Found it, open it up for input
input_file = new char[strlen(filename)+1];
strcpy(input_file,filename);
scanner_file(f);
check_suffix(name);
return 0;
}
d = d->next;
}
if (!found) fprintf(stderr,"%s : Line %d. Unable to find include file %s (ignored).\n",input_file, line_number, name);
return -1;
}
static char buffer[1024];
// -----------------------------------------------------------------------------
// void copy_data(FILE *f1, FILE *f2)
@ -220,6 +74,8 @@ static char buffer[1024];
// Copies data from file f1 to file f2.
// -----------------------------------------------------------------------------
static char buffer[1024];
void copy_data(FILE *f1, FILE *f2) {
while (fgets(buffer,1023,f1)) {
@ -247,50 +103,13 @@ void copy_data(FILE *f1, String &s2) {
//
// Looks for a file and inserts into file f.
// -----------------------------------------------------------------------------
int insert_file(char *name, FILE *f_out) {
FILE *f;
char filename[256];
int found = 0;
Dnode *d;
if (!include_init) return -1; // Not initialized yet
if (add_iname(name)) {
if (Verbose) fprintf(stderr,"file %s already included.\n", name);
return -1; // Already included this file
}
if (Verbose) fprintf(stderr,"Looking for ./%s\n", name);
if ((f = fopen(name,"r")) != NULL) {
f = SWIG_open((void *) name);
if (f) {
copy_data(f,f_out);
return 0;
}
// Now start searching libraries
d = ihead.next; // Start of search list
while (d != &iz) {
// Look for the wrap file in language directory
sprintf(filename,"%s%c%s%c%s", d->dirname,DELIMETER,LibDir,DELIMETER,name);
if (Verbose) fprintf(stderr,"Looking for %s\n", filename);
if((f = fopen(filename,"r")) != NULL) {
found = 1;
} else {
sprintf(filename,"%s%c%s", d->dirname, DELIMETER, name);
if (Verbose) fprintf(stderr,"Looking for %s\n", filename);
if ((f = fopen(filename,"r")) != NULL) {
found = 1;
}
}
if (found) {
copy_data(f,f_out);
return 0;
}
d = d->next;
}
if ((!found) && (Verbose)) fprintf(stderr,"unable to find %s. (Ignored)\n",name);
return -1;
}
@ -301,192 +120,34 @@ int insert_file(char *name, FILE *f_out) {
// -----------------------------------------------------------------------------
void swig_append(char *filename, FILE *f) {
FILE *in_file;
if ((in_file = fopen(filename,"r")) == NULL) {
fprintf(stderr,"** SWIG ERROR ** file %s not found.\n",filename);
FatalError();
return;
}
while (fgets(buffer,1023,in_file)) {
fputs(buffer, f);
}
fclose(in_file);
copy_data(in_file, f);
}
// -----------------------------------------------------------------------------
// 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 filename[256];
int found = 0;
Dnode *d;
if (!include_init) return -1; // Not initialized yet
if (Verbose) fprintf(stderr,"Looking for %s\n", name);
if ((f = fopen(name,"r")) != NULL) {
copy_data(f,str);
return 0;
}
// Now start searching libraries
d = ihead.next; // Start of search list
while (d != &iz) {
// Look for the wrap file in language directory
sprintf(filename,"%s%c%s%c%s", d->dirname,DELIMETER,LibDir,DELIMETER,name);
if (Verbose) fprintf(stderr,"Looking for %s\n", filename);
if((f = fopen(filename,"r")) != NULL) {
found = 1;
} else {
sprintf(filename,"%s%c%s", d->dirname, DELIMETER, name);
if (Verbose) fprintf(stderr,"Looking for %s\n", filename);
if ((f = fopen(filename,"r")) != NULL) {
found = 1;
}
}
if (found) {
copy_data(f,str);
return 0;
}
d = d->next;
}
if ((!found)) fprintf(stderr,"SWIG Error. Unable to find %s. Possible installation problem.\n",name);
FatalError();
return -1;
}
static char *libs[1000];
static int nlibs = 0;
// -----------------------------------------------------------------------------
// void library_add(char *name)
//
// Adds a filename to the list of libraries. This is usually only called by
// the SWIG main program.
// -----------------------------------------------------------------------------
void library_add(char *name) {
int i;
// Check to make sure it's not already added
if (!(*name)) return;
for (i = 0; i < nlibs; i++) {
if (strcmp(libs[i],name) == 0) return;
}
libs[nlibs] = copy_string(name);
nlibs++;
}
// -----------------------------------------------------------------------------
// void library_insert()
//
// Starts parsing all of the SWIG library files.
// -----------------------------------------------------------------------------
void library_insert() {
int i;
i = nlibs-1;
while (i >= 0) {
include_file(libs[i]);
i--;
}
}
// -----------------------------------------------------------------------------
// int checkout(char *filename,char *dest)
//
// Tries to check a file out of the SWIG library. If found, it will save it in
// the current directory. This is a useful mechanism for using SWIG as a code
// manager and for extracting library files.
// -----------------------------------------------------------------------------
int checkout_file(char *filename,char *dest) {
FILE *f1;
char tempn[256];
// First check to see if the file already exists in current directory
f1 = fopen(dest,"r");
if (f1) {
if (Verbose)
fprintf(stderr,"Warning. Unable to check-out %s. File already exists.\n", filename);
fclose(f1);
return -1;
}
while (!f1) {
sprintf(tempn,"%s%d",dest,rand());
f1 = fopen(tempn,"r");
if (f1) {
fclose(f1);
f1 = 0;
} else {
f1 = fopen(tempn,"w");
if (!f1) {
fprintf(stderr,"Unable to open %s for writing\n", tempn);
return -1;
}
}
}
// Now try to insert the library file into the destination file
if ((insert_file(filename,f1)) == -1) {
fprintf(stderr,"Unable to check-out '%s'. File does not exist in SWIG library.\n",filename);
fclose(f1);
remove(tempn); // Unsuccessful, remove file we created
f = SWIG_open((void *) name);
if (!f) {
fprintf(stderr,"SWIG Error. Unable to find %s. Possible installation problem.\n",name);
FatalError();
return -1;
}
fclose(f1);
// Now move the file
rename(tempn,dest);
copy_data(f,str);
return 0;
}
// -----------------------------------------------------------------------------
// int checkin_file(char *dir, char *lang, char *source,char *dest)
//
// Attempts to check a file into the SWIG library.
// Output : 0 on success
// -1 on failure.
// -----------------------------------------------------------------------------
int checkin_file(char *dir, char *lang, char *source, char *dest) {
FILE *f1;
char tempn[256];
String s;
// First check to see if the file exists
f1 = fopen(source,"r");
if (!f1) return -1;
copy_data(f1,s);
// Now try to open the destination file
sprintf(tempn,"%s/%s/%s", dir,lang,dest);
f1 = fopen(tempn,"w");
if (!f1) return -1;
fprintf(f1,"%s",s.get());
fclose(f1);
return 0;
}

View file

@ -51,16 +51,15 @@ void Language::create_command(char *, char *) {
}
// -----------------------------------------------------------------
// void Language::add_native(char *targetlang, char *funcname)
// void Language::add_native(char *name, char *iname, DataType *t, ParmList *l)
//
// Method for adding a native function
// -----------------------------------------------------------------
// Method for adding a native function with full argument info
// default is to call the old-style add_native method
// -----------------------------------------------------------------
void
Language::add_native(char *, char *funcname) {
fprintf(stderr,"%s : Line %d. Adding native function %s not supported (ignored).\n", input_file, line_number, funcname);
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);
}
static char *ClassName = 0; // This is the real name of the current class

View file

@ -26,9 +26,6 @@ static char cvsroot[] = "$Header$";
#define WRAP
#include "internal.h"
#include "ascii.h"
#include "html.h"
#include "nodoc.h"
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
@ -39,14 +36,9 @@ static char cvsroot[] = "$Header$";
class SwigException {};
static char *usage = "\
\nDocumentation Options\n\
-dascii - ASCII documentation.\n\
-dhtml - HTML documentation.\n\
-dnone - No documentation.\n\n\
General Options\n\
\nGeneral Options\n\
-c - Produce raw wrapper code (omit support code)\n\
-c++ - Enable C++ processing\n\
-ci - Check a file into the SWIG library\n\
-co - Check a file out of the SWIG library\n\
-d docfile - Set name of the documentation file.\n\
-Dsymbol - Define a symbol (for conditional compilation)\n\
@ -56,10 +48,8 @@ General Options\n\
-nocomment - Ignore all comments (for documentation).\n\
-o outfile - Set name of the output file.\n\
-objc - Enable Objective C processing\n\
-stat - Print statistics\n\
-strict n - Set pointer type-checking strictness\n\
-swiglib - Report location of SWIG library and exit\n\
-t typemap_file - Use a typemap file.\n\
-v - Run in verbose mode\n\
-version - Print SWIG version number\n\
-help - This output.\n\n";
@ -90,7 +80,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
int i;
char *c;
extern FILE *LEX_in;
extern void add_directory(char *);
extern char *get_time();
char temp[512];
char infile[512];
@ -100,13 +89,13 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
int help = 0;
int ignorecomments = 0;
int checkout = 0;
int checkin = 0;
int cpp_only = 0;
char *typemap_file = 0;
char *includefiles[256];
int includecount = 0;
extern void check_suffix(char *);
extern void scanner_file(FILE *);
DOH *libfiles = 0;
#ifdef MACSWIG
try {
@ -153,10 +142,7 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
add_directory(":swig_lib");
#else
sprintf(temp,"%s/config", LibDir);
add_directory(temp);
add_directory("./swig_lib/config");
add_directory(LibDir);
add_directory("./swig_lib");
SWIG_add_directory((DOH *) temp);
SWIG_add_directory((DOH *) "./swig_lib/config");
SWIG_add_directory((DOH *) LibDir);
@ -166,6 +152,8 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
sprintf(InitName,"init_wrap");
libfiles = NewList();
// Initialize the preprocessor
SWIG_cpp_init();
@ -175,85 +163,64 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
if (strncmp(argv[i],"-I",2) == 0) {
// Add a new directory search path
includefiles[includecount++] = copy_string(argv[i]+2);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strncmp(argv[i],"-D",2) == 0) {
DOH *d = NewString(argv[i]+2);
String_replace(d,"="," ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
SWIG_cpp_define(d,0);
// Create a symbol
add_symbol(argv[i]+2, (DataType *) 0, (char *) 0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-strict") == 0) {
if (argv[i+1]) {
TypeStrict = atoi(argv[i+1]);
mark_arg(i);
mark_arg(i+1);
SWIG_mark_arg(i);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-E") == 0) {
cpp_only = 1;
mark_arg(i);
SWIG_mark_arg(i);
} else if ((strcmp(argv[i],"-verbose") == 0) || (strcmp(argv[i],"-v") == 0)) {
Verbose = 1;
mark_arg(i);
} else if (strcmp(argv[i],"-dascii") == 0) {
doc = new ASCII;
mark_arg(i);
} else if (strcmp(argv[i],"-dnone") == 0) {
doc = new NODOC;
mark_arg(i);
} else if (strcmp(argv[i],"-dhtml") == 0) {
doc = new HTML;
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-nocomment") == 0) {
ignorecomments = 1;
mark_arg(i);
} else if (strcmp(argv[i],"-stat") == 0) {
Stats=1;
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-c++") == 0) {
CPlusPlus=1;
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-objc") == 0) {
ObjC = 1;
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-c") == 0) {
NoInclude=1;
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-make_default") == 0) {
GenerateDefault = 1;
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-swiglib") == 0) {
printf("%s\n", LibDir);
SWIG_exit(0);
} else if (strcmp(argv[i],"-o") == 0) {
mark_arg(i);
SWIG_mark_arg(i);
if (argv[i+1]) {
outfile_name = copy_string(argv[i+1]);
mark_arg(i+1);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-d") == 0) {
mark_arg(i);
SWIG_mark_arg(i);
if (argv[i+1]) {
doc_file = copy_string(argv[i+1]);
mark_arg(i+1);
SWIG_mark_arg(i+1);
i++;
} else {
arg_error();
}
} else if (strcmp(argv[i],"-t") == 0) {
mark_arg(i);
if (argv[i+1]) {
typemap_file = copy_string(argv[i+1]);
mark_arg(i+1);
i++;
} else {
arg_error();
SWIG_arg_error();
}
} else if (strcmp(argv[i],"-version") == 0) {
fprintf(stderr,"\nSWIG Version %d.%d %s\n", SWIG_MAJOR_VERSION,
@ -264,17 +231,14 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
SWIG_exit(0);
} else if (strncmp(argv[i],"-l",2) == 0) {
// Add a new directory search path
library_add(argv[i]+2);
mark_arg(i);
Append(libfiles,argv[i]+2);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-co") == 0) {
checkout = 1;
mark_arg(i);
} else if (strcmp(argv[i],"-ci") == 0) {
checkin = 1;
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stderr);
mark_arg(i);
SWIG_mark_arg(i);
help = 1;
}
}
@ -282,13 +246,8 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
while (includecount > 0) {
SWIG_add_directory((DOH *) includefiles[includecount]);
add_directory(includefiles[--includecount]);
}
// Create a new documentation handler
if (doc == 0) doc = new ASCII;
// Open up a comment handler
comment_handler = new CommentHandler();
@ -313,7 +272,9 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
// Check all of the options to make sure we're cool.
check_options();
SWIG_check_options();
SWIG_set_library(LibDir);
// If we made it this far, looks good. go for it....
@ -326,34 +287,30 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
// If the user has requested to check out a file, handle that
if (checkout) {
int stat;
DOH *s;
char *outfile = input_file;
if (outfile_name)
outfile = outfile_name;
stat = checkout_file(input_file,outfile);
if (!stat) {
fprintf(stderr,"%s checked out from the SWIG library\n",input_file);
s = SWIG_include(input_file);
if (!s) {
fprintf(stderr,"Unable to locate '%s' in the SWIG library.\n", input_file);
} else {
FILE * f = fopen(input_file,"r");
FILE *f = fopen(outfile,"r");
if (f) {
fprintf(stderr,"Unable to check-out %s. File already exists.\n", input_file);
fclose(f);
fprintf(stderr,"File '%s' already exists. Checkout aborted.\n", outfile);
} else {
fprintf(stderr,"Unable to check-out %s\n", input_file);
f = fopen(outfile,"w");
if (!f) {
fprintf(stderr,"Unable to create file '%s'\n", outfile);
} else {
fprintf(stderr,"'%s' checked out from the SWIG library.\n", input_file);
fputs(Char(s),f);
fclose(f);
}
}
}
} else if (checkin) {
// Try to check-in a file to the SWIG library
int stat;
char *outname = input_file;
if (outfile_name)
outname = outfile_name;
stat = checkin_file(SwigLib, LibDir, input_file, outname);
if (!stat) {
fprintf(stderr,"%s checked-in to %s/%s/%s\n", input_file, SwigLib, LibDir, outname);
} else {
fprintf(stderr,"Unable to check-in %s to %s/%s\n", input_file, SwigLib, LibDir);
}
} else {
doctitle->file = copy_string(input_file);
doctitle->line_number = -1000;
@ -434,7 +391,12 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
{
DOH *cpps;
FILE *f;
int i;
DOH *ds = SWIG_include(input_file);
Seek(ds,0,SEEK_END);
for (i = 0; i < Len(libfiles); i++) {
Printf(ds,"\n%%include \"%s\"\n", Getitem(libfiles,i));
}
Seek(ds,0,SEEK_SET);
cpps = SWIG_cpp_parse(ds);
if (cpp_only) {
@ -451,9 +413,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
SWIG_exit(0);
}
// Add to the include list
add_iname(infilename);
// Initialize the scanner
LEX_in = f_input;
scanner_file(LEX_in);
@ -506,16 +465,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
if (CPlusPlus)
add_symbol("__cplusplus",0,0);
// Load up the typemap file if given
if (typemap_file) {
if (include_file(typemap_file) == -1) {
fprintf(stderr,"Unable to locate typemap file %s. Aborting.\n", typemap_file);
SWIG_exit(1);
}
}
// If in Objective-C mode. Load in a configuration file
if (ObjC) {
@ -569,13 +518,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
if (Verbose)
type_undefined_check();
if (Stats) {
fprintf(stderr,"Wrapped %d functions\n", Stat_func);
fprintf(stderr,"Wrapped %d variables\n", Stat_var);
fprintf(stderr,"Wrapped %d constants\n", Stat_const);
type_undefined_check();
}
if (checkout) {
// File was checked out from the SWIG library. Remove it now
remove(input_file);

View file

@ -269,22 +269,22 @@ void DocEntry::parse_args(int argc, char **argv) {
if (argv[i]) {
if (strcmp(argv[i],"-Ssort") == 0) {
this->style("sort",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Snosort") == 0) {
this->style("nosort",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Sinfo") == 0) {
this->style("info",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Snoinfo") == 0) {
this->style("noinfo",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Spre") == 0) {
this->style("pre",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-Sformat") == 0) {
this->style("format",0);
mark_arg(i);
SWIG_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(doc_usage,stderr);
}

View file

@ -1,54 +0,0 @@
/*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
*
* Author : David Beazley
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
*
* Please read the file LICENSE for the copyright and terms by which SWIG
* can be used and distributed.
*******************************************************************************/
/***********************************************************************
* $Header$
*
* nodoc.h
*
* A null documentation header. Does nothing.
***********************************************************************/
class NODOC : public Documentation {
private:
public:
NODOC() { };
void parse_args(int, char **) { };
void title(DocEntry *) { };
void newsection(DocEntry *, int) { };
void endsection() { };
void print_decl(DocEntry *) { };
void print_text(DocEntry *) { };
void separator() { };
void init(char *) { };
void close(void) { };
void style(char *, char *) { };
};

View file

@ -159,9 +159,6 @@ static void init_language() {
int oldignore = IgnoreDoc;
IgnoreDoc = 1;
if (ConfigFile) {
include_file(ConfigFile);
}
IgnoreDoc = oldignore;
}
lang_init = 1;
@ -482,12 +479,11 @@ static void dump_nested(char *parent) {
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE DEFINE PERIOD
%token CONST STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
%token ILLEGAL CONSTANT
%token READONLY READWRITE NAME RENAME CHECKOUT ADDMETHODS PRAGMA
%token READONLY READWRITE NAME RENAME ADDMETHODS PRAGMA
%token CVALUE COUT
%token ENUM ENDDEF MACRO
%token CLASS PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND OPERATOR THROW TEMPLATE
%token NATIVE INLINE
%token IFDEF IFNDEF ENDIF ELSE UNDEF IF DEFINED ELIF
%token RAW_MODE ALPHA_MODE TEXT DOC_DISABLE DOC_ENABLE STYLE LOCALSTYLE
%token TYPEMAP EXCEPT ECHO NEW APPLY CLEAR DOCONLY
%token <ivalue> TITLE SECTION SUBSECTION SUBSUBSECTION
@ -511,7 +507,7 @@ static void dump_nested(char *parent) {
%type <pl> parms ptail;
%type <p> parm parm_type;
%type <tmparm> typemap_parm tm_list tm_tail;
%type <id> pname cpptype base_specifier access_specifier typemap_name tm_method idstring;
%type <id> pname cpptype base_specifier access_specifier typemap_name tm_method;
%type <type> type opt_signed opt_unsigned strict_type;
%type <decl> declaration nested_decl;
%type <ivalue> stars;
@ -608,15 +604,6 @@ statement : INCLUDE STRING LBRACE {
line_number = $1.line;
}
/* %checkout directive. Like %include, but simply copies the file into the
current directory */
| CHECKOUT idstring {
if ((checkout_file($2,$2)) == 0) {
fprintf(stderr,"%s checked out from the SWIG library.\n",$2);
}
}
/* An unknown C preprocessor statement. Just throw it away */
| POUND {
@ -823,7 +810,7 @@ statement : INCLUDE STRING LBRACE {
input_file, line_number, $3);
} else {
doc_entry = new DocDecl($3,doc_stack[doc_stack_top]);
lang->add_native($3,$6);
lang->add_native($3,$6,0,0);
}
}
}
@ -839,7 +826,7 @@ statement : INCLUDE STRING LBRACE {
emit_extern_func($7.id, $6, $9, $5, f_header);
}
doc_entry = new DocDecl($3,doc_stack[doc_stack_top]);
lang->add_native($3,$7.id);
lang->add_native($3,$7.id,$6,$9);
}
}
delete $6;
@ -3818,11 +3805,6 @@ typemap_args : LPAREN parms RPAREN {
}
;
idstring : ID {$$ = $1;}
| STRING { $$ = $1;}
;
/* User defined directive */
user_directive : USERDIRECTIVE LPAREN parms RPAREN uservalue { }

View file

@ -132,7 +132,6 @@ void scanner_file(FILE *f) {
void scanner_close() {
InFile *p;
static int lib_insert = 0;
fclose(LEX_in);
if (!in_head) return;
p = in_head->prev;
@ -148,15 +147,6 @@ void scanner_close() {
}
delete in_head;
in_head = p;
// if LEX_in is NULL it means we're done with the interface file. We're now
// going to grab all of the library files.
if ((!LEX_in) && (!lib_insert)) {
library_insert();
lib_insert = 1;
}
}
/**************************************************************
@ -810,61 +800,14 @@ int yylook(void) {
break;
case 3: /* a CPP directive */
if (( c= nextchar()) == 0) return 0;
if (c == '\n') {
retract(1);
yytext[yylen] = 0;
yylval.id = yytext;
return(POUND);
} else if ((c == ' ') || (c == '\t')) { // Ignore white space after # symbol
yytext[yylen] = 0;
yylen--;
state = 3;
} else {
yytext[yylen] = 0;
state = 31;
}
break;
case 31:
if ((c = nextchar()) == 0) return 0;
if ((c == ' ') || (c == '\t') || (c=='\n')) {
retract(1);
yytext[yylen] = 0;
if (strcmp(yytext,"#define") == 0) {
in_define = 1;
define_first_id = 1;
return(DEFINE);
} else if (strcmp(yytext,"#ifdef") == 0) {
return(IFDEF);
} else if (strcmp(yytext,"#ifndef") == 0) {
return(IFNDEF);
} else if (strcmp(yytext,"#else") == 0) {
return(ELSE);
} else if (strcmp(yytext,"#endif") == 0) {
return(ENDIF);
} else if (strcmp(yytext,"#undef") == 0) {
return(UNDEF);
} else if (strcmp(yytext,"#if") == 0) {
return(IF);
} else if (strcmp(yytext,"#elif") == 0) {
return(ELIF);
} else {
/* Some kind of "unknown CPP directive. Skip to end of the line */
state = 32;
}
}
break;
case 32:
if ((c = nextchar()) == 0) return 0;
if (c == '\n') {
retract(1);
yytext[yylen] = 0;
yylval.id = yytext;
return(POUND);
}
state = 32;
break;
case 4: /* A wrapper generator directive (maybe) */
if (( c= nextchar()) == 0) return 0;
@ -1281,7 +1224,6 @@ extern "C" int yylex(void) {
if (strcmp(yytext,"union") == 0) return(UNION);
if (strcmp(yytext,"enum") == 0) return(ENUM);
if (strcmp(yytext,"sizeof") == 0) return(SIZEOF);
if (strcmp(yytext,"defined") == 0) return(DEFINED);
// Ignored keywords
@ -1296,9 +1238,8 @@ extern "C" int yylex(void) {
if (strcmp(yytext,"%readwrite") == 0) return(READWRITE);
if (strcmp(yytext,"%name") == 0) return(NAME);
if (strcmp(yytext,"%rename") == 0) return(RENAME);
if (strcmp(yytext,"%include") == 0) return(INCLUDE);
if (strcmp(yytext,"%extern") == 0) return(WEXTERN);
if (strcmp(yytext,"%checkout") == 0) return(CHECKOUT);
if (strcmp(yytext,"%includefile") == 0) return(INCLUDE);
if (strcmp(yytext,"%externfile") == 0) return(WEXTERN);
if (strcmp(yytext,"%val") == 0) return(CVALUE);
if (strcmp(yytext,"%out") == 0) return(COUT);
if (strcmp(yytext,"%constant") == 0) return(CONSTANT);
@ -1336,18 +1277,12 @@ extern "C" int yylex(void) {
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,"%ifdef") == 0) return(IFDEF);
if (strcmp(yytext,"%else") == 0) return(ELSE);
if (strcmp(yytext,"%ifndef") == 0) return(IFNDEF);
if (strcmp(yytext,"%endif") == 0) return(ENDIF);
if (strcmp(yytext,"%if") == 0) return(IF);
if (strcmp(yytext,"%elif") == 0) return(ELIF);
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,"%import") == 0) return(IMPORT);
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);

View file

@ -395,7 +395,7 @@ public:
virtual void close(void) = 0;
virtual void set_module(char *mod_name,char **mod_list) = 0;
virtual void set_init(char *init_name);
virtual void add_native(char *, char *);
virtual void add_native(char *name, char *iname, DataType *t, ParmList *l);
virtual char *type_mangle(DataType *t) {
return t->print_mangle_default();
}
@ -557,22 +557,19 @@ extern void cplus_support_doc(String &f);
/* Function for building search directories */
extern void add_directory(char *dirname);
extern int insert_file(char *, FILE *);
extern int get_file(char *filename, String &str);
extern int checkout_file(char *filename, char *dest);
extern int checkin_file(char *dir, char *lang, char *source, char *dest);
extern int include_file(char *filename);
extern void swig_append(char *filename, FILE *);
/* Miscellaneous */
/* These are in the new core */
extern void check_options();
extern void init_args(int argc, char **);
extern void mark_arg(int n);
extern void arg_error();
extern void library_add(char *name);
extern void library_insert();
extern "C" {
/* Option processing */
extern void SWIG_init_args(int argc, char **);
extern void SWIG_mark_arg(int n);
extern void SWIG_check_options();
extern void SWIG_arg_error();
}
// -----------------------------------------------------------------------
// Class for Creating Wrapper Functions