Cleanup
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@492 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e560c1d445
commit
8e0010c43a
22 changed files with 368 additions and 1825 deletions
|
|
@ -1,5 +1,11 @@
|
|||
|
||||
/* SWIG version information */
|
||||
|
||||
#define SWIG_VERSION "1.3u-20000306-0939"
|
||||
#define SWIG_SPIN "(Alpha 2)"
|
||||
#ifndef SWIG_VERSION
|
||||
#define SWIG_VERSION "1.3u-20000616-0748"
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_SPIN
|
||||
#define SWIG_SPIN "(Alpha 3)"
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
|
||||
/* SWIG version information */
|
||||
|
||||
#ifndef SWIG_VERSION
|
||||
#define SWIG_VERSION "@SWIG_VERSION@"
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_SPIN
|
||||
#define SWIG_SPIN "@SWIG_SPIN@"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ INCLUDE = -I$(srcdir)/../Include \
|
|||
-I$(srcdir)/../SWIG1.1 \
|
||||
-I$(srcdir)/../SWIG1.3 \
|
||||
-I$(srcdir)/../DOH/Include \
|
||||
-I$(srcdir)/../Swig \
|
||||
-I../Include
|
||||
|
||||
# Rules for creation of a .o file from .cxx
|
||||
|
|
|
|||
|
|
@ -441,10 +441,10 @@ void JAVA::initialize()
|
|||
sprintf(bigbuf, "Java_%s%s", c_pkgstr, module);
|
||||
c_pkgstr = copy_string(bigbuf);
|
||||
sprintf(bigbuf, "%s_%%f", c_pkgstr);
|
||||
name_register((char*)"wrapper", copy_string(bigbuf));
|
||||
name_register((char*)"set", (char*)"set_%v");
|
||||
name_register((char*)"get", (char*)"get_%v");
|
||||
name_register((char*)"member", (char*)"%c_%f");
|
||||
Swig_name_register("wrapper", copy_string(bigbuf));
|
||||
Swig_name_register("set", "set_%v");
|
||||
Swig_name_register("get", "get_%v");
|
||||
Swig_name_register("member", "%c_%m");
|
||||
|
||||
// Generate the java class
|
||||
sprintf(bigbuf, "%s.java", module);
|
||||
|
|
@ -524,7 +524,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
// Make a wrapper name for this function
|
||||
|
||||
char *jniname = makeValidJniName(iname);
|
||||
char *wname = name_wrapper(jniname,package);
|
||||
char *wname = Swig_name_wrapper(jniname);
|
||||
free(jniname);
|
||||
|
||||
char *jnirettype = JavaTypeFromTypemap((char*)"jni", typemap_lang, t, iname);
|
||||
|
|
@ -546,7 +546,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
|
|||
fprintf(f_java, "native %s %s(", javarettype, iname);
|
||||
if(shadow && member_func) {
|
||||
String member_name = "";
|
||||
if(strcmp(iname, name_set(name_member(shadow_name, shadow_classname))) == 0)
|
||||
if(strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, shadow_name))) == 0)
|
||||
member_name << "set";
|
||||
else member_name << "get";
|
||||
member_name << (char) toupper((int) *shadow_name);
|
||||
|
|
@ -1032,7 +1032,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
nativecall << "new " << shadowrettype << "(new Long(";
|
||||
}
|
||||
}
|
||||
nativecall << module << "." << name_member(iname, shadow_classname) << "(_self";
|
||||
nativecall << module << "." << Swig_name_member(shadow_classname,iname) << "(_self";
|
||||
|
||||
int pcount = l->nparms;
|
||||
|
||||
|
|
@ -1100,7 +1100,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
nativecall << "new " << shadowrettype << "(new Long(";
|
||||
}
|
||||
}
|
||||
nativecall << module << "." << name_member(iname, shadow_classname) << "(";
|
||||
nativecall << module << "." << Swig_name_member(shadow_classname,iname) << "(";
|
||||
|
||||
int pcount = l->nparms;
|
||||
int gencomma = 0;
|
||||
|
|
@ -1162,9 +1162,9 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
|
||||
nativecall << " if(_self == 0 && " << shadow_classname << ".class == _selfClass()) {\n";
|
||||
if (iname != NULL)
|
||||
nativecall << tab8 << " _self = " << module << "." << name_construct(iname) << "(";
|
||||
nativecall << tab8 << " _self = " << module << "." << Swig_name_construct(iname) << "(";
|
||||
else
|
||||
nativecall << tab8 << " _self = " << module << "." << name_construct(shadow_classname) << "(";
|
||||
nativecall << tab8 << " _self = " << module << "." << Swig_name_construct(shadow_classname) << "(";
|
||||
|
||||
int pcount = l->nparms;
|
||||
if(pcount == 0) // We must have a default constructor
|
||||
|
|
@ -1227,7 +1227,7 @@ void JAVA::cpp_destructor(char *name, char *newname) {
|
|||
|
||||
fprintf(f_shadow, " public void _delete() {\n");
|
||||
fprintf(f_shadow, " if(_self != 0 && %s.class == _selfClass()) {\n", shadow_classname);
|
||||
fprintf(f_shadow, "\t%s.%s(_self);\n", module, name_destroy(realname));
|
||||
fprintf(f_shadow, "\t%s.%s(_self);\n", module, Swig_name_destroy(realname));
|
||||
fprintf(f_shadow, "\t_self = 0;\n");
|
||||
fprintf(f_shadow, " }\n");
|
||||
fprintf(f_shadow, " }\n\n");
|
||||
|
|
|
|||
|
|
@ -5,3 +5,7 @@ extern "C" {
|
|||
#include "doh.h"
|
||||
}
|
||||
#include "swig11.h"
|
||||
|
||||
extern "C" {
|
||||
#include "swig.h"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
int argout_set = 0;
|
||||
|
||||
// Make a wrapper name for this
|
||||
char * wname = name_wrapper (iname, prefix);
|
||||
char * wname = Swig_name_wrapper (iname);
|
||||
|
||||
// Build the name for Scheme.
|
||||
proc_name = "";
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ void PERL5::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
void PERL5::create_command(char *cname, char *iname) {
|
||||
fprintf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, name_wrapper(cname,(char*)""));
|
||||
fprintf(f_init,"\t newXS(\"%s::%s\", %s, file);\n", package, iname, Swig_name_wrapper(cname));
|
||||
if (export_all) {
|
||||
exported << iname << " ";
|
||||
}
|
||||
|
|
@ -683,7 +683,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Make a wrapper name for this
|
||||
|
||||
wname = name_wrapper(iname,(char*)"");
|
||||
wname = Swig_name_wrapper(iname);
|
||||
|
||||
// Now write the wrapper function itself....this is pretty ugly
|
||||
|
||||
|
|
@ -1706,7 +1706,7 @@ void PERL5::cpp_close_class() {
|
|||
// Output a FETCH method. This is actually common to all classes
|
||||
pm << "sub FETCH {\n"
|
||||
<< tab4 << "my ($self,$field) = @_;\n"
|
||||
<< tab4 << "my $member_func = \"" << package << "::" << name_get(name_member((char*)"${field}",class_name,AS_IS),AS_IS) << "\";\n"
|
||||
<< tab4 << "my $member_func = \"" << package << "::" << Swig_name_get(Swig_name_member(class_name,"${field}")) << "\";\n"
|
||||
<< tab4 << "my $val = &$member_func($self);\n"
|
||||
<< tab4 << "if (exists $BLESSEDMEMBERS{$field}) {\n"
|
||||
<< tab8 << "return undef if (!defined($val));\n"
|
||||
|
|
@ -1721,7 +1721,7 @@ void PERL5::cpp_close_class() {
|
|||
|
||||
pm << "sub STORE {\n"
|
||||
<< tab4 << "my ($self,$field,$newval) = @_;\n"
|
||||
<< tab4 << "my $member_func = \"" << package << "::" << name_set(name_member((char*)"${field}",class_name,AS_IS),AS_IS) << "\";\n"
|
||||
<< tab4 << "my $member_func = \"" << package << "::" << Swig_name_set(Swig_name_member(class_name,"${field}")) << "\";\n"
|
||||
<< tab4 << "if (exists $BLESSEDMEMBERS{$field}) {\n"
|
||||
<< tab8 << "&$member_func($self,tied(%{$newval}));\n"
|
||||
<< tab4 << "} else {\n"
|
||||
|
|
@ -1834,7 +1834,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
|
||||
// Okay. We've made argument adjustments, now call into the package
|
||||
|
||||
func << tab4 << "my $result = " << package << "::" << name_member(realname,class_name)
|
||||
func << tab4 << "my $result = " << package << "::" << Swig_name_member(class_name,realname)
|
||||
<< "(@args);\n";
|
||||
|
||||
// Now check to see what kind of return result was found.
|
||||
|
|
@ -1988,7 +1988,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
|
||||
// Constructor doesn't match classname so we'll just use the normal name
|
||||
|
||||
*pcode << "sub " << name_construct(realname) << " () {\n";
|
||||
*pcode << "sub " << Swig_name_construct(realname) << " () {\n";
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -2015,7 +2015,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
i++;
|
||||
}
|
||||
|
||||
*pcode << tab4 << "$self = " << package << "::" << name_construct(realname) << "(@args);\n"
|
||||
*pcode << tab4 << "$self = " << package << "::" << Swig_name_construct(realname) << "(@args);\n"
|
||||
<< tab4 << "return undef if (!defined($self));\n"
|
||||
<< tab4 << "bless $self, \"" << fullclassname << "\";\n"
|
||||
<< tab4 << "$OWNER{$self} = 1;\n"
|
||||
|
|
@ -2055,7 +2055,7 @@ void PERL5::cpp_destructor(char *name, char *newname) {
|
|||
<< tab4 << "my $self = tied(%{$_[0]});\n"
|
||||
<< tab4 << "delete $ITERATORS{$self};\n"
|
||||
<< tab4 << "if (exists $OWNER{$self}) {\n"
|
||||
<< tab8 << package << "::" << name_destroy(realname) << "($self);\n"
|
||||
<< tab8 << package << "::" << Swig_name_destroy(realname) << "($self);\n"
|
||||
<< tab8 << "delete $OWNER{$self};\n"
|
||||
<< tab4 << "}\n}\n\n";
|
||||
|
||||
|
|
@ -2077,7 +2077,7 @@ void PERL5::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
else realname = iname;
|
||||
|
||||
if (blessed) {
|
||||
*pcode << "*" << realname << " = *" << realpackage << "::" << name_member(realname,class_name) << ";\n";
|
||||
*pcode << "*" << realname << " = *" << realpackage << "::" << Swig_name_member(class_name,realname) << ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2150,7 +2150,7 @@ void PERL5::cpp_declare_const(char *name, char *iname, DataType *type, char *val
|
|||
Setattr(symbols, cname.get(),cname.get());
|
||||
|
||||
// Create a symbol table entry for it
|
||||
*pcode << "*" << realname << " = *" << package << "::" << name_member(realname,class_name) << ";\n";
|
||||
*pcode << "*" << realname << " = *" << package << "::" << Swig_name_member(class_name,realname) << ";\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,8 +161,8 @@ void PYTHON::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l)
|
|||
|
||||
|
||||
if (!((Getattr(hash,t->name)) && (t->is_pointer <=1)) && !noopt) {
|
||||
*imethod << class_name << "." << realname << " = new.instancemethod(" << module << "." << name_member(realname,class_name) << ", None, " << class_name << ")\n";
|
||||
/* *pyclass << tab4 << realname << " = " << module << ".__shadow__." << name_member(realname,class_name) << "\n"; */
|
||||
*imethod << class_name << "." << realname << " = new.instancemethod(" << module << "." << Swig_name_member(class_name,realname) << ", None, " << class_name << ")\n";
|
||||
/* *pyclass << tab4 << realname << " = " << module << ".__shadow__." << Swig_name_member(class_name,realname) << "\n"; */
|
||||
} else {
|
||||
|
||||
// Now add it to the class
|
||||
|
|
@ -173,13 +173,13 @@ void PYTHON::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l)
|
|||
*pyclass << tab4 << "def " << realname << "(*args):\n";
|
||||
|
||||
if (use_kw)
|
||||
*pyclass << tab8 << "val = apply(" << module << "." << name_member(realname,class_name) << ",args, kwargs)\n";
|
||||
*pyclass << tab8 << "val = apply(" << module << "." << Swig_name_member(class_name,realname) << ",args, kwargs)\n";
|
||||
else
|
||||
*pyclass << tab8 << "val = apply(" << module << "." << name_member(realname,class_name) << ",args)\n";
|
||||
*pyclass << tab8 << "val = apply(" << module << "." << Swig_name_member(class_name,realname) << ",args)\n";
|
||||
|
||||
// Check to see if the return type is an object
|
||||
if ((Getattr(hash,t->name)) && (t->is_pointer <= 1)) {
|
||||
if (!typemap_check((char*)"out",typemap_lang,t,name_member(realname,class_name))) {
|
||||
if (!typemap_check((char*)"out",typemap_lang,t,Swig_name_member(class_name,realname))) {
|
||||
if (!have_output) {
|
||||
*pyclass << tab8 << "if val: val = " << GetChar(hash,t->name) << "Ptr(val) ";
|
||||
if (((Getattr(hash,t->name)) && (t->is_pointer < 1)) ||
|
||||
|
|
@ -244,9 +244,9 @@ void PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
*construct << tab4 << "def __init__(self,*args):\n";
|
||||
|
||||
if (use_kw)
|
||||
*construct << tab8 << "self.this = apply(" << module << "." << name_construct(realname) << ",args,kwargs)\n";
|
||||
*construct << tab8 << "self.this = apply(" << module << "." << Swig_name_construct(realname) << ",args,kwargs)\n";
|
||||
else
|
||||
*construct << tab8 << "self.this = apply(" << module << "." << name_construct(realname) << ",args)\n";
|
||||
*construct << tab8 << "self.this = apply(" << module << "." << Swig_name_construct(realname) << ",args)\n";
|
||||
*construct << tab8 << "self.thisown = 1\n";
|
||||
emitAddPragmas(*construct,(char*)"__init__",(char*)tab8);
|
||||
have_constructor = 1;
|
||||
|
|
@ -262,9 +262,9 @@ void PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
|
||||
*additional << tab4 << "val = " << class_name << "Ptr(apply(";
|
||||
if (use_kw)
|
||||
*additional << module << "." << name_construct(realname) << ",args,kwargs))\n";
|
||||
*additional << module << "." << Swig_name_construct(realname) << ",args,kwargs))\n";
|
||||
else
|
||||
*additional << module << "." << name_construct(realname) << ",args))\n";
|
||||
*additional << module << "." << Swig_name_construct(realname) << ",args))\n";
|
||||
*additional << tab4 << "val.thisown = 1\n"
|
||||
<< tab4 << "return val\n\n";
|
||||
}
|
||||
|
|
@ -294,7 +294,7 @@ void PYTHON::cpp_destructor(char *name, char *newname) {
|
|||
*pyclass << tab4 << "def __del__(self," << module << "=" << module << "):\n";
|
||||
emitAddPragmas(*pyclass,(char*)"__del__",(char*)tab8);
|
||||
*pyclass << tab8 << "if self.thisown == 1 :\n"
|
||||
<< tab8 << tab4 << module << "." << name_destroy(realname) << "(self)\n";
|
||||
<< tab8 << tab4 << module << "." << Swig_name_destroy(realname) << "(self)\n";
|
||||
|
||||
have_destructor = 1;
|
||||
}
|
||||
|
|
@ -452,14 +452,14 @@ void PYTHON::cpp_variable(char *name, char *iname, DataType *t) {
|
|||
if (Status & STAT_READONLY) {
|
||||
// *setattr << tab8 << tab4 << "raise RuntimeError, \'Member is read-only\'\n";
|
||||
} else {
|
||||
*csetattr << tab8 << "\"" << realname << "\" : " << module << "." << name_set(name_member(realname,class_name)) << ",\n";
|
||||
*csetattr << tab8 << "\"" << realname << "\" : " << module << "." << Swig_name_set(Swig_name_member(class_name,realname)) << ",\n";
|
||||
}
|
||||
// Write some code to get the variable
|
||||
if (inhash) {
|
||||
*cgetattr << tab8 << "\"" << realname << "\" : lambda x : " << GetChar(hash,t->name) << "Ptr(" << module << "." << name_get(name_member(realname,class_name)) << "(x)),\n";
|
||||
*cgetattr << tab8 << "\"" << realname << "\" : lambda x : " << GetChar(hash,t->name) << "Ptr(" << module << "." << Swig_name_get(Swig_name_member(class_name,realname)) << "(x)),\n";
|
||||
|
||||
} else {
|
||||
*cgetattr << tab8 << "\"" << realname << "\" : " << module << "." << name_get(name_member(realname,class_name)) << ",\n";
|
||||
*cgetattr << tab8 << "\"" << realname << "\" : " << module << "." << Swig_name_get(Swig_name_member(class_name,realname)) << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -493,7 +493,7 @@ void PYTHON::cpp_declare_const(char *name, char *iname, DataType *type, char *va
|
|||
}
|
||||
Setattr(symbols,cname.get(),cname.get());
|
||||
|
||||
*cinit << tab4 << realname << " = " << module << "." << name_member(realname,class_name) << "\n";
|
||||
*cinit << tab4 << realname << " = " << module << "." << Swig_name_member(class_name,realname) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ char *PYTHON::convert_self(WrapperFunction &)
|
|||
// ----------------------------------------------------------------------
|
||||
char *PYTHON::make_funcname_wrapper(char *fnName)
|
||||
{
|
||||
return name_wrapper(fnName,(char*)"");
|
||||
return Swig_name_wrapper(fnName);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
@ -546,7 +546,7 @@ void PYTHON::create_command(char *cname, char *iname) {
|
|||
|
||||
// Create the name of the wrapper function
|
||||
|
||||
char *wname = name_wrapper(cname,(char*)"");
|
||||
char *wname = Swig_name_wrapper(cname);
|
||||
|
||||
// Now register the function with the interpreter.
|
||||
|
||||
|
|
@ -1057,7 +1057,7 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
|||
// First make a sanitized version of the function name (in case it's some
|
||||
// funky C++ thing).
|
||||
|
||||
wname = name_wrapper(name,(char*)"");
|
||||
wname = Swig_name_wrapper(name);
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Create a function for setting the value of the variable
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ void TCL8::get_pointer(char *iname, char *srcname, char *src, char *dest,
|
|||
|
||||
void TCL8::create_command(char *cname, char *iname) {
|
||||
|
||||
char *wname = name_wrapper(cname,prefix);
|
||||
char *wname = Swig_name_wrapper(cname);
|
||||
|
||||
cmd_info << tab4 << "{ SWIG_prefix \"" << iname << "\", " << wname << ", NULL},\n";
|
||||
|
||||
|
|
@ -449,7 +449,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
|||
|
||||
// Make a wrapper name for this function
|
||||
|
||||
wname = name_wrapper(iname,prefix);
|
||||
wname = Swig_name_wrapper(iname);
|
||||
|
||||
// Now write the wrapper function itself....this is pretty ugly
|
||||
|
||||
|
|
@ -1277,7 +1277,7 @@ void TCL8::cpp_close_class() {
|
|||
|
||||
if (have_destructor) {
|
||||
code << "static void _swig_delete_" << class_name << "(void *obj) {\n"
|
||||
<< tab4 << name_destroy(class_name) << "((" << t->print_type() << ") obj);\n"
|
||||
<< tab4 << Swig_name_destroy(class_name) << "((" << t->print_type() << ") obj);\n"
|
||||
<< "}\n";
|
||||
}
|
||||
|
||||
|
|
@ -1293,7 +1293,7 @@ void TCL8::cpp_close_class() {
|
|||
<< "\", &SWIGTYPE" << t->print_mangle() << ",";
|
||||
|
||||
if (have_constructor) {
|
||||
code << name_wrapper(name_construct(class_name),prefix);
|
||||
code << Swig_name_wrapper(Swig_name_construct(class_name));
|
||||
} else {
|
||||
code << "0";
|
||||
}
|
||||
|
|
@ -1326,10 +1326,10 @@ void TCL8::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
// Add stubs for this member to our class handler function
|
||||
|
||||
temp = "";
|
||||
temp << name_member(realname,class_name);
|
||||
temp << Swig_name_member(class_name,realname);
|
||||
rname = GetChar(repeatcmd,temp);
|
||||
if (!rname)
|
||||
rname = name_wrapper(temp.get(),prefix);
|
||||
rname = Swig_name_wrapper(temp.get());
|
||||
|
||||
methods << tab4 << "{\"" << realname << "\", " << rname << "}, \n";
|
||||
}
|
||||
|
|
@ -1354,18 +1354,18 @@ void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
|
|||
|
||||
// Try to figure out if there is a wrapper for this function
|
||||
temp = "";
|
||||
temp << name_get(name_member(realname,bc));
|
||||
temp << Swig_name_get(Swig_name_member(bc,realname));
|
||||
rname = GetChar(repeatcmd,temp);
|
||||
if (!rname)
|
||||
rname = name_wrapper(temp.get(),prefix);
|
||||
rname = Swig_name_wrapper(temp.get());
|
||||
attributes << rname << ", ";
|
||||
|
||||
if (!(Status & STAT_READONLY)) {
|
||||
temp = "";
|
||||
temp << name_set(name_member(realname,bc));
|
||||
temp << Swig_name_set(Swig_name_member(bc,realname));
|
||||
rname = GetChar(repeatcmd,temp);
|
||||
if (!rname)
|
||||
rname = name_wrapper(temp.get(),prefix);
|
||||
rname = Swig_name_wrapper(temp.get());
|
||||
attributes << rname << "},\n";
|
||||
} else {
|
||||
attributes << "0 },\n";
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ 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 \
|
||||
typemap.o naming.o
|
||||
typemap.o
|
||||
|
||||
SRCS = main.cxx scanner.cxx symbol.cxx types.cxx parms.cxx \
|
||||
emit.cxx cplus.cxx lang.cxx hash.cxx \
|
||||
sstring.cxx wrapfunc.cxx typemap.cxx naming.cxx
|
||||
sstring.cxx wrapfunc.cxx typemap.cxx
|
||||
|
||||
PARSER = $(srcdir)/parser.yxx
|
||||
INCLUDE = -I$(srcdir)/../Include \
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "internal.h"
|
||||
extern "C" {
|
||||
#include "swig.h"
|
||||
}
|
||||
|
||||
static char cvstag[] = "$Header$";
|
||||
|
||||
|
|
@ -1493,7 +1496,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
// Generate the name of the C wrapper function (is always the same, regardless
|
||||
// of renaming).
|
||||
|
||||
cname << name_member(mname,bc);
|
||||
cname << Swig_name_member(bc,mname);
|
||||
|
||||
// Generate the scripting name of this function
|
||||
if (classrename)
|
||||
|
|
@ -1502,9 +1505,9 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
|
|||
prefix = classname;
|
||||
|
||||
if (mrename)
|
||||
iname << name_member(mrename,prefix);
|
||||
iname << Swig_name_member(prefix,mrename);
|
||||
else
|
||||
iname << name_member(mname,prefix);
|
||||
iname << Swig_name_member(prefix,mname);
|
||||
|
||||
// Now check to see if we have already wrapped a function like this.
|
||||
// If so, we'll just use the existing wrapper.
|
||||
|
|
@ -1708,7 +1711,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
if ((!mode) && (!ObjCClass)) {
|
||||
cname << bc << "::" << mname;
|
||||
} else {
|
||||
cname << name_member(mname,bc);
|
||||
cname << Swig_name_member(bc,mname);
|
||||
}
|
||||
|
||||
// Generate the scripting name of this function
|
||||
|
|
@ -1718,9 +1721,9 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
|
|||
prefix = classname;
|
||||
|
||||
if (mrename)
|
||||
iname << name_member(mrename,prefix);
|
||||
iname << Swig_name_member(prefix,mrename);
|
||||
else
|
||||
iname << name_member(mname,prefix);
|
||||
iname << Swig_name_member(prefix,mname);
|
||||
|
||||
// Perform a hash table lookup to see if we've wrapped anything like this before
|
||||
|
||||
|
|
@ -1870,11 +1873,11 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
|
|||
else
|
||||
prefix = classname;
|
||||
|
||||
cname << name_destroy(classname);
|
||||
cname << Swig_name_destroy(classname);
|
||||
if (mrename)
|
||||
iname << name_destroy(mrename);
|
||||
iname << Swig_name_destroy(mrename);
|
||||
else
|
||||
iname << name_destroy(prefix);
|
||||
iname << Swig_name_destroy(prefix);
|
||||
|
||||
if (!mode) {
|
||||
// Spit out a helper function for this member function
|
||||
|
|
@ -1959,11 +1962,11 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
|
|||
else
|
||||
prefix = classname;
|
||||
|
||||
cname << name_construct(classname);
|
||||
cname << Swig_name_construct(classname);
|
||||
if (mrename)
|
||||
iname << name_construct(mrename);
|
||||
iname << Swig_name_construct(mrename);
|
||||
else
|
||||
iname << name_construct(prefix);
|
||||
iname << Swig_name_construct(prefix);
|
||||
|
||||
// Create a return type
|
||||
|
||||
|
|
@ -2131,7 +2134,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
// Generate the name of the C wrapper function (is always the same, regardless
|
||||
// of renaming).
|
||||
|
||||
cname << name_get(name_member(mname,bc));
|
||||
cname << Swig_name_get(Swig_name_member(bc,mname));
|
||||
|
||||
// Generate the scripting name of this function
|
||||
if (classrename)
|
||||
|
|
@ -2140,9 +2143,9 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
|
|||
prefix = classname;
|
||||
|
||||
if (mrename)
|
||||
iname << name_get(name_member(mrename,prefix));
|
||||
iname << Swig_name_get(Swig_name_member(prefix,mrename));
|
||||
else
|
||||
iname << name_get(name_member(mname,prefix));
|
||||
iname << Swig_name_get(Swig_name_member(prefix,mname));
|
||||
|
||||
// Now check to see if we have already wrapped a variable like this.
|
||||
|
||||
|
|
@ -2308,7 +2311,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
// Generate the name of the C wrapper function (is always the same, regardless
|
||||
// of renaming).
|
||||
|
||||
cname << name_set(name_member(mname,bc));
|
||||
cname << Swig_name_set(Swig_name_member(bc,mname));
|
||||
|
||||
// Generate the scripting name of this function
|
||||
if (classrename)
|
||||
|
|
@ -2317,9 +2320,9 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
|
|||
prefix = classname;
|
||||
|
||||
if (mrename)
|
||||
iname << name_set(name_member(mrename,prefix));
|
||||
iname << Swig_name_set(Swig_name_member(prefix,mrename));
|
||||
else
|
||||
iname << name_set(name_member(mname,prefix));
|
||||
iname << Swig_name_set(Swig_name_member(prefix,mname));
|
||||
|
||||
// Now check to see if we have already wrapped a variable like this.
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "internal.h"
|
||||
extern "C" {
|
||||
#include "swig.h"
|
||||
}
|
||||
|
||||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
|
|
@ -442,11 +446,11 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||
t->is_pointer++;
|
||||
fprintf(f_header,"static %s %s(%s val) {\n",
|
||||
t->print_type(), name_set(name), t->print_type());
|
||||
t->print_type(), Swig_name_set(name), t->print_type());
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
fprintf(f_header,"static %s %s(%s val) {\n",
|
||||
t->print_type(), name_set(name), t->print_type());
|
||||
t->print_type(), Swig_name_set(name), t->print_type());
|
||||
}
|
||||
|
||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||
|
|
@ -498,8 +502,8 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
p->name[0] = 0;
|
||||
l->append(p);
|
||||
|
||||
new_name = name_set(name);
|
||||
new_iname = name_set(iname);
|
||||
new_name = Swig_name_set(name);
|
||||
new_iname = Swig_name_set(iname);
|
||||
|
||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||
t->is_pointer++;
|
||||
|
|
@ -517,12 +521,12 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||
t->is_pointer++;
|
||||
fprintf(f_header,"static %s %s() { \n",
|
||||
t->print_type(), name_get(name));
|
||||
t->print_type(), Swig_name_get(name));
|
||||
fprintf(f_header,"\t return (%s) &%s;\n", t->print_type(), name);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
fprintf(f_header,"static %s %s() { \n",
|
||||
t->print_type(), name_get(name));
|
||||
t->print_type(), Swig_name_get(name));
|
||||
fprintf(f_header,"\t return (%s) %s;\n", t->print_type(), name);
|
||||
}
|
||||
|
||||
|
|
@ -532,8 +536,8 @@ void emit_set_get(char *name, char *iname, DataType *t) {
|
|||
|
||||
l = new ParmList;
|
||||
|
||||
new_name = name_get(name);
|
||||
new_iname = name_get(iname);
|
||||
new_name = Swig_name_get(name);
|
||||
new_iname = Swig_name_get(iname);
|
||||
|
||||
if ((t->type == T_USER) && (!t->is_pointer)) {
|
||||
t->is_pointer++;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ static char cvsroot[] = "$Header$";
|
|||
#include "internal.h"
|
||||
#include <ctype.h>
|
||||
|
||||
extern "C" {
|
||||
#include "swig.h"
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// void Language::set_init(char *iname)
|
||||
//
|
||||
|
|
@ -148,19 +152,19 @@ void Language::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
if (AddMethods) {
|
||||
char *bc = cplus_base_class(name); // Get base class name of this method
|
||||
if (bc)
|
||||
strcpy(cname, name_member(name,bc));
|
||||
strcpy(cname, Swig_name_member(bc,name));
|
||||
else
|
||||
strcpy(cname, name_member(name,ClassName));
|
||||
strcpy(cname, Swig_name_member(ClassName,name));
|
||||
} else {
|
||||
strcpy(cname, name_member(name,ClassName));
|
||||
strcpy(cname, Swig_name_member(ClassName,name));
|
||||
}
|
||||
|
||||
// Create the actual function name
|
||||
|
||||
if (iname) {
|
||||
strcpy(new_name, name_member(iname, prefix));
|
||||
strcpy(new_name, Swig_name_member(prefix,iname));
|
||||
} else {
|
||||
strcpy(new_name, name_member(name,prefix));
|
||||
strcpy(new_name, Swig_name_member(prefix,name));
|
||||
}
|
||||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
|
@ -202,9 +206,9 @@ void Language::cpp_constructor(char *name, char *iname, ParmList *l) {
|
|||
prefix = ClassName;
|
||||
|
||||
if (iname)
|
||||
cname = name_construct(iname);
|
||||
cname = Swig_name_construct(iname);
|
||||
else
|
||||
cname = name_construct(prefix);
|
||||
cname = Swig_name_construct(prefix);
|
||||
|
||||
// Add this function to the SWIG symbol table
|
||||
|
||||
|
|
@ -236,9 +240,9 @@ void Language::cpp_destructor(char *name, char *iname) {
|
|||
char *cname;
|
||||
|
||||
if (ClassRename)
|
||||
cname = name_destroy(ClassRename);
|
||||
cname = Swig_name_destroy(ClassRename);
|
||||
else
|
||||
cname = name_destroy(ClassName);
|
||||
cname = Swig_name_destroy(ClassName);
|
||||
|
||||
// Add this function to the SWIG symbol table
|
||||
|
||||
|
|
@ -314,9 +318,9 @@ void Language::cpp_variable(char *name, char *iname, DataType *t) {
|
|||
}
|
||||
|
||||
if (iname)
|
||||
cname = name_get(name_member(iname,prefix));
|
||||
cname = Swig_name_get(Swig_name_member(prefix,iname));
|
||||
else
|
||||
cname = name_get(name_member(name,prefix));
|
||||
cname = Swig_name_get(Swig_name_member(prefix,name));
|
||||
|
||||
// Check the symbol table
|
||||
|
||||
|
|
@ -369,7 +373,7 @@ void Language::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l
|
|||
else
|
||||
mname = name;
|
||||
|
||||
cname = name_member(mname,prefix);
|
||||
cname = Swig_name_member(prefix,mname);
|
||||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
||||
|
|
@ -418,9 +422,9 @@ void Language::cpp_declare_const(char *name, char *iname, DataType *type, char *
|
|||
// Set the constant name
|
||||
|
||||
if (iname)
|
||||
cname = name_member(iname,prefix);
|
||||
cname = Swig_name_member(prefix,iname);
|
||||
else
|
||||
cname = name_member(name,prefix);
|
||||
cname = Swig_name_member(prefix,name);
|
||||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
||||
|
|
@ -478,9 +482,9 @@ void Language::cpp_static_var(char *name, char *iname, DataType *t) {
|
|||
// Create the variable name
|
||||
|
||||
if (iname)
|
||||
cname = name_member(iname,prefix);
|
||||
cname = Swig_name_member(prefix,iname);
|
||||
else
|
||||
cname = name_member(name,prefix);
|
||||
cname = Swig_name_member(prefix,name);
|
||||
|
||||
// Now do a symbol table lookup on it :
|
||||
|
||||
|
|
|
|||
|
|
@ -1,230 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* naming.cxx
|
||||
*
|
||||
* Functions for creating various kinds of names used during code generation.
|
||||
*
|
||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (C) 1998-2000. The University of Chicago
|
||||
* Copyright (C) 1995-1998. The University of Utah and The Regents of the
|
||||
* University of California.
|
||||
*
|
||||
* See the file LICENSE for information on usage and redistribution.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
#include "internal.h"
|
||||
#include <ctype.h>
|
||||
|
||||
// Hash table containing naming data
|
||||
|
||||
static Hash naming_hash;
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// make_wrap_name(char *s)
|
||||
//
|
||||
// Takes the name at src, and converts it into a syntactically
|
||||
// valid identifier name. This is a hack to get the wrapper
|
||||
// generator to support class member functions and other things.
|
||||
//
|
||||
// ie. We can define a function name as obj->foo(),
|
||||
// but we'll need to call the wrapper function something like
|
||||
// _wrap_obj__foo()
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
void make_wrap_name(char *s) {
|
||||
|
||||
char *c1 = s;
|
||||
int i;
|
||||
for (i = 0; i < (int) strlen(s); i++, c1++) {
|
||||
if(!isalnum(*c1)) *c1 = '_';
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// void name_register(char *method, char *format)
|
||||
//
|
||||
// Registers a new naming scheme.
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
void name_register(char *method, char *format) {
|
||||
naming_hash.remove(method);
|
||||
naming_hash.add(method,copy_string(format));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// char *name_getformat(char *method)
|
||||
//
|
||||
// Get name format
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
static char *name_getformat(char *method) {
|
||||
return (char *) naming_hash.lookup(method);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// char *name_wrapper(char *fname, char *prefix, int suppress)
|
||||
//
|
||||
// Returns the name of a wrapper function. The following variables are
|
||||
// available :
|
||||
//
|
||||
// %f -> fname
|
||||
// %p -> prefix
|
||||
// %l -> language
|
||||
//
|
||||
// By default a wrapper function gets the name _wrap_prefixfname.
|
||||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
char *name_wrapper(char *fname, char *prefix, int suppress) {
|
||||
static String fmt;
|
||||
char *f;
|
||||
|
||||
f = name_getformat((char*)"wrapper");
|
||||
if (!f) {
|
||||
f = (char*)"_wrap_%p%f"; // Default wrapper name
|
||||
}
|
||||
fmt = f;
|
||||
fmt.replace("%f",fname);
|
||||
fmt.replace("%l",typemap_lang);
|
||||
fmt.replace("%p",prefix);
|
||||
if (!suppress)
|
||||
make_wrap_name(fmt);
|
||||
return fmt;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// char *name_member(char *fname, char *classname, int suppress)
|
||||
//
|
||||
// Returns the name of a method function. The following variables are
|
||||
// available :
|
||||
//
|
||||
// %f -> fname
|
||||
// %c -> classname
|
||||
// %l -> language
|
||||
//
|
||||
// By default, the name of a method is given as Classname_method.
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
char *name_member(char *fname, char *classname, int suppress) {
|
||||
static String fmt;
|
||||
char *f;
|
||||
|
||||
f = name_getformat((char*)"member");
|
||||
if (!f) {
|
||||
f = (char*)"%c_%f";
|
||||
}
|
||||
fmt = f;
|
||||
fmt.replace("%f",fname);
|
||||
fmt.replace("%l",typemap_lang);
|
||||
fmt.replace("%c",classname);
|
||||
if (!suppress)
|
||||
make_wrap_name(fmt);
|
||||
return fmt;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// char *name_get(char *vname, int suppress)
|
||||
//
|
||||
// Returns the name of the accessor function used to get a variable.
|
||||
//
|
||||
// %v -> variable name
|
||||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
char *name_get(char *vname, int suppress) {
|
||||
static String fmt;
|
||||
char *f;
|
||||
|
||||
f = name_getformat((char*)"get");
|
||||
if (!f) {
|
||||
f = (char*)"%v_get";
|
||||
}
|
||||
fmt = f;
|
||||
fmt.replace("%v",vname);
|
||||
if (!suppress)
|
||||
make_wrap_name(fmt);
|
||||
return fmt;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// char *name_set(char *vname, int suppress)
|
||||
//
|
||||
// Returns the name of the accessor function used to set a variable.
|
||||
//
|
||||
// %v -> variable name
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
char *name_set(char *vname, int suppress) {
|
||||
static String fmt;
|
||||
char *f;
|
||||
|
||||
f = name_getformat((char*)"set");
|
||||
if (!f) {
|
||||
f = (char*)"%v_set";
|
||||
}
|
||||
fmt = f;
|
||||
fmt.replace("%v",vname);
|
||||
if (!suppress)
|
||||
make_wrap_name(fmt);
|
||||
return fmt;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// char *name_construct(char *classname, int suppress)
|
||||
//
|
||||
// Returns the name of the accessor function used to create an object.
|
||||
// By default this is "new_classname"
|
||||
//
|
||||
// %c -> classname
|
||||
// %l -> language
|
||||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
char *name_construct(char *classname, int suppress) {
|
||||
static String fmt;
|
||||
char *f;
|
||||
|
||||
f = name_getformat((char*)"construct");
|
||||
if (!f) {
|
||||
f = (char*)"new_%c";
|
||||
}
|
||||
fmt = f;
|
||||
fmt.replace("%l",typemap_lang);
|
||||
fmt.replace("%c",classname);
|
||||
if (!suppress)
|
||||
make_wrap_name(fmt);
|
||||
return fmt;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// char *name_destroy(char *classname, int suppress)
|
||||
//
|
||||
// Returns the name of the accessor function used to destroy an object.
|
||||
// By default this is "delete_classname"
|
||||
//
|
||||
// %c -> classname
|
||||
// %l -> language
|
||||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
char *name_destroy(char *classname, int suppress) {
|
||||
static String fmt;
|
||||
char *f;
|
||||
|
||||
f = name_getformat((char*)"destroy");
|
||||
if (!f) {
|
||||
f = (char*)"delete_%c";
|
||||
}
|
||||
fmt = f;
|
||||
fmt.replace("%l",typemap_lang);
|
||||
fmt.replace("%c",classname);
|
||||
if (!suppress)
|
||||
make_wrap_name(fmt);
|
||||
return fmt;
|
||||
}
|
||||
|
|
@ -472,15 +472,18 @@ extern "C" {
|
|||
extern FILE *Swig_open(const void *filename);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Class for Creating Wrapper Functions
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
class WrapperFunction {
|
||||
private:
|
||||
Hash h;
|
||||
Hash localh;
|
||||
void *h;
|
||||
void *localh;
|
||||
public:
|
||||
WrapperFunction();
|
||||
~WrapperFunction();
|
||||
String def;
|
||||
String locals;
|
||||
String code;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,20 @@ static char cvsroot[] = "$Header$";
|
|||
#include "internal.h"
|
||||
#include <ctype.h>
|
||||
|
||||
extern "C" {
|
||||
#include "doh.h"
|
||||
}
|
||||
|
||||
WrapperFunction::WrapperFunction() {
|
||||
h = NewHash();
|
||||
localh = NewHash();
|
||||
}
|
||||
|
||||
WrapperFunction::~WrapperFunction() {
|
||||
Delete(h);
|
||||
Delete(localh);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// isolate the type name. This is a hack (sorry).
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -52,12 +66,15 @@ static char *isolate_type_name(char *tname) {
|
|||
|
||||
void WrapperFunction::print(FILE *f) {
|
||||
String *s;
|
||||
s = (String *) localh.first();
|
||||
while (s) {
|
||||
DOH *key;
|
||||
|
||||
key = Firstkey(localh);
|
||||
while (key) {
|
||||
s = (String *) GetVoid(localh,key);
|
||||
char *c = s->get();
|
||||
c[strlen(c)-1] = 0;
|
||||
locals << tab4 << c << ";\n";
|
||||
s = (String *) localh.next();
|
||||
key = Nextkey(localh);
|
||||
}
|
||||
fprintf(f,"%s\n",def.get());
|
||||
fprintf(f,"%s",locals.get());
|
||||
|
|
@ -70,12 +87,14 @@ void WrapperFunction::print(FILE *f) {
|
|||
|
||||
void WrapperFunction::print(String &f) {
|
||||
String *s;
|
||||
s = (String *) localh.first();
|
||||
while (s) {
|
||||
DOH *key;
|
||||
key = Firstkey(localh);
|
||||
while (key) {
|
||||
s = (String *) GetVoid(localh,key);
|
||||
char *c = s->get();
|
||||
c[strlen(c)-1] = 0;
|
||||
locals << tab4 << c << ";\n";
|
||||
s = (String *) localh.next();
|
||||
key = Nextkey(localh);
|
||||
}
|
||||
|
||||
f << def << "\n"
|
||||
|
|
@ -106,23 +125,25 @@ void WrapperFunction::add_local(char *type, char *name, char *defarg) {
|
|||
c++;
|
||||
}
|
||||
*t = 0;
|
||||
if (h.add(temp,new_type,WrapperFunction::del_type) == -1) {
|
||||
if (Getattr(h,temp)) {
|
||||
// Check to see if a type mismatch has occurred
|
||||
stored_type = (char *) h.lookup(temp);
|
||||
stored_type = GetChar(h,temp);
|
||||
if (strcmp(type,stored_type) != 0)
|
||||
fprintf(stderr,"Error. Type %s conflicts with previously declared type of %s\n",
|
||||
type, stored_type);
|
||||
return;
|
||||
} else {
|
||||
SetChar(h,temp,new_type);
|
||||
}
|
||||
|
||||
// See if any wrappers have been generated with this type
|
||||
|
||||
char *tname = isolate_type_name(type);
|
||||
String *lstr = (String *)localh.lookup(tname);
|
||||
String *lstr = (String *) GetVoid(localh,tname);
|
||||
if (!lstr) {
|
||||
lstr = new String;
|
||||
*(lstr) << tname << " ";
|
||||
localh.add(tname, (void *) lstr);
|
||||
SetVoid(localh,tname,lstr);
|
||||
}
|
||||
|
||||
// Successful, write some wrapper code
|
||||
|
|
@ -158,7 +179,7 @@ char *WrapperFunction::new_local(char *type, char *name, char *defarg) {
|
|||
new_name << *c;
|
||||
|
||||
// Try to add a new local variable
|
||||
if (h.add(new_name,new_type,WrapperFunction::del_type) == -1) {
|
||||
if (Getattr(h,new_name.get())) {
|
||||
// Local variable already exists, try to generate a new name
|
||||
int i = 0;
|
||||
new_name = "";
|
||||
|
|
@ -169,7 +190,7 @@ char *WrapperFunction::new_local(char *type, char *name, char *defarg) {
|
|||
for (c = name; ((isalnum(*c) || (*c == '_') || (*c == '$')) && (*c)); c++)
|
||||
new_name << *c;
|
||||
new_name << i;
|
||||
while (h.add(new_name,new_type,WrapperFunction::del_type) == -1) {
|
||||
while (Getattr(h,new_name.get())) {
|
||||
i++;
|
||||
c = name;
|
||||
new_name = "";
|
||||
|
|
@ -177,6 +198,9 @@ char *WrapperFunction::new_local(char *type, char *name, char *defarg) {
|
|||
new_name << *c;
|
||||
new_name << i;
|
||||
}
|
||||
Setattr(h,new_name.get(),new_type);
|
||||
} else {
|
||||
Setattr(h,new_name.get(),new_type);
|
||||
}
|
||||
new_name << c;
|
||||
// Successful, write some wrapper code
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
SRCS = tree.c stype.c scanner.c include.c getopt.c misc.c
|
||||
OBJS = tree.o stype.o scanner.o include.o getopt.o misc.o
|
||||
SRCS = naming.c tree.c stype.c scanner.c include.c getopt.c misc.c
|
||||
OBJS = naming.o tree.o stype.o scanner.o include.o getopt.o misc.o
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
|
|
|||
191
Source/Swig/naming.c
Normal file
191
Source/Swig/naming.c
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* naming.c
|
||||
*
|
||||
* Functions for generating various kinds of names during code generation
|
||||
*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static char cvsroot[] = "$Header$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/* Hash table containing naming data */
|
||||
|
||||
static DOH *naming_hash = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_register()
|
||||
*
|
||||
* Register a new naming format.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_name_register(DOHString_or_char *method, DOHString_or_char *format) {
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
Setattr(naming_hash,method,format);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_mangle()
|
||||
*
|
||||
* Converts all of the non-identifier characters of a string to underscores.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_name_mangle(DOHString_or_char *s) {
|
||||
static DOHString *r = 0;
|
||||
char *c;
|
||||
if (!r) r = NewString("");
|
||||
Clear(r);
|
||||
Append(r,s);
|
||||
c = Char(r);
|
||||
while (*c) {
|
||||
if (!isalnum(*c)) *c = '_';
|
||||
c++;
|
||||
}
|
||||
return Char(r);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_wrapper()
|
||||
*
|
||||
* Returns the name of a wrapper function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_name_wrapper(DOHString_or_char *fname) {
|
||||
static DOHString *r = 0;
|
||||
DOHString *f;
|
||||
|
||||
if (!r) r = NewString("");
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
Clear(r);
|
||||
f = Getattr(naming_hash,"wrapper");
|
||||
if (!f) {
|
||||
Append(r,"_wrap_%f");
|
||||
} else {
|
||||
Append(r,f);
|
||||
}
|
||||
Replace(r,"%f",fname, DOH_REPLACE_ANY);
|
||||
return Char(r);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_member()
|
||||
*
|
||||
* Returns the name of a class method.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_name_member(DOHString_or_char *classname, DOHString_or_char *mname) {
|
||||
static DOHString *r = 0;
|
||||
DOHString *f;
|
||||
|
||||
if (!r) r = NewString("");
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
Clear(r);
|
||||
f = Getattr(naming_hash,"member");
|
||||
if (!f) {
|
||||
Append(r,"%c_%m");
|
||||
} else {
|
||||
Append(r,f);
|
||||
}
|
||||
Replace(r,"%c",classname, DOH_REPLACE_ANY);
|
||||
Replace(r,"%m",mname, DOH_REPLACE_ANY);
|
||||
return Char(r);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_get()
|
||||
*
|
||||
* Returns the name of the accessor function used to get a variable.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_name_get(DOHString_or_char *vname) {
|
||||
static DOHString *r = 0;
|
||||
DOHString *f;
|
||||
|
||||
if (!r) r = NewString("");
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
Clear(r);
|
||||
f = Getattr(naming_hash,"get");
|
||||
if (!f) {
|
||||
Append(r,"%v_get");
|
||||
} else {
|
||||
Append(r,f);
|
||||
}
|
||||
Replace(r,"%v",vname, DOH_REPLACE_ANY);
|
||||
return Char(r);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_set()
|
||||
*
|
||||
* Returns the name of the accessor function used to set a variable.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_name_set(DOHString_or_char *vname) {
|
||||
static DOHString *r = 0;
|
||||
DOHString *f;
|
||||
|
||||
if (!r) r = NewString("");
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
Clear(r);
|
||||
f = Getattr(naming_hash,"set");
|
||||
if (!f) {
|
||||
Append(r,"%v_set");
|
||||
} else {
|
||||
Append(r,f);
|
||||
}
|
||||
Replace(r,"%v",vname, DOH_REPLACE_ANY);
|
||||
return Char(r);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_construct()
|
||||
*
|
||||
* Returns the name of the accessor function used to create an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_name_construct(DOHString_or_char *classname) {
|
||||
static DOHString *r = 0;
|
||||
DOHString *f;
|
||||
|
||||
if (!r) r = NewString("");
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
Clear(r);
|
||||
f = Getattr(naming_hash,"construct");
|
||||
if (!f) {
|
||||
Append(r,"new_%c");
|
||||
} else {
|
||||
Append(r,f);
|
||||
}
|
||||
Replace(r,"%c",classname, DOH_REPLACE_ANY);
|
||||
return Char(r);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_destroy()
|
||||
*
|
||||
* Returns the name of the accessor function used to destroy an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_name_destroy(DOHString_or_char *classname) {
|
||||
static DOHString *r = 0;
|
||||
DOHString *f;
|
||||
|
||||
if (!r) r = NewString("");
|
||||
if (!naming_hash) naming_hash = NewHash();
|
||||
Clear(r);
|
||||
f = Getattr(naming_hash,"destroy");
|
||||
if (!f) {
|
||||
Append(r,"delete_%c");
|
||||
} else {
|
||||
Append(r,f);
|
||||
}
|
||||
Replace(r,"%c",classname, DOH_REPLACE_ANY);
|
||||
return Char(r);
|
||||
}
|
||||
|
|
@ -22,10 +22,6 @@
|
|||
|
||||
#include "doh.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --- File interface --- */
|
||||
|
||||
extern void Swig_add_directory(const DOHString_or_char *dirname);
|
||||
|
|
@ -143,52 +139,6 @@ extern int StringType_isstruct(DOHString *t);
|
|||
extern int StringType_isqualifier(DOHString *t);
|
||||
extern DOHString *StringType_base(DOHString *t);
|
||||
|
||||
/* --- NEW Type system --- */
|
||||
|
||||
/* constructors */
|
||||
DOH *SwigType_fromstring(DOH *string);
|
||||
DOH *SwigType_new(int type, DOH *tag, DOH *contents, DOH *parent, int width);
|
||||
|
||||
DOH *SwigType_integer(int width);
|
||||
DOH *SwigType_unsigned(int width);
|
||||
DOH *SwigType_character(int width);
|
||||
DOH *SwigType_float(int width);
|
||||
DOH *SwigType_void();
|
||||
DOH *SwigType_name(DOH *tag);
|
||||
DOH *SwigType_enum(DOH *tag, DOH *contents);
|
||||
DOH *SwigType_struct(DOH *tag, DOH *contents);
|
||||
DOH *SwigType_union(DOH *tag, DOH *contents);
|
||||
|
||||
DOH *SwigType_array(DOH *size, DOH *parent);
|
||||
DOH *SwigType_function(DOH *parameters, DOH *parent);
|
||||
DOH *SwigType_pointer(DOH *parent);
|
||||
DOH *SwigType_qualifier(DOH *tag, DOH *parent);
|
||||
|
||||
/* accessors -- return information about the outermost
|
||||
constructor. */
|
||||
int SwigType_get_type(DOH *t);
|
||||
int SwigType_get_width(DOH *t);
|
||||
DOH *SwigType_get_tag(DOH *t);
|
||||
DOH *SwigType_get_contents(DOH *t);
|
||||
|
||||
/* Type constants (returned from SwigType_gettype) */
|
||||
|
||||
#define SWIGTYPE_INTEGER 0
|
||||
#define SWIGTYPE_UNSIGNED 1
|
||||
#define SWIGTYPE_CHARACTER 2
|
||||
#define SWIGTYPE_FLOAT 3
|
||||
#define SWIGTYPE_VOID 4
|
||||
#define SWIGTYPE_NAME 5
|
||||
#define SWIGTYPE_ENUM 6
|
||||
#define SWIGTYPE_STRUCT 7
|
||||
#define SWIGTYPE_UNION 8
|
||||
#define SWIGTYPE_CLASS 9
|
||||
#define SWIGTYPE_ARRAY 10
|
||||
#define SWIGTYPE_FUNCTION 11
|
||||
#define SWIGTYPE_POINTER 12
|
||||
#define SWIGTYPE_REFERENCE 13
|
||||
#define SWIGTYPE_QUALIFIER 14
|
||||
|
||||
/* --- Parse tree support --- */
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -202,7 +152,7 @@ extern void Swig_add_rules(SwigRule ruleset[]);
|
|||
extern void Swig_clear_rules();
|
||||
extern int Swig_emit(DOH *obj, void *clientdata);
|
||||
|
||||
/* -- Wrapper function Object */
|
||||
/* -- Wrapper function Object */
|
||||
|
||||
typedef struct {
|
||||
DOHHash *localh;
|
||||
|
|
@ -217,14 +167,21 @@ extern void SwigWrapper_print(SwigWrapper *w, DOHFile *f);
|
|||
extern int SwigWrapper_add_local(SwigWrapper *w, DOHString_or_char *decl, DOHString_or_char *name);
|
||||
extern int SwigWrapper_check_local(SwigWrapper *w, DOHString_or_char *name);
|
||||
|
||||
/* --- Naming functions --- */
|
||||
|
||||
extern void Swig_name_register(DOHString_or_char *method, DOHString_or_char *format);
|
||||
extern char *Swig_name_mangle(DOHString_or_char *s);
|
||||
extern char *Swig_name_wrapper(DOHString_or_char *fname);
|
||||
extern char *Swig_name_member(DOHString_or_char *classname, DOHString_or_char *mname);
|
||||
extern char *Swig_name_get(DOHString_or_char *vname);
|
||||
extern char *Swig_name_set(DOHString_or_char *vname);
|
||||
extern char *Swig_name_construct(DOHString_or_char *classname);
|
||||
extern char *Swig_name_destroy(DOHString_or_char *classname);
|
||||
|
||||
/* --- Misc --- */
|
||||
extern char *Swig_copy_string(const char *c);
|
||||
extern void Swig_banner(DOHFile *f);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
1065
Source/Swig/type.c
1065
Source/Swig/type.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,364 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* types.c
|
||||
*
|
||||
* This file defines a generic type object implementation. Types are
|
||||
* defined recursively as described in the "dragon book", pg. 355.
|
||||
*
|
||||
* 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"
|
||||
|
||||
/* External structure */
|
||||
typedef struct SwigType {
|
||||
DOHXCOMMON;
|
||||
int type;
|
||||
DOH *value;
|
||||
struct SwigType *next;
|
||||
struct SwigType *prev;
|
||||
} SwigType;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_copy()
|
||||
*
|
||||
* Copy a datatype.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
DOH *
|
||||
SwigType_copy(DOH *tobj) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
SwigType *nt;
|
||||
|
||||
nt = NewSwigType(t->type, Copy(t->value));
|
||||
nt->prev = 0;
|
||||
nt->next = (SwigType *) Copy(t->next);
|
||||
return (DOH *) nt;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_delete()
|
||||
*
|
||||
* Delete a datatype.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
SwigType_delete(DOH *tobj) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
Delete(t->value);
|
||||
Delete(t->next);
|
||||
DohObjFree(t);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_str()
|
||||
*
|
||||
* Create a string representation of this datatype. This is language neutral
|
||||
* and is really ugly.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOH *
|
||||
SwigType_str(DOH *tobj) {
|
||||
DOH *s, *s1;
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
s = NewString("");
|
||||
switch(t->type) {
|
||||
case SWIG_TYPE_BYTE:
|
||||
Printf(s,"BYTE");
|
||||
break;
|
||||
case SWIG_TYPE_UBYTE:
|
||||
Printf(s,"UBYTE");
|
||||
break;
|
||||
case SWIG_TYPE_SHORT:
|
||||
Printf(s,"SHORT");
|
||||
break;
|
||||
case SWIG_TYPE_USHORT:
|
||||
Printf(s,"USHORT");
|
||||
break;
|
||||
case SWIG_TYPE_INT:
|
||||
Printf(s,"INT");
|
||||
break;
|
||||
case SWIG_TYPE_UINT:
|
||||
Printf(s,"UINT");
|
||||
break;
|
||||
case SWIG_TYPE_LONG:
|
||||
Printf(s,"LONG");
|
||||
break;
|
||||
case SWIG_TYPE_ULONG:
|
||||
Printf(s,"ULONG");
|
||||
break;
|
||||
case SWIG_TYPE_LONGLONG:
|
||||
Printf(s,"LONGLONG");
|
||||
break;
|
||||
case SWIG_TYPE_ULONGLONG:
|
||||
Printf(s,"ULONGLONG");
|
||||
break;
|
||||
case SWIG_TYPE_FLOAT:
|
||||
Printf(s,"FLOAT");
|
||||
break;
|
||||
case SWIG_TYPE_DOUBLE:
|
||||
Printf(s,"DOUBLE");
|
||||
break;
|
||||
case SWIG_TYPE_QUAD:
|
||||
Printf(s,"QUAD");
|
||||
break;
|
||||
case SWIG_TYPE_CHAR:
|
||||
Printf(s,"CHAR");
|
||||
break;
|
||||
case SWIG_TYPE_WCHAR:
|
||||
Printf(s,"WCHAR");
|
||||
break;
|
||||
case SWIG_TYPE_VOID:
|
||||
Printf(s,"VOID");
|
||||
break;
|
||||
case SWIG_TYPE_ENUM:
|
||||
Printf(s,"ENUM-%s", t->value);
|
||||
break;
|
||||
case SWIG_TYPE_VARARGS:
|
||||
Printf(s,"VARARGS");
|
||||
break;
|
||||
case SWIG_TYPE_TYPEDEF:
|
||||
Printf(s,"TYPEDEF-%s",t->value);
|
||||
break;
|
||||
case SWIG_TYPE_POINTER:
|
||||
Printf(s,"POINTER");
|
||||
break;
|
||||
case SWIG_TYPE_REFERENCE:
|
||||
Printf(s,"REFERENCE");
|
||||
break;
|
||||
case SWIG_TYPE_FUNCTION:
|
||||
Printf(s,"FUNCTION[%s]",t->value);
|
||||
break;
|
||||
case SWIG_TYPE_ARRAY:
|
||||
Printf(s,"ARRAY[%s]",t->value);
|
||||
break;
|
||||
case SWIG_TYPE_RECORD:
|
||||
Printf(s,"RECORD[%s]",t->value);
|
||||
break;
|
||||
case SWIG_TYPE_NAME:
|
||||
Printf(s,"NAME-%s",t->value);
|
||||
break;
|
||||
default:
|
||||
Printf(s,"UNKNOWN");
|
||||
break;
|
||||
}
|
||||
if (t->next) {
|
||||
s1 = SwigType_str(t->next);
|
||||
Printf(s,"(%s)",s1);
|
||||
Delete(s1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_len()
|
||||
*
|
||||
* Return the length of a type (the number of type constructors)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_len(DOH *tobj) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
if (t->next) return (1 + SwigType_len(t->next));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_getitem()
|
||||
*
|
||||
* Get the nth item from the type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOH *SwigType_getitem(DOH *tobj, int n) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
|
||||
if (n == 0) {
|
||||
return tobj;
|
||||
}
|
||||
if ((n < 0) && (t->prev)) return SwigType_getitem(t->prev,n+1);
|
||||
if ((n > 0) && (t->next)) return SwigType_getitem(t->next,n-1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_setitem()
|
||||
*
|
||||
* Change the nth item for this type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_setitem(DOH *tobj, int n, DOH *value) {
|
||||
SwigType *tv;
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
if (!SwigType_check(value)) return -1;
|
||||
|
||||
tv = (SwigType *) value;
|
||||
if (n == 0) {
|
||||
tv->prev = t->prev;
|
||||
{
|
||||
SwigType *tt = tv;
|
||||
while (tt->next) {
|
||||
tt = (SwigType *) tt->next;
|
||||
}
|
||||
tt->next = t->next;
|
||||
if (t->next) t->next->prev = tt;
|
||||
}
|
||||
if (t->prev) t->prev->next = tv;
|
||||
Incref(tv);
|
||||
Setscope(tv,t->scope);
|
||||
t->next = 0;
|
||||
t->prev = 0;
|
||||
Delete(t);
|
||||
return 0;
|
||||
}
|
||||
if ((n < 0) && (t->prev)) return SwigType_setitem(t->prev,n+1,value);
|
||||
if ((n > 0) && (t->next)) return SwigType_setitem(t->next,n-1,value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_delitem()
|
||||
*
|
||||
* Delete an item from the type constructor list
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_delitem(DOH *tobj, int n) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
|
||||
if (n == 0) {
|
||||
if (t->prev) t->prev->next = t->next;
|
||||
if (t->next) t->next->prev = t->prev;
|
||||
t->next = 0;
|
||||
t->prev = 0;
|
||||
Delete(t);
|
||||
return 0;
|
||||
}
|
||||
if ((n < 0) && (t->prev)) return SwigType_delitem(t->prev,n+1);
|
||||
if ((n > 0) && (t->next)) return SwigType_delitem(t->next,n-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_insert()
|
||||
*
|
||||
* Inserts a new constructor into the type.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
SwigType_insert(DOH *tobj, int pos, DOH *item) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
SwigType *tv, *tt, *tt1, *tp;
|
||||
int i, l;
|
||||
|
||||
if (!SwigType_check(item)) return -1;
|
||||
l = SwigType_len(t);
|
||||
if (pos == DOH_END) pos = l;
|
||||
if (pos < 0) pos = 0;
|
||||
if (pos > l) pos = l;
|
||||
tt = t;
|
||||
tp = t;
|
||||
for (i = 0; i < pos; i++) {
|
||||
tp = t;
|
||||
tt = t->next;
|
||||
}
|
||||
tv = (SwigType *) item;
|
||||
tv->prev = tp;
|
||||
if (tt)
|
||||
tv->next = tt;
|
||||
tt1 = tv;
|
||||
while (tt1->next) {
|
||||
tt1 = (SwigType *) tt1->next;
|
||||
}
|
||||
if (tt) {
|
||||
tt1->next = tt->next;
|
||||
if (tt->next) tt->next->prev = tt1;
|
||||
if (tt->prev) tt->prev->next = tv;
|
||||
} else {
|
||||
tp->next = tv;
|
||||
}
|
||||
Incref(tv);
|
||||
Setscope(t, t->scope);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void SwigType_scope()
|
||||
*
|
||||
* Set the scope on this object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SwigType_scope(DOH *tobj, int s) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
t->scope = s;
|
||||
if (t->next) SwigType_scope(t->next,s);
|
||||
}
|
||||
|
||||
static DohSequenceMethods SwigTypeSeqMethods = {
|
||||
SwigType_getitem,
|
||||
SwigType_setitem,
|
||||
SwigType_delitem,
|
||||
SwigType_insert,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
static DohObjInfo SwigTypeType = {
|
||||
"SwigType", /* objname */
|
||||
sizeof(SwigType), /* List size */
|
||||
SwigType_delete, /* doh_del */
|
||||
SwigType_copy, /* doh_copy */
|
||||
0, /* doh_clear */
|
||||
SwigType_scope, /* doh_scope */
|
||||
SwigType_str, /* doh_str */
|
||||
0, /* doh_data */
|
||||
0, /* doh_dump */
|
||||
0, /* doh_load */
|
||||
SwigType_len, /* doh_len */
|
||||
0, /* doh_hash */
|
||||
0, /* doh_cmp */
|
||||
0, /* doh_mapping */
|
||||
&SwigTypeSeqMethods, /* doh_sequence */
|
||||
0, /* doh_file */
|
||||
0, /* doh_string */
|
||||
0, /* doh_callable */
|
||||
0, /* doh_position */
|
||||
};
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_check()
|
||||
*
|
||||
* Return 1 if an object is a SwigType object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
int
|
||||
SwigType_check(DOH *tobj) {
|
||||
SwigType *t = (SwigType *) tobj;
|
||||
if (!t) return 0;
|
||||
if (!DohCheck(tobj)) return 0;
|
||||
if (t->objinfo != &SwigTypeType) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewSwigType()
|
||||
*
|
||||
* Create a new datatype
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOH *
|
||||
NewSwigType(int code, DOH *value) {
|
||||
SwigType *t;
|
||||
t = (SwigType *) DohObjMalloc(sizeof(SwigType));
|
||||
t->objinfo = &SwigTypeType;
|
||||
DohXInit(t);
|
||||
t->type = code;
|
||||
t->value = 0;
|
||||
if (value) {
|
||||
if (!DohCheck(value)) t->value = NewString(value);
|
||||
else {
|
||||
t->value = value;
|
||||
Incref(value);
|
||||
}
|
||||
}
|
||||
t->next = 0;
|
||||
t->prev = 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue