commit 8227290f2aadf071e88f2382ba7e9e563e5cb169
parent 1469d184365c3c440be2921f73bcaf618e6415ed
Author: Kyle Milz <kyle@0x30.net>
Date: Fri, 29 Jul 2016 20:33:32 -0600
src: use better c++ style
Diffstat:
3 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/runtime.cc b/src/runtime.cc
@@ -21,37 +21,37 @@
#include "runtime.h"
RuntimeProcess::RuntimeProcess(af_unix &sock) :
- socket(sock)
+ m_socket(sock)
{
uint16_t sz;
assert(sizeof(pid_t) == 4);
// Protocol defined in lib/runtime.c send_static().
// This is the receive side of things.
- socket.read_all(m_ver);
- socket.read_all(num_tus);
- socket.read_all(lines_total);
- socket.read_all(process_id);
- socket.read_all(parent_process_id);
- socket.read_all(process_group);
+ m_socket.read_all(m_ver);
+ m_socket.read_all(m_num_tus);
+ m_socket.read_all(m_lines_total);
+ m_socket.read_all(m_pid);
+ m_socket.read_all(m_ppid);
+ m_socket.read_all(m_pgrp);
- socket.read_all(sz);
- program_name.resize(sz);
- socket.read_all((uint8_t *)&program_name[0], sz);
+ m_socket.read_all(sz);
+ m_progname.resize(sz);
+ m_socket.read_all((uint8_t *)&m_progname[0], sz);
- socket.read_all(sz);
+ m_socket.read_all(sz);
m_cwd.resize(sz);
- socket.read_all((uint8_t *)&m_cwd[0], sz);
+ m_socket.read_all((uint8_t *)&m_cwd[0], sz);
- translation_units.resize(num_tus);
- for (auto &t : translation_units) {
- socket.read_all(sz);
+ m_tus.resize(m_num_tus);
+ for (auto &t : m_tus) {
+ m_socket.read_all(sz);
t.file_name.resize(sz);
- socket.read_all((uint8_t *)&t.file_name[0], sz);
- socket.read_all(t.num_lines);
- socket.read_all(t.inst_sites);
+ m_socket.read_all((uint8_t *)&t.file_name[0], sz);
+ m_socket.read_all(t.num_lines);
+ m_socket.read_all(t.inst_sites);
- t.execution_counts.resize(t.num_lines, 0);
+ t.exec_diffs.resize(t.num_lines, 0);
t.source.resize(t.num_lines);
read_source(t);
}
@@ -73,20 +73,20 @@ RuntimeProcess::read_source(struct TranslationUnit &t)
void
RuntimeProcess::read_executions()
{
- for (auto &t : translation_units) {
+ for (auto &t : m_tus) {
uint8_t flag = 0;
- socket.read_all(flag);
+ m_socket.read_all(flag);
if (flag == 0) {
- std::fill(t.execution_counts.begin(), t.execution_counts.end(), 0);
+ std::fill(t.exec_diffs.begin(), t.exec_diffs.end(), 0);
continue;
}
size_t bytes_total = t.num_lines * sizeof(uint32_t);
- socket.read_all((uint8_t *)&t.execution_counts[0], bytes_total);
+ m_socket.read_all((uint8_t *)&t.exec_diffs[0], bytes_total);
}
// Send response back
uint8_t msg_type = 1;
- assert(socket.write_all(&msg_type, 1) == 1);
+ assert(m_socket.write_all(&msg_type, 1) == 1);
}
diff --git a/src/runtime.h b/src/runtime.h
@@ -6,10 +6,10 @@
#include "af_unix.h"
struct TranslationUnit {
- std::string file_name;
- uint32_t num_lines;
- uint32_t inst_sites;
- std::vector<uint32_t> execution_counts;
+ std::string file_name;
+ uint32_t num_lines;
+ uint32_t inst_sites;
+ std::vector<uint32_t> exec_diffs;
std::vector<std::string> source;
};
@@ -20,18 +20,18 @@ public:
// Protocol defined in lib/runtime.c send_static().
uint8_t m_ver;
- std::string program_name;
+ std::string m_progname;
std::string m_cwd;
- uint32_t num_tus;
- uint32_t lines_total;
- pid_t process_id;
- pid_t parent_process_id;
- pid_t process_group;
- std::vector<TranslationUnit> translation_units;
+ uint32_t m_num_tus;
+ uint32_t m_lines_total;
+ pid_t m_pid;
+ pid_t m_ppid;
+ pid_t m_pgrp;
+ std::vector<TranslationUnit> m_tus;
private:
void read_source(struct TranslationUnit &);
- af_unix socket;
+ af_unix m_socket;
};
#endif
diff --git a/src/term_main.cc b/src/term_main.cc
@@ -52,10 +52,10 @@ draw_source(RuntimeProcess &conn)
erase();
conn.read_executions();
- auto &t = conn.translation_units[tu];
+ auto &t = conn.m_tus[tu];
total_executions = 0;
for (int i = offset; i < (size_y - 2 + offset) && i < t.num_lines; i++) {
- uint32_t e = t.execution_counts[i + 1];
+ uint32_t e = t.exec_diffs[i + 1];
std::string l = t.source[i];
total_executions += e;
@@ -87,7 +87,7 @@ draw_source(RuntimeProcess &conn)
offset++;
else if (ch == 'k' && offset > 0)
offset--;
- else if (ch == 'l' && tu < conn.num_tus)
+ else if (ch == 'l' && tu < conn.m_num_tus)
tu++;
else if (ch == 'h' && tu > 0)
tu--;
@@ -96,7 +96,7 @@ draw_source(RuntimeProcess &conn)
clrtoeol();
printw("%s (%i): [%s] [%i fps] [%ik execs/s] ",
- conn.program_name.c_str(), conn.num_tus,
+ conn.m_progname.c_str(), conn.m_num_tus,
t.file_name.c_str(), fps, eps / 1000);
for (int i = 1; i <= 5; i++) {
attron(COLOR_PAIR(i));