Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
SRCS = example.c
TARGET = my-guile
INTERFACE = example.i
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean

View File

@@ -0,0 +1,9 @@
A very simple example.
To run it, start the program 'my-guile' and type:
(load "runme.scm")
Alternatively, you can use the shell command:
./my-guile -s runme.scm

View File

@@ -0,0 +1,21 @@
/* Simple example from documentation */
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
int mod(int n, int m) {
return (n % m);
}
char *get_time() {
long ltime;
time(&ltime);
return ctime(&ltime);
}

View File

@@ -0,0 +1,14 @@
/* File : example.i */
%module Example
%{
/* Put headers and other declarations here */
%}
%inline %{
extern double My_variable;
extern int fact(int);
extern int mod(int n, int m);
extern char *get_time();
%}
%include guile/guilemain.i

View File

@@ -0,0 +1,26 @@
(define (mdisplay-newline . args) ; does guile-1.3.4 have `format #t'?
(for-each display args)
(newline))
(mdisplay-newline (get-time) "My variable = " (My-variable))
(do ((i 0 (1+ i)))
((= 14 i))
(mdisplay-newline i " factorial is " (fact i)))
(define (mods i imax j jmax)
(if (< i imax)
(if (< j jmax)
(begin
(My-variable (+ (My-variable) (mod i j)))
(mods i imax (+ j 1) jmax))
(mods (+ i 1) imax 1 jmax))))
(mods 1 150 1 150)
(mdisplay-newline "My-variable = " (My-variable))
(exit (and (= 1932053504 (fact 13))
(= 745470.0 (My-variable))))