/** * 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); }
public static NSValue valueOf(VoidPtr value, String type) { BytePtr p = type == null ? null : BytePtr.toBytePtrAsciiZ(type); return valueOf(value, p); }
public static Selector register(String name) { if (name == null) { throw new NullPointerException("name"); } synchronized (selectors) { Selector sel = selectors.get(name); if (sel == null) { sel = ObjCRuntime.sel_registerName(BytePtr.toBytePtrAsciiZ(name)); if (sel == null) { // sel_registerName should never return nil throw new IllegalStateException("Objective-C failed to register selector '" + name + "'"); } selectors.put(name, sel); } return sel; } }
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(); }
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(); }
for (int i = 0; i < argc; i++) { BytePtr arg = BytePtr.toBytePtrAsciiZ(args[i]); argv.next(i).set(arg);
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
public static NSValue valueOf(VoidPtr value, String type) { BytePtr p = type == null ? null : BytePtr.toBytePtrAsciiZ(type); return valueOf(value, p); }
public static NSValue valueOf(VoidPtr value, String type) { BytePtr p = type == null ? null : BytePtr.toBytePtrAsciiZ(type); return valueOf(value, p); }
public static Selector register(String name) { if (name == null) { throw new NullPointerException("name"); } synchronized (selectors) { Selector sel = selectors.get(name); if (sel == null) { sel = ObjCRuntime.sel_registerName(BytePtr.toBytePtrAsciiZ(name)); if (sel == null) { // sel_registerName should never return nil throw new IllegalStateException("Objective-C failed to register selector '" + name + "'"); } selectors.put(name, sel); } return sel; } }
public void glShaderSource(int shader, String source) { BytePtr.BytePtrPtr sources = Struct.allocate(BytePtr.BytePtrPtr.class, 1); sources.next(0).set(BytePtr.toBytePtrAsciiZ(source)); OpenGLES.glShaderSource(shader, 1, sources, null); } public void glStencilFunc(int func, int ref, int mask) {
@Override public void glShaderSource(int shader, String source) { BytePtr.BytePtrPtr sources = Struct.allocate(BytePtr.BytePtrPtr.class, 1); sources.next(0).set(BytePtr.toBytePtrAsciiZ(source)); OpenGLES.glShaderSource(shader, 1, sources, null); } @Override public void glStencilFunc(int func, int ref, int mask) {
private Wrapper(Method method, boolean validate) { if (validate && method.getAnnotation(Callback.class) == null) { throw new IllegalArgumentException("Method " + method + " is not a @Callback method"); } TypeEncoding typeEncoding = method.getAnnotation(TypeEncoding.class); if (typeEncoding != null) { descriptor = new Descriptor() .literal_size(ObjCBlock.sizeOf()) .copy_helper(DESCRIPTOR.copy_helper()) .dispose_helper(DESCRIPTOR.dispose_helper()) .signature(BytePtr.toBytePtrAsciiZ(typeEncoding.value())); } else { descriptor = DESCRIPTOR; } callbackImpl = VM.getCallbackMethodImpl(method); int flags = BLOCK_HAS_COPY_DISPOSE | BLOCK_HAS_SIGNATURE; if (ObjCRuntime.isStret(method)) { flags |= BLOCK_HAS_STRET; } this.flags = flags; }
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(); }
for (int i = 0; i < argc; i++) { BytePtr arg = BytePtr.toBytePtrAsciiZ(args[i]); argv.next(i).set(arg);
for (int i = 0; i < argc; i++) { BytePtr arg = BytePtr.toBytePtrAsciiZ(args[i]); argv.next(i).set(arg);