C++ String class and all operator overloading removed.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@551 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f5d582988f
commit
d9535328a1
14 changed files with 556 additions and 723 deletions
|
|
@ -199,7 +199,7 @@ void RUBY::parse() {
|
|||
void RUBY::set_module(char *mod_name, char **mod_list) {
|
||||
if (import_file) {
|
||||
Printf(f_init, "%srb_f_require(Qnil, rb_str_new2(\"%s\"));\n", tab4, mod_name);
|
||||
delete [] import_file;
|
||||
free(import_file); // Note: was allocated from C
|
||||
import_file = 0;
|
||||
}
|
||||
|
||||
|
|
@ -450,18 +450,18 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
int vararg = (numoptreal != 0);
|
||||
|
||||
// Now write the wrapper function itself
|
||||
Printv(f._def, "static VALUE\n", wname, "(", 0);
|
||||
Printv(f.def, "static VALUE\n", wname, "(", 0);
|
||||
if (vararg) {
|
||||
Printv(f._def, "int argc, VALUE *argv, VALUE self",0);
|
||||
Printv(f.def, "int argc, VALUE *argv, VALUE self",0);
|
||||
} else {
|
||||
Printv(f._def, "VALUE self", 0);
|
||||
Printv(f.def, "VALUE self", 0);
|
||||
for (i = start; i < l->nparms; i++) {
|
||||
if (!l->get(i)->ignore) {
|
||||
Printf(f._def,", VALUE varg%d", i);
|
||||
Printf(f.def,", VALUE varg%d", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Printf(f._def,") {");
|
||||
Printf(f.def,") {");
|
||||
|
||||
// Emit all of the local variables for holding arguments.
|
||||
if (vararg) {
|
||||
|
|
@ -494,13 +494,13 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
#endif
|
||||
// Emit count to check the number of arguments
|
||||
if (vararg) {
|
||||
Printf(f._code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal);
|
||||
Printf(f.code," rb_scan_args(argc, argv, \"%d%d\"", (numarg-numoptreal), numoptreal);
|
||||
for (i = start; i < l->nparms; i++) {
|
||||
if (!l->get(i)->ignore) {
|
||||
Printf(f._code,", &varg%d", i);
|
||||
Printf(f.code,", &varg%d", i);
|
||||
}
|
||||
}
|
||||
Printf(f._code,");\n");
|
||||
Printf(f.code,");\n");
|
||||
}
|
||||
|
||||
// Now walk the function parameter list and generate code
|
||||
|
|
@ -522,7 +522,7 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (!p.ignore) {
|
||||
char *tab = (char*)tab4;
|
||||
if (j >= (pcount-numopt)) { // Check if parsing an optional argument
|
||||
Printf(f._code," if (argc > %d) {\n", j - start);
|
||||
Printf(f.code," if (argc > %d) {\n", j - start);
|
||||
tab = (char*)tab8;
|
||||
}
|
||||
|
||||
|
|
@ -531,15 +531,15 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s,tab);
|
||||
Printv(f._code, s, "\n", 0);
|
||||
Replace(f._code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Printv(f.code, s, "\n", 0);
|
||||
Replace(f.code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Delete(s);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. No typemapping for datatype %s\n",
|
||||
input_file,line_number, p.t->print_type());
|
||||
}
|
||||
if (j >= (pcount-numopt))
|
||||
Printv(f._code, tab4, "} \n");
|
||||
Printv(f.code, tab4, "} \n");
|
||||
j++;
|
||||
}
|
||||
|
||||
|
|
@ -548,8 +548,8 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code, s, "\n", 0);
|
||||
Replace(f._code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Printv(f.code, s, "\n", 0);
|
||||
Replace(f.code, "$arg", source, DOH_REPLACE_ANY);
|
||||
Delete(s);
|
||||
}
|
||||
|
||||
|
|
@ -579,13 +579,13 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
// Return value if necessary
|
||||
if ((t->type != T_VOID) || (t->is_pointer)) {
|
||||
if (predicate) {
|
||||
Printv(f._code, tab4, "vresult = (_result ? Qtrue : Qfalse);\n", 0);
|
||||
Printv(f.code, tab4, "vresult = (_result ? Qtrue : Qfalse);\n", 0);
|
||||
} else {
|
||||
tm = ruby_typemap_lookup((char*)"out",t,name,(char*)"_result",(char*)"vresult");
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code, s, "\n", 0);
|
||||
Printv(f.code, s, "\n", 0);
|
||||
Delete(s);
|
||||
} else {
|
||||
Printf(stderr,"%s : Line %d. No return typemap for datatype %s\n",
|
||||
|
|
@ -595,10 +595,10 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
}
|
||||
|
||||
// Dump argument output code;
|
||||
Printv(f._code,outarg,0);
|
||||
Printv(f.code,outarg,0);
|
||||
|
||||
// Dump the argument cleanup code
|
||||
Printv(f._code,cleanup,0);
|
||||
Printv(f.code,cleanup,0);
|
||||
|
||||
// Look for any remaining cleanup. This processes the %new directive
|
||||
if (NewObject) {
|
||||
|
|
@ -606,14 +606,14 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code,s,"\n", 0);
|
||||
Printv(f.code,s,"\n", 0);
|
||||
Delete(s);
|
||||
}
|
||||
}
|
||||
|
||||
// free pragma
|
||||
if (current == MEMBER_FUNC && Getattr(klass->freemethods, mname)) {
|
||||
Printv(f._code, tab4, "DATA_PTR(self) = 0;\n", 0);
|
||||
Printv(f.code, tab4, "DATA_PTR(self) = 0;\n", 0);
|
||||
}
|
||||
|
||||
// Special processing on return value.
|
||||
|
|
@ -621,14 +621,14 @@ void RUBY::create_function(char *name, char *iname, DataType *t, ParmList *l) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(f._code,s,"\n", 0);
|
||||
Printv(f.code,s,"\n", 0);
|
||||
}
|
||||
|
||||
// Wrap things up (in a manner of speaking)
|
||||
Printv(f._code, tab4, "return vresult;\n}\n", 0);
|
||||
Printv(f.code, tab4, "return vresult;\n}\n", 0);
|
||||
|
||||
// Substitute the cleanup code
|
||||
Replace(f._code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
Replace(f.code,"$cleanup",cleanup, DOH_REPLACE_ANY);
|
||||
|
||||
// Emit the function
|
||||
f.print(f_wrappers);
|
||||
|
|
@ -661,9 +661,9 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
// create getter
|
||||
getfname = NewString(Swig_name_get(name));
|
||||
Replace(getfname,"::", "_", DOH_REPLACE_ANY); /* FIXME: Swig_name_get bug? */
|
||||
Printv(getf._def, "static VALUE\n", getfname, "(", 0);
|
||||
if (mod_attr) Printf(getf._def, "VALUE self");
|
||||
Printf(getf._def, ") {");
|
||||
Printv(getf.def, "static VALUE\n", getfname, "(", 0);
|
||||
if (mod_attr) Printf(getf.def, "VALUE self");
|
||||
Printf(getf.def, ") {");
|
||||
getf.add_local((char*)"VALUE", (char*)"_val");
|
||||
tm = ruby_typemap_lookup((char*)"varout",t,name,name,(char*)"_val");
|
||||
if (!tm)
|
||||
|
|
@ -671,20 +671,20 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(getf._code,s,"\n", 0);
|
||||
Printv(getf.code,s,"\n", 0);
|
||||
Delete(s);
|
||||
} else if (!t->is_pointer && t->type == T_USER) {
|
||||
// Hack this into a pointer
|
||||
t->is_pointer++;
|
||||
t->remember();
|
||||
Printv(getf._code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
|
||||
Printv(getf.code, tab4, "_val = SWIG_NewPointerObj((void *)&", name,
|
||||
", \"", t->print_mangle(), "\");\n", 0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
||||
input_file,line_number,t->print_type());
|
||||
}
|
||||
Printv(getf._code, tab4, "return _val;\n}\n", 0);
|
||||
Printv(getf.code, tab4, "return _val;\n}\n", 0);
|
||||
getf.print(f_wrappers);
|
||||
|
||||
if (Status & STAT_READONLY) {
|
||||
|
|
@ -694,33 +694,33 @@ void RUBY::link_variable(char *name, char *iname, DataType *t) {
|
|||
setfname = NewString(Swig_name_set(name));
|
||||
Replace(setfname,"::", "_", DOH_REPLACE_ANY); /* FIXME: Swig_name_get bug? */
|
||||
if (mod_attr)
|
||||
Printv(setf._def, "static VALUE\n", setfname, "(VALUE self, ", 0);
|
||||
Printv(setf.def, "static VALUE\n", setfname, "(VALUE self, ", 0);
|
||||
else
|
||||
Printv(setf._def, "static void\n", setfname, "(", 0);
|
||||
Printf(setf._def, "VALUE _val) {");
|
||||
Printv(setf.def, "static void\n", setfname, "(", 0);
|
||||
Printf(setf.def, "VALUE _val) {");
|
||||
tm = ruby_typemap_lookup((char*)"varin",t,name,(char*)"_val",name);
|
||||
if (!tm)
|
||||
tm = ruby_typemap_lookup((char*)"in",t,name,(char*)"_val",name);
|
||||
if (tm) {
|
||||
DOHString *s = NewString(tm);
|
||||
indent(s);
|
||||
Printv(setf._code,s,"\n",0);
|
||||
Printv(setf.code,s,"\n",0);
|
||||
Delete(s);
|
||||
} else if (!t->is_pointer && t->type == T_USER) {
|
||||
t->is_pointer++;
|
||||
setf.add_local(t->print_type(), (char*)"temp");
|
||||
Printv(setf._code, tab4, "temp = (", t->print_type(), ")",
|
||||
Printv(setf.code, tab4, "temp = (", t->print_type(), ")",
|
||||
"SWIG_ConvertPtr(_val, \"", t->print_mangle(), "\");\n",
|
||||
0);
|
||||
Printv(setf._code, tab4, name, " = *temp;\n",0);
|
||||
Printv(setf.code, tab4, name, " = *temp;\n",0);
|
||||
t->is_pointer--;
|
||||
} else {
|
||||
Printf(stderr,"%s: Line %d. Unable to link with variable type %s\n",
|
||||
input_file,line_number,t->print_type());
|
||||
}
|
||||
if (mod_attr)
|
||||
Printv(setf._code, tab4, "return _val;\n",0);
|
||||
Printf(setf._code,"}\n");
|
||||
Printv(setf.code, tab4, "return _val;\n",0);
|
||||
Printf(setf.code,"}\n");
|
||||
setf.print(f_wrappers);
|
||||
}
|
||||
|
||||
|
|
@ -1382,8 +1382,8 @@ void RUBY::cpp_pragma(Pragma *plist) {
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
void RUBY::import(char *filename) {
|
||||
if (import_file) delete [] import_file;
|
||||
import_file = copy_string(filename);
|
||||
if (import_file) free(import_file);
|
||||
import_file = Swig_copy_string(filename);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue