Removed dependency on the Hash object
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@290 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b1f0a87a70
commit
b363cd0a82
10 changed files with 110 additions and 101 deletions
|
|
@ -98,8 +98,8 @@ char *JAVA::SwigTcToJavaType(DataType *t, int ret, int inShadow) {
|
||||||
case T_SCHAR: return "byte []";
|
case T_SCHAR: return "byte []";
|
||||||
case T_BOOL: return "boolean []";
|
case T_BOOL: return "boolean []";
|
||||||
case T_VOID:
|
case T_VOID:
|
||||||
case T_USER: if(inShadow && shadow_classes.lookup(t->name))
|
case T_USER: if(inShadow && Getattr(shadow_classes,t->name))
|
||||||
return (char *)shadow_classes.lookup(t->name);
|
return GetChar(shadow_classes,t->name);
|
||||||
else return "long";
|
else return "long";
|
||||||
}
|
}
|
||||||
} else if(t->is_pointer > 1) {
|
} else if(t->is_pointer > 1) {
|
||||||
|
|
@ -170,8 +170,8 @@ char *JAVA::JavaMethodSignature(DataType *t, int ret, int inShadow) {
|
||||||
case T_SCHAR: return "[B";
|
case T_SCHAR: return "[B";
|
||||||
case T_BOOL: return "[Z";
|
case T_BOOL: return "[Z";
|
||||||
case T_VOID:
|
case T_VOID:
|
||||||
case T_USER: if(inShadow && shadow_classes.lookup(t->name))
|
case T_USER: if(inShadow && Getattr(shadow_classes,t->name))
|
||||||
return (char *)shadow_classes.lookup(t->name);
|
return GetChar(shadow_classes,t->name);
|
||||||
else return "J";
|
else return "J";
|
||||||
}
|
}
|
||||||
} else if(t->is_pointer > 1) {
|
} else if(t->is_pointer > 1) {
|
||||||
|
|
@ -912,15 +912,15 @@ void JAVA::add_typedef(DataType *t, char *name) {
|
||||||
|
|
||||||
if (t->is_pointer > 1) return;
|
if (t->is_pointer > 1) return;
|
||||||
|
|
||||||
if(shadow_classes.lookup(name)) return; // Already added
|
if(Getattr(shadow_classes,name)) return; // Already added
|
||||||
|
|
||||||
// Now look up the datatype in our shadow class hash table
|
// Now look up the datatype in our shadow class hash table
|
||||||
|
|
||||||
if (shadow_classes.lookup(t->name)) {
|
if (Getattr(shadow_classes,t->name)) {
|
||||||
|
|
||||||
// Yep. This datatype is in the hash
|
// Yep. This datatype is in the hash
|
||||||
// Put this types 'new' name into the hash
|
// Put this types 'new' name into the hash
|
||||||
shadow_classes.add(name,copy_string((char *) shadow_classes.lookup(t->name)));
|
Setattr(shadow_classes,name,GetChar(shadow_classes,t->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -939,10 +939,10 @@ void JAVA::cpp_open_class(char *classname, char *rename, char *ctype, int strip)
|
||||||
SWIG_exit(1);
|
SWIG_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
shadow_classes.add(classname, shadow_classname);
|
Setattr(shadow_classes,classname, shadow_classname);
|
||||||
if(ctype && strcmp(ctype, "struct") == 0) {
|
if(ctype && strcmp(ctype, "struct") == 0) {
|
||||||
sprintf(bigbuf, "struct %s", classname);
|
sprintf(bigbuf, "struct %s", classname);
|
||||||
shadow_classes.add(copy_string(bigbuf), shadow_classname);
|
Setattr(shadow_classes, bigbuf, shadow_classname);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(bigbuf, "%s.java", shadow_classname);
|
sprintf(bigbuf, "%s.java", shadow_classname);
|
||||||
|
|
@ -1020,7 +1020,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
if(!javarettype) javarettype = SwigTcToJavaType(t, 1, 0);
|
if(!javarettype) javarettype = SwigTcToJavaType(t, 1, 0);
|
||||||
char *shadowrettype = JavaTypeFromTypemap("jstype", typemap_lang, t, iname);
|
char *shadowrettype = JavaTypeFromTypemap("jstype", typemap_lang, t, iname);
|
||||||
if(!shadowrettype && t->type == T_USER) {
|
if(!shadowrettype && t->type == T_USER) {
|
||||||
shadowrettype = (char *)shadow_classes.lookup(t->name);
|
shadowrettype = GetChar(shadow_classes,t->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f_shadow, " public %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
fprintf(f_shadow, " public %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
||||||
|
|
@ -1045,7 +1045,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
arg << i;
|
arg << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p->t->type == T_USER && shadow_classes.lookup(p->t->name)) {
|
if(p->t->type == T_USER && Getattr(shadow_classes,p->t->name)) {
|
||||||
nativecall << ", " << arg << "._self";
|
nativecall << ", " << arg << "._self";
|
||||||
} else nativecall << ", " << arg;
|
} else nativecall << ", " << arg;
|
||||||
|
|
||||||
|
|
@ -1054,7 +1054,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
|
|
||||||
char *jstype = JavaTypeFromTypemap("jstype", typemap_lang, p->t, p->name);
|
char *jstype = JavaTypeFromTypemap("jstype", typemap_lang, p->t, p->name);
|
||||||
if(!jstype && p->t->type == T_USER) {
|
if(!jstype && p->t->type == T_USER) {
|
||||||
jstype = (char *)shadow_classes.lookup(p->t->name);
|
jstype = GetChar(shadow_classes,p->t->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to java function header
|
// Add to java function header
|
||||||
|
|
@ -1088,7 +1088,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
if(!javarettype) javarettype = SwigTcToJavaType(t, 1, 0);
|
if(!javarettype) javarettype = SwigTcToJavaType(t, 1, 0);
|
||||||
char *shadowrettype = JavaTypeFromTypemap("jstype", typemap_lang, t, iname);
|
char *shadowrettype = JavaTypeFromTypemap("jstype", typemap_lang, t, iname);
|
||||||
if(!shadowrettype && t->type == T_USER) {
|
if(!shadowrettype && t->type == T_USER) {
|
||||||
shadowrettype = (char *)shadow_classes.lookup(t->name);
|
shadowrettype = GetChar(shadow_classes,t->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f_shadow, " public static %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
fprintf(f_shadow, " public static %s %s(", (shadowrettype) ? shadowrettype : javarettype, iname);
|
||||||
|
|
@ -1116,7 +1116,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
|
|
||||||
if(gencomma) nativecall << ", ";
|
if(gencomma) nativecall << ", ";
|
||||||
|
|
||||||
if(p->t->type == T_USER && shadow_classes.lookup(p->t->name)) {
|
if(p->t->type == T_USER && Getattr(shadow_classes,p->t->name)) {
|
||||||
nativecall << arg << "._self";
|
nativecall << arg << "._self";
|
||||||
} else nativecall << arg;
|
} else nativecall << arg;
|
||||||
|
|
||||||
|
|
@ -1127,7 +1127,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
|
|
||||||
char *jstype = JavaTypeFromTypemap("jstype", typemap_lang, p->t, p->name);
|
char *jstype = JavaTypeFromTypemap("jstype", typemap_lang, p->t, p->name);
|
||||||
if(!jstype && p->t->type == T_USER) {
|
if(!jstype && p->t->type == T_USER) {
|
||||||
jstype = (char *)shadow_classes.lookup(p->t->name);
|
jstype = GetChar(shadow_classes, p->t->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to java function header
|
// Add to java function header
|
||||||
|
|
@ -1188,7 +1188,7 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
// Add to java function header
|
// Add to java function header
|
||||||
fprintf(f_shadow, "%s %s", (jstype) ? jstype : jtype, (char *) arg);
|
fprintf(f_shadow, "%s %s", (jstype) ? jstype : jtype, (char *) arg);
|
||||||
|
|
||||||
if(p->t->type == T_USER && shadow_classes.lookup(p->t->name)) {
|
if(p->t->type == T_USER && Getattr(shadow_classes,p->t->name)) {
|
||||||
nativecall << arg << "._self";
|
nativecall << arg << "._self";
|
||||||
} else nativecall << arg;
|
} else nativecall << arg;
|
||||||
|
|
||||||
|
|
@ -1237,10 +1237,10 @@ void JAVA::cpp_class_decl(char *name, char *rename, char *type) {
|
||||||
|
|
||||||
char *realname = (rename) ? rename : name;
|
char *realname = (rename) ? rename : name;
|
||||||
|
|
||||||
shadow_classes.add(name, copy_string(realname));
|
Setattr(shadow_classes,name, realname);
|
||||||
if(type && strcmp(type, "struct") == 0) {
|
if(type && strcmp(type, "struct") == 0) {
|
||||||
sprintf(bigbuf, "struct %s", name);
|
sprintf(bigbuf, "struct %s", name);
|
||||||
shadow_classes.add(copy_string(bigbuf), rename);
|
Setattr(shadow_classes, bigbuf, rename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ private:
|
||||||
FILE *f_java;
|
FILE *f_java;
|
||||||
FILE *f_shadow;
|
FILE *f_shadow;
|
||||||
int shadow;
|
int shadow;
|
||||||
Hash shadow_classes;
|
DOH *shadow_classes;
|
||||||
String shadow_classdef;
|
String shadow_classdef;
|
||||||
char *shadow_name;
|
char *shadow_name;
|
||||||
char *shadow_baseclass;
|
char *shadow_baseclass;
|
||||||
|
|
@ -44,6 +44,7 @@ public :
|
||||||
jnic = -1;
|
jnic = -1;
|
||||||
useRegisterNatives=0;
|
useRegisterNatives=0;
|
||||||
finalize=0;
|
finalize=0;
|
||||||
|
shadow_classes = NewHash();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Virtual functions required by the SWIG parser
|
// Virtual functions required by the SWIG parser
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
/* Include the proper SWIG core header */
|
/* Include the proper SWIG core header */
|
||||||
/* Feel free to change this when compiling against experiment cores */
|
/* Feel free to change this when compiling against experiment cores */
|
||||||
|
#include "doh.h"
|
||||||
#include "swig11.h"
|
#include "swig11.h"
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,6 @@ static char *import_file = 0;
|
||||||
static char *smodule = 0;
|
static char *smodule = 0;
|
||||||
static int compat = 0;
|
static int compat = 0;
|
||||||
|
|
||||||
static Hash symbols;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// PERL5::parse_args(int argc, char *argv[])
|
// PERL5::parse_args(int argc, char *argv[])
|
||||||
//
|
//
|
||||||
|
|
@ -599,10 +597,10 @@ PERL5::type_mangle(DataType *t) {
|
||||||
|
|
||||||
// Check to see if we've blessed this datatype
|
// Check to see if we've blessed this datatype
|
||||||
|
|
||||||
if ((classes.lookup(t->name)) && (t->is_pointer <= 1)) {
|
if ((Getattr(classes,t->name)) && (t->is_pointer <= 1)) {
|
||||||
|
|
||||||
// This is a blessed class. Return just the type-name
|
// This is a blessed class. Return just the type-name
|
||||||
strcpy(result,(char *) classes.lookup(t->name));
|
strcpy(result, GetChar(classes,t->name));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1021,7 +1019,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
if ((tm = typemap_lookup("perl5in","perl5",p->t,"",sourceNtarget,sourceNtarget)))
|
if ((tm = typemap_lookup("perl5in","perl5",p->t,"",sourceNtarget,sourceNtarget)))
|
||||||
func << tm << "\n";
|
func << tm << "\n";
|
||||||
else if ((classes.lookup(p->t->name)) && (p->t->is_pointer <= 1)) {
|
else if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {
|
||||||
if (i >= (pcount - numopt))
|
if (i >= (pcount - numopt))
|
||||||
func << tab4 << "if (scalar(@args) >= " << i << ") {\n" << tab4;
|
func << tab4 << "if (scalar(@args) >= " << i << ") {\n" << tab4;
|
||||||
|
|
||||||
|
|
@ -1048,7 +1046,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
func << tm << "\n"
|
func << tm << "\n"
|
||||||
<< tab4 <<"return $result;\n"
|
<< tab4 <<"return $result;\n"
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
} else if ((classes.lookup(d->name)) && (d->is_pointer <=1)) {
|
} else if ((Getattr(classes,d->name)) && (d->is_pointer <=1)) {
|
||||||
|
|
||||||
func << tab4 << "return undef if (!defined($result));\n";
|
func << tab4 << "return undef if (!defined($result));\n";
|
||||||
|
|
||||||
|
|
@ -1056,16 +1054,13 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// into our local hash table
|
// into our local hash table
|
||||||
|
|
||||||
if ((d->is_pointer == 0) || ((d->is_pointer == 1) && NewObject)) {
|
if ((d->is_pointer == 0) || ((d->is_pointer == 1) && NewObject)) {
|
||||||
func << tab4 << "$" << (char *) classes.lookup(d->name) << "::OWNER{$result} = 1;\n";
|
func << tab4 << "$" << GetChar(classes,d->name) << "::OWNER{$result} = 1;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're returning a Perl "object" of some kind. Turn it into
|
// We're returning a Perl "object" of some kind. Turn it into
|
||||||
// a tied hash
|
// a tied hash
|
||||||
|
|
||||||
func << tab4 << "my %resulthash;\n"
|
func << tab4 << "my %resulthash;\n"
|
||||||
/* << tab4 << "tie %resulthash, \"" << (char *) classes.lookup(d->name) << "\", $result;\n"
|
|
||||||
<< tab4 << "return bless \\%resulthash, \"" << (char *) classes.lookup(d->name) << "\";\n"
|
|
||||||
*/
|
|
||||||
<< tab4 << "tie %resulthash, ref($result), $result;\n"
|
<< tab4 << "tie %resulthash, ref($result), $result;\n"
|
||||||
<< tab4 << "return bless \\%resulthash, ref($result);\n"
|
<< tab4 << "return bless \\%resulthash, ref($result);\n"
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
|
|
@ -1275,12 +1270,12 @@ void PERL5::link_variable(char *name, char *iname, DataType *t)
|
||||||
// 2. Otherwise, just hack Perl's symbol table
|
// 2. Otherwise, just hack Perl's symbol table
|
||||||
|
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
if ((classes.lookup(t->name)) && (t->is_pointer <= 1)) {
|
if ((Getattr(classes,t->name)) && (t->is_pointer <= 1)) {
|
||||||
var_stubs << "\nmy %__" << iname << "_hash;\n"
|
var_stubs << "\nmy %__" << iname << "_hash;\n"
|
||||||
<< "tie %__" << iname << "_hash,\"" << (char *) classes.lookup(t->name) << "\", $"
|
<< "tie %__" << iname << "_hash,\"" << GetChar(classes,t->name) << "\", $"
|
||||||
<< package << "::" << iname << ";\n"
|
<< package << "::" << iname << ";\n"
|
||||||
<< "$" << iname << "= \\%__" << iname << "_hash;\n"
|
<< "$" << iname << "= \\%__" << iname << "_hash;\n"
|
||||||
<< "bless $" << iname << ", " << (char *) classes.lookup(t->name) << ";\n";
|
<< "bless $" << iname << ", " << GetChar(classes,t->name) << ";\n";
|
||||||
} else {
|
} else {
|
||||||
var_stubs << "*" << iname << " = *" << package << "::" << iname << ";\n";
|
var_stubs << "*" << iname << " = *" << package << "::" << iname << ";\n";
|
||||||
}
|
}
|
||||||
|
|
@ -1420,12 +1415,12 @@ PERL5::declare_const(char *name, char *, DataType *type, char *value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
if ((classes.lookup(type->name)) && (type->is_pointer <= 1)) {
|
if ((Getattr(classes,type->name)) && (type->is_pointer <= 1)) {
|
||||||
var_stubs << "\nmy %__" << name << "_hash;\n"
|
var_stubs << "\nmy %__" << name << "_hash;\n"
|
||||||
<< "tie %__" << name << "_hash,\"" << (char *) classes.lookup(type->name) << "\", $"
|
<< "tie %__" << name << "_hash,\"" << GetChar(classes,type->name) << "\", $"
|
||||||
<< package << "::" << name << ";\n"
|
<< package << "::" << name << ";\n"
|
||||||
<< "$" << name << "= \\%__" << name << "_hash;\n"
|
<< "$" << name << "= \\%__" << name << "_hash;\n"
|
||||||
<< "bless $" << name << ", " << (char *) classes.lookup(type->name) << ";\n";
|
<< "bless $" << name << ", " << GetChar(classes,type->name) << ";\n";
|
||||||
} else {
|
} else {
|
||||||
var_stubs << "*" << name << " = *" << package << "::" << name << ";\n";
|
var_stubs << "*" << name << " = *" << package << "::" << name << ";\n";
|
||||||
}
|
}
|
||||||
|
|
@ -1633,12 +1628,11 @@ void PERL5::cpp_open_class(char *classname, char *rname, char *ctype, int strip)
|
||||||
// Add some symbols to the hash tables
|
// Add some symbols to the hash tables
|
||||||
|
|
||||||
// classes.add(real_classname,copy_string(class_name)); /* Map original classname to class */
|
// classes.add(real_classname,copy_string(class_name)); /* Map original classname to class */
|
||||||
classes.add(real_classname,copy_string(fullclassname)); /* Map original classname to class */
|
Setattr(classes,real_classname,fullclassname);
|
||||||
|
|
||||||
// Add full name of datatype to the hash table just in case the user uses it
|
// Add full name of datatype to the hash table just in case the user uses it
|
||||||
|
|
||||||
sprintf(temp,"%s %s", class_type, fullclassname.get());
|
sprintf(temp,"%s %s", class_type, fullclassname.get());
|
||||||
// classes.add(temp,copy_string(class_name)); /* Map full classname to classs */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1793,9 +1787,10 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
realname = iname;
|
realname = iname;
|
||||||
|
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(),0)) == -1) {
|
if (Getattr(symbols,cname.get())) {
|
||||||
return; // Forget it, we saw this function already
|
return; // Forget it, we saw this already
|
||||||
}
|
}
|
||||||
|
Setattr(symbols,cname.get(),cname.get());
|
||||||
|
|
||||||
func << "sub " << realname << " {\n"
|
func << "sub " << realname << " {\n"
|
||||||
<< tab4 << "my @args = @_;\n"
|
<< tab4 << "my @args = @_;\n"
|
||||||
|
|
@ -1817,7 +1812,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
if ((tm = typemap_lookup("perl5in","perl5",p->t,"",sourceNtarget,sourceNtarget)))
|
if ((tm = typemap_lookup("perl5in","perl5",p->t,"",sourceNtarget,sourceNtarget)))
|
||||||
func << tm << "\n";
|
func << tm << "\n";
|
||||||
// Look up the datatype name here
|
// Look up the datatype name here
|
||||||
else if ((classes.lookup(p->t->name)) && (p->t->is_pointer <= 1)) {
|
else if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {
|
||||||
// Yep. This smells alot like an object, patch up the arguments
|
// Yep. This smells alot like an object, patch up the arguments
|
||||||
|
|
||||||
if (i >= (pcount - numopt))
|
if (i >= (pcount - numopt))
|
||||||
|
|
@ -1847,7 +1842,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
func << tm << "\n"
|
func << tm << "\n"
|
||||||
<< tab4 <<"return $result;\n"
|
<< tab4 <<"return $result;\n"
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
} else if ((classes.lookup(t->name)) && (t->is_pointer <=1)) {
|
} else if ((Getattr(classes,t->name)) && (t->is_pointer <=1)) {
|
||||||
|
|
||||||
func << tab4 << "return undef if (!defined($result));\n";
|
func << tab4 << "return undef if (!defined($result));\n";
|
||||||
|
|
||||||
|
|
@ -1855,15 +1850,15 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
// into our local hash table
|
// into our local hash table
|
||||||
|
|
||||||
if ((t->is_pointer == 0) || ((t->is_pointer == 1) && NewObject)) {
|
if ((t->is_pointer == 0) || ((t->is_pointer == 1) && NewObject)) {
|
||||||
func << tab4 << "$" << (char *) classes.lookup(t->name) << "::OWNER{$result} = 1;\n";
|
func << tab4 << "$" << GetChar(classes,t->name) << "::OWNER{$result} = 1;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're returning a Perl "object" of some kind. Turn it into
|
// We're returning a Perl "object" of some kind. Turn it into
|
||||||
// a tied hash
|
// a tied hash
|
||||||
|
|
||||||
func << tab4 << "my %resulthash;\n"
|
func << tab4 << "my %resulthash;\n"
|
||||||
/* << tab4 << "tie %resulthash, \"" << (char *) classes.lookup(t->name) << "\", $result;\n"
|
/* << tab4 << "tie %resulthash, \"" << GetChar(classes,t->name) << "\", $result;\n"
|
||||||
<< tab4 << "return bless \\%resulthash, \"" << (char *) classes.lookup(t->name) << "\";\n" */
|
<< tab4 << "return bless \\%resulthash, \"" << GetChar(classes,t->name) << "\";\n" */
|
||||||
<< tab4 << "tie %resulthash, ref($result), $result;\n"
|
<< tab4 << "tie %resulthash, ref($result), $result;\n"
|
||||||
<< tab4 << "return bless \\%resulthash, ref($result);\n"
|
<< tab4 << "return bless \\%resulthash, ref($result);\n"
|
||||||
|
|
||||||
|
|
@ -1917,9 +1912,10 @@ void PERL5::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
|
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(),0)) == -1) {
|
if (Getattr(symbols,cname.get())) {
|
||||||
return; // Forget it, we saw this already
|
return; // Forget it, we saw this already
|
||||||
}
|
}
|
||||||
|
Setattr(symbols,cname.get(),cname.get());
|
||||||
|
|
||||||
// Store name of key for future reference
|
// Store name of key for future reference
|
||||||
|
|
||||||
|
|
@ -1927,12 +1923,12 @@ void PERL5::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
|
|
||||||
// Now we need to generate a little Perl code for this
|
// Now we need to generate a little Perl code for this
|
||||||
|
|
||||||
if ((classes.lookup(t->name)) && (t->is_pointer <= 1)) {
|
if ((Getattr(classes,t->name)) && (t->is_pointer <= 1)) {
|
||||||
|
|
||||||
// This is a Perl object that we have already seen. Add an
|
// This is a Perl object that we have already seen. Add an
|
||||||
// entry to the members list
|
// entry to the members list
|
||||||
|
|
||||||
*blessedmembers << tab4 << realname << " => '" << (hidden ? realpackage : "") << (hidden ? "::" : "") << (char *) classes.lookup(t->name) << "',\n";
|
*blessedmembers << tab4 << realname << " => '" << (hidden ? realpackage : "") << (hidden ? "::" : "") << GetChar(classes,t->name) << "',\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1970,9 +1966,10 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(),0)) == -1) {
|
if (Getattr(symbols,cname.get())) {
|
||||||
return; // Forget it, we saw this already
|
return; // Forget it, we saw this already
|
||||||
}
|
}
|
||||||
|
Setattr(symbols,cname.get(), cname.get());
|
||||||
if ((strcmp(realname,class_name) == 0) || ((!iname) && (ObjCClass)) ){
|
if ((strcmp(realname,class_name) == 0) || ((!iname) && (ObjCClass)) ){
|
||||||
|
|
||||||
// Emit a blessed constructor
|
// Emit a blessed constructor
|
||||||
|
|
@ -2001,7 +1998,7 @@ void PERL5::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
|
|
||||||
// Look up the datatype name here
|
// Look up the datatype name here
|
||||||
|
|
||||||
if ((classes.lookup(p->t->name)) && (p->t->is_pointer <= 1)) {
|
if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {
|
||||||
|
|
||||||
// Yep. This smells alot like an object, patch up the arguments
|
// Yep. This smells alot like an object, patch up the arguments
|
||||||
*pcode << tab4 << "$args[" << i << "] = tied(%{$args[" << i << "]});\n";
|
*pcode << tab4 << "$args[" << i << "] = tied(%{$args[" << i << "]});\n";
|
||||||
|
|
@ -2101,7 +2098,7 @@ void PERL5::cpp_inherit(char **baseclass, int) {
|
||||||
base_class = new String;
|
base_class = new String;
|
||||||
while (baseclass[i]) {
|
while (baseclass[i]) {
|
||||||
// See if this is a class we know about
|
// See if this is a class we know about
|
||||||
bc = (char *) classes.lookup(baseclass[i]);
|
bc = GetChar(classes,baseclass[i]);
|
||||||
if (bc) {
|
if (bc) {
|
||||||
if (have_first) *base_class << " ";
|
if (have_first) *base_class << " ";
|
||||||
*base_class << bc;
|
*base_class << bc;
|
||||||
|
|
@ -2139,9 +2136,10 @@ void PERL5::cpp_declare_const(char *name, char *iname, DataType *type, char *val
|
||||||
realname = iname;
|
realname = iname;
|
||||||
|
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(),0)) == -1) {
|
if (Getattr(symbols, cname.get())) {
|
||||||
return; // Forget it, we saw this already
|
return; // Forget it, we saw this already
|
||||||
}
|
}
|
||||||
|
Setattr(symbols, cname.get(),cname.get());
|
||||||
|
|
||||||
// Create a symbol table entry for it
|
// Create a symbol table entry for it
|
||||||
*pcode << "*" << realname << " = *" << package << "::" << name_member(realname,class_name) << ";\n";
|
*pcode << "*" << realname << " = *" << package << "::" << name_member(realname,class_name) << ";\n";
|
||||||
|
|
@ -2159,11 +2157,11 @@ void PERL5::cpp_declare_const(char *name, char *iname, DataType *type, char *val
|
||||||
void PERL5::cpp_class_decl(char *name, char *rename, char *type) {
|
void PERL5::cpp_class_decl(char *name, char *rename, char *type) {
|
||||||
char temp[256];
|
char temp[256];
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
classes.add(name,copy_string(rename));
|
Setattr(classes, name, rename);
|
||||||
// Add full name of datatype to the hash table
|
// Add full name of datatype to the hash table
|
||||||
if (strlen(type) > 0) {
|
if (strlen(type) > 0) {
|
||||||
sprintf(temp,"%s %s", type, name);
|
sprintf(temp,"%s %s", type, name);
|
||||||
classes.add(temp,copy_string(rename));
|
Setattr(classes,temp,rename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2190,17 +2188,17 @@ void PERL5::add_typedef(DataType *t, char *name) {
|
||||||
|
|
||||||
if (t->is_pointer > 1) return;
|
if (t->is_pointer > 1) return;
|
||||||
|
|
||||||
if (classes.lookup(name)) return; // Already added
|
if (Getattr(classes,name)) return; // Already added
|
||||||
|
|
||||||
// Now look up the datatype in our shadow class hash table
|
// Now look up the datatype in our shadow class hash table
|
||||||
|
|
||||||
if (classes.lookup(t->name)) {
|
if (Getattr(classes,t->name)) {
|
||||||
|
|
||||||
// Yep. This datatype is in the hash
|
// Yep. This datatype is in the hash
|
||||||
|
|
||||||
// Put this types 'new' name into the hash
|
// Put this types 'new' name into the hash
|
||||||
|
|
||||||
classes.add(name,copy_string((char *) classes.lookup(t->name)));
|
Setattr(classes,name,GetChar(classes,t->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ private:
|
||||||
|
|
||||||
int blessed; // Enable object oriented features
|
int blessed; // Enable object oriented features
|
||||||
int hidden; // Every symbol hidden in <hide> package name
|
int hidden; // Every symbol hidden in <hide> package name
|
||||||
Hash classes; // A hash table for storing the classes we've seen so far
|
DOH *classes; // A hash table for storing the classes we've seen so far
|
||||||
|
DOH *symbols;
|
||||||
int have_constructor;
|
int have_constructor;
|
||||||
int have_destructor;
|
int have_destructor;
|
||||||
int have_data_members;
|
int have_data_members;
|
||||||
|
|
@ -73,6 +74,8 @@ public :
|
||||||
hidden = 0;
|
hidden = 0;
|
||||||
alt_header = 0;
|
alt_header = 0;
|
||||||
member_func = 0;
|
member_func = 0;
|
||||||
|
classes = NewHash();
|
||||||
|
symbols = NewHash();
|
||||||
};
|
};
|
||||||
virtual void parse_args(int, char *argv[]);
|
virtual void parse_args(int, char *argv[]);
|
||||||
virtual void parse();
|
virtual void parse();
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ static String base_getattr;
|
||||||
static String base_setattr;
|
static String base_setattr;
|
||||||
static int class_renamed = 0;
|
static int class_renamed = 0;
|
||||||
|
|
||||||
static Hash symbols;
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// PYTHON::cpp_open_class(char *classname, char *rname, char *ctype, int strip)
|
// PYTHON::cpp_open_class(char *classname, char *rname, char *ctype, int strip)
|
||||||
//
|
//
|
||||||
|
|
@ -101,10 +99,10 @@ void PYTHON::cpp_open_class(char *classname, char *rname, char *ctype, int strip
|
||||||
class_type = copy_string(ctype);
|
class_type = copy_string(ctype);
|
||||||
|
|
||||||
// Build up the hash table
|
// Build up the hash table
|
||||||
hash.add(real_classname,copy_string(class_name));
|
Setattr(hash,real_classname,class_name);
|
||||||
|
|
||||||
sprintf(temp,"%s %s", class_type, real_classname);
|
sprintf(temp,"%s %s", class_type, real_classname);
|
||||||
hash.add(temp,copy_string(class_name));
|
Setattr(hash,temp,class_name);
|
||||||
|
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
*setattr << tab4 << "def __setattr__(self,name,value):\n"
|
*setattr << tab4 << "def __setattr__(self,name,value):\n"
|
||||||
|
|
@ -153,15 +151,16 @@ void PYTHON::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
|
|
||||||
// Check to see if we've already seen this
|
// Check to see if we've already seen this
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(),0)) == -1) {
|
if (Getattr(symbols,cname.get())) {
|
||||||
return; // Forget it, already saw it
|
return; // Forget it, already saw it
|
||||||
}
|
}
|
||||||
|
Setattr(symbols,cname.get(),cname.get());
|
||||||
|
|
||||||
if (strcmp(realname,"__repr__") == 0)
|
if (strcmp(realname,"__repr__") == 0)
|
||||||
have_repr = 1;
|
have_repr = 1;
|
||||||
|
|
||||||
|
|
||||||
if (!((hash.lookup(t->name)) && (t->is_pointer <=1)) && !noopt) {
|
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";
|
*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"; */
|
/* *pyclass << tab4 << realname << " = " << module << ".__shadow__." << name_member(realname,class_name) << "\n"; */
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -179,12 +178,12 @@ void PYTHON::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l)
|
||||||
*pyclass << tab8 << "val = apply(" << module << "." << name_member(realname,class_name) << ",args)\n";
|
*pyclass << tab8 << "val = apply(" << module << "." << name_member(realname,class_name) << ",args)\n";
|
||||||
|
|
||||||
// Check to see if the return type is an object
|
// Check to see if the return type is an object
|
||||||
if ((hash.lookup(t->name)) && (t->is_pointer <= 1)) {
|
if ((Getattr(hash,t->name)) && (t->is_pointer <= 1)) {
|
||||||
if (!typemap_check("out",typemap_lang,t,name_member(realname,class_name))) {
|
if (!typemap_check("out",typemap_lang,t,name_member(realname,class_name))) {
|
||||||
if (!have_output) {
|
if (!have_output) {
|
||||||
*pyclass << tab8 << "if val: val = " << (char *) hash.lookup(t->name) << "Ptr(val) ";
|
*pyclass << tab8 << "if val: val = " << GetChar(hash,t->name) << "Ptr(val) ";
|
||||||
if (((hash.lookup(t->name)) && (t->is_pointer < 1)) ||
|
if (((Getattr(hash,t->name)) && (t->is_pointer < 1)) ||
|
||||||
((hash.lookup(t->name)) && (t->is_pointer == 1) && NewObject))
|
((Getattr(hash,t->name)) && (t->is_pointer == 1) && NewObject))
|
||||||
*pyclass << "; val.thisown = 1\n";
|
*pyclass << "; val.thisown = 1\n";
|
||||||
else
|
else
|
||||||
*pyclass << "\n";
|
*pyclass << "\n";
|
||||||
|
|
@ -230,9 +229,10 @@ void PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) {
|
||||||
|
|
||||||
// Check to see if we've already seen this
|
// Check to see if we've already seen this
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(), 0)) == -1) {
|
if (Getattr(symbols,cname.get())) {
|
||||||
return; // Forget it, already seen it
|
return; // Forget it, already seen it
|
||||||
}
|
}
|
||||||
|
Setattr(symbols,cname.get(),cname.get());
|
||||||
|
|
||||||
if (!have_constructor) {
|
if (!have_constructor) {
|
||||||
|
|
||||||
|
|
@ -398,7 +398,7 @@ void PYTHON::cpp_inherit(char **baseclass,int) {
|
||||||
// Now tell the Python module that we're inheriting from a base class
|
// Now tell the Python module that we're inheriting from a base class
|
||||||
|
|
||||||
while (baseclass[i]) {
|
while (baseclass[i]) {
|
||||||
bc = (char *) hash.lookup(baseclass[i]);
|
bc = GetChar(hash,baseclass[i]);
|
||||||
if (bc) {
|
if (bc) {
|
||||||
if (first_base) *base_class << ",";
|
if (first_base) *base_class << ",";
|
||||||
*base_class << bc;
|
*base_class << bc;
|
||||||
|
|
@ -439,13 +439,14 @@ void PYTHON::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
// Check to see if we've already seen this
|
// Check to see if we've already seen this
|
||||||
|
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(), 0)) == -1) {
|
if (Getattr(symbols,cname.get())) {
|
||||||
return; // Forget it, already seen it
|
return; // Forget it, already seen it
|
||||||
}
|
}
|
||||||
|
Setattr(symbols,cname.get(),cname.get());
|
||||||
|
|
||||||
// Figure out if we've seen this datatype before
|
// Figure out if we've seen this datatype before
|
||||||
|
|
||||||
if ((hash.lookup(t->name)) && (t->is_pointer <= 1)) inhash = 1;
|
if ((Getattr(hash,t->name)) && (t->is_pointer <= 1)) inhash = 1;
|
||||||
|
|
||||||
// Now write some code to set the variable
|
// Now write some code to set the variable
|
||||||
*csetattr << tab8 << "\"" << realname << "\" : " << module << "." << name_set(name_member(realname,class_name)) << ",\n";
|
*csetattr << tab8 << "\"" << realname << "\" : " << module << "." << name_set(name_member(realname,class_name)) << ",\n";
|
||||||
|
|
@ -456,7 +457,7 @@ void PYTHON::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
}
|
}
|
||||||
// Write some code to get the variable
|
// Write some code to get the variable
|
||||||
if (inhash) {
|
if (inhash) {
|
||||||
*cgetattr << tab8 << "\"" << realname << "\" : lambda x : " << (char *) hash.lookup(t->name) << "Ptr(" << module << "." << name_get(name_member(realname,class_name)) << "(x)),\n";
|
*cgetattr << tab8 << "\"" << realname << "\" : lambda x : " << GetChar(hash,t->name) << "Ptr(" << module << "." << name_get(name_member(realname,class_name)) << "(x)),\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*cgetattr << tab8 << "\"" << realname << "\" : " << module << "." << name_get(name_member(realname,class_name)) << ",\n";
|
*cgetattr << tab8 << "\"" << realname << "\" : " << module << "." << name_get(name_member(realname,class_name)) << ",\n";
|
||||||
|
|
@ -488,9 +489,10 @@ void PYTHON::cpp_declare_const(char *name, char *iname, DataType *type, char *va
|
||||||
// Check to see if we've already seen this
|
// Check to see if we've already seen this
|
||||||
|
|
||||||
cname << class_name << "::" << realname;
|
cname << class_name << "::" << realname;
|
||||||
if ((symbols.add(cname.get(), 0)) == -1) {
|
if (Getattr(symbols,cname.get())) {
|
||||||
return; // Forget it, already seen it
|
return; // Forget it, already seen it
|
||||||
}
|
}
|
||||||
|
Setattr(symbols,cname.get(),cname.get());
|
||||||
|
|
||||||
*cinit << tab4 << realname << " = " << module << "." << name_member(realname,class_name) << "\n";
|
*cinit << tab4 << realname << " = " << module << "." << name_member(realname,class_name) << "\n";
|
||||||
}
|
}
|
||||||
|
|
@ -518,17 +520,17 @@ void PYTHON::add_typedef(DataType *t, char *name) {
|
||||||
|
|
||||||
if (t->is_pointer > 1) return;
|
if (t->is_pointer > 1) return;
|
||||||
|
|
||||||
if (hash.lookup(name)) return; // Already added
|
if (Getattr(hash,name)) return; // Already added
|
||||||
|
|
||||||
|
|
||||||
// Now look up the datatype in our shadow class hash table
|
// Now look up the datatype in our shadow class hash table
|
||||||
|
|
||||||
if (hash.lookup(t->name)) {
|
if (Getattr(hash,t->name)) {
|
||||||
|
|
||||||
// Yep. This datatype is in the hash
|
// Yep. This datatype is in the hash
|
||||||
|
|
||||||
// Put this types 'new' name into the hash
|
// Put this types 'new' name into the hash
|
||||||
|
|
||||||
hash.add(name,copy_string((char *) hash.lookup(t->name)));
|
Setattr(hash,name, GetChar(hash,t->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -978,7 +978,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
int have_optional = 0;
|
int have_optional = 0;
|
||||||
|
|
||||||
// Check return code for modification
|
// Check return code for modification
|
||||||
if ((hash.lookup(d->name)) && (d->is_pointer <=1)) {
|
if ((Getattr(hash,d->name)) && (d->is_pointer <=1)) {
|
||||||
need_wrapper = 1;
|
need_wrapper = 1;
|
||||||
munge_return = 1;
|
munge_return = 1;
|
||||||
}
|
}
|
||||||
|
|
@ -1003,9 +1003,9 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
// unchanged. Otherwise, emit some shadow class conversion code.
|
// unchanged. Otherwise, emit some shadow class conversion code.
|
||||||
|
|
||||||
if (!have_output) {
|
if (!have_output) {
|
||||||
func << tab4 << "if val: val = " << (char *) hash.lookup(d->name) << "Ptr(val)";
|
func << tab4 << "if val: val = " << GetChar(hash,d->name) << "Ptr(val)";
|
||||||
if (((hash.lookup(d->name)) && (d->is_pointer < 1)) ||
|
if (((Getattr(hash,d->name)) && (d->is_pointer < 1)) ||
|
||||||
((hash.lookup(d->name)) && (d->is_pointer == 1) && NewObject))
|
((Getattr(hash,d->name)) && (d->is_pointer == 1) && NewObject))
|
||||||
func << "; val.thisown = 1\n";
|
func << "; val.thisown = 1\n";
|
||||||
else
|
else
|
||||||
func << "\n";
|
func << "\n";
|
||||||
|
|
@ -1241,8 +1241,8 @@ void PYTHON::link_variable(char *name, char *iname, DataType *t) {
|
||||||
// Output a shadow variable. (If applicable and possible)
|
// Output a shadow variable. (If applicable and possible)
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||||
if ((hash.lookup(t->name)) && (t->is_pointer <= 1)) {
|
if ((Getattr(hash,t->name)) && (t->is_pointer <= 1)) {
|
||||||
vars << iname << " = " << (char *) hash.lookup(t->name) << "Ptr(" << module << "." << global_name
|
vars << iname << " = " << GetChar(hash,t->name) << "Ptr(" << module << "." << global_name
|
||||||
<< "." << iname << ")\n";
|
<< "." << iname << ")\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1426,11 +1426,11 @@ void PYTHON::add_native(char *name, char *funcname, DataType *, ParmList *) {
|
||||||
void PYTHON::cpp_class_decl(char *name, char *rename, char *type) {
|
void PYTHON::cpp_class_decl(char *name, char *rename, char *type) {
|
||||||
char temp[256];
|
char temp[256];
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
hash.add(name,copy_string(rename));
|
Setattr(hash,name,rename);
|
||||||
// Add full name of datatype to the hash table
|
// Add full name of datatype to the hash table
|
||||||
if (strlen(type) > 0) {
|
if (strlen(type) > 0) {
|
||||||
sprintf(temp,"%s %s", type, name);
|
sprintf(temp,"%s %s", type, name);
|
||||||
hash.add(temp,copy_string(rename));
|
Setattr(hash,temp,rename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,8 @@ protected:
|
||||||
int use_kw;
|
int use_kw;
|
||||||
int noopt;
|
int noopt;
|
||||||
FILE *f_shadow;
|
FILE *f_shadow;
|
||||||
Hash hash;
|
DOH *hash;
|
||||||
|
DOH *symbols;
|
||||||
String classes;
|
String classes;
|
||||||
String func;
|
String func;
|
||||||
String vars;
|
String vars;
|
||||||
|
|
@ -68,6 +69,8 @@ public :
|
||||||
import_file = 0;
|
import_file = 0;
|
||||||
use_kw = 0;
|
use_kw = 0;
|
||||||
noopt = 0;
|
noopt = 0;
|
||||||
|
hash = NewHash();
|
||||||
|
symbols = NewHash();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't change any of this
|
// Don't change any of this
|
||||||
|
|
|
||||||
|
|
@ -422,7 +422,7 @@ void TCL8::create_command(char *cname, char *iname) {
|
||||||
// Add interpreter name to repeatcmd hash table. This hash is used in C++ code
|
// Add interpreter name to repeatcmd hash table. This hash is used in C++ code
|
||||||
// generation to try and find repeated wrapper functions.
|
// generation to try and find repeated wrapper functions.
|
||||||
|
|
||||||
repeatcmd.add(iname,copy_string(wname));
|
Setattr(repeatcmd,iname,wname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
@ -767,8 +767,6 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
|
||||||
|
|
||||||
void TCL8::link_variable(char *name, char *iname, DataType *t)
|
void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||||
{
|
{
|
||||||
|
|
||||||
static Hash setget;
|
|
||||||
String s;
|
String s;
|
||||||
char *tm, *tm1;
|
char *tm, *tm1;
|
||||||
|
|
||||||
|
|
@ -782,8 +780,8 @@ void TCL8::link_variable(char *name, char *iname, DataType *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump a collection of set/get functions suitable for variable tracing
|
// Dump a collection of set/get functions suitable for variable tracing
|
||||||
if (!setget.lookup(t->print_type())) {
|
if (!Getattr(setget,t->print_type())) {
|
||||||
setget.add(t->print_type(),(void *)1);
|
Setattr(setget,t->print_type(),"1");
|
||||||
WrapperFunction get;
|
WrapperFunction get;
|
||||||
WrapperFunction set;
|
WrapperFunction set;
|
||||||
set.def << "static char *_swig_" << t->print_mangle() << "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {";
|
set.def << "static char *_swig_" << t->print_mangle() << "_set(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {";
|
||||||
|
|
@ -1320,7 +1318,7 @@ void TCL8::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
|
||||||
|
|
||||||
temp = "";
|
temp = "";
|
||||||
temp << name_member(realname,class_name);
|
temp << name_member(realname,class_name);
|
||||||
rname = (char *) repeatcmd.lookup(temp);
|
rname = GetChar(repeatcmd,temp);
|
||||||
if (!rname)
|
if (!rname)
|
||||||
rname = name_wrapper(temp.get(),prefix);
|
rname = name_wrapper(temp.get(),prefix);
|
||||||
|
|
||||||
|
|
@ -1348,7 +1346,7 @@ void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
// Try to figure out if there is a wrapper for this function
|
// Try to figure out if there is a wrapper for this function
|
||||||
temp = "";
|
temp = "";
|
||||||
temp << name_get(name_member(realname,bc));
|
temp << name_get(name_member(realname,bc));
|
||||||
rname = (char *) repeatcmd.lookup(temp);
|
rname = GetChar(repeatcmd,temp);
|
||||||
if (!rname)
|
if (!rname)
|
||||||
rname = name_wrapper(temp.get(),prefix);
|
rname = name_wrapper(temp.get(),prefix);
|
||||||
attributes << rname << ", ";
|
attributes << rname << ", ";
|
||||||
|
|
@ -1356,7 +1354,7 @@ void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
|
||||||
if (!(Status & STAT_READONLY)) {
|
if (!(Status & STAT_READONLY)) {
|
||||||
temp = "";
|
temp = "";
|
||||||
temp << name_set(name_member(realname,bc));
|
temp << name_set(name_member(realname,bc));
|
||||||
rname = (char *) repeatcmd.lookup(temp);
|
rname = GetChar(repeatcmd,temp);
|
||||||
if (!rname)
|
if (!rname)
|
||||||
rname = name_wrapper(temp.get(),prefix);
|
rname = name_wrapper(temp.get(),prefix);
|
||||||
attributes << rname << "},\n";
|
attributes << rname << "},\n";
|
||||||
|
|
@ -1409,15 +1407,15 @@ void TCL8::add_typedef(DataType *t, char *name) {
|
||||||
// First check to see if there aren't too many pointers
|
// First check to see if there aren't too many pointers
|
||||||
|
|
||||||
if (t->is_pointer > 1) return;
|
if (t->is_pointer > 1) return;
|
||||||
if (hash.lookup(name)) return; // Already added
|
if (Getattr(hash,name)) return; // Already added
|
||||||
|
|
||||||
// Now look up the datatype in our shadow class hash table
|
// Now look up the datatype in our shadow class hash table
|
||||||
|
|
||||||
if (hash.lookup(t->name)) {
|
if (Getattr(hash,t->name)) {
|
||||||
|
|
||||||
// Yep. This datatype is in the hash
|
// Yep. This datatype is in the hash
|
||||||
// Put this types 'new' name into the hash
|
// Put this types 'new' name into the hash
|
||||||
hash.add(name,copy_string((char *) hash.lookup(t->name)));
|
Setattr(hash,name,GetChar(hash,t->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1433,11 +1431,11 @@ void TCL8::cpp_class_decl(char *name, char *rename, char *type) {
|
||||||
this->Language::cpp_class_decl(name,rename, type);
|
this->Language::cpp_class_decl(name,rename, type);
|
||||||
|
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
hash.add(name,copy_string(rename));
|
Setattr(hash,name,rename);
|
||||||
// Add full name of datatype to the hash table
|
// Add full name of datatype to the hash table
|
||||||
if (strlen(type) > 0) {
|
if (strlen(type) > 0) {
|
||||||
sprintf(temp,"%s %s", type, name);
|
sprintf(temp,"%s %s", type, name);
|
||||||
hash.add(temp,copy_string(rename));
|
Setattr(hash,temp,rename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,9 @@ private:
|
||||||
char *class_type;
|
char *class_type;
|
||||||
char *real_classname;
|
char *real_classname;
|
||||||
char *base_class;
|
char *base_class;
|
||||||
Hash hash;
|
DOH *hash;
|
||||||
Hash repeatcmd;
|
DOH *repeatcmd;
|
||||||
|
DOH *setget;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
TCL8() {
|
TCL8() {
|
||||||
|
|
@ -65,6 +66,9 @@ public :
|
||||||
class_type = 0;
|
class_type = 0;
|
||||||
real_classname = 0;
|
real_classname = 0;
|
||||||
base_class = 0;
|
base_class = 0;
|
||||||
|
hash = NewHash();
|
||||||
|
repeatcmd = NewHash();
|
||||||
|
setget = NewHash();
|
||||||
};
|
};
|
||||||
virtual void parse_args(int, char *argv[]);
|
virtual void parse_args(int, char *argv[]);
|
||||||
virtual void parse();
|
virtual void parse();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue