Added files
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@39 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7ee1dec92d
commit
09bd3946db
37 changed files with 6653 additions and 0 deletions
4
SWIG/Lib/guile/Makefile
Normal file
4
SWIG/Lib/guile/Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
co::
|
||||
co RCS/*.i* RCS/*.swg*
|
||||
|
||||
15
SWIG/Lib/guile/guile.swg
Normal file
15
SWIG/Lib/guile/guile.swg
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* -----------------------------------------------------------------------
|
||||
* swig_lib/guile/guile.swg
|
||||
*
|
||||
* Guile configuration file. This file assumes FSF Guile 1.0. It may not
|
||||
* work with other versions
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#include "guile/gh.h"
|
||||
|
||||
/* Since GUILE seems to be somewhat incomplete, these bindings
|
||||
are used in the SWIG generated code. To change the Guile
|
||||
interface, simply change this file */
|
||||
|
||||
#define GH_NOT_PASSED SCM_UNDEFINED
|
||||
|
||||
21
SWIG/Lib/guile/guilemain.i
Normal file
21
SWIG/Lib/guile/guilemain.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
%{
|
||||
void guile_main(void *closure, int argc, char **argv) {
|
||||
char buffer[1024];
|
||||
void SWIG_init();
|
||||
SWIG_init();
|
||||
printf("starting Guile...\n");
|
||||
printf("guile >");
|
||||
while (fgets(buffer,1024,stdin)) {
|
||||
gh_eval_str(buffer);
|
||||
printf("guile >");
|
||||
}
|
||||
}
|
||||
|
||||
void main(int argc, char **argv) {
|
||||
gh_enter(argc,argv, guile_main);
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
||||
71
SWIG/Lib/guile/interpreter.i
Normal file
71
SWIG/Lib/guile/interpreter.i
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
//
|
||||
// $Header$
|
||||
//
|
||||
// SWIG file for a simple Guile interpreter
|
||||
//
|
||||
/* Revision History
|
||||
* $Log$
|
||||
* Revision 1.1 2000/01/11 21:15:50 beazley
|
||||
* Added files
|
||||
*
|
||||
* Revision 1.1.1.1 1999/02/28 02:00:54 beazley
|
||||
* Swig1.1
|
||||
*
|
||||
* Revision 1.1 1996/05/22 20:02:10 beazley
|
||||
* Initial revision
|
||||
*
|
||||
*/
|
||||
|
||||
%{
|
||||
|
||||
#include <stdio.h>
|
||||
GSCM_status guile_init();
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
GSCM_status status;
|
||||
GSCM_top_level toplev;
|
||||
char *eval_answer;
|
||||
char input_str[16384];
|
||||
int done;
|
||||
|
||||
/* start a scheme interpreter */
|
||||
status = gscm_run_scm(argc, argv, 0, stdout, stderr, guile_init, 0, "#t");
|
||||
if (status != GSCM_OK) {
|
||||
fputs(gscm_error_msg(status), stderr);
|
||||
fputc('\n', stderr);
|
||||
printf("Error in startup.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* create the top level environment */
|
||||
status = gscm_create_top_level(&toplev);
|
||||
if (status != GSCM_OK) {
|
||||
fputs(gscm_error_msg(status), stderr);
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* now sit in a scheme eval loop: I input the expressions, have guile
|
||||
* evaluate them, and then get another expression.
|
||||
*/
|
||||
done = 0;
|
||||
fprintf(stdout,"Guile > ");
|
||||
while (!done) {
|
||||
if (fgets(input_str,16384,stdin) == NULL) {
|
||||
exit(1);
|
||||
} else {
|
||||
if (strncmp(input_str,"quit",4) == 0) exit(1);
|
||||
status = gscm_eval_str(&eval_answer, toplev, input_str);
|
||||
fprintf(stdout,"%s\n", eval_answer);
|
||||
fprintf(stdout,"Guile > ");
|
||||
}
|
||||
}
|
||||
|
||||
/* now clean up and quit */
|
||||
gscm_destroy_top_level(toplev);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue