*** empty log message ***

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4143 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2002-12-01 20:45:43 +00:00
commit b0941de80a
15 changed files with 0 additions and 3710 deletions

View file

@ -1,31 +0,0 @@
# ---------------------------------------------------------------
# $Header$
#----------------------------------------------------------------
srcdir = @srcdir@
VPATH = @srcdir@
SRCS = init.c inputmodule.c cppmodule.c cparsemodule.c
OBJS = init.o inputmodule.o cppmodule.o cparsemodule.o
prefix = @prefix@
exec_prefix = @exec_prefix@
CC = @CC@
AR = @AR@
RANLIB = @RANLIB@
CFLAGS = @CFLAGS@
INCLUDE = -I$(srcdir)/. -I$(srcdir)/../Include -I$(srcdir)/../DOH/Include -I$(srcdir)/../Swig -I$(srcdir)/../Preprocessor -I$(srcdir)/../LParse
TARGET = libmodules.a
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $<
all: $(TARGET)
$(TARGET): $(OBJS)
$(AR) cr $(TARGET) $(OBJS)
$(RANLIB) $(TARGET)
clean:
rm -f *.o *~ core *.so *.a *_wrap.*

View file

@ -1,55 +0,0 @@
/* -----------------------------------------------------------------------------
* cparsemodule.c
*
* This module is responsible for running the SWIG C Parsing module.
*
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
#include "swig.h"
#include "swigconfig.h"
#include "lparse.h"
static const char *usage = "C Parsing options:\n\
";
static
int cparse_init(int argc, char **argv) {
int i;
/* Look for command line options */
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i],"-c++") == 0) {
LParse_cplusplus(1);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
Printf(stderr,"%s",usage);
Swig_mark_arg(i);
}
}
}
return 0;
}
static
DOH *cparse_run(DOH *node) {
String *data;
DOH *result;
data = Getattr(node,"data");
if (!data) {
Printf(stderr,"SWIG: cparse error. no data.\n");
Swig_exit(1);
}
Seek(data,0, SEEK_SET);
result = LParse_parse(data);
Setattr(result,"last",node);
return result;
}
void cparsemodule() {
Swig_register_module("cparse","swig:preprocess", cparse_init, cparse_run);
}

View file

@ -1,92 +0,0 @@
/* -----------------------------------------------------------------------------
* cppmodule.c
*
* This module is responsible for running the SWIG preprocessor module.
*
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
#include "swig.h"
#include "swigconfig.h"
#include "preprocessor.h"
static int cpp_only = 0;
static const char *usage = "Preprocessor options:\n\
-E - Run the preprocessor only\n\
-Dmacro - Define a new macro\n\
";
static
int preprocessor_init(int argc, char **argv) {
int i;
/* Look for command line options */
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i],"-E") == 0) {
cpp_only = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-c++") == 0) {
Preprocessor_define("__cplusplus 1", 0);
Swig_mark_arg(i);
} else if (strncmp(argv[i],"-D",2) == 0) {
DOH *d = NewString(argv[i]+2);
Replace(d,"="," ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
Preprocessor_define(d,0);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-includeall") == 0) {
Preprocessor_include_all(1);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
Printf(stderr,"%s",usage);
Swig_mark_arg(i);
}
}
}
return 0;
}
static
DOH *preprocessor_run(DOH *node) {
String *cpps, *data;
DOH *result;
data = Getattr(node,"data");
if (!data) {
Printf(stderr,"SWIG: preprocessor error. no data.\n");
Swig_exit(1);
}
Preprocessor_define("SWIG 1", 0);
Preprocessor_define("__STDC__ 1", 0);
#ifdef MACSWIG
Preprocessor_define("SWIGMAC 1", 0);
#endif
#ifdef SWIGWIN32
Preprocessor_define("SWIGWIN32 1", 0);
#endif
Seek(data,0, SEEK_SET);
cpps = Preprocessor_parse(data);
if (cpp_only) {
Printf(stdout,"%s", cpps);
return 0;
}
result = NewHash();
Settag(result,"swig:preprocess");
Setfile(cpps,Getfile(data));
Setline(cpps,Getline(data));
Seek(cpps,0,SEEK_SET);
Setattr(result,"data",cpps);
Setattr(result,"last",node);
return result;
}
void preprocessormodule() {
Swig_register_module("preprocessor","swig:input", preprocessor_init, preprocessor_run);
Preprocessor_init();
}

