[yast-commit] r40946 - in /trunk/ruby-bindings/src/ruby: Y2CCRuby.cc Y2RubyTypeConv.cc Y2RubyTypeTerm.cc Y2RubyTypeTerm.h YCP.cc yast.rb
Author: dmacvicar Date: Mon Sep 17 18:26:46 2007 New Revision: 40946 URL: http://svn.opensuse.org/viewcvs/yast?rev=40946&view=rev Log: - Lot of updates to get the UI working Modified: trunk/ruby-bindings/src/ruby/Y2CCRuby.cc trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.cc trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.h trunk/ruby-bindings/src/ruby/YCP.cc trunk/ruby-bindings/src/ruby/yast.rb Modified: trunk/ruby-bindings/src/ruby/Y2CCRuby.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ruby-bindings/src/ruby/Y2CCRuby.cc?rev=40946&r1=40945&r2=40946&view=diff ============================================================================== --- trunk/ruby-bindings/src/ruby/Y2CCRuby.cc (original) +++ trunk/ruby-bindings/src/ruby/Y2CCRuby.cc Mon Sep 17 18:26:46 2007 @@ -46,9 +46,10 @@ // is there a ruby module? // must be the same in Y2CCRuby and Y2RubyComponent string module = YCPPathSearch::find (YCPPathSearch::Module, string (name) + ".rb"); - y2milestone("Find result '%s'", module.c_str()); + if (!module.empty ()) { + y2milestone("Find module result: '%s'", module.c_str()); if (!cruby) { y2milestone("new ruby component"); Modified: trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc?rev=40946&r1=40945&r2=40946&view=diff ============================================================================== --- trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc (original) +++ trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc Mon Sep 17 18:26:46 2007 @@ -96,7 +96,7 @@ } else if (ycpval->isTerm()) { - return ryast_term_from_term(ycpval->asTerm()); + return ryast_rterm_from_yterm(ycpval->asTerm()); } else if (ycpval->isInteger()) { @@ -146,7 +146,9 @@ YCPValue rbvalue_2_ycpvalue( VALUE value ) { - y2internal("type: '%d'", TYPE(value)); + VALUE klass = rb_funcall( value, rb_intern("class"), 0); + std::cout << RSTRING( rb_funcall( klass, rb_intern("to_s"), 0))->ptr << " | " << RSTRING(rb_funcall( value, rb_intern("inspect"), 0))->ptr << std::endl; + //y2internal("type: '%d'", TYPE(value)); // TODO conver integers, and add support for lists, ah, and boleans! switch (TYPE(value)) { @@ -179,6 +181,17 @@ rb_raise( rb_eRuntimeError, "Object"); break; default: + /* get the Term class object */ + VALUE cTerm = rb_funcall( rb_mKernel, rb_intern("const_get"), 1, rb_str_new2("YaST::Term") ); + VALUE is_term = rb_funcall(value, rb_intern("is_a?"), cTerm); + if ( TYPE(is_term) == T_TRUE ) + { + return ryast_yterm_from_rterm(value); + } + else + { + std::cout << "no term" << std::endl; + } std::cout << TYPE(value) << std::endl; rb_raise( rb_eRuntimeError, "Conversion of Ruby type not supported"); return YCPValue(); Modified: trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.cc?rev=40946&r1=40945&r2=40946&view=diff ============================================================================== --- trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.cc (original) +++ trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.cc Mon Sep 17 18:26:46 2007 @@ -48,13 +48,21 @@ } VALUE -ryast_term_from_term( const YCPTerm &term ) +ryast_rterm_from_yterm( const YCPTerm &term ) { VALUE rterm_obj = rb_funcall( ryast_cTerm, rb_intern("new"), 0); ryast_term_set_term( rterm_obj, term ); return rterm_obj; } +YCPTerm +ryast_yterm_from_rterm( VALUE term ) +{ + ryast_Term_Wrapper *wrapper; + Data_Get_Struct(term, ryast_Term_Wrapper, wrapper); + return wrapper->term; +} + static void ryast_term_mark (ryast_Term_Wrapper *r) { @@ -104,7 +112,9 @@ int i=0; for ( ; i<argc; ++i ) { - wrapper->term->add(rbvalue_2_ycpvalue(argv[i])); + std::cout << "Hi! term::add: " << TYPE(argv[i]) << std::endl; + YCPValue value = rbvalue_2_ycpvalue(argv[i]); + wrapper->term->add(value); } } return self; @@ -121,17 +131,17 @@ static VALUE -ryast_term_to_s(VALUE klass) +ryast_term_to_s(VALUE self) { ryast_Term_Wrapper *wrapper; Data_Get_Struct(self, ryast_Term_Wrapper, wrapper); - return rb_str_new2(wrapper->term.toString().c_str()); } void ryast_term_init( VALUE super ) { + //std::cout << "Hi! term" << std::endl; ryast_cTerm = rb_define_class_under( super, "Term", rb_cObject ); rb_define_alloc_func( ryast_cTerm, ryast_term_allocate ); rb_define_method( ryast_cTerm, "initialize", RB_METHOD( ryast_term_initialize ), -1 ); Modified: trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.h?rev=40946&r1=40945&r2=40946&view=diff ============================================================================== --- trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.h (original) +++ trunk/ruby-bindings/src/ruby/Y2RubyTypeTerm.h Mon Sep 17 18:26:46 2007 @@ -27,7 +27,10 @@ void ryast_term_init( VALUE super ); VALUE -ryast_term_from_term( const YCPTerm &term ); +ryast_rterm_from_yterm( const YCPTerm &term ); + +YCPTerm +ryast_yterm_from_rterm( VALUE term ); #endif Modified: trunk/ruby-bindings/src/ruby/YCP.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ruby-bindings/src/ruby/YCP.cc?rev=40946&r1=40945&r2=40946&view=diff ============================================================================== --- trunk/ruby-bindings/src/ruby/YCP.cc (original) +++ trunk/ruby-bindings/src/ruby/YCP.cc Mon Sep 17 18:26:46 2007 @@ -382,9 +382,6 @@ y2internal("%s\n", (*it).c_str() ); } - string module = YCPPathSearch::find (YCPPathSearch::Module, string ("MyModule.ycp")); - y2internal("%s\n", module.c_str() ); - rb_mYaST = rb_define_module("YaST"); rb_cBroker = rb_define_class_under( rb_mYaST, "Module", rb_cObject); Modified: trunk/ruby-bindings/src/ruby/yast.rb URL: http://svn.opensuse.org/viewcvs/yast/trunk/ruby-bindings/src/ruby/yast.rb?rev=40946&r1=40945&r2=40946&view=diff ============================================================================== --- trunk/ruby-bindings/src/ruby/yast.rb (original) +++ trunk/ruby-bindings/src/ruby/yast.rb Mon Sep 17 18:26:46 2007 @@ -32,7 +32,7 @@ def initialize(&block) @buffer = Array.new @term = nil - instance_eval(&block) + @term = instance_eval(&block) end def method_missing(name, *args, &block ) @@ -40,8 +40,8 @@ term = nil elements = block ? nil : args @__to_s = nil # invalidate to_s cache - term = YaST::Term(name) - if elements + term = YaST::Term.new(name.to_s) + if not elements.nil? #puts "here" @buffer << name << "(" elements.each do | e | @@ -54,14 +54,15 @@ # puts "there" @buffer << name << "(" r = instance_eval(&block) - term.add(r) if r + puts term.class + term.add(r) if not r.nil? @buffer << ") " end return term end def to_s - return @buffer.to_s + return @term.to_s end end -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
dmacvicar@svn.opensuse.org