(guile_usage): Remove usage info for "-with-smobs" option.

(GUILE::GUILE, GUILE::parse_args): No longer set `with_smobs'.

(GUILE::get_pointer, GUILE::create_function, GUILE::link_variable):
Make `with_smobs' branch unconditional.  Remove code in `!with_smobs'
branch.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@527 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Thien-Thi Nguyen 2000-07-06 21:51:37 +00:00
commit bff6667f73

View file

@ -31,7 +31,6 @@ Guile Options (available with -guile)\n\
-module name - Set base name of module\n\ -module name - Set base name of module\n\
-prefix name - Use NAME as prefix [default \"gswig_\"]\n\ -prefix name - Use NAME as prefix [default \"gswig_\"]\n\
-package name - Set the path of the module [default NULL]\n\ -package name - Set the path of the module [default NULL]\n\
-with-smobs - Represent SWIG objects as smobs\n\
-Linkage lstyle - Use linkage protocol LSTYLE [default `ltdlmod']\n\ -Linkage lstyle - Use linkage protocol LSTYLE [default `ltdlmod']\n\
\n\ \n\
The module option does not create a guile module with a separate name\n\ The module option does not create a guile module with a separate name\n\
@ -61,7 +60,6 @@ GUILE::GUILE ()
module = NULL; module = NULL;
package = NULL; package = NULL;
linkage = GUILE_LSTYLE_SIMPLE; linkage = GUILE_LSTYLE_SIMPLE;
with_smobs = 0;
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -84,10 +82,6 @@ GUILE::parse_args (int argc, char *argv[])
fputs (guile_usage, stderr); fputs (guile_usage, stderr);
SWIG_exit (0); SWIG_exit (0);
} }
else if (strcmp (argv[i], "-with-smobs") == 0) {
Swig_mark_arg (i);
with_smobs = 1;
}
else if (strcmp (argv[i], "-prefix") == 0) { else if (strcmp (argv[i], "-prefix") == 0) {
if (argv[i + 1]) { if (argv[i + 1]) {
prefix = new char[strlen (argv[i + 1]) + 2]; prefix = new char[strlen (argv[i + 1]) + 2];
@ -355,36 +349,18 @@ GUILE::get_pointer (char *iname, int parm, DataType *t,
WrapperFunction &f, const String &proc_name, WrapperFunction &f, const String &proc_name,
int num_scheme_parm) int num_scheme_parm)
{ {
if (with_smobs) { /* Pointers are smobs */
/* Pointers are smobs */ f.code << tab4 << "if (SWIG_Guile_GetPtr_Str(s_" << parm << ", "
f.code << tab4 << "if (SWIG_Guile_GetPtr_Str(s_" << parm << ", " << "(void **) &_arg" << parm;
<< "(void **) &_arg" << parm; if (t->type == T_VOID)
if (t->type == T_VOID) f.code << ", (char *) 0)) {\n";
f.code << ", (char *) 0)) {\n"; else
else f.code << ", \"" << t->print_mangle() << "\")) {\n";
f.code << ", \"" << t->print_mangle() << "\")) {\n"; /* Raise exception */
/* Raise exception */ f.code << tab8
f.code << tab8 << "scm_wrong_type_arg(\"" << proc_name << "\", "
<< "scm_wrong_type_arg(\"" << proc_name << "\", " << num_scheme_parm << ", s_" << parm << ");\n";
<< num_scheme_parm << ", s_" << parm << ");\n"; f.code << tab4 << "}\n";
f.code << tab4 << "}\n";
}
else {
// Pointers are read as hex-strings with encoded type information
f.code << tab4 << "_tempc = gh_scm2newstr (s_" << parm << ", &_len);\n";
f.code << tab4 << "if (SWIG_GetPtr (_tempc, (void **) &_arg" << parm;
if (t->type == T_VOID)
f.code << ", (char *) 0)) {\n";
else
f.code << ", \"" << t->print_mangle() << "\")) {\n";
/* Raise exception */
f.code << tab8
<< "scm_wrong_type_arg(\"" << proc_name << "\", "
<< num_scheme_parm << ", s_" << parm << ");\n";
f.code << tab4 << "}\n";
f.code << tab4 << "free(_tempc);\n";
}
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -476,10 +452,6 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
int numargs = 0; int numargs = 0;
int numopt = 0; int numopt = 0;
if (!with_smobs) {
f.add_local ((char*)"int", (char*)"_len");
f.add_local ((char*)"char *", (char*)"_tempc");
}
f.add_local ((char*)"SCM", (char*)"gswig_result"); f.add_local ((char*)"SCM", (char*)"gswig_result");
// Now write code to extract the parameters (this is super ugly) // Now write code to extract the parameters (this is super ugly)
@ -560,25 +532,14 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
mreplace (f.code, argnum, arg, proc_name); mreplace (f.code, argnum, arg, proc_name);
} }
else if (d->is_pointer) { else if (d->is_pointer) {
if (with_smobs) { /* MK: I would like to use SWIG_Guile_MakePtr here to save one type
/* MK: I would like to use SWIG_Guile_MakePtr here to save one type look-up. */
look-up. */
f.code << tab4
<< "gswig_result = SWIG_Guile_MakePtr_Str ("
<< "_result, "
<< "\"" << d->print_mangle() << "\", "
<< "\"" << d->print_type() << "\""
<< ");\n";
}
else {
f.add_local ((char*)"char", (char*)"_ptemp[128]");
f.code << tab4 f.code << tab4
<< "SWIG_MakePtr (_ptemp, _result,\"" << "gswig_result = SWIG_Guile_MakePtr_Str ("
<< d->print_mangle() << "_result, "
<< "\");\n"; << "\"" << d->print_mangle() << "\", "
f.code << tab4 << "\"" << d->print_type() << "\""
<< "gswig_result = gh_str02scm (_ptemp);\n"; << ");\n";
}
} }
else { else {
throw_unhandled_guile_type_error (d); throw_unhandled_guile_type_error (d);
@ -666,18 +627,9 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
fprintf (f_wrappers, "SCM %s(SCM s_0) {\n", var_name); fprintf (f_wrappers, "SCM %s(SCM s_0) {\n", var_name);
if (with_smobs) { if (!(Status & STAT_READONLY) && t->type == T_CHAR && t->is_pointer==1) {
if (!(Status & STAT_READONLY) && t->type == T_CHAR && t->is_pointer==1) { fprintf (f_wrappers, "\t char *_temp;\n");
fprintf (f_wrappers, "\t char *_temp;\n"); fprintf (f_wrappers, "\t int _len;\n");
fprintf (f_wrappers, "\t int _len;\n");
}
}
else {
if ((t->type == T_CHAR) || (t->is_pointer)){
fprintf (f_wrappers, "\t char _ptemp[128];\n");
fprintf (f_wrappers, "\t char *_temp;\n");
fprintf (f_wrappers, "\t int _len;\n");
}
} }
fprintf (f_wrappers, "\t SCM gswig_result;\n"); fprintf (f_wrappers, "\t SCM gswig_result;\n");
@ -706,16 +658,9 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
fprintf (f_wrappers, "\t\t %s[_len] = 0;\n", name); fprintf (f_wrappers, "\t\t %s[_len] = 0;\n", name);
} else { } else {
// Set the value of a pointer // Set the value of a pointer
if (with_smobs) { /* MK: I would like to use SWIG_Guile_GetPtr here */
/* MK: I would like to use SWIG_Guile_GetPtr here */ fprintf (f_wrappers, "\t if (SWIG_Guile_GetPtr_Str(s_0, "
fprintf (f_wrappers, "\t if (SWIG_Guile_GetPtr_Str(s_0, " "(void **) &%s, ", name);
"(void **) &%s, ", name);
}
else {
fprintf (f_wrappers, "\t\t _temp = gh_scm2newstr(s_0,&_len);\n");
fprintf (f_wrappers, "\t if (SWIG_GetPtr(_temp, (void **) &%s,",
name);
}
if (t->type == T_VOID) if (t->type == T_VOID)
fprintf (f_wrappers, "(char *) 0)) {\n"); fprintf (f_wrappers, "(char *) 0)) {\n");
else else
@ -743,17 +688,11 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
fprintf (f_wrappers, "\t gswig_result = gh_str02scm(%s);\n", name); fprintf (f_wrappers, "\t gswig_result = gh_str02scm(%s);\n", name);
} else { } else {
// Is an ordinary pointer type. // Is an ordinary pointer type.
if (with_smobs) { /* MK: I would like to use SWIG_Guile_MakePtr here to save one type
/* MK: I would like to use SWIG_Guile_MakePtr here to save one type look-up. */
look-up. */ fprintf (f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr_Str ("
fprintf(f_wrappers, "\t gswig_result = SWIG_Guile_MakePtr_Str (" "%s, \"%s\", \"%s\");\n", name, t->print_mangle(),
"%s, \"%s\", \"%s\");\n", name, t->print_mangle(), t->print_type()); t->print_type());
}
else {
fprintf (f_wrappers, "\t SWIG_MakePtr(_ptemp, %s,\"%s\");\n",
name, t->print_mangle());
fprintf (f_wrappers, "\t gswig_result = gh_str02scm(_ptemp);\n");
}
} }
} }
else { else {