File insertion now data-driven via %insert.

Using %define for multiline defines.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@721 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Matthias Köppe 2000-08-30 08:50:06 +00:00
commit 74ac578ba8
3 changed files with 29 additions and 33 deletions

View file

@ -2,6 +2,13 @@
This file is parsed by SWIG before reading any other interface
file. */
/* Include headers */
%insert(runtime) "guiledec.swg"
#ifndef SWIG_NOINCLUDE
%insert(runtime) "guile.swg"
#endif
/* Read in standard typemaps. */
%include "typemaps.i"

View file

@ -5,26 +5,27 @@
/* Basic types */
#define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME) \
%typemap (guile, in) 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, varout) C_NAME "$target = C_TO_SCM($source);"; \
%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;" \
%typemap (guile, indoc) C_NAME *INPUT "($arg <SCM_NAME>)"; \
%typemap (guile, ignore) C_NAME *OUTPUT (C_NAME temp) \
"$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, 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; \
%typemap (guile, argoutdoc) C_NAME *BOTH = C_NAME *OUTPUT
%define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME)
%typemap (guile, in) 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, varout) C_NAME "$target = C_TO_SCM($source);";
%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;"
%typemap (guile, indoc) C_NAME *INPUT "($arg <SCM_NAME>)";
%typemap (guile, ignore) C_NAME *OUTPUT (C_NAME temp)
"$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, 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;
%typemap (guile, argoutdoc) C_NAME *BOTH = C_NAME *OUTPUT;
%enddef
SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean);
SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char);
SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char);

View file

@ -230,6 +230,7 @@ GUILE::set_init (char *iname)
void
GUILE::headers (void)
{
Printf(f_runtime, "/* -*- buffer-read-only: t -*- */\n");
Swig_banner (f_runtime);
Printf (f_runtime, "/* Implementation : GUILE */\n\n");
@ -239,19 +240,6 @@ GUILE::headers (void)
if (NoInclude) {
Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
}
if (Swig_insert_file ("guiledec.swg", f_runtime) == -1) {
Printf (stderr, "SWIG : Fatal error. ");
Printf (stderr, "Unable to locate 'guiledec.swg' in SWIG library.\n");
SWIG_exit (1);
}
if (!NoInclude) {
// Write out function definitions
if (Swig_insert_file ("guile.swg", f_runtime) == -1) {
Printf (stderr, "SWIG : Fatal error. ");
Printf (stderr, "Unable to locate 'guile.swg' in SWIG library.\n");
SWIG_exit (1);
}
}
}
// --------------------------------------------------------------------