diff options
Diffstat (limited to 'Examples/guile/constants')
| -rw-r--r-- | Examples/guile/constants/Makefile | 17 | ||||
| -rw-r--r-- | Examples/guile/constants/constants.scm | 10 | ||||
| -rw-r--r-- | Examples/guile/constants/example.i | 27 |
3 files changed, 54 insertions, 0 deletions
diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile new file mode 100644 index 0000000..70243c7 --- /dev/null +++ b/Examples/guile/constants/Makefile @@ -0,0 +1,17 @@ +SRCS = +TARGET = my-guile +IFILE = example.i +MKDIR = .. + +all:: + $(MAKE) -f $(MKDIR)/Makefile \ + SRCS='$(SRCS)' \ + TARGET=$(TARGET) \ + IFILE=$(IFILE) \ + sub-all + +clean:: + $(MAKE) -f $(MKDIR)/Makefile TARGET='$(TARGET)' guile_clean + +check: all + ./my-guile -s constants.scm diff --git a/Examples/guile/constants/constants.scm b/Examples/guile/constants/constants.scm new file mode 100644 index 0000000..5220150 --- /dev/null +++ b/Examples/guile/constants/constants.scm @@ -0,0 +1,10 @@ +(or (= (ICONST) 42) (exit 1)) +(or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1)) +(or (char=? (CCONST) #\x) (exit 1)) +(or (char=? (CCONST2) #\newline) (exit 1)) +(or (string=? (SCONST) "Hello World") (exit 1)) +(or (string=? (SCONST2) "\"Hello World\"") (exit 1)) +(or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1)) +(or (= (iconst) 37) (exit 1)) +(or (< (abs (- (fconst) 3.14)) 0.00001) (exit 1)) +(exit 0) diff --git a/Examples/guile/constants/example.i b/Examples/guile/constants/example.i new file mode 100644 index 0000000..0b602e5 --- /dev/null +++ b/Examples/guile/constants/example.i @@ -0,0 +1,27 @@ +/* File : example.i */ +%module example + +/* A few preprocessor macros */ + +#define ICONST 42 +#define FCONST 2.1828 +#define CCONST 'x' +#define CCONST2 '\n' +#define SCONST "Hello World" +#define SCONST2 "\"Hello World\"" + +/* This should work just fine */ +#define EXPR ICONST + 3*(FCONST) + +/* This shouldn't do anything */ +#define EXTERN extern + +/* Neither should this (BAR isn't defined) */ +#define FOO (ICONST + BAR) + +/* The following directives also produce constants */ + +%constant int iconst = 37; +%constant double fconst = 3.14; + +%include guilemain.i |
