예제 #1
0
  public IOSMethod(String s, IMethodBinding binding, ITypeBinding returnType, AST ast) {
    if (s.endsWith(";")) {
      s = s.substring(0, s.length() - 1);
    }
    int i = s.indexOf(' ');
    String className = s.substring(0, i);
    IOSTypeBinding clazz = Types.resolveIOSType(className);
    if (clazz == null) {
      clazz = new IOSTypeBinding(className, false);
    }
    declaringClass = clazz.getName();
    s = s.substring(i + 1);

    parameters = Lists.newArrayList();
    i = s.indexOf(':');
    if (i > 0) { // if there are parameters
      name = s.substring(0, i);
      String[] argDefs = splitParameterString(s);
      for (i = 0; i < argDefs.length; i++) {
        IOSParameter param = new IOSParameter(argDefs[i], i, ast);
        parameters.add(param);
        if (param.isVarArgs()) {
          varArgs = true;
          break;
        }
      }
    } else {
      name = s;
    }
    this.binding = new IOSMethodBinding(name, binding, clazz, returnType, varArgs);
  }
예제 #2
0
파일: Types.java 프로젝트: hellojory/j2objc
 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"));
 }
예제 #3
0
파일: Types.java 프로젝트: hellojory/j2objc
  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);
  }
예제 #4
0
파일: Types.java 프로젝트: hellojory/j2objc
 public boolean isStringType(ITypeBinding type) {
   return javaStringType.isEqualTo(type) || NSString.isEqualTo(type);
 }
예제 #5
0
파일: Types.java 프로젝트: hellojory/j2objc
 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);
 }
예제 #6
0
파일: Types.java 프로젝트: hellojory/j2objc
 private IOSTypeBinding mapIOSType(IOSTypeBinding type) {
   iosBindingMap.put(type.getName(), type);
   return type;
 }