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

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

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

Memory.instanceOf介绍

暂无

代码示例

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

public static boolean instanceOfRight(String name, String lowerName, Memory o) {
    return o.instanceOf(name, lowerName);
  }
}

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

@Override
public boolean instanceOf(String name) {
  return getValue().instanceOf(name);
}

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

@Override
public boolean instanceOf(String className, String lowerClassName) {
  return getValue().instanceOf(className, lowerClassName);
}

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

@Override
public boolean instanceOf(Class<? extends IObject> clazz) {
  return getValue().instanceOf(clazz);
}

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

/**
 * @param arg
 * @return
 */
public static String getPath(Memory arg) {
  if (arg.instanceOf(FileObject.class)){
    return arg.toObject(FileObject.class).file.getPath();
  } else if (arg.instanceOf(Stream.class)){
    return arg.toObject(Stream.class).getPath();
  } else
    return arg.toString();
}

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

public static TimeZone getTimeZone(Environment env, Memory arg) {
  if (arg.isNull()) {
    TimeZone zone = env.getUserValue(WrapTime.class.getName() + "#def_time_zone", TimeZone.class);
    if (zone == null)
      return TimeZone.getDefault();
    else
      return zone;
  } else if (arg.instanceOf(WrapTimeZone.class)) {
    WrapTimeZone timeZone = arg.toObject(WrapTimeZone.class);
    return timeZone.timeZone;
  } else
    throw new IllegalArgumentException();
}

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

public static Memory fclose(Environment env, TraceInfo trace, Memory stream) {
  if (stream.instanceOf(Stream.CLASS_NAME)) {
    try {
      env.invokeMethod(trace, stream, "close");
      return Memory.TRUE;
    } catch (Throwable throwable) {
      return Memory.FALSE;
    }
  } else {
    env.warning("fclose(): unable to close a non-stream");
    return Memory.FALSE;
  }
}

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

@Signature
public void bindTimestamp(Environment env, int index, Memory value) throws SQLException {
  if (value.instanceOf(WrapTime.class)) {
    WrapTime time = value.toObject(WrapTime.class);
    statement.setTimestamp(index + 1, new Timestamp(time.getDate().getTime()), time.getCalendar());
  } else {
    statement.setTimestamp(index + 1, new Timestamp(value.toLong()));
  }
}

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

public static Memory ftell(Environment env, TraceInfo trace, Memory stream) {
  if (stream.instanceOf(Stream.CLASS_NAME)) {
    try {
      return env.invokeMethod(trace, stream, "getPosition");
    } catch (Throwable throwable) {
      env.warning(trace, "ftell(): " + throwable.getMessage());
      return Memory.FALSE;
    }
  }
  env.warning(trace, "ftell(): unable to get position from a non-stream");
  return Memory.FALSE;
}

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

public static Memory feof(Environment env, TraceInfo trace, Memory stream) {
  if (stream.instanceOf(Stream.CLASS_NAME)) {
    try {
      return env.invokeMethod(trace, stream, "eof");
    } catch (Throwable throwable) {
      env.warning(trace, "feof(): " + throwable.getMessage());
      return Memory.FALSE;
    }
  }
  env.warning(trace, "feof(): unable get eof from a non-stream");
  return Memory.FALSE;
}

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

public static File valueOf(Memory arg) {
  if (arg.instanceOf(FileObject.class))
    return arg.toObject(FileObject.class).getFile();
  else
    return new File(arg.toString());
}

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

public static Memory fwrite(Environment env, TraceInfo trace, Memory stream, Memory value, Memory length) {
  if (stream.instanceOf(Stream.CLASS_NAME)) {
    try {
      return env.invokeMethod(trace, stream, "write", value, length);
    } catch (Throwable throwable) {
      env.warning(trace, "fwrite(): " + throwable.getMessage());
      return Memory.FALSE;
    }
  }
  env.warning(trace, "fwrite(): unable to write to a non-stream");
  return Memory.FALSE;
}

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

public static Memory fread(Environment env, TraceInfo trace, Memory stream, int length) {
  if (stream.instanceOf(Stream.CLASS_NAME)) {
    try {
      return env.invokeMethod(trace, stream, "read", LongMemory.valueOf(length));
    } catch (Throwable throwable) {
      env.warning(trace, "fread(): " + throwable.getMessage());
      return Memory.FALSE;
    }
  }
  env.warning(trace, "fread(): unable to read from a non-stream");
  return Memory.FALSE;
}

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

@Override
public Pattern convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  if (arg.instanceOf(WrapRegex.class)) {
    return arg.toObject(WrapRegex.class).getMatcher().pattern();
  } else {
    return Pattern.compile(arg.toString());
  }
}

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

public static Memory fgetc(Environment env, TraceInfo trace, Memory stream) {
  if (stream.instanceOf(Stream.CLASS_NAME)) {
    try {
      Memory memory = env.invokeMethod(trace, stream, "read", Memory.CONST_INT_1);
      return memory.isNull() ? Memory.FALSE : memory;
    } catch (Throwable throwable) {
      env.warning(trace, "fgetc(): " + throwable.getMessage());
      return Memory.FALSE;
    }
  }
  env.warning(trace, "fgetc(): unable to read from a non-stream");
  return Memory.FALSE;
}

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

@Override
public Color convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  return arg.isNull() ? null : (arg.instanceOf(PColor.class) ? arg.toObject(PColor.class).getColor() : Color.decode(arg.toString()));
}

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

@Signature
public void update(Environment env, Memory any) throws Throwable {
  if (any.instanceOf(SourceFile.class)) {
    SourceFile sourceFile = any.toObject(SourceFile.class);
    env.invokeMethod(sourceFile, "update", ObjectMemory.valueOf(this));
  }
}

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

@Signature
public Memory getLastInsertId(Environment env) throws SQLException {
  Memory keys = getGeneratedKeys(env);
  if (keys.instanceOf(PSqlResult.class)) {
    return keys.toObject(PSqlResult.class).getTyped(env, 0);
  }
  return Memory.NULL;
}

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

@Override
public ObjectId convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  if (arg.isNull()) return null;
  if (arg.instanceOf(WrapObjectId.class)) {
    return arg.toObject(WrapObjectId.class).getWrappedObject();
  }
  return new ObjectId(arg.toString());
}

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

@Test
public void testObjectJsonDecode() {
  Memory r = JsonFunctions.json_decode(env, "{\"x\":100, \"y\":500}");
  assertTrue(r.instanceOf(StdClass.class));
  StdClass stdClass = r.toObject(StdClass.class);
  assertEquals(2, stdClass.getProperties().size());
  assertEquals(100, stdClass.getProperties().valueOfIndex("x").toLong());
  assertEquals(500, stdClass.getProperties().valueOfIndex("y").toLong());
}

相关文章