public Types(AST ast) { this.ast = ast; // Find core java types. javaObjectType = ast.resolveWellKnownType("java.lang.Object"); javaClassType = ast.resolveWellKnownType("java.lang.Class"); javaCloneableType = ast.resolveWellKnownType("java.lang.Cloneable"); javaStringType = ast.resolveWellKnownType("java.lang.String"); javaThrowableType = ast.resolveWellKnownType("java.lang.Throwable"); javaVoidType = ast.resolveWellKnownType("java.lang.Void"); ITypeBinding binding = ast.resolveWellKnownType("java.lang.Integer"); javaNumberType = binding.getSuperclass(); // Create core IOS types. NSCopying = mapIOSType(IOSTypeBinding.newInterface("NSCopying", javaCloneableType)); NSObject = mapIOSType(IOSTypeBinding.newClass("NSObject", javaObjectType)); NSNumber = mapIOSType(IOSTypeBinding.newClass("NSNumber", javaNumberType, NSObject)); NSString = mapIOSType(IOSTypeBinding.newClass("NSString", javaStringType, NSObject)); NSException = mapIOSType(IOSTypeBinding.newClass("NSException", javaThrowableType, NSObject)); IOSClass = mapIOSType(IOSTypeBinding.newUnmappedClass("IOSClass")); mapIOSType(IOSTypeBinding.newUnmappedClass("NSZone")); idType = mapIOSType(IOSTypeBinding.newUnmappedClass("id")); initializeArrayTypes(); initializeTypeMap(); initializeCommonJavaTypes(); populatePrimitiveAndWrapperTypeMaps(); ITypeBinding voidType = ast.resolveWellKnownType("void"); // Commonly used methods. retainMethod = IOSMethodBinding.newMethod(NameTable.RETAIN_METHOD, Modifier.PUBLIC, idType, NSObject); releaseMethod = IOSMethodBinding.newMethod(NameTable.RELEASE_METHOD, Modifier.PUBLIC, voidType, NSObject); autoreleaseMethod = IOSMethodBinding.newMethod(NameTable.AUTORELEASE_METHOD, Modifier.PUBLIC, idType, NSObject); allocMethod = IOSMethodBinding.newMethod(NameTable.ALLOC_METHOD, Modifier.PUBLIC, idType, NSObject); deallocMethod = IOSMethodBinding.newMethod(NameTable.DEALLOC_METHOD, Modifier.PUBLIC, idType, NSObject); }
private void initializeArrayTypes() { initializePrimitiveArray("boolean", "IOSBooleanArray"); initializePrimitiveArray("byte", "IOSByteArray"); initializePrimitiveArray("char", "IOSCharArray"); initializePrimitiveArray("double", "IOSDoubleArray"); initializePrimitiveArray("float", "IOSFloatArray"); initializePrimitiveArray("int", "IOSIntArray"); initializePrimitiveArray("long", "IOSLongArray"); initializePrimitiveArray("short", "IOSShortArray"); IOSObjectArray = mapIOSType(IOSTypeBinding.newUnmappedClass("IOSObjectArray")); }
private void initializePrimitiveArray(String javaTypeName, String iosTypeName) { ITypeBinding javaType = ast.resolveWellKnownType(javaTypeName); IOSTypeBinding iosType = mapIOSType(IOSTypeBinding.newUnmappedClass(iosTypeName)); iosType.setHeader("IOSPrimitiveArray.h"); arrayBindingMap.put(javaType, iosType); }