Removed the documentation system. A lot of cleanup.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@208 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
890e6f131c
commit
34ed03f10b
36 changed files with 683 additions and 4810 deletions
|
|
@ -13,8 +13,8 @@ AR = @AR@
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
|
|
||||||
TARGET = libmodules11.a
|
TARGET = libmodules11.a
|
||||||
OBJS = swigmain.o tcl8.o perl5.o python.o pycpp.o guile.o java.o ascii.o html.o
|
OBJS = swigmain.o tcl8.o perl5.o python.o pycpp.o guile.o java.o
|
||||||
SRCS = swigmain.cxx tcl8.cxx perl5.cxx python.cxx pycpp.cxx guile.cxx java.cxx ascii.cxx html.cxx
|
SRCS = swigmain.cxx tcl8.cxx perl5.cxx python.cxx pycpp.cxx guile.cxx java.cxx
|
||||||
INCLUDE = -I../Include -I../SWIG1.1
|
INCLUDE = -I../Include -I../SWIG1.1
|
||||||
|
|
||||||
# Rules for creation of a .o file from .cxx
|
# Rules for creation of a .o file from .cxx
|
||||||
|
|
|
||||||
|
|
@ -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 "swig11.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -164,20 +164,12 @@ void GUILE::initialize()
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!module) {
|
if (!module) {
|
||||||
module = "swig_init";
|
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||||
fprintf(stderr,"SWIG : *** Warning. No module name specified.\n");
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f_header,"#define SWIG_init %s\n\n", module);
|
fprintf(f_header,"#define SWIG_init %s\n\n", module);
|
||||||
fprintf(f_init,"void %s() {\n", module);
|
fprintf(f_init,"void %s() {\n", module);
|
||||||
|
|
||||||
if (InitNames) {
|
|
||||||
i = 0;
|
|
||||||
while (InitNames[i]) {
|
|
||||||
fprintf(f_init,"\t %s();\n",InitNames[i]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
@ -211,27 +203,9 @@ void GUILE::get_pointer(char *iname, int parm, DataType *t) {
|
||||||
else
|
else
|
||||||
fprintf(f_wrappers,"\"%s\")) {\n", t->print_mangle());
|
fprintf(f_wrappers,"\"%s\")) {\n", t->print_mangle());
|
||||||
|
|
||||||
// Now emit code according to the level of strictness desired
|
|
||||||
|
|
||||||
switch(TypeStrict) {
|
|
||||||
case 0: // No type checking
|
|
||||||
fprintf(f_wrappers,"\t}\n");
|
|
||||||
break;
|
|
||||||
case 1: // Warning message only
|
|
||||||
fprintf(f_wrappers,
|
|
||||||
"\t fprintf(stderr,\"Warning : type mismatch in argument %d of %s. Expected %s, received %%s\\n\", _tempc);\n", parm+1,iname, t->print_mangle());
|
|
||||||
fprintf(f_wrappers,"\t }\n");
|
|
||||||
break;
|
|
||||||
case 2: // Super strict mode.
|
|
||||||
|
|
||||||
// fprintf(f_wrappers,"\t\t gscm_error(\"Type error in argument %d of %s. Expected %s.\", s_%d);\n", parm+1,iname,t->print_mangle(),parm);
|
// fprintf(f_wrappers,"\t\t gscm_error(\"Type error in argument %d of %s. Expected %s.\", s_%d);\n", parm+1,iname,t->print_mangle(),parm);
|
||||||
fprintf(f_wrappers,"\t}\n");
|
fprintf(f_wrappers,"\t}\n");
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
fprintf(stderr,"Unknown strictness level\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
@ -480,20 +454,6 @@ void GUILE::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// Now register the function
|
// Now register the function
|
||||||
fprintf(f_init,"\t gh_new_procedure(\"%s\", _wrap_gscm_%s, %d, %d, 0);\n",
|
fprintf(f_init,"\t gh_new_procedure(\"%s\", _wrap_gscm_%s, %d, %d, 0);\n",
|
||||||
iname, wname, reqargs, pcount-reqargs);
|
iname, wname, reqargs, pcount-reqargs);
|
||||||
|
|
||||||
// Make a documentation entry for this
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
static DocEntry *last_doc_entry = 0;
|
|
||||||
char *usage = 0;
|
|
||||||
usage_func(iname,d,l,&usage);
|
|
||||||
doc_entry->usage << usage;
|
|
||||||
if (last_doc_entry != doc_entry) {
|
|
||||||
doc_entry->cinfo << "returns " << d->print_type();
|
|
||||||
last_doc_entry = doc_entry;
|
|
||||||
}
|
|
||||||
delete usage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
@ -604,25 +564,9 @@ void GUILE::link_variable(char *name, char *iname, DataType *t)
|
||||||
|
|
||||||
// Now emit code according to the level of strictness desired
|
// Now emit code according to the level of strictness desired
|
||||||
|
|
||||||
switch(TypeStrict) {
|
|
||||||
case 0: // No type checking
|
|
||||||
fprintf(f_wrappers,"\t}\n");
|
|
||||||
break;
|
|
||||||
case 1: // Warning message only
|
|
||||||
fprintf(f_wrappers,
|
|
||||||
"\t fprintf(stderr,\"Warning : type mismatch in variable %s. Expected %s, received %%s\\n\", _temp);\n", name, t->print_mangle());
|
|
||||||
fprintf(f_wrappers,"\t }\n");
|
|
||||||
break;
|
|
||||||
case 2: // Super strict mode.
|
|
||||||
|
|
||||||
// fprintf(f_wrappers,"\t\t gscm_error(\"Type error in variable %s. Expected %s.\", s_0);\n", name,t->print_mangle());
|
// fprintf(f_wrappers,"\t\t gscm_error(\"Type error in variable %s. Expected %s.\", s_0);\n", name,t->print_mangle());
|
||||||
fprintf(f_wrappers,"\t}\n");
|
fprintf(f_wrappers,"\t}\n");
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
fprintf(stderr,"Unknown strictness level\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -696,17 +640,6 @@ void GUILE::link_variable(char *name, char *iname, DataType *t)
|
||||||
fprintf(stderr,"%s : Line %d. ** Warning. Unable to link with type %s (ignored).\n",
|
fprintf(stderr,"%s : Line %d. ** Warning. Unable to link with type %s (ignored).\n",
|
||||||
input_file, line_number, t->print_type());
|
input_file, line_number, t->print_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
char *usage = 0;
|
|
||||||
usage_var(iname,t,&usage);
|
|
||||||
doc_entry->usage << usage;
|
|
||||||
doc_entry->cinfo << "Global : " << t->print_type() << " " << name;
|
|
||||||
delete usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
@ -745,17 +678,6 @@ void GUILE::declare_const(char *name, char *, DataType *type, char *value) {
|
||||||
|
|
||||||
link_variable(var_name, name, type);
|
link_variable(var_name, name, type);
|
||||||
Status = OldStatus;
|
Status = OldStatus;
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
char *usage = 0;
|
|
||||||
usage_const(name,type,value,&usage);
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << usage;
|
|
||||||
doc_entry->cinfo = "";
|
|
||||||
doc_entry->cinfo << "Constant: " << type->print_type();
|
|
||||||
delete usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -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 "swig11.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 << """;
|
|
||||||
break;
|
|
||||||
case '&':
|
|
||||||
str << "&";
|
|
||||||
break;
|
|
||||||
case '<':
|
|
||||||
if (mode == PRE)
|
|
||||||
str << "<";
|
|
||||||
else
|
|
||||||
str << (char) *c;
|
|
||||||
break;
|
|
||||||
case '>':
|
|
||||||
if (mode == PRE)
|
|
||||||
str << ">";
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -420,7 +420,7 @@ void JAVA::headers(void)
|
||||||
void JAVA::initialize()
|
void JAVA::initialize()
|
||||||
{
|
{
|
||||||
if (!module) {
|
if (!module) {
|
||||||
fprintf(stderr,"SWIG : *** Error. No module name specified.\n");
|
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -798,24 +798,6 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
methodEntry << "\"" << name << "\", \"(" << javaParameterSignature << ")" << javaReturnSignature << "\", " << wname;
|
methodEntry << "\"" << name << "\", \"(" << javaParameterSignature << ")" << javaReturnSignature << "\", " << wname;
|
||||||
registerNativesList << tab4 << "{" << methodEntry << "}," << "\n";
|
registerNativesList << tab4 << "{" << methodEntry << "}," << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's a documentation entry, produce a usage string
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
|
|
||||||
static DocEntry *last_doc_entry = 0;
|
|
||||||
|
|
||||||
// Use usage as description
|
|
||||||
doc_entry->usage << iname;
|
|
||||||
|
|
||||||
// Set the cinfo field to specific a return type
|
|
||||||
|
|
||||||
if (last_doc_entry != doc_entry) {
|
|
||||||
doc_entry->cinfo << "returns " << t->print_type();
|
|
||||||
last_doc_entry = doc_entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -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 *) { };
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -335,8 +335,8 @@ void PERL5::initialize()
|
||||||
char filen[256];
|
char filen[256];
|
||||||
|
|
||||||
if (!module){
|
if (!module){
|
||||||
module = "swig";
|
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||||
fprintf(stderr,"SWIG : *** Warning. No module name specified.\n");
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!package) {
|
if (!package) {
|
||||||
|
|
@ -577,14 +577,6 @@ void PERL5::close(void)
|
||||||
|
|
||||||
fprintf(f_pm,"1;\n");
|
fprintf(f_pm,"1;\n");
|
||||||
fclose(f_pm);
|
fclose(f_pm);
|
||||||
|
|
||||||
// Patch up documentation title
|
|
||||||
|
|
||||||
if ((doc_entry) && (module)) {
|
|
||||||
doc_entry->cinfo << "Module : " << module << ", "
|
|
||||||
<< "Package : " << realpackage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
@ -647,40 +639,11 @@ void PERL5::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
||||||
else
|
else
|
||||||
f << "\"" << (hidden ? realpackage : "") << (hidden ? "::" : "") << t->print_mangle() << "\")) {\n";
|
f << "\"" << (hidden ? realpackage : "") << (hidden ? "::" : "") << t->print_mangle() << "\")) {\n";
|
||||||
|
|
||||||
// This part handles the type checking according to three different
|
// Change this part to return an error.
|
||||||
// levels. 0 = no checking, 1 = warning message, 2 = strict.
|
f << tab8 << "croak(\"Type error in " << srcname
|
||||||
|
<< " of " << iname << ". Expected " << (hidden ? realpackage : "") << (hidden ? "::" : "") << t->print_mangle() << ".\");\n"
|
||||||
switch(TypeStrict) {
|
<< tab8 << ret << ";\n"
|
||||||
case 0: // No type checking
|
<< tab4 << "}\n";
|
||||||
f << tab4 << "}\n";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // Warning message only
|
|
||||||
|
|
||||||
// Change this part to how you want to handle a type-mismatch warning.
|
|
||||||
// By default, it will just print to stderr.
|
|
||||||
|
|
||||||
f << tab8 << "fprintf(stderr,\"Warning : type mismatch in " << srcname
|
|
||||||
<< " of " << iname << ". Expected " << (hidden ? realpackage : "") << (hidden ? "::" : "") << t->print_mangle()
|
|
||||||
<< ", received %s\\n\"," << src << ");\n"
|
|
||||||
<< tab4 << "}\n";
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2: // Super strict mode.
|
|
||||||
|
|
||||||
// Change this part to return an error.
|
|
||||||
|
|
||||||
f << tab8 << "croak(\"Type error in " << srcname
|
|
||||||
<< " of " << iname << ". Expected " << (hidden ? realpackage : "") << (hidden ? "::" : "") << t->print_mangle() << ".\");\n"
|
|
||||||
<< tab8 << ret << ";\n"
|
|
||||||
<< tab4 << "}\n";
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
fprintf(stderr,"SWIG Error. Unknown strictness level\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
@ -1012,17 +975,6 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
f.print(f_wrappers);
|
f.print(f_wrappers);
|
||||||
|
|
||||||
// Create a first crack at a documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
static DocEntry *last_doc_entry = 0;
|
|
||||||
doc_entry->usage << usage;
|
|
||||||
if (last_doc_entry != doc_entry) {
|
|
||||||
doc_entry->cinfo << "returns " << d->print_type();
|
|
||||||
last_doc_entry = doc_entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now register the function
|
// Now register the function
|
||||||
|
|
||||||
fprintf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, wname);
|
fprintf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, wname);
|
||||||
|
|
@ -1313,12 +1265,6 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
||||||
} else {
|
} else {
|
||||||
vinit << tab4 << "swig_create_magic(sv,\"" << package << "::" << iname << "\", MAGIC_CAST MAGIC_CLASS " << set_name << ", MAGIC_CAST MAGIC_CLASS " << val_name << ");\n";
|
vinit << tab4 << "swig_create_magic(sv,\"" << package << "::" << iname << "\", MAGIC_CAST MAGIC_CLASS " << set_name << ", MAGIC_CAST MAGIC_CLASS " << val_name << ");\n";
|
||||||
}
|
}
|
||||||
// Add a documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage << usage_var(iname,t);
|
|
||||||
doc_entry->cinfo << "Global : " << t->print_type() << " " << name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're blessed, try to figure out what to do with the variable
|
// If we're blessed, try to figure out what to do with the variable
|
||||||
// 1. If it's a Perl object of some sort, create a tied-hash
|
// 1. If it's a Perl object of some sort, create a tied-hash
|
||||||
|
|
@ -1470,15 +1416,6 @@ PERL5::declare_const(char *name, char *, DataType *type, char *value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch up the documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << usage_const(name,type,value);
|
|
||||||
doc_entry->cinfo = "";
|
|
||||||
doc_entry->cinfo << "Constant: " << type->print_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
if ((classes.lookup(type->name)) && (type->is_pointer <= 1)) {
|
if ((classes.lookup(type->name)) && (type->is_pointer <= 1)) {
|
||||||
var_stubs << "\nmy %__" << name << "_hash;\n"
|
var_stubs << "\nmy %__" << name << "_hash;\n"
|
||||||
|
|
@ -1942,13 +1879,6 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
// Append our function to the pcode segment
|
// Append our function to the pcode segment
|
||||||
|
|
||||||
*pcode << func;
|
*pcode << func;
|
||||||
|
|
||||||
// Create a new kind of documentation entry for the shadow class
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = ""; // Blow away whatever was there before
|
|
||||||
doc_entry->usage << usage_func(realname,t,l);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
@ -2002,13 +1932,6 @@ void PERL5::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
*blessedmembers << tab4 << realname << " => '" << (hidden ? realpackage : "") << (hidden ? "::" : "") << (char *) classes.lookup(t->name) << "',\n";
|
*blessedmembers << tab4 << realname << " => '" << (hidden ? realpackage : "") << (hidden ? "::" : "") << (char *) classes.lookup(t->name) << "',\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch up the documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << "$this->{" << realname << "}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
have_data_members++;
|
have_data_members++;
|
||||||
}
|
}
|
||||||
|
|
@ -2094,12 +2017,6 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
<< "}\n\n";
|
<< "}\n\n";
|
||||||
have_constructor = 1;
|
have_constructor = 1;
|
||||||
|
|
||||||
// Patch up the documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << usage_func("new",0,l);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
member_func = 0;
|
member_func = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2136,10 +2053,6 @@ void PERL5::cpp_destructor(char *name, char *newname) {
|
||||||
|
|
||||||
have_destructor = 1;
|
have_destructor = 1;
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "DESTROY";
|
|
||||||
doc_entry->cinfo = "Destructor";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
member_func = 0;
|
member_func = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2230,15 +2143,6 @@ void PERL5::cpp_declare_const(char *name, char *iname, DataType *type, char *val
|
||||||
// Create a symbol table entry for it
|
// Create a symbol table entry for it
|
||||||
*pcode << "*" << realname << " = *" << package << "::" << name_member(realname,class_name) << ";\n";
|
*pcode << "*" << realname << " = *" << package << "::" << name_member(realname,class_name) << ";\n";
|
||||||
|
|
||||||
// Fix up the documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << realname;
|
|
||||||
if (value) {
|
|
||||||
doc_entry->usage << " = " << value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,6 @@ void PYTHON::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
else
|
else
|
||||||
*pyclass << tab4 << "def " << realname << "(*args):\n";
|
*pyclass << tab4 << "def " << realname << "(*args):\n";
|
||||||
|
|
||||||
// Create a doc string
|
|
||||||
if (docstring && doc_entry) {
|
|
||||||
*pyclass << tab8 << "\"\"\"" << add_docstring(doc_entry) << "\"\"\"\n";
|
|
||||||
}
|
|
||||||
if (use_kw)
|
if (use_kw)
|
||||||
*pyclass << tab8 << "val = apply(" << module << "." << name_member(realname,class_name) << ",args, kwargs)\n";
|
*pyclass << tab8 << "val = apply(" << module << "." << name_member(realname,class_name) << ",args, kwargs)\n";
|
||||||
else
|
else
|
||||||
|
|
@ -174,12 +170,6 @@ void PYTHON::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
}
|
}
|
||||||
emitAddPragmas(*pyclass, realname, tab8);
|
emitAddPragmas(*pyclass, realname, tab8);
|
||||||
*pyclass << tab8 << "return val\n";
|
*pyclass << tab8 << "return val\n";
|
||||||
|
|
||||||
// Change the usage string to reflect our shadow class
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << usage_func(realname,t,l);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,9 +216,6 @@ void PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
else
|
else
|
||||||
*construct << tab4 << "def __init__(self,*args):\n";
|
*construct << tab4 << "def __init__(self,*args):\n";
|
||||||
|
|
||||||
if (docstring && doc_entry)
|
|
||||||
*construct << tab8 << "\"\"\"" << add_docstring(doc_entry) << "\"\"\"\n";
|
|
||||||
|
|
||||||
if (use_kw)
|
if (use_kw)
|
||||||
*construct << tab8 << "self.this = apply(" << module << "." << name_construct(realname) << ",args,kwargs)\n";
|
*construct << tab8 << "self.this = apply(" << module << "." << name_construct(realname) << ",args,kwargs)\n";
|
||||||
else
|
else
|
||||||
|
|
@ -254,11 +241,6 @@ void PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
*additional << tab4 << "val.thisown = 1\n"
|
*additional << tab4 << "val.thisown = 1\n"
|
||||||
<< tab4 << "return val\n\n";
|
<< tab4 << "return val\n\n";
|
||||||
}
|
}
|
||||||
// Patch up the documentation entry
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << usage_func(class_name,0,l);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,10 +270,6 @@ void PYTHON::cpp_destructor(char *name, char *newname) {
|
||||||
<< tab8 << tab4 << module << "." << name_destroy(realname) << "(self)\n";
|
<< tab8 << tab4 << module << "." << name_destroy(realname) << "(self)\n";
|
||||||
|
|
||||||
have_destructor = 1;
|
have_destructor = 1;
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << "del this";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -319,9 +297,6 @@ void PYTHON::cpp_close_class() {
|
||||||
} else {
|
} else {
|
||||||
ptrclass << "class " << class_name << ":\n";
|
ptrclass << "class " << class_name << ":\n";
|
||||||
}
|
}
|
||||||
if (docstring && doc_entry) {
|
|
||||||
classes << tab4 << "\"\"\"" << add_docstring(doc_entry) << "\"\"\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// *getattr << tab8 << "return self.__dict__[name]\n";
|
// *getattr << tab8 << "return self.__dict__[name]\n";
|
||||||
*getattr << tab8 << "raise AttributeError,name\n";
|
*getattr << tab8 << "raise AttributeError,name\n";
|
||||||
|
|
@ -451,13 +426,6 @@ void PYTHON::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
} else {
|
} else {
|
||||||
*getattr << tab8 << tab4 << "return " << module << "." << name_get(name_member(realname,class_name)) << "(self)\n";
|
*getattr << tab8 << tab4 << "return " << module << "." << name_get(name_member(realname,class_name)) << "(self)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch up ye old documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << "self." << realname;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -490,14 +458,6 @@ void PYTHON::cpp_declare_const(char *name, char *iname, DataType *type, char *va
|
||||||
}
|
}
|
||||||
|
|
||||||
*cinit << tab4 << realname << " = " << module << "." << name_member(realname,class_name) << "\n";
|
*cinit << tab4 << realname << " = " << module << "." << name_member(realname,class_name) << "\n";
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << "self." << realname;
|
|
||||||
if (value) {
|
|
||||||
doc_entry->usage << " = " << value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,21 +27,10 @@ static char cvsroot[] = "$Header$";
|
||||||
#include "swig11.h"
|
#include "swig11.h"
|
||||||
#include "python.h"
|
#include "python.h"
|
||||||
|
|
||||||
// Structures for managing doc strings
|
|
||||||
|
|
||||||
struct DocString {
|
|
||||||
DocEntry *de;
|
|
||||||
char *name;
|
|
||||||
DocString *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int doc_index = 0;
|
|
||||||
static DocString *doc_strings = 0;
|
|
||||||
static String const_code;
|
static String const_code;
|
||||||
|
|
||||||
static char *usage = "\
|
static char *usage = "\
|
||||||
Python Options (available with -python)\n\
|
Python Options (available with -python)\n\
|
||||||
-docstring - Produce docstrings (only applies to shadow classes)\n\
|
|
||||||
-globals name - Set name used to access C global variable ('cvar' by default).\n\
|
-globals name - Set name used to access C global variable ('cvar' by default).\n\
|
||||||
-module name - Set module name\n\
|
-module name - Set module name\n\
|
||||||
-keyword - Use keyword arguments\n\
|
-keyword - Use keyword arguments\n\
|
||||||
|
|
@ -60,8 +49,6 @@ void PYTHON::parse_args(int argc, char *argv[]) {
|
||||||
|
|
||||||
sprintf(LibDir,"%s",path);
|
sprintf(LibDir,"%s",path);
|
||||||
|
|
||||||
docstring = 0;
|
|
||||||
|
|
||||||
// Look for additional command line options.
|
// Look for additional command line options.
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (argv[i]) {
|
if (argv[i]) {
|
||||||
|
|
@ -88,9 +75,6 @@ void PYTHON::parse_args(int argc, char *argv[]) {
|
||||||
} else if (strcmp(argv[i],"-shadow") == 0) {
|
} else if (strcmp(argv[i],"-shadow") == 0) {
|
||||||
shadow = 1;
|
shadow = 1;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strcmp(argv[i],"-docstring") == 0) {
|
|
||||||
docstring = 1;
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-keyword") == 0) {
|
} else if (strcmp(argv[i],"-keyword") == 0) {
|
||||||
use_kw = 1;
|
use_kw = 1;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
|
|
@ -248,30 +232,6 @@ void PYTHON::print_methods() {
|
||||||
fprintf(f_wrappers,"#endif\n");
|
fprintf(f_wrappers,"#endif\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
|
||||||
// char *PYTHON::add_docstring(DocEntry *de)
|
|
||||||
//
|
|
||||||
// Adds a documentation entry to the doc-string generator. Returns a
|
|
||||||
// unique character symbol that will be used to fill in the doc-string
|
|
||||||
// at a later time.
|
|
||||||
// ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
char *PYTHON::add_docstring(DocEntry *de) {
|
|
||||||
DocString *s;
|
|
||||||
String str;
|
|
||||||
|
|
||||||
str = "@doc";
|
|
||||||
str << doc_index << "@";
|
|
||||||
|
|
||||||
s = new DocString();
|
|
||||||
s->de = de;
|
|
||||||
s->name = copy_string(str);
|
|
||||||
s->next = doc_strings;
|
|
||||||
doc_strings = s;
|
|
||||||
doc_index++;
|
|
||||||
return s->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// PYTHON::headers(void)
|
// PYTHON::headers(void)
|
||||||
//
|
//
|
||||||
|
|
@ -311,8 +271,8 @@ void PYTHON::initialize(void)
|
||||||
char *oldmodule = 0;
|
char *oldmodule = 0;
|
||||||
|
|
||||||
if (!module) {
|
if (!module) {
|
||||||
module = "swig";
|
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||||
fprintf(stderr,"SWIG : *** Warning. No module name specified.\n");
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If shadow classing is enabled, we're going to change the module
|
// If shadow classing is enabled, we're going to change the module
|
||||||
|
|
@ -390,14 +350,6 @@ void PYTHON::initialize_cmodule(void)
|
||||||
|
|
||||||
fprintf(f_init,"SWIGEXPORT(void) init%s() {\n",module);
|
fprintf(f_init,"SWIGEXPORT(void) init%s() {\n",module);
|
||||||
fprintf(f_init,"\t PyObject *m, *d;\n");
|
fprintf(f_init,"\t PyObject *m, *d;\n");
|
||||||
|
|
||||||
if (InitNames) {
|
|
||||||
i = 0;
|
|
||||||
while (InitNames[i]) {
|
|
||||||
fprintf(f_init,"\t %s();\n", InitNames[i]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(f_init,"\t SWIG_globals = SWIG_newvarlink();\n");
|
fprintf(f_init,"\t SWIG_globals = SWIG_newvarlink();\n");
|
||||||
fprintf(f_init,"\t m = Py_InitModule(\"%s\", %sMethods);\n", module, module);
|
fprintf(f_init,"\t m = Py_InitModule(\"%s\", %sMethods);\n", module, module);
|
||||||
fprintf(f_init,"\t d = PyModule_GetDict(m);\n");
|
fprintf(f_init,"\t d = PyModule_GetDict(m);\n");
|
||||||
|
|
@ -416,15 +368,6 @@ void PYTHON::close(void)
|
||||||
|
|
||||||
print_methods();
|
print_methods();
|
||||||
close_cmodule();
|
close_cmodule();
|
||||||
if ((doc_entry) && (module)){
|
|
||||||
String temp;
|
|
||||||
temp << "Python Module : ";
|
|
||||||
if (shadow) {
|
|
||||||
module[strlen(module)-1] = 0;
|
|
||||||
}
|
|
||||||
temp << module;
|
|
||||||
doc_entry->cinfo << temp;
|
|
||||||
}
|
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
String fullshadow;
|
String fullshadow;
|
||||||
fullshadow << classes
|
fullshadow << classes
|
||||||
|
|
@ -437,25 +380,6 @@ void PYTHON::close(void)
|
||||||
fullshadow << "\n\n#-------------- USER INCLUDE -----------------------\n\n"
|
fullshadow << "\n\n#-------------- USER INCLUDE -----------------------\n\n"
|
||||||
<< pragma_include;
|
<< pragma_include;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through all of the docstrings and replace the docstrings
|
|
||||||
|
|
||||||
DocString *s;
|
|
||||||
s = doc_strings;
|
|
||||||
while (s) {
|
|
||||||
fullshadow.replace(s->name, s->de->text);
|
|
||||||
s = s->next;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
fprintf(f_shadow,"\n\n#-------------- FUNCTION WRAPPERS ------------------\n\n");
|
|
||||||
fprintf(f_shadow,"%s",func.get());
|
|
||||||
fprintf(f_shadow,"\n\n#-------------- VARIABLE WRAPPERS ------------------\n\n");
|
|
||||||
fprintf(f_shadow,"%s",vars.get());
|
|
||||||
if (strlen(pragma_include) > 0) {
|
|
||||||
fprintf(f_shadow,"\n\n#-------------- USER INCLUDE -----------------------\n\n");
|
|
||||||
fprintf(f_shadow,"%s",pragma_include.get());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
fprintf(f_shadow, "%s", fullshadow.get());
|
fprintf(f_shadow, "%s", fullshadow.get());
|
||||||
fclose(f_shadow);
|
fclose(f_shadow);
|
||||||
}
|
}
|
||||||
|
|
@ -1012,17 +936,6 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
add_method(iname, wname);
|
add_method(iname, wname);
|
||||||
|
|
||||||
// Create a documentation entry for this
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
static DocEntry *last_doc_entry = 0;
|
|
||||||
doc_entry->usage << usage;
|
|
||||||
if (last_doc_entry != doc_entry) {
|
|
||||||
doc_entry->cinfo << "returns " << d->print_type();
|
|
||||||
last_doc_entry = doc_entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Create a shadow for this function (if enabled and not in a member function)
|
// Create a shadow for this function (if enabled and not in a member function)
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
@ -1040,9 +953,6 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
munge_return = 1;
|
munge_return = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (docstring && doc_entry)
|
|
||||||
need_wrapper = 1;
|
|
||||||
|
|
||||||
// If no modification is needed. We're just going to play some
|
// If no modification is needed. We're just going to play some
|
||||||
// symbol table games instead
|
// symbol table games instead
|
||||||
|
|
||||||
|
|
@ -1051,11 +961,6 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
} else {
|
} else {
|
||||||
func << "def " << iname << "(*args, **kwargs):\n";
|
func << "def " << iname << "(*args, **kwargs):\n";
|
||||||
|
|
||||||
// Create a docstring for this
|
|
||||||
if (docstring && doc_entry) {
|
|
||||||
func << tab4 << "\"\"\"" << add_docstring(doc_entry) << "\"\"\"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
func << tab4 << "val = apply(" << module << "." << iname << ",args,kwargs)\n";
|
func << tab4 << "val = apply(" << module << "." << iname << ",args,kwargs)\n";
|
||||||
|
|
||||||
if (munge_return) {
|
if (munge_return) {
|
||||||
|
|
@ -1302,14 +1207,6 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
||||||
|
|
||||||
fprintf(f_init,"\t SWIG_addvarlink(SWIG_globals,\"%s\",%s_get, %s_set);\n", iname, wname, wname);
|
fprintf(f_init,"\t SWIG_addvarlink(SWIG_globals,\"%s\",%s_get, %s_set);\n", iname, wname, wname);
|
||||||
|
|
||||||
|
|
||||||
// Fill in the documentation entry
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage << usage_var(iname, t);
|
|
||||||
doc_entry->cinfo << "Global : " << t->print_type() << " " << name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
// Output a shadow variable. (If applicable and possible)
|
// Output a shadow variable. (If applicable and possible)
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
|
|
@ -1378,12 +1275,6 @@ void PYTHON::declare_const(char *name, char *, DataType *type, char *value) {
|
||||||
if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||||
vars << name << " = " << module << "." << name << "\n";
|
vars << name << " = " << module << "." << name << "\n";
|
||||||
}
|
}
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << usage_const(name,type,value);
|
|
||||||
doc_entry->cinfo = "";
|
|
||||||
doc_entry->cinfo << "Constant: " << type->print_type();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,6 @@ protected:
|
||||||
char *usage_var(char *, DataType *);
|
char *usage_var(char *, DataType *);
|
||||||
char *usage_func(char *, DataType *, ParmList *);
|
char *usage_func(char *, DataType *, ParmList *);
|
||||||
char *usage_const(char *, DataType *, char *);
|
char *usage_const(char *, DataType *, char *);
|
||||||
char *add_docstring(DocEntry *de);
|
|
||||||
|
|
||||||
// Add for Python-COM support
|
// Add for Python-COM support
|
||||||
virtual void initialize_cmodule();
|
virtual void initialize_cmodule();
|
||||||
|
|
|
||||||
|
|
@ -25,18 +25,18 @@ static char cvsroot[] = "$Header$";
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include "swigconfig.h"
|
#include "swigconfig.h"
|
||||||
|
#include "swig11.h"
|
||||||
#include "wrap.h"
|
|
||||||
#include "tcl8.h"
|
#include "tcl8.h"
|
||||||
#include "perl5.h"
|
#include "perl5.h"
|
||||||
#include "java.h"
|
#include "java.h"
|
||||||
#include "python.h"
|
#include "python.h"
|
||||||
#include "guile.h"
|
#include "guile.h"
|
||||||
#include "ascii.h"
|
|
||||||
#include "html.h"
|
|
||||||
#include "nodoc.h"
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifndef SWIG_LANG
|
||||||
|
#define SWIG_LANG PYTHON
|
||||||
|
#endif
|
||||||
|
|
||||||
static char *usage = "\
|
static char *usage = "\
|
||||||
swig <options> filename\n\n\
|
swig <options> filename\n\n\
|
||||||
|
|
@ -45,26 +45,7 @@ Target Language Options:\n\
|
||||||
-python - Generate Python wrappers.\n\
|
-python - Generate Python wrappers.\n\
|
||||||
-perl5 - Generate Perl5 wrappers.\n\
|
-perl5 - Generate Perl5 wrappers.\n\
|
||||||
-java - Generate Java wrappers.\n\
|
-java - Generate Java wrappers.\n\
|
||||||
-guile - Generate Guile wrappers.\n\n\
|
-guile - Generate Guile wrappers.\n";
|
||||||
Documentation Options\n\
|
|
||||||
-dascii - ASCII documentation.\n\
|
|
||||||
-dhtml - HTML documentation.\n\
|
|
||||||
-dnone - No documentation.\n";
|
|
||||||
|
|
||||||
#ifdef MACSWIG
|
|
||||||
static char *macmessage = "\
|
|
||||||
Copyright (c) 1995-1997\n\
|
|
||||||
University of Utah and the Regents of the University of California\n\n\
|
|
||||||
Enter SWIG processing options and filename below. For example :\n\
|
|
||||||
\n\
|
|
||||||
-tcl -c++ interface.i\n\
|
|
||||||
\n\
|
|
||||||
-help displays a list of all available options.\n\
|
|
||||||
\n\
|
|
||||||
Note : Macintosh filenames should be enclosed in quotes if they contain whitespace.\n\
|
|
||||||
\n";
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
// main()
|
// main()
|
||||||
|
|
@ -72,18 +53,11 @@ Note : Macintosh filenames should be enclosed in quotes if they contain whitespa
|
||||||
// Main program. Initializes the files and starts the parser.
|
// Main program. Initializes the files and starts the parser.
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef MACSWIG
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
#else
|
|
||||||
int Mac_main(int argc, char **argv) {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Language *dl = new SWIG_LANG;
|
Language *dl = new SWIG_LANG;
|
||||||
Documentation *dd = new SWIG_DOC;
|
extern int SWIG_main(int, char **, Language *);
|
||||||
extern int SWIG_main(int, char **, Language *, Documentation *);
|
|
||||||
|
|
||||||
Swig_init_args(argc,argv);
|
Swig_init_args(argc,argv);
|
||||||
|
|
||||||
// Get options
|
// Get options
|
||||||
|
|
@ -108,78 +82,11 @@ int Mac_main(int argc, char **argv) {
|
||||||
} else if (strcmp(argv[i],"-java") == 0) {
|
} else if (strcmp(argv[i],"-java") == 0) {
|
||||||
dl = new JAVA;
|
dl = new JAVA;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strcmp(argv[i],"-dascii") == 0) {
|
|
||||||
dd = new ASCII;
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-dnone") == 0) {
|
|
||||||
dd = new NODOC;
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-dhtml") == 0) {
|
|
||||||
dd = new HTML;
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-help") == 0) {
|
} else if (strcmp(argv[i],"-help") == 0) {
|
||||||
fputs(usage,stderr);
|
fputs(usage,stderr);
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!dd) dd = new ASCII;
|
return SWIG_main(argc,argv,dl);
|
||||||
|
|
||||||
SWIG_main(argc,argv,dl,dd);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MACSWIG
|
|
||||||
int MacMainEntry(char *options) {
|
|
||||||
static char *_argv[256];
|
|
||||||
int i,argc;
|
|
||||||
char *c,*s,*t;
|
|
||||||
|
|
||||||
swig_log = fopen("swig_log","w");
|
|
||||||
fprintf(swig_log,"SWIG 1.1\n");
|
|
||||||
fprintf(swig_log,"Options : %s\n", options);
|
|
||||||
fprintf(swig_log,"-----------------------------------------------------\n");
|
|
||||||
|
|
||||||
// Tokenize the user input
|
|
||||||
|
|
||||||
_argv[0] = "swig";
|
|
||||||
i=1;
|
|
||||||
c = options;
|
|
||||||
while (*c) {
|
|
||||||
while(isspace(*c)) c++;
|
|
||||||
if (*c) {
|
|
||||||
s = c; // Starting character
|
|
||||||
while(isgraph(*c)) {
|
|
||||||
if (*c == '\"') {
|
|
||||||
c++;
|
|
||||||
while ((*c) && (*c != '\"'))
|
|
||||||
c++;
|
|
||||||
c++;
|
|
||||||
} else {
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Found some whitespace
|
|
||||||
if (*c) {
|
|
||||||
*c = 0;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
_argv[i] = copy_string(s);
|
|
||||||
// Go through and remove quotes (if necessary)
|
|
||||||
|
|
||||||
t = _argv[i];
|
|
||||||
while(*s) {
|
|
||||||
if (*s != '\"')
|
|
||||||
*(t++) = *s;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
*t = 0;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc = i;
|
|
||||||
_argv[i] = 0;
|
|
||||||
return Mac_main(argc,_argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -263,8 +263,8 @@ void TCL8::initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!init_name) {
|
if (!init_name) {
|
||||||
init_name = "Swig_Init";
|
fprintf(stderr,"*** Error. No module name specified.\n");
|
||||||
fprintf(stderr,"SWIG : *** Warning. No module name specified.\n");
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f_header,"#define SWIG_init %s\n", init_name);
|
fprintf(f_header,"#define SWIG_init %s\n", init_name);
|
||||||
|
|
@ -748,23 +748,6 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// Now register the function with Tcl
|
// Now register the function with Tcl
|
||||||
|
|
||||||
cmd_info << tab4 << "{ SWIG_prefix \"" << iname << "\", " << wname << ", NULL},\n";
|
cmd_info << tab4 << "{ SWIG_prefix \"" << iname << "\", " << wname << ", NULL},\n";
|
||||||
|
|
||||||
// If there's a documentation entry, produce a usage string
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
|
|
||||||
static DocEntry *last_doc_entry = 0;
|
|
||||||
|
|
||||||
// Use usage as description
|
|
||||||
doc_entry->usage << usage;
|
|
||||||
|
|
||||||
// Set the cinfo field to specific a return type
|
|
||||||
|
|
||||||
if (last_doc_entry != doc_entry) {
|
|
||||||
doc_entry->cinfo << "returns " << d->print_type();
|
|
||||||
last_doc_entry = doc_entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
@ -1003,24 +986,12 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||||
s << ");\n";
|
s << ");\n";
|
||||||
|
|
||||||
fprintf(f_init,"\t Tcl_LinkVar(%s, SWIG_prefix \"%s\", %s",interp_name, iname, s.get());
|
fprintf(f_init,"\t Tcl_LinkVar(%s, SWIG_prefix \"%s\", %s",interp_name, iname, s.get());
|
||||||
|
|
||||||
// Make a usage string for it
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage << usage_var(iname,t);
|
|
||||||
doc_entry->cinfo = "";
|
|
||||||
doc_entry->cinfo << "Global : " << t->print_type() << " " << name;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Have some sort of "other" type.
|
// Have some sort of "other" type.
|
||||||
// We're going to emit some functions to set/get it's value instead
|
// We're going to emit some functions to set/get it's value instead
|
||||||
|
|
||||||
emit_set_get(name,iname, t);
|
emit_set_get(name,iname, t);
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->cinfo = "";
|
|
||||||
doc_entry->cinfo << "Global : " << t->print_type() << " " << iname;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If shadow classes are enabled and we have a user-defined type
|
// If shadow classes are enabled and we have a user-defined type
|
||||||
// that we know about, create a command for it.
|
// that we know about, create a command for it.
|
||||||
|
|
@ -1167,16 +1138,6 @@ void TCL8::declare_const(char *name, char *, DataType *type, char *value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a documentation entry for this
|
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = ""; // Destroy any previous information from linking
|
|
||||||
doc_entry->usage << usage_const(name, type, value);
|
|
||||||
doc_entry->cinfo = "";
|
|
||||||
doc_entry->cinfo << "Constant : " << type->print_type();
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = OldStatus;
|
Status = OldStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1304,15 +1265,6 @@ void TCL8::add_native(char *name, char *funcname, DataType *, ParmList *) {
|
||||||
|
|
||||||
fprintf(f_init,"\t Tcl_CreateCommand(%s, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",interp_name, name, funcname);
|
fprintf(f_init,"\t Tcl_CreateCommand(%s, SWIG_prefix \"%s\", %s, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);\n",interp_name, name, funcname);
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
if (nspace)
|
|
||||||
doc_entry->usage << ns_name << "::" << name << " args";
|
|
||||||
else
|
|
||||||
doc_entry->usage << prefix << name << " args";
|
|
||||||
|
|
||||||
doc_entry->cinfo << "Native method : " << funcname;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -1440,11 +1392,6 @@ void TCL8::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
rname = name_wrapper(temp.get(),prefix);
|
rname = name_wrapper(temp.get(),prefix);
|
||||||
|
|
||||||
methods << tab4 << "{\"" << realname << "\", " << rname << "}, \n";
|
methods << tab4 << "{\"" << realname << "\", " << rname << "}, \n";
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << usage_string(realname,t,l);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1483,10 +1430,6 @@ void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
} else {
|
} else {
|
||||||
attributes << "0 },\n";
|
attributes << "0 },\n";
|
||||||
}
|
}
|
||||||
if (doc_entry){
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << "-" << realname << "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1494,21 +1437,12 @@ void TCL8::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
this->Language::cpp_constructor(name,iname,l);
|
this->Language::cpp_constructor(name,iname,l);
|
||||||
|
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
if ((!have_constructor) && (doc_entry)) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->usage << class_name << usage_string(" name",0,l);
|
|
||||||
}
|
|
||||||
have_constructor = 1;
|
have_constructor = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void TCL8::cpp_destructor(char *name, char *newname) {
|
void TCL8::cpp_destructor(char *name, char *newname) {
|
||||||
this->Language::cpp_destructor(name,newname);
|
this->Language::cpp_destructor(name,newname);
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
if (!have_destructor) {
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "rename obj {}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
have_destructor = 1;
|
have_destructor = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,38 +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$
|
|
||||||
*
|
|
||||||
* wrap.h
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
#include "swig11.h"
|
|
||||||
|
|
||||||
#ifndef SWIG_LIB
|
|
||||||
#define SWIG_LIB = "./swig_lib"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SWIG_LANG
|
|
||||||
#define SWIG_LANG TCL8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SWIG_DOC
|
|
||||||
#define SWIG_DOC ASCII
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,13 +14,13 @@ RANLIB = @RANLIB@
|
||||||
|
|
||||||
TARGET = libswig11.a
|
TARGET = libswig11.a
|
||||||
|
|
||||||
OBJS = parser.o main.o scanner.o symbol.o types.o include.o parms.o emit.o newdoc.o \
|
OBJS = parser.o main.o scanner.o symbol.o types.o include.o parms.o emit.o \
|
||||||
cplus.o lang.o hash.o sstring.o wrapfunc.o comment.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 emit.cxx \
|
SRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx emit.cxx \
|
||||||
newdoc.cxx cplus.cxx lang.cxx hash.cxx \
|
cplus.cxx lang.cxx hash.cxx \
|
||||||
sstring.cxx wrapfunc.cxx comment.cxx typemap.cxx naming.cxx
|
sstring.cxx wrapfunc.cxx typemap.cxx naming.cxx
|
||||||
|
|
||||||
PARSER = parser.yxx
|
PARSER = parser.yxx
|
||||||
INCLUDE = -I../Include -I. -I../Swig -I../Preprocessor -I../DOH/Include
|
INCLUDE = -I../Include -I. -I../Swig -I../Preprocessor -I../DOH/Include
|
||||||
|
|
|
||||||
7
SWIG/Source/SWIG1.1/README
Normal file
7
SWIG/Source/SWIG1.1/README
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
2/10/00
|
||||||
|
|
||||||
|
This is the old SWIG1.1 core written in C++. This is a real mess
|
||||||
|
and in the process of being deprecated. Please bear with us.
|
||||||
|
|
||||||
|
-- Dave
|
||||||
|
|
||||||
|
|
@ -1,648 +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"
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* $Header$
|
|
||||||
*
|
|
||||||
* File : comment.cxx
|
|
||||||
*
|
|
||||||
* This is a semi-magical module for associating C/C++ comments with
|
|
||||||
* documentation entries. While this sounds like it might be easy,
|
|
||||||
* there are a number of subtle problems getting things to associate
|
|
||||||
* correctly.
|
|
||||||
*
|
|
||||||
* Here's the general idea :
|
|
||||||
*
|
|
||||||
* 1. The parser and scanner feed both C comments and documentation
|
|
||||||
* entries to this class. These may show up in really bizarre
|
|
||||||
* orders (not necessarily the order seen in an interface file).
|
|
||||||
*
|
|
||||||
* 2. We maintain separate lists of comments and documentation
|
|
||||||
* entries.
|
|
||||||
*
|
|
||||||
* 3. Periodically, we go through the list of documentation entries
|
|
||||||
* and see if we can associate any comments.
|
|
||||||
*
|
|
||||||
* 4. Upon completion of parsing, it's critical that we cleanup
|
|
||||||
* the lists using the cleanup() method.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
static char cvstag[] = "$Header$";
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// struct Comment
|
|
||||||
//
|
|
||||||
// Structure used to maintain a linked list of comments for later use.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class Comment {
|
|
||||||
public:
|
|
||||||
String *text; // Text of the comment
|
|
||||||
int first_line; // First line of the comment
|
|
||||||
int last_line; // Last line of the comment
|
|
||||||
int column; // First column of comment
|
|
||||||
char *file; // Name of the file that it was in
|
|
||||||
Comment *next; // Next comment (when in a linked list)
|
|
||||||
Comment *prev; // Previous comment
|
|
||||||
static Comment *comment_list; // List of all comments
|
|
||||||
|
|
||||||
Comment(char *t, int line, int col, char *f);
|
|
||||||
~Comment();
|
|
||||||
static Comment *find(DocEntry *de, CommentHandler *ch);
|
|
||||||
void attach(DocEntry *de, CommentHandler *ch);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// Create a new comment. Automatically puts it on the linked list
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
Comment::Comment(char *t, int line, int col, char *f) {
|
|
||||||
int nlines = 0;
|
|
||||||
char *c;
|
|
||||||
|
|
||||||
text = new String(t);
|
|
||||||
c = t;
|
|
||||||
while (*c) {
|
|
||||||
if (*c == '\n') nlines++;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
first_line = line;
|
|
||||||
column = col;
|
|
||||||
last_line = line + nlines - 1;
|
|
||||||
file = copy_string(f);
|
|
||||||
if (comment_list) {
|
|
||||||
comment_list->prev = this;
|
|
||||||
}
|
|
||||||
next = comment_list;
|
|
||||||
comment_list = this;
|
|
||||||
prev = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// Destroy a comment
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
Comment::~Comment() {
|
|
||||||
delete text;
|
|
||||||
delete file;
|
|
||||||
// Remove from linked list (if applicable)
|
|
||||||
if (prev) {
|
|
||||||
prev->next = next;
|
|
||||||
}
|
|
||||||
if (next) {
|
|
||||||
next->prev = prev;
|
|
||||||
}
|
|
||||||
if (this == comment_list) comment_list = next;
|
|
||||||
}
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// find(DocEntry *de, CommentHandler *ch)
|
|
||||||
//
|
|
||||||
// This function tries to a find a comment matching the search criteria
|
|
||||||
// of a given comment handler and documentation entry.
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Comment *Comment::find(DocEntry *de, CommentHandler *ch) {
|
|
||||||
Comment *c;
|
|
||||||
|
|
||||||
c = comment_list;
|
|
||||||
|
|
||||||
// Start walking down our list of stored comments
|
|
||||||
|
|
||||||
while (c) {
|
|
||||||
// printf("Searching %x : %s\n", c, c->text->get());
|
|
||||||
if (strcmp(de->file,c->file) == 0) {
|
|
||||||
|
|
||||||
// At least comment is in the right file. Now check line numbers
|
|
||||||
|
|
||||||
if (ch->location == BEFORE) {
|
|
||||||
|
|
||||||
// Check to see if the last line of the comment is close
|
|
||||||
// enough to our declaration.
|
|
||||||
|
|
||||||
if ((c->last_line <= de->line_number) &&
|
|
||||||
((de->line_number - c->last_line) <= ch->skip_lines)) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
} else { // AFTER mode
|
|
||||||
// Check to see if the first line of the comment is close
|
|
||||||
// enough to our declaration.
|
|
||||||
|
|
||||||
if ((c->first_line >= de->end_line) &&
|
|
||||||
((c->first_line - de->end_line) <= ch->skip_lines)) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check to see if the line numbers are too small. Comments
|
|
||||||
// are processed in order so there's no sense in checking
|
|
||||||
// all entries.
|
|
||||||
|
|
||||||
if (c->last_line < de->line_number)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
c = c->next;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// void attach(DocEntry *de, CommentHandler *ch)
|
|
||||||
//
|
|
||||||
// This function attachs a comment to a documentation entry and applies
|
|
||||||
// all of the style information in the comment handler.
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
void Comment::attach(DocEntry *de, CommentHandler *ch) {
|
|
||||||
int nlines = 0;
|
|
||||||
char **split = 0;
|
|
||||||
char *c;
|
|
||||||
int i,lnum,el;
|
|
||||||
if (!de) return;
|
|
||||||
|
|
||||||
// If we're ignoring comments, forget it
|
|
||||||
if (ch->ignore) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the comment is formatted, no style processing is applied
|
|
||||||
|
|
||||||
if (de->format) {
|
|
||||||
de->text << *text;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Untabify the comment
|
|
||||||
|
|
||||||
if (ch->untabify) text->untabify();
|
|
||||||
|
|
||||||
// Count how many lines we have
|
|
||||||
|
|
||||||
c = text->get();
|
|
||||||
while (*c) {
|
|
||||||
if (*c == '\n') nlines++;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nlines == 0) return;
|
|
||||||
|
|
||||||
// Tokenize the documentation string into lines
|
|
||||||
|
|
||||||
split = new char*[nlines+1];
|
|
||||||
c = text->get();
|
|
||||||
i = 0;
|
|
||||||
split[i] = c;
|
|
||||||
while (*c) {
|
|
||||||
if (*c == '\n') {
|
|
||||||
*(c++) = 0;
|
|
||||||
split[++i] = c;
|
|
||||||
} else c++;
|
|
||||||
}
|
|
||||||
lnum = 0;
|
|
||||||
|
|
||||||
// Now process the chop_top and chop_bottom values
|
|
||||||
// if nlines < (chop_top + chop_bottom), then we do nothing
|
|
||||||
|
|
||||||
if (nlines > (ch->chop_top + ch->chop_bottom)) {
|
|
||||||
lnum += ch->chop_top;
|
|
||||||
el = nlines-ch->chop_bottom;
|
|
||||||
} else {
|
|
||||||
el = nlines;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now process in-between lines
|
|
||||||
|
|
||||||
while (lnum < el) {
|
|
||||||
/* Chop line */
|
|
||||||
if (split[lnum]) {
|
|
||||||
if (strlen(split[lnum]) > (unsigned) (ch->chop_left+ch->chop_right)) {
|
|
||||||
if (ch->chop_right > 0)
|
|
||||||
split[lnum][strlen(split[lnum]) - ch->chop_right] = 0;
|
|
||||||
de->text << &split[lnum][ch->chop_left];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lnum++;
|
|
||||||
de->text << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// printf("*** ATTACHING %s : %s\n", de->usage.get(), de->text.get());
|
|
||||||
delete split;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CommentHandler *comment_handler = 0;
|
|
||||||
Comment *Comment::comment_list = 0;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// struct DocEntryList
|
|
||||||
//
|
|
||||||
// This structure manages a linked list of documentation entries that
|
|
||||||
// haven't had comments attached to them yet.
|
|
||||||
//
|
|
||||||
// As a general rule, this list tends to remain rather short.
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
struct DocEntryList {
|
|
||||||
DocEntry *de;
|
|
||||||
CommentHandler *ch;
|
|
||||||
DocEntryList *next;
|
|
||||||
DocEntryList *prev;
|
|
||||||
static DocEntryList *doc_list;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// Create a new list entry
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
DocEntryList(DocEntry *d, CommentHandler *c) {
|
|
||||||
|
|
||||||
de = d;
|
|
||||||
ch = c;
|
|
||||||
next = doc_list;
|
|
||||||
prev = 0;
|
|
||||||
if (doc_list)
|
|
||||||
doc_list->prev = this;
|
|
||||||
doc_list = this;
|
|
||||||
|
|
||||||
// Only allow a few doc entries to survive
|
|
||||||
|
|
||||||
if (this->next) {
|
|
||||||
if (this->next->next) {
|
|
||||||
delete this->next->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// Destroy a list entry
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
~DocEntryList() {
|
|
||||||
if (prev) {
|
|
||||||
prev->next = next;
|
|
||||||
}
|
|
||||||
if (next) {
|
|
||||||
next->prev = prev;
|
|
||||||
}
|
|
||||||
if (this == doc_list) doc_list = next;
|
|
||||||
};
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// static check()
|
|
||||||
//
|
|
||||||
// Checks the list of documentation entries to see if any can be associated.
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void check() {
|
|
||||||
|
|
||||||
DocEntryList *dl, *dl_temp;
|
|
||||||
Comment *cmt;
|
|
||||||
|
|
||||||
// printf ("Checking\n");
|
|
||||||
dl = doc_list;
|
|
||||||
while (dl) {
|
|
||||||
cmt = Comment::find(dl->de,dl->ch);
|
|
||||||
if (cmt) {
|
|
||||||
// Okay, we found a matching comment. Attach it to this
|
|
||||||
// documentation entry.
|
|
||||||
cmt->attach(dl->de,dl->ch);
|
|
||||||
|
|
||||||
// Destroy the comment and doc list entry
|
|
||||||
delete cmt;
|
|
||||||
|
|
||||||
// Declarations are always coming in order so we're going
|
|
||||||
// to blow away all of them past this point
|
|
||||||
|
|
||||||
dl_temp = dl->next;
|
|
||||||
delete dl;
|
|
||||||
dl = dl_temp;
|
|
||||||
} else {
|
|
||||||
dl = dl->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
DocEntryList *DocEntryList::doc_list = 0;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// CommentHandler::CommentHandler()
|
|
||||||
//
|
|
||||||
// Constructor. Creates a new comment handler. Sets up some default values
|
|
||||||
// for comment handling.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CommentHandler::CommentHandler() {
|
|
||||||
skip_lines = 1;
|
|
||||||
location = AFTER;
|
|
||||||
chop_top = 0;
|
|
||||||
chop_bottom = 0;
|
|
||||||
chop_left = 3;
|
|
||||||
chop_right = 0;
|
|
||||||
untabify = 1;
|
|
||||||
ignore = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// CommentHandler::CommentHandler(CommentHandler *c)
|
|
||||||
//
|
|
||||||
// Constructor. Creates a new comment handler, but copies attributes from
|
|
||||||
// another handler.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CommentHandler::CommentHandler(CommentHandler *c) {
|
|
||||||
skip_lines = c->skip_lines;
|
|
||||||
location = c->location;
|
|
||||||
chop_top = c->chop_top;
|
|
||||||
chop_bottom = c->chop_bottom;
|
|
||||||
chop_left = c->chop_left;
|
|
||||||
chop_right = c->chop_right;
|
|
||||||
untabify = c->untabify;
|
|
||||||
ignore = c->ignore;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// CommentHandler::~CommentHandler()
|
|
||||||
//
|
|
||||||
// Destructor. Destroys a comment handler. Does nothing interesting at the
|
|
||||||
// moment.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CommentHandler::~CommentHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void CommentHandler::add_comment(char *text, int line_num, int col, char *file)
|
|
||||||
//
|
|
||||||
// This function takes a character string as comment text and appends
|
|
||||||
// it to the current comment string (which is held in Comment::comment_list)
|
|
||||||
//
|
|
||||||
// 1. If two comments appear in successive lines, they are
|
|
||||||
// concatenated. This is to handle C++ style comments like the
|
|
||||||
// one surrounding this text.
|
|
||||||
//
|
|
||||||
// 2. If a new comment appears, we simply create a new one
|
|
||||||
//
|
|
||||||
// Inputs :
|
|
||||||
// text = Text of the comment
|
|
||||||
// line_num = Starting line number of the comment
|
|
||||||
// col = Starting column of the comment
|
|
||||||
// file = File in which the comment was located.
|
|
||||||
//
|
|
||||||
// Side Effects :
|
|
||||||
// Saves the comment in an internal linked list.
|
|
||||||
// If multiple comments appear in succession, some may end up
|
|
||||||
// in our comment list permanently (ie. never attached to any
|
|
||||||
// particular declaration).
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void CommentHandler::add_comment(char *text, int line_num, int col, char *file) {
|
|
||||||
|
|
||||||
char *c;
|
|
||||||
int nlines = 0;
|
|
||||||
Comment *cmt;
|
|
||||||
|
|
||||||
// printf("line_num = %d, %s\n", line_num,text);
|
|
||||||
|
|
||||||
// Count up how many lines are in this comment
|
|
||||||
|
|
||||||
c = text;
|
|
||||||
while (*c) {
|
|
||||||
if (*c == '\n') nlines++;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to see if this comment is in a successive line to the last one
|
|
||||||
|
|
||||||
cmt = Comment::comment_list;
|
|
||||||
|
|
||||||
if (cmt) {
|
|
||||||
|
|
||||||
// Check for column alignment
|
|
||||||
if ((cmt->column == col) && (line_num == (cmt->last_line + 1)) &&
|
|
||||||
(nlines <= 1)) {
|
|
||||||
*(cmt->text) << text;
|
|
||||||
cmt->last_line = line_num + nlines - 1;
|
|
||||||
} else {
|
|
||||||
// This is a new comment, add it to our list
|
|
||||||
cmt = new Comment(text,line_num,col,file);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cmt = new Comment(text,line_num,col,file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void CommentHanlder::set_entry(DocEntry *d)
|
|
||||||
//
|
|
||||||
// This grabs a DocEntry and hangs onto it.
|
|
||||||
//
|
|
||||||
// We will place the doc entry into our documentation list and then
|
|
||||||
// check it to see if any comments are sitting around.
|
|
||||||
//
|
|
||||||
// Side Effects :
|
|
||||||
// May attach comments to the documentation entry. In this case,
|
|
||||||
// comments and DocEntries may be removed from internal lists.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void CommentHandler::set_entry(DocEntry *d) {
|
|
||||||
|
|
||||||
// printf("Set entry : file: %s, line %d, %s\n", d->file, d->line_number, d->usage.get());
|
|
||||||
|
|
||||||
// Create a new list entry and save it
|
|
||||||
|
|
||||||
new DocEntryList(d,this);
|
|
||||||
|
|
||||||
// Check all of the documentation entries to see if they can be placed
|
|
||||||
|
|
||||||
DocEntryList::check();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// static void CommentHandler::cleanup()
|
|
||||||
//
|
|
||||||
// Checks all documentation entries and sees if there are any comments available.
|
|
||||||
// If so, they are attached. This function is usually only called upon completion
|
|
||||||
// of parsing.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void CommentHandler::cleanup() {
|
|
||||||
int nc, nd;
|
|
||||||
Comment *c;
|
|
||||||
DocEntryList *d;
|
|
||||||
|
|
||||||
DocEntryList::check();
|
|
||||||
|
|
||||||
// Figure out how bad we're doing on memory
|
|
||||||
|
|
||||||
nc = 0;
|
|
||||||
nd = 0;
|
|
||||||
c = Comment::comment_list;
|
|
||||||
while (c) {
|
|
||||||
nc++;
|
|
||||||
c = c->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
d = DocEntryList::doc_list;
|
|
||||||
while(d) {
|
|
||||||
nd++;
|
|
||||||
d = d->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Verbose) {
|
|
||||||
printf("%d unprocessed comments, %d unprocessed doc entries.\n",nc,nd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void CommentHandler::style(char *name, char *value)
|
|
||||||
//
|
|
||||||
// Processes comment handling style parameters. The following parameters
|
|
||||||
// are available :
|
|
||||||
//
|
|
||||||
// after - Comments appear after a declaration
|
|
||||||
// before - Comments appear before a declaration
|
|
||||||
// skip - Number of blank lines between comment and decl.
|
|
||||||
// chop_top - Number of lines to chop from top of a comment
|
|
||||||
// chop_bottom - Number of lines to chop from bottom of a comment
|
|
||||||
// chop_left - Number of characters to chop from left
|
|
||||||
// chop_right - Number of characters to chop from right
|
|
||||||
// tabify - Leave tabs in comment text
|
|
||||||
// untabify - Strip tabs and convert them into spaces.
|
|
||||||
// ignore - Ignore comments
|
|
||||||
// enable - Enable comments
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void CommentHandler::style(char *name, char *value) {
|
|
||||||
|
|
||||||
if (strcmp(name,"before") == 0) {
|
|
||||||
location = BEFORE;
|
|
||||||
} else if (strcmp(name,"after") == 0) {
|
|
||||||
location = AFTER;
|
|
||||||
} else if (strcmp(name,"skip") == 0) {
|
|
||||||
if (value)
|
|
||||||
skip_lines = atoi(value);
|
|
||||||
} else if (strcmp(name,"chop_top") == 0) {
|
|
||||||
if (value)
|
|
||||||
chop_top = atoi(value);
|
|
||||||
} else if (strcmp(name,"chop_bottom") == 0) {
|
|
||||||
if (value)
|
|
||||||
chop_bottom = atoi(value);
|
|
||||||
} else if (strcmp(name,"chop_left") == 0) {
|
|
||||||
if (value)
|
|
||||||
chop_left = atoi(value);
|
|
||||||
} else if (strcmp(name,"chop_right") == 0) {
|
|
||||||
if (value)
|
|
||||||
chop_right = atoi(value);
|
|
||||||
} else if (strcmp(name,"tabify") == 0) {
|
|
||||||
untabify = 0;
|
|
||||||
} else if (strcmp(name,"untabify") == 0) {
|
|
||||||
untabify = 1;
|
|
||||||
} else if (strcmp(name,"ignore") == 0) {
|
|
||||||
ignore = 1;
|
|
||||||
} else if (strcmp(name,"enable") == 0) {
|
|
||||||
ignore = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void CommentHandler::parse_args(int argc, char **argv)
|
|
||||||
//
|
|
||||||
// Function for processing command line options given on the SWIG command line.
|
|
||||||
// See the help string below for available options.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static char *comment_usage = "\
|
|
||||||
Comment Style Options : \n\
|
|
||||||
-Safter - Use comments after a declaration.\n\
|
|
||||||
-Sbefore - Use comments before a declaration.\n\
|
|
||||||
-Schop_bottom n - Chop n lines from bottom of comments.\n\
|
|
||||||
-Schop_left n - Chop n characters from left of a comment.\n\
|
|
||||||
-Schop_right n - Chop n characters from right of a comment.\n\
|
|
||||||
-Schop_top n - Chop n lines from top of comments.\n\
|
|
||||||
-Signore - Ignore comments.\n\
|
|
||||||
-Sskip n - Max lines between comment and declaration.\n\
|
|
||||||
-Stabify - Do not convert tabs.\n\
|
|
||||||
-Suntabify - Convert tabs into spaces (the default).\n\n";
|
|
||||||
|
|
||||||
void CommentHandler::parse_args(int argc, char **argv) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
|
||||||
if (argv[i]) {
|
|
||||||
if (strcmp(argv[i],"-Sbefore") == 0) {
|
|
||||||
this->style("before",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Safter") == 0) {
|
|
||||||
this->style("after",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Schop_top") == 0) {
|
|
||||||
if (argv[i+1]) {
|
|
||||||
this->style("chop_top",argv[i+1]);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
Swig_mark_arg(i+1);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
Swig_arg_error();
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i],"-Schop_bottom") == 0) {
|
|
||||||
if (argv[i+1]) {
|
|
||||||
this->style("chop_bottom",argv[i+1]);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
Swig_mark_arg(i+1);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
Swig_arg_error();
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i],"-Schop_left") == 0) {
|
|
||||||
if (argv[i+1]) {
|
|
||||||
this->style("chop_left",argv[i+1]);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
Swig_mark_arg(i+1);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
Swig_arg_error();
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i],"-Schop_right") == 0) {
|
|
||||||
if (argv[i+1]) {
|
|
||||||
this->style("chop_right",argv[i+1]);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
Swig_mark_arg(i+1);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
Swig_arg_error();
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i],"-Sskip") == 0) {
|
|
||||||
if (argv[i+1]) {
|
|
||||||
this->style("skip",argv[i+1]);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
Swig_mark_arg(i+1);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
Swig_arg_error();
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i],"-Suntabify") == 0) {
|
|
||||||
this->style("untabify",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Stabify") == 0) {
|
|
||||||
this->style("tabify",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Signore") == 0) {
|
|
||||||
this->style("ignore",0);
|
|
||||||
} else if (strcmp(argv[i],"-help") == 0) {
|
|
||||||
fputs(comment_usage,stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +1,23 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* cplus.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* This file contains code for C++ support in SWIG1.1. Beware!
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
static char cvstag[] = "$Header$";
|
static char cvstag[] = "$Header$";
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* $Header$
|
* Note:
|
||||||
*
|
|
||||||
* File : cplus.cxx
|
|
||||||
*
|
|
||||||
* This module defines parser entry points for supporting C++. Primarily
|
|
||||||
* this module is in charge of keeping track of the contents of C++ classes,
|
|
||||||
* organizing inheritance, and other things.
|
|
||||||
*
|
|
||||||
* Eventually this module will be merged with the type handling mechanism
|
|
||||||
* in SWIG 2.0 so it's a little messy right now.
|
|
||||||
*
|
|
||||||
* General comments :
|
|
||||||
*
|
|
||||||
* 1. The words "simple" and "C++" are rarely used in the same
|
|
||||||
* sentence. Therefore this module is going to be some sort
|
|
||||||
* of compromise.
|
|
||||||
*
|
|
||||||
* 2. I'm using the "Annotated C++ Reference Manual" (ARM) as my
|
|
||||||
* reference for handling certain cases. Of course, there
|
|
||||||
* is a high probability that I have misinterpreted or overlooked
|
|
||||||
* certain cases.
|
|
||||||
*
|
|
||||||
* 3. It is not my intent to write a full C++ compiler.
|
|
||||||
*
|
|
||||||
* My goals are simple :
|
|
||||||
* - Support simple ANSI C-like class member functions and data.
|
|
||||||
* - Support constructors and destructors.
|
|
||||||
* - static member functions.
|
|
||||||
* - basic inheritance.
|
|
||||||
* - virtual functions.
|
|
||||||
* - References
|
|
||||||
*
|
|
||||||
* I do not plan to support the following anytime in the near future
|
|
||||||
* - Operator overloading
|
|
||||||
* - templates
|
|
||||||
*
|
|
||||||
* Caution :
|
|
||||||
*
|
*
|
||||||
* The control flow in this module is completely insane. But here's the
|
* The control flow in this module is completely insane. But here's the
|
||||||
* rough outline.
|
* rough outline.
|
||||||
|
|
@ -222,7 +185,6 @@ public:
|
||||||
char *code; // Was there any supplied code?
|
char *code; // Was there any supplied code?
|
||||||
char *base; // Base class where this was defined
|
char *base; // Base class where this was defined
|
||||||
int inherited; // Was this member inherited?
|
int inherited; // Was this member inherited?
|
||||||
DocEntry *de; // Documentation entry
|
|
||||||
CPP_member *next; // Next member (for building linked lists)
|
CPP_member *next; // Next member (for building linked lists)
|
||||||
int id; // type id when created
|
int id; // type id when created
|
||||||
|
|
||||||
|
|
@ -253,7 +215,6 @@ public:
|
||||||
new_method = AddMethods;
|
new_method = AddMethods;
|
||||||
new_object = NewObject;
|
new_object = NewObject;
|
||||||
inherited = Inherit_mode;
|
inherited = Inherit_mode;
|
||||||
de = 0;
|
|
||||||
next = 0;
|
next = 0;
|
||||||
line = line_number;
|
line = line_number;
|
||||||
file = input_file;
|
file = input_file;
|
||||||
|
|
@ -272,7 +233,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void inherit(int mode) {
|
void inherit(int mode) {
|
||||||
doc_entry = 0; // No documentation for an inherited member
|
|
||||||
if (mode & INHERIT_FUNC) {
|
if (mode & INHERIT_FUNC) {
|
||||||
// Set up the proper addmethods mode and provide C code (if provided)
|
// Set up the proper addmethods mode and provide C code (if provided)
|
||||||
int oldaddmethods = AddMethods;
|
int oldaddmethods = AddMethods;
|
||||||
|
|
@ -295,7 +255,6 @@ public:
|
||||||
DataType *t;
|
DataType *t;
|
||||||
AddMethods = new_method;
|
AddMethods = new_method;
|
||||||
NewObject = new_object;
|
NewObject = new_object;
|
||||||
doc_entry = de; // Restore documentation entry
|
|
||||||
line_number = line; // Restore line and file
|
line_number = line; // Restore line and file
|
||||||
input_file = file;
|
input_file = file;
|
||||||
ccode = code;
|
ccode = code;
|
||||||
|
|
@ -331,7 +290,6 @@ public:
|
||||||
parms = new ParmList(l);
|
parms = new ParmList(l);
|
||||||
new_method = AddMethods;
|
new_method = AddMethods;
|
||||||
inherited = 0;
|
inherited = 0;
|
||||||
de = 0;
|
|
||||||
next = 0;
|
next = 0;
|
||||||
line = line_number;
|
line = line_number;
|
||||||
file = input_file;
|
file = input_file;
|
||||||
|
|
@ -349,7 +307,6 @@ public:
|
||||||
if (1) {
|
if (1) {
|
||||||
ParmList *l;
|
ParmList *l;
|
||||||
AddMethods = new_method;
|
AddMethods = new_method;
|
||||||
doc_entry = de;
|
|
||||||
line_number = line;
|
line_number = line;
|
||||||
input_file = file;
|
input_file = file;
|
||||||
ccode = code;
|
ccode = code;
|
||||||
|
|
@ -360,11 +317,6 @@ public:
|
||||||
update_parms(l);
|
update_parms(l);
|
||||||
lang->cpp_constructor(name,iname,l);
|
lang->cpp_constructor(name,iname,l);
|
||||||
delete l;
|
delete l;
|
||||||
} else {
|
|
||||||
if (Verbose) {
|
|
||||||
fprintf(stderr,"%s:%d: Constructor for abstract base class ignored.\n",
|
|
||||||
file,line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -383,7 +335,6 @@ public:
|
||||||
name = copy_string(n);
|
name = copy_string(n);
|
||||||
iname = copy_string(i);
|
iname = copy_string(i);
|
||||||
new_method = AddMethods;
|
new_method = AddMethods;
|
||||||
de = 0;
|
|
||||||
next = 0;
|
next = 0;
|
||||||
inherited = 0;
|
inherited = 0;
|
||||||
line = line_number;
|
line = line_number;
|
||||||
|
|
@ -401,7 +352,6 @@ public:
|
||||||
}
|
}
|
||||||
void emit() {
|
void emit() {
|
||||||
AddMethods = new_method;
|
AddMethods = new_method;
|
||||||
doc_entry = de;
|
|
||||||
line_number = line;
|
line_number = line;
|
||||||
input_file = file;
|
input_file = file;
|
||||||
ccode = code;
|
ccode = code;
|
||||||
|
|
@ -425,7 +375,6 @@ public:
|
||||||
type = new DataType(t);
|
type = new DataType(t);
|
||||||
is_static = s;
|
is_static = s;
|
||||||
status = Status;
|
status = Status;
|
||||||
de = 0;
|
|
||||||
next = 0;
|
next = 0;
|
||||||
new_method = AddMethods;
|
new_method = AddMethods;
|
||||||
line = line_number;
|
line = line_number;
|
||||||
|
|
@ -444,7 +393,6 @@ public:
|
||||||
void emit() {
|
void emit() {
|
||||||
DataType *t;
|
DataType *t;
|
||||||
int old_status = Status;
|
int old_status = Status;
|
||||||
doc_entry = de;
|
|
||||||
AddMethods = new_method;
|
AddMethods = new_method;
|
||||||
Status = status;
|
Status = status;
|
||||||
line_number = line;
|
line_number = line;
|
||||||
|
|
@ -470,7 +418,6 @@ public:
|
||||||
void inherit(int mode) {
|
void inherit(int mode) {
|
||||||
int oldstatus = Status;
|
int oldstatus = Status;
|
||||||
Status = status;
|
Status = status;
|
||||||
doc_entry = 0;
|
|
||||||
if (mode & INHERIT_VAR) {
|
if (mode & INHERIT_VAR) {
|
||||||
if (!is_static) {
|
if (!is_static) {
|
||||||
int oldaddmethods = AddMethods;
|
int oldaddmethods = AddMethods;
|
||||||
|
|
@ -502,7 +449,6 @@ public:
|
||||||
iname = copy_string(i);
|
iname = copy_string(i);
|
||||||
type = new DataType(t);
|
type = new DataType(t);
|
||||||
value = copy_string(v);
|
value = copy_string(v);
|
||||||
de = 0;
|
|
||||||
new_method = AddMethods;
|
new_method = AddMethods;
|
||||||
next = 0;
|
next = 0;
|
||||||
line = line_number;
|
line = line_number;
|
||||||
|
|
@ -516,7 +462,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void emit() {
|
void emit() {
|
||||||
doc_entry = de;
|
|
||||||
AddMethods = new_method;
|
AddMethods = new_method;
|
||||||
line_number = line;
|
line_number = line;
|
||||||
input_file = file;
|
input_file = file;
|
||||||
|
|
@ -525,7 +470,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void inherit(int mode) {
|
void inherit(int mode) {
|
||||||
doc_entry = 0;
|
|
||||||
if (mode & INHERIT_CONST)
|
if (mode & INHERIT_CONST)
|
||||||
cplus_declare_const(name, iname, type, value);
|
cplus_declare_const(name, iname, type, value);
|
||||||
}
|
}
|
||||||
|
|
@ -556,7 +500,6 @@ public:
|
||||||
char **baseclass; // Base classes (if any)
|
char **baseclass; // Base classes (if any)
|
||||||
Hash *local; // Hash table for local types
|
Hash *local; // Hash table for local types
|
||||||
void *scope; // Local scope hash table
|
void *scope; // Local scope hash table
|
||||||
DocEntry *de; // Documentation entry of class
|
|
||||||
CPP_member *members; // Linked list of members
|
CPP_member *members; // Linked list of members
|
||||||
CPP_class *next; // Next class
|
CPP_class *next; // Next class
|
||||||
static CPP_class *classlist; // List of all classes stored
|
static CPP_class *classlist; // List of all classes stored
|
||||||
|
|
@ -568,7 +511,6 @@ public:
|
||||||
classtype = copy_string(ctype);
|
classtype = copy_string(ctype);
|
||||||
classrename = 0;
|
classrename = 0;
|
||||||
baseclass = 0;
|
baseclass = 0;
|
||||||
de = doc_entry;
|
|
||||||
local = new Hash; // Create hash table for storing local datatypes
|
local = new Hash; // Create hash table for storing local datatypes
|
||||||
scope = 0;
|
scope = 0;
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
@ -657,15 +599,12 @@ public:
|
||||||
|
|
||||||
void emit_decls() {
|
void emit_decls() {
|
||||||
CPP_member *m = members;
|
CPP_member *m = members;
|
||||||
int last_scope = name_scope(0);
|
|
||||||
abstract = is_abstract;
|
abstract = is_abstract;
|
||||||
while (m) {
|
while (m) {
|
||||||
cpp_id = m->id;
|
cpp_id = m->id;
|
||||||
name_scope(cpp_id); // Set proper naming scope
|
|
||||||
m->emit();
|
m->emit();
|
||||||
m = m->next;
|
m = m->next;
|
||||||
}
|
}
|
||||||
name_scope(last_scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
@ -697,12 +636,10 @@ public:
|
||||||
if ((!have_constructor) && (1)) {
|
if ((!have_constructor) && (1)) {
|
||||||
ParmList *l;
|
ParmList *l;
|
||||||
l = new ParmList();
|
l = new ParmList();
|
||||||
doc_entry = new DocDecl(classname,this->de);
|
|
||||||
cplus_constructor(classname,0,l);
|
cplus_constructor(classname,0,l);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!have_destructor) {
|
if (!have_destructor) {
|
||||||
doc_entry = new DocDecl(classname,this->de);
|
|
||||||
cplus_destructor(classname,0);
|
cplus_destructor(classname,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -726,14 +663,12 @@ void CPP_class::create_all() {
|
||||||
localtypes = c->local;
|
localtypes = c->local;
|
||||||
if ((!c->wextern) && (c->classtype)) {
|
if ((!c->wextern) && (c->classtype)) {
|
||||||
ObjCClass = c->objective_c;
|
ObjCClass = c->objective_c;
|
||||||
doc_entry = c->de;
|
|
||||||
lang->cpp_open_class(c->classname,c->classrename,c->classtype,c->strip);
|
lang->cpp_open_class(c->classname,c->classrename,c->classtype,c->strip);
|
||||||
lang->cpp_pragma(c->pragmas);
|
lang->cpp_pragma(c->pragmas);
|
||||||
c->create_default();
|
c->create_default();
|
||||||
if (c->baseclass)
|
if (c->baseclass)
|
||||||
cplus_inherit_decl(c->baseclass);
|
cplus_inherit_decl(c->baseclass);
|
||||||
c->emit_decls();
|
c->emit_decls();
|
||||||
doc_entry = c->de;
|
|
||||||
lang->cpp_close_class();
|
lang->cpp_close_class();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -800,7 +735,6 @@ void cplus_open_class(char *name, char *rname, char *ctype) {
|
||||||
} else {
|
} else {
|
||||||
// Create a new class
|
// Create a new class
|
||||||
current_class = new CPP_class(name, ctype);
|
current_class = new CPP_class(name, ctype);
|
||||||
current_class->de = doc_entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set localtypes hash to our current class
|
// Set localtypes hash to our current class
|
||||||
|
|
@ -830,7 +764,7 @@ void cplus_open_class(char *name, char *rname, char *ctype) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// DocEntry *cplus_set_class(char *name)
|
// void cplus_set_class(char *name)
|
||||||
//
|
//
|
||||||
// This function sets the current class to a given name. If the class
|
// This function sets the current class to a given name. If the class
|
||||||
// doesn't exist, this function will create one. If it already exists,
|
// doesn't exist, this function will create one. If it already exists,
|
||||||
|
|
@ -845,22 +779,9 @@ void cplus_open_class(char *name, char *rname, char *ctype) {
|
||||||
// ... members ...
|
// ... members ...
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Sounds weird, but returns the documentation entry to class if it exists.
|
|
||||||
// The parser needs this so we can generate documentation correctly.
|
|
||||||
//
|
|
||||||
// Inputs : name = Name of the class
|
|
||||||
//
|
|
||||||
// Output : Documentation entry of class or NULL if it doesn't exist.
|
|
||||||
// The parser needs the documentation entry to properly associate
|
|
||||||
// new members.
|
|
||||||
//
|
|
||||||
// Side Effects :
|
|
||||||
// Changes the current class object. Resets a number of internal
|
|
||||||
// state variables. Should not be called inside of a open class
|
|
||||||
// declaration.
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
DocEntry *cplus_set_class(char *name) {
|
void cplus_set_class(char *name) {
|
||||||
|
|
||||||
CPP_class *c;
|
CPP_class *c;
|
||||||
|
|
||||||
|
|
@ -870,12 +791,10 @@ DocEntry *cplus_set_class(char *name) {
|
||||||
if (c) {
|
if (c) {
|
||||||
current_class = c;
|
current_class = c;
|
||||||
localtypes = c->local;
|
localtypes = c->local;
|
||||||
return c->de;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"%s:%d: Warning class %s undefined.\n",input_file,line_number,name);
|
fprintf(stderr,"%s:%d: Warning class %s undefined.\n",input_file,line_number,name);
|
||||||
current_class = new CPP_class(name,0);
|
current_class = new CPP_class(name,0);
|
||||||
localtypes = current_class->local;
|
localtypes = current_class->local;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1203,7 +1122,6 @@ void cplus_member_func(char *name, char *iname, DataType *type, ParmList *l,
|
||||||
// Add it to our C++ class list
|
// Add it to our C++ class list
|
||||||
|
|
||||||
f = new CPP_function(name,temp_iname,type,l,0,is_virtual);
|
f = new CPP_function(name,temp_iname,type,l,0,is_virtual);
|
||||||
f->de = doc_entry;
|
|
||||||
current_class->add_member(f);
|
current_class->add_member(f);
|
||||||
|
|
||||||
// If this is a pure virtual function, the class is abstract
|
// If this is a pure virtual function, the class is abstract
|
||||||
|
|
@ -1236,7 +1154,6 @@ void cplus_constructor(char *name, char *iname, ParmList *l) {
|
||||||
// May want to check the naming scheme here
|
// May want to check the naming scheme here
|
||||||
|
|
||||||
c = new CPP_constructor(name,iname,l);
|
c = new CPP_constructor(name,iname,l);
|
||||||
c->de = doc_entry;
|
|
||||||
current_class->add_member(c);
|
current_class->add_member(c);
|
||||||
current_class->have_constructor = 1;
|
current_class->have_constructor = 1;
|
||||||
|
|
||||||
|
|
@ -1263,7 +1180,6 @@ void cplus_destructor(char *name, char *iname) {
|
||||||
CPP_destructor *d;
|
CPP_destructor *d;
|
||||||
|
|
||||||
d = new CPP_destructor(name,iname);
|
d = new CPP_destructor(name,iname);
|
||||||
d->de = doc_entry;
|
|
||||||
current_class->add_member(d);
|
current_class->add_member(d);
|
||||||
current_class->have_destructor = 1;
|
current_class->have_destructor = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -1303,7 +1219,6 @@ void cplus_variable(char *name, char *iname, DataType *t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
v = new CPP_variable(name,iname,t,0);
|
v = new CPP_variable(name,iname,t,0);
|
||||||
v->de = doc_entry;
|
|
||||||
current_class->add_member(v);
|
current_class->add_member(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1342,7 +1257,6 @@ void cplus_static_func(char *name, char *iname, DataType *type, ParmList *l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CPP_function *f = new CPP_function(name, temp_iname, type, l, 1);
|
CPP_function *f = new CPP_function(name, temp_iname, type, l, 1);
|
||||||
f->de = doc_entry;
|
|
||||||
current_class->add_member(f);
|
current_class->add_member(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1381,7 +1295,6 @@ void cplus_declare_const(char *name, char *iname, DataType *type, char *value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CPP_constant *c = new CPP_constant(name, temp_iname, type, value);
|
CPP_constant *c = new CPP_constant(name, temp_iname, type, value);
|
||||||
c->de = doc_entry;
|
|
||||||
current_class->add_member(c);
|
current_class->add_member(c);
|
||||||
|
|
||||||
// Update this symbol in the symbol table
|
// Update this symbol in the symbol table
|
||||||
|
|
@ -1424,7 +1337,6 @@ void cplus_static_var(char *name, char *iname, DataType *type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CPP_variable *v = new CPP_variable(name, temp_iname, type, 1);
|
CPP_variable *v = new CPP_variable(name, temp_iname, type, 1);
|
||||||
v->de = doc_entry;
|
|
||||||
current_class->add_member(v);
|
current_class->add_member(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2535,34 +2447,6 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void cplus_support_doc(String &f)
|
|
||||||
//
|
|
||||||
// This function adds a supporting documentation entry to the
|
|
||||||
// end of a class. This should only be used if there is an
|
|
||||||
// alternative interface available or if additional information is needed.
|
|
||||||
//
|
|
||||||
// doc_entry should be set to the class entry before calling this. Otherwise,
|
|
||||||
// who knows where this text is going to end up!
|
|
||||||
//
|
|
||||||
// Inputs : f = String with additional text
|
|
||||||
//
|
|
||||||
// Output : None
|
|
||||||
//
|
|
||||||
// Side Effects :
|
|
||||||
// Adds a text block to the current documentation entry.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void cplus_support_doc(String &f) {
|
|
||||||
|
|
||||||
DocEntry *de;
|
|
||||||
if (doc_entry) {
|
|
||||||
de = new DocText(f.get(),doc_entry);
|
|
||||||
de->format = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// void cplus_register_type(char *typename)
|
// void cplus_register_type(char *typename)
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,21 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* emit.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Useful functions for emitting various pieces of code.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
static char cvsroot[] = "$Header$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* File : emit.cxx
|
|
||||||
*
|
|
||||||
* This file contains some useful functions for emitting code that would be
|
|
||||||
* common to all of the interface languages. Mainly this function deals with
|
|
||||||
* declaring functions external, creating lists of arguments, and making
|
|
||||||
* function calls.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// void emit_banner(FILE *f)
|
// void emit_banner(FILE *f)
|
||||||
//
|
//
|
||||||
|
|
@ -708,7 +698,6 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
||||||
}
|
}
|
||||||
delete l;
|
delete l;
|
||||||
delete p;
|
delete p;
|
||||||
if (doc_entry) doc_entry->usage << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now write a function to get the value of the variable
|
// Now write a function to get the value of the variable
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,22 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* hash.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Hash table object.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "doh.h"
|
#include "doh.h"
|
||||||
|
|
||||||
static char cvsroot[] = "$Header$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* File : hash.cxx
|
|
||||||
*
|
|
||||||
* This is now just a wrapper around the DOH hash table object.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
Hash::Hash() {
|
Hash::Hash() {
|
||||||
data = NewHash();
|
data = NewHash();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,132 +1,68 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* include.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* File inclusion functions. This file is deprecated. These are only a
|
||||||
|
* thin wrapper over the functions in Swig/include.c.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
extern "C" FILE *Swig_open(void *);
|
extern "C" FILE *Swig_open(void *);
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* $Header$
|
|
||||||
*
|
|
||||||
* File : include.cxx
|
|
||||||
*
|
|
||||||
* Code for including files into a wrapper file.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// void check_suffix(char *name)
|
// check_suffix(char *name)
|
||||||
//
|
//
|
||||||
// Checks the suffix of an include file to see if we need to handle it
|
// Checks the suffix of a file to see if we should emit extern declarations.
|
||||||
// differently. C and C++ source files need a little extra help.
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void check_suffix(char *name) {
|
int
|
||||||
|
check_suffix(char *name) {
|
||||||
char *c;
|
char *c;
|
||||||
|
if (!name) return 0;
|
||||||
if (!name) return;
|
if (strlen(name) == 0) return 0;
|
||||||
if (strlen(name) == 0) return;
|
|
||||||
c = name+strlen(name)-1;
|
c = name+strlen(name)-1;
|
||||||
while (c != name) {
|
while (c != name) {
|
||||||
if (*c == '.') break;
|
if (*c == '.') break;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
if (c == name) return;
|
if (c == name) return 0;
|
||||||
|
if ((strcmp(c,".c") == 0) ||
|
||||||
/* Check suffixes */
|
(strcmp(c,".C") == 0) ||
|
||||||
|
(strcmp(c,".cc") == 0) ||
|
||||||
if (strcmp(c,".c") == 0) {
|
(strcmp(c,".cxx") == 0) ||
|
||||||
ForceExtern = 1;
|
(strcmp(c,".c++") == 0) ||
|
||||||
} else if (strcmp(c,".C") == 0) {
|
(strcmp(c,".cpp") == 0)) {
|
||||||
ForceExtern = 1;
|
return 1;
|
||||||
} else if (strcmp(c,".cc") == 0) {
|
|
||||||
ForceExtern = 1;
|
|
||||||
} else if (strcmp(c,".cxx") == 0) {
|
|
||||||
ForceExtern = 1;
|
|
||||||
} else if (strcmp(c,".c++") == 0) {
|
|
||||||
ForceExtern = 1;
|
|
||||||
} else if (strcmp(c,".cpp") == 0) {
|
|
||||||
ForceExtern = 1;
|
|
||||||
} else {
|
|
||||||
ForceExtern = 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// void copy_data(FILE *f1, FILE *f2)
|
// int insert_file(char *filename, FILE *f)
|
||||||
//
|
|
||||||
// Copies data from file f1 to file f2.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static char buffer[1024];
|
|
||||||
|
|
||||||
void copy_data(FILE *f1, FILE *f2) {
|
|
||||||
|
|
||||||
while (fgets(buffer,1023,f1)) {
|
|
||||||
fputs(buffer, f2);
|
|
||||||
}
|
|
||||||
fclose(f1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void copy_data(FILE *f1, String *s2)
|
|
||||||
//
|
|
||||||
// Copies data from file f1 to String s2.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void copy_data(FILE *f1, String &s2) {
|
|
||||||
|
|
||||||
while (fgets(buffer,1023,f1)) {
|
|
||||||
s2 << buffer;
|
|
||||||
}
|
|
||||||
fclose(f1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// int insert_file(char *name, FILE *f)
|
|
||||||
//
|
|
||||||
// Looks for a file and inserts into file f.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
int insert_file(char *name, FILE *f_out) {
|
|
||||||
FILE *f;
|
|
||||||
f = Swig_open((void *) name);
|
|
||||||
if (f) {
|
|
||||||
copy_data(f,f_out);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// void swig_append(char *filename, FILE *f)
|
|
||||||
//
|
//
|
||||||
// Appends the contents of filename to stream f.
|
// Appends the contents of filename to stream f.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
int insert_file(char *filename, FILE *f) {
|
||||||
void swig_append(char *filename, FILE *f) {
|
|
||||||
FILE *in_file;
|
FILE *in_file;
|
||||||
if ((in_file = fopen(filename,"r")) == NULL) {
|
char buffer[1024];
|
||||||
fprintf(stderr,"** SWIG ERROR ** file %s not found.\n",filename);
|
if ((in_file = Swig_open((void *) filename)) == NULL) {
|
||||||
FatalError();
|
return -1;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
copy_data(in_file, f);
|
while (fgets(buffer,1023,in_file)) {
|
||||||
|
fputs(buffer, f);
|
||||||
|
}
|
||||||
|
fclose(in_file);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -136,13 +72,17 @@ void swig_append(char *filename, FILE *f) {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
int get_file(char *name, String &str) {
|
int get_file(char *name, String &str) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
char buffer[1024];
|
||||||
f = Swig_open((void *) name);
|
f = Swig_open((void *) name);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
fprintf(stderr,"SWIG Error. Unable to find %s. Possible installation problem.\n",name);
|
fprintf(stderr,"SWIG Error. Unable to find %s. Possible installation problem.\n",name);
|
||||||
FatalError();
|
FatalError();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
copy_data(f,str);
|
while (fgets(buffer,1023,f)) {
|
||||||
|
str << buffer;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,154 +1,31 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* internal.h
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Internal declarations used by the SWIG core
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* University of Chicago
|
*
|
||||||
* 1100 E 58th Street
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* Chicago, IL 60637
|
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
||||||
* beazley@cs.uchicago.edu
|
* University of California.
|
||||||
|
*
|
||||||
|
* See the file LICENSE for information on usage and redistribution.
|
||||||
*
|
*
|
||||||
* Please read the file LICENSE for the copyright and terms by which SWIG
|
|
||||||
* can be used and distributed.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* $Header$
|
* $Header$
|
||||||
*
|
* ----------------------------------------------------------------------------- */
|
||||||
* internals.h
|
|
||||||
*
|
|
||||||
* Contains global variables used in libswig, but which are otherwise
|
|
||||||
* inaccessible to the user.
|
|
||||||
*
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
#include "swig11.h"
|
#include "swig11.h"
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// class DocTitle : public DocEntry
|
|
||||||
//
|
|
||||||
// Top level class for managing documentation. Prints out a title,
|
|
||||||
// date, etc...
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DocTitle : public DocEntry {
|
|
||||||
public:
|
|
||||||
DocTitle(char *title, DocEntry *_parent); // Create a new title
|
|
||||||
void output(Documentation *d); // Output documentation
|
|
||||||
};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// class DocSection : public DocEntry
|
|
||||||
//
|
|
||||||
// Documentation entry for a section
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DocSection : public DocEntry {
|
|
||||||
public:
|
|
||||||
DocSection(char *section, DocEntry *_parent);
|
|
||||||
void output(Documentation *d);
|
|
||||||
};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// class DocFunction : public DocEntry
|
|
||||||
//
|
|
||||||
// Documentation entry for generic sorts of declarations
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DocDecl : public DocEntry {
|
|
||||||
public:
|
|
||||||
DocDecl(char *fname, DocEntry *_parent);
|
|
||||||
DocDecl(DocEntry *de, DocEntry *_parent);
|
|
||||||
void output(Documentation *d);
|
|
||||||
};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// class DocClass : public DocEntry
|
|
||||||
//
|
|
||||||
// Documentation entry for a C++ class or C struct
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DocClass : public DocEntry {
|
|
||||||
public:
|
|
||||||
DocClass(char *classname, DocEntry *_parent);
|
|
||||||
void output(Documentation *d);
|
|
||||||
};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// class DocText : public DocEntry
|
|
||||||
//
|
|
||||||
// Documentation entry for some plain ole text. Declared using
|
|
||||||
// the %text %{,%} directive.
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DocText : public DocEntry {
|
|
||||||
public:
|
|
||||||
DocText(char *_text, DocEntry *_parent);
|
|
||||||
void output(Documentation *d);
|
|
||||||
};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// class CommentHandler
|
|
||||||
//
|
|
||||||
// Class for managing comment processing.
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
class CommentHandler {
|
|
||||||
public:
|
|
||||||
CommentHandler();
|
|
||||||
CommentHandler(CommentHandler *c);
|
|
||||||
~CommentHandler();
|
|
||||||
void add_comment(char *text, int line_num, int col, char *file); // Add a comment
|
|
||||||
void set_entry(DocEntry *d); // Set documentation entry
|
|
||||||
static void cleanup(); // Clean-up everything before quitting
|
|
||||||
void style(char *name, char *value);
|
|
||||||
void parse_args(int argc, char **argv); // Parse command line options
|
|
||||||
|
|
||||||
// Comment handling style parameters
|
|
||||||
int skip_lines; // # blank lines before comment is throw away
|
|
||||||
int location; // Comment location (BEFORE or AFTER)
|
|
||||||
int chop_top; // Lines to chop from the top of a comment
|
|
||||||
int chop_bottom; // Lines to chop from the bottom
|
|
||||||
int chop_left; // Characters to chop from left
|
|
||||||
int chop_right; // Characters to chop from right
|
|
||||||
int untabify; // Expand tabs
|
|
||||||
int ignore; // Ignore comments
|
|
||||||
};
|
|
||||||
|
|
||||||
#define BEFORE 0
|
|
||||||
#define AFTER 1
|
|
||||||
|
|
||||||
|
|
||||||
extern int include_file(char *); // Insert library file
|
|
||||||
extern char category[256];
|
|
||||||
extern char title[256];
|
|
||||||
extern DocEntry *doc_entry;
|
|
||||||
extern DocEntry *doctitle; // The very first docentry
|
|
||||||
extern DocEntry *doc_stack[256]; // Stack of documentation entries
|
|
||||||
extern CommentHandler *handler_stack[256]; // Stack of comment handlers
|
|
||||||
extern int doc_stack_top; // Top of stack
|
|
||||||
|
|
||||||
extern Language *lang;
|
extern Language *lang;
|
||||||
extern Documentation *doc;
|
|
||||||
extern CommentHandler *comment_handler; // Comment handling system
|
|
||||||
extern void swig_append(char *, FILE *);
|
|
||||||
extern int Stat_func, Stat_var, Stat_const;
|
|
||||||
extern int IgnoreDoc;
|
|
||||||
extern int ForceExtern;
|
extern int ForceExtern;
|
||||||
extern int WrapExtern;
|
extern int WrapExtern;
|
||||||
extern String CCode;
|
extern String CCode;
|
||||||
extern int GenerateDefault;
|
extern int GenerateDefault;
|
||||||
extern int type_id;
|
extern int type_id;
|
||||||
extern char *ConfigFile;
|
|
||||||
extern char *objc_construct;
|
extern char *objc_construct;
|
||||||
extern char *objc_destruct;
|
extern char *objc_destruct;
|
||||||
extern int DocOnly;
|
|
||||||
|
|
||||||
// Structure for holding typemap parameters
|
// Structure for holding typemap parameters
|
||||||
// A typemap parameter consists of a single parameter (type + name)
|
|
||||||
// and an optional list of arguments corresponding to local variables.
|
|
||||||
// Has an optional link for building linked lists of parameter lists
|
|
||||||
|
|
||||||
struct TMParm {
|
struct TMParm {
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
@ -159,58 +36,6 @@ struct TMParm {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Global variables. Needs to be cleaned up */
|
|
||||||
|
|
||||||
#ifdef WRAP
|
|
||||||
|
|
||||||
FILE *f_runtime;
|
|
||||||
FILE *f_header; // Some commonly used
|
|
||||||
FILE *f_wrappers; // FILE pointers
|
|
||||||
FILE *f_init;
|
|
||||||
FILE *f_input;
|
|
||||||
char InitName[256];
|
|
||||||
char LibDir[512]; // Library directory
|
|
||||||
char **InitNames = 0;
|
|
||||||
int Status;
|
|
||||||
int TypeStrict; // Type checking strictness
|
|
||||||
int Verbose;
|
|
||||||
char category[256]; // Variables for documentation
|
|
||||||
char title[256];
|
|
||||||
DocEntry *doc_entry = 0; // Current documentation entry
|
|
||||||
DocEntry *doctitle = 0; // First doc entry
|
|
||||||
DocEntry *doc_stack[256]; // Stack of documentation entries
|
|
||||||
CommentHandler *handler_stack[256]; // Stack of comment handlers
|
|
||||||
int doc_stack_top = 0; // Top of stack
|
|
||||||
|
|
||||||
Language *lang; // Language method
|
|
||||||
Documentation *doc; // Documentation method
|
|
||||||
int Stat_func = 0;
|
|
||||||
int Stat_var = 0;
|
|
||||||
int Stat_const = 0;
|
|
||||||
int CPlusPlus = 0;
|
|
||||||
int ObjC = 0;
|
|
||||||
int ObjCClass = 0;
|
|
||||||
int AddMethods = 0; // AddMethods flag
|
|
||||||
int NewObject = 0; // NewObject flag
|
|
||||||
int Inline = 0; // Inline mode
|
|
||||||
int Stats = 0;
|
|
||||||
int IgnoreDoc = 0; // Ignore documentation mode
|
|
||||||
int ForceExtern = 0; // Force extern mode
|
|
||||||
int WrapExtern = 0;
|
|
||||||
int GenerateDefault = 0; // Generate default constructors
|
|
||||||
char *Config = 0;
|
|
||||||
int NoInclude = 0;
|
|
||||||
char *typemap_lang = 0; // Typemap name
|
|
||||||
int type_id = 0; // Type identifier
|
|
||||||
int error_count = 0; // Error count
|
|
||||||
char *ConfigFile = 0;
|
|
||||||
int DocOnly = 0; // Only produce documentation
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Number of initialization names that can be used */
|
/* Number of initialization names that can be used */
|
||||||
|
|
||||||
#define NI_NAMES 512
|
#define NI_NAMES 512
|
||||||
|
|
||||||
extern void type_undefined_check(void);
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,22 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* lang.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Language base class functions. Default C++ handling is also implemented here.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// $Header$
|
|
||||||
//
|
|
||||||
// lang.cxx
|
|
||||||
//
|
|
||||||
// This file contains some default methods for the SWIG language class.
|
|
||||||
// Default C++ handling is implemented here as well as a few utility functions.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// void Language::set_init(char *iname)
|
// void Language::set_init(char *iname)
|
||||||
//
|
//
|
||||||
|
|
@ -105,16 +93,6 @@ void Language::cpp_open_class(char *classname, char *classrename, char *ctype, i
|
||||||
ClassType = new char[strlen(ctype)+2];
|
ClassType = new char[strlen(ctype)+2];
|
||||||
if (strip) ClassType[0] = 0;
|
if (strip) ClassType[0] = 0;
|
||||||
else sprintf(ClassType,"%s ",ctype);
|
else sprintf(ClassType,"%s ",ctype);
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->usage = "";
|
|
||||||
doc_entry->name = copy_string(classname);
|
|
||||||
doc_entry->usage << "class ";
|
|
||||||
if (ClassRename) doc_entry->usage << ClassRename;
|
|
||||||
else doc_entry->usage << ClassName;
|
|
||||||
doc_entry->cinfo << "created from " << ctype
|
|
||||||
<< " " << classname;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
@ -192,11 +170,6 @@ void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l
|
||||||
input_file, line_number, cname, name);
|
input_file, line_number, cname, name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now produce the resulting wrapper function
|
|
||||||
if (doc_entry) {
|
|
||||||
doc_entry->cinfo << "Member : ";
|
|
||||||
}
|
|
||||||
cplus_emit_member_func(ClassName, ClassType, ClassRename, name, iname, t, l, AddMethods);
|
cplus_emit_member_func(ClassName, ClassType, ClassRename, name, iname, t, l, AddMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,11 +214,6 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach a note to the cinfo field.
|
|
||||||
|
|
||||||
if (doc_entry)
|
|
||||||
doc_entry->cinfo << "Constructor: ";
|
|
||||||
|
|
||||||
// Call our default method
|
// Call our default method
|
||||||
|
|
||||||
cplus_emit_constructor(ClassName, ClassType, ClassRename, name, iname, l, AddMethods);
|
cplus_emit_constructor(ClassName, ClassType, ClassRename, name, iname, l, AddMethods);
|
||||||
|
|
@ -281,11 +249,6 @@ void Language::cpp_destructor(char *name, char *iname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Attach a note to the description
|
|
||||||
|
|
||||||
if (doc_entry)
|
|
||||||
doc_entry->cinfo << "Destructor: ";
|
|
||||||
|
|
||||||
// Call our default method
|
// Call our default method
|
||||||
|
|
||||||
cplus_emit_destructor(ClassName, ClassType, ClassRename, name, iname, AddMethods);
|
cplus_emit_destructor(ClassName, ClassType, ClassRename, name, iname, AddMethods);
|
||||||
|
|
@ -362,17 +325,10 @@ void Language::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach a c descriptor
|
|
||||||
|
|
||||||
if (doc_entry)
|
|
||||||
doc_entry->cinfo << "Member data: ";
|
|
||||||
|
|
||||||
// Create a function to set the value of the variable
|
// Create a function to set the value of the variable
|
||||||
|
|
||||||
if (!(Status & STAT_READONLY)) {
|
if (!(Status & STAT_READONLY)) {
|
||||||
cplus_emit_variable_set(ClassName, ClassType, ClassRename, name, iname, t, AddMethods);
|
cplus_emit_variable_set(ClassName, ClassType, ClassRename, name, iname, t, AddMethods);
|
||||||
// Add a new line to the documentation entry
|
|
||||||
if (doc_entry) doc_entry->usage << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a function to get the value of a variable
|
// Create a function to get the value of a variable
|
||||||
|
|
@ -426,14 +382,6 @@ void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l
|
||||||
input_file, line_number, cname);
|
input_file, line_number, cname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc_entry) {
|
|
||||||
if (ObjCClass)
|
|
||||||
doc_entry->cinfo << "Class method : ";
|
|
||||||
else
|
|
||||||
doc_entry->cinfo << "Static member : ";
|
|
||||||
}
|
|
||||||
|
|
||||||
cplus_emit_static_func(ClassName,ClassType, ClassRename, name, iname, t, l, AddMethods);
|
cplus_emit_static_func(ClassName,ClassType, ClassRename, name, iname, t, l, AddMethods);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -546,9 +494,6 @@ void Language::cpp_static_var(char *name, char *iname, DataType *t) {
|
||||||
|
|
||||||
sprintf(mname,"%s::%s",ClassName,name);
|
sprintf(mname,"%s::%s",ClassName,name);
|
||||||
|
|
||||||
if (doc_entry)
|
|
||||||
doc_entry->cinfo << "Static member : ";
|
|
||||||
|
|
||||||
// Link with this variable
|
// Link with this variable
|
||||||
|
|
||||||
lang->link_variable(mname,cname,t);
|
lang->link_variable(mname,cname,t);
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,19 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* 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$
|
|
||||||
*
|
|
||||||
* main.cxx
|
* main.cxx
|
||||||
*
|
*
|
||||||
* The main program.
|
* Main entry point to the SWIG core.
|
||||||
*
|
*
|
||||||
***********************************************************************/
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
#define WRAP
|
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "swigconfig.h"
|
#include "swigconfig.h"
|
||||||
|
|
||||||
|
|
@ -43,6 +32,32 @@ static char cvsroot[] = "$Header$";
|
||||||
#define SWIG_CC "CC"
|
#define SWIG_CC "CC"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Global variables
|
||||||
|
|
||||||
|
FILE *f_runtime;
|
||||||
|
FILE *f_header; // Some commonly used
|
||||||
|
FILE *f_wrappers; // FILE pointers
|
||||||
|
FILE *f_init;
|
||||||
|
FILE *f_input;
|
||||||
|
char InitName[256];
|
||||||
|
char LibDir[512]; // Library directory
|
||||||
|
int Status;
|
||||||
|
Language *lang; // Language method
|
||||||
|
int CPlusPlus = 0;
|
||||||
|
int ObjC = 0;
|
||||||
|
int ObjCClass = 0;
|
||||||
|
int AddMethods = 0; // AddMethods flag
|
||||||
|
int NewObject = 0; // NewObject flag
|
||||||
|
int Inline = 0; // Inline mode
|
||||||
|
int ForceExtern = 0; // Force extern mode
|
||||||
|
int WrapExtern = 0;
|
||||||
|
int GenerateDefault = 0; // Generate default constructors
|
||||||
|
char *Config = 0;
|
||||||
|
int NoInclude = 0;
|
||||||
|
char *typemap_lang = 0; // Typemap name
|
||||||
|
int type_id = 0; // Type identifier
|
||||||
|
int error_count = 0; // Error count
|
||||||
|
|
||||||
class SwigException {};
|
class SwigException {};
|
||||||
|
|
||||||
static char *usage = "\
|
static char *usage = "\
|
||||||
|
|
@ -50,15 +65,12 @@ static char *usage = "\
|
||||||
-c - Produce raw wrapper code (omit support code)\n\
|
-c - Produce raw wrapper code (omit support code)\n\
|
||||||
-c++ - Enable C++ processing\n\
|
-c++ - Enable C++ processing\n\
|
||||||
-co - Check a file out of 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\
|
-Dsymbol - Define a symbol (for conditional compilation)\n\
|
||||||
-I<dir> - Look for SWIG files in <dir>\n\
|
-I<dir> - Look for SWIG files in <dir>\n\
|
||||||
-l<ifile> - Include SWIG library file.\n\
|
-l<ifile> - Include SWIG library file.\n\
|
||||||
-make_default - Create default constructors/destructors\n\
|
-make_default - Create default constructors/destructors\n\
|
||||||
-nocomment - Ignore all comments (for documentation).\n\
|
|
||||||
-o outfile - Set name of the output file.\n\
|
-o outfile - Set name of the output file.\n\
|
||||||
-objc - Enable Objective C processing\n\
|
-objc - Enable Objective C processing\n\
|
||||||
-strict n - Set pointer type-checking strictness\n\
|
|
||||||
-swiglib - Report location of SWIG library and exit\n\
|
-swiglib - Report location of SWIG library and exit\n\
|
||||||
-v - Run in verbose mode\n\
|
-v - Run in verbose mode\n\
|
||||||
-version - Print SWIG version number\n\
|
-version - Print SWIG version number\n\
|
||||||
|
|
@ -86,26 +98,23 @@ FILE *swig_log;
|
||||||
char *SwigLib;
|
char *SwigLib;
|
||||||
static int freeze = 0;
|
static int freeze = 0;
|
||||||
|
|
||||||
int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
int SWIG_main(int argc, char *argv[], Language *l) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
char *c;
|
char *c;
|
||||||
extern FILE *LEX_in;
|
extern FILE *LEX_in;
|
||||||
extern char *get_time();
|
extern char *get_time();
|
||||||
char temp[512];
|
char temp[512];
|
||||||
char infile[512];
|
char infile[512];
|
||||||
|
|
||||||
char *outfile_name = 0;
|
char *outfile_name = 0;
|
||||||
extern int add_iname(char *);
|
extern int add_iname(char *);
|
||||||
int help = 0;
|
int help = 0;
|
||||||
int ignorecomments = 0;
|
|
||||||
int checkout = 0;
|
int checkout = 0;
|
||||||
int cpp_only = 0;
|
int cpp_only = 0;
|
||||||
|
|
||||||
char *typemap_file = 0;
|
char *typemap_file = 0;
|
||||||
char *includefiles[256];
|
char *includefiles[256];
|
||||||
int includecount = 0;
|
int includecount = 0;
|
||||||
extern void check_suffix(char *);
|
extern int check_suffix(char *);
|
||||||
extern void scanner_file(FILE *);
|
extern void scanner_file(FILE *);
|
||||||
DOH *libfiles = 0;
|
DOH *libfiles = 0;
|
||||||
|
|
||||||
|
|
@ -121,11 +130,7 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
f_header = 0;
|
f_header = 0;
|
||||||
|
|
||||||
lang = l;
|
lang = l;
|
||||||
doc = d;
|
|
||||||
Status = 0;
|
Status = 0;
|
||||||
TypeStrict = 2; // Very strict type checking
|
|
||||||
Verbose = 0;
|
|
||||||
char *doc_file = 0;
|
|
||||||
|
|
||||||
DataType::init_typedef(); // Initialize the type handler
|
DataType::init_typedef(); // Initialize the type handler
|
||||||
|
|
||||||
|
|
@ -149,24 +154,13 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigLib = copy_string(LibDir); // Make a copy of the real library location
|
SwigLib = copy_string(LibDir); // Make a copy of the real library location
|
||||||
#ifdef MACSWIG
|
|
||||||
/* This needs to be fixed */
|
|
||||||
sprintf(temp,"%s:config", LibDir);
|
|
||||||
add_directory(temp);
|
|
||||||
add_directory(":swig_lib:config");
|
|
||||||
add_directory(LibDir);
|
|
||||||
add_directory(":swig_lib");
|
|
||||||
#else
|
|
||||||
sprintf(temp,"%s/config", LibDir);
|
|
||||||
|
|
||||||
|
sprintf(temp,"%s/config", LibDir);
|
||||||
Swig_add_directory((DOH *) temp);
|
Swig_add_directory((DOH *) temp);
|
||||||
Swig_add_directory((DOH *) "./swig_lib/config");
|
Swig_add_directory((DOH *) "./swig_lib/config");
|
||||||
Swig_add_directory((DOH *) LibDir);
|
Swig_add_directory((DOH *) LibDir);
|
||||||
Swig_add_directory((DOH *) "./swig_lib");
|
Swig_add_directory((DOH *) "./swig_lib");
|
||||||
sprintf(InitName,"init_wrap");
|
sprintf(InitName,"init_wrap");
|
||||||
#endif
|
|
||||||
|
|
||||||
sprintf(InitName,"init_wrap");
|
|
||||||
|
|
||||||
libfiles = NewList();
|
libfiles = NewList();
|
||||||
|
|
||||||
|
|
@ -183,23 +177,10 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
Preprocessor_define((DOH *) d,0);
|
Preprocessor_define((DOH *) d,0);
|
||||||
// Create a symbol
|
// Create a symbol
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strcmp(argv[i],"-strict") == 0) {
|
|
||||||
if (argv[i+1]) {
|
|
||||||
TypeStrict = atoi(argv[i+1]);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
Swig_mark_arg(i+1);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
Swig_arg_error();
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i],"-E") == 0) {
|
} else if (strcmp(argv[i],"-E") == 0) {
|
||||||
cpp_only = 1;
|
cpp_only = 1;
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if ((strcmp(argv[i],"-verbose") == 0) || (strcmp(argv[i],"-v") == 0)) {
|
} else if ((strcmp(argv[i],"-verbose") == 0) || (strcmp(argv[i],"-v") == 0)) {
|
||||||
Verbose = 1;
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-nocomment") == 0) {
|
|
||||||
ignorecomments = 1;
|
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strcmp(argv[i],"-c++") == 0) {
|
} else if (strcmp(argv[i],"-c++") == 0) {
|
||||||
CPlusPlus=1;
|
CPlusPlus=1;
|
||||||
|
|
@ -225,15 +206,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
} else {
|
} else {
|
||||||
Swig_arg_error();
|
Swig_arg_error();
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i],"-d") == 0) {
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
if (argv[i+1]) {
|
|
||||||
doc_file = copy_string(argv[i+1]);
|
|
||||||
Swig_mark_arg(i+1);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
Swig_arg_error();
|
|
||||||
}
|
|
||||||
} else if (strcmp(argv[i],"-version") == 0) {
|
} else if (strcmp(argv[i],"-version") == 0) {
|
||||||
fprintf(stderr,"\nSWIG Version %d.%d %s\n", SWIG_MAJOR_VERSION,
|
fprintf(stderr,"\nSWIG Version %d.%d %s\n", SWIG_MAJOR_VERSION,
|
||||||
SWIG_MINOR_VERSION, SWIG_SPIN);
|
SWIG_MINOR_VERSION, SWIG_SPIN);
|
||||||
|
|
@ -263,32 +235,15 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
Swig_add_directory((DOH *) includefiles[--includecount]);
|
Swig_add_directory((DOH *) includefiles[--includecount]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open up a comment handler
|
|
||||||
|
|
||||||
comment_handler = new CommentHandler();
|
|
||||||
comment_handler->parse_args(argc,argv);
|
|
||||||
if (ignorecomments) comment_handler->style("ignore",0);
|
|
||||||
|
|
||||||
// Create a new documentation entry
|
|
||||||
|
|
||||||
doctitle = new DocTitle("",0);
|
|
||||||
doctitle->parse_args(argc,argv);
|
|
||||||
doc_entry = doctitle;
|
|
||||||
|
|
||||||
// Handle documentation module options
|
|
||||||
|
|
||||||
doc->parse_args(argc,argv);
|
|
||||||
|
|
||||||
// Parse language dependent options
|
// Parse language dependent options
|
||||||
|
|
||||||
lang->parse_args(argc,argv);
|
lang->parse_args(argc,argv);
|
||||||
|
|
||||||
if (help) SWIG_exit(0); // Exit if we're in help mode
|
if (help) SWIG_exit(0); // Exit if we're in help mode
|
||||||
|
|
||||||
// Check all of the options to make sure we're cool.
|
// Check all of the options to make sure we're cool.
|
||||||
|
|
||||||
Swig_check_options();
|
Swig_check_options();
|
||||||
|
|
||||||
|
// Add language dependent directory to the search path
|
||||||
{
|
{
|
||||||
DOH *rl = NewString("");
|
DOH *rl = NewString("");
|
||||||
Printf(rl,"%s/%s", SwigLib,LibDir);
|
Printf(rl,"%s/%s", SwigLib,LibDir);
|
||||||
|
|
@ -296,7 +251,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we made it this far, looks good. go for it....
|
// If we made it this far, looks good. go for it....
|
||||||
|
|
||||||
// Create names of temporary files that are created
|
// Create names of temporary files that are created
|
||||||
|
|
||||||
sprintf(infilename,"%s", argv[argc-1]);
|
sprintf(infilename,"%s", argv[argc-1]);
|
||||||
|
|
@ -304,7 +258,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
strcpy(input_file, infilename);
|
strcpy(input_file, infilename);
|
||||||
|
|
||||||
// If the user has requested to check out a file, handle that
|
// If the user has requested to check out a file, handle that
|
||||||
|
|
||||||
if (checkout) {
|
if (checkout) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
char *outfile = input_file;
|
char *outfile = input_file;
|
||||||
|
|
@ -331,15 +284,10 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
doctitle->file = copy_string(input_file);
|
|
||||||
doctitle->line_number = -1000;
|
|
||||||
doctitle->end_line = -1000;
|
|
||||||
|
|
||||||
// Check the suffix for a .c file. If so, we're going to
|
// Check the suffix for a .c file. If so, we're going to
|
||||||
// declare everything we see as "extern"
|
// declare everything we see as "extern"
|
||||||
|
|
||||||
check_suffix(infilename);
|
ForceExtern = check_suffix(infilename);
|
||||||
|
|
||||||
// Strip off suffix
|
// Strip off suffix
|
||||||
|
|
||||||
c = infilename + strlen(infilename);
|
c = infilename + strlen(infilename);
|
||||||
|
|
@ -362,11 +310,7 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
char *cc = outfile_name;
|
char *cc = outfile_name;
|
||||||
char *lastc = outfile_name;
|
char *lastc = outfile_name;
|
||||||
while (*cc) {
|
while (*cc) {
|
||||||
#ifdef MACSWIG
|
|
||||||
if (*cc == ':') lastc = cc+1;
|
|
||||||
#else
|
|
||||||
if (*cc == '/') lastc = cc+1;
|
if (*cc == '/') lastc = cc+1;
|
||||||
#endif
|
|
||||||
cc++;
|
cc++;
|
||||||
}
|
}
|
||||||
cc = outfile_name;
|
cc = outfile_name;
|
||||||
|
|
@ -380,17 +324,10 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
// Patch up the input filename
|
// Patch up the input filename
|
||||||
cc = infilename + strlen(infilename);
|
cc = infilename + strlen(infilename);
|
||||||
while (cc != infilename) {
|
while (cc != infilename) {
|
||||||
#ifdef MACSWIG
|
|
||||||
if (*cc == ':') {
|
|
||||||
cc++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (*cc == '/') {
|
if (*cc == '/') {
|
||||||
cc++;
|
cc++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
cc--;
|
cc--;
|
||||||
}
|
}
|
||||||
strcpy(infile,cc);
|
strcpy(infile,cc);
|
||||||
|
|
@ -401,16 +338,11 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
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);
|
||||||
|
|
||||||
sprintf(title,"%s", fn_runtime);
|
|
||||||
|
|
||||||
// Define the __cplusplus symbol
|
// Define the __cplusplus symbol
|
||||||
if (CPlusPlus)
|
if (CPlusPlus)
|
||||||
Preprocessor_define((DOH *) "__cplusplus 1", 0);
|
Preprocessor_define((DOH *) "__cplusplus 1", 0);
|
||||||
|
|
||||||
// Open up files
|
// Run the preprocessor
|
||||||
|
|
||||||
/* Preprocess. Ugh */
|
|
||||||
|
|
||||||
{
|
{
|
||||||
DOH *cpps;
|
DOH *cpps;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
@ -467,16 +399,6 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open up documentation
|
|
||||||
|
|
||||||
if (doc_file) {
|
|
||||||
doc->init(doc_file);
|
|
||||||
} else {
|
|
||||||
doc_file = new char[strlen(infile)+strlen(output_dir)+8];
|
|
||||||
sprintf(doc_file,"%s%s_wrap",output_dir,infile);
|
|
||||||
doc->init(doc_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up the typemap for handling new return strings
|
// Set up the typemap for handling new return strings
|
||||||
{
|
{
|
||||||
DataType *temp_t = new DataType(T_CHAR);
|
DataType *temp_t = new DataType(T_CHAR);
|
||||||
|
|
@ -509,22 +431,12 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
fclose(f_wrappers);
|
fclose(f_wrappers);
|
||||||
fclose(f_init);
|
fclose(f_init);
|
||||||
|
|
||||||
swig_append(fn_header, f_runtime);
|
insert_file(fn_header, f_runtime);
|
||||||
swig_append(fn_wrapper,f_runtime);
|
insert_file(fn_wrapper,f_runtime);
|
||||||
swig_append(fn_init,f_runtime);
|
insert_file(fn_init,f_runtime);
|
||||||
|
|
||||||
fclose(f_runtime);
|
fclose(f_runtime);
|
||||||
|
|
||||||
// Print out documentation. Due to tree-like nature of documentation,
|
|
||||||
// printing out the title prints out everything.
|
|
||||||
|
|
||||||
while(doctitle) {
|
|
||||||
doctitle->output(doc);
|
|
||||||
doctitle = doctitle->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
doc->close();
|
|
||||||
|
|
||||||
// Remove temporary files
|
// Remove temporary files
|
||||||
|
|
||||||
remove(fn_cpp);
|
remove(fn_cpp);
|
||||||
|
|
@ -532,26 +444,13 @@ int SWIG_main(int argc, char *argv[], Language *l, Documentation *d) {
|
||||||
remove(fn_wrapper);
|
remove(fn_wrapper);
|
||||||
remove(fn_init);
|
remove(fn_init);
|
||||||
|
|
||||||
// If only producing documentation, remove the wrapper file as well
|
|
||||||
|
|
||||||
if (DocOnly)
|
|
||||||
remove(fn_runtime);
|
|
||||||
|
|
||||||
if (checkout) {
|
if (checkout) {
|
||||||
// File was checked out from the SWIG library. Remove it now
|
// File was checked out from the SWIG library. Remove it now
|
||||||
remove(input_file);
|
remove(input_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef MACSWIG
|
|
||||||
fclose(swig_log);
|
|
||||||
} catch (SwigException) {
|
|
||||||
fclose(swig_log);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
while (freeze);
|
while (freeze);
|
||||||
exit(error_count);
|
return error_count;
|
||||||
#endif
|
|
||||||
return(error_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
@ -578,12 +477,9 @@ void SWIG_exit(int) {
|
||||||
fclose(f_runtime);
|
fclose(f_runtime);
|
||||||
remove(fn_runtime);
|
remove(fn_runtime);
|
||||||
}
|
}
|
||||||
|
remove (fn_cpp);
|
||||||
while (freeze);
|
while (freeze);
|
||||||
#ifndef MACSWIG
|
|
||||||
exit(1);
|
exit(1);
|
||||||
#else
|
|
||||||
throw SwigException();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,26 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* naming.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Functions for creating various kinds of names used during code generation.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include <limits.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
|
||||||
// $Header$
|
|
||||||
//
|
|
||||||
// naming.cxx
|
|
||||||
//
|
|
||||||
// SWIG naming service.
|
|
||||||
//
|
|
||||||
// This module provides universal naming services for manufacturing function names.
|
|
||||||
// All language modules use this so it provides a convenient centralized
|
|
||||||
// mechanism for producing names.
|
|
||||||
// --------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Structure for holding names
|
|
||||||
|
|
||||||
struct NamingScheme {
|
|
||||||
char *format;
|
|
||||||
int first; // Scoping information
|
|
||||||
int last; // Scoping information
|
|
||||||
NamingScheme *next;
|
|
||||||
NamingScheme(char *n) {
|
|
||||||
format = copy_string(n);
|
|
||||||
first = type_id;
|
|
||||||
last = INT_MAX;
|
|
||||||
next = 0;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Hash table containing naming data
|
// Hash table containing naming data
|
||||||
|
|
||||||
static Hash naming_hash;
|
static Hash naming_hash;
|
||||||
|
|
||||||
// Variable indicating naming scope
|
|
||||||
|
|
||||||
static int naming_scope = -1;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
// make_wrap_name(char *s)
|
// make_wrap_name(char *s)
|
||||||
//
|
//
|
||||||
|
|
@ -70,25 +37,11 @@ void make_wrap_name(char *s) {
|
||||||
|
|
||||||
char *c1 = s;
|
char *c1 = s;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < (int) strlen(s); i++, c1++) {
|
for (i = 0; i < (int) strlen(s); i++, c1++) {
|
||||||
if(!isalnum(*c1)) *c1 = '_';
|
if(!isalnum(*c1)) *c1 = '_';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
|
||||||
// int name_scope(int scope)
|
|
||||||
//
|
|
||||||
// Set the scope variable. This is used to determine what naming scheme to
|
|
||||||
// use. Returns the current value of the scope.
|
|
||||||
// --------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int name_scope(int scope) {
|
|
||||||
int s = naming_scope;
|
|
||||||
naming_scope = scope;
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
// void name_register(char *method, char *format)
|
// void name_register(char *method, char *format)
|
||||||
//
|
//
|
||||||
|
|
@ -96,42 +49,18 @@ int name_scope(int scope) {
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
||||||
void name_register(char *method, char *format) {
|
void name_register(char *method, char *format) {
|
||||||
NamingScheme *ns, *nns;
|
naming_hash.remove(method);
|
||||||
|
naming_hash.add(method,copy_string(format));
|
||||||
ns = (NamingScheme *) naming_hash.lookup(method);
|
}
|
||||||
if (ns) {
|
|
||||||
naming_hash.remove(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
nns = new NamingScheme(format); // Create a new naming scheme
|
|
||||||
if (ns) ns->last = type_id;
|
|
||||||
nns->next = ns;
|
|
||||||
|
|
||||||
naming_hash.add(method,nns);
|
|
||||||
};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
// char *name_getformat(char *method)
|
// char *name_getformat(char *method)
|
||||||
//
|
//
|
||||||
// Looks up a naming scheme in the hash table. The scope of the name should have
|
// Get name format
|
||||||
// been set prior to calling this. If not set, we just use the last name entered.
|
|
||||||
// Returns the format string or NULL if no name has been set.
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
||||||
static char *name_getformat(char *method) {
|
static char *name_getformat(char *method) {
|
||||||
|
return (char *) naming_hash.lookup(method);
|
||||||
NamingScheme *ns;
|
|
||||||
int scope;
|
|
||||||
if (naming_scope == -1) scope = type_id;
|
|
||||||
else scope = naming_scope;
|
|
||||||
|
|
||||||
ns = (NamingScheme *) naming_hash.lookup(method);
|
|
||||||
while (ns) {
|
|
||||||
if ((ns->first <= scope) && (scope < ns->last))
|
|
||||||
return ns->format;
|
|
||||||
ns = ns->next;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,609 +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$
|
|
||||||
*
|
|
||||||
* newdoc.cxx
|
|
||||||
*
|
|
||||||
* SWIG Documentation system. (2nd attempt)
|
|
||||||
*
|
|
||||||
* SWIG organizes documentation as a tree structure where each node is a
|
|
||||||
* documentation entry (DocEntry) of some kind. To generate documentation,
|
|
||||||
* we simply traverse the tree and call output methods.
|
|
||||||
*
|
|
||||||
* A sample documentation tree looks something like the following :
|
|
||||||
*
|
|
||||||
* TITLE ----> SECTION 1 ----> func1
|
|
||||||
* ----> func2
|
|
||||||
* ----> func3
|
|
||||||
* ----> class ---> func1
|
|
||||||
* ---> func2
|
|
||||||
* ---> var1
|
|
||||||
* ----> func4
|
|
||||||
*
|
|
||||||
* ----> SECTION 2 ----> func1
|
|
||||||
* ----> var1
|
|
||||||
*
|
|
||||||
* and so on.
|
|
||||||
*
|
|
||||||
* This structure makes it possible to organize C++ classes and more
|
|
||||||
* complicated structures. Hopefully this will provide enough structure
|
|
||||||
* for later versions of SWIG.
|
|
||||||
*
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
static char cvsroot[] = "$Header$";
|
|
||||||
|
|
||||||
#include "internal.h"
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
extern char *get_time();
|
|
||||||
static char *last_name = 0;
|
|
||||||
|
|
||||||
DocEntry *DocEntry::dead_entries = 0;
|
|
||||||
|
|
||||||
// Utility function for converting a string to upper case
|
|
||||||
|
|
||||||
static void str_toupper(char *str) {
|
|
||||||
char *c;
|
|
||||||
c = str;
|
|
||||||
while (*c) {
|
|
||||||
*c = toupper(*c);
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocEntry::~DocEntry
|
|
||||||
//
|
|
||||||
// Destroy a documentation entry. Destroys this entry and all of
|
|
||||||
// its children.
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocEntry::~DocEntry() {
|
|
||||||
DocEntry *de, *de1;
|
|
||||||
|
|
||||||
if (name) delete name;
|
|
||||||
|
|
||||||
// Now kill all of the children (well, figuratively speaking)
|
|
||||||
|
|
||||||
de = child;
|
|
||||||
while (de) {
|
|
||||||
de1 = de->next;
|
|
||||||
delete de;
|
|
||||||
de = de1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// void DocEntry::sort_children()
|
|
||||||
//
|
|
||||||
// Sort children by name (not height). This function gathers all
|
|
||||||
// of the children up into an array of pointers. Then we do an
|
|
||||||
// insertion sort on it and place the children back in order.
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocEntry::sort_children() {
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
int i,j;
|
|
||||||
DocEntry *d;
|
|
||||||
DocEntry **list;
|
|
||||||
DocEntry *v;
|
|
||||||
|
|
||||||
if (!child) return; // Nothing to sort
|
|
||||||
|
|
||||||
d = child;
|
|
||||||
while (d) {
|
|
||||||
count++;
|
|
||||||
d = d->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// allocate a temporary array for sorting everything
|
|
||||||
|
|
||||||
list = new DocEntry *[count+2];
|
|
||||||
|
|
||||||
// Now put pointers into list
|
|
||||||
|
|
||||||
d = child;
|
|
||||||
i = 0;
|
|
||||||
while (d) {
|
|
||||||
list[i] = d;
|
|
||||||
d = d->next;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do an insertion sort by name
|
|
||||||
|
|
||||||
for (i = 1; i < count; i++) {
|
|
||||||
v = list[i];
|
|
||||||
j = i;
|
|
||||||
while((j > 0) && (strcmp(list[j-1]->name,v->name) > 0)) {
|
|
||||||
list[j] = list[j-1];
|
|
||||||
j--;
|
|
||||||
}
|
|
||||||
list[j] = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now, we're going to reorganize the children in order
|
|
||||||
|
|
||||||
list[count] = 0;
|
|
||||||
child = list[0]; // Our child is the first one in the list
|
|
||||||
d = child;
|
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
d->next = list[i+1];
|
|
||||||
d = d->next;
|
|
||||||
}
|
|
||||||
delete list;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// void DocEntry::output()
|
|
||||||
//
|
|
||||||
// Output this entry
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocEntry::output(Documentation *) {
|
|
||||||
fprintf(stderr,"SWIG (internal) : No output method defined for DocEntry.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocEntry::add(DocEntry *de)
|
|
||||||
//
|
|
||||||
// Adds a new DocEntry as a sibling. Basically we just walk down the
|
|
||||||
// linked list and append ourselves to the end. The documentation
|
|
||||||
// Entry we're adding may, in fact, have siblings too, but this function
|
|
||||||
// Should still work.
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocEntry::add(DocEntry *de) {
|
|
||||||
DocEntry *d,*d1;
|
|
||||||
d = next;
|
|
||||||
d1 = this;
|
|
||||||
while (d) {
|
|
||||||
d1 = d;
|
|
||||||
d = d->next;
|
|
||||||
}
|
|
||||||
d1->next = de;
|
|
||||||
de->previous = d1; // Set up the previous list member
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocEntry::addchild(DocEntry *de)
|
|
||||||
//
|
|
||||||
// Adds a new DocEntry as a child. If we're in Ignore mode, the
|
|
||||||
// documentation entry is still created, but we simply abandon it.
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocEntry::addchild(DocEntry *de) {
|
|
||||||
if (!IgnoreDoc) {
|
|
||||||
if (child) child->add(de);
|
|
||||||
else child = de;
|
|
||||||
} else {
|
|
||||||
if (dead_entries) dead_entries->add(de);
|
|
||||||
else dead_entries = de;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// DocEntry::remove()
|
|
||||||
//
|
|
||||||
// Removes a documentation entry from the tree and places it on
|
|
||||||
// the dead_entries list
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocEntry::remove() {
|
|
||||||
|
|
||||||
if (previous) {
|
|
||||||
if (next)
|
|
||||||
previous->next = next; // Take out of the linked list
|
|
||||||
else
|
|
||||||
previous->next = 0;
|
|
||||||
} else { // Make sure our parent isn't pointing to us
|
|
||||||
if (parent)
|
|
||||||
parent->child = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
previous = 0;
|
|
||||||
next = 0;
|
|
||||||
|
|
||||||
if (!dead_entries) dead_entries = this;
|
|
||||||
else dead_entries->add(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// void DocEntry::style(char *name, char *value)
|
|
||||||
//
|
|
||||||
// Set style parameters of a documentation entry
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocEntry::style(char *pname, char *) {
|
|
||||||
if (strcmp(pname,"sort") == 0) {
|
|
||||||
sorted = 1;
|
|
||||||
} else if (strcmp(pname,"nosort") == 0) {
|
|
||||||
sorted = 0;
|
|
||||||
} else if (strcmp(pname,"info") == 0) {
|
|
||||||
print_info = 1;
|
|
||||||
} else if (strcmp(pname,"noinfo") == 0) {
|
|
||||||
print_info = 0;
|
|
||||||
} else if (strcmp(pname,"pre") == 0) {
|
|
||||||
format = 0;
|
|
||||||
} else if (strcmp(pname,"format") == 0) {
|
|
||||||
format = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// void DocEntry::parse_args(int argc, char **argv)
|
|
||||||
//
|
|
||||||
// Take command line options and process them. This really only
|
|
||||||
// applies to the top-level documentation entry.
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
static char *doc_usage = "\
|
|
||||||
Documentation Processing : \n\
|
|
||||||
-Sformat - Reformat comment text\n\
|
|
||||||
-Sinfo - Print C formatting information (the default)\n\
|
|
||||||
-Snoinfo - Omit C formatting information.\n\
|
|
||||||
-Snosort - Print everything in order (the default)\n\
|
|
||||||
-Spre - Assume comments are pre-formatted (the default)\n\
|
|
||||||
-Ssort - Sort documentation alphabetically\n\n";
|
|
||||||
|
|
||||||
void DocEntry::parse_args(int argc, char **argv) {
|
|
||||||
int i;
|
|
||||||
for (i = 1; i < argc; i++) {
|
|
||||||
if (argv[i]) {
|
|
||||||
if (strcmp(argv[i],"-Ssort") == 0) {
|
|
||||||
this->style("sort",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Snosort") == 0) {
|
|
||||||
this->style("nosort",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Sinfo") == 0) {
|
|
||||||
this->style("info",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Snoinfo") == 0) {
|
|
||||||
this->style("noinfo",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Spre") == 0) {
|
|
||||||
this->style("pre",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-Sformat") == 0) {
|
|
||||||
this->style("format",0);
|
|
||||||
Swig_mark_arg(i);
|
|
||||||
} else if (strcmp(argv[i],"-help") == 0) {
|
|
||||||
fputs(doc_usage,stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// DocTitle::DocTitle(char *title, DocEntry *_parent);
|
|
||||||
//
|
|
||||||
// Create a new title documentation entry. The name of the entry
|
|
||||||
// is the title.
|
|
||||||
//
|
|
||||||
// The body text is optional, but may be filled in with a description
|
|
||||||
// as well.
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocTitle::DocTitle(char *title, DocEntry *_parent) {
|
|
||||||
name = copy_string(title);
|
|
||||||
str_toupper(name);
|
|
||||||
parent = _parent;
|
|
||||||
child = 0;
|
|
||||||
next = 0;
|
|
||||||
previous = 0;
|
|
||||||
usage << title << "\n";
|
|
||||||
counter = 1;
|
|
||||||
is_separator = 1;
|
|
||||||
line_number = ::start_line;
|
|
||||||
end_line = ::line_number;
|
|
||||||
file = copy_string(input_file);
|
|
||||||
if (_parent) {
|
|
||||||
sorted = _parent->sorted;
|
|
||||||
format = _parent->format;
|
|
||||||
print_info = _parent->print_info;
|
|
||||||
} else {
|
|
||||||
sorted = SWIGDEFAULT_SORT;
|
|
||||||
format = SWIGDEFAULT_FORMAT;
|
|
||||||
print_info = SWIGDEFAULT_INFO;
|
|
||||||
}
|
|
||||||
comment_handler->set_entry(this);
|
|
||||||
if (last_name) delete last_name;
|
|
||||||
last_name = 0;
|
|
||||||
}
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocTitle::output(Documentation *d)
|
|
||||||
//
|
|
||||||
// Output a title to the Documentation module
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocTitle::output(Documentation *d) {
|
|
||||||
DocEntry *de;
|
|
||||||
|
|
||||||
d->title(this);
|
|
||||||
if (sorted) {
|
|
||||||
sort_children();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now output my children
|
|
||||||
|
|
||||||
de = child;
|
|
||||||
while (de) {
|
|
||||||
de->output(d);
|
|
||||||
de = de->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// DocSection::DocSection(char *section, DocEntry *_parent);
|
|
||||||
//
|
|
||||||
// Create a new documentation section. The name and description is
|
|
||||||
// set to the name of the section. The text field is optional
|
|
||||||
// but could contain a more complete description.
|
|
||||||
//
|
|
||||||
// The sorted field indicates whether members of this section are
|
|
||||||
// sorted or not.
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocSection::DocSection(char *section, DocEntry *_parent) {
|
|
||||||
name = copy_string(section);
|
|
||||||
str_toupper(name);
|
|
||||||
parent = _parent;
|
|
||||||
child = 0;
|
|
||||||
next = 0;
|
|
||||||
previous = 0;
|
|
||||||
usage << section;
|
|
||||||
counter = 1;
|
|
||||||
is_separator = 1;
|
|
||||||
if (_parent) _parent->addchild(this);
|
|
||||||
line_number = ::start_line;
|
|
||||||
end_line = ::line_number;
|
|
||||||
file = copy_string(input_file);
|
|
||||||
if (_parent) {
|
|
||||||
sorted = _parent->sorted;
|
|
||||||
format = _parent->format;
|
|
||||||
print_info = _parent->print_info;
|
|
||||||
} else {
|
|
||||||
sorted = SWIGDEFAULT_SORT;
|
|
||||||
format = SWIGDEFAULT_FORMAT;
|
|
||||||
print_info = SWIGDEFAULT_INFO;
|
|
||||||
}
|
|
||||||
comment_handler->set_entry(this);
|
|
||||||
if (last_name) delete last_name;
|
|
||||||
last_name = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocSection::output(Documentation *d)
|
|
||||||
//
|
|
||||||
// Output a section to the documentation module
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocSection::output(Documentation *d) {
|
|
||||||
DocEntry *de;
|
|
||||||
|
|
||||||
// Make a new section
|
|
||||||
|
|
||||||
d->newsection(this,this->parent->counter++); // Make a new section
|
|
||||||
|
|
||||||
// Sort the children if necessary
|
|
||||||
|
|
||||||
if (sorted) {
|
|
||||||
sort_children();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now output my children
|
|
||||||
|
|
||||||
de = child;
|
|
||||||
while (de) {
|
|
||||||
de->output(d);
|
|
||||||
de = de->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// End this section
|
|
||||||
|
|
||||||
d->endsection();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// DocDecl::DocDecl(char *fname, DocEntry *_parent);
|
|
||||||
//
|
|
||||||
// Create documentation for a function declaration.
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocDecl::DocDecl(char *fname, DocEntry *_parent) {
|
|
||||||
name = copy_string(fname);
|
|
||||||
str_toupper(name);
|
|
||||||
parent = _parent;
|
|
||||||
child = 0;
|
|
||||||
next = 0;
|
|
||||||
previous = 0;
|
|
||||||
is_separator = 0;
|
|
||||||
if (_parent) _parent->addchild(this);
|
|
||||||
line_number = ::start_line;
|
|
||||||
end_line = ::line_number;
|
|
||||||
file = copy_string(input_file);
|
|
||||||
if (_parent) {
|
|
||||||
sorted = _parent->sorted;
|
|
||||||
format = _parent->format;
|
|
||||||
print_info = _parent->print_info;
|
|
||||||
} else {
|
|
||||||
sorted = SWIGDEFAULT_SORT;
|
|
||||||
format = SWIGDEFAULT_FORMAT;
|
|
||||||
print_info = SWIGDEFAULT_INFO;
|
|
||||||
}
|
|
||||||
comment_handler->set_entry(this);
|
|
||||||
if (last_name) delete last_name;
|
|
||||||
last_name = copy_string(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocDecl::DocDecl(DocEntry *de, DocEntry *_parent)
|
|
||||||
//
|
|
||||||
// Make a new declaration entry, but copy attributes from someone else
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocDecl::DocDecl(DocEntry *de, DocEntry *_parent) {
|
|
||||||
name = copy_string(de->name);
|
|
||||||
usage = de->usage.get();
|
|
||||||
cinfo = de->cinfo.get();
|
|
||||||
text = de->text.get();
|
|
||||||
line_number = de->line_number;
|
|
||||||
end_line = de->end_line;
|
|
||||||
file = copy_string(de->file);
|
|
||||||
print_info = de->print_info;
|
|
||||||
format = de->format;
|
|
||||||
if (_parent) {
|
|
||||||
_parent->addchild(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocDecl::output(Documentation *d)
|
|
||||||
//
|
|
||||||
// Output a function to the documentation module
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocDecl::output(Documentation *d) {
|
|
||||||
d->print_decl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// DocClass::DocClass(char *classname, DocEntry *_parent);
|
|
||||||
//
|
|
||||||
// Create a new class section. Classes are created as funny sorts of
|
|
||||||
// sections.
|
|
||||||
//
|
|
||||||
// The sorted field indicates whether members of this section are
|
|
||||||
// sorted or not.
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocClass::DocClass(char *classname, DocEntry *_parent) {
|
|
||||||
name = copy_string(classname);
|
|
||||||
str_toupper(name);
|
|
||||||
parent = _parent;
|
|
||||||
child = 0;
|
|
||||||
next = 0;
|
|
||||||
previous = 0;
|
|
||||||
usage << classname<< "\n";
|
|
||||||
counter = 1;
|
|
||||||
is_separator = 1;
|
|
||||||
if (_parent) _parent->addchild(this);
|
|
||||||
line_number = ::start_line;
|
|
||||||
end_line = ::line_number;
|
|
||||||
file = copy_string(input_file);
|
|
||||||
if (_parent) {
|
|
||||||
sorted = _parent->sorted;
|
|
||||||
format = _parent->format;
|
|
||||||
print_info = _parent->print_info;
|
|
||||||
} else {
|
|
||||||
sorted = SWIGDEFAULT_SORT;
|
|
||||||
format = SWIGDEFAULT_FORMAT;
|
|
||||||
print_info = SWIGDEFAULT_INFO;
|
|
||||||
}
|
|
||||||
comment_handler->set_entry(this);
|
|
||||||
if (last_name) delete last_name;
|
|
||||||
last_name = copy_string(name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocClass::output(Documentation *d)
|
|
||||||
//
|
|
||||||
// Output a section to the documentation module
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocClass::output(Documentation *d) {
|
|
||||||
DocEntry *de;
|
|
||||||
|
|
||||||
// Make a new section
|
|
||||||
|
|
||||||
d->newsection(this,this->parent->counter++); // Make a subsection for this
|
|
||||||
|
|
||||||
// Sort the children if necessary
|
|
||||||
|
|
||||||
if (sorted) {
|
|
||||||
sort_children();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now output my children
|
|
||||||
|
|
||||||
de = child;
|
|
||||||
while (de) {
|
|
||||||
de->output(d);
|
|
||||||
de = de->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// End this section
|
|
||||||
|
|
||||||
d->endsection();
|
|
||||||
|
|
||||||
// We now check to see if the next thing is a separator. If not, we'll
|
|
||||||
// emit a separator
|
|
||||||
|
|
||||||
if (next) {
|
|
||||||
if (!next->is_separator)
|
|
||||||
d->separator();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// DocText::DocText(char *_text, DocEntry *_parent);
|
|
||||||
//
|
|
||||||
// Create documentation for a function declaration.
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
|
|
||||||
DocText::DocText(char *_text, DocEntry *_parent) {
|
|
||||||
if (!last_name)
|
|
||||||
name = copy_string(""); // There is no name for text
|
|
||||||
else
|
|
||||||
name = copy_string(last_name);
|
|
||||||
parent = _parent;
|
|
||||||
child = 0;
|
|
||||||
next = 0;
|
|
||||||
previous = 0;
|
|
||||||
text << _text;
|
|
||||||
is_separator = 0;
|
|
||||||
if (_parent) _parent->addchild(this);
|
|
||||||
if (_parent) {
|
|
||||||
sorted = _parent->sorted;
|
|
||||||
format = _parent->format;
|
|
||||||
print_info = _parent->print_info;
|
|
||||||
} else {
|
|
||||||
sorted = SWIGDEFAULT_SORT;
|
|
||||||
format = SWIGDEFAULT_FORMAT;
|
|
||||||
print_info = SWIGDEFAULT_INFO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// DocText::output(Documentation *d)
|
|
||||||
//
|
|
||||||
// Output a function to the documentation module
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void DocText::output(Documentation *d) {
|
|
||||||
d->print_text(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,30 +1,19 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* parms.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Parameter list class.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
|
||||||
$Header$
|
|
||||||
|
|
||||||
parms.cxx
|
|
||||||
|
|
||||||
This file is used to manage function parameters and parameter lists.
|
|
||||||
Rewritten (10/27) to solve a bunch of problems with memory management
|
|
||||||
and proper cleanup of things.
|
|
||||||
------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,36 +1,19 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* scanner.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* SWIG1.1 tokenizer.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* $Header$
|
|
||||||
* scanner.c
|
|
||||||
*
|
|
||||||
* Dave Beazley
|
|
||||||
* January 1996
|
|
||||||
*
|
|
||||||
* Input scanner. This scanner finds and returns tokens
|
|
||||||
* for the wrapper generator. Since using lex/flex from
|
|
||||||
* C++ is so F'ed up, I've written this function to replace
|
|
||||||
* them entirely. It's not as fast, but hopefully it will
|
|
||||||
* eliminate alot of compilation problems.
|
|
||||||
*
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -301,8 +284,7 @@ void start_inline(char *text, int line) {
|
||||||
* Inserts a comment into a documentation entry.
|
* Inserts a comment into a documentation entry.
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
|
|
||||||
void yycomment(char *s, int line, int col) {
|
void yycomment(char *, int, int) {
|
||||||
comment_handler->add_comment(s,line,col,input_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************
|
/**************************************************************
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* sstring.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* SWIG string object.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,18 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* swig11.h
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Main header file for the SWIG1.1 core.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* University of Chicago
|
*
|
||||||
* 1100 E 58th Street
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* Chicago, IL 60637
|
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
||||||
* beazley@cs.uchicago.edu
|
* University of California.
|
||||||
|
*
|
||||||
|
* See the file LICENSE for information on usage and redistribution.
|
||||||
*
|
*
|
||||||
* Please read the file LICENSE for the copyright and terms by which SWIG
|
|
||||||
* can be used and distributed.
|
|
||||||
*******************************************************************************/
|
|
||||||
/***********************************************************************
|
|
||||||
* $Header$
|
* $Header$
|
||||||
*
|
* ----------------------------------------------------------------------------- */
|
||||||
* swig.h
|
|
||||||
*
|
|
||||||
* This is the header file containing the main class definitions and
|
|
||||||
* declarations. Should be included in all extensions and code
|
|
||||||
* modules.
|
|
||||||
*
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -45,10 +36,8 @@ extern FILE *f_init; // Initialization code
|
||||||
extern FILE *f_input;
|
extern FILE *f_input;
|
||||||
extern char InitName[256];
|
extern char InitName[256];
|
||||||
extern char LibDir[512]; // Library directory
|
extern char LibDir[512]; // Library directory
|
||||||
extern char **InitNames; // List of other init functions
|
//extern char **InitNames; // List of other init functions
|
||||||
extern int Status; // Variable creation status
|
extern int Status; // Variable creation status
|
||||||
extern int TypeStrict; // Type checking strictness
|
|
||||||
extern int Verbose;
|
|
||||||
extern int yyparse();
|
extern int yyparse();
|
||||||
extern int line_number;
|
extern int line_number;
|
||||||
extern int start_line;
|
extern int start_line;
|
||||||
|
|
@ -209,7 +198,6 @@ static void record_base(char *derived, char *base);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define STAT_REPLACETYPE 2
|
#define STAT_REPLACETYPE 2
|
||||||
#define STAT_VISIT 4
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* class Parm
|
* class Parm
|
||||||
|
|
@ -431,86 +419,6 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Documentation;
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// class DocEntry
|
|
||||||
//
|
|
||||||
// Base class for the documentation system. Basically everything is
|
|
||||||
// a documentation entry of some sort. Specific derived classes
|
|
||||||
// are created internally and shouldn't be accessed by third-party
|
|
||||||
// modules.
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
class DocEntry {
|
|
||||||
public:
|
|
||||||
char *name; // Name of the entry
|
|
||||||
String usage; // Short description (optional)
|
|
||||||
String cinfo; // Information about C interface (optional).
|
|
||||||
String text; // Supporting text (optional)
|
|
||||||
DocEntry *parent; // Parent of this entry (optional)
|
|
||||||
DocEntry *child; // Children of this entry (optional)
|
|
||||||
DocEntry *next; // Next entry (or sibling)
|
|
||||||
DocEntry *previous; // Previous entry
|
|
||||||
int counter; // Counter for section control
|
|
||||||
int is_separator; // Is this a separator entry?
|
|
||||||
int sorted; // Sorted?
|
|
||||||
int line_number; // Line number
|
|
||||||
int end_line; // Ending line number
|
|
||||||
int format; // Format this documentation entry
|
|
||||||
int print_info; // Print C information about this entry
|
|
||||||
char *file; // File
|
|
||||||
virtual ~DocEntry(); // Destructor (common to all subclasses)
|
|
||||||
|
|
||||||
// Methods applicable to all documentation entries
|
|
||||||
|
|
||||||
virtual void output(Documentation *d);
|
|
||||||
void add(DocEntry *de); // Add documentation entry to the list
|
|
||||||
void addchild(DocEntry *de); // Add documentation entry as a child
|
|
||||||
void sort_children(); // Sort all of the children
|
|
||||||
void remove(); // Remove this doc entry
|
|
||||||
void parse_args(int argc, char **argv); // Parse command line options
|
|
||||||
void style(char *name,char *value);// Change doc style.
|
|
||||||
static DocEntry *dead_entries; // Dead documentation entries
|
|
||||||
};
|
|
||||||
|
|
||||||
extern DocEntry *doc_entry;
|
|
||||||
|
|
||||||
// Default DocEntry style parameters
|
|
||||||
|
|
||||||
#define SWIGDEFAULT_SORT 0
|
|
||||||
#define SWIGDEFAULT_FORMAT 1
|
|
||||||
#define SWIGDEFAULT_INFO 1
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Documentation module base class
|
|
||||||
//
|
|
||||||
// This class defines methods that need to be implemented for a
|
|
||||||
// documentation module.
|
|
||||||
//
|
|
||||||
// title() - Print out a title entry
|
|
||||||
// newsection() - Start a new section (may be nested to form subsections)
|
|
||||||
// endsection() - End a section
|
|
||||||
// print_decl() - Print a standard declaration
|
|
||||||
// print_text() - Print standard text
|
|
||||||
// init() - Initialize the documentation module
|
|
||||||
// close() - Close documentation module
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
class Documentation {
|
|
||||||
public:
|
|
||||||
virtual void parse_args(int argc, char **argv) = 0;
|
|
||||||
virtual void title(DocEntry *de) = 0;
|
|
||||||
virtual void newsection(DocEntry *de, int sectnum) = 0;
|
|
||||||
virtual void endsection() = 0;
|
|
||||||
virtual void print_decl(DocEntry *de) = 0;
|
|
||||||
virtual void print_text(DocEntry *de) = 0;
|
|
||||||
virtual void separator() = 0;
|
|
||||||
virtual void init(char *filename) = 0;
|
|
||||||
virtual void close(void) = 0;
|
|
||||||
virtual void style(char *name, char *value) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Emit functions */
|
/* Emit functions */
|
||||||
|
|
||||||
extern void emit_extern_var(char *, DataType *, int, FILE *);
|
extern void emit_extern_var(char *, DataType *, int, FILE *);
|
||||||
|
|
@ -523,7 +431,7 @@ extern void emit_hex(FILE *);
|
||||||
extern void emit_set_get(char *, char *, DataType *);
|
extern void emit_set_get(char *, char *, DataType *);
|
||||||
extern void emit_banner(FILE *);
|
extern void emit_banner(FILE *);
|
||||||
extern void emit_ptr_equivalence(FILE *);
|
extern void emit_ptr_equivalence(FILE *);
|
||||||
extern int SWIG_main(int, char **, Language *, Documentation *);
|
extern int SWIG_main(int, char **, Language *);
|
||||||
extern void make_wrap_name(char *);
|
extern void make_wrap_name(char *);
|
||||||
|
|
||||||
// Some functions for emitting some C++ helper code
|
// Some functions for emitting some C++ helper code
|
||||||
|
|
@ -550,13 +458,10 @@ 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);
|
||||||
|
|
||||||
extern void cplus_support_doc(String &f);
|
|
||||||
|
|
||||||
/* Function for building search directories */
|
/* Function for building search directories */
|
||||||
|
|
||||||
extern int insert_file(char *, FILE *);
|
extern int insert_file(char *, FILE *);
|
||||||
extern int get_file(char *filename, String &str);
|
extern int get_file(char *filename, String &str);
|
||||||
extern void swig_append(char *filename, FILE *);
|
|
||||||
|
|
||||||
/* These are in the new core */
|
/* These are in the new core */
|
||||||
|
|
||||||
|
|
@ -636,7 +541,6 @@ extern void emit_ptr_equivalence(WrapperFunction &);
|
||||||
#define AS_IS 1
|
#define AS_IS 1
|
||||||
|
|
||||||
extern void name_register(char *method, char *format);
|
extern void name_register(char *method, char *format);
|
||||||
extern int name_scope(int);
|
|
||||||
extern char *name_wrapper(char *fname, char *prefix, int suppress=0);
|
extern char *name_wrapper(char *fname, char *prefix, int suppress=0);
|
||||||
extern char *name_member(char *fname, char *classname, int suppress=0);
|
extern char *name_member(char *fname, char *classname, int suppress=0);
|
||||||
extern char *name_get(char *vname, int suppress=0);
|
extern char *name_get(char *vname, int suppress=0);
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,19 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* symbol.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Symbol table management.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* $Header$
|
|
||||||
*
|
|
||||||
* File : symbol.cxx
|
|
||||||
*
|
|
||||||
* Symbol table management.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
static char cvstag[] = "$Header$";
|
static char cvstag[] = "$Header$";
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,23 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* typemap.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Typemap support.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// $Header$
|
|
||||||
//
|
|
||||||
// typemap.cxx
|
|
||||||
//
|
|
||||||
// This file provides universal support for typemaps. Typemaps are created
|
// This file provides universal support for typemaps. Typemaps are created
|
||||||
// using the following SWIG command in an interface file:
|
// using the following SWIG command in an interface file:
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,18 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* 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$";
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* $Header$
|
|
||||||
*
|
|
||||||
* types.cxx
|
* types.cxx
|
||||||
*
|
*
|
||||||
* This file contains functions for dealing with datatypes. This
|
* This file contains code for SWIG1.1 type objects.
|
||||||
* is a combination of the file typedef.cc (now obsolete) and functions
|
|
||||||
* that used to be in the swig.h header.
|
|
||||||
*
|
*
|
||||||
***********************************************************************/
|
* 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"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -936,7 +924,6 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
||||||
void typeeq_derived(char *n1, char *n2, char *cast=0) {
|
void typeeq_derived(char *n1, char *n2, char *cast=0) {
|
||||||
DataType t,t1;
|
DataType t,t1;
|
||||||
String name,name2;
|
String name,name2;
|
||||||
EqEntry *e1;
|
|
||||||
|
|
||||||
if (!te_init) typeeq_init();
|
if (!te_init) typeeq_init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,20 @@
|
||||||
/*******************************************************************************
|
/* -----------------------------------------------------------------------------
|
||||||
* Simplified Wrapper and Interface Generator (SWIG)
|
* wrapfunc.cxx
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Wrapper function object.
|
||||||
*
|
*
|
||||||
* Department of Computer Science
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
* 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
|
* Copyright (C) 1998-2000. The University of Chicago
|
||||||
* can be used and distributed.
|
* 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$";
|
static char cvsroot[] = "$Header$";
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// wrapfunc.cxx
|
|
||||||
//
|
|
||||||
// Created : June 22, 1996
|
|
||||||
// Dave Beazley
|
|
||||||
//
|
|
||||||
// This file defines a class for writing wrappers. Instead of worrying
|
// This file defines a class for writing wrappers. Instead of worrying
|
||||||
// about I/O problems, this wrapper class can be used to write functions
|
// about I/O problems, this wrapper class can be used to write functions
|
||||||
// out of order.
|
// out of order.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue