Package com.sun.jna

Examples of com.sun.jna.FromNativeConverter


  ToNativeConverter converter = new ObjCObjectTypeConverter(ObjCObject.class);
        assertEquals(null, converter.toNative(null, null));
    }
   
    @Test public void convertsReturnedIDToNSObjectSubclass() {
        FromNativeConverter converter = new ObjCObjectTypeConverter(NSNumber.class);
            // returning is based on declared type, see RococoaTypeMapper

  NSNumber number = Rococoa.create("NSNumber", NSNumber.class, "numberWithInt:", 45);

        // We can cope with 64 bits on 64 and 32
        Number nativeValue = new Long(number.id().longValue());
        NSNumber converted = (NSNumber) converter.fromNative(nativeValue, null);
        assertEquals(converted.id(), number.id());
        assertEquals(45, converted.intValue());       

        // We must cope with 32 bits on 32-bit
        if (NativeLong.SIZE == 4) {
            nativeValue = new Integer(number.id().intValue());
            converted = (NSNumber) converter.fromNative(nativeValue, null);
            assertEquals(45, converted.intValue());       
        }   
    }
View Full Code Here


        }   
    }
   
    @Test public void convertsReturnedNilToNull() {
  // Again I'm not sure that this is desirable, but it is what happens.
        FromNativeConverter converter = new ObjCObjectTypeConverter(NSNumber.class);
        Number nativeValue = new Long(0);
        assertNull(converter.fromNative(nativeValue, null));
    }
View Full Code Here

        Number nativeValue = new Long(0);
        assertNull(converter.fromNative(nativeValue, null));
    }
   
    @Test public void returnedNSObjectIsNormallyRetained() {
        FromNativeConverter converter = new ObjCObjectTypeConverter(NSNumber.class);

  NSNumber number = Rococoa.create("NSNumber", NSNumber.class, "numberWithInt:", 45);
  assertRetainCount(2, number); // one for the pool, one for Java

        NSNumber converted = (NSNumber) converter.fromNative(new Long(number.id().longValue()), null);
  assertRetainCount(3, converted); // now we have another Java alias
  assertRetainCount(3, number);
    }
View Full Code Here

TOP

Related Classes of com.sun.jna.FromNativeConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.