OCaml's classHandler() requires name, not sym:name.

In classHandler(), assign sym:name to the classname global so that it
can be used in membervariableHandler().

Add a small runme test for li_std_vector.
Use swigp4 when compiling the runme tests.
This commit is contained in:
Zackery Spytz 2019-01-08 20:10:07 -07:00
commit 4ca6fdc551
3 changed files with 33 additions and 9 deletions

View file

@ -4,6 +4,7 @@
LANGUAGE = ocaml
OCAMLC = @OCAMLC@
OCAMLPP = -pp "camlp4o ./swigp4.cmo"
VARIANT = _static
SCRIPTSUFFIX = _runme.ml
@ -51,7 +52,7 @@ run_testcase = \
if [ $(srcdir) != . ]; then \
cp $(srcdir)/$(ml_runme) $(ml_runme); \
fi ; \
$(COMPILETOOL) $(OCAMLC) -c $(ml_runme) && \
$(COMPILETOOL) $(OCAMLC) $(OCAMLPP) -c $(ml_runme) && \
if [ -f $(top_srcdir)/Examples/test-suite/$*.list ]; then \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme; \
else \

View file

@ -0,0 +1,23 @@
open Swig
open Li_std_vector
let _ =
let iv = new_IntVector '() in
assert (iv -> "empty" () as bool);
assert ((iv -> "size" () as int) = 0);
ignore (iv -> "push_back" (123));
assert ((iv -> "empty" () as bool) = false);
assert ((iv -> "size" () as int) = 1);
assert ((iv -> "[]" (0) as int) = 123);
ignore (iv -> "clear" ());
assert (iv -> "empty" () as bool);
assert ((iv -> "size" () as int) = 0);
;;
let _ =
let rv = new_RealVector '() in
ignore (rv -> "push_back" (100.));
ignore (rv -> "push_back" (200.));
assert ((rv -> "[]" (0) as float) = 100.);
assert ((rv -> "[]" (1) as float) = 200.);
;;