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,7 +132,17 @@ 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 {
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 { } else {
Swig_arg_error(); 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,6 +506,7 @@ 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 (procdoc) {
if (!guile_do_typemap(returns, "outdoc", d, name, if (!guile_do_typemap(returns, "outdoc", d, name,
(char*)"result", (char*)"gswig_result", (char*)"result", (char*)"gswig_result",
0, proc_name, f, 1)) { 0, proc_name, f, 1)) {
@ -499,6 +515,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Printf(returns, "<%s>", s); Printf(returns, "<%s>", s);
Delete(s); Delete(s);
} }
}
/* Now write code to extract the parameters */ /* Now write code to extract the parameters */
@ -528,6 +545,7 @@ 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);
} }
if (procdoc) {
/* Add to signature */ /* Add to signature */
Printf(signature, " "); Printf(signature, " ");
if (!guile_do_typemap(signature, "indoc", pt, pn, if (!guile_do_typemap(signature, "indoc", pt, pn,
@ -538,6 +556,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Delete(s); Delete(s);
} }
} }
}
/* Check if there are any constraints. */ /* Check if there are any constraints. */
@ -549,6 +568,7 @@ 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);
if (procdoc) {
/* Document output arguments */ /* Document output arguments */
Clear(tmp); Clear(tmp);
if (guile_do_typemap(tmp, "argoutdoc", pt, pn, if (guile_do_typemap(tmp, "argoutdoc", pt, pn,
@ -561,6 +581,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
returns_list = 1; returns_list = 1;
} }
} }
}
// free up any memory allocated for the arguments. // free up any memory allocated for the arguments.
@ -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) {
/* Write out procedure documentation */
Printv(signature, "Returns ", 0); Printv(signature, "Returns ", 0);
if (Len(returns)==0) Printv(signature, "unspecified", 0); if (Len(returns)==0) Printv(signature, "unspecified", 0);
else if (returns_list) Printv(signature, "list (", returns, ")", 0); else if (returns_list) Printv(signature, "list (", returns, ")", 0);
else Printv(signature, returns, 0); else Printv(signature, returns, 0);
Printv(signature, "\n", 0); Printv(signature, "\n", 0);
printf("%s\n", Char(signature)); 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 :