com.apple.jobjc.PrimitiveCoder.SCharCoder Java Examples

The following examples show how to use com.apple.jobjc.PrimitiveCoder.SCharCoder. 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: PrimitiveCoderDescriptor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #2
Source File: Coder.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: PrimitiveCoderDescriptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #4
Source File: Coder.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: PrimitiveCoderDescriptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #6
Source File: Coder.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: PrimitiveCoderDescriptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #8
Source File: Coder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #9
Source File: PrimitiveCoderDescriptor.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #10
Source File: Coder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #11
Source File: PrimitiveCoderDescriptor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #12
Source File: Coder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #13
Source File: PrimitiveCoderDescriptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #14
Source File: Coder.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #15
Source File: PrimitiveCoderDescriptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #16
Source File: Coder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #17
Source File: PrimitiveCoderDescriptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #18
Source File: Coder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #19
Source File: PrimitiveCoderDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #20
Source File: Coder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #21
Source File: PrimitiveCoderDescriptor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #22
Source File: Coder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #23
Source File: PrimitiveCoderDescriptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #24
Source File: Coder.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}