org.robovm.rt.bro.ptr.BytePtr类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(55)

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

BytePtr介绍

[英]Points to an 8-bit signed value (char * in C).
[中]指向8位有符号值(C中为char *)。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Converts the specified {@link String} to a NUL-terminated C string of 
 * ASCII characters. Non ASCII characters will be replaced with '?' in the 
 * result. The memory will be allocated on the GCed heaped. This method is 
 * more efficient than using {@link #toStringZ(Charset)} with ASCII as 
 * {@link Charset}.
 * 
 * @param s the {@link String} to convert.
 * @return a {@link BytePtr} which points to the first character in the result.
 */
public static BytePtr toBytePtrAsciiZ(String s) {
  return toBytePtrAsciiZ(s, false);
}

代码示例来源:origin: robovm/robovm

/**
 * @since Available in iOS 2.0 and later.
 */
public static CGBitmapContext create(byte[] data, long width, long height, long bitsPerComponent, long bytesPerRow, CGColorSpace space, CGBitmapInfo bitmapInfo) {
  BytePtr ptr = new BytePtr();
  ptr.set(data);
  return create(ptr.as(IntPtr.class), width, height, bitsPerComponent, bytesPerRow, space, bitmapInfo);
}
/**

代码示例来源:origin: robovm/robovm

/**
 * Copies {@code count} bytes from the memory pointed to by this 
 * {@link BytePtr} to {@code dst} starting at offset {@code offset}.
 * 
 * @param dst the destination.
 * @param offset the offset within the destination array to start copying to.
 * @param count the number of elements to copy.
 */
public void get(byte[] dst, int offset, int count) {
  asByteBuffer(count).get(dst, offset, count);
}

代码示例来源:origin: robovm/robovm

public CTLineBreakMode getLineBreakMode() {
  BytePtr ptr = new BytePtr();
  getValueForSpecifier(CTParagraphStyleSpecifier.LineBreakMode, BytePtr.sizeOf(), ptr.as(VoidPtr.class));
  return CTLineBreakMode.valueOf(ptr.get());
}
public CTWritingDirection getBaseWritingDirection() {

代码示例来源:origin: robovm/robovm

public CAFPacketTableHeader setPacketDescriptions(byte[] packetDescriptions) {
  BytePtr ptr = new BytePtr();
  ptr.set(packetDescriptions);
  setPacketDescriptions0(ptr);
  return this;
}
/*<members>*/

代码示例来源:origin: libgdx/libgdx

public static String getMachineString () {
  BytePtr name = BytePtr.toBytePtrAsciiZ("hw.machine");
  MachineSizedUIntPtr size = new MachineSizedUIntPtr();
  sysctlbyname(name, null, size, null, 0);
  BytePtr machine = Struct.allocate(BytePtr.class, (int) size.get());
  sysctlbyname(name, machine.as(VoidPtr.class), size, null, 0);
  return machine.toStringAsciiZ();
}

代码示例来源:origin: robovm/robovm

/**
 * Converts the specified {@link String} to a NUL-terminated C string using
 * the specified {@link Charset}. Illegal characters will be replaced with 
 * '?' in the result. The memory will be allocated on the GCed heaped.
 * 
 * @param s the {@link String} to convert.
 * @param charset the {@link Charset} to use. Must be an 8-bit or variable
 *        length character encoding with 8-bits as smallest value and that 
 *        can be NUL-terminated (e.g. UTF-8).
 * @return a {@link BytePtr} which points to the first character in the result.
 */
public static BytePtr toBytePtrZ(String s, Charset charset) {
  return toBytePtrZ(s, charset, false);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link ByteBuffer} which reads and writes to the same memory
 * location pointed to by this {@link BytePtr}.
 * 
 * @param n the maximum number of bytes the {@link ByteBuffer} can 
 *        read/write. This will be the {@link ByteBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link ByteBuffer}.
 */
public ByteBuffer asByteBuffer(int n) {
  return VM.newDirectByteBuffer(getHandle(), n);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link String} created from the NUL-terminated C string pointed 
 * to by this {@link BytePtr} using the default {@link Charset}. Illegal 
 * characters will be replaced with '?' in the result. This assumes that
 * the default {@link Charset} is an 8-bit encoding or a variable length
 * encoding with 8-bits as smallest bit length such as UTF-8.
 * 
 * @return a {@link String} converted from the C string bytes.
 */
public String toStringZ() {
  return toStringZ(Charset.defaultCharset());
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link String} created from the NUL-terminated C string pointed 
 * to by this {@link BytePtr} using the specified {@link Charset}. Illegal 
 * characters will be replaced with '?' in the result.
 * 
 * @param charset the {@link Charset} to use. Must be an 8-bit or variable
 *        length character encoding with 8-bits as smallest value and that 
 *        can be NUL-terminated (e.g. UTF-8).
 * @return a {@link String} converted from the C string bytes.
 */
public String toStringZ(Charset charset) {
  int length = 0;
  long address = getHandle();
  while (VM.getByte(address++) != 0) {
    length++;
  }
  return charset.decode(asByteBuffer(length)).toString();
}

代码示例来源:origin: robovm/robovm

/**
 * Copies {@code n} bytes from the memory pointed to by this {@link BytePtr}
 * to a new {@code byte[]} instance.
 * 
 * @param n the number of bytes to copy.
 * @return the {@code byte[]}.
 */
public byte[] toByteArray(int n) {
  byte[] result = new byte[n];
  get(result);
  return result;
}

代码示例来源:origin: robovm/robovm

/**
 * @throws OSStatusException 
 * @since Available in iOS 4.0 and later.
 */
public CMTextJustification getVerticalJustification() throws OSStatusException {
  BytePtr ptr = new BytePtr();
  OSStatus status = getJustification0(null, ptr);
  OSStatusException.throwIfNecessary(status);
  return CMTextJustification.valueOf(ptr.get());
} 
/**

代码示例来源:origin: robovm/robovm

/**
 * Copies {@code src.length} bytes from {@code src} to the memory pointed to by
 * this {@link BytePtr}.
 * 
 * @param src the source.
 */
public void set(byte[] src) {
  set(src, 0, src.length);
}

代码示例来源:origin: robovm/robovm

public static CFNumber valueOf(byte value) {
  return create(null, CFNumberType.SInt8Type, new BytePtr(value).as(VoidPtr.class));
}
public static CFNumber valueOf(short value) {

代码示例来源:origin: robovm/robovm

/**
 * @throws OSStatusException 
 * @since Available in iOS 5.0 and later.
 */
public String getPeerDomainName() throws OSStatusException {
  BytePtr peerNamePtr = new BytePtr();
  MachineSizedUIntPtr peerNameLenPtr = new MachineSizedUIntPtr();
  OSStatus status = getPeerDomainName0(peerNamePtr, peerNameLenPtr);
  OSStatusException.throwIfNecessary(status);
  return peerNamePtr.toStringZ();
}
/**

代码示例来源:origin: robovm/robovm

public CTTextAlignment getAlignment() {
  BytePtr ptr = new BytePtr();
  getValueForSpecifier(CTParagraphStyleSpecifier.Alignment, BytePtr.sizeOf(), ptr.as(VoidPtr.class));
  return CTTextAlignment.valueOf(ptr.get());
}
public CTLineBreakMode getLineBreakMode() {

代码示例来源:origin: libgdx/libgdx

public static String getMachineString () {
  BytePtr name = BytePtr.toBytePtrAsciiZ("hw.machine");
  MachineSizedUIntPtr size = new MachineSizedUIntPtr();
  sysctlbyname(name, null, size, null, 0);
  BytePtr machine = Struct.allocate(BytePtr.class, (int) size.get());
  sysctlbyname(name, machine.as(VoidPtr.class), size, null, 0);
  return machine.toStringAsciiZ();
}

代码示例来源:origin: robovm/robovm

/**
 * Converts the specified {@link String} to a NUL-terminated C string using
 * the default {@link Charset}. Illegal characters will be replaced with 
 * '?' in the result. The memory will be allocated on the GCed heaped.
 * This assumes that the default {@link Charset} is an 8-bit encoding or a
 * variable length encoding with 8-bits as smallest bit length such as 
 * UTF-8.
 * 
 * @param s the {@link String} to convert.
 * @return a {@link BytePtr} which points to the first character in the result.
 */
public static BytePtr toBytePtrZ(String s) {
  return toBytePtrZ(s, Charset.defaultCharset(), false);
}

代码示例来源:origin: robovm/robovm

public long read(BytePtr buffer, long len) {
  return read(buffer.getHandle(), len);
}
public long read(ByteBuffer bytes) {

代码示例来源:origin: robovm/robovm

/**
 * @since Available in iOS 2.0 and later.
 */
public static String getStatusDescription(SCStatusCode status) {
  BytePtr ptr = getStatusDescription0(status);
  return ptr.toStringZ();
}
/*<methods>*/

相关文章