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

The following examples show how to use com.apple.internal.jobjc.generator.model.types.NType. 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: NTypeParser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override protected NType parse(StringStream ss) {
    assert parsePossible(ss);
    // {_NSRect=
    //   "origin"{_NSPoint="x"f"y"f}
    //   "size"{_NSSize="width"f"height"f}}
    ss.eat(getOpen());
    String cname = ss.readUntilEither("=" + getClose());
    List<NStruct.NField> fields = new ArrayList<NStruct.NField>();
    if(ss.peek() == '='){
        ss.eat('=');
        while(ss.peek() != getClose()){
            String fname = "";
            if(ss.peek() == '"'){
                ss.eat('"');
                fname = ss.readUntil('"');
                ss.eat('"');
            }
            NType type = NTypeParser.parseFrom(ss);
            fields.add(new NStruct.NField(fname, type));
        }
    }
    ss.eat(getClose());
    return getNew(cname, fields);
}
 
Example #2
Source File: NTypeMerger.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Merge a and b.
 */
public NType merge(NType a, NType b) throws MergeFailed{
    if(a!=null && b==null) return a;
    if(a==null && b!=null) return b;
    if(a==null && b==null) return null;
    if(a.equals(b)) return a;
    try {
        return Dispatcher.dispatch(getClass(), this, "accept", a, b);
    } catch (NoSuchMethodException e) {
        throw new MergeFailed("a and b are of different NType", a, b);
    }
}
 
Example #3
Source File: ComplexCoderDescriptor.java    From openjdk-jdk8u-backup 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 #4
Source File: NTypeParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override protected NType parse(StringStream ss) {
    ss.eat('[');
    int size = Integer.parseInt(ss.readWhileDigits());
    NType type = NTypeParser.parseFrom(ss);
    ss.eat(']');
    return new NArray(size, type);
}
 
Example #5
Source File: NTypeParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override protected NType parse(StringStream ss) {
    if(ss.peek() == '*'){
        ss.eat('*');
        return CHAR_PTR;
    }
    else{
        ss.eat('^');
        return new NPointer(NTypeParser.parseFrom(ss));
    }
}
 
Example #6
Source File: NTypeMerger.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Merge a and b.
 */
public NType merge(NType a, NType b) throws MergeFailed{
    if(a!=null && b==null) return a;
    if(a==null && b!=null) return b;
    if(a==null && b==null) return null;
    if(a.equals(b)) return a;
    try {
        return Dispatcher.dispatch(getClass(), this, "accept", a, b);
    } catch (NoSuchMethodException e) {
        throw new MergeFailed("a and b are of different NType", a, b);
    }
}
 
Example #7
Source File: NTypeParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected static NType parseFrom(StringStream ss) {
    if(ss.left() == 0)
        return null;
    try{
        for(NTypeParser nt : PARSERS)
            if(nt.parsePossible(ss))
                return nt.parse(ss);
    }
    catch(RuntimeException x){
        throw new RuntimeException("Exception while parsing '" + ss.remainingToString()
                + "' from '" + ss.toString() + "'", x);
    }
    throw new RuntimeException("Found no parser for '" + ss.remainingToString()
            + "' from '" + ss.toString() + "'");
}
 
Example #8
Source File: NativeTypeTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private NType doParse(String type){
    NType nt = NTypeParser.parseFrom(type);
    String printed = nt.toString();
    System.out.println("Original: " + type);
    System.out.println("Printed.: " + printed);
    assertEquals(type, printed);
    return nt;
}
 
