From: Jens Thiele Date: Tue, 21 Nov 2006 16:04:55 +0000 (+0000) Subject: added test using own class as argument X-Git-Tag: v0.2~101 X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=commitdiff_plain;h=63291e4f84b127b479bee0710860e5fdbfbd5b11 added test using own class as argument --- diff --git a/example-codegen/Makefile.am b/example-codegen/Makefile.am index f1ce586..5deff2e 100644 --- a/example-codegen/Makefile.am +++ b/example-codegen/Makefile.am @@ -8,7 +8,7 @@ noinst_LTLIBRARIES = libclient.la client_SOURCES = client.cpp client_LDADD = $(LDADD) libclient.la -server_SOURCES = server.cpp codegen_server.cpp +server_SOURCES = server.cpp codegen_server.cpp foo.hxx noinst_PROGRAMS = client server @@ -17,7 +17,7 @@ codegen.stamp: server.hxx $(top_builddir)/codegen/codegen # todo use tmp file for server.xml gccxml $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $< -fxml=server.xml $(top_builddir)/codegen/codegen $< server.xml codegen_ - touch codegen.stamp + touch $@ codegen_common.hxx codegen_common.cpp codegen_client.hxx codegen_client.cpp codegen_server.cpp: codegen.stamp diff --git a/example-codegen/client.cpp b/example-codegen/client.cpp index 266bef0..008d9e1 100644 --- a/example-codegen/client.cpp +++ b/example-codegen/client.cpp @@ -24,12 +24,15 @@ int main(int argc, char** argv) throwok=(std::string(e.what())=="throw me around"); } + Foo foo={10,10}; + return ( throwok && ( cc.testfunc("hello") == "hello, testfunc() was here" ) && ( cc.testfunc_ref("hello") == "hello, testfunc() was here" ) && ( cc.t2(10) == 10 ) && ( cc_other.t3(10, 20, "hello", std::pair(10,20)) ) && ( cc_other.t3(10) == 10 ) - && ( cc_other.t3(std::vector(1,10)) ) ) + && ( cc_other.t3(std::vector(1,10)) ) + && ( cc_other.t3(foo) ) ) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/example-codegen/foo.hxx b/example-codegen/foo.hxx new file mode 100644 index 0000000..49d0197 --- /dev/null +++ b/example-codegen/foo.hxx @@ -0,0 +1,21 @@ +#ifndef FOO_HXX +#define FOO_HXX + +#include + +struct Foo +{ + int i,j; + + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int /* version */) + { + ar & BOOST_SERIALIZATION_NVP(i); + ar & BOOST_SERIALIZATION_NVP(j); + } +}; + +BOOST_CLASS_VERSION(Foo, 1) + +#endif diff --git a/example-codegen/server.cpp b/example-codegen/server.cpp index 7bf0bf2..1931ab8 100644 --- a/example-codegen/server.cpp +++ b/example-codegen/server.cpp @@ -5,6 +5,12 @@ using namespace libt2n; +bool t3(const Foo &foo) +{ + return (foo.i==foo.j); +} + + int main(int argc, char** argv) { socket_server ss("./socket"); socket_server ss_other("./socket_other"); diff --git a/example-codegen/server.hxx b/example-codegen/server.hxx index b15ccee..16068a0 100644 --- a/example-codegen/server.hxx +++ b/example-codegen/server.hxx @@ -8,6 +8,8 @@ #include #include +#include "foo.hxx" + #include "codegen_common.hxx" LIBT2N_SET_DEFAULTGROUP(default); @@ -63,3 +65,6 @@ LIBT2N_EXPORT_GROUP(other) bool t3(const std::vector &i) { return (i.size()==1) && (i[0]==10); } + +//! test own type and seperate declaration and definition +LIBT2N_EXPORT_GROUP(other) bool t3(const Foo &foo);