libabigail/include/abg-corpus.h

76 lines
1.8 KiB
C
Raw Normal View History

// -*- mode: C++ -*-
//
// Copyright (C) 2013 Red Hat, Inc.
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
// free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this program; see the file COPYING-LGPLV3. If
// not, see <http://www.gnu.org/licenses/>.
/// @file
#ifndef __ABG_CORPUS_H__
#define __ABG_CORPUS_H__
#include <abg-ir.h>
namespace abigail
{
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
Prepare serialization API for multiple backends * include/abg-reader.h: New file with abigail::xml_reader APIs. * include/abg-writer.h: New file with abigail::xml_writer APIs. * include/Makefile.am: Add the new files above to the source distribution. * src/abg-reader.cc: Update top-file comments. (namespace xml_reader): Rename namespace reader into this. (read_to_translation_unit, read_corpus_from_archive): New static functions. (read_translation_unit_from_file) (read_translation_unit_from_file, read_corpus_from_file): New entry points. (struct array_deleter): New functor. (translation_unit::read): Remove this. * src/abg-writer.cc: Update top file comments. (namespace xml_writer): Rename namespace writer into this. (struct archive_write_ctxt): New internal type. (create_archive_write_context, write_translation_unit_to_archive) (write_translation_unit, write_corpus_to_archive): New low level static functions overloads. (write_corpus_to_archive, write_translation_unit): Public higher level overloads. (translation_unit::write): Remove. (dump): Update for new xml_writer namespace. * include/abg-ir.h (translation_unit::{read, write}): Remove these serialization methods. * include/abg-corpus.h (corpus_sptr): New convenience typedef. (corpus::{read, write}): Remove these methods. * src/abg-corpus.cc (corpus::{read, write}) (corpus::impl::{serialized_tus, archive}): Remove these members. (corpus::impl::{get_archive, close_archive, write_tu_to_archive, read_to_translation_unit}): Remove these methods. * tests/test-bidiff.cc (main): Update for usage of the new xml_reader API. * tests/test-read-write.cc (main): Likewise. Update for the usage of the new xml_writer API, too. * tests/test-walker.cc (main): Update for the usage of the new xml_reader API. * tests/test-write-read-archive.cc (main): Likewise. And for the xml_writer API, too. * tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise. * tools/bidiff.cc (main): Likewise, for xml_reader APIs. * tools/bilint.cc (main): Likewise, for xml_writer APIs, too. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-04 08:44:20 +00:00
class corpus;
/// A convenience typedef for shared pointer to @ref corpus.
typedef shared_ptr<corpus> corpus_sptr;
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
/// This is the abstraction of a set of translation units (themselves
/// seen as bundles of unitary abi artefacts like types and decls)
/// bundled together as a corpus. A corpus is thus the Application
/// binary interface of a program, a library or just a set of modules
/// put together.
class corpus
{
public:
struct impl;
typedef std::string string;
private:
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
shared_ptr<impl> m_priv;
corpus();
public:
corpus(const string&);
void
add(const translation_unit_sptr);
const translation_units&
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
get_translation_units() const;
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
void
drop_translation_units();
string&
get_path() const;
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
void
set_path(const string&);
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
bool
is_empty() const;
Prepare serialization API for multiple backends * include/abg-reader.h: New file with abigail::xml_reader APIs. * include/abg-writer.h: New file with abigail::xml_writer APIs. * include/Makefile.am: Add the new files above to the source distribution. * src/abg-reader.cc: Update top-file comments. (namespace xml_reader): Rename namespace reader into this. (read_to_translation_unit, read_corpus_from_archive): New static functions. (read_translation_unit_from_file) (read_translation_unit_from_file, read_corpus_from_file): New entry points. (struct array_deleter): New functor. (translation_unit::read): Remove this. * src/abg-writer.cc: Update top file comments. (namespace xml_writer): Rename namespace writer into this. (struct archive_write_ctxt): New internal type. (create_archive_write_context, write_translation_unit_to_archive) (write_translation_unit, write_corpus_to_archive): New low level static functions overloads. (write_corpus_to_archive, write_translation_unit): Public higher level overloads. (translation_unit::write): Remove. (dump): Update for new xml_writer namespace. * include/abg-ir.h (translation_unit::{read, write}): Remove these serialization methods. * include/abg-corpus.h (corpus_sptr): New convenience typedef. (corpus::{read, write}): Remove these methods. * src/abg-corpus.cc (corpus::{read, write}) (corpus::impl::{serialized_tus, archive}): Remove these members. (corpus::impl::{get_archive, close_archive, write_tu_to_archive, read_to_translation_unit}): Remove these methods. * tests/test-bidiff.cc (main): Update for usage of the new xml_reader API. * tests/test-read-write.cc (main): Likewise. Update for the usage of the new xml_writer API, too. * tests/test-walker.cc (main): Update for the usage of the new xml_reader API. * tests/test-write-read-archive.cc (main): Likewise. And for the xml_writer API, too. * tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise. * tools/bidiff.cc (main): Likewise, for xml_reader APIs. * tools/bilint.cc (main): Likewise, for xml_writer APIs, too. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-04 08:44:20 +00:00
};// end class corpus.
Initial writing/reading of an ABI corpus to an archive * configure.ac: Support detection of libzip dependency. Define new DEPS_CFLAGS and DEPS_LIBS variables for use in Makefile.am to refer to the dependency headers and libraries. * doc/website/mainpage.txt: Update this to talk about the new libzip dependency. * include/Makefile.am: Add abg-libzip-utils.h to the build system. * include/abg-corpus.h (corps): Hide abigail::corpus's private behind a pimpl idiom. (corpus::{drop_translation_units, get_file_path, set_file_path, write, read}): New methods. * include/abg-libxml-utils.h (new_reader_from_buffer): Declare new function. * include/abg-libzip-utils.h: New file. * src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to the build system. Refer to the library and headers dependencies via the new DEPS_LIBS and DEPS_CFLAGS variables. * src/abg-corpus.cc: New file. * src/abg-ir.cc (translation::set_path): New method. * src/abg-libxml-utils.cc (new_reader_from_buffer): Define new function. * src/abg-libzip-utils.cc: New file. * src/abg-reader.cc (translation_unit::read): New overload. * src/abg-writer.cc: Inject the names from the std namespace into the abigail namespace, rather than into abigail::writer. (abigail::translation_unit::write): New overload. This can now use ofstream and the other stuff from std that are injected in the abigail:: namespace. * tests/Makefile.am: Add tests/test-write-read-archive.cc to the build system; use that to build runtestwritereadarchive. Also add the input test data from tests/data/test-write-read-archive/test[0-4].xml. * /tests/data/test-write-read-archive/test[0-4].xml: New test input data files. * tests/test-write-read-archive.cc: New test for this archive write/read support. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:18:59 +00:00
}//end namespace abigail
#endif //__ABG_CORPUS_H__