New Guile command-line argument "-procdoc", specifying procedure

documentation output file.
Fixed "-Linkage" parsing.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@715 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Matthias Köppe 2000-08-29 12:05:01 +00:00
commit aeba1f7c50
3 changed files with 63 additions and 38 deletions

View file

@ -10,7 +10,7 @@
%typemap (guile, varin) C_NAME "$target = SCM_TO_C($source);"; \
%typemap (guile, out) C_NAME "$target = C_TO_SCM($source);"; \
%typemap (guile, varout) C_NAME "$target = C_TO_SCM($source);"; \
%typemap (guile, indoc) C_NAME "($ARG <SCM_NAME>)"; \
%typemap (guile, indoc) C_NAME "($arg <SCM_NAME>)"; \
%typemap (guile, outdoc) C_NAME "<SCM_NAME>"; \
%typemap (guile, in) C_NAME *INPUT (C_NAME temp) \
{ temp = (C_NAME) C_TO_SCM($source); $target = &temp; } \
@ -19,7 +19,7 @@
{ $target = &temp; } \
%typemap (guile, argout) C_NAME *OUTPUT \
"GUILE_APPEND_RESULT(C_TO_SCM(*$target));"; \
%typemap (guile, argoutdoc) C_NAME *OUTPUT "($ARG <SCM_NAME>)"; \
%typemap (guile, argoutdoc) C_NAME *OUTPUT "($arg <SCM_NAME>)"; \
%typemap (guile, in) C_NAME *BOTH = C_NAME *INPUT; \
%typemap (guile, indoc) C_NAME *BOTH = C_NAME *INPUT; \
%typemap (guile, argout) C_NAME *BOTH = C_NAME *OUTPUT; \

View file

@ -32,6 +32,7 @@ Guile Options (available with -guile)\n\
-prefix name - Use NAME as prefix [default \"gswig_\"]\n\
-package name - Set the path of the module [default NULL]\n\
-Linkage lstyle - Use linkage protocol LSTYLE [default `ltdlmod']\n\
-procdoc file - Output procedure documentation to file\n\
\n\
The module option does not create a guile module with a separate name\n\
space. It specifies the name of the initialization function and is\n\
@ -57,6 +58,7 @@ GUILE::GUILE ()
module = NULL;
package = NULL;
linkage = GUILE_LSTYLE_SIMPLE;
procdoc = NULL;
}
// ---------------------------------------------------------------------
@ -130,11 +132,21 @@ GUILE::parse_args (int argc, char *argv[])
Swig_arg_error ();
Swig_mark_arg (i);
Swig_mark_arg (i + 1);
i += 2;
i++;
} else {
Swig_arg_error();
}
}
else if (strcmp (argv[i], "-procdoc") == 0) {
if (argv[i + 1]) {
procdoc = NewFile(argv[i + 1], "w");
Swig_mark_arg (i);
Swig_mark_arg (i + 1);
i++;
} else {
Swig_arg_error();
}
}
}
}
@ -330,6 +342,11 @@ GUILE::close (void)
strcpy(module_name,module);
}
emit_linkage (module_name);
if (procdoc) {
Delete(procdoc);
procdoc = NULL;
}
}
// ----------------------------------------------------------------------
@ -406,8 +423,6 @@ guile_do_typemap(DOHFile *file, const char *op,
sprintf(argnum_s, "%d", argnum);
Replace(s,"$argnum", argnum_s, DOH_REPLACE_ANY);
Replace(s,"$arg", arg, DOH_REPLACE_ANY);
/* FIXME: Produce all-uppercase version of arg */
Replace(s,"$ARG", arg, DOH_REPLACE_ANY);
Replace(s,"$name", name, DOH_REPLACE_ANY);
if (nonewline_p)
Printv(file, s, 0);
@ -491,13 +506,15 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Wrapper_add_local (f,"gswig_result", "SCM gswig_result");
if (!guile_do_typemap(returns, "outdoc", d, name,
(char*)"result", (char*)"gswig_result",
0, proc_name, f, 1)) {
String *s = NewString(SwigType_str(d, 0));
Chop(s);
Printf(returns, "<%s>", s);
Delete(s);
if (procdoc) {
if (!guile_do_typemap(returns, "outdoc", d, name,
(char*)"result", (char*)"gswig_result",
0, proc_name, f, 1)) {
String *s = NewString(SwigType_str(d, 0));
Chop(s);
Printf(returns, "<%s>", s);
Delete(s);
}
}
/* Now write code to extract the parameters */
@ -528,14 +545,16 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
else {
throw_unhandled_guile_type_error (pt);
}
/* Add to signature */
Printf(signature, " ");
if (!guile_do_typemap(signature, "indoc", pt, pn,
source, target, numargs, proc_name, f, 1)) {
String *s = NewString(SwigType_str(pt, 0));
Chop(s);
Printf(signature, "(%s <%s>)", pn, s);
Delete(s);
if (procdoc) {
/* Add to signature */
Printf(signature, " ");
if (!guile_do_typemap(signature, "indoc", pt, pn,
source, target, numargs, proc_name, f, 1)) {
String *s = NewString(SwigType_str(pt, 0));
Chop(s);
Printf(signature, "(%s <%s>)", pn, s);
Delete(s);
}
}
}
@ -549,16 +568,18 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
guile_do_typemap(outarg, "argout", pt, pn,
source, target, numargs, proc_name, f, 0);
/* Document output arguments */
Clear(tmp);
if (guile_do_typemap(tmp, "argoutdoc", pt, pn,
source, target, numargs, proc_name, f, 1)) {
if (Len(returns) == 0) { /* unspecified -> singleton */
Printv(returns, tmp, 0);
}
else { /* append to list */
Printv(returns, " ", tmp, 0);
returns_list = 1;
if (procdoc) {
/* Document output arguments */
Clear(tmp);
if (guile_do_typemap(tmp, "argoutdoc", pt, pn,
source, target, numargs, proc_name, f, 1)) {
if (Len(returns) == 0) { /* unspecified -> singleton */
Printv(returns, tmp, 0);
}
else { /* append to list */
Printv(returns, " ", tmp, 0);
returns_list = 1;
}
}
}
@ -636,13 +657,15 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Printf (f_init, "\t gh_new_procedure(\"%s\", %s, %d, %d, 0);\n",
proc_name, wname, numargs-numopt, numopt);
}
/* Register procedure documentation */
Printv(signature, "Returns ", 0);
if (Len(returns)==0) Printv(signature, "unspecified", 0);
else if (returns_list) Printv(signature, "list (", returns, ")", 0);
else Printv(signature, returns, 0);
Printv(signature, "\n", 0);
printf("%s\n", Char(signature));
if (procdoc) {
/* Write out procedure documentation */
Printv(signature, "Returns ", 0);
if (Len(returns)==0) Printv(signature, "unspecified", 0);
else if (returns_list) Printv(signature, "list (", returns, ")", 0);
else Printv(signature, returns, 0);
Printv(signature, "\n", 0);
Printv(procdoc, "\f\n", signature, 0);
}
Delete(proc_name);
Delete(outarg);

View file

@ -19,10 +19,11 @@
* class GUILE
*
* Guile implementation
* (Caution : This is *somewhat* experimental)
*
**************************************************************************/
#include "swig.h"
class GUILE : public Language
{
private:
@ -34,6 +35,7 @@ private:
GUILE_LSTYLE_LTDLMOD, // "native" guile?
GUILE_LSTYLE_HOBBIT // use (hobbit4d link)
} linkage;
File *procdoc;
void emit_linkage(char *module_name);
public :