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@715 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Matthias Köppe 2000-08-29 12:05:01 +00:00
commit 006146b8f0
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, varin) C_NAME "$target = SCM_TO_C($source);"; \
%typemap (guile, out) C_NAME "$target = C_TO_SCM($source);"; \ %typemap (guile, out) C_NAME "$target = C_TO_SCM($source);"; \
%typemap (guile, varout) 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, outdoc) C_NAME "<SCM_NAME>"; \
%typemap (guile, in) C_NAME *INPUT (C_NAME temp) \ %typemap (guile, in) C_NAME *INPUT (C_NAME temp) \
{ temp = (C_NAME) C_TO_SCM($source); $target = &temp; } \ { temp = (C_NAME) C_TO_SCM($source); $target = &temp; } \
@ -19,7 +19,7 @@
{ $target = &temp; } \ { $target = &temp; } \
%typemap (guile, argout) C_NAME *OUTPUT \ %typemap (guile, argout) C_NAME *OUTPUT \
"GUILE_APPEND_RESULT(C_TO_SCM(*$target));"; \ "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, in) C_NAME *BOTH = C_NAME *INPUT; \
%typemap (guile, indoc) C_NAME *BOTH = C_NAME *INPUT; \ %typemap (guile, indoc) C_NAME *BOTH = C_NAME *INPUT; \
%typemap (guile, argout) C_NAME *BOTH = C_NAME *OUTPUT; \ %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\ -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\
-Linkage lstyle - Use linkage protocol LSTYLE [default `ltdlmod']\n\ -Linkage lstyle - Use linkage protocol LSTYLE [default `ltdlmod']\n\
-procdoc file - Output procedure documentation to file\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\
space. It specifies the name of the initialization function and is\n\ space. It specifies the name of the initialization function and is\n\
@ -57,6 +58,7 @@ GUILE::GUILE ()
module = NULL; module = NULL;
package = NULL; package = NULL;
linkage = GUILE_LSTYLE_SIMPLE; linkage = GUILE_LSTYLE_SIMPLE;
procdoc = NULL;
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -130,11 +132,21 @@ GUILE::parse_args (int argc, char *argv[])
Swig_arg_error (); Swig_arg_error ();
Swig_mark_arg (i); Swig_mark_arg (i);
Swig_mark_arg (i + 1); Swig_mark_arg (i + 1);
i += 2; i++;
} else { } else {
Swig_arg_error(); 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); strcpy(module_name,module);
} }
emit_linkage (module_name); 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); sprintf(argnum_s, "%d", argnum);
Replace(s,"$argnum", argnum_s, DOH_REPLACE_ANY); Replace(s,"$argnum", argnum_s, DOH_REPLACE_ANY);
Replace(s,"$arg", arg, 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); Replace(s,"$name", name, DOH_REPLACE_ANY);
if (nonewline_p) if (nonewline_p)
Printv(file, s, 0); 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"); Wrapper_add_local (f,"gswig_result", "SCM gswig_result");
if (!guile_do_typemap(returns, "outdoc", d, name, if (procdoc) {
(char*)"result", (char*)"gswig_result", if (!guile_do_typemap(returns, "outdoc", d, name,
0, proc_name, f, 1)) { (char*)"result", (char*)"gswig_result",
String *s = NewString(SwigType_str(d, 0)); 0, proc_name, f, 1)) {
Chop(s); String *s = NewString(SwigType_str(d, 0));
Printf(returns, "<%s>", s); Chop(s);
Delete(s); Printf(returns, "<%s>", s);
Delete(s);
}
} }
/* Now write code to extract the parameters */ /* Now write code to extract the parameters */
@ -528,14 +545,16 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
else { else {
throw_unhandled_guile_type_error (pt); throw_unhandled_guile_type_error (pt);
} }
/* Add to signature */ if (procdoc) {
Printf(signature, " "); /* Add to signature */
if (!guile_do_typemap(signature, "indoc", pt, pn, Printf(signature, " ");
source, target, numargs, proc_name, f, 1)) { if (!guile_do_typemap(signature, "indoc", pt, pn,
String *s = NewString(SwigType_str(pt, 0)); source, target, numargs, proc_name, f, 1)) {
Chop(s); String *s = NewString(SwigType_str(pt, 0));
Printf(signature, "(%s <%s>)", pn, s); Chop(s);
Delete(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, guile_do_typemap(outarg, "argout", pt, pn,
source, target, numargs, proc_name, f, 0); source, target, numargs, proc_name, f, 0);
/* Document output arguments */ if (procdoc) {
Clear(tmp); /* Document output arguments */
if (guile_do_typemap(tmp, "argoutdoc", pt, pn, Clear(tmp);
source, target, numargs, proc_name, f, 1)) { if (guile_do_typemap(tmp, "argoutdoc", pt, pn,
if (Len(returns) == 0) { /* unspecified -> singleton */ source, target, numargs, proc_name, f, 1)) {
Printv(returns, tmp, 0); if (Len(returns) == 0) { /* unspecified -> singleton */
} Printv(returns, tmp, 0);
else { /* append to list */ }
Printv(returns, " ", tmp, 0); else { /* append to list */
returns_list = 1; 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", Printf (f_init, "\t gh_new_procedure(\"%s\", %s, %d, %d, 0);\n",
proc_name, wname, numargs-numopt, numopt); proc_name, wname, numargs-numopt, numopt);
} }
/* Register procedure documentation */ if (procdoc) {
Printv(signature, "Returns ", 0); /* Write out procedure documentation */
if (Len(returns)==0) Printv(signature, "unspecified", 0); Printv(signature, "Returns ", 0);
else if (returns_list) Printv(signature, "list (", returns, ")", 0); if (Len(returns)==0) Printv(signature, "unspecified", 0);
else Printv(signature, returns, 0); else if (returns_list) Printv(signature, "list (", returns, ")", 0);
Printv(signature, "\n", 0); else Printv(signature, returns, 0);
printf("%s\n", Char(signature)); Printv(signature, "\n", 0);
Printv(procdoc, "\f\n", signature, 0);
}
Delete(proc_name); Delete(proc_name);
Delete(outarg); Delete(outarg);

View file

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