ctf: compile plugin as C++
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 19 Jan 2022 18:32:03 +0000 (13:32 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jan 2022 16:22:26 +0000 (11:22 -0500)
commit087cd0f57f0f7d815a609a4e041d1200f380e4aa
tree47f311ab918adab5f1d93e70f747721ef38b9117
parent516bf0a77e025cfccce2fa400b757e94dc0bf1d8
ctf: compile plugin as C++

Rename files under src/plugins/ctf:

 - .c to .cpp
 - .h to .hpp
 - .y to .ypp
 - .l to .lpp

Do the necessary adjustements to get it to compile as C++.  Most changes
are not too surprising, just typical adjustments to casts and things
like that.  But there a few things worthy of mention:

  * g++ 7 doesn't accept non-trivial static initializers.  This means
    that parameter validation descriptors don't compile, and we need
    another approach.  Add constructors (only if __cplusplus is
    defined) to bt_param_validation_value_descr to allow constructing a
    descriptor of the various types.  This allows retaining a syntax
    very close to the existing one.

  * Similary, g++ 7 doesn't like the existing initialization of
    node_error, in parser.ypp.  Explicitly initialize the fields before
    `type` to work around that.

  * About the class hierarchies of ctf_field_class and
    fs_sink_ctf_field_class.  Casting to sub- or super-class is
    currently done by casting to `void *`, which doesn't work in C++.
    Replace that with:

     * to cast to a super-class, get the pointer to the right base, like
     `&fc->base.base`.  It might be a bit ugly, but it's shorter than
     casting and type-safe, so why not.

     * to cast to a sub-class, add some free functions such as
     `ctf_field_class_as_string` that check the field class' type, make
     sure they are indeed an instance of the requested type, and do the
     cast.  Note that this cast still assumes that bases are the first
     member in each sub-class.

  * For the rest, if you are wondering why some change is necessary, try
    reverting and compiling (with a recent gcc and clang), the compiler
    will tell you.

Change-Id: I05b12b906c5df0d89fdc2a70ce4a3b6810b48d41
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7096
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
155 files changed:
src/common/macros.h
src/common/mmap-align.h
src/compat/bitfield.h
src/compat/memstream.h
src/compat/mman.h
src/compat/socket.h
src/ctfser/ctfser.h
src/plugins/common/muxing/muxing.h
src/plugins/common/param-validation/param-validation.h
src/plugins/ctf/Makefile.am
src/plugins/ctf/common/Makefile.am
src/plugins/ctf/common/bfcr/Makefile.am
src/plugins/ctf/common/bfcr/bfcr.c [deleted file]
src/plugins/ctf/common/bfcr/bfcr.cpp [new file with mode: 0644]
src/plugins/ctf/common/bfcr/bfcr.h [deleted file]
src/plugins/ctf/common/bfcr/bfcr.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/Makefile.am
src/plugins/ctf/common/metadata/ast.h [deleted file]
src/plugins/ctf/common/metadata/ast.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.h [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-configure-ir-trace.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-resolve.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-translate.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-translate.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-update-alignments.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-update-alignments.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-update-default-clock-classes.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-update-in-ir.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-update-meanings.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-update-meanings.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-update-stream-class-config.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-update-text-array-sequence.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-update-value-storing-indexes.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-validate.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-validate.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-visitors.h [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-visitors.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.c [deleted file]
src/plugins/ctf/common/metadata/ctf-meta-warn-meaningless-header-fields.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/ctf-meta.h [deleted file]
src/plugins/ctf/common/metadata/ctf-meta.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c [deleted file]
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.h [deleted file]
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/decoder.c [deleted file]
src/plugins/ctf/common/metadata/decoder.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/decoder.h [deleted file]
src/plugins/ctf/common/metadata/decoder.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/lexer.l [deleted file]
src/plugins/ctf/common/metadata/lexer.lpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/logging.c [deleted file]
src/plugins/ctf/common/metadata/logging.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/logging.h [deleted file]
src/plugins/ctf/common/metadata/logging.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/objstack.c [deleted file]
src/plugins/ctf/common/metadata/objstack.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/objstack.h [deleted file]
src/plugins/ctf/common/metadata/objstack.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/parser-wrap.h [deleted file]
src/plugins/ctf/common/metadata/parser-wrap.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/parser.y [deleted file]
src/plugins/ctf/common/metadata/parser.ypp [new file with mode: 0644]
src/plugins/ctf/common/metadata/scanner-symbols.h [deleted file]
src/plugins/ctf/common/metadata/scanner-symbols.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/scanner.h [deleted file]
src/plugins/ctf/common/metadata/scanner.hpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/visitor-generate-ir.c [deleted file]
src/plugins/ctf/common/metadata/visitor-generate-ir.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/visitor-parent-links.c [deleted file]
src/plugins/ctf/common/metadata/visitor-parent-links.cpp [new file with mode: 0644]
src/plugins/ctf/common/metadata/visitor-semantic-validator.c [deleted file]
src/plugins/ctf/common/metadata/visitor-semantic-validator.cpp [new file with mode: 0644]
src/plugins/ctf/common/msg-iter/Makefile.am
src/plugins/ctf/common/msg-iter/msg-iter.c [deleted file]
src/plugins/ctf/common/msg-iter/msg-iter.cpp [new file with mode: 0644]
src/plugins/ctf/common/msg-iter/msg-iter.h [deleted file]
src/plugins/ctf/common/msg-iter/msg-iter.hpp [new file with mode: 0644]
src/plugins/ctf/common/print.h [deleted file]
src/plugins/ctf/common/print.hpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/Makefile.am
src/plugins/ctf/fs-sink/fs-sink-ctf-meta.h [deleted file]
src/plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/fs-sink-stream.c [deleted file]
src/plugins/ctf/fs-sink/fs-sink-stream.cpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/fs-sink-stream.h [deleted file]
src/plugins/ctf/fs-sink/fs-sink-stream.hpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/fs-sink-trace.c [deleted file]
src/plugins/ctf/fs-sink/fs-sink-trace.cpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/fs-sink-trace.h [deleted file]
src/plugins/ctf/fs-sink/fs-sink-trace.hpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/fs-sink.c [deleted file]
src/plugins/ctf/fs-sink/fs-sink.cpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/fs-sink.h [deleted file]
src/plugins/ctf/fs-sink/fs-sink.hpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.c [deleted file]
src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.cpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.h [deleted file]
src/plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.hpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c [deleted file]
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp [new file with mode: 0644]
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.h [deleted file]
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.hpp [new file with mode: 0644]
src/plugins/ctf/fs-src/Makefile.am
src/plugins/ctf/fs-src/data-stream-file.c [deleted file]
src/plugins/ctf/fs-src/data-stream-file.cpp [new file with mode: 0644]
src/plugins/ctf/fs-src/data-stream-file.h [deleted file]
src/plugins/ctf/fs-src/data-stream-file.hpp [new file with mode: 0644]
src/plugins/ctf/fs-src/file.c [deleted file]
src/plugins/ctf/fs-src/file.cpp [new file with mode: 0644]
src/plugins/ctf/fs-src/file.h [deleted file]
src/plugins/ctf/fs-src/file.hpp [new file with mode: 0644]
src/plugins/ctf/fs-src/fs.c [deleted file]
src/plugins/ctf/fs-src/fs.cpp [new file with mode: 0644]
src/plugins/ctf/fs-src/fs.h [deleted file]
src/plugins/ctf/fs-src/fs.hpp [new file with mode: 0644]
src/plugins/ctf/fs-src/lttng-index.h [deleted file]
src/plugins/ctf/fs-src/lttng-index.hpp [new file with mode: 0644]
src/plugins/ctf/fs-src/metadata.c [deleted file]
src/plugins/ctf/fs-src/metadata.cpp [new file with mode: 0644]
src/plugins/ctf/fs-src/metadata.h [deleted file]
src/plugins/ctf/fs-src/metadata.hpp [new file with mode: 0644]
src/plugins/ctf/fs-src/query.c [deleted file]
src/plugins/ctf/fs-src/query.cpp [new file with mode: 0644]
src/plugins/ctf/fs-src/query.h [deleted file]
src/plugins/ctf/fs-src/query.hpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/Makefile.am
src/plugins/ctf/lttng-live/data-stream.c [deleted file]
src/plugins/ctf/lttng-live/data-stream.cpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/data-stream.h [deleted file]
src/plugins/ctf/lttng-live/data-stream.hpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/lttng-live.c [deleted file]
src/plugins/ctf/lttng-live/lttng-live.cpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/lttng-live.h [deleted file]
src/plugins/ctf/lttng-live/lttng-live.hpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/lttng-viewer-abi.h [deleted file]
src/plugins/ctf/lttng-live/lttng-viewer-abi.hpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/metadata.c [deleted file]
src/plugins/ctf/lttng-live/metadata.cpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/metadata.h [deleted file]
src/plugins/ctf/lttng-live/metadata.hpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/viewer-connection.c [deleted file]
src/plugins/ctf/lttng-live/viewer-connection.cpp [new file with mode: 0644]
src/plugins/ctf/lttng-live/viewer-connection.h [deleted file]
src/plugins/ctf/lttng-live/viewer-connection.hpp [new file with mode: 0644]
src/plugins/ctf/plugin.c [deleted file]
src/plugins/ctf/plugin.cpp [new file with mode: 0644]
This page took 0.039245 seconds and 4 git commands to generate.