[yast-commit] r66200 - /trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc
Author: mvidner Date: Mon Oct 3 17:23:26 2011 New Revision: 66200 URL: http://svn.opensuse.org/viewcvs/yast?rev=66200&view=rev Log: Pass ruby objects as YCPExternal FIXME no reference counting Modified: trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc Modified: trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc?rev=66200&r1=66199&r2=66200&view=diff ============================================================================== --- trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc (original) +++ trunk/ruby-bindings/src/ruby/Y2RubyTypeConv.cc Mon Oct 3 17:23:26 2011 @@ -43,6 +43,7 @@ #include <ycp/YCPSymbol.h> #include <ycp/YCPPath.h> #include <ycp/YCPVoid.h> +#include <ycp/YCPExternal.h> #include <ycp/Import.h> #include <y2util/stringutil.h> @@ -97,6 +98,14 @@ } +#define YCP_EXTERNAL_MAGIC "Ruby object" + +static YCPExternal rbobject_2_ycpexternal( VALUE value ) +{ + YCPExternal ex((void*) value, string(YCP_EXTERNAL_MAGIC), NULL); + return ex; +} + /** * * ycpvalue_2_rbvalue @@ -171,6 +180,14 @@ YCPSymbol symbol = ycpval->asSymbol(); return rb_intern(symbol->symbol_cstr()); } + else if (ycpval->isExternal()) + { + YCPExternal ex = ycpval->asExternal(); + if (ex->magic() == string(YCP_EXTERNAL_MAGIC)) { + return (VALUE)(ex->payload()); // FIXME reference counting + } + y2error("Unexpected magic '%s'.", (ex->magic()).c_str()); + } rb_raise( rb_eTypeError, "Conversion of YCP type %s not supported", ycpval->toString().c_str() ); return Qnil; } @@ -232,6 +249,8 @@ return ryast_yterm_from_rterm(value); } + return rbobject_2_ycpexternal(value); + /* string msg = stringutil::form("Conversion of Ruby type %s not supported", class_name); if (flags & DONT_RAISE) { y2error("%s", msg.c_str()); @@ -239,6 +258,7 @@ rb_raise(rb_eTypeError, msg.c_str()); } return YCPVoid(); + */ } } } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mvidner@svn2.opensuse.org