View file

@ -1,52 +0,0 @@
/* -----------------------------------------------------------------------------
* init.c
*
* Initialize built-in SWIG modules.
*
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
#include "swig.h"
extern void inputmodule();
extern void preprocessormodule();
extern void cparsemodule();
extern void swig11module();
static void (*modules[])(void) = {
inputmodule,
preprocessormodule,
cparsemodule,
swig11module,
0
};
/* -----------------------------------------------------------------------------
* init_modules()
*
* ----------------------------------------------------------------------------- */
void init_modules() {
int i = 0;
while (modules[i]) {
(*modules[i])();
i++;
}
}
/* This array contains the names of modules that should be loaded by default */
static char *default_modules[] = {
"input",
"preprocessor",
"cparse",
0
};
int main(int argc, char **argv) {
init_modules();
return Swig_main(argc, argv, default_modules);
}

View file

@ -1,186 +0,0 @@
/* -----------------------------------------------------------------------------
* inputmodule.c
*
* This module is responsible for reading input files and setting up all
* of the proper search paths.
*
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* Copyright (C) 1999-2000. The University of Chicago
* See the file LICENSE for information on usage and redistribution.
* ----------------------------------------------------------------------------- */
#include "swig.h"
#include "swigconfig.h"
#ifndef SWIG_LIB
#define SWIG_LIB "./swiglib"
#endif
static int checkout = 0;
static List *includedirs;
static List *libfiles;
static String *outfile = 0;
static int debug_path = 0;
static int debug_input = 0;
static const char *usage = "File options:\n\
-I<dir> - Look for SWIG files in <dir>\n\
-l<ifile> - Include SWIG library file.\n\
-o outfile - Set name of the output file.\n\
-co - Check file out of SWIG library.\n\
";
static
int input_init(int argc, char **argv) {
char *c;
int i;
/* Directories included with the -I option */
includedirs = NewList();
/* Files added with the -l option */
libfiles = NewList();
/* Look for command line options */
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strncmp(argv[i],"-I",2) == 0) {
Append(includedirs,argv[i]+2);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-debug_path") == 0) {
debug_path = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-debug_input") == 0) {
debug_input = 1;
Swig_mark_arg(i);
} else if (strncmp(argv[i],"-l",2) == 0) {
Append(libfiles, argv[i]+2);
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-co") == 0) {
checkout = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-o") == 0) {
Swig_mark_arg(i);
if (argv[i+1]) {
outfile = NewString(argv[i+1]);
Swig_mark_arg(i+1);
i++;
} else {
Swig_arg_error();
}
} else if (strcmp(argv[i],"-help") == 0) {
Printf(stderr,"%s",usage);
Swig_mark_arg(i);
}
}
}
/* Set the location of the SWIG library */
if (!(c = getenv("SWIG_LIB"))) {
Append(includedirs,SWIG_LIB);
} else {
Append(includedirs,c);
}
return 0;
}
static
DOH *input_run(DOH *node) {
int i;
String *infile;
FILE *f;
String *input;
DOH *result;
String *swiglib;
String *lang_config;
infile = Getname(node);
/* Register all of the include directories */
swiglib = Swig_swiglib_get();
for (i = Len(includedirs); i > 0; i--) {
if (swiglib) {
String *l = NewStringf("%s%s%s", Getitem(includedirs,i-1),SWIG_FILE_DELIMETER,swiglib);
Swig_add_directory(l);
}
Swig_add_directory(Getitem(includedirs,i-1));
}
if (debug_path) {
List *l;
Printf(stdout,"SWIG search path:\n");
l = Swig_search_path();
if (l) {
String *s;
for (s = Firstitem(l); s; s = Nextitem(l)) {
Printf(stdout," %s\n", s);
}
}
}
/* user has requested to simply check out a file */
if (checkout) {
String *outfilename;
String *s;
outfilename = outfile ? outfile : infile;
/* Grab the file */
s = Swig_include(infile);
if (!s) {
Printf(stderr,"Unable to locate '%s' in the SWIG library.\n", infile);
Swig_exit(EXIT_FAILURE);
} else {
File *f = NewFile(outfilename,"r");
if (f) {
Delete(f);
Printf(stderr,"File '%s' already exists. Checkout aborted.\n", outfilename);
} else {
f = NewFile(outfilename,"w");
if (!f) {
Printf(stderr,"Unable to create file '%s'\n", outfilename);
} else {
Printf(stderr,"'%s' checked out from the SWIG library.\n", infile);
Dump(s,f);
Delete(f);
}
}
}
return 0;
}
/* Try to find input files */
f = Swig_open(infile);
if (!f) {
Printf(stderr,"Unable to find '%s'\n", infile);
Swig_exit (EXIT_FAILURE);
}
fclose(f);
input = NewString("%include \"swig.swg\"\n");
lang_config = Swig_get_config_file();
if (lang_config) {
Printf(input,"\n%%include \"%s\"\n", lang_config);
}
Printf(input,"\n%%include \"%s\"\n", infile);
for (i = 0; i < Len(libfiles); i++) {
Printf(input,"\n%%include \"%s\"\n", Getitem(libfiles,i));
}
result = NewHash();
Settag(result,"swig:input");
Setattr(result,"name", infile);
Setattr(result,"path", Getfile(input));
Setattr(result,"outfile", outfile);
Setattr(result,"data",input);
Setattr(result,"last",node);
if (debug_input) {
Printf(stdout,"::: inputmodule :::\n");
Printf(stdout,"%s\n", input);
}
return result;
}
void inputmodule() {
Swig_register_module("input","swig:initial", input_init, input_run);
}

View file

@ -1,228 +0,0 @@
/* -----------------------------------------------------------------------------
* test.c
*
* This module is used to test the tag-based parser.
* ----------------------------------------------------------------------------- */
#include "swig.h"
int test_unknown(DOH *node, void *clientdata) {
Printf(stdout,"::: Unknown tag - '%s'\n", Getattr(node,"tag"));
return 0;
}
int test_file(DOH *node, void *clientdata) {
DOH *c;
Printf(stdout,"::: File\n");
Printf(stdout," name = '%s'\n", Getattr(node,"name"));
Printf(stdout," type = '%s'\n", Getattr(node,"type"));
c = Getchild(node);
Printf(stdout," # elements = %d\n", Swig_count_nodes(c));
Swig_emit_all(c,clientdata);
return 0;
}
int test_scope(DOH *node, void *clientdata) {
DOH *c;
Printf(stdout,"::: Scope\n");
Printf(stdout," name = '%s'\n", Getattr(node,"name"));
c = Getchild(node);
Swig_emit_all(c,clientdata);
return 0;
}
int test_module(DOH *node, void *clientdata) {
Printf(stdout,"::: Module\n");
Printf(stdout," name = '%s'\n", Getname(node));
return 0;
}
int test_insert(DOH *node, void *clientdata) {
Printf(stdout,"::: Insert\n");
Printf(stdout," section = '%s'\n", Getattr(node,"section"));
Printf(stdout," filename = '%s'\n", Getattr(node,"filename"));
Printf(stdout," code = '%s'\n", Getattr(node,"code"));
return 0;
}
int test_pragma(DOH *node, void *clientdata) {
Printf(stdout,"::: Pragma\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," value = '%s'\n", Getvalue(node));
return 0;
}
int test_typemap(DOH *node, void *clientdata) {
Printf(stdout,"::: Typemap\n");
Printf(stdout," type = '%s'\n", Gettype(node));
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," code = '%s'\n", Getattr(node,"code"));
Printf(stdout," srcname = '%s'\n", Getattr(node,"srcname"));
Printf(stdout," srctype = '%s'\n", Getattr(node,"srctype"));
{
DOH *p = Getattr(node,"parms");
if (p) {
Printf(stdout," parms = '%s'\n", ParmList_protostr(p));
}
}
return 0;
}
int test_apply(DOH *node, void *clientdata) {
Printf(stdout,"::: Apply\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," type = '%s'\n", Gettype(node));
Printf(stdout," parms = (%s)\n", ParmList_protostr(Getattr(node,"parms")));
return 0;
}
int test_exception(DOH *node, void *clientdata) {
Printf(stdout,"::: Exception\n");
Printf(stdout," code = '%s'\n", Getattr(node,"code"));
return 0;
}
int test_clear(DOH *node, void *clientdata) {
Printf(stdout,"::: Clear\n");
Printf(stdout," parms = (%s)\n", ParmList_protostr(Getattr(node,"parms")));
return 0;
}
int test_constant(DOH *node, void *clientdata) {
Printf(stdout,"::: Constant\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," type = '%s'\n", Gettype(node));
Printf(stdout," value = '%s'\n", Getvalue(node));
return 0;
}
int test_function(DOH *node, void *clientdata) {
Printf(stdout,"::: Function\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," type = '%s'\n", Gettype(node));
Printf(stdout," parms = (%s)\n", ParmList_protostr(Getattr(node,"parms")));
Printf(stdout," storage = '%s'\n", Getattr(node,"storage"));
Printf(stdout," code = '%s'\n", Getattr(node,"code"));
return 0;
}
int test_variable(DOH *node, void *clientdata) {
Printf(stdout,"::: Variable\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," type = '%s'\n", Gettype(node));
Printf(stdout," storage = '%s'\n", Getattr(node,"storage"));
Printf(stdout," value = '%s'\n", Getattr(node,"value"));
return 0;
}
int test_typedef(DOH *node, void *clientdata) {
Printf(stdout,"::: Typedef\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," type = '%s'\n", Gettype(node));
return 0;
}
int test_enum(DOH *node, void *clientdata) {
DOH *c;
Printf(stdout,"::: Enum\n");
Printf(stdout," name = '%s'\n", Getname(node));
c = Getchild(node);
Swig_emit_all(c,clientdata);
return 0;
}
int test_enumvalue(DOH *node, void *clientdata) {
Printf(stdout,"::: Enumvalue\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," value = '%s'\n", Getvalue(node));
return 0;
}
int test_class(DOH *node, void *clientdata) {
DOH *c;
Printf(stdout,"::: Class\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," bases = %s\n", Getattr(node,"bases"));
Printf(stdout," altname = '%s'\n", Getattr(node,"altname"));
Printf(stdout," classtype = '%s'\n", Getattr(node,"classtype"));
c = Getchild(node);
Swig_emit_all(c,clientdata);
return 0;
}
int test_classdecl(DOH *node, void *clientdata) {
Printf(stdout,"::: Classdecl\n");
Printf(stdout," name = '%s'\n", Getname(node));
return 0;
}
int test_addmethods(DOH *node, void *clientdata) {
DOH *c;
Printf(stdout,"::: Addmethods\n");
Printf(stdout," name = '%s'\n", Getname(node));
c = Getchild(node);
Swig_emit_all(c,clientdata);
return 0;
}
int test_destructor(DOH *node, void *clientdata) {
Printf(stdout,"::: Destructor\n");
Printf(stdout," name = '%s'\n", Getname(node));
Printf(stdout," code = '%s'\n", Getattr(node,"code"));
return 0;
}
int test_access(DOH *node, void *clientdata) {
Printf(stdout,"::: AccessSpecifier\n");
Printf(stdout," name = '%s'\n", Getname(node));
return 0;
}
static SwigRule rules[] = {
{ "file", test_file},
{ "module", test_module},
{ "scope", test_scope},
{ "insert", test_insert},
{ "pragma", test_pragma},
{ "typemap", test_typemap},
{ "apply", test_apply},
{ "exception", test_exception},
{ "clear", test_clear},
{ "addmethods", test_addmethods},
{ "constant", test_constant},
{ "function", test_function},
{ "variable", test_variable},
{ "typedef", test_typedef},
{ "enum", test_enum},
{ "enumvalue", test_enumvalue},
{ "class", test_class},
{ "classdecl", test_classdecl},
{ "destructor", test_destructor},
{ "access", test_access},
{ "*", test_unknown},
{ 0 }
};
static
int test_init(int argc, char **argv) {
Printf(stdout,"test_init:\n");
return 0;
}
static
DOH *test_run(DOH *node) {
DOH *c;
Printf(stdout,"test_run:\n");
Swig_add_rules(rules);
c = Getattr(node,"child");
Swig_emit_all(c,0);
return 0;
}
void testmodule() {
Swig_register_module("test","swig:top", test_init, test_run);
}