Java源码示例:com.apple.jobjc.PrimitiveCoder.BoolCoder

示例1
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例2
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例3
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例4
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例5
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例6
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例7
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例8
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例9
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例10
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例11
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例12
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例13
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例14
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例15
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例16
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例17
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例18
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例19
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例20
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例21
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例22
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}
 
示例23
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
    switch(encoding) {
        case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");

        case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
        case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");

        case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
        case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");

        case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
        case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");

        case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
        case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
        case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
        case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");

        case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
        case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
        default: throw new RuntimeException("unknown encoding: " + encoding);
    }
}
 
示例24
static public Coder getCoderAtRuntimeForType(Class cls){
    if(runtimeCoders == null) runtimeCoders = new Coder[]{
        NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
        DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
        SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
        VoidCoder.INST
    };

    for(Coder c : runtimeCoders)
        if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
                (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
            return c;

    if(Struct.class.isAssignableFrom(cls)){
        try {
            Method m = cls.getDeclaredMethod("getStructCoder");
            m.setAccessible(true);
            return (Coder) m.invoke(null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    throw new RuntimeException("Could not find suitable coder for " + cls);
}