php.runtime.Memory.unwrap()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(116)

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

Memory.unwrap介绍

暂无

代码示例

代码示例来源:origin: jphp-group/jphp

@Override
public Object convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  return Memory.unwrap(env, arg);
}

代码示例来源:origin: jphp-group/jphp

public static Object unwrap(Environment env, Memory memory) {
  return unwrap(env, memory, false);
}

代码示例来源:origin: jphp-group/jphp

@Override
@SuppressWarnings("unchecked")
public List convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  List result = new ArrayList();
  for (Memory el : arg.getNewIterator(env)) {
    if (operations.length >= 1) {
      result.add(operations[0].convert(env, trace, el));
    } else {
      result.add(Memory.unwrap(env, el, true));
    }
  }
  return result;
}

代码示例来源:origin: jphp-group/jphp

public Map toMap(Environment env) {
  Map<String, Object> r = new LinkedHashMap<>();
  ForeachIterator iterator = foreachIterator(false, false);
  while (iterator.next()) {
    r.put(iterator.getKey().toString(), Memory.unwrap(env, iterator.getValue(), true));
  }
  return r;
}

代码示例来源:origin: jphp-group/jphp

@Override
@Signature
public Memory format(Environment env, Memory... args) {
  try {
    return StringMemory.valueOf(yaml.dump(Memory.unwrap(env, args[0], true)));
  } catch (YAMLException e) {
    env.exception(ProcessorException.class, e.getMessage());
    return Memory.NULL;
  }
}

代码示例来源:origin: jphp-group/jphp

public Object toMapOrList(Environment env) {
  if (isList()) {
    List<Object> result = new ArrayList<>();
    ForeachIterator iterator = foreachIterator(false, false);
    while (iterator.next()) {
      result.add(Memory.unwrap(env, iterator.getValue(), true));
    }
    return result;
  } else {
    return toMap(env);
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
  @Signature
  public Memory formatTo(Environment env, Memory... args) {
    try {
      yaml.dump(
          Memory.unwrap(env, args[0], true),
          new OutputStreamWriter(Stream.getOutputStream(env, args[1]), env.getDefaultCharset())
      );

      return Memory.NULL;
    } catch (YAMLException e) {
      env.exception(ProcessorException.class, e.getMessage());
      return Memory.NULL;
    }
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
@SuppressWarnings("unchecked")
public Map convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  Map result = this.createHashMap();
  ForeachIterator iterator = arg.getNewIterator(env);
  while (iterator.next()) {
    if (operations.length == 2) {
      result.put(
          operations[0].convert(env, trace, iterator.getMemoryKey()),
          operations[1].convert(env, trace, iterator.getValue())
      );
    } else {
      result.put(
          Memory.unwrap(env, iterator.getMemoryKey(), true),
          Memory.unwrap(env, iterator.getValue(), true)
      );
    }
  }
  return result;
}

代码示例来源:origin: jphp-group/jphp

@Override
public BasicDBObject convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  if (arg.isNull()) return null;
  ForeachIterator iterator = arg.getNewIterator(env);
  BasicDBObject dbObject = new BasicDBObject();
  while (iterator.next()) {
    if (iterator.getValue().isTraversable()) {
      dbObject.append(iterator.getStringKey(), convert(env, trace, iterator.getValue()));
    } else {
      dbObject.append(iterator.getStringKey(), Memory.unwrap(env, iterator.getValue()));
    }
  }
  return dbObject;
}

代码示例来源:origin: jphp-group/jphp

@Override
public Document convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  if (arg.isNull()) return null;
  ForeachIterator iterator = arg.getNewIterator(env);
  Document dbObject = new Document();
  while (iterator.next()) {
    if (iterator.getValue().isTraversable()) {
      dbObject.append(iterator.getStringKey(), convert(env, trace, iterator.getValue()));
    } else {
      dbObject.append(iterator.getStringKey(), Memory.unwrap(env, iterator.getValue()));
    }
  }
  return dbObject;
}

相关文章