From ebe664dd499269676d67c161eda8e2e320e498e5 Mon Sep 17 00:00:00 2001 From: lispbub Date: Mon, 6 Feb 2017 16:24:16 +0100 Subject: [PATCH] fix #60, cxx casts + test case --- INSTALL | 4 +-- Makefile.am | 3 ++- c-mera.asd | 7 +++-- tests/Makefile | 2 +- tests/cxx.misc.cast.00.lisp | 27 +++++++++++++++++++ ...xpr.00.lisp => cxx.misc.stmt-expr.00.lisp} | 0 6 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 tests/cxx.misc.cast.00.lisp rename tests/{cxx.stmt-expr.00.lisp => cxx.misc.stmt-expr.00.lisp} (100%) diff --git a/INSTALL b/INSTALL index 007e939..2099840 100644 --- a/INSTALL +++ b/INSTALL @@ -12,8 +12,8 @@ without warranty of any kind. Basic Installation ================== - Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following + Briefly, the shell command `./configure && make && make install' +should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented diff --git a/Makefile.am b/Makefile.am index 61dedb5..9283d15 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,8 @@ cm_cxx_SOURCES = src/cxx/nodes.lisp \ src/cxx/syntax.lisp \ src/cxx/pretty.lisp \ src/cxx/reader.lisp \ - src/cxx/cm-cxx.lisp + src/cxx/cm-cxx.lisp \ + src/cxx/cmu-cxx.lisp cm_glsl_SOURCES = src/glsl/nodes.lisp \ src/glsl/syntax.lisp \ diff --git a/c-mera.asd b/c-mera.asd index ee1886b..e80392d 100644 --- a/c-mera.asd +++ b/c-mera.asd @@ -152,14 +152,16 @@ (append c-symbols '(delete decl))) -;; symbols not shadowed but expoted +;; symbols not shadowed but exported (defparameter c++syntax (append c-syntax '(class vector new constructor private public protected namespace using reference-type using-namespace from-namespace - template instantiate))) + template instantiate + dynamic-cast static-cast + reinterpret-cast const-cast))) (defparameter c++exports (append default-exports @@ -529,6 +531,7 @@ (asdf:defsystem cmu-c++ :name "c-mera user c++" :version "0.0.2" + :components ((:file "src/cxx/cmu-cxx")) :depends-on ("c-mera" "cm-c" "cmu-c" diff --git a/tests/Makefile b/tests/Makefile index 1deb0c7..3b40f65 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -38,7 +38,7 @@ cxx-decl-tests-pre: @echo "- Declarations:" cxx-decl-tests: cxx-decl-tests-pre $(cxx-decl-results) -cxx-misc-test-files = $(shell ls cxx.stmt-expr.*.lisp) +cxx-misc-test-files = $(shell ls cxx.misc.*.lisp) cxx-misc-results = $(cxx-misc-test-files:%.lisp=%.ok) cxx-misc-tests-pre: @echo "- Misc:" diff --git a/tests/cxx.misc.cast.00.lisp b/tests/cxx.misc.cast.00.lisp new file mode 100644 index 0000000..c5f7466 --- /dev/null +++ b/tests/cxx.misc.cast.00.lisp @@ -0,0 +1,27 @@ +(include ) +(include ) +(using-namespace std) + +(class A () + (decl ((int a)))) + +(class B ((public A)) + (decl ((int b)))) + +(function main () -> int + (decl ((int foo = 0) + (const int* bar = (const-cast const int* &foo)) + (float foo2 = 3.14) + (B* foo3 = (new B)) + (A* foo4 = (dynamic-cast A* foo3))) + (set (dref (const-cast int* bar)) 1) + (<< cout foo endl) + (<< cout (static-cast int foo2) endl) + (<< cout (oref (typeid foo3) (name)) endl) + (<< cout (oref (typeid foo4) (name)) endl) + (return 0))) + +;;## 1 +;;## 3 +;;## P1B +;;## P1A diff --git a/tests/cxx.stmt-expr.00.lisp b/tests/cxx.misc.stmt-expr.00.lisp similarity index 100% rename from tests/cxx.stmt-expr.00.lisp rename to tests/cxx.misc.stmt-expr.00.lisp