/** * Defines the specified struct as inner of this struct. * * @param struct the inner struct. * @return the specified struct. * @throws IllegalArgumentException if the specified struct is already an inner struct. */ protected /*<S extends Struct> S*/ Struct inner(/*S*/ Struct struct) { if (struct._outer != null) throw new java.lang.IllegalArgumentException("struct: Already an inner struct"); struct._outer = this; final int bitSize = struct.size() << 3; updateIndexes(struct._alignment, bitSize, bitSize); struct._outerOffset = (_bitIndex - bitSize) >> 3; return (/*S*/ Struct) struct; }
/** * @throws OSStatusException * @since Available in iOS 2.0 and later. */ public int getPropertySize(Struct<?> specifier) throws OSStatusException { IntPtr ptr = new IntPtr(); OSStatus status = getPropertyInfo0( this, specifier == null ? 0 : Struct.sizeOf(specifier), specifier == null ? null : specifier.as(VoidPtr.class), ptr); OSStatusException.throwIfNecessary(status); return ptr.get(); }
/** * @throws OSStatusException * @since Available in iOS 2.0 and later. */ public <T extends Struct<T>> T getProperty(Struct<?> specifier, Class<T> type) throws OSStatusException { T data = Struct.allocate(type); IntPtr dataSize = new IntPtr(Struct.sizeOf(data)); OSStatus status = getProperty0( this, specifier == null ? 0 : Struct.sizeOf(specifier), specifier == null ? null : specifier.as(VoidPtr.class), dataSize, data.as(VoidPtr.class)); OSStatusException.throwIfNecessary(status); return data; }
public CIVector(double[] values) { super((SkipInit) null); if (values == null) { throw new NullPointerException("values"); } MachineSizedFloatPtr p = Struct.allocate(MachineSizedFloatPtr.class, values.length); p.set(values); initObject(initWithValues$count$(p, values.length)); }
private static CGGradient create(CGColorSpace space, CGColor[] colors, Object locations) { if (colors == null) { throw new NullPointerException("colors"); } try (CFMutableArray colorsArray = CFMutableArray.createMutable(null, colors.length, CoreFoundation.TypeArrayCallBacks())) { for (CGColor c : colors) { colorsArray.appendValue(Struct.toStruct(VoidPtr.class, c.getHandle())); } return create( space, colorsArray, locations != null ? VM.getArrayValuesAddress(CoreGraphics.toMachineSizedFloatArray(locations)) : 0); } }
/** * Returns the byte buffer for this struct. This method will allocate a new <b>direct</b> buffer * if none has been set. * * <p>Changes to the buffer's content are visible in this struct, and vice versa. * * <p>The buffer of an inner struct is the same as its parent struct. * * <p>The position of a {@link Struct.Member struct's member} within the byte buffer is given by * {@link Struct.Member#position member.position()} * * @return the current byte buffer or a new direct buffer if none set. * @see #setByteBuffer */ public final ByteBuffer getByteBuffer() { if (_outer != null) return _outer.getByteBuffer(); return (_byteBuffer != null) ? _byteBuffer : newBuffer(); }
/** * Returns the absolute position of this struct within its associated {@link #getByteBuffer byte * buffer}. * * @return the absolute position of this struct in the byte buffer. */ public final int getByteBufferPosition() { return (_outer != null) ? _outer.getByteBufferPosition() + _outerOffset : _outerOffset; }
public static MKPolyline create(CLLocationCoordinate2D[] coords) { CLLocationCoordinate2D first = Struct.allocate(CLLocationCoordinate2D.class, coords.length); first.update(coords); return create(first, coords.length); }
/*</members>*/ public static MKPolyline create(MKMapPoint[] points) { MKMapPoint first = Struct.allocate(MKMapPoint.class, points.length); first.update(points); return create(first, points.length); }