MzScheme missing destructor added in, std_vector example fixed
This commit is contained in:
parent
f6da155fda
commit
b21a28f26a
3 changed files with 20 additions and 24 deletions
|
|
@ -1,21 +1,18 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIGEXE = $(TOP)/../swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
SRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
||||||
GPP = `which g++`
|
|
||||||
MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc
|
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(SWIGEXE) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(CXXSRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
$(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
$(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,17 @@
|
||||||
(if (< i size)
|
(if (< i size)
|
||||||
(begin
|
(begin
|
||||||
(proc v i)
|
(proc v i)
|
||||||
(with-vector-item v (+ i 1)))))
|
(with-vector-item v (+ i 1)))
|
||||||
|
(void)))
|
||||||
(with-vector-item v 0)))
|
(with-vector-item v 0)))
|
||||||
|
|
||||||
(define (with-intvector v proc)
|
(define (with-IntVector v proc)
|
||||||
(with-vector v proc intvector-length))
|
(with-vector v proc IntVector-length))
|
||||||
(define (with-doublevector v proc)
|
(define (with-DoubleVector v proc)
|
||||||
(with-vector v proc doublevector-length))
|
(with-vector v proc DoubleVector-length))
|
||||||
|
|
||||||
(define (print-doublevector v)
|
(define (print-DoubleVector v)
|
||||||
(with-doublevector v (lambda (v i) (display (doublevector-ref v i))
|
(with-DoubleVector v (lambda (v i) (display (DoubleVector-ref v i))
|
||||||
(display " ")))
|
(display " ")))
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
|
|
@ -29,11 +30,11 @@
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
; ... or a wrapped std::vector<int>
|
; ... or a wrapped std::vector<int>
|
||||||
(define v (new-intvector 4))
|
(define v (new-IntVector 4))
|
||||||
(with-intvector v (lambda (v i) (intvector-set! v i (+ i 1))))
|
(with-IntVector v (lambda (v i) (IntVector-set! v i (+ i 1))))
|
||||||
(display (average v))
|
(display (average v))
|
||||||
(newline)
|
(newline)
|
||||||
(delete-intvector v)
|
(delete-IntVector v)
|
||||||
|
|
||||||
; half will return a Scheme vector.
|
; half will return a Scheme vector.
|
||||||
; Call it with a Scheme vector...
|
; Call it with a Scheme vector...
|
||||||
|
|
@ -42,13 +43,12 @@
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
; ... or a wrapped std::vector<double>
|
; ... or a wrapped std::vector<double>
|
||||||
(define v (new-doublevector))
|
(define v (new-DoubleVector))
|
||||||
(map (lambda (i) (doublevector-push! v i)) '(1 2 3 4))
|
(map (lambda (i) (DoubleVector-push! v i)) '(1 2 3 4))
|
||||||
(display (half v))
|
(display (half v))
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
; now halve a wrapped std::vector<double> in place
|
; now halve a wrapped std::vector<double> in place
|
||||||
(halve-in-place v)
|
(halve-in-place v)
|
||||||
(print-doublevector v)
|
(print-DoubleVector v)
|
||||||
(delete-doublevector v)
|
(delete-DoubleVector v)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -439,9 +439,8 @@ public:
|
||||||
sprintf(temp, "%d", numargs);
|
sprintf(temp, "%d", numargs);
|
||||||
if (exporting_destructor) {
|
if (exporting_destructor) {
|
||||||
Printf(init_func_def, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
Printf(init_func_def, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
||||||
} else {
|
|
||||||
Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs);
|
|
||||||
}
|
}
|
||||||
|
Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs);
|
||||||
} else {
|
} else {
|
||||||
if (!Getattr(n, "sym:nextSibling")) {
|
if (!Getattr(n, "sym:nextSibling")) {
|
||||||
/* Emit overloading dispatch function */
|
/* Emit overloading dispatch function */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue