Skip to content

Commit

Permalink
Added a list of excluded methods as well as classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblotsky committed Sep 22, 2011
1 parent e3a9500 commit 7f3eea2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
27 changes: 21 additions & 6 deletions C++/E_Reporter.cpp
Expand Up @@ -25,8 +25,18 @@ const string START_CHAR = "+";
const string END_CHAR = "\\";

// report exclusions
const int NUM_EXCLUDED_CLASSES = 2;
const string EXCLUDED_CLASSES[NUM_EXCLUDED_CLASSES] = {"E_Command", "E_Node"};
const int NUM_EXCLUDED_CLASSES = 1;
const int NUM_EXCLUDED_METHODS = 5;
const string EXCLUDED_CLASSES[NUM_EXCLUDED_CLASSES] = {
"E_Command"
};
const string EXCLUDED_METHODS[NUM_EXCLUDED_METHODS] = {
"print_prompt",
"get_color",
"get_color_at",
"print_color",
"get_node_at"
};

// statics
static int stack_depth = 0;
Expand Down Expand Up @@ -123,7 +133,7 @@ FunctionType get_function_type(const string& class_name, const string& function_
void prologue(const string& class_name, const string& function_name) {

if (!debug) { return; }
if (is_excluded(class_name)) { return; }
if (is_excluded(class_name, function_name)) { return; }

// skip a line if there has been a report at the current depth
if (been_function_at_depth || been_value_at_depth) { debug_indent_line(); }
Expand All @@ -138,7 +148,7 @@ void prologue(const string& class_name, const string& function_name) {
void epilogue(const string& class_name, const string& function_name) {

if (!debug) { return; }
if (is_excluded(class_name)) { return; }
if (is_excluded(class_name, function_name)) { return; }

decrement_depth();
report_function(END, class_name, function_name);
Expand Down Expand Up @@ -209,13 +219,18 @@ void decrement_depth() {
been_value_at_depth = false;
}

// returns true if the current class name is excluded from debugging
bool is_excluded(const string& class_name) {
// returns true if the current class or function name is excluded from debugging
bool is_excluded(const string& class_name, const string& method_name) {
for(int i = 0; i < NUM_EXCLUDED_CLASSES; i++) {
if (class_name == EXCLUDED_CLASSES[i]) {
return true;
}
}
for(int i = 0; i < NUM_EXCLUDED_METHODS; i++) {
if (method_name == EXCLUDED_METHODS[i]) {
return true;
}
}
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions C++/E_Reporter.h
Expand Up @@ -8,9 +8,9 @@ using std::string;
// TODO: make this a singleton class

// enums
enum FunctionType {CONSTRUCTOR, DESTRUCTOR, METHOD, PROCEDURE};
enum ReportStage {START, END};
enum PointerType {INT, LONG_INT, LONG, LONG_LONG, STRING, CHAR, VOID};
enum FunctionType {CONSTRUCTOR, DESTRUCTOR, METHOD, PROCEDURE};
enum ReportStage {START, END};
enum PointerType {INT, LONG_INT, LONG, LONG_LONG, STRING, CHAR, VOID};

// constants
const string QUOTE = "\"";
Expand All @@ -34,7 +34,7 @@ FunctionType get_function_type(const string& class_name, const string& function_
void increment_depth();
void decrement_depth();
void stay_at_depth();
bool is_excluded(const string& class_name);
bool is_excluded(const string& class_name, const string& method_name);
string build_string(const string& token, const int n);
string indent_buffer();
string alignment_buffer(const int num_already_printed = 0);
Expand Down

0 comments on commit 7f3eea2

Please sign in to comment.