当前位置: 首页>>代码示例>>Java>>正文


Java IRubyObject.toJava方法代码示例

本文整理汇总了Java中org.jruby.runtime.builtin.IRubyObject.toJava方法的典型用法代码示例。如果您正苦于以下问题:Java IRubyObject.toJava方法的具体用法?Java IRubyObject.toJava怎么用?Java IRubyObject.toJava使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jruby.runtime.builtin.IRubyObject的用法示例。


在下文中一共展示了IRubyObject.toJava方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enter

import org.jruby.runtime.builtin.IRubyObject; //导入方法依赖的package包/类
@Override
public Object enter( String entryPointName, Executable executable, ExecutionContext executionContext, Object... arguments ) throws NoSuchMethodException, ParsingException, ExecutionException
{
	entryPointName = toRubyStyle( entryPointName );
	Ruby rubyRuntime = getRubyRuntime( executionContext );

	// Note that we're using the shared compilerRuntime to do the
	// conversions, so that we can cache Java proxies. It's very, very
	// slow if we have to generate them on the fly every time!

	IRubyObject[] rubyArguments = JavaUtil.convertJavaArrayToRuby( compilerRuntime, arguments );
	try
	{
		IRubyObject value = rubyRuntime.getTopSelf().callMethod( rubyRuntime.getCurrentContext(), entryPointName, rubyArguments );
		return value.toJava( Object.class );
	}
	catch( RaiseException x )
	{
		throw createExecutionException( x );
	}
	finally
	{
		rubyRuntime.getOut().flush();
		rubyRuntime.getErr().flush();
	}
}
 
开发者ID:tliron,项目名称:scripturian,代码行数:27,代码来源:JRubyAdapter.java

示例2: compare

import org.jruby.runtime.builtin.IRubyObject; //导入方法依赖的package包/类
/**
 * This calls to the static method compare of DataByteArray. Given two DataByteArrays, it will call it
 * on the underlying bytes.
 *
 * @param context the context the method is being executed in
 * @param self    an class which contains metadata on the calling class (required for static Ruby methods)
 * @param arg1    a RubyDataByteArray or byte array to compare
 * @param arg2    a RubyDataByteArray or byte array to compare
 * @return        the Fixnum result of comparing arg1 and arg2's bytes
 */
@JRubyMethod
public static RubyFixnum compare(ThreadContext context, IRubyObject self, IRubyObject arg1, IRubyObject arg2) {
    byte[] buf1, buf2;
    if (arg1 instanceof RubyDataByteArray) {
        buf1 = ((RubyDataByteArray)arg1).getDBA().get();
    } else {
        buf1 = (byte[])arg1.toJava(byte[].class);
    }
    if (arg2 instanceof RubyDataByteArray) {
        buf2 = ((RubyDataByteArray)arg2).getDBA().get();
    } else {
        buf2 = (byte[])arg2.toJava(byte[].class);
    }
    return RubyFixnum.newFixnum(context.getRuntime(), DataByteArray.compare(buf1, buf2));
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:26,代码来源:RubyDataByteArray.java


注:本文中的org.jruby.runtime.builtin.IRubyObject.toJava方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。