From 362303298ac4c1f93bda87535df2b726481d54bb Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 14 Dec 2020 08:10:27 -0800 Subject: Add libcody In order to separate compiler from build system, C++ Modules, as implemented in GCC introduces a communication channel between those two entities. This is implemented by libcody. It is anticipated that other implementations will also implement this protocol, or use libcody to provide it. * Makefile.def: Add libcody. * configure.ac: Add libcody. * Makefile.in: Regenerated. * configure: Regenerated. gcc/ * Makefile.in (CODYINC, CODYLIB, CODYLIB_H): New. Use them. libcody/ * configure.ac: New. * CMakeLists.txt: New. * CODING.md: New. * CONTRIB.md: New. * LICENSE: New. * LICENSE.gcc: New. * Makefile.in: New. * Makesub.in: New. * README.md: New. * buffer.cc: New. * build-aux/config.guess: New. * build-aux/config.sub: New. * build-aux/install-sh: New. * client.cc: New. * cmake/libcody-config-ix.cmake * cody.hh: New. * config.h.in: New. * config.m4: New. * configure: New. * configure.ac: New. * dox.cfg.in: New. * fatal.cc: New. * gdbinit.in: New. * internal.hh: New. * netclient.cc: New. * netserver.cc: New. * packet.cc: New. * resolver.cc: New. * server.cc: New. * tests/01-serialize/connect.cc: New. * tests/01-serialize/decoder.cc: New. * tests/01-serialize/encoder.cc: New. * tests/02-comms/client-1.cc: New. * tests/02-comms/pivot-1.cc: New. * tests/02-comms/server-1.cc: New. * tests/Makesub.in: New. * tests/jouster: New. --- libcody/packet.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 libcody/packet.cc (limited to 'libcody/packet.cc') diff --git a/libcody/packet.cc b/libcody/packet.cc new file mode 100644 index 0000000..65dc8f4 --- /dev/null +++ b/libcody/packet.cc @@ -0,0 +1,50 @@ +// CODYlib -*- mode:c++ -*- +// Copyright (C) 2020 Nathan Sidwell, nathan@acm.org +// License: Apache v2.0 + +// Cody +#include "internal.hh" + +namespace Cody { + +void Packet::Destroy () +{ + switch (cat) + { + case STRING: + // Silly scope destructor name rules + using S = std::string; + string.~S (); + break; + + case VECTOR: + using V = std::vector; + vector.~V (); + break; + + default:; + } +} + +void Packet::Create (Packet &&t) +{ + cat = t.cat; + code = t.code; + request = t.request; + switch (cat) + { + case STRING: + new (&string) std::string (std::move (t.string)); + break; + + case VECTOR: + new (&vector) std::vector (std::move (t.vector)); + break; + + default: + integer = t.integer; + break; + } +} + +} -- cgit v1.1