]> icculus.org git repositories - duncan/yast2-ruby-bindings.git/blob - examples/ruby/libycp.rb
- Lot of fixes and support for the UI!!!
[duncan/yast2-ruby-bindings.git] / examples / ruby / libycp.rb
1 require 'ryast'
2 include Ryast
3
4 def get_ns(name)
5   import = Import.new(name)
6   ns = import.name_space
7   puts ns.filename
8   #ns.initialize
9
10   return ns
11 end
12
13 component = Y2ComponentBroker.get_namespace_component("Arch");
14 #puts component.methods
15 #Y2Namespace *ns = c->import(RSTRING (namespace_name)->ptr);
16 nsname = "Arch"
17 fncname = "sparc32"
18 ns = get_ns(nsname)
19 #/**/
20 #t = Type.from_signature("bool()")
21 #puts t
22 sym = ns.table.find(fncname);
23 puts sym.class
24 if (sym.nil?)
25   raise ("No such symbol #{nsname}::#{fncname}")
26 elsif (sym.sentry.is_variable or sym.sentry.reference? )
27   # set the variable
28   #ret_yv = YCP_getset_variable (aTHX_ ns_name, sym_te->sentry (), args);
29 else
30   fnccall = ns.create_function_call(fncname, nil)
31   if fnccall.nil?
32     raise("No such function #{nsname}::#{fncname}")
33   end
34 end
35 exit
36
37 h = ns.lookup_symbol("sparc32")
38 puts h.class
39 exit
40 function = ns.create_function_call("sparc32",0)
41 #call->appendParameter (v);
42 function.finish_parameters
43 res = function.evaluate_call
44 puts res
45 exit