Major cleanup of comments

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@128 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-01-20 05:45:58 +00:00
commit fc2fb1ff98
25 changed files with 769 additions and 853 deletions

View file

@ -1,44 +1,39 @@
/*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
/* -----------------------------------------------------------------------------
* getopt.c
*
* Handles the parsing of command line options. This is particularly nasty
* compared to other utilities given that command line options can potentially
* be read by many different modules within SWIG. Thus, in order to make sure
* there are no unrecognized options, each module is required to "mark"
* the options that it uses. Afterwards, we can make a quick scan to make
* sure there are no unmarked options.
*
* Author : David Beazley
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
* Copyright (C) 1999-2000. The University of Chicago
* 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.
*******************************************************************************/
* To do:
* - This module needs to be modified so that it doesn't call exit().
* Should have cleaner error handling in general.
* ----------------------------------------------------------------------------- */
static char cvsroot[] = "$Header$";
#include "swig.h"
/*******************************************************************************
* $Header$
*
* File : getopt.c
*
* Functions for handling command line arguments. This is a little funky because
* the arguments are checked in multiple places.
*******************************************************************************/
static char **args;
static int numargs;
static int *marked;
/* -----------------------------------------------------------------------------
* void Swig_init_args(int argc, char **argv)
* Swig_init_args()
*
* Initializes the argument list.
* Initialize the argument list handler.
* ----------------------------------------------------------------------------- */
void
Swig_init_args(int argc, char **argv)
{
Swig_init_args(int argc, char **argv) {
int i;
assert(argc > 0);
assert(argv);
@ -53,10 +48,9 @@ Swig_init_args(int argc, char **argv)
}
/* -----------------------------------------------------------------------------
* void Swig_mark_arg(int n)
* Swig_mark_arg()
*
* Marks an argument as being parsed. All modules should do this whenever they
* parse a command line option.
* Marks an argument as being parsed.
* ----------------------------------------------------------------------------- */
void
@ -67,16 +61,16 @@ Swig_mark_arg(int n) {
}
/* -----------------------------------------------------------------------------
* void Swig_check_options()
* Swig_check_options()
*
* Checks for unparsed command line options. If so, issues an error and exits.
* Checkers for unprocessed command line options and errors.
* ----------------------------------------------------------------------------- */
void Swig_check_options() {
void
Swig_check_options() {
int error = 0;
int i;
assert(marked);
for (i = 1; i < numargs-1; i++) {
if (!marked[i]) {
Printf(stderr,"swig error : Unrecognized option %s\n", args[i]);
@ -94,12 +88,13 @@ void Swig_check_options() {
}
/* -----------------------------------------------------------------------------
* void Swig_arg_error()
* Swig_arg_error()
*
* Generates a generic error message and exits.
* ----------------------------------------------------------------------------- */
void Swig_arg_error() {
void
Swig_arg_error() {
Printf(stderr,"SWIG : Unable to parse command line options.\n");
Printf(stderr,"Use 'swig -help' for available options.\n");
exit(1);

View file

@ -1,46 +1,34 @@
/****************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
/* -----------------------------------------------------------------------------
* include.c
*
* The functions in this file are used to manage files in the SWIG library.
* General purpose functions for opening, including, and retrieving pathnames
* are provided.
*
* Author : David Beazley
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* 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.
****************************************************************************/
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
static char cvsroot[] = "$Header$";
#include "swig.h"
/*******************************************************************************
* $Header$
*
* File : include.c
*
* Various file manipulation functions.
*******************************************************************************/
/* Delimeter used in accessing files and directories */
static DOH *directories = 0; /* List of include directories */
static DOH *libdir = 0; /* SWIG library directory */
static DOH *lastpath = 0; /* Last file that was included */
static int bytes_read = 0; /* Bytes read */
/* -----------------------------------------------------------------------------
* void Swig_add_directory( DOH *dirname)
* Swig_add_directory()
*
* Adds a directory to the SWIG search path.
* ----------------------------------------------------------------------------- */
void
Swig_add_directory(DOH *dirname)
{
Swig_add_directory(DOH *dirname) {
if (!directories) directories = NewList();
assert(directories);
if (!String_check(dirname)) {
@ -51,35 +39,7 @@ Swig_add_directory(DOH *dirname)
}
/* -----------------------------------------------------------------------------
* void Swig_set_library(DOH *libname)
*
* Sets the language specific library name like 'tcl', 'perl5', 'python', etc...
* ----------------------------------------------------------------------------- */
void
Swig_set_library(DOH *libname)
{
Delete(libdir);
if (!String_check(libname)) {
libname = NewString((char *) libname);
assert(libname);
}
libdir = libname;
}
/* -----------------------------------------------------------------------------
* DOH *Swig_get_library()
*
* Gets the language specific name like 'tcl', 'perl5', etc...
* ----------------------------------------------------------------------------- */
DOH *
Swig_get_library() {
assert(libdir);
return libdir;
}
/* -----------------------------------------------------------------------------
* DOH *Swig_last_file()
* Swig_last_file()
*
* Returns the full pathname of the last file opened.
* ----------------------------------------------------------------------------- */
@ -91,13 +51,13 @@ Swig_last_file() {
}
/* -----------------------------------------------------------------------------
* DOH *Swig_search_path()
* Swig_search_path()
*
* Returns a list of the current search paths.
* ----------------------------------------------------------------------------- */
DOH *Swig_search_path()
{
DOH *
Swig_search_path() {
DOH *filename;
DOH *dirname;
DOH *slist;
@ -111,12 +71,6 @@ DOH *Swig_search_path()
Append(slist,filename);
for (i = 0; i < Len(directories); i++) {
dirname = Getitem(directories,i);
if (libdir) {
filename = NewString("");
assert(filename);
Printf(filename,"%s%s%s%s", dirname, SWIG_FILE_DELIMETER, libdir, SWIG_FILE_DELIMETER);
Append(slist,filename);
}
filename = NewString("");
assert(filename);
Printf(filename, "%s%s", dirname, SWIG_FILE_DELIMETER);
@ -126,14 +80,13 @@ DOH *Swig_search_path()
}
/* -----------------------------------------------------------------------------
* FILE *Swig_open( DOH *name)
* Swig_open()
*
* Looks for a file and open it.
* Looks for a file and open it. Returns an open FILE * on success.
* ----------------------------------------------------------------------------- */
FILE *
Swig_open(DOH *name)
{
Swig_open(DOH *name) {
FILE *f;
DOH *filename;
DOH *spath = 0;
@ -166,12 +119,13 @@ Swig_open(DOH *name)
}
/* -----------------------------------------------------------------------------
* DOH *Swig_read_file(FILE *f)
* Swig_read_file()
*
* Reads data from f and returns as a new string
* Reads data from an open FILE * and returns it as a string.
* ----------------------------------------------------------------------------- */
DOH *Swig_read_file(FILE *f) {
DOH *
Swig_read_file(FILE *f) {
char buffer[4096];
DOH *str = NewString("");
assert(str);
@ -183,14 +137,13 @@ DOH *Swig_read_file(FILE *f) {
}
/* -----------------------------------------------------------------------------
* DOH *Swig_include(DOH *name)
* Swig_include()
*
* Open a file and return it as a string.
* Opens a file and returns it as a string.
* ----------------------------------------------------------------------------- */
DOH *
Swig_include(DOH *name)
{
Swig_include(DOH *name) {
FILE *f;
DOH *str;
f = Swig_open(name);
@ -201,7 +154,12 @@ Swig_include(DOH *name)
Seek(str,0,SEEK_SET);
Setfile(str,lastpath);
Setline(str,1);
/* fprintf(stderr,"%d bytes read\n", bytes_read); */
return str;
}

View file

@ -1,29 +1,27 @@
/****************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
/* -----------------------------------------------------------------------------
* misc.c
*
* Miscellaneous functions that don't really fit anywhere else.
*
* Author : David Beazley
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* 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.
****************************************************************************/
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
static char cvsroot[] = "$Header$";
#include "swig.h"
/* -----------------------------------------------------------------------------
* $Header$
* Swig_copy_string()
*
* misc.c
* Duplicate a NULL-terminate string given as a char *.
* ----------------------------------------------------------------------------- */
char *copy_string(const char *s) {
char *
Swig_copy_string(const char *s) {
char *c = 0;
if (s) {
c = (char *) malloc(strlen(s)+1);

View file

@ -1,21 +1,21 @@
/****************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
/* -----------------------------------------------------------------------------
* scanner.c
*
* This file implements a general purpose C/C++ compatible lexical scanner.
* This scanner isn't intended to be plugged directly into a parser built
* with yacc. Rather, it contains a lot of generic code that could be used
* to easily construct yacc-compatible scanners.
*
* Author : David Beazley
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* 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.
****************************************************************************/
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
static char cvsroot[] = "$Header$";
#include "swig.h"
#include <ctype.h>
struct SwigScanner {
DOH *text; /* Current token value */
@ -30,21 +30,14 @@ struct SwigScanner {
DOH *file;
};
#include <ctype.h>
/* -----------------------------------------------------------------------------
* $Header$
* NewSwigScanner()
*
* scanner.c
*
* A generic C-based lexical scanner.
* Create a new scanner object
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* SwigScanner *NewSwigScanner() - Create a new scanner object.
* ----------------------------------------------------------------------------- */
SwigScanner *NewSwigScanner()
{
SwigScanner *
NewSwigScanner() {
SwigScanner *s;
s = (SwigScanner *) malloc(sizeof(SwigScanner));
s->line = 1;
@ -61,10 +54,13 @@ SwigScanner *NewSwigScanner()
}
/* -----------------------------------------------------------------------------
* DelSwigScanner(SwigScanner *s) - Delete a SwigScanner object
* DelSwigScanner()
*
* Delete a scanner object.
* ----------------------------------------------------------------------------- */
void DelSwigScanner(SwigScanner *s)
{
void
DelSwigScanner(SwigScanner *s) {
assert(s);
Delete(s->scanobjs);
Delete(s->text);
@ -73,9 +69,13 @@ void DelSwigScanner(SwigScanner *s)
}
/* -----------------------------------------------------------------------------
* SwigScanner_clear(SwigScanner *s) - Clear a scanner object
* SwigScanner_clear()
*
* Clear the contents of a scanner object.
* ----------------------------------------------------------------------------- */
void SwigScanner_clear(SwigScanner *s) {
void
SwigScanner_clear(SwigScanner *s) {
assert(s);
Delete(s->str);
Clear(s->text);
@ -88,11 +88,14 @@ void SwigScanner_clear(SwigScanner *s) {
}
/* -----------------------------------------------------------------------------
* SwigScanner_push(SwigScanner *s, DOH *txt) - Push text into the scanner
* SwigScanner_push()
*
* Push some new text into the scanner. The scanner will start parsing this text
* immediately before returning to the old text.
* ----------------------------------------------------------------------------- */
void SwigScanner_push(SwigScanner *s, DOH *txt)
{
void
SwigScanner_push(SwigScanner *s, DOH *txt) {
assert(s && txt);
Push(s->scanobjs,txt);
if (s->str) Delete(s->str);
@ -100,30 +103,37 @@ void SwigScanner_push(SwigScanner *s, DOH *txt)
Incref(s->str);
s->line = Getline(txt);
}
/* -----------------------------------------------------------------------------
* SwigScanner_pushtoken(SwigScanner *s, int nt)
* SwigScanner_pushtoken()
*
* Set the next processing token.
* Push a token into the scanner. This token will be returned on the next
* call to SwigScanner_token().
* ----------------------------------------------------------------------------- */
void SwigScanner_pushtoken(SwigScanner *s, int nt) {
void
SwigScanner_pushtoken(SwigScanner *s, int nt) {
assert(s);
assert((nt >= 0) && (nt < SWIG_MAXTOKENS));
s->nexttoken = nt;
}
/* -----------------------------------------------------------------------------
* SwigScanner_set_location(SwigScanner *s, DOH *file, int line)
* SwigScanner_set_location()
*
* Set the file and line number location of the scanner.
* ----------------------------------------------------------------------------- */
void
SwigScanner_set_location(SwigScanner *s, DOH *file, int line)
{
SwigScanner_set_location(SwigScanner *s, DOH *file, int line) {
Setline(s->str,line);
Setfile(s->str,file);
}
/* -----------------------------------------------------------------------------
* SwigScanner_get_file(SwigScanner *s) - Get current file
* SwigScanner_get_file()
*
* Get the current file.
* ----------------------------------------------------------------------------- */
DOH *
@ -131,24 +141,29 @@ SwigScanner_get_file(SwigScanner *s) {
return Getfile(s->str);
}
/* -----------------------------------------------------------------------------
* SwigScanner_get_line()
*
* Get the current line number
* ----------------------------------------------------------------------------- */
int
SwigScanner_get_line(SwigScanner *s) {
return Getline(s->str);
}
/* -----------------------------------------------------------------------------
* void SwigScanner_idstart(SwigScanner *s, char *id)
* SwigScanner_idstart()
*
* Set the characters that can be used to start an identifier
* Change the set of additional characters that can be used to start an identifier.
* ----------------------------------------------------------------------------- */
void
SwigScanner_idstart(SwigScanner *s, char *id) {
s->idstart = copy_string(id);
s->idstart = Swig_copy_string(id);
}
/* -----------------------------------------------------------------------------
* char nextchar(SwigScanner *s)
* nextchar()
*
* Returns the next character from the scanner or 0 if end of the string.
* ----------------------------------------------------------------------------- */
@ -176,7 +191,7 @@ nextchar(SwigScanner *s)
}
/* -----------------------------------------------------------------------------
* void retract(SwigScanner *s, int n)
* retract()
*
* Retract n characters
* ----------------------------------------------------------------------------- */
@ -199,14 +214,13 @@ retract(SwigScanner *s, int n) {
}
/* -----------------------------------------------------------------------------
* int look(SwigScanner *s)
* look()
*
* Get the next token.
* Return the raw value of the next token.
* ----------------------------------------------------------------------------- */
static int
look(SwigScanner *s)
{
look(SwigScanner *s) {
int state;
char c = 0;
@ -632,14 +646,13 @@ look(SwigScanner *s)
}
/* -----------------------------------------------------------------------------
* int SwigScanner_token(SwigScanner *s)
* SwigScanner_token()
*
* Return the next token or 0 if at the end of the string
* Real entry point to return the next token. Returns 0 if at end of input.
* ----------------------------------------------------------------------------- */
int
SwigScanner_token(SwigScanner *s)
{
SwigScanner_token(SwigScanner *s) {
int t;
Clear(s->text);
if (s->nexttoken >= 0) {
@ -652,25 +665,24 @@ SwigScanner_token(SwigScanner *s)
}
/* -----------------------------------------------------------------------------
* DOH *SwigScanner_text(SwigScanner *s)
* SwigScanner_text()
*
* Return the text associated with the last token returned.
* Return the lexene associated with the last returned token.
* ----------------------------------------------------------------------------- */
DOH *
SwigScanner_text(SwigScanner *s)
{
SwigScanner_text(SwigScanner *s) {
return s->text;
}
/* -----------------------------------------------------------------------------
* void SwigScanner_skip_line(SwigScanner *s)
* SwigScanner_skip_line()
*
* Skips to the end of a line
* ----------------------------------------------------------------------------- */
void
SwigScanner_skip_line(SwigScanner *s)
{
SwigScanner_skip_line(SwigScanner *s) {
char c;
int done = 0;
Clear(s->text);
@ -685,15 +697,14 @@ SwigScanner_skip_line(SwigScanner *s)
}
/* -----------------------------------------------------------------------------
* void SwigScanner_skip_balanced(SwigScanner *s, int start, int end)
* SwigScanner_skip_balanced()
*
* Skips a piece of code enclosed in begin/end symbols such as '{...}' or
* (...). Ignores symbols inside comments or strings.
* ----------------------------------------------------------------------------- */
int
SwigScanner_skip_balanced(SwigScanner *s, int startchar, int endchar)
{
SwigScanner_skip_balanced(SwigScanner *s, int startchar, int endchar) {
char c;
int num_levels = 1;
int l;

View file

@ -1,30 +1,21 @@
/* ----------------------------------------------------------------------
* Simplified Wrapper and Interface Generator (SWIG)
/* -----------------------------------------------------------------------------
* super.c
*
* SuperStrings are just like strings, except that they maintain
* information as to the origininal file/line of each character they
* contain.
*
* Authors : David Beazley
* Dustin Mitchell
* Author(s) : Dustin Mitchell (djmitche@cs.uchicago.edu)
*
* 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.
---------------------------------------------------------------------- */
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
#include "doh.h"
#include "swig.h"
static char cvstag[] = "$Header$";
/*
* SuperStrings are just like strings, except that they maintain
* information as to the origininal file/line of each character they
* contain.
*/
typedef struct SSTag
{
int length; /* distance to the next tag */

View file

@ -1,17 +1,16 @@
/****************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
/* -----------------------------------------------------------------------------
* swig.h
*
* Header file for the SWIG core.
*
* Author : David Beazley
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
* Dustin Mitchell (djmitche@cs.uchicago.edu)
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
* Copyright (C) 1999-2000. The University of Chicago
* 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$
* ----------------------------------------------------------------------------- */
#ifndef _SWIGCORE_H
#define _SWIGCORE_H
@ -20,6 +19,7 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "doh.h"
#ifdef __cplusplus
@ -29,8 +29,6 @@ extern "C" {
/* --- File interface --- */
extern void Swig_add_directory(DOH *dirname);
extern void Swig_set_library(DOH *libname);
extern DOH *Swig_get_library();
extern DOH *Swig_last_file();
extern DOH *Swig_search_path();
extern FILE *Swig_open(DOH *name);
@ -51,7 +49,6 @@ extern void Swig_mark_arg(int n);
extern void Swig_check_options();
extern void Swig_arg_error();
/* --- Scanner Interface --- */
typedef struct SwigScanner SwigScanner;
@ -122,8 +119,7 @@ extern void SwigScanner_idstart(SwigScanner *, char *idchar);
#define SWIG_TOKEN_LAST 99
/* --- Misc --- */
extern char *copy_string(const char *c);
extern char *Swig_copy_string(const char *c);
#ifdef __cplusplus
}