Replaced the C++ String class with a wrapper around DOHString. Eliminated

the automatic conversion of String --> char * at the risk of breaking the
universe (although I think I have fixed everything).  This change made the wrapper
modules a lot more ugly, but it's now a lot more obvious as to what is a
String and what is a char * which will be useful when I get around to patching
up all of the interfaces and objects.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@504 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-06-28 03:32:58 +00:00
commit 1368c716af
14 changed files with 164 additions and 480 deletions

View file

@ -397,9 +397,9 @@ GUILE::get_pointer (char *iname, int parm, DataType *t,
static void
mreplace (String &s, String &argnum, String &arg, String &proc_name)
{
s.replace ("$argnum", argnum);
s.replace ("$arg", arg);
s.replace ("$name", proc_name);
s.replace ("$argnum", argnum.get());
s.replace ("$arg", arg.get());
s.replace ("$name", proc_name.get());
}
static void
@ -507,7 +507,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
else {
++numargs;
if ((tm = typemap_lookup ((char*)"in", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
f.code << tm << "\n";
mreplace (f.code, argnum, arg, proc_name);
}
@ -522,7 +522,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Check if there are any constraints.
if ((tm = typemap_lookup ((char*)"check", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
f.code << tm << "\n";
mreplace (f.code, argnum, arg, proc_name);
}
@ -530,7 +530,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Pass output arguments back to the caller.
if ((tm = typemap_lookup ((char*)"argout", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
outarg << tm << "\n";
mreplace (outarg, argnum, arg, proc_name);
}
@ -538,7 +538,7 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Free up any memory allocated for the arguments.
if ((tm = typemap_lookup ((char*)"freearg", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
cleanup << tm << "\n";
mreplace (cleanup, argnum, arg, proc_name);
}

View file

@ -227,9 +227,9 @@ char *JAVA::makeValidJniName(char *name) {
// !! this approach fails for functions without arguments
char *JAVA::JNICALL(String& func) {
if(jnic)
sprintf(bigbuf, "(*jenv)->%s(jenv, ", (char *) func);
sprintf(bigbuf, "(*jenv)->%s(jenv, ", (char *) func.get());
else
sprintf(bigbuf, "jenv->%s(", (char *) func);
sprintf(bigbuf, "jenv->%s(", (char *) func.get());
return strdup(bigbuf);
}
@ -259,25 +259,25 @@ void JAVA::writeRegisterNatives()
// The registerNatives function
String registerFunction;
registerFunction << "jint registerNatives(JNIEnv *jenv) {" << endl
registerFunction << "jint registerNatives(JNIEnv *jenv) {" << "\n"
<< tab4 << "jclass nativeClass = " << JNICALL((char*)"FindClass")
<< "\"" << jni_pkgstr << module << "\");" <<endl;
registerFunction << tab4 << "if (nativeClass == 0)" << endl << tab8 << "return -1;" << endl;
<< "\"" << jni_pkgstr << module << "\");" <<"\n";
registerFunction << tab4 << "if (nativeClass == 0)" << "\n" << tab8 << "return -1;" << "\n";
registerFunction << tab4 << "return " << JNICALL((char*)"RegisterNatives") << "nativeClass, nativeMethods, " << "numberOfNativeMethods);" << endl;
registerFunction << "}" << endl << endl;
registerFunction << tab4 << "return " << JNICALL((char*)"RegisterNatives") << "nativeClass, nativeMethods, " << "numberOfNativeMethods);" << "\n";
registerFunction << "}" << "\n" << "\n";
// The unregisterNatives function
registerFunction << "jint unregisterNatives(JNIEnv *jenv) {" << endl
registerFunction << "jint unregisterNatives(JNIEnv *jenv) {" << "\n"
<< tab4 << "jclass nativeClass = " << JNICALL((char*)"FindClass")
<< "\"" << jni_pkgstr << module << "\");" <<endl;
registerFunction << tab4 << "if (nativeClass == 0)" << endl << tab8 << "return -1;" << endl;
<< "\"" << jni_pkgstr << module << "\");" <<"\n";
registerFunction << tab4 << "if (nativeClass == 0)" << "\n" << tab8 << "return -1;" << "\n";
registerFunction << tab4 << "// Sun documentation suggests that this method should not be invoked in "
<< "\"normal native code\"." << endl;
registerFunction << tab4 << "// return " << JNICALL((char*)"UnregisterNatives") << "nativeClass);" << endl;
registerFunction << tab4 << "return 0;" << endl;
registerFunction << "}" << endl;
<< "\"normal native code\"." << "\n";
registerFunction << tab4 << "// return " << JNICALL((char*)"UnregisterNatives") << "nativeClass);" << "\n";
registerFunction << tab4 << "return 0;" << "\n";
registerFunction << "}" << "\n";
// Now write the C function
fprintf(f_wrappers,registerFunction.get());
@ -551,7 +551,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
else member_name << "get";
member_name << (char) toupper((int) *shadow_name);
member_name << shadow_name + 1;
fprintf(f_shadow, " public %s %s(", javarettype, (char *) member_name);
fprintf(f_shadow, " public %s %s(", javarettype, (char *) member_name.get());
body << tab4 << "return " << module << "." << iname << "(_self";
}
@ -590,13 +590,13 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
if(shadow && member_func) {
if(i > 0) {
if(i>1) fprintf(f_shadow, ", ");
fprintf(f_shadow, "%s %s", jtype, (char *) source);
fprintf(f_shadow, "%s %s", jtype, (char *) source.get());
body << ", " << source;
}
}
if(gencomma) fprintf(f_java, ", ");
fprintf(f_java, "%s %s", jtype, (char *) source);
fprintf(f_java, "%s %s", jtype, (char *) source.get());
gencomma = 1;
@ -604,10 +604,10 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
f.def << ", " << jnitype << " " << source;
// Get typemap for this argument
tm = typemap_lookup((char*)"in",typemap_lang,p->t,p->name,source,target,&f);
tm = typemap_lookup((char*)"in",typemap_lang,p->t,p->name,source.get(),target.get(),&f);
if (tm) {
f.code << tm << "\n";
f.code.replace("$arg",source); // Perform a variable replacement
f.code.replace("$arg",source.get()); // Perform a variable replacement
} else {
if(!p->t->is_pointer)
f.code << tab4 << target << " = " << p->t->print_cast() << source << ";\n";
@ -618,7 +618,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
p->t->is_pointer--;
} else {
if(p->t->type == T_CHAR && p->t->is_pointer == 1) {
f.code << tab4 << (char *) target << " = (" << source << ") ? (char *)" << JNICALL((char*)"GetStringUTFChars") << source << ", 0) : NULL;\n";
f.code << tab4 << target << " = (" << source << ") ? (char *)" << JNICALL((char*)"GetStringUTFChars") << source << ", 0) : NULL;\n";
} else {
char *scalarType = SwigTcToJniScalarType(p->t);
char *cptrtype = p->t->print_type();
@ -636,8 +636,8 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
String source_length = JNICALL((char*)"GetArrayLength");
source_length << source << ")";
target_copy = copy_string(f.new_local((char *) basic_jniptrtype, target, NULL));
target_length = copy_string(f.new_local((char*)"jsize", target, source_length));
target_copy = copy_string(f.new_local((char *) basic_jniptrtype.get(), target.get(), NULL));
target_length = copy_string(f.new_local((char*)"jsize", target.get(), source_length.get()));
if(local_i == NULL) local_i = copy_string(f.new_local((char*)"int", (char*)"i", NULL));
String scalarFunc = "Get";
@ -658,23 +658,23 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
}
// Check to see if there was any sort of a constaint typemap
if ((tm = typemap_lookup((char*)"check",typemap_lang,p->t,p->name,source,target))) {
if ((tm = typemap_lookup((char*)"check",typemap_lang,p->t,p->name,source.get(),target.get()))) {
// Yep. Use it instead of the default
f.code << tm << "\n";
f.code.replace("$arg",source);
f.code.replace("$arg",source.get());
}
// Check if there was any cleanup code (save it for later)
if ((tm = typemap_lookup((char*)"freearg",typemap_lang,p->t,p->name,source,target))) {
if ((tm = typemap_lookup((char*)"freearg",typemap_lang,p->t,p->name,source.get(),target.get()))) {
// Yep. Use it instead of the default
cleanup << tm << "\n";
cleanup.replace("$arg",source);
cleanup.replace("$arg",source.get());
}
if ((tm = typemap_lookup((char*)"argout",typemap_lang,p->t,p->name,source,target))) {
if ((tm = typemap_lookup((char*)"argout",typemap_lang,p->t,p->name,source.get(),target.get()))) {
// Yep. Use it instead of the default
outarg << tm << "\n";
outarg.replace("$arg",source);
outarg.replace("$arg",source.get());
} else {
// if(p->t->is_pointer && p->t->type != T_USER && p->t->type != T_VOID) {
if(p->t->is_pointer) {
@ -718,7 +718,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
if(shadow && member_func) {
fprintf(f_shadow, ") {\n");
body << ")";
fprintf(f_shadow, "%s;\n }\n\n", (char *) body);
fprintf(f_shadow, "%s;\n }\n\n", (char *) body.get());
}
f.def << ") {";
@ -784,7 +784,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l)
f.code << "}\n";
// Substitute the cleanup code (some exception handlers like to have this)
f.code.replace("$cleanup",cleanup);
f.code.replace("$cleanup",cleanup.get());
// Emit the function
@ -833,7 +833,7 @@ void JAVA::declare_const(char *name, char *iname, DataType *type, char *value) {
if ((tm = typemap_lookup((char*)"const",typemap_lang,type,name,name,iname))) {
String str = tm;
str.replace("$value",value);
fprintf(jfile," %s\n\n", (char *) str);
fprintf(jfile," %s\n\n", (char *) str.get());
} else {
if((type->is_pointer == 0)) {
char *jtype = typemap_lookup((char*)"jtype", typemap_lang, type, name, name, iname);
@ -878,17 +878,17 @@ void JAVA::pragma(char *lang, char *code, char *value) {
String s = value;
s.replace("\\\"", "\"");
if(strcmp(code, "import") == 0) {
jimport = copy_string((char *) s);
jimport = copy_string((char *) s.get());
fprintf(f_java, "// pragma\nimport %s;\n\n", jimport);
} else if(strcmp(code, "module") == 0) {
if(!classdef_emitted) emit_classdef();
fprintf(f_java, "// pragma\n");
fprintf(f_java, (char *) s);
fprintf(f_java, (char *) s.get());
fprintf(f_java, "\n\n");
} else if(strcmp(code, "shadow") == 0) {
if(shadow && f_shadow) {
fprintf(f_shadow, "// pragma\n");
fprintf(f_shadow, (char *) s);
fprintf(f_shadow, (char *) s.get());
fprintf(f_shadow, "\n\n");
}
} else if(strcmp(code, "modifiers") == 0) {
@ -985,7 +985,7 @@ void JAVA::emit_shadow_classdef() {
shadow_classdef << " public Class _selfClass() {\n" << tab4 << "return " << shadow_classname << ".class;\n" << " };\n\n";
fprintf(f_shadow, (char *) shadow_classdef);
fprintf(f_shadow, (char *) shadow_classdef.get());
shadow_classdef_emitted = 1;
}
@ -1059,7 +1059,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
}
// 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.get());
if(i != pcount-1) {
fprintf(f_shadow, ", ");
}
@ -1072,7 +1072,7 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
nativecall << ");\n";
fprintf(f_shadow, ") {\n");
fprintf(f_shadow, "\t%s\n", (char *) nativecall);
fprintf(f_shadow, "\t%s\n", (char *) nativecall.get());
fprintf(f_shadow, " }\n\n");
}
@ -1132,7 +1132,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
}
// 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.get());
if(i != pcount-1) {
fprintf(f_shadow, ", ");
}
@ -1145,7 +1145,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) {
nativecall << ");\n";
fprintf(f_shadow, ") {\n");
fprintf(f_shadow, "\t%s\n", (char *) nativecall);
fprintf(f_shadow, "\t%s\n", (char *) nativecall.get());
fprintf(f_shadow, " }\n\n");
}
@ -1187,7 +1187,7 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
if(strcmp(jtype, jstype) == 0) jstype = NULL;
// 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.get());
if(p->t->type == T_USER && p->t->is_pointer <= 1 && Getattr(shadow_classes,p->t->name)) {
nativecall << arg << "._self";
@ -1205,7 +1205,7 @@ void JAVA::cpp_constructor(char *name, char *iname, ParmList *l) {
nativecall << tab8 << " _selfown = true;\n";
nativecall << " }\n";
fprintf(f_shadow, "%s", (char *) nativecall);
fprintf(f_shadow, "%s", (char *) nativecall.get());
fprintf(f_shadow, " }\n\n");
}

View file

@ -269,9 +269,9 @@ MZSCHEME::get_pointer (String &name, int parm, DataType *t,
static void
mreplace (String &s, String &argnum, String &arg, String &proc_name)
{
s.replace ("$argnum", argnum);
s.replace ("$arg", arg);
s.replace ("$name", proc_name);
s.replace ("$argnum", argnum.get());
s.replace ("$arg", arg.get());
s.replace ("$name", proc_name.get());
}
static void
@ -365,7 +365,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
else {
++numargs;
if ((tm = typemap_lookup ((char*)"in", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
f.code << tm << "\n";
mreplace (f.code, argnum, arg, proc_name);
}
@ -381,7 +381,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Check if there are any constraints.
if ((tm = typemap_lookup ((char*)"check", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
// Yep. Use it instead of the default
f.code << tm << "\n";
mreplace (f.code, argnum, arg, proc_name);
@ -390,7 +390,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Pass output arguments back to the caller.
if ((tm = typemap_lookup ((char*)"argout", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
// Yep. Use it instead of the default
outarg << tm << "\n";
mreplace (outarg, argnum, arg, proc_name);
@ -399,7 +399,7 @@ MZSCHEME::create_function (char *name, char *iname, DataType *d, ParmList *l)
// Free up any memory allocated for the arguments.
if ((tm = typemap_lookup ((char*)"freearg", typemap_lang,
p.t, p.name, source, target, &f))) {
p.t, p.name, source.get(), target.get(), &f))) {
// Yep. Use it instead of the default
cleanup << tm << "\n";
mreplace (cleanup, argnum, arg, proc_name);

View file

@ -969,7 +969,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
f.add_local((char*)"dXSARGS",(char*)"");
// Substitute the cleanup code
f.code.replace("$cleanup",cleanup);
f.code.replace("$cleanup",cleanup.get());
f.code.replace("$name",iname);
// Dump this function out
@ -1017,7 +1017,7 @@ void PERL5::create_function(char *name, char *iname, DataType *d, ParmList *l)
String sourceNtarget;
sourceNtarget << "$args[" << i << "]";
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",p->t,(char*)"",sourceNtarget,sourceNtarget)))
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",p->t,(char*)"",sourceNtarget.get(),sourceNtarget.get())))
func << tm << "\n";
else if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {
if (i >= (pcount - numopt))
@ -1632,7 +1632,7 @@ void PERL5::cpp_open_class(char *classname, char *rname, char *ctype, int strip)
// Add some symbols to the hash tables
// classes.add(real_classname,copy_string(class_name)); /* Map original classname to class */
Setattr(classes,real_classname,fullclassname);
Setattr(classes,real_classname,fullclassname.get());
// Add full name of datatype to the hash table just in case the user uses it
@ -1813,7 +1813,7 @@ void PERL5::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
String sourceNtarget;
sourceNtarget << "$args[" << i << "]";
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",p->t,(char*)"",sourceNtarget,sourceNtarget)))
if ((tm = typemap_lookup((char*)"perl5in",(char*)"perl5",p->t,(char*)"",sourceNtarget.get(),sourceNtarget.get())))
func << tm << "\n";
// Look up the datatype name here
else if ((Getattr(classes,p->t->name)) && (p->t->is_pointer <= 1)) {

View file

@ -399,7 +399,7 @@ void PYTHON::close(void)
<< "\n\n#-------------- VARIABLE WRAPPERS ------------------\n\n"
<< vars;
if (strlen(pragma_include) > 0) {
if (strlen(pragma_include.get()) > 0) {
fullshadow << "\n\n#-------------- USER INCLUDE -----------------------\n\n"
<< pragma_include;
}
@ -600,7 +600,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
// should modify this to return the appropriate types and use the
// appropriate parameters.
emit_function_header(f, wname);
emit_function_header(f, wname.get());
f.add_local((char*)"PyObject *",(char*)"_resultobj");
@ -835,7 +835,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
call_name = "";
call_name << self_name << name;
emit_func_call(call_name,d,l,f);
emit_func_call(call_name.get(),d,l,f);
// Now emit code to return the functions return value (if any).
// If there was a result, it was saved in _result.
@ -952,7 +952,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
f.code << "}\n";
// Substitute the cleanup code
f.code.replace("$cleanup",cleanup);
f.code.replace("$cleanup",cleanup.get());
// Substitute the function name
f.code.replace("$name",iname);
@ -962,7 +962,7 @@ void PYTHON::create_function(char *name, char *iname, DataType *d, ParmList *l)
// Now register the function with the interpreter.
add_method(iname, wname, use_kw);
add_method(iname, wname.get(), use_kw);
#ifdef SHADOW_METHODS
if (shadow && (shadow & PYSHADOW_MEMBER)) {
@ -1500,8 +1500,8 @@ void PYTHON::cpp_pragma(Pragma *plist) {
pragmas = 0;
}
while (plist) {
if (strcmp(plist->lang,(char*)"python") == 0) {
if (strcmp(plist->name,"addtomethod") == 0) {
if (strcmp(plist->lang.get(),(char*)"python") == 0) {
if (strcmp(plist->name.get(),"addtomethod") == 0) {
// parse value, expected to be in the form "methodName:line"
String temp = plist->value;
char* txtptr = strchr(temp.get(), ':');
@ -1509,7 +1509,7 @@ void PYTHON::cpp_pragma(Pragma *plist) {
// add name and line to a list in current_class
*txtptr = 0;
txtptr++;
pyp1 = new PyPragma(temp,txtptr);
pyp1 = new PyPragma(temp.get(),txtptr);
if (pyp2) {
pyp2->next = pyp1;
pyp2 = pyp1;
@ -1521,8 +1521,8 @@ void PYTHON::cpp_pragma(Pragma *plist) {
fprintf(stderr,"%s : Line %d. Malformed addtomethod pragma. Should be \"methodName:text\"\n",
plist->filename.get(),plist->lineno);
}
} else if (strcmp(plist->name, "addtoclass") == 0) {
pyp1 = new PyPragma((char*)"__class__",plist->value);
} else if (strcmp(plist->name.get(), "addtoclass") == 0) {
pyp1 = new PyPragma((char*)"__class__",plist->value.get());
if (pyp2) {
pyp2->next = pyp1;
pyp2 = pyp1;
@ -1547,7 +1547,7 @@ void PYTHON::emitAddPragmas(String& output, char* name, char* spacing)
{
PyPragma *p = pragmas;
while (p) {
if (strcmp(p->m_method,name) == 0) {
if (strcmp(p->m_method.get(),name) == 0) {
output << spacing << p->m_text << "\n";
}
p = p->next;

View file

@ -756,7 +756,7 @@ void TCL8::create_function(char *name, char *iname, DataType *d, ParmList *l)
f.code << tab4 << "return TCL_OK;\n}";
// Substitute the cleanup code
f.code.replace("$cleanup",cleanup);
f.code.replace("$cleanup",cleanup.get());
f.code.replace("$name",iname);
// Dump out the function
@ -1154,7 +1154,7 @@ char * TCL8::usage_string(char *iname, DataType *, ParmList *l) {
}
p = l->get_next();
}
return temp;
return temp.get();
}
// ---------------------------------------------------------------------------
@ -1172,7 +1172,7 @@ char * TCL8::usage_func(char *iname, DataType *t, ParmList *l) {
} else {
temp << prefix << iname;
}
return usage_string(temp,t,l);
return usage_string(temp.get(),t,l);
}
// -----------------------------------------------------------------
@ -1327,7 +1327,7 @@ void TCL8::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) {
temp = "";
temp << Swig_name_member(class_name,realname);
rname = GetChar(repeatcmd,temp);
rname = GetChar(repeatcmd,temp.get());
if (!rname)
rname = Swig_name_wrapper(temp.get());
@ -1355,7 +1355,7 @@ void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
// Try to figure out if there is a wrapper for this function
temp = "";
temp << Swig_name_get(Swig_name_member(bc,realname));
rname = GetChar(repeatcmd,temp);
rname = GetChar(repeatcmd,temp.get());
if (!rname)
rname = Swig_name_wrapper(temp.get());
attributes << rname << ", ";
@ -1363,7 +1363,7 @@ void TCL8::cpp_variable(char *name, char *iname, DataType *t) {
if (!(Status & STAT_READONLY)) {
temp = "";
temp << Swig_name_set(Swig_name_member(bc,realname));
rname = GetChar(repeatcmd,temp);
rname = GetChar(repeatcmd,temp.get());
if (!rname)
rname = Swig_name_wrapper(temp.get());
attributes << rname << "},\n";

View file

@ -1515,7 +1515,7 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
key << cname << "+";
l->print_types(key);
// printf("key = %s\n", (char *) key);
char *temp = copy_string(iname);
char *temp = copy_string(iname.get());
if (!member_hash) member_hash = NewHash();
if (Getattr(member_hash,key.get())) {
delete [] temp;
@ -1629,11 +1629,11 @@ void cplus_emit_member_func(char *classname, char *classtype, char *classrename,
// Now wrap the thing. The name of the function is iname
lang->create_function(cname, iname, type, newparms);
lang->create_function(cname.get(), iname.get(), type, newparms);
delete newparms;
} else {
// Already wrapped this function. Just patch it up
lang->create_command(prev_wrap, iname);
lang->create_command(prev_wrap, iname.get());
}
}
@ -1733,7 +1733,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
key << cname << "+";
l->print_types(key);
char *temp = copy_string(iname);
char *temp = copy_string(iname.get());
if (!member_hash) member_hash = NewHash();
if (Getattr(member_hash,key.get())) {
delete [] temp;
@ -1746,7 +1746,7 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
if (!prev_wrap) {
if (!((mode) || (ObjCClass))) {
// Not an added method and not objective C, just wrap it
lang->create_function(cname,iname, type, l);
lang->create_function(cname.get(),iname.get(), type, l);
} else {
// This is either an added method or an objective C class function
//
@ -1823,11 +1823,11 @@ void cplus_emit_static_func(char *classname, char *, char *classrename,
}
if (ObjCClass || (mode && ccode))
fprintf(f_wrappers,"%s\n",wrap.get());
lang->create_function(cname,iname,type,l);
lang->create_function(cname.get(),iname.get(),type,l);
}
} else {
// Already wrapped this function. Just hook up to it.
lang->create_command(prev_wrap, iname);
lang->create_command(prev_wrap, iname.get());
}
}
@ -1925,7 +1925,7 @@ void cplus_emit_destructor(char *classname, char *classtype, char *classrename,
// iname is the desired name of the function in the target language
lang->create_function(cname,iname,type,l);
lang->create_function(cname.get(),iname.get(),type,l);
delete type;
delete l;
@ -2068,7 +2068,7 @@ void cplus_emit_constructor(char *classname, char *classtype, char *classrename,
// We've now created a C wrapper. We're going to add it to the interpreter
lang->create_function(cname, iname, type, l);
lang->create_function(cname.get(), iname.get(), type, l);
delete type;
}
@ -2158,7 +2158,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
// Now check to see if we have already wrapped a variable like this.
key << cname;
char *temp = copy_string(iname);
char *temp = copy_string(iname.get());
if (!member_hash) member_hash = NewHash();
if (Getattr(member_hash,key.get())) {
delete [] temp;
@ -2177,7 +2177,7 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
// Now write a function to get the value of the variable
tm = typemap_lookup((char*)"memberout",typemap_lang,type,mname,source,(char*)"result");
tm = typemap_lookup((char*)"memberout",typemap_lang,type,mname,source.get(),(char*)"result");
if ((type->type == T_USER) && (!type->is_pointer)) {
type->is_pointer++;
@ -2227,18 +2227,18 @@ void cplus_emit_variable_get(char *classname, char *classtype, char *classrename
if ((type->type == T_USER) && (!type->is_pointer)) {
type->is_pointer++;
lang->create_function(cname,iname, type, l);
lang->create_function(cname.get(),iname.get(), type, l);
type->is_pointer--;
} else {
int is_ref = type->is_reference;
type->is_reference = 0;
lang->create_function(cname,iname, type, l);
lang->create_function(cname.get(),iname.get(), type, l);
type->is_reference = is_ref;
}
delete l;
} else {
// Already wrapped this function. Just patch it up
lang->create_command(prev_wrap,iname);
lang->create_command(prev_wrap,iname.get());
}
}
@ -2339,7 +2339,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
// Now check to see if we have already wrapped a variable like this.
key << cname;
char *temp = copy_string(iname);
char *temp = copy_string(iname.get());
if (!member_hash) member_hash = NewHash();
if (Getattr(member_hash,key.get())) {
delete [] temp;
@ -2357,7 +2357,7 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
target << "obj->" << mname;
// Lookup any typemaps that might exist
tm = typemap_lookup((char*)"memberin",typemap_lang,type,mname,(char*)"val",target);
tm = typemap_lookup((char*)"memberin",typemap_lang,type,mname,(char*)"val",target.get());
// First write a function to set the variable
@ -2452,17 +2452,17 @@ void cplus_emit_variable_set(char *classname, char *classtype, char *classrename
if ((type->type == T_USER) && (!type->is_pointer)) {
type->is_pointer++;
lang->create_function(cname,iname, type, l);
lang->create_function(cname.get(),iname.get(), type, l);
type->is_pointer--;
} else {
int is_ref = type->is_reference;
type->is_reference = 0;
lang->create_function(cname,iname, type, l);
lang->create_function(cname.get(),iname.get(), type, l);
type->is_reference = is_ref;
}
delete l;
} else {
lang->create_command(prev_wrap,iname);
lang->create_command(prev_wrap,iname.get());
}
}

View file

@ -351,12 +351,12 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, WrapperFunction &f) {
if ((tm = typemap_lookup((char*)"except",typemap_lang,t,decl,(char*)"_result",(char*)""))) {
// Found a type-specific mapping
exc << tm;
exc.replace("$function",fcall);
exc.replace("$function",fcall.get());
exc.replace("$name",decl);
f.code << exc;
} else if ((tm = fragment_lookup((char*)"except",typemap_lang, t->id))) {
exc << tm;
exc.replace("$function",fcall);
exc.replace("$function",fcall.get());
exc.replace("$name",decl);
f.code << exc;
} else {
@ -472,10 +472,10 @@ void emit_set_get(char *name, char *iname, DataType *t) {
if ((t->type == T_USER) && (!t->is_pointer)) {
t->is_pointer++;
lang->create_function(new_name, new_iname, t, l);
lang->create_function(new_name.get(), new_iname.get(), t, l);
t->is_pointer--;
} else {
lang->create_function(new_name, new_iname, t, l);
lang->create_function(new_name.get(), new_iname.get(), t, l);
}
delete l;
delete p;
@ -506,10 +506,10 @@ void emit_set_get(char *name, char *iname, DataType *t) {
if ((t->type == T_USER) && (!t->is_pointer)) {
t->is_pointer++;
lang->create_function(new_name, new_iname, t, l);
lang->create_function(new_name.get(), new_iname.get(), t, l);
t->is_pointer--;
} else {
lang->create_function(new_name, new_iname, t, l);
lang->create_function(new_name.get(), new_iname.get(), t, l);
}
delete l;
}

View file

@ -185,7 +185,7 @@ static char *make_name(char *name) {
temp = "";
temp << name;
temp.replace("$","_S_");
return temp;
return temp.get();
} else {
return name;
}
@ -548,7 +548,7 @@ statement : INCLUDE STRING LBRACE {
if ($4 > 0) {
$2->is_pointer++;
$2->status = STAT_READONLY;
$2->arraystr = copy_string(ArrayString);
$2->arraystr = copy_string(ArrayString.get());
}
if ($3.is_reference) {
fprintf(stderr,"%s : Line %d. Error. Linkage to C++ reference not allowed.\n", input_file, line_number);
@ -929,7 +929,7 @@ statement : INCLUDE STRING LBRACE {
skip_brace();
p = $7;
while (p) {
typemap_register($5,$3,p->p->t,p->p->name,CCode,p->args);
typemap_register($5,$3,p->p->t,p->p->name,CCode.get(),p->args);
p = p->next;
}
delete $3;
@ -947,7 +947,7 @@ statement : INCLUDE STRING LBRACE {
skip_brace();
p = $5;
while (p) {
typemap_register($3,typemap_lang,p->p->t,p->p->name,CCode,p->args);
typemap_register($3,typemap_lang,p->p->t,p->p->name,CCode.get(),p->args);
p = p->next;
}
}
@ -1052,14 +1052,14 @@ statement : INCLUDE STRING LBRACE {
/* An exception definition */
| EXCEPT LPAREN ID RPAREN LBRACE {
skip_brace();
fragment_register((char *)"except",$3, CCode);
fragment_register((char *)"except",$3, CCode.get());
delete $3;
}
/* A Generic Exception (no language specified */
| EXCEPT LBRACE {
skip_brace();
fragment_register((char *) "except",typemap_lang, CCode);
fragment_register((char *) "except",typemap_lang, CCode.get());
}
/* Clear an exception */
@ -1194,7 +1194,7 @@ typedef_decl : TYPEDEF type declaration {
$2->is_pointer += $3.is_pointer;
// Turn this into a "pointer" corresponding to the array
$2->is_pointer++;
$2->arraystr = copy_string(ArrayString);
$2->arraystr = copy_string(ArrayString.get());
$2->typedef_add($3.id);
fprintf(stderr,"%s : Line %d. Warning. Array type %s will be read-only without a typemap\n",input_file,line_number, $3.id);
cplus_register_type($3.id);
@ -1227,7 +1227,7 @@ typedeflist : COMMA declaration typedeflist {
t = new DataType(Active_typedef);
t->status = STAT_READONLY | STAT_REPLACETYPE;
t->is_pointer += $2.is_pointer + 1;
t->arraystr = copy_string(ArrayString);
t->arraystr = copy_string(ArrayString.get());
t->typedef_add($2.id);
cplus_register_type($2.id);
delete t;
@ -1264,7 +1264,7 @@ stail : SEMI { }
if ($3 > 0) {
temp_typeptr->is_pointer++;
temp_typeptr->status = STAT_READONLY;
temp_typeptr->arraystr = copy_string(ArrayString);
temp_typeptr->arraystr = copy_string(ArrayString.get());
}
if ($2.is_reference) {
fprintf(stderr,"%s : Line %d. Error. Linkage to C++ reference not allowed.\n", input_file, line_number);
@ -2399,7 +2399,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end {
Active_type = new DataType($1);
$1->is_pointer += $2.is_pointer + 1;
$1->is_reference = $2.is_reference;
$1->arraystr = copy_string(ArrayString);
$1->arraystr = copy_string(ArrayString.get());
if (!(tm = typemap_lookup((char*)"memberin",typemap_lang,$1,$2.id,(char*)"",(char*)"")))
Status = STAT_READONLY;
@ -2979,7 +2979,7 @@ objc_var : type declaration {
Active_type = new DataType($1);
$1->is_pointer += $2.is_pointer;
$1->is_reference = $2.is_reference;
$1->arraystr = copy_string(ArrayString);
$1->arraystr = copy_string(ArrayString.get());
if ($1->status & STAT_READONLY) {
if (!(tm = typemap_lookup((char*)"memberin",typemap_lang,$1,$2.id,(char*)"",(char*)"")))
Status = Status | STAT_READONLY;
@ -3024,7 +3024,7 @@ objc_vartail : COMMA declaration objc_vartail {
DataType *t = new DataType (Active_type);
t->is_pointer += $2.is_pointer;
t->is_reference = $2.is_reference;
t->arraystr = copy_string(ArrayString);
t->arraystr = copy_string(ArrayString.get());
if (t->status & STAT_READONLY) {
if (!(tm = typemap_lookup((char*)"memberin",typemap_lang,t,$2.id,(char*)"",(char*)"")))
Status = Status | STAT_READONLY;
@ -3222,7 +3222,7 @@ tm_tail : COMMA typemap_parm tm_tail {
typemap_parm : type typemap_name {
if (InArray) {
$1->is_pointer++;
$1->arraystr = copy_string(ArrayString);
$1->arraystr = copy_string(ArrayString.get());
}
$$ = new TMParm;
$$->p = new Parm($1,$2);
@ -3239,7 +3239,7 @@ typemap_parm : type typemap_name {
$$->p->call_type = 0;
if (InArray) {
$$->p->t->is_pointer++;
$$->p->t->arraystr = copy_string(ArrayString);
$$->p->t->arraystr = copy_string(ArrayString.get());
}
$$->args = tm_parm;
delete $1;

View file

@ -3,6 +3,8 @@
*
* SWIG string object.
*
* Note: 6/27/2000 - This module is now just a wrapper around a DOHString.
*
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
*
* Copyright (C) 1998-2000. The University of Chicago
@ -16,6 +18,9 @@ static char cvsroot[] = "$Header$";
#include "internal.h"
#include <ctype.h>
extern "C" {
#include "doh.h"
}
//-----------------------------------------------------------------------
// char *copy_string(char *str)
@ -114,383 +119,71 @@ void format_string(char *str) {
// functions as strings before writing them out to a file.
//
// ---------------------------------------------------------------------------
#define INIT_MAXSIZE 64
// ---------------------------------------------------------------
// String::String()
//
// Create a new string with nothing in it
// ---------------------------------------------------------------
String::String() {
maxsize = INIT_MAXSIZE;
str = new char[maxsize];
str[0] = 0;
len = 0;
str = NewString("");
}
// ---------------------------------------------------------------
// String::String(const char *s)
//
// Create a new string copied from a normal C-style string
// ---------------------------------------------------------------
String::String(const char *s) {
maxsize = INIT_MAXSIZE;
int l = 0;
if (s) {
l = (int) strlen(s);
if ((l+1) > maxsize) maxsize = l+1;
}
str = new char[maxsize];
if (s) {
strcpy(str,s);
len = l;
} else {
str[0] = 0;
len = 0;
}
str = NewString(s);
}
// ---------------------------------------------------------------
// String::~String(const char *s)
//
// Destroy a string
// ---------------------------------------------------------------
String::~String() {
delete [] str;
Delete(str);
}
// ---------------------------------------------------------------
// String::add(const char *newstr)
//
// Concatenate newstr onto the current string
// ---------------------------------------------------------------
void String::add(const char *newstr) {
int newlen;
char *nstr = 0;
int newmaxsize;
int l;
l = (int) strlen(newstr);
newlen = len+l + 1;
if (newlen >= maxsize-1) {
newmaxsize = 2*maxsize;
if (newlen >= newmaxsize -1) newmaxsize = newlen + 1;
nstr = new char[newmaxsize];
strcpy(nstr,str);
delete [] str;
maxsize = newmaxsize;
str = nstr;
}
strcpy(str+len,newstr);
len += l;
}
// ---------------------------------------------------------------
// String::add(char)
//
// Adds a single character to the current string
// ---------------------------------------------------------------
void String::add(char nc) {
int newlen;
char *nstr = 0;
int newmaxsize;
newlen = len+ 1;
if (newlen >= maxsize-1) {
newmaxsize = 2*maxsize;
if (newlen >= newmaxsize -1) newmaxsize = newlen + 1;
nstr = new char[newmaxsize];
strcpy(nstr,str);
delete [] str;
maxsize = newmaxsize;
str = nstr;
}
str[len++] = nc;
str[len] = 0;
}
// -----------------------------------------------------------------
// String::insert(const char *newstr)
//
// Inserts a string into the front of a string. (Primarily used
// for documentation generation)
// -----------------------------------------------------------------
void String::insert(const char *newstr) {
int newlen;
char *nstr = 0;
int newmaxsize;
int i,l;
l = strlen(newstr);
newlen = len + l + 1;
if (newlen >= maxsize-1) {
newmaxsize = 2*maxsize;
if (newlen >= newmaxsize -1) newmaxsize = newlen + 1;
nstr = new char[newmaxsize];
strcpy(nstr,str);
delete [] str;
maxsize = newmaxsize;
str = nstr;
}
/* Shift all of the characters over */
for (i = len -1; i >= 0; i--) {
str[i+l] = str[i];
}
/* Now insert the new string */
strncpy(str,newstr,l);
len += l;
str[len] = 0;
}
// -----------------------------------------------------------------
// char *String::get()
//
// Get the current value of the string
// -----------------------------------------------------------------
char *String::get() const {
return str;
return Char(str);
}
// -----------------------------------------------------------------
// String &operator<<(...)
//
// Shorthand for appending to the end of a string
// -----------------------------------------------------------------
String &operator<<(String &t,const char *s) {
t.add(s);
Append(t.str,s);
return t;
}
String &operator<<(String &t,const char s) {
t.add(s);
char temp[2] = { 0, 0 };
temp[0] = s;
Append(t.str,temp);
return t;
}
String &operator<<(String &t,const int a) {
char temp[64];
sprintf(temp,"%d",a);
t.add(temp);
Append(t.str,temp);
return t;
}
String &operator<<(String &t, const String &s) {
t.add(s.get());
Append(t.str,s.str);
return t;
}
String &String::operator=(const char *s) {
int newlen;
if (s) {
newlen = strlen(s);
if ((newlen >= maxsize) && (str)) {
delete [] str;
str = new char[newlen+1];
maxsize = newlen+1;
}
strcpy(str,s);
len = newlen;
} else {
str[0] = 0;
len = 0;
}
Delete(str);
str = NewString(s);
return *this;
}
// -----------------------------------------------------------------
// String &operator>>(...)
//
// Shorthand for inserting into the beginning of a string
// -----------------------------------------------------------------
String &operator>>(const char *s, String &t) {
t.insert(s);
Insert(t.str,0,s);
return t;
}
String &operator>>(const String &s, String &t) {
t.insert(s.get());
Insert(t.str,0,s.str);
return t;
}
// -----------------------------------------------------------------
// void String::untabify()
//
// Expand all tabs into spaces. This is useful for producing
// documentation and other things.
// -----------------------------------------------------------------
void String::untabify() {
char *s;
char *c;
int pos;
int i;
int oldmaxsize;
// Copy the current string representation
s = str;
oldmaxsize = maxsize;
// Reset the internal state of this string
len = 0;
str = new char[maxsize];
str[0]= 0;
// Now walk down the old string and expand tabs. Tabs are usually place
// every 8 characters.
pos = 0;
c = s;
while (*c) {
if (*c == '\n') {
pos = -1;
}
if (*c == '\t') {
// Expand the character
for (i = 0; i < (8 - (pos % 8)); i++) {
this->add(' ');
}
pos+=(8-(pos % 8));
} else {
this->add(*c);
pos++;
}
c++;
}
// Blow away the old string
delete [] s;
}
// -----------------------------------------------------------------
// void String::replace(const char *token, const char *rep)
//
// Search for tokens in a string and replace them with rep.
// This probably isn't the fastest implementation, but fortunately
// SWIG rarely calls this function.
// -----------------------------------------------------------------
void String::replace(const char *token, const char *rep) {
char *s, *c, *t;
int oldmaxsize = maxsize;
// Copy the current string representation
s = str;
// Now walk down the old string and search for tokens
c = s;
t = strstr(c,token);
if (t) {
len = 0;
str = new char[maxsize];
while (t) {
// Found a token in string s
// Dump characters into our string
char temp;
temp = *t;
*t = 0;
this->add(c);
c = t;
*t = temp;
// Now dump the replacement string into place
this->add(rep);
// Jump over the token
c+=strlen(token);
t = strstr(c,token);
}
// Attach rest of the string
if (*c)
this->add(c);
delete [] s;
}
Replace(str,token,rep,DOH_REPLACE_ANY);
}
// -----------------------------------------------------------------
// void String::replaceid(char *token, char *rep)
//
// Searches for valid identifiers matching token and replaces
// them with rep. Unlike replace() tokens must be a valid C
// identifier (surrounded by whitespace).
// -----------------------------------------------------------------
void String::replaceid(const char *token, const char *rep) {
char *s, *c, *t;
int whitespace, tokenlen;
int oldmaxsize = maxsize;
// Copy the current string representation
s = str;
// Reset the internal state of this string
tokenlen = strlen(token);
// Now walk down the old string and search for tokens
c = s;
t = strstr(c,token);
if (t) {
len = 0;
str = new char[maxsize];
while (t) {
// Found a token in string s
// Dump characters into our string
whitespace = 1;
while (c != t) {
this->add(*c);
if (!(isalpha(*c) || (*c == '_') || (*c == '$'))) whitespace = 1;
else whitespace = 0;
c++;
}
if (whitespace) {
// Check to see if there is whitespace afterwards
if ((!c[tokenlen]) || (!(isalnum(c[tokenlen]) || (c[tokenlen] == '_') || (c[tokenlen] == '$')))) {
this->add(rep);
} else {
this->add(token);
}
c+=tokenlen;
} else {
this->add(*c);
c++;
}
t = strstr(c,token);
}
// Attach rest of the string
if (*c)
this->add(c);
// Delete the old string
delete [] s;
}
Replace(str,token,rep,DOH_REPLACE_ID);
}
// -----------------------------------------------------------------
// void String::strip()
//
@ -500,14 +193,12 @@ void String::replaceid(const char *token, const char *rep) {
// -----------------------------------------------------------------
void String::strip() {
char *s = str; // Old pointer value
DOH *so = str;
char *s = Char(so);
char *c, lastchar = 0;
int whitespace = 0;
int oldmaxsize = maxsize;
str = new char[maxsize];
len = 0;
str = NewString("");
c = s;
while(*c) {
if (!isspace(*c)) {
@ -515,10 +206,10 @@ void String::strip() {
if (whitespace) {
if (isalnum(lastchar) || (lastchar == '_') || (lastchar == '$')) {
if (isalnum(*c) || (*c == '_') || (*c == '$'))
this->add(' ');
Putc(' ', str);
}
}
this->add(*c);
Putc(*c,str);
lastchar = *c;
whitespace = 0;
} else {
@ -526,5 +217,8 @@ void String::strip() {
}
c++;
}
delete [] s;
Delete(so);
}

View file

@ -68,12 +68,7 @@ extern int Verbose;
class String {
private:
int maxsize; // Max size of current string
void add(const char *newstr); // Function to add a new string
void add(char c); // Add a character
void insert(const char *newstr);
int len;
char *str; // String data
void *str; // String object
public:
String();
String(const char *s);
@ -86,8 +81,6 @@ public:
friend String& operator>>(const char *s, String&);
friend String& operator>>(const String&,String&);
String& operator=(const char *);
operator char*() const { return str; }
void untabify();
void replace(const char *token, const char *rep);
void replaceid(const char *id, const char *rep);
void strip();
@ -96,9 +89,6 @@ public:
#define tab2 " "
#define tab4 " "
#define tab8 " "
#define br "\n"
#define endl "\n"
#define quote "\""
/************************************************************************
* class DataType

View file

@ -249,7 +249,7 @@ static char *typemap_string(char *lang, DataType *type, char *pname, char *ary,
str << lang << type->print_type() << pname << suffix;
type->status = old_status;
return str;
return str.get();
}
// ------------------------------------------------------------------------
@ -292,7 +292,7 @@ void typemap_register(char *op, char *lang, DataType *type, char *pname,
if (type_id < tm_old->last) {
sprintf(temp,"$%s",op);
tm->code.replace(temp,tm_old->code);
tm->code.replace(temp,tm_old->code.get());
}
// If found, we need to attach the old version to the new one
@ -525,12 +525,12 @@ static void typemap_locals(DataType *t, char *pname, String &s, ParmList *l, Wra
char temp_ip1 = tt->implicit_ptr;
tt->is_pointer = 0;
tt->implicit_ptr = 0;
new_name = f.new_local(tt->print_type(),str);
new_name = f.new_local(tt->print_type(),str.get());
tt->is_pointer = temp_ip;
tt->implicit_ptr = temp_ip1;
}
else
new_name = f.new_local(tt->print_full(),str);
new_name = f.new_local(tt->print_full(),str.get());
if (tt->arraystr) tt->is_pointer++;
// Substitute
@ -661,7 +661,7 @@ char *typemap_lookup_internal(char *op, char *lang, DataType *type, char *pname,
// Return character string
return str;
return str.get();
}
// ----------------------------------------------------------
@ -827,7 +827,7 @@ char *typemap_check_internal(char *op, char *lang, DataType *type, char *pname)
// Return character string
return str;
return str.get();
}
// Function for checking with applications
@ -982,7 +982,7 @@ void typemap_copy(char *op, char *lang, DataType *stype, char *sname,
SetVoid(typemap_hash,key, tn);
}
} else {
typemap_register(op,lang,ttype,tname,tm->code,tm->args);
typemap_register(op,lang,ttype,tname,tm->code.get(),tm->args);
}
}
@ -999,7 +999,7 @@ static char *fragment_string(char *op, char *lang) {
str = "";
str << "fragment:" << lang << op;
return str;
return str.get();
}
// ------------------------------------------------------------------------
@ -1027,7 +1027,7 @@ void fragment_register(char *op, char *lang, char *code) {
sprintf(temp,"$%s",op);
if (type_id < tm_old->last)
tm->code.replace(temp,tm_old->code);
tm->code.replace(temp,tm_old->code.get());
tm->next = tm_old;
tm_old->last = type_id;
@ -1074,7 +1074,7 @@ char *fragment_lookup(char *op, char *lang, int age) {
if (!tm) return 0;
str << tm->code;
return str;
return str.get();
}
// ------------------------------------------------------------------------

View file

@ -400,7 +400,7 @@ char *DataType::get_dimension(int n) {
char *c;
dim = "";
if (n >= array_dimensions()) return dim;
if (n >= array_dimensions()) return dim.get();
// Attemp to locate the right dimension
@ -417,7 +417,7 @@ char *DataType::get_dimension(int n) {
c++;
}
}
return dim;
return dim.get();
}
// --------------------------------------------------------------------
@ -499,8 +499,8 @@ void DataType::typedef_add(char *tname, int mode) {
strcpy(t1.name,tname);
name2 << t1.print_mangle();
name1 << print_mangle();
typeeq_addtypedef(name1,name2,&t1);
typeeq_addtypedef(name2,name1,this);
typeeq_addtypedef(name1.get(),name2.get(),&t1);
typeeq_addtypedef(name2.get(),name1.get(),this);
}
}
// Call into the target language with this typedef
@ -583,7 +583,7 @@ void DataType::typedef_replace () {
delete arraystr;
}
temp << td->arraystr;
arraystr = copy_string(temp);
arraystr = copy_string(temp.get());
}
}
// Not found, do nothing
@ -939,7 +939,7 @@ void typeeq_derived(char *n1, char *n2, char *cast=0) {
strcpy(t1.name,n2);
name << t.print_mangle();
name2 << t1.print_mangle();
typeeq_add(name,name2,cast, &t1);
typeeq_add(name.get(),name2.get(),cast, &t1);
}
// ------------------------------------------------------------------------------
@ -958,7 +958,7 @@ void typeeq_mangle(char *n1, char *n2, char *cast=0) {
strcpy(t1.name,n2);
name << t.print_mangle();
name2 << t1.print_mangle();
typeeq_add(name,name2,cast);
typeeq_add(name.get(),name2.get(),cast);
}
// ------------------------------------------------------------------------------

View file

@ -215,7 +215,7 @@ char *WrapperFunction::new_local(char *type, char *name, char *defarg) {
while ((isalnum(*c) || (*c == '_') || (*c == '$')) && (*c))
c++;
*c = 0;
return new_name;
return new_name.get();
}
// ------------------------------------------------------------------