예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * @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();
 }
예제 #3
0
 /**
  * @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;
 }
예제 #4
0
 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));
 }
예제 #5
0
 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);
   }
 }
예제 #6
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();
 }
예제 #7
0
 /**
  * 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;
 }
예제 #8
0
 public static MKPolyline create(CLLocationCoordinate2D[] coords) {
   CLLocationCoordinate2D first = Struct.allocate(CLLocationCoordinate2D.class, coords.length);
   first.update(coords);
   return create(first, coords.length);
 }
예제 #9
0
 /*</members>*/
 public static MKPolyline create(MKMapPoint[] points) {
   MKMapPoint first = Struct.allocate(MKMapPoint.class, points.length);
   first.update(points);
   return create(first, points.length);
 }