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 = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS =
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
|
||||
GPP = `which g++`
|
||||
MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
|
||||
|
||||
build:
|
||||
$(SWIGEXE) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
|
||||
$(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx
|
||||
$(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(CXXSRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
||||
|
|
|
|||
|
|
@ -9,16 +9,17 @@
|
|||
(if (< i size)
|
||||
(begin
|
||||
(proc v i)
|
||||
(with-vector-item v (+ i 1)))))
|
||||
(with-vector-item v (+ i 1)))
|
||||
(void)))
|
||||
(with-vector-item v 0)))
|
||||
|
||||
(define (with-intvector v proc)
|
||||
(with-vector v proc intvector-length))
|
||||
(define (with-doublevector v proc)
|
||||
(with-vector v proc doublevector-length))
|
||||
(define (with-IntVector v proc)
|
||||
(with-vector v proc IntVector-length))
|
||||
(define (with-DoubleVector v proc)
|
||||
(with-vector v proc DoubleVector-length))
|
||||
|
||||
(define (print-doublevector v)
|
||||
(with-doublevector v (lambda (v i) (display (doublevector-ref v i))
|
||||
(define (print-DoubleVector v)
|
||||
(with-DoubleVector v (lambda (v i) (display (DoubleVector-ref v i))
|
||||
(display " ")))
|
||||
(newline))
|
||||
|
||||
|
|
@ -29,11 +30,11 @@
|
|||
(newline)
|
||||
|
||||
; ... or a wrapped std::vector<int>
|
||||
(define v (new-intvector 4))
|
||||
(with-intvector v (lambda (v i) (intvector-set! v i (+ i 1))))
|
||||
(define v (new-IntVector 4))
|
||||
(with-IntVector v (lambda (v i) (IntVector-set! v i (+ i 1))))
|
||||
(display (average v))
|
||||
(newline)
|
||||
(delete-intvector v)
|
||||
(delete-IntVector v)
|
||||
|
||||
; half will return a Scheme vector.
|
||||
; Call it with a Scheme vector...
|
||||
|
|
@ -42,13 +43,12 @@
|
|||
(newline)
|
||||
|
||||
; ... or a wrapped std::vector<double>
|
||||
(define v (new-doublevector))
|
||||
(map (lambda (i) (doublevector-push! v i)) '(1 2 3 4))
|
||||
(define v (new-DoubleVector))
|
||||
(map (lambda (i) (DoubleVector-push! v i)) '(1 2 3 4))
|
||||
(display (half v))
|
||||
(newline)
|
||||
|
||||
; now halve a wrapped std::vector<double> in place
|
||||
(halve-in-place v)
|
||||
(print-doublevector v)
|
||||
(delete-doublevector v)
|
||||
|
||||
(print-DoubleVector v)
|
||||
(delete-DoubleVector v)
|
||||
|
|
|
|||
|
|
@ -439,9 +439,8 @@ public:
|
|||
sprintf(temp, "%d", numargs);
|
||||
if (exporting_destructor) {
|
||||
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 {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
/* Emit overloading dispatch function */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue