Hello community,

here is the log from the commit of package yast2-ruby-bindings for 
openSUSE:Factory checked in at 2016-11-17 12:20:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-ruby-bindings (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-ruby-bindings"

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-ruby-bindings/yast2-ruby-bindings.changes  
2016-11-01 09:49:38.000000000 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new/yast2-ruby-bindings.changes 
    2016-11-17 12:20:46.000000000 +0100
@@ -1,0 +2,8 @@
+Tue Nov 15 10:34:51 UTC 2016 - [email protected]
+
+- Improved debugger support: catch the magic debugging key
+  combination (Shift+Ctrl+Alt+D in Qt) returned by UI calls and
+  start the Ruby debugger when received (FATE#318421)
+- 3.2.2
+
+-------------------------------------------------------------------

Old:
----
  yast2-ruby-bindings-3.2.1.tar.bz2

New:
----
  yast2-ruby-bindings-3.2.2.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-ruby-bindings.spec ++++++
--- /var/tmp/diff_new_pack.DEVtN5/_old  2016-11-17 12:20:47.000000000 +0100
+++ /var/tmp/diff_new_pack.DEVtN5/_new  2016-11-17 12:20:47.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ruby-bindings
-Version:        3.2.1
+Version:        3.2.2
 Release:        0
 Url:            https://github.com/yast/yast-ruby-bindings
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-ruby-bindings-3.2.1.tar.bz2 -> yast2-ruby-bindings-3.2.2.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.2.1/package/yast2-ruby-bindings.changes 
new/yast2-ruby-bindings-3.2.2/package/yast2-ruby-bindings.changes
--- old/yast2-ruby-bindings-3.2.1/package/yast2-ruby-bindings.changes   
2016-10-26 12:58:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.2.2/package/yast2-ruby-bindings.changes   
2016-11-15 15:35:44.000000000 +0100
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Tue Nov 15 10:34:51 UTC 2016 - [email protected]
+
+- Improved debugger support: catch the magic debugging key
+  combination (Shift+Ctrl+Alt+D in Qt) returned by UI calls and
+  start the Ruby debugger when received (FATE#318421)
+- 3.2.2
+
+-------------------------------------------------------------------
 Wed Oct 26 09:46:54 UTC 2016 - [email protected]
 
 - fix crash when references passed between clients (bsc#935385)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.2.1/package/yast2-ruby-bindings.spec 
new/yast2-ruby-bindings-3.2.2/package/yast2-ruby-bindings.spec
--- old/yast2-ruby-bindings-3.2.1/package/yast2-ruby-bindings.spec      
2016-10-26 12:58:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.2.2/package/yast2-ruby-bindings.spec      
2016-11-15 15:35:44.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ruby-bindings
-Version:        3.2.1
+Version:        3.2.2
 Url:            https://github.com/yast/yast-ruby-bindings
 Release:        0
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.2.1/src/binary/Yast.cc 
new/yast2-ruby-bindings-3.2.2/src/binary/Yast.cc
--- old/yast2-ruby-bindings-3.2.1/src/binary/Yast.cc    2016-10-26 
12:58:09.000000000 +0200
+++ new/yast2-ruby-bindings-3.2.2/src/binary/Yast.cc    2016-11-15 
15:35:45.000000000 +0100
@@ -34,6 +34,8 @@
 #include <ycp/YCPValue.h>
 #include <ycp/YCPVoid.h>
 #include <ycp/YCPCode.h>
+#include <ycp/YCPSymbol.h>
+#include <ycp/YCPMap.h>
 #include <ycp/YCPByteblock.h>
 #include <ycp/Import.h>
 #include <ycp/y2log.h>
@@ -166,6 +168,80 @@
   YaST::ee.setLinenumber(FIX2INT(lineno));
 }
 
+/**
+ * Returns true if the function name is an UI user input function which returns
+ * a symbol.
+ * @param  function_name name of the function
+ * @return true/false
+ */
+static bool ui_input_function(const char *function_name)
+{
+    return strcmp(function_name, "UserInput") == 0  ||
+        strcmp(function_name, "TimeoutUserInput") == 0 ||
+        strcmp(function_name, "PollInput") == 0;
+}
+
+/**
+ * Returns true if the input symbol starts debugging.
+ * @param  val YCPSymbol returned from an UI input call
+ * @return true/false
+ */
+static bool is_debug_symbol(YCPValue val)
+{
+    return !val.isNull() && val->isSymbol() &&
+        val->asSymbol()->symbol() == "debugHotkey";
+}
+
+/**
+ * Returns true if the function name is an event function returning a map.
+ * @param  function_name name of the function
+ * @return true/false
+ */
+static bool ui_event_function(const char *function_name)
+{
+    return strcmp(function_name, "WaitForEvent") == 0;
+}
+
+/**
+ * Returns true if the input is a debug UI event.
+ * @param  val YCPMap returned from the UI::WaitForEvent call
+ * @return true/false
+ */
+static bool is_debug_event(YCPValue val)
+{
+    // is it a map?
+    if (val.isNull() || !val->isMap())
+        return false;
+
+    YCPMap map = val->asMap();
+
+    YCPValue event_type = map->value(YCPString("EventType"));
+    // is map["EventType"] == "DebugEvent"?
+    if (event_type.isNull() || !event_type->isString() ||
+        event_type->asString()->value() != "DebugEvent")
+        return false;
+
+    YCPValue event_id = map->value(YCPString("ID"));
+    // is map["ID"] == :debugHotkey?
+    return !event_id.isNull() && event_id->isSymbol() &&
+        event_id->asSymbol()->symbol() == "debugHotkey";
+}
+
+/**
+ * Start the Ruby debugger, it calls "Yast::Debugger.start" Ruby code.
+ * See file ../ruby/yast/debugger.rb for more details.
+ */
+static void start_ruby_debugger()
+{
+    y2milestone("Starting the Ruby debugger...");
+
+    rb_require("yast/debugger");
+    // call "Yast::Debugger.start"
+    VALUE module = rb_const_get(rb_cObject, rb_intern("Yast"));
+    VALUE klass = rb_const_get(module, rb_intern("Debugger"));
+    rb_funcall(klass, rb_intern("start"), 0);
+}
+
 /*
  * call_ycp_function
  *
@@ -261,6 +337,21 @@
       RB_GC_GUARD(val);
       rb_funcall(argv[i->first], rb_intern("value="), 1, val);
     }
+
+    // hack: handle the Shift+Ctrl+Alt+D debugging magic key combination
+    // returned from UI calls, start the Ruby debugger when the magic key is 
received
+    if (strcmp(namespace_name, "UI") == 0)
+    {
+        if (
+            (ui_input_function(function_name) && is_debug_symbol(res)) ||
+            (ui_event_function(function_name) && is_debug_event(res))
+        )
+        {
+          y2milestone("UI::%s() caught magic debug key: %s", function_name, 
res->toString().c_str());
+          start_ruby_debugger();
+        }
+    }
+
     return ycpvalue_2_rbvalue(res);
   }
 }


Reply via email to