Lot's of cleanup. Removed some more source files. Migrated more functionality to C.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@494 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2ff8e83a04
commit
243ef9cfee
21 changed files with 241 additions and 482 deletions
12
CHANGES
12
CHANGES
|
|
@ -1,5 +1,17 @@
|
|||
SWIG (Simplified Wrapper and Interface Generator)
|
||||
|
||||
Version 1.3 Alpha 3 (June 18, 2000)
|
||||
===================================
|
||||
|
||||
6/18/00 : beazley
|
||||
Removed the naming.cxx, hash.cxx, and symbol.cxx files from
|
||||
the SWIG1.1 directory. Continued to migrate things away
|
||||
from the C++ base (although there's still a lot of work to do).
|
||||
|
||||
6/17/00 : beazley
|
||||
Added a few more examples to the Examples directory. Still
|
||||
need to do a lot of work on this.
|
||||
|
||||
6/16/00 : beazley
|
||||
Added -includeall to follow all #include statements in the
|
||||
preprocessor.
|
||||
|
|
|
|||
18
README
18
README
|
|
@ -22,15 +22,18 @@ SWIG release. The guilty parties working on this are:
|
|||
***** IMPORTANT NOTICE -- READ THIS NOW! *****
|
||||
***********************************************************************
|
||||
|
||||
If you downloaded SWIG as a prepackaged release such as SWIG1.3a2, be
|
||||
If you downloaded SWIG as a prepackaged release such as SWIG1.3a3, be
|
||||
advised that this distribution represents a snapshot of the most
|
||||
stable part of the SWIG CVS repository. As this is an unstable
|
||||
release, there is a pretty good chance that a number of features are
|
||||
broken or under repair. Currently, SWIG is undergoing a large
|
||||
redevelopment effort. The SWIG1.3 series of releases should be viewed
|
||||
as a transitional releases leading to the eventual release of SWIG2.0.
|
||||
First-time users may want to start with SWIG1.1p5 which is significantly
|
||||
more stable (and includes a wider range of documentation and examples).
|
||||
redevelopment effort in which it is being converted from C++ to ANSI
|
||||
C. As a result, the source code is a little disorganized at the
|
||||
moment. The SWIG1.3 series of releases should be viewed as
|
||||
transitional releases leading to the eventual release of
|
||||
SWIG2.0. First-time users may want to start with SWIG1.1p5 which is
|
||||
significantly more stable (and includes a wider range of documentation
|
||||
and examples).
|
||||
|
||||
Please report any errors and submit patches (if possible)! We only
|
||||
have access to a limited variety of hardware (Linux, Solaris, and
|
||||
|
|
@ -70,6 +73,11 @@ What's Broken?
|
|||
|
||||
- SWIG requires an ANSI C compiler.
|
||||
|
||||
- A number of low-level data structures have been converted
|
||||
to C. Since things haven't yet been fully tested, there's
|
||||
a chance that unusual corner cases might cause SWIG to crash.
|
||||
If so, please send us a debugger traceback if possible.
|
||||
|
||||
Installation
|
||||
============
|
||||
To build and install SWIG, simply type the following:
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ GUILE::set_init (char *iname)
|
|||
void
|
||||
GUILE::headers (void)
|
||||
{
|
||||
emit_banner (f_header);
|
||||
Swig_banner (f_header);
|
||||
|
||||
fprintf (f_header, "/* Implementation : GUILE */\n\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ void JAVA::set_module(char *mod_name, char **mod_list) {
|
|||
|
||||
void JAVA::headers(void)
|
||||
{
|
||||
emit_banner(f_header); // Print the SWIG banner message
|
||||
Swig_banner(f_header); // Print the SWIG banner message
|
||||
fprintf(f_header,"/* Implementation : Java */\n\n");
|
||||
|
||||
// Include header file code fragment into the output
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ MZSCHEME::set_init (char *iname)
|
|||
void
|
||||
MZSCHEME::headers (void)
|
||||
{
|
||||
emit_banner (f_header);
|
||||
Swig_banner (f_header);
|
||||
|
||||
fprintf (f_header, "/* Implementation : MZSCHEME */\n\n");
|
||||
fprintf (f_header, "#include <stdio.h>\n");
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ void PERL5::set_init(char *iname) {
|
|||
void PERL5::headers(void)
|
||||
{
|
||||
|
||||
emit_banner(f_header);
|
||||
Swig_banner(f_header);
|
||||
|
||||
if (!alt_header) {
|
||||
if (Swig_insert_file("headers.swg", f_header) == -1) {
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ void PYTHON::print_methods() {
|
|||
void PYTHON::headers(void)
|
||||
{
|
||||
|
||||
emit_banner(f_runtime);
|
||||
Swig_banner(f_runtime);
|
||||
|
||||
fprintf(f_runtime,"/* Implementation : PYTHON */\n\n");
|
||||
fprintf(f_runtime,"#define SWIGPYTHON\n");
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ void TCL8::set_init(char *iname) {
|
|||
void TCL8::headers(void)
|
||||
{
|
||||
|
||||
emit_banner(f_runtime);
|
||||
Swig_banner(f_runtime);
|
||||
|
||||
// Include a Tcl configuration file for Unix,Mac,Wintel.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ RANLIB = @RANLIB@
|
|||
|
||||
TARGET = libswig11.a
|
||||
|
||||
OBJS = parser.o main.o scanner.o symbol.o types.o parms.o \
|
||||
emit.o cplus.o lang.o hash.o sstring.o wrapfunc.o \
|
||||
OBJS = parser.o main.o scanner.o types.o parms.o \
|
||||
emit.o cplus.o lang.o sstring.o wrapfunc.o \
|
||||
typemap.o
|
||||
|
||||
SRCS = main.cxx scanner.cxx symbol.cxx types.cxx parms.cxx \
|
||||
emit.cxx cplus.cxx lang.cxx hash.cxx \
|
||||
SRCS = main.cxx scanner.cxx types.cxx parms.cxx \
|
||||
emit.cxx cplus.cxx lang.cxx \
|
||||
sstring.cxx wrapfunc.cxx typemap.cxx
|
||||
|
||||
PARSER = $(srcdir)/parser.yxx
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ static char cvstag[] = "$Header$";
|
|||
|
||||
static int Inherit_mode = 0; // Set if we're inheriting members
|
||||
static char *ccode = 0; // Set to optional C code (if available)
|
||||
static Hash *localtypes; // Localtype hash
|
||||
static DOHHash *localtypes = 0; // Localtype hash
|
||||
static int abstract =0; // Status bit set during code generation
|
||||
|
||||
static int cpp_id = 0;
|
||||
|
|
@ -116,7 +116,7 @@ static void add_local_type(char *type, char *classname) {
|
|||
if (!localtypes) return; // No hash table initialized, ignore this
|
||||
|
||||
str << classname << "::" << type;
|
||||
localtypes->add(type,copy_string(str));
|
||||
Setattr(localtypes,type,str.get());
|
||||
}
|
||||
|
||||
void add_local_type(DataType *type, char *classname) {
|
||||
|
|
@ -139,7 +139,7 @@ static void update_local_type(DataType *type) {
|
|||
|
||||
if (!localtypes) return;
|
||||
|
||||
newname = (char *) localtypes->lookup(type->name);
|
||||
newname = GetChar(localtypes,type->name);
|
||||
if (newname) {
|
||||
strcpy(type->name, newname);
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ static void update_parms(ParmList *l) {
|
|||
|
||||
if ((p->defvalue) && (localtypes)) {
|
||||
char *s;
|
||||
s = (char *) localtypes->lookup(p->defvalue);
|
||||
s = (char *) GetChar(localtypes,p->defvalue);
|
||||
if (s) {
|
||||
delete p->defvalue;
|
||||
p->defvalue = copy_string(s);
|
||||
|
|
@ -501,7 +501,7 @@ public:
|
|||
int error; // Set if this class can't be generated
|
||||
int line; // Line number
|
||||
char **baseclass; // Base classes (if any)
|
||||
Hash *local; // Hash table for local types
|
||||
DOHHash *local; // Hash table for local types
|
||||
void *scope; // Local scope hash table
|
||||
CPP_member *members; // Linked list of members
|
||||
CPP_class *next; // Next class
|
||||
|
|
@ -514,7 +514,7 @@ public:
|
|||
classtype = copy_string(ctype);
|
||||
classrename = 0;
|
||||
baseclass = 0;
|
||||
local = new Hash; // Create hash table for storing local datatypes
|
||||
local = NewHash(); // Create hash table for storing local datatypes
|
||||
scope = 0;
|
||||
error = 0;
|
||||
pragmas = 0;
|
||||
|
|
@ -944,7 +944,7 @@ void cplus_inherit(int count, char **baseclass) {
|
|||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static Hash convert; // Hash table of conversion functions
|
||||
static DOHHash *convert = 0; // Hash table of conversion functions
|
||||
|
||||
void cplus_generate_types(char **baseclass) {
|
||||
CPP_class *bc;
|
||||
|
|
@ -956,6 +956,8 @@ void cplus_generate_types(char **baseclass) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!convert) convert = NewHash();
|
||||
|
||||
// Generate type-conversion functions and type-equivalence
|
||||
|
||||
i = 0;
|
||||
|
|
@ -970,7 +972,8 @@ void cplus_generate_types(char **baseclass) {
|
|||
temp3 = "";
|
||||
temp3 << "Swig" << current_class->classname << "To" << bc->classname;
|
||||
|
||||
if (convert.add(temp3,(void *) 1) != -1) {
|
||||
if (!Getattr(convert,temp3.get())) {
|
||||
SetVoid(convert,temp3.get(),(void*) 1);
|
||||
|
||||
// Write a function for casting derived type to parent class
|
||||
|
||||
|
|
@ -1300,9 +1303,6 @@ void cplus_declare_const(char *name, char *iname, DataType *type, char *value) {
|
|||
CPP_constant *c = new CPP_constant(name, temp_iname, type, value);
|
||||
current_class->add_member(c);
|
||||
|
||||
// Update this symbol in the symbol table
|
||||
update_symbol(name, type, value);
|
||||
|
||||
// Add this symbol to local scope of a class
|
||||
add_local_type(name, current_class->classname);
|
||||
}
|
||||
|
|
@ -1387,7 +1387,7 @@ void cplus_add_pragma(char *lang, char *name, char *value)
|
|||
// sharing code between base and derived classes.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static Hash member_hash; // Hash wrapping member function wrappers to scripting wrappers
|
||||
static DOHHash *member_hash = 0; // Hash wrapping member function wrappers to scripting wrappers
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
||||
|
|
@ -1516,9 +1516,13 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
l->print_types(key);
|
||||
// printf("key = %s\n", (char *) key);
|
||||
char *temp = copy_string(iname);
|
||||
if ((member_hash.add(key,temp)) == -1) {
|
||||
if (!member_hash) member_hash = NewHash();
|
||||
if (Getattr(member_hash,key.get())) {
|
||||
delete [] temp;
|
||||
prev_wrap = GetChar(member_hash,key.get());
|
||||
} else {
|
||||
Setattr(member_hash,key.get(),temp);
|
||||
delete [] temp;
|
||||
prev_wrap = (char *) member_hash.lookup(key);
|
||||
}
|
||||
|
||||
// Only generate code if an already existing wrapper doesn't exist
|
||||
|
|
@ -1730,9 +1734,13 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
key << cname << "+";
|
||||
l->print_types(key);
|
||||
char *temp = copy_string(iname);
|
||||
if ((member_hash.add(key,temp)) == -1) {
|
||||
if (!member_hash) member_hash = NewHash();
|
||||
if (Getattr(member_hash,key.get())) {
|
||||
delete [] temp;
|
||||
prev_wrap = GetChar(member_hash,key.get());
|
||||
} else {
|
||||
Setattr(member_hash,key.get(),temp);
|
||||
delete [] temp;
|
||||
prev_wrap = (char *) member_hash.lookup(key);
|
||||
}
|
||||
|
||||
if (!prev_wrap) {
|
||||
|
|
@ -2151,9 +2159,13 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
|
||||
key << cname;
|
||||
char *temp = copy_string(iname);
|
||||
if ((member_hash.add(key,temp)) == -1) {
|
||||
if (!member_hash) member_hash = NewHash();
|
||||
if (Getattr(member_hash,key.get())) {
|
||||
delete [] temp;
|
||||
prev_wrap = GetChar(member_hash,key.get());
|
||||
} else {
|
||||
Setattr(member_hash,key.get(),temp);
|
||||
delete [] temp;
|
||||
prev_wrap = (char *) member_hash.lookup(key);
|
||||
}
|
||||
|
||||
// Only generate code if already existing wrapper doesn't exist
|
||||
|
|
@ -2328,9 +2340,13 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
|
||||
key << cname;
|
||||
char *temp = copy_string(iname);
|
||||
if ((member_hash.add(key,temp)) == -1) {
|
||||
if (!member_hash) member_hash = NewHash();
|
||||
if (Getattr(member_hash,key.get())) {
|
||||
delete [] temp;
|
||||
prev_wrap = GetChar(member_hash,key.get());
|
||||
} else {
|
||||
Setattr(member_hash,key.get(),temp);
|
||||
delete [] temp;
|
||||
prev_wrap = (char *) member_hash.lookup(key);
|
||||
}
|
||||
|
||||
// Only generate code if already existing wrapper doesn't exist
|
||||
|
|
@ -2519,9 +2535,9 @@ void cplus_register_scope(void *h) {
|
|||
void cplus_inherit_scope(int count, char **baseclass) {
|
||||
CPP_class *bc;
|
||||
int i;
|
||||
char *key, *val;
|
||||
char *val;
|
||||
String str;
|
||||
|
||||
DOH *key;
|
||||
if (count && current_class) {
|
||||
for (i = 0; i < count; i++) {
|
||||
bc = CPP_class::search(baseclass[i]);
|
||||
|
|
@ -2531,13 +2547,13 @@ void cplus_inherit_scope(int count, char **baseclass) {
|
|||
|
||||
if (bc->local) {
|
||||
// Copy local symbol table
|
||||
key = bc->local->firstkey();
|
||||
key = Firstkey(bc->local);
|
||||
while (key) {
|
||||
val = (char *) bc->local->lookup(key);
|
||||
val = GetChar(bc->local,key);
|
||||
str = val;
|
||||
// str.replace(bc->classname,current_class->classname);
|
||||
localtypes->add(key,copy_string(str));
|
||||
key = bc->local->nextkey();
|
||||
Setattr(localtypes,key,str.get());
|
||||
key = Nextkey(bc->local);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,43 +17,8 @@ extern "C" {
|
|||
#include "swig.h"
|
||||
}
|
||||
|
||||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void emit_banner(FILE *f)
|
||||
//
|
||||
// Emits the SWIG identifying banner in the wrapper file
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void emit_banner(FILE *f) {
|
||||
|
||||
extern char *get_time();
|
||||
extern char fn_runtime[];
|
||||
|
||||
fprintf(f,
|
||||
"/*\n\
|
||||
* FILE : %s\n\
|
||||
* \n\
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).\n\
|
||||
* Version %s %s\n\
|
||||
* \n\
|
||||
* Portions Copyright (c) 1995-1999\n\
|
||||
* The University of Utah, The Regents of the University of California, and\n\
|
||||
* The University of Chicago. Permission is granted to use and distribute this\n\
|
||||
* file in any manner provided this notice remains intact.\n\
|
||||
* \n\
|
||||
* This file is not intended to be easily readable and contains a number of \n\
|
||||
* coding conventions designed to improve portability and efficiency. Do not make\n\
|
||||
* changes to this file unless you know what you are doing--modify the SWIG \n\
|
||||
* interface file instead. \n\
|
||||
*\n\
|
||||
*/\n\n", fn_runtime, SWIG_VERSION, SWIG_SPIN);
|
||||
|
||||
fprintf(f,"\n#define SWIGCODE\n");
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// emit_extern_var(char *decl, DataType *t, int extern_type, FILE *f)
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* hash.cxx
|
||||
*
|
||||
* Hash table object.
|
||||
*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "internal.h"
|
||||
extern "C" {
|
||||
#include "doh.h"
|
||||
}
|
||||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
Hash::Hash() {
|
||||
data = NewHash();
|
||||
}
|
||||
|
||||
Hash::~Hash() {
|
||||
Delete(data);
|
||||
}
|
||||
|
||||
int Hash::add(const char *k, void *obj) {
|
||||
DOH *v = NewVoid(obj,0);
|
||||
if (Getattr(data, (DOH *) k)) return -1;
|
||||
Setattr(data, (DOH *) k, v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Hash::add(const char *k, void *obj, void (*d)(void *)) {
|
||||
DOH *v = NewVoid(obj,d);
|
||||
if (Getattr(data, (DOH *) k)) return -1;
|
||||
Setattr(data, (DOH *) k, v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *Hash::lookup(const char *k) {
|
||||
DOH *v;
|
||||
v = Getattr(data,(DOH *)k);
|
||||
if (!v) return 0;
|
||||
return Data(v);
|
||||
}
|
||||
|
||||
void Hash::remove(const char *k) {
|
||||
Delattr(data,(DOH *)k);
|
||||
}
|
||||
|
||||
void *Hash::first() {
|
||||
DOH *o;
|
||||
DOH *v = Firstkey(data);
|
||||
if (v) {
|
||||
o = Getattr(data,v);
|
||||
return Data(o);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *Hash::firstkey() {
|
||||
DOH *v = Firstkey(data);
|
||||
if (v) {
|
||||
return Char(v);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *Hash::next() {
|
||||
DOH *o;
|
||||
DOH *v = Nextkey(data);
|
||||
if (v) {
|
||||
o = Getattr(data,v);
|
||||
return Data(o);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *Hash::nextkey() {
|
||||
DOH *v = Nextkey(data);
|
||||
if (v) {
|
||||
return Char(v);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -21,6 +21,8 @@ extern "C" {
|
|||
#include "swig.h"
|
||||
}
|
||||
|
||||
extern int add_symbol(char *name);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// void Language::set_init(char *iname)
|
||||
//
|
||||
|
|
@ -169,7 +171,7 @@ void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
||||
if (add_symbol(new_name, 0,0)) {
|
||||
if (add_symbol(new_name)) {
|
||||
fprintf(stderr,"%s : Line %d. Function %s (member %s) multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, cname, name);
|
||||
return;
|
||||
|
|
@ -212,7 +214,7 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
|
||||
// Add this function to the SWIG symbol table
|
||||
|
||||
if (add_symbol(cname, 0,0)) {
|
||||
if (add_symbol(cname)) {
|
||||
fprintf(stderr,"%s : Line %d. Constructor %s multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, cname);
|
||||
return;
|
||||
|
|
@ -246,7 +248,7 @@ void Language::cpp_destructor(char *name, char *iname) {
|
|||
|
||||
// Add this function to the SWIG symbol table
|
||||
|
||||
if (add_symbol(cname, 0,0)) {
|
||||
if (add_symbol(cname)) {
|
||||
fprintf(stderr,"%s : Line %d. Destructor %s multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, cname);
|
||||
return;
|
||||
|
|
@ -324,7 +326,7 @@ void Language::cpp_variable(char *name, char *iname, DataType *t) {
|
|||
|
||||
// Check the symbol table
|
||||
|
||||
if (add_symbol(cname,(DataType *) 0,(char *) 0)) {
|
||||
if (add_symbol(cname)) {
|
||||
fprintf(stderr,"%s : Line %d. Variable %s multiply defined (2nd definition ignored).\n", input_file, line_number, cname);
|
||||
return;
|
||||
}
|
||||
|
|
@ -377,7 +379,7 @@ void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
||||
if (add_symbol(cname, 0,0)) {
|
||||
if (add_symbol(cname)) {
|
||||
if (ObjCClass)
|
||||
fprintf(stderr,"%s : Line %d. class function %s multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, cname);
|
||||
|
|
@ -428,7 +430,7 @@ void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *
|
|||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
||||
if (add_symbol(cname, 0,0)) {
|
||||
if (add_symbol(cname)) {
|
||||
fprintf(stderr,"%s : Line %d. Constant %s (member %s) multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, cname, name);
|
||||
return;
|
||||
|
|
@ -488,7 +490,7 @@ void Language::cpp_static_var(char *name, char *iname, DataType *t) {
|
|||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
||||
if (add_symbol(cname, 0,0)) {
|
||||
if (add_symbol(cname)) {
|
||||
fprintf(stderr,"%s : Line %d. Variable %s (member %s) multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, cname, name);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
int includecount = 0;
|
||||
extern int check_suffix(char *);
|
||||
extern void scanner_file(FILE *);
|
||||
extern void typemap_initialize(void);
|
||||
DOH *libfiles = 0;
|
||||
|
||||
#ifdef MACSWIG
|
||||
|
|
@ -155,7 +156,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
// Initialize the preprocessor
|
||||
Preprocessor_init();
|
||||
|
||||
typemap_initialize();
|
||||
f_wrappers = 0;
|
||||
f_init = 0;
|
||||
f_header = 0;
|
||||
|
|
|
|||
|
|
@ -76,10 +76,12 @@ static String ArrayBackup; // Array backup string
|
|||
static char *DefArg = 0; // Default argument hack
|
||||
static char *ConstChar = 0; // Used to store raw character constants
|
||||
static ParmList *tm_parm = 0; // Parameter list used to hold typemap parameters
|
||||
static Hash name_hash; // Hash table containing renamings
|
||||
static DOHHash *name_hash = 0; // Hash table containing renamings
|
||||
char *objc_construct = (char *) "new"; // Objective-C constructor
|
||||
char *objc_destruct = (char *) "free"; // Objective-C destructor
|
||||
|
||||
static DOHHash *symbols = 0;
|
||||
|
||||
/* Some macros for building constants */
|
||||
|
||||
#define E_BINARY(TARGET, SRC1, SRC2, OP) \
|
||||
|
|
@ -129,6 +131,14 @@ static void init_language() {
|
|||
lang_init = 1;
|
||||
}
|
||||
|
||||
/* Add a symbol to the symbol table. Return -1 if it already exists */
|
||||
int add_symbol(char *name) {
|
||||
if (!symbols) symbols = NewHash();
|
||||
if (Getattr(symbols,name)) return -1;
|
||||
Setattr(symbols,name,name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// int promote(int t1, int t2)
|
||||
//
|
||||
|
|
@ -160,7 +170,9 @@ int promote(int t1, int t2) {
|
|||
|
||||
static char *make_name(char *name) {
|
||||
// Check to see if the name is in the hash
|
||||
char *nn = (char *) name_hash.lookup(name);
|
||||
if (!name_hash) name_hash = NewHash();
|
||||
char *nn = GetChar(name_hash,name);
|
||||
|
||||
if (nn) return nn; // Yep, return it.
|
||||
|
||||
if (Rename_true) {
|
||||
|
|
@ -197,7 +209,7 @@ void create_function(int ext, char *name, DataType *t, ParmList *l) {
|
|||
|
||||
// Check if symbol already exists
|
||||
|
||||
if (add_symbol(iname, t, (char *) 0)) {
|
||||
if (add_symbol(iname)) {
|
||||
fprintf(stderr,"%s : Line %d. Function %s multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, iname);
|
||||
} else {
|
||||
|
|
@ -232,7 +244,7 @@ void create_variable(int ext, char *name, DataType *t) {
|
|||
init_language();
|
||||
|
||||
char *iname = make_name(name);
|
||||
if (add_symbol(iname, t, (char *) 0)) {
|
||||
if (add_symbol(iname)) {
|
||||
fprintf(stderr,"%s : Line %d. Variable %s multiply defined (2nd definition ignored).\n",
|
||||
input_file, line_number, iname);
|
||||
} else {
|
||||
|
|
@ -278,13 +290,10 @@ void create_constant(char *name, DataType *type, char *value) {
|
|||
|
||||
if (!value) value = copy_string(name);
|
||||
sprintf(temp_name,"const:%s", name);
|
||||
if (add_symbol(temp_name, type, value)) {
|
||||
if (add_symbol(temp_name)) {
|
||||
fprintf(stderr,"%s : Line %d. Constant %s multiply defined. (2nd definition ignored)\n",
|
||||
input_file, line_number, name);
|
||||
} else {
|
||||
// Update symbols value if already defined.
|
||||
update_symbol(name, type, value);
|
||||
|
||||
if (!WrapExtern) { // Only wrap the constant if not in %extern mode
|
||||
lang->declare_const(name, name, type, value);
|
||||
}
|
||||
|
|
@ -685,10 +694,8 @@ statement : INCLUDE STRING LBRACE {
|
|||
|
||||
/* %rename directive */
|
||||
| RENAME ID ID SEMI {
|
||||
if (name_hash.lookup($2)) {
|
||||
name_hash.remove($2);
|
||||
}
|
||||
name_hash.add($2,copy_string($3));
|
||||
if (!name_hash) name_hash = NewHash();
|
||||
Setattr(name_hash,$2,$3);
|
||||
}
|
||||
|
||||
/* %new directive */
|
||||
|
|
@ -714,7 +721,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
| NATIVE LPAREN ID RPAREN extern ID SEMI {
|
||||
if (!WrapExtern) {
|
||||
init_language();
|
||||
if (add_symbol($3,(DataType *) 0, (char *) 0)) {
|
||||
if (add_symbol($3)) {
|
||||
fprintf(stderr,"%s : Line %d. Name of native function %s conflicts with previous declaration (ignored)\n",
|
||||
input_file, line_number, $3);
|
||||
} else {
|
||||
|
|
@ -726,7 +733,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
if (!WrapExtern) {
|
||||
init_language();
|
||||
$6->is_pointer += $7.is_pointer;
|
||||
if (add_symbol($3,(DataType *) 0, (char *) 0)) {
|
||||
if (add_symbol($3)) {
|
||||
fprintf(stderr,"%s : Line %d. Name of native function %s conflicts with previous declaration (ignored)\n",
|
||||
input_file, line_number, $3);
|
||||
} else {
|
||||
|
|
@ -877,7 +884,7 @@ statement : INCLUDE STRING LBRACE {
|
|||
delete temp_typeptr;
|
||||
} else if ($3.type == T_SYMBOL) {
|
||||
// Add a symbol to the SWIG symbol table
|
||||
if (add_symbol($2,(DataType *) 0, (char *) 0)) {
|
||||
if (add_symbol($2)) {
|
||||
fprintf(stderr,"%s : Line %d. Warning. Symbol %s already defined.\n",
|
||||
input_file,line_number, $2);
|
||||
}
|
||||
|
|
@ -1843,16 +1850,8 @@ expr : NUM_INT {
|
|||
$$.type = $2->type;
|
||||
}
|
||||
| ID {
|
||||
$$.id = lookup_symvalue($1);
|
||||
if ($$.id == (char *) 0)
|
||||
$$.id = $1;
|
||||
else {
|
||||
$$.id = new char[strlen($$.id)+3];
|
||||
sprintf($$.id,"(%s)",lookup_symvalue($1));
|
||||
}
|
||||
temp_typeptr = lookup_symtype($1);
|
||||
if (temp_typeptr) $$.type = temp_typeptr->type;
|
||||
else $$.type = T_INT;
|
||||
$$.id = $1;
|
||||
$$.type = T_INT;
|
||||
}
|
||||
| ID DCOLON ID {
|
||||
$$.id = new char[strlen($1)+strlen($3)+3];
|
||||
|
|
@ -1987,7 +1986,7 @@ cpp_class :
|
|||
DataType::new_scope();
|
||||
|
||||
sprintf(temp_name,"CPP_CLASS:%s\n",$3);
|
||||
if (add_symbol(temp_name, (DataType *) 0, (char *) 0)) {
|
||||
if (add_symbol(temp_name)) {
|
||||
fprintf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3);
|
||||
FatalError();
|
||||
}
|
||||
|
|
@ -2042,7 +2041,7 @@ cpp_class :
|
|||
DataType::new_scope();
|
||||
|
||||
sprintf(temp_name,"CPP_CLASS:%s\n",$3);
|
||||
if (add_symbol(temp_name, (DataType *) 0, (char *) 0)) {
|
||||
if (add_symbol(temp_name)) {
|
||||
fprintf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3);
|
||||
FatalError();
|
||||
}
|
||||
|
|
@ -2147,7 +2146,7 @@ cpp_class :
|
|||
cplus_abort();
|
||||
} else {
|
||||
sprintf(temp_name,"CPP_CLASS:%s\n",$7.id);
|
||||
if (add_symbol(temp_name, (DataType *) 0, (char *) 0)) {
|
||||
if (add_symbol(temp_name)) {
|
||||
fprintf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $7.id);
|
||||
FatalError();
|
||||
}
|
||||
|
|
@ -2855,7 +2854,7 @@ objective_c : OC_INTERFACE ID objc_inherit {
|
|||
init_language();
|
||||
cplus_mode = CPLUS_PROTECTED;
|
||||
sprintf(temp_name,"CPP_CLASS:%s\n",$2);
|
||||
if (add_symbol(temp_name,(DataType *) 0, (char *) 0)) {
|
||||
if (add_symbol(temp_name)) {
|
||||
fprintf(stderr,"%s : Line %d. @interface %s is multiple defined.\n",
|
||||
input_file,line_number,$2);
|
||||
FatalError();
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ void scanner_close() {
|
|||
line_number = p->line_number;
|
||||
input_file = p->in_file;
|
||||
WrapExtern = p->extern_mode;
|
||||
if (!WrapExtern) remove_symbol((char*)"SWIGEXTERN");
|
||||
ForceExtern = p->force_extern;
|
||||
} else {
|
||||
LEX_in = NULL;
|
||||
|
|
|
|||
|
|
@ -100,26 +100,6 @@ public:
|
|||
#define endl "\n"
|
||||
#define quote "\""
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Hash table class
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
class Hash {
|
||||
private:
|
||||
void *data;
|
||||
public:
|
||||
Hash();
|
||||
~Hash();
|
||||
int add(const char *key, void *object);
|
||||
int add(const char *key, void *object, void (*del)(void *));
|
||||
void *lookup(const char *key);
|
||||
void remove(const char *key);
|
||||
void *first();
|
||||
void *next();
|
||||
char *firstkey();
|
||||
char *nextkey();
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* class DataType
|
||||
*
|
||||
|
|
@ -424,16 +404,11 @@ public:
|
|||
|
||||
extern void emit_extern_var(char *, DataType *, int, FILE *);
|
||||
extern void emit_extern_func(char *, DataType *, ParmList *, int, FILE *);
|
||||
extern int emit_args(DataType *, ParmList *, FILE *);
|
||||
|
||||
extern void emit_func_call(char *, DataType *, ParmList *, FILE *);
|
||||
|
||||
extern void emit_hex(FILE *);
|
||||
extern void emit_set_get(char *, char *, DataType *);
|
||||
extern void emit_banner(FILE *);
|
||||
extern void emit_ptr_equivalence(FILE *);
|
||||
extern int SWIG_main(int, char **, Language *);
|
||||
extern void make_wrap_name(char *);
|
||||
|
||||
// Some functions for emitting some C++ helper code
|
||||
|
||||
|
|
@ -472,7 +447,6 @@ extern "C" {
|
|||
extern FILE *Swig_open(const void *filename);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Class for Creating Wrapper Functions
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
@ -499,15 +473,6 @@ extern int emit_args(DataType *, ParmList *, WrapperFunction &f);
|
|||
extern void emit_func_call(char *, DataType *, ParmList *, WrapperFunction &f);
|
||||
extern void SWIG_exit(int);
|
||||
|
||||
// Symbol table management
|
||||
|
||||
extern int add_symbol(char *, DataType *, char *);
|
||||
extern void remove_symbol(char *);
|
||||
extern int update_symbol(char *, DataType *, char *);
|
||||
extern char *lookup_symvalue(char *);
|
||||
extern DataType *lookup_symtype(char *);
|
||||
extern int lookup_symbol(char *);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Typemap support
|
||||
// -----------------------------------------------------------------------
|
||||
|
|
@ -535,16 +500,7 @@ extern void fragment_clear(char *op, char *lang);
|
|||
|
||||
extern void emit_ptr_equivalence(WrapperFunction &);
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Naming system
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
#define AS_IS 1
|
||||
|
||||
extern void name_register(char *method, char *format);
|
||||
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_get(char *vname, int suppress=0);
|
||||
extern char *name_set(char *vname, int suppress=0);
|
||||
extern char *name_construct(char *classname, int suppress=0);
|
||||
extern char *name_destroy(char *classname, int suppress=0);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,146 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* symbol.cxx
|
||||
*
|
||||
* Symbol table management.
|
||||
*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
static char cvstag[] = "$Header$";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Symbol object
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
struct Symbol {
|
||||
~Symbol() {
|
||||
if (name) delete name;
|
||||
if (type) delete type;
|
||||
if (value) delete value;
|
||||
}
|
||||
char *name;
|
||||
DataType *type; // Optional datatype
|
||||
char *value; // Optional value (for constant expressions)
|
||||
};
|
||||
|
||||
static Hash SymHash; // SWIG Symbol table
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// int add_symbol(char *name, DataType *type, char *value)
|
||||
//
|
||||
// Adds a symbol to the symbol table. Returns -1 if symbol is already in the table.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
int add_symbol(char *name, DataType *type, char *value) {
|
||||
|
||||
Symbol *s;
|
||||
int ret;
|
||||
|
||||
s = new Symbol;
|
||||
s->name = copy_string(name);
|
||||
if (type)
|
||||
s->type = new DataType(type);
|
||||
else s->type = (DataType *) 0;
|
||||
if (value)
|
||||
s->value = copy_string(value);
|
||||
else s->value = (char *) 0;
|
||||
|
||||
// Add this to the symbol table
|
||||
|
||||
ret = SymHash.add(s->name, s);
|
||||
if (ret == -1) {
|
||||
delete s;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// int lookup_symbol(char *name)
|
||||
//
|
||||
// Checks to see if a symbol is in the symbol table.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
int lookup_symbol(char *name) {
|
||||
Symbol *s;
|
||||
|
||||
s = (Symbol *) SymHash.lookup(name);
|
||||
if (s) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// DataType *lookup_symtype(char *name)
|
||||
//
|
||||
// Returns the datatype of a symbol or NULL if not found.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
DataType *lookup_symtype(char *name) {
|
||||
|
||||
Symbol *s;
|
||||
|
||||
s = (Symbol *) SymHash.lookup(name);
|
||||
if (s) return s->type;
|
||||
else return (DataType *) 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// char *lookup_symvalue(char *name)
|
||||
//
|
||||
// Returns the value associate with a symbol.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
char *lookup_symvalue(char *name) {
|
||||
|
||||
Symbol *s;
|
||||
|
||||
s = (Symbol *) SymHash.lookup(name);
|
||||
if (s) return s->value;
|
||||
else return (char *) 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// int update_symbol(char *name, DataType *type, char *value)
|
||||
//
|
||||
// Updates a symbol (or create it) in the hash table.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
int update_symbol(char *name, DataType *type, char *value) {
|
||||
|
||||
Symbol *s;
|
||||
|
||||
s = (Symbol *) SymHash.lookup(name);
|
||||
if (s) {
|
||||
if (s->type) delete s->type;
|
||||
if (s->value) delete s->value;
|
||||
if (type)
|
||||
s->type = new DataType(type);
|
||||
else
|
||||
s->type = (DataType *) 0;
|
||||
if (value)
|
||||
s->value = copy_string(value);
|
||||
else
|
||||
s->value = (char *) 0;
|
||||
return 0;
|
||||
} else {
|
||||
return add_symbol(name, type, value);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// void remove_symbol(char *name)
|
||||
//
|
||||
// Removes a symbol from the symbol table.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void remove_symbol(char *name) {
|
||||
SymHash.remove(name);
|
||||
}
|
||||
|
||||
|
|
@ -17,6 +17,10 @@ static char cvsroot[] = "$Header$";
|
|||
#include "internal.h"
|
||||
#include <limits.h>
|
||||
|
||||
extern "C" {
|
||||
#include "doh.h"
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// This file provides universal support for typemaps. Typemaps are created
|
||||
// using the following SWIG command in an interface file:
|
||||
|
|
@ -127,7 +131,7 @@ struct TypeMap {
|
|||
|
||||
// Hash tables for storing type-mappings
|
||||
|
||||
static Hash typemap_hash;
|
||||
static DOH *typemap_hash = 0;
|
||||
|
||||
// Structure for holding "applications of a typemap"
|
||||
|
||||
|
|
@ -149,7 +153,7 @@ struct TmMethod {
|
|||
|
||||
// Hash table for storing applications of a datatype
|
||||
|
||||
static Hash application_hash;
|
||||
static DOH *application_hash = 0;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname)
|
||||
|
|
@ -168,11 +172,12 @@ void typemap_apply(DataType *tm_type, char *tm_name, DataType *type, char *pname
|
|||
|
||||
// See if there is a method already defined
|
||||
|
||||
m = (TmMethod *) application_hash.lookup(temp);
|
||||
if (!application_hash) application_hash = NewHash();
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
|
||||
if (!m) {
|
||||
m = new TmMethod(temp,type,0);
|
||||
application_hash.add(temp,m);
|
||||
SetVoid(application_hash,temp,m);
|
||||
}
|
||||
|
||||
// Check to see if an array typemap has been applied to a non-array type
|
||||
|
|
@ -219,7 +224,8 @@ void typemap_clear_apply(DataType *type, char *pname) {
|
|||
char temp[512];
|
||||
if (!pname) pname = (char*)"";
|
||||
sprintf(temp,"%s$%s", type->print_type(), pname);
|
||||
application_hash.remove(temp);
|
||||
if (!application_hash) application_hash = NewHash();
|
||||
Delattr(application_hash,temp);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
@ -263,6 +269,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
|
||||
// printf("Registering : %s %s %s %s\n%s\n", op, lang, type->print_type(), pname, getcode);
|
||||
|
||||
if (!typemap_hash) typemap_hash = NewHash();
|
||||
|
||||
tm = new TypeMap(lang,type,getcode,args);
|
||||
// If this is a default typemap, downgrade the type!
|
||||
|
|
@ -276,7 +283,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
|
||||
// Get any previous setting of the typemap
|
||||
|
||||
tm_old = (TypeMap *) typemap_hash.lookup(key);
|
||||
tm_old = (TypeMap *) GetVoid(typemap_hash,key);
|
||||
|
||||
if (tm_old) {
|
||||
|
||||
|
|
@ -296,11 +303,11 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
|
|||
|
||||
// Remove the old one from the hash
|
||||
|
||||
typemap_hash.remove(key);
|
||||
Delattr(typemap_hash,key);
|
||||
}
|
||||
|
||||
// Add new typemap to the hash table
|
||||
typemap_hash.add(key,(void *) tm);
|
||||
SetVoid(typemap_hash,key,tm);
|
||||
|
||||
// Now try to perform default chaining operation (if available)
|
||||
// if (!is_default) {
|
||||
|
|
@ -390,7 +397,8 @@ TypeMap *typemap_search(char *key, int id) {
|
|||
|
||||
TypeMap *tm;
|
||||
|
||||
tm = (TypeMap *) typemap_hash.lookup(key);
|
||||
if (!typemap_hash) typemap_hash = NewHash();
|
||||
tm = (TypeMap *) GetVoid(typemap_hash,key);
|
||||
while (tm) {
|
||||
if ((id >= tm->first) && (id < tm->last)) return tm;
|
||||
else tm = tm->next;
|
||||
|
|
@ -691,10 +699,10 @@ char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *so
|
|||
tstr = type->print_type();
|
||||
sprintf(temp,"%s$%s",tstr,ppname);
|
||||
// No mapping was found. See if the name has been mapped with %apply
|
||||
m = (TmMethod *) application_hash.lookup(temp);
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
if (!m) {
|
||||
sprintf(temp,"%s$",tstr);
|
||||
m = (TmMethod *) application_hash.lookup(temp);
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
}
|
||||
if (m) {
|
||||
m = m->next;
|
||||
|
|
@ -847,10 +855,11 @@ char *typemap_check(char *op, char *lang, DataType *type, char *pname) {
|
|||
tstr = type->print_type();
|
||||
sprintf(temp,"%s$%s",tstr,ppname);
|
||||
// No mapping was found. See if the name has been mapped with %apply
|
||||
m = (TmMethod *) application_hash.lookup(temp);
|
||||
if (!application_hash) application_hash = NewHash();
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
if (!m) {
|
||||
sprintf(temp,"%s$",tstr);
|
||||
m = (TmMethod *) application_hash.lookup(temp);
|
||||
m = (TmMethod *) GetVoid(application_hash,temp);
|
||||
}
|
||||
if (m) {
|
||||
m = m->next;
|
||||
|
|
@ -938,7 +947,8 @@ void typemap_clear(char *op, char *lang, DataType *type, char *pname) {
|
|||
// Look for any previous version, simply set the last id if
|
||||
// applicable.
|
||||
|
||||
tm = (TypeMap *) typemap_hash.lookup(key);
|
||||
if (!typemap_hash) typemap_hash = NewHash();
|
||||
tm = (TypeMap *) GetVoid(typemap_hash,key);
|
||||
if (tm) {
|
||||
if (tm->last > type_id) tm->last = type_id;
|
||||
}
|
||||
|
|
@ -968,8 +978,8 @@ void typemap_copy(char *op, char *lang, DataType *stype, char *sname,
|
|||
if (tk) {
|
||||
tn = new TypeMap(tk); // Make a copy of the previous typemap
|
||||
tn->next = tm; // Set up symlinks
|
||||
typemap_hash.remove(key); // Remove old hash entry
|
||||
typemap_hash.add(key,(void *) tn);
|
||||
Delattr(typemap_hash,key); // Remove old hash entry
|
||||
SetVoid(typemap_hash,key, tn);
|
||||
}
|
||||
} else {
|
||||
typemap_register(op,lang,ttype,tname,tm->code,tm->args);
|
||||
|
|
@ -1009,7 +1019,7 @@ void fragment_register(char *op, char *lang, char *code) {
|
|||
|
||||
// Get any previous setting of the typemap
|
||||
|
||||
tm_old = (TypeMap *) typemap_hash.lookup(key);
|
||||
tm_old = (TypeMap *) GetVoid(typemap_hash,key);
|
||||
if (tm_old) {
|
||||
// If found, we need to attach the old version to the new one
|
||||
|
||||
|
|
@ -1024,7 +1034,7 @@ void fragment_register(char *op, char *lang, char *code) {
|
|||
|
||||
// Remove the old one from the hash
|
||||
|
||||
typemap_hash.remove(key);
|
||||
Delattr(typemap_hash,key);
|
||||
}
|
||||
|
||||
// Perform a default chaining operation if needed (defaults to nothing)
|
||||
|
|
@ -1032,7 +1042,7 @@ void fragment_register(char *op, char *lang, char *code) {
|
|||
tm->code.replace(temp,"");
|
||||
|
||||
// Add new typemap to the hash table
|
||||
typemap_hash.add(key,(void *) tm);
|
||||
SetVoid(typemap_hash,key,tm);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1084,8 +1094,20 @@ void fragment_clear(char *op, char *lang) {
|
|||
// Look for any previous version, simply set the last id if
|
||||
// applicable.
|
||||
|
||||
tm = (TypeMap *) typemap_hash.lookup(key);
|
||||
tm = (TypeMap *) GetVoid(typemap_hash,key);
|
||||
if (tm) {
|
||||
if (tm->last > type_id) tm->last = type_id;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// typemap_initialize()
|
||||
//
|
||||
// Initialize the hash tables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
typemap_initialize() {
|
||||
typemap_hash = NewHash();
|
||||
application_hash = NewHash();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ static char cvsroot[] = "$Header$";
|
|||
|
||||
#include "internal.h"
|
||||
|
||||
extern "C" {
|
||||
#include "doh.h"
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// class DataType member functions.
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -430,7 +434,7 @@ char *DataType::get_array() {
|
|||
// typedef support. This needs to be scoped.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
static Hash *typedef_hash[MAXSCOPE];
|
||||
static DOHHash *typedef_hash[MAXSCOPE];
|
||||
static int scope = 0; // Current scope
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -449,7 +453,7 @@ void DataType::init_typedef() {
|
|||
typedef_hash[i] = 0;
|
||||
scope = 0;
|
||||
// Create a new hash
|
||||
typedef_hash[scope] = new Hash;
|
||||
typedef_hash[scope] = NewHash();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
|
@ -471,7 +475,7 @@ void DataType::typedef_add(char *tname, int mode) {
|
|||
// We only check in the local scope. C++ classes may make typedefs
|
||||
// that shadow global ones.
|
||||
|
||||
if (typedef_hash[scope]->lookup(tname)) {
|
||||
if (Getattr(typedef_hash[scope],tname)) {
|
||||
fprintf(stderr,"%s : Line %d. Warning. Datatype %s already defined (2nd definition ignored).\n",
|
||||
input_file, line_number, tname);
|
||||
return;
|
||||
|
|
@ -486,7 +490,7 @@ void DataType::typedef_add(char *tname, int mode) {
|
|||
// strcpy(nt->name,tname); // Copy over the new name
|
||||
|
||||
// Add this type to our hash table
|
||||
typedef_hash[scope]->add(tname,(void *) nt);
|
||||
SetVoid(typedef_hash[scope],tname, (void *) nt);
|
||||
|
||||
// Now add this type mapping to our type-equivalence table
|
||||
|
||||
|
|
@ -534,7 +538,7 @@ void DataType::typedef_resolve(int level) {
|
|||
int s = scope - level;
|
||||
|
||||
while (s >= 0) {
|
||||
if ((td = (DataType *) typedef_hash[s]->lookup(name))) {
|
||||
if ((td = (DataType *) GetVoid(typedef_hash[s],name))) {
|
||||
type = td->type;
|
||||
is_pointer += td->is_pointer;
|
||||
implicit_ptr += td->implicit_ptr;
|
||||
|
|
@ -568,7 +572,7 @@ void DataType::typedef_replace () {
|
|||
DataType *td;
|
||||
String temp;
|
||||
|
||||
if ((td = (DataType *) typedef_hash[scope]->lookup(name))) {
|
||||
if ((td = (DataType *) GetVoid(typedef_hash[scope],name))) {
|
||||
type = td->type;
|
||||
is_pointer = td->is_pointer;
|
||||
implicit_ptr -= td->implicit_ptr;
|
||||
|
|
@ -596,7 +600,7 @@ void DataType::typedef_replace () {
|
|||
int DataType::is_typedef(char *t) {
|
||||
int s = scope;
|
||||
while (s >= 0) {
|
||||
if (typedef_hash[s]->lookup(t)) return 1;
|
||||
if (Getattr(typedef_hash[s],t)) return 1;
|
||||
s--;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -613,7 +617,7 @@ int DataType::is_typedef(char *t) {
|
|||
void DataType::typedef_updatestatus(int newstatus) {
|
||||
|
||||
DataType *t;
|
||||
if ((t = (DataType *) typedef_hash[scope]->lookup(name))) {
|
||||
if ((t = (DataType *) GetVoid(typedef_hash[scope],name))) {
|
||||
t->status = newstatus;
|
||||
}
|
||||
}
|
||||
|
|
@ -633,19 +637,19 @@ void DataType::typedef_updatestatus(int newstatus) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void DataType::merge_scope(void *ho) {
|
||||
char *key;
|
||||
DOHString *key;
|
||||
DataType *t, *nt;
|
||||
Hash *h = (Hash *) ho;
|
||||
DOHHash *h = (DOHHash *) ho;
|
||||
|
||||
if (h) {
|
||||
// Copy all of the entries in the given hash table to this new one
|
||||
key = h->firstkey();
|
||||
key = Firstkey(h);
|
||||
while (key) {
|
||||
// printf("%s\n", key);
|
||||
t = (DataType *) h->lookup(key);
|
||||
t = (DataType *) GetVoid(h,key);
|
||||
nt = new DataType(t);
|
||||
typedef_hash[scope]->add(key,(void *) nt);
|
||||
key = h->nextkey();
|
||||
SetVoid(typedef_hash[scope],key,(void *) nt);
|
||||
key = Nextkey(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -664,12 +668,10 @@ void DataType::merge_scope(void *ho) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void DataType::new_scope(void *ho) {
|
||||
Hash *h = (Hash *) ho;
|
||||
scope++;
|
||||
typedef_hash[scope] = new Hash;
|
||||
|
||||
if (h) {
|
||||
merge_scope(h);
|
||||
typedef_hash[scope] = NewHash();
|
||||
if (ho) {
|
||||
merge_scope(ho);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -697,22 +699,22 @@ void DataType::new_scope(void *ho) {
|
|||
|
||||
void *DataType::collapse_scope(char *prefix) {
|
||||
DataType *t,*nt;
|
||||
char *key;
|
||||
DOHString *key;
|
||||
char *temp;
|
||||
Hash *h;
|
||||
DOHHash *h;
|
||||
|
||||
if (scope > 0) {
|
||||
if (prefix) {
|
||||
key = typedef_hash[scope]->firstkey();
|
||||
key = Firstkey(typedef_hash[scope]);
|
||||
while (key) {
|
||||
t = (DataType *) typedef_hash[scope]->lookup(key);
|
||||
t = (DataType *) GetVoid(typedef_hash[scope],key);
|
||||
nt = new DataType(t);
|
||||
temp = new char[strlen(prefix)+strlen(key)+3];
|
||||
sprintf(temp,"%s::%s",prefix,key);
|
||||
temp = new char[strlen(prefix)+strlen(Char(key))+3];
|
||||
sprintf(temp,"%s::%s",prefix,Char(key));
|
||||
// printf("creating %s\n", temp);
|
||||
typedef_hash[scope-1]->add(temp,(void *) nt);
|
||||
SetVoid(typedef_hash[scope-1],temp, (void *)nt);
|
||||
delete temp;
|
||||
key = typedef_hash[scope]->nextkey();
|
||||
key = Nextkey(typedef_hash[scope]);
|
||||
}
|
||||
}
|
||||
h = typedef_hash[scope];
|
||||
|
|
@ -740,11 +742,12 @@ struct EqEntry {
|
|||
EqEntry *next;
|
||||
};
|
||||
|
||||
static Hash typeeq_hash;
|
||||
static DOHHash *typeeq_hash = 0;
|
||||
static int te_init = 0;
|
||||
|
||||
void typeeq_init() {
|
||||
void typeeq_standard();
|
||||
if (!typeeq_hash) typeeq_hash = NewHash();
|
||||
te_init = 1;
|
||||
typeeq_standard();
|
||||
}
|
||||
|
|
@ -768,7 +771,7 @@ void typeeq_add(char *name, char *eqname, char *cast = 0, DataType *type = 0) {
|
|||
|
||||
// Search for "name" entry in the hash table
|
||||
|
||||
e1 = (EqEntry *) typeeq_hash.lookup(name);
|
||||
e1 = (EqEntry *) GetVoid(typeeq_hash,name);
|
||||
|
||||
if (!e1) {
|
||||
// Create a new entry
|
||||
|
|
@ -777,7 +780,7 @@ void typeeq_add(char *name, char *eqname, char *cast = 0, DataType *type = 0) {
|
|||
e1->next = 0;
|
||||
e1->cast = 0;
|
||||
// Add it to the hash table
|
||||
typeeq_hash.add(name,(void *) e1);
|
||||
SetVoid(typeeq_hash,name,(void *) e1);
|
||||
}
|
||||
|
||||
// Add new type to the list
|
||||
|
|
@ -829,7 +832,7 @@ void typeeq_addtypedef(char *name, char *eqname, DataType *t) {
|
|||
|
||||
// Now find the hash entry
|
||||
|
||||
e1 = (EqEntry *) typeeq_hash.lookup(name);
|
||||
e1 = (EqEntry *) GetVoid(typeeq_hash,name);
|
||||
if (!e1) return;
|
||||
|
||||
// Walk down the list and make other equivalences
|
||||
|
|
@ -856,6 +859,7 @@ void typeeq_addtypedef(char *name, char *eqname, DataType *t) {
|
|||
void emit_ptr_equivalence(FILE *f) {
|
||||
|
||||
EqEntry *e1,*e2;
|
||||
DOH *k;
|
||||
void typeeq_standard();
|
||||
String ttable;
|
||||
|
||||
|
|
@ -867,8 +871,9 @@ void emit_ptr_equivalence(FILE *f) {
|
|||
*/\n\
|
||||
static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {\n";
|
||||
|
||||
e1 = (EqEntry *) typeeq_hash.first();
|
||||
while (e1) {
|
||||
k = Firstkey(typeeq_hash);
|
||||
while (k) {
|
||||
e1 = (EqEntry *) GetVoid(typeeq_hash,k);
|
||||
e2 = e1->next;
|
||||
// Walk through the equivalency list
|
||||
while (e2) {
|
||||
|
|
@ -878,7 +883,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
|||
ttable << tab4 << "{ \"" << e1->name << "\",\"" << e2->name << "\",0},\n";
|
||||
e2 = e2->next;
|
||||
}
|
||||
e1 = (EqEntry *) typeeq_hash.next();
|
||||
k = Nextkey(typeeq_hash);
|
||||
}
|
||||
ttable << "{0,0,0}};\n";
|
||||
fprintf(f_wrappers,"%s\n", ttable.get());
|
||||
|
|
@ -895,8 +900,9 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
|||
<< " void *(*convert)(void *);\n"
|
||||
<< "} SwigType;\n";
|
||||
|
||||
e1 = (EqEntry *) typeeq_hash.first();
|
||||
while (e1) {
|
||||
k = Firstkey(typeeq_hash);
|
||||
while (k) {
|
||||
e1 = (EqEntry *) GetVoid(typeeq_hash,k);
|
||||
e2 = e1->next;
|
||||
ctable << "static SwigType " << e1->name << "[] = {";
|
||||
// Walk through the equivalency list
|
||||
|
|
@ -909,7 +915,7 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
|
|||
e2 = e2->next;
|
||||
}
|
||||
ctable << "{0,0}};\n";
|
||||
e1 = (EqEntry *) typeeq_hash.next();
|
||||
k = Nextkey(typeeq_hash);
|
||||
}
|
||||
ctable << "*/\n";
|
||||
fprintf(f_wrappers,"%s\n", ctable.get());
|
||||
|
|
@ -993,14 +999,17 @@ check_equivalent(DataType *t) {
|
|||
static String out;
|
||||
int npointer = t->is_pointer;
|
||||
String m;
|
||||
DOH *k;
|
||||
|
||||
out = "";
|
||||
while (t->is_pointer >= t->implicit_ptr) {
|
||||
m = t->print_mangle();
|
||||
|
||||
if (!te_init) typeeq_init();
|
||||
e1 = (EqEntry *) typeeq_hash.first();
|
||||
while (e1) {
|
||||
|
||||
k = Firstkey(typeeq_hash);
|
||||
while (k) {
|
||||
e1 = (EqEntry *) GetVoid(typeeq_hash,k);
|
||||
/* printf("'%s', '%s'\n", m.get(),e1->name); */
|
||||
if (strcmp(m.get(),e1->name) == 0) {
|
||||
e2 = e1->next;
|
||||
|
|
@ -1017,7 +1026,7 @@ check_equivalent(DataType *t) {
|
|||
e2 = e2->next;
|
||||
}
|
||||
}
|
||||
e1 = (EqEntry *) typeeq_hash.next();
|
||||
k = Nextkey(typeeq_hash);
|
||||
}
|
||||
t->is_pointer--;
|
||||
}
|
||||
|
|
@ -1033,19 +1042,19 @@ check_equivalent(DataType *t) {
|
|||
// work across multiple files.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static Hash bases;
|
||||
static DOHHash *bases = 0;
|
||||
|
||||
void DataType::record_base(char *derived, char *base)
|
||||
{
|
||||
Hash *nh;
|
||||
nh = (Hash *) bases.lookup(derived);
|
||||
DOHHash *nh;
|
||||
if (!bases) bases = NewHash();
|
||||
nh = Getattr(bases,derived);
|
||||
if (!nh) {
|
||||
nh = new Hash();
|
||||
bases.add(derived, (void *) nh);
|
||||
nh = NewHash();
|
||||
Setattr(bases,derived,nh);
|
||||
}
|
||||
if (!nh->lookup(base)) {
|
||||
char *bn = copy_string(base);
|
||||
nh->add(base,(void *) bn);
|
||||
if (!Getattr(nh,base)) {
|
||||
Setattr(nh,base,base);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1056,46 +1065,51 @@ void DataType::record_base(char *derived, char *base)
|
|||
// construct a big table of pointer values at the end.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static Hash remembered;
|
||||
static DOHHash *remembered = 0;
|
||||
|
||||
void DataType::remember() {
|
||||
Hash *h;
|
||||
DOHHash *h;
|
||||
DataType *t = new DataType(this);
|
||||
remembered.add(t->print_mangle(),(void *) t);
|
||||
|
||||
if (!remembered) remembered = NewHash();
|
||||
SetVoid(remembered, t->print_mangle(), t);
|
||||
|
||||
if (!bases) bases = NewHash();
|
||||
/* Now, do the base-class hack */
|
||||
h = (Hash *) bases.lookup(t->name);
|
||||
h = Getattr(bases,t->name);
|
||||
if (h) {
|
||||
char *key;
|
||||
key = h->firstkey();
|
||||
DOH *key;
|
||||
key = Firstkey(h);
|
||||
while (key) {
|
||||
DataType *nt = new DataType(t);
|
||||
strcpy(nt->name,key);
|
||||
if (!remembered.lookup(nt->print_mangle()))
|
||||
strcpy(nt->name,Char(key));
|
||||
if (!Getattr(remembered,nt->print_mangle()))
|
||||
nt->remember();
|
||||
delete nt;
|
||||
key = h->nextkey();
|
||||
key = Nextkey(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
emit_type_table() {
|
||||
char *key;
|
||||
DOH *key;
|
||||
String types, table;
|
||||
int i = 0;
|
||||
|
||||
if (!remembered) remembered = NewHash();
|
||||
|
||||
table << "static _swig_type_info *_swig_types_initial[] = {\n";
|
||||
key = remembered.firstkey();
|
||||
key = Firstkey(remembered);
|
||||
fprintf(f_runtime,"/* ---- TYPES TABLE (BEGIN) ---- */\n");
|
||||
while (key) {
|
||||
fprintf(f_runtime,"#define SWIGTYPE%s _swig_types[%d] \n", key, i);
|
||||
types << "static _swig_type_info _swigt_" << key << "[] = {";
|
||||
types << "{\"" << key << "\",0},";
|
||||
types << "{\"" << key << "\",0},";
|
||||
types << check_equivalent((DataType *)remembered.lookup(key)) << "};\n";
|
||||
table << "_swigt_" << key << ", \n";
|
||||
key = remembered.nextkey();
|
||||
fprintf(f_runtime,"#define SWIGTYPE%s _swig_types[%d] \n", Char(key), i);
|
||||
types << "static _swig_type_info _swigt_" << Char(key) << "[] = {";
|
||||
types << "{\"" << Char(key) << "\",0},";
|
||||
types << "{\"" << Char(key) << "\",0},";
|
||||
types << check_equivalent((DataType *)GetVoid(remembered,key)) << "};\n";
|
||||
table << "_swigt_" << Char(key) << ", \n";
|
||||
key = Nextkey(remembered);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ Swig_banner(DOHFile *f) {
|
|||
* changes to this file unless you know what you are doing--modify the SWIG \n\
|
||||
* interface file instead. \n\
|
||||
* ----------------------------------------------------------------------------- */\n\n", SWIG_VERSION, SWIG_SPIN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue