com.apple.jobjc.PrimitiveCoder.SIntCoder Java Examples

The following examples show how to use com.apple.jobjc.PrimitiveCoder.SIntCoder. 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: 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 #2
Source File: SubclassingTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #3
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 #4
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 #5
Source File: SubclassingTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #6
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 #7
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 #8
Source File: SubclassingTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #9
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 #10
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 #11
Source File: SubclassingTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #12
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 #13
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 #14
Source File: SubclassingTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #15
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 #16
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 #17
Source File: SubclassingTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #18
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 #19
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 #20
Source File: SubclassingTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #21
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 #22
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 #23
Source File: SubclassingTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
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);
}
 
Example #25
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 #26
Source File: SubclassingTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #27
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 #28
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 #29
Source File: SubclassingTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #30
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);
}