[yast-devel] Objects in YCP (HackWeek?)
Hi, I have this idea and Lukas has pointed out that someone could be interested in it for the Hack Week, so here goes: As I am thinking about refactoring the network code, not having objects in YCP is a pain. The twist is, I don't want to add YCP objects but use Ruby objects. (We can already use Perl objects, yast2-storage does it, but it's limited.) Here's sample code to show how it could look, modeled after http://www.ruby-doc.org/stdlib-1.8.7/libdoc/uri/rdoc/classes/URI.html { import "Assert"; // Yes, you can! (also in SP2) // http://svn.opensuse.org/viewvc/yast/trunk/yast2/library/modules/Assert.ycp?v... // Original Ruby code: // require 'uri' import $[ "what": "uri", "language": "ruby", "namespaces": ["URI", "URI::HTTP"] ]; /* The above complicated syntax enables - loading modules from elsewhere than /usr/share/YaST2/modules - loading YCP namespaces (Ruby modules (classes)) named otherwise than the file they are in, without needing to annotate them with TYPEINFO (like perl-bindings/pluglib-bindings do) */ // uri = URI.parse("http://www.ruby-lang.org/") any uri = URI::parse("http://www.ruby-lang.org/"); // [1] // assert_equal "http", uri.scheme Assert::Equal("http", uri->scheme()); // newuri = URI::HTTP.build( {:host => 'www.example.com', :path => '/foo/bar'}) any newuri = URI::HTTP::build($[ `host: "www.example.com", `path: "/foo/bar"]); // assert_equal "http://www.example.com/foo/bar", newuri.request_uri Assert::Equal ("http://www.example.com/foo/bar", newuri->request_uri()); } Formally, whereas now YCP has NAMESPACE :: IDENTIFIER ( PARAMS ) which calls a function (a module/class method in Ruby, a class method in Perl), we add EXPRESSION -> IDENTIFIER ( PARAMS ) which calls a method (an instance method in Ruby. [1] "any" is a lie, the type is actually a distinct one, called YCPExternal in C++. We could use "extern" which is currently an unused reserved word in YCP. But URIs are not my target. I am aiming for { any eth = SUSE::Ifcfg::new("eth0"); any br = SUSE::Ifcfg::Bridge::new("br0"); br->startmode(`auto); br->add(eth); /* br->add will also set: eth->bootproto(`none); eth->startmode(br->startmode()); */ any tap = SUSE::Ifcfg::Tap::new("tap0")->tunnel_set_owner("tux"); br->add(tap); foreach(any i, [br, tap, eth], { i->save(); }); } if (you->are_interested()) { you->please()->tell(martin); } -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner kthxbai();
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dne 21.9.2011 14:35, Martin Vidner napsal(a):
Hi,
I have this idea and Lukas has pointed out that someone could be interested in it for the Hack Week, so here goes:
Please use https://features.opensuse.org/feature/new?products%5b%5d=hackweek_7 for entering the project. Thanks Lukas - -- Lukas Ocilka, Appliances Department, SUSE LINUX s.r.o. MD: Jeff Hawn, Jennifer Guild, Alena Hendrichova -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iD8DBQFOee1gVSqMdRCqTiwRAuxsAJ0d1yuEBgmUX57zcjjicx3WnAgTnwCeONzX 4TY4xYd1eNLapT7h2EDvnIw= =meJr -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Wed, Sep 21, 2011 at 03:57:52PM +0200, Lukas Ocilka wrote:
I have this idea and Lukas has pointed out that someone could be interested in it for the Hack Week, so here goes:
Please use https://features.opensuse.org/feature/new?products%5b%5d=hackweek_7 for entering the project.
https://features.opensuse.org/312825 -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
participants (2)
-
Lukas Ocilka
-
Martin Vidner