Skip to content

Commit

Permalink
Clean up class vs. struct
Browse files Browse the repository at this point in the history
  • Loading branch information
eyck committed Oct 12, 2017
1 parent a0baf6e commit 35d9bbf
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 30 deletions.
6 changes: 4 additions & 2 deletions incl/iss/arch_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ namespace iss {
/**
* exception to be thrown if the architecture encounters a synchronous trap
*/
struct trap_access {
class trap_access {
public:
trap_access(unsigned id, uint64_t addr)
: id(id)
, addr(addr) {}
Expand All @@ -55,7 +56,8 @@ struct trap_access {
/**
* architecture interface
*/
struct arch_if {
class arch_if {
public:
/* deprecated */
enum operations {
NOP,
Expand Down
6 changes: 4 additions & 2 deletions incl/iss/debugger/cmdhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ enum signals {
#define GEN_ENTRY(name, hlp) \
{ #name, &cmd_handler::rcmd_##name, hlp }

struct cmd_handler {
class cmd_handler {
public:
/* Table entry definition */
struct my_custom_command {
class my_custom_command {
public:
/* command name */
const char *name;
/* command function */
Expand Down
3 changes: 2 additions & 1 deletion incl/iss/debugger/encoderdecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
namespace iss {
namespace debugger {

struct encoder_decoder {
class encoder_decoder {
public:
/* Decode/encode functions */
std::vector<uint8_t> dec_data(const char *in);

Expand Down
6 changes: 4 additions & 2 deletions incl/iss/debugger/serialized_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class connection : public boost::enable_shared_from_this<connection<TREQ, TRESP>
public:
using ptr = boost::shared_ptr<connection<TREQ, TRESP>>;

struct async_listener : public boost::enable_shared_from_this<async_listener> {
class async_listener : public boost::enable_shared_from_this<async_listener> {
public:
virtual void send_completed(const boost::system::error_code &error) = 0;
virtual void receive_completed(const boost::system::error_code &error, TREQ *result) = 0;
};
Expand Down Expand Up @@ -278,7 +279,8 @@ template <>
class connection<std::string, std::string>
: public boost::enable_shared_from_this<connection<std::string, std::string>> {
public:
struct async_listener : public boost::enable_shared_from_this<async_listener> {
class async_listener : public boost::enable_shared_from_this<async_listener> {
public:
virtual void send_completed(const boost::system::error_code &error) = 0;
virtual void receive_completed(const boost::system::error_code &error, std::string *result) = 0;
virtual bool message_completed(std::vector<char> &buffer) { return true; };
Expand Down
3 changes: 2 additions & 1 deletion incl/iss/debugger/server_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
namespace iss {
namespace debugger {

struct server_base : public server_if {
class server_base : public server_if {
public:

server_base(debugger_if *adapter);

Expand Down
7 changes: 4 additions & 3 deletions incl/iss/debugger/server_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@

namespace iss {

struct debugger_if;
class debugger_if;

namespace debugger {
// forward declaration
struct target_adapter_if;
class target_adapter_if;
/**
* the debug server interface
*/
struct server_if {
class server_if {
public:
friend class iss::debugger_if;
/**
* debugger access type
Expand Down
3 changes: 2 additions & 1 deletion incl/iss/debugger/target_adapter_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
namespace iss {
namespace debugger {

struct target_adapter_base : public target_adapter_if {
class target_adapter_base : public target_adapter_if {
public:

target_adapter_base(iss::debugger::server_if *srv)
: srv(srv)
Expand Down
13 changes: 8 additions & 5 deletions incl/iss/debugger/target_adapter_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,25 @@ using data_func = std::function<void (const std::string&)>;
/* Function to do logging */
using log_func = void (*)(int level, const char *string, ...);

struct rp_thread_ref {
class rp_thread_ref {
public:
uint64_t val = std::numeric_limits<uint64_t>::max();
};

struct rp_thread_info {
class rp_thread_info {
public:
rp_thread_ref thread_id;
int exists;
char display[256];
char thread_name[32];
char more_display[256];
};

struct target_adapter_if {

class target_adapter_if {
public:
/* Table entry definition */
struct custom_command {
class custom_command {
public:
/* command name */
const char *name;
/* command function */
Expand Down
3 changes: 2 additions & 1 deletion incl/iss/debugger_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@

namespace iss {

struct debugger_if {
class debugger_if {
public:
/**
* destructor
*/
Expand Down
6 changes: 4 additions & 2 deletions incl/iss/jit/MCJIThelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ namespace vm {
/**
* MCJIT helper class
*/
struct MCJIT_helper {
class MCJIT_helper {
public:
/**
* constructor
* @param context the LLVM context to use
Expand Down Expand Up @@ -130,7 +131,8 @@ struct MCJIT_helper {
/**
* template wrapper to get get rid of casting in code
*/
template <typename ARCH> struct MCJIT_arch_helper : public MCJIT_helper {
template <typename ARCH> class MCJIT_arch_helper : public MCJIT_helper {
public:
using fPtr_t = typename arch::traits<ARCH>::addr_t (*)();
/**
* constructor
Expand Down
4 changes: 2 additions & 2 deletions incl/iss/log_categories.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <util/logging.h>
namespace logging {
struct connection {};
struct disass {};
class connection {};
class disass {};
}

#endif /* DBT_CORE_INCL_ISS_LOG_CATEGORIES_H_ */
3 changes: 2 additions & 1 deletion incl/iss/vm_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ template <typename ARCH> class vm_base : public debugger_if, public vm_if {
}

llvm::ConstantInt *reg_index(unsigned r) const { return llvm::ConstantInt::get(getContext(), llvm::APInt(16, r)); }
struct processing_pc_entry {
class processing_pc_entry {
public:
processing_pc_entry(vm_base<ARCH> &vm, vm_base<ARCH>::virt_addr_t pc_v, vm_base<ARCH>::phys_addr_t pc_p)
: vm(vm) {
vm.processing_pc.push(std::make_pair(pc_v, pc_p));
Expand Down
11 changes: 7 additions & 4 deletions incl/iss/vm_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@

namespace iss {
// forward declaration
struct arch_if;
class arch_if;

struct vm_if {
class vm_if {
public:
/**
* get the underlying class of the core to be simulated
* @return pointer to the core
Expand Down Expand Up @@ -88,7 +89,8 @@ struct vm_if {
/**
* exception class signaling an error while decoding an instruction
*/
struct decoding_error : public std::runtime_error {
class decoding_error : public std::runtime_error {
public:
const uint64_t addr;
decoding_error(uint64_t a)
: std::runtime_error("decoding error")
Expand All @@ -97,7 +99,8 @@ struct decoding_error : public std::runtime_error {
/**
* exception class signaling end of simulation, state contains the result
*/
struct simulation_stopped : public std::runtime_error {
class simulation_stopped : public std::runtime_error {
public:
const int state;
simulation_stopped(int s)
: std::runtime_error("simulation stopped")
Expand Down
6 changes: 4 additions & 2 deletions incl/iss/vm_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ enum access_type {

enum address_type { LOGICAL = 0x10, VIRTUAL = 0x20, PHYSICAL = 0x30, ADDRESS_TYPE = 0x30 };

struct addr_t {
class addr_t {
public:
const unsigned type{READ | PHYSICAL};
unsigned space{0};
uint64_t val{0};
Expand Down Expand Up @@ -133,7 +134,8 @@ inline std::ostream &operator<<(std::ostream &os, const addr_t &op) {
return os;
}

template <address_type TYPE> struct typed_addr_t : public addr_t {
template <address_type TYPE> class typed_addr_t : public addr_t {
public:
constexpr typed_addr_t()
: addr_t(READ, TYPE, 0){};
constexpr typed_addr_t(access_type t, uint64_t v)
Expand Down
3 changes: 2 additions & 1 deletion src/gdb_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ inline bool compare(string input, string match, size_t offset = 0) {
return (input.length() >= (offset + match.length())) && (input.compare(offset, match.length(), match) == 0);
}

struct gdb_resp_msg {
class gdb_resp_msg {
public:
gdb_resp_msg() = default;

explicit gdb_resp_msg(bool is_notification): start_char(is_notification?'%':'$') {}
Expand Down

0 comments on commit 35d9bbf

Please sign in to comment.