Author: dmacvicar
Date: Wed Jun 27 17:52:19 2007
New Revision: 39058
URL: http://svn.opensuse.org/viewcvs/yast?rev=39058&view=rev
Log:
SCR calls dont crash anymore
Modified:
branches/tmp/dmacvicar/ruby-yast/examples/ruby/Bar.rb
branches/tmp/dmacvicar/ruby-yast/examples/ruby/scr.ycp
branches/tmp/dmacvicar/ruby-yast/examples/ruby/ycp_from_ruby.rb
branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.cc
branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.h
branches/tmp/dmacvicar/ruby-yast/src/ruby/YCP.cc
branches/tmp/dmacvicar/ruby-yast/src/ruby/YRubyNamespace.cc
Modified: branches/tmp/dmacvicar/ruby-yast/examples/ruby/Bar.rb
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/ruby-yast/examples/ruby/Bar.rb?rev=39058&r1=39057&r2=39058&view=diff
==============================================================================
--- branches/tmp/dmacvicar/ruby-yast/examples/ruby/Bar.rb (original)
+++ branches/tmp/dmacvicar/ruby-yast/examples/ruby/Bar.rb Wed Jun 27 17:52:19 2007
@@ -3,6 +3,6 @@
module Bar
def self.try
m = YaST::Module.new("SCR")
- return m.Read(".proc.modules")
+ return m.Read(".proc.modules").class.to_s
end
end
Modified: branches/tmp/dmacvicar/ruby-yast/examples/ruby/scr.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/ruby-yast/examples/ruby/scr.ycp?rev=39058&r1=39057&r2=39058&view=diff
==============================================================================
--- branches/tmp/dmacvicar/ruby-yast/examples/ruby/scr.ycp (original)
+++ branches/tmp/dmacvicar/ruby-yast/examples/ruby/scr.ycp Wed Jun 27 17:52:19 2007
@@ -1,4 +1,3 @@
-
{
import "Bar";
string result = (string) Bar::try();
Modified: branches/tmp/dmacvicar/ruby-yast/examples/ruby/ycp_from_ruby.rb
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/ruby-yast/examples/ruby/ycp_from_ruby.rb?rev=39058&r1=39057&r2=39058&view=diff
==============================================================================
--- branches/tmp/dmacvicar/ruby-yast/examples/ruby/ycp_from_ruby.rb (original)
+++ branches/tmp/dmacvicar/ruby-yast/examples/ruby/ycp_from_ruby.rb Wed Jun 27 17:52:19 2007
@@ -1,5 +1,22 @@
require 'yast'
+m = YaST::Module.new("SCR")
+m.Read(".proc.modules")
+
+exit
+m = YaST::Module.new("Timezone")
+zonemap = m.get_zonemap()
+puts zonemap.class
+zonemap.each do | element |
+ element.each do | key, value |
+ value.each do | k, v |
+ puts "#{k} #{v}"
+ end
+ end
+end
+
+
+exit
m = YaST::Module.new("Arch")
puts m.sparc32
puts m.arch_short
Modified: branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.cc?rev=39058&r1=39057&r2=39058&view=diff
==============================================================================
--- branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.cc (original)
+++ branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.cc Wed Jun 27 17:52:19 2007
@@ -9,6 +9,9 @@
#include
#include
#include
+#include
+#include
+#include
#include
#include "Y2RubyTypeConv.h"
@@ -65,6 +68,11 @@
}
return rblist;
}
+ else if (ycpval->isSymbol())
+ {
+ YCPSymbol symbol = ycpval->asSymbol();
+ return rb_intern(symbol->symbol_cstr());
+ }
rb_raise( rb_eRuntimeError, "Conversion of YCP type %s not supported", ycpval->toString().c_str() );
return Qnil;
}
@@ -73,9 +81,12 @@
YCPValue
rbvalue_2_ycpvalue( VALUE value )
{
+ y2internal("type: '%d'", TYPE(value));
// TODO conver integers, and add support for lists, ah, and boleans!
switch (TYPE(value))
{
+ case T_NIL:
+ return YCPVoid();
case T_STRING:
return YCPString(RSTRING (value)->ptr);
break;
@@ -99,6 +110,11 @@
// FIXME
return YCPValue();
break;
+ case T_SYMBOL:
+ y2internal("mira un mono!!!");
+ //return YCPSymbol(RSTRING(rb_funcall(value, rb_intern("to_s"), 0))->ptr);
+ return YCPSymbol(rb_id2name(rb_to_id(value)));
+
case T_DATA:
rb_raise( rb_eRuntimeError, "Object");
break;
@@ -108,3 +124,10 @@
return YCPValue();
}
}
+
+YCPValue
+rbvalue_2_ycppath( VALUE value )
+{
+ VALUE stringrep = rb_funcall(value, rb_intern("to_s"), 0);
+ return YCPPath(RSTRING(stringrep)->ptr);
+}
\ No newline at end of file
Modified: branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.h?rev=39058&r1=39057&r2=39058&view=diff
==============================================================================
--- branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.h (original)
+++ branches/tmp/dmacvicar/ruby-yast/src/ruby/Y2RubyTypeConv.h Wed Jun 27 17:52:19 2007
@@ -19,5 +19,8 @@
YCPValue
rbvalue_2_ycpvalue( VALUE value );
+YCPValue
+rbvalue_2_ycppath( VALUE value );
+
#endif
Modified: branches/tmp/dmacvicar/ruby-yast/src/ruby/YCP.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/ruby-yast/src/ruby/YCP.cc?rev=39058&r1=39057&r2=39058&view=diff
==============================================================================
--- branches/tmp/dmacvicar/ruby-yast/src/ruby/YCP.cc (original)
+++ branches/tmp/dmacvicar/ruby-yast/src/ruby/YCP.cc Wed Jun 27 17:52:19 2007
@@ -143,7 +143,7 @@
// the func name (1st argument, is a symbol
// lets convert it to string
VALUE symbol_str = rb_funcall(symbol, rb_intern("to_s"), 0);
- y2internal("Function: [%s::%s] params: [%d]\n", RSTRING(namespace_name)->ptr, RSTRING(symbol_str)->ptr, argc);
+ y2internal("Dynamic Proxy: [%s::%s] with [%d] params\n", RSTRING(namespace_name)->ptr, RSTRING(symbol_str)->ptr, argc);
//Check_Type(argv[0], T_STRING);
//y2internal(RSTRING (symbol)->ptr);
@@ -158,10 +158,11 @@
// this is a hack before the builtin namespaces get a uniform interface:
if (! strcmp (RSTRING (namespace_name)->ptr, "SCR"))
{
+ y2internal("Dynamic Proxy: [%s::%s] is a call to SCR\n", RSTRING(namespace_name)->ptr, RSTRING(symbol_str)->ptr);
YCPValue res;
res = ycp_call_builtin( RSTRING(namespace_name)->ptr, RSTRING(symbol_str)->ptr, argc, argv);
- //return ycpvalue_2_rbvalue(res);
- return Qnil;
+ return ycpvalue_2_rbvalue(res);
+ //return Qnil;
}
Y2Component *c;
@@ -241,6 +242,7 @@
string qualified_name_s = module_name + "::" + func_name;
const char *qualified_name = qualified_name_s.c_str ();
+ y2milestone("Qualified name '%s'", qualified_name);
/*
this does not work across namespaces
TableEntry *bi_te = static_declarations.symbolTable ()->find (qualified_name);
@@ -261,7 +263,7 @@
y2error ("No such builtin '%s'", qualified_name);
return YCPNull ();
}
-
+ y2milestone("builtin '%s' found.", module_name.c_str());
// construct a builtin call using the proper overloaded builtin
YEBuiltin *bi_call = new YEBuiltin (bi_dt);
@@ -275,12 +277,21 @@
// go through the actual parameters
unsigned j;
- for (j = 0; j < argc; ++j)
+ for (j = 1; j < argc; ++j)
{
+ y2milestone("builtin param '%d'", j-1);
// convert the value according to the expected type:
constTypePtr param_tp = (j == 0)? Type::Path : Type::Any;
-
- YCPValue param_v = rbvalue_2_ycpvalue(argv[j] /*, param_tp */);
+ y2milestone("builtin param '%d' 1", j-1);
+
+ // convert the first argument to a path
+ YCPValue param_v;
+ if ( j == 1 )
+ param_v = rbvalue_2_ycppath(argv[j]);
+ else
+ param_v = rbvalue_2_ycpvalue(argv[j] /*, param_tp */);
+
+ y2milestone("builtin param '%d' 2", j-1);
if (param_v.isNull ())
{
// an error has already been reported, now refine it.
Modified: branches/tmp/dmacvicar/ruby-yast/src/ruby/YRubyNamespace.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/ruby-yast/src/ruby/YRubyNamespace.cc?rev=39058&r1=39057&r2=39058&view=diff
==============================================================================
--- branches/tmp/dmacvicar/ruby-yast/src/ruby/YRubyNamespace.cc (original)
+++ branches/tmp/dmacvicar/ruby-yast/src/ruby/YRubyNamespace.cc Wed Jun 27 17:52:19 2007
@@ -92,7 +92,7 @@
*/
virtual bool appendParameter (const YCPValue& arg)
{
- y2milestone("Adding parameter to function %s::%s of type %s", m_module_name.c_str(), m_local_name.c_str(), arg->valuetype_str());
+ y2internal("Adding parameter to function %s::%s of type %s", m_module_name.c_str(), m_local_name.c_str(), arg->valuetype_str());
m_call->add (arg);
return true;
}
@@ -222,7 +222,7 @@
signature += ",";
}
signature += ")";
- y2milestone("going to parse signature: '%s'", signature.c_str());
+ y2internal("going to parse signature: '%s'", signature.c_str());
sym_tp = Type::fromSignature(signature);
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org