com.apple.internal.jobjc.generator.model.types.NType.NPrimitive Java Examples

The following examples show how to use com.apple.internal.jobjc.generator.model.types.NType.NPrimitive. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NativeEnum.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){
    if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null);

    NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()};
    for(NumTest t : tests)
        if(t.confirm(value32, value64, le_value, be_value))
            return t.getType();

    throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n",
            name, value32, value64, le_value, be_value));
}
 
Example #2
Source File: ComplexCoderDescriptor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) {
    Pair<NType,NType> cacheKey = new Pair(nt32, nt64);
    if(cache.containsKey(cacheKey)) return cache.get(cacheKey);

    final PrimitiveCoderDescriptor desc32 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt32);
    final PrimitiveCoderDescriptor desc64 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt64);

    final ComplexCoderDescriptor newDesc = nt32.equals(nt64) ? new ComplexCoderDescriptor(desc64) : new MixedEncodingDescriptor(desc32, desc64);
    cache.put(cacheKey, newDesc);
    if(newDesc instanceof MixedEncodingDescriptor)
        mixedEncodingDescriptors.add((MixedEncodingDescriptor) newDesc);

    return newDesc;
}
 
Example #3
Source File: NativeEnum.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){
    if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null);

    NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()};
    for(NumTest t : tests)
        if(t.confirm(value32, value64, le_value, be_value))
            return t.getType();

    throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n",
            name, value32, value64, le_value, be_value));
}
 
Example #4
Source File: NativeEnum.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){
    if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null);

    NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()};
    for(NumTest t : tests)
        if(t.confirm(value32, value64, le_value, be_value))
            return t.getType();

    throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n",
            name, value32, value64, le_value, be_value));
}
 
Example #5
Source File: ComplexCoderDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) {
    Pair<NType,NType> cacheKey = new Pair(nt32, nt64);
    if(cache.containsKey(cacheKey)) return cache.get(cacheKey);

    final PrimitiveCoderDescriptor desc32 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt32);
    final PrimitiveCoderDescriptor desc64 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt64);

    final ComplexCoderDescriptor newDesc = nt32.equals(nt64) ? new ComplexCoderDescriptor(desc64) : new MixedEncodingDescriptor(desc32, desc64);
    cache.put(cacheKey, newDesc);
    if(newDesc instanceof MixedEncodingDescriptor)
        mixedEncodingDescriptors.add((MixedEncodingDescriptor) newDesc);

    return newDesc;
}
 
Example #6
Source File: NativeEnum.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){
    if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null);

    NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()};
    for(NumTest t : tests)
        if(t.confirm(value32, value64, le_value, be_value))
            return t.getType();

    throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n",
            name, value32, value64, le_value, be_value));
}
 
Example #7
Source File: ComplexCoderDescriptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) {
    Pair<NType,NType> cacheKey = new Pair(nt32, nt64);
    if(cache.containsKey(cacheKey)) return cache.get(cacheKey);

    final PrimitiveCoderDescriptor desc32 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt32);
    final PrimitiveCoderDescriptor desc64 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt64);

    final ComplexCoderDescriptor newDesc = nt32.equals(nt64) ? new ComplexCoderDescriptor(desc64) : new MixedEncodingDescriptor(desc32, desc64);
    cache.put(cacheKey, newDesc);
    if(newDesc instanceof MixedEncodingDescriptor)
        mixedEncodingDescriptors.add((MixedEncodingDescriptor) newDesc);

    return newDesc;
}
 
Example #8
Source File: JType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the suffix placed on java literals to indicate the type. If none applies, return ' '.
 */
public char getLiteralSuffix() {
    char t = ((NPrimitive)type.type64).type;
    switch(t){
        case 'l': case 'L': case 'f': case 'd': return t;
        case 'q': case 'Q': return 'L';
    }
    return ' ';
}
 
Example #9
Source File: NativeEnum.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){
    if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null);

    NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()};
    for(NumTest t : tests)
        if(t.confirm(value32, value64, le_value, be_value))
            return t.getType();

    throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n",
            name, value32, value64, le_value, be_value));
}
 
Example #10
Source File: NativeEnum.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){
    if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null);

    NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()};
    for(NumTest t : tests)
        if(t.confirm(value32, value64, le_value, be_value))
            return t.getType();

    throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n",
            name, value32, value64, le_value, be_value));
}
 
Example #11
Source File: ComplexCoderDescriptor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) {
    Pair<NType,NType> cacheKey = new Pair(nt32, nt64);
    if(cache.containsKey(cacheKey)) return cache.get(cacheKey);

    final PrimitiveCoderDescriptor desc32 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt32);
    final PrimitiveCoderDescriptor desc64 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt64);

    final ComplexCoderDescriptor newDesc = nt32.equals(nt64) ? new ComplexCoderDescriptor(desc64) : new MixedEncodingDescriptor(desc32, desc64);
    cache.put(cacheKey, newDesc);
    if(newDesc instanceof MixedEncodingDescriptor)
        mixedEncodingDescriptors.add((MixedEncodingDescriptor) newDesc);

    return newDesc;
}
 
Example #12
Source File: JType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the suffix placed on java literals to indicate the type. If none applies, return ' '.
 */
public char getLiteralSuffix() {
    char t = ((NPrimitive)type.type64).type;
    switch(t){
        case 'l': case 'L': case 'f': case 'd': return t;
        case 'q': case 'Q': return 'L';
    }
    return ' ';
}
 
Example #13
Source File: NTypeParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override protected boolean parsePossible(StringStream ss) {
    return NPrimitive.CODES.contains(ss.peek());
}
 
Example #14
Source File: Type.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static NType getNSPointType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("x", new NPrimitive('f')));
    fields.add(new NField("y", new NPrimitive('f')));
    return new NStruct("_NSPoint", fields);
}
 
Example #15
Source File: TypeToJType.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected JType accept(Type type, NPrimitive nt32, NPrimitive nt64){
    final ComplexCoderDescriptor coderDesc = ComplexCoderDescriptor.getCoderDescriptorFor(type.type32, type.type64);
    if (coderDesc == null) return null;
    return new JPrimitive(type, coderDesc);
}
 
Example #16
Source File: Type.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static NType getCGPointType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("x", new NPrimitive('d')));
    fields.add(new NField("y", new NPrimitive('d')));
    return new NStruct("CGPoint", fields);
}
 
Example #17
Source File: Type.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static NType getCGSizeType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("width", new NPrimitive('d')));
    fields.add(new NField("height", new NPrimitive('d')));
    return new NStruct("CGSize", fields);
}
 
Example #18
Source File: NTypePrinter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected String accept(NPrimitive nt) {
    return Character.toString(nt.type);
}
 
Example #19
Source File: NTypeMerger.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected NType accept(NPrimitive a, NPrimitive b) {
    mustEqual(a, b);
    return a;
}
 
Example #20
Source File: PrimitiveCoderDescriptor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static PrimitiveCoderDescriptor getCoderDescriptorFor(NPrimitive nt) {
    return getCoderDescriptorFor(nt.type);
}
 
Example #21
Source File: NTypePrinter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected String accept(NPointer nt) {
    if(nt.subject instanceof NPrimitive && ((NPrimitive) nt.subject).type == 'C')
        return "*";
    else
        return "^" + print(nt.subject);
}
 
Example #22
Source File: Type.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static NType getNSSizeType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("width", new NPrimitive('f')));
    fields.add(new NField("height", new NPrimitive('f')));
    return new NStruct("_NSSize", fields);
}
 
Example #23
Source File: Type.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static NType getCGSizeType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("width", new NPrimitive('d')));
    fields.add(new NField("height", new NPrimitive('d')));
    return new NStruct("CGSize", fields);
}
 
Example #24
Source File: Type.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static NType getNSSizeType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("width", new NPrimitive('f')));
    fields.add(new NField("height", new NPrimitive('f')));
    return new NStruct("_NSSize", fields);
}
 
Example #25
Source File: Type.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static NType getCGSizeType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("width", new NPrimitive('d')));
    fields.add(new NField("height", new NPrimitive('d')));
    return new NStruct("CGSize", fields);
}
 
Example #26
Source File: Type.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static NType getNSPointType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("x", new NPrimitive('f')));
    fields.add(new NField("y", new NPrimitive('f')));
    return new NStruct("_NSPoint", fields);
}
 
Example #27
Source File: Type.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static NType getCGPointType() {
    List<NField> fields = new ArrayList<NField>();
    fields.add(new NField("x", new NPrimitive('d')));
    fields.add(new NField("y", new NPrimitive('d')));
    return new NStruct("CGPoint", fields);
}
 
Example #28
Source File: TypeToJType.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected JType accept(Type type, NPrimitive nt32, NPrimitive nt64){
    final ComplexCoderDescriptor coderDesc = ComplexCoderDescriptor.getCoderDescriptorFor(type.type32, type.type64);
    if (coderDesc == null) return null;
    return new JPrimitive(type, coderDesc);
}
 
Example #29
Source File: NTypeParser.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override protected boolean parsePossible(StringStream ss) {
    return NPrimitive.CODES.contains(ss.peek());
}
 
Example #30
Source File: NTypeParser.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override protected boolean parsePossible(StringStream ss) {
    return NPrimitive.CODES.contains(ss.peek());
}