Example #9
Source File: NTypePrinter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public String print(NType nt){
    try {
        return Dispatcher.dispatch(getClass(), this, "accept", nt);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
 
Example #10
Source File: ComplexCoderDescriptor.java    From jdk8u60 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 #11
Source File: NTypeParser.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override protected NType parse(StringStream ss) {
    ss.eat('[');
    int size = Integer.parseInt(ss.readWhileDigits());
    NType type = NTypeParser.parseFrom(ss);
    ss.eat(']');
    return new NArray(size, type);
}
 
Example #12
Source File: NativeTypeTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private NType doParse(String type){
    NType nt = NTypeParser.parseFrom(type);
    String printed = nt.toString();
    System.out.println("Original: " + type);
    System.out.println("Printed.: " + printed);
    assertEquals(type, printed);
    return nt;
}
 
Example #13
Source File: NTypeMerger.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Merge a and b.
 */
public NType merge(NType a, NType b) throws MergeFailed{
    if(a!=null && b==null) return a;
    if(a==null && b!=null) return b;
    if(a==null && b==null) return null;
    if(a.equals(b)) return a;
    try {
        return Dispatcher.dispatch(getClass(), this, "accept", a, b);
    } catch (NoSuchMethodException e) {
        throw new MergeFailed("a and b are of different NType", a, b);
    }
}
 
Example #14
Source File: NativeTypeTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private NType doParse(String type){
    NType nt = NTypeParser.parseFrom(type);
    String printed = nt.toString();
    System.out.println("Original: " + type);
    System.out.println("Printed.: " + printed);
    assertEquals(type, printed);
    return nt;
}
 
Example #15
Source File: NTypeParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override protected NType parse(StringStream ss) {
    if(ss.peek() == '*'){
        ss.eat('*');
        return CHAR_PTR;
    }
    else{
        ss.eat('^');
        return new NPointer(NTypeParser.parseFrom(ss));
    }
}
 
Example #16
Source File: NTypeParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected static NType parseFrom(StringStream ss) {
    if(ss.left() == 0)
        return null;
    try{
        for(NTypeParser nt : PARSERS)
            if(nt.parsePossible(ss))
                return nt.parse(ss);
    }
    catch(RuntimeException x){
        throw new RuntimeException("Exception while parsing '" + ss.remainingToString()
                + "' from '" + ss.toString() + "'", x);
    }
    throw new RuntimeException("Found no parser for '" + ss.remainingToString()
            + "' from '" + ss.toString() + "'");
}
 
Example #17
Source File: NTypePrinter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public String print(NType nt){
    try {
        return Dispatcher.dispatch(getClass(), this, "accept", nt);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
 
Example #18
Source File: NativeTypeTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testMerge(){
    NType a = doParse("{_NSRect={_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=ff}}");
    NType b = doParse("{_NSRect=\"origin\"{_NSPoint=ff}{_NSSize=\"width\"f\"height\"f}}");
    NType c = NTypeMerger.inst().merge(a, b);
    NType expected = doParse("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}");
    System.out.println("Merge results:");
    System.out.println("\ta: " + a.toString());
    System.out.println("\tb: " + b.toString());
    System.out.println("\tc: " + c.toString());
    System.out.println("\tx: " + expected.toString());
    assertEquals(expected, c);
}
 
Example #19
Source File: StructOffsetResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #20
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 #21
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 #22
Source File: NTypeParser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override protected NType parse(StringStream ss) {
    ss.eat('[');
    int size = Integer.parseInt(ss.readWhileDigits());
    NType type = NTypeParser.parseFrom(ss);
    ss.eat(']');
    return new NArray(size, type);
}
 
Example #23
Source File: NTypeMerger.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Merge a and b.
 */
public NType merge(NType a, NType b) throws MergeFailed{
    if(a!=null && b==null) return a;
    if(a==null && b!=null) return b;
    if(a==null && b==null) return null;
    if(a.equals(b)) return a;
    try {
        return Dispatcher.dispatch(getClass(), this, "accept", a, b);
    } catch (NoSuchMethodException e) {
        throw new MergeFailed("a and b are of different NType", a, b);
    }
}
 
Example #24
Source File: NTypePrinter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public String print(NType nt){
    try {
        return Dispatcher.dispatch(getClass(), this, "accept", nt);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
 
Example #25
Source File: NTypeParser.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override protected NType parse(StringStream ss) {
    assert parsePossible(ss);
    return NPrimitive.inst(ss.read());
}
 
Example #26
Source File: NTypeParser.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected NType getNew(String cname, List<NStruct.NField> fields){
    return new NStruct(cname, fields);
}
 
Example #27
Source File: NTypeParser.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static NType parseFrom(String s) {
    if(!cached.containsKey(s)) cached.put(s, parseFrom(new StringStream(s)));
    return cached.get(s);
}
 
Example #28
Source File: NTypeMerger.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected NType accept(NArray a, NArray b) {
    if(a.length != b.length)
        throw new MergeFailed("a and b are of different sizes", a, b);
    return new NArray(a.length, NTypeMerger.inst().merge(a.type, b.type));
}
 
Example #29
Source File: NTypeMerger.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected NType accept(NUnion a, NUnion b) {
    NStruct nst = mergeStructs(a, b);
    return new NUnion(nst.name, Fp.map(NUnion.zeroOffsets, nst.fields), nst.sizeof);
}
 
Example #30
Source File: NTypeMerger.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected NType accept(NUnion a, NUnion b) {
    NStruct nst = mergeStructs(a, b);
    return new NUnion(nst.name, Fp.map(NUnion.zeroOffsets, nst.fields), nst.sizeof);
}