org.jruby.Ruby.encodeToBytes()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.jruby.Ruby.encodeToBytes方法的一些代码示例,展示了Ruby.encodeToBytes的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.encodeToBytes方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:encodeToBytes

Ruby.encodeToBytes介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

public Node parseEval(String content, String file, DynamicScope scope, int lineNumber) {
  addEvalParseToStats();
  return parser.parse(file, encodeToBytes(content), scope, new ParserConfiguration(this, lineNumber, false, false, config));
}

代码示例来源:origin: org.jruby/jruby-core

public Node parseEval(String content, String file, DynamicScope scope, int lineNumber) {
  addEvalParseToStats();
  return parser.parse(file, encodeToBytes(content), scope, new ParserConfiguration(this, lineNumber, false, false, config));
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Parse and execute the specified script
 * This differs from the other methods in that it accepts a string-based script and
 * parses and runs it as though it were loaded at a command-line. This is the preferred
 * way to start up a new script when calling directly into the Ruby object (which is
 * generally *dis*couraged.
 *
 * @param script The contents of the script to run as a normal, root script
 * @return The last value of the script
 */
public IRubyObject executeScript(String script, String filename) {
  byte[] bytes = encodeToBytes(script);
  ParseResult root = (ParseResult) parseInline(new ByteArrayInputStream(bytes), filename, null);
  ThreadContext context = getCurrentContext();
  String oldFile = context.getFile();
  int oldLine = context.getLine();
  try {
    context.setFileAndLine(root.getFile(), root.getLine());
    return runInterpreter(root);
  } finally {
    context.setFileAndLine(oldFile, oldLine);
  }
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Parse and execute the specified script
 * This differs from the other methods in that it accepts a string-based script and
 * parses and runs it as though it were loaded at a command-line. This is the preferred
 * way to start up a new script when calling directly into the Ruby object (which is
 * generally *dis*couraged.
 *
 * @param script The contents of the script to run as a normal, root script
 * @return The last value of the script
 */
public IRubyObject executeScript(String script, String filename) {
  byte[] bytes = encodeToBytes(script);
  ParseResult root = (ParseResult) parseInline(new ByteArrayInputStream(bytes), filename, null);
  ThreadContext context = getCurrentContext();
  String oldFile = context.getFile();
  int oldLine = context.getLine();
  try {
    context.setFileAndLine(root.getFile(), root.getLine());
    return runInterpreter(root);
  } finally {
    context.setFileAndLine(oldFile, oldLine);
  }
}

相关文章

Ruby类方法