From 7f3eea27205b2aa955bcdc59c0ae524484c5e572 Mon Sep 17 00:00:00 2001 From: Dmitry Blotsky Date: Thu, 22 Sep 2011 03:43:18 -0400 Subject: [PATCH] Added a list of excluded methods as well as classes. --- C++/E_Reporter.cpp | 27 +++++++++++++++++++++------ C++/E_Reporter.h | 8 ++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/C++/E_Reporter.cpp b/C++/E_Reporter.cpp index 8249827..4f289c5 100644 --- a/C++/E_Reporter.cpp +++ b/C++/E_Reporter.cpp @@ -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; @@ -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(); } @@ -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); @@ -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; } diff --git a/C++/E_Reporter.h b/C++/E_Reporter.h index 72ed05b..86724b9 100644 --- a/C++/E_Reporter.h +++ b/C++/E_Reporter.h @@ -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 = "\""; @@ -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);