Guile add two more examples and use load-extension instead of dynamic-load
This commit is contained in:
parent
4e4b73e7c0
commit
d3cddb1355
5 changed files with 52 additions and 5 deletions
47
Examples/guile/Makefile
Normal file
47
Examples/guile/Makefile
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Makefile for Guile. Used by all of the example programs.
|
||||||
|
|
||||||
|
subdirs = simple matrix port constants class multimap multivalue std_vector
|
||||||
|
|
||||||
|
top_srcdir = ../..
|
||||||
|
SWIG = ../$(top_srcdir)/preinst-swig
|
||||||
|
CC = gcc
|
||||||
|
CXX = g++
|
||||||
|
CFLAGS =
|
||||||
|
LIBS =
|
||||||
|
GUILE = /usr/bin/guile
|
||||||
|
GUILE_CFLAGS = -pthread
|
||||||
|
GUILE_LIBS = -pthread -lguile
|
||||||
|
SWIGOPT =
|
||||||
|
|
||||||
|
WRAP = $(IFILE:.i=_wrap.c)
|
||||||
|
CXXWRAP = $(IFILE:.i=_wrap.cxx)
|
||||||
|
|
||||||
|
SO = .so
|
||||||
|
|
||||||
|
all:
|
||||||
|
for d in $(subdirs) ; do (cd $$d ; $(MAKE)) ; done
|
||||||
|
|
||||||
|
clean:
|
||||||
|
for d in $(subdirs) ; do (cd $$d ; $(MAKE) clean) ; done
|
||||||
|
rm -f *~ .~*
|
||||||
|
|
||||||
|
guile_clean:
|
||||||
|
rm -f *.o *$(SO) *_wrap* *~ .~* core my-guile $(TARGET)
|
||||||
|
|
||||||
|
# This is meant to be used w/ "make -f ../Makefile" from subdirs.
|
||||||
|
# Doesn't make sense to use it from here.
|
||||||
|
|
||||||
|
sub-all:
|
||||||
|
$(SWIG) -guile $(SWIGOPT) $(IFILE)
|
||||||
|
$(CC) $(CFLAGS) -o $(TARGET) $(SRCS) $(WRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS)
|
||||||
|
|
||||||
|
sub-all-cxx:
|
||||||
|
$(SWIG) -c++ -guile $(SWIGOPT) $(IFILE)
|
||||||
|
$(CXX) $(CFLAGS) -o $(TARGET) $(SRCS) $(CXXWRAP) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS)
|
||||||
|
|
||||||
|
run_example:
|
||||||
|
if [ -f $(RUNSCRIPT) ]; then \
|
||||||
|
env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(RUNSCRIPT); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Makefile ends here
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
; file: runme.py
|
; file: runme.scm
|
||||||
|
|
||||||
; This file illustrates the proxy class C++ interface generated
|
; This file illustrates the proxy class C++ interface generated
|
||||||
; by SWIG.
|
; by SWIG.
|
||||||
|
|
||||||
(dynamic-call "scm_init_example_module" (dynamic-link "./libexample"))
|
(load-extension "./libexample" "scm_init_example_module")
|
||||||
|
|
||||||
; Convenience wrapper around the display function
|
; Convenience wrapper around the display function
|
||||||
; (which only accepts one argument at the time)
|
; (which only accepts one argument at the time)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
;;; Test out some multi-argument typemaps
|
;;; Test out some multi-argument typemaps
|
||||||
|
|
||||||
(dynamic-call "scm_init_example_module" (dynamic-link "./libexample"))
|
(load-extension "./libexample" "scm_init_example_module")
|
||||||
|
|
||||||
; Call the GCD function
|
; Call the GCD function
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
;;;; Show the three different ways to deal with multiple return values
|
;;;; Show the three different ways to deal with multiple return values
|
||||||
|
|
||||||
(dynamic-call "scm_init_example_module" (dynamic-link "./libexample"))
|
(load-extension "./libexample" "scm_init_example_module")
|
||||||
|
|
||||||
;;; Multiple values as lists. By default, if more than one value is to
|
;;; Multiple values as lists. By default, if more than one value is to
|
||||||
;;; be returned, a list of the values is created and returned. The
|
;;; be returned, a list of the values is created and returned. The
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(dynamic-call "scm_init_example_module" (dynamic-link "./libexample"))
|
(load-extension "./libexample" "scm_init_example_module")
|
||||||
|
|
||||||
; repeatedly invoke a procedure with v and an index as arguments
|
; repeatedly invoke a procedure with v and an index as arguments
|
||||||
(define (with-vector v proc size-proc)
|
(define (with-vector v proc size-proc)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue