[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57862] branches/soc-2013-depsgraph_mt/ source/blender/windowmanager/intern/wm_event_system.c: Code cleanup: replace bunch of ifdef+if(do_debug_handler) with

Sergey Sharybin sergey.vfx at gmail.com
Fri Jun 28 23:58:48 CEST 2013


Revision: 57862
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57862
Author:   nazgul
Date:     2013-06-28 21:58:48 +0000 (Fri, 28 Jun 2013)
Log Message:
-----------
Code cleanup: replace bunch of ifdef+if(do_debug_handler) with
a macro which checks all the stuff and keeps code easy to follow.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c

Modified: branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c	2013-06-28 21:24:38 UTC (rev 57861)
+++ branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c	2013-06-28 21:58:48 UTC (rev 57862)
@@ -1743,7 +1743,15 @@
 	        /* comment this out to flood the console! (if you really want to test) */
 	        !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)
 	        ;
+#  if defined __GNUC__ || defined __sun
+#    define PRINT(format, args ...) { if (do_debug_handler) printf(format, ##args); } (void)0
+#  else
+#    define PRINT(format, ...) { if (do_debug_handler) printf(__VA_ARGS__); } (void)0
+#  endif
+#else
+#  define PRINT(format, ...)
 #endif
+
 	wmWindowManager *wm = CTX_wm_manager(C);
 	wmEventHandler *handler, *nexthandler;
 	int action = WM_HANDLER_CONTINUE;
@@ -1779,28 +1787,16 @@
 				wmKeyMap *keymap = WM_keymap_active(wm, handler->keymap);
 				wmKeyMapItem *kmi;
 
-#ifndef NDEBUG
-				if (do_debug_handler) {
-					printf("%s:   checking '%s' ...", __func__, keymap->idname);
-				}
-#endif
+				PRINT("%s:   checking '%s' ...", __func__, keymap->idname);
 
 				if (!keymap->poll || keymap->poll(C)) {
 
-#ifndef NDEBUG
-					if (do_debug_handler) {
-						printf("pass\n");
-					}
-#endif
+					PRINT("pass\n");
 
 					for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
 						if (wm_eventmatch(event, kmi)) {
 
-#ifndef NDEBUG
-							if (do_debug_handler) {
-								printf("%s:     item matched '%s'\n", __func__, kmi->idname);
-							}
-#endif
+							PRINT("%s:     item matched '%s'\n", __func__, kmi->idname);
 
 							/* weak, but allows interactive callback to not use rawkey */
 							event->keymap_idname = kmi->idname;
@@ -1819,21 +1815,13 @@
 									if (G.debug & (G_DEBUG_EVENTS | G_DEBUG_HANDLERS))
 										printf("%s:       handled - and pass on! '%s'\n", __func__, kmi->idname);
 								
-#ifndef NDEBUG
-								if (do_debug_handler) {
-									printf("%s:       un-handled '%s'...", __func__, kmi->idname);
-								}
-#endif
+									PRINT("%s:       un-handled '%s'...", __func__, kmi->idname);
 							}
 						}
 					}
 				}
 				else {
-#ifndef NDEBUG
-					if (do_debug_handler) {
-						printf("fail\n");
-					}
-#endif
+					PRINT("fail\n");
 				}
 			}
 			else if (handler->ui_handle) {
@@ -1910,6 +1898,8 @@
 	if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL))
 		wm_cursor_arrow_move(CTX_wm_window(C), event);
 
+#undef PRINT
+
 	return action;
 }
 




More information about the Bf-blender-cvs mailing list