com.apple.jobjc.PrimitiveCoder.DoubleCoder Java Examples
The following examples show how to use
com.apple.jobjc.PrimitiveCoder.DoubleCoder.
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 |
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 |
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 |
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: IntroTest.java From hottub with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #5
Source File: SubclassingTest.java From hottub with GNU General Public License v2.0 | 6 votes |
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 |
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: IntroTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #8
Source File: SubclassingTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 |
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: IntroTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #11
Source File: SubclassingTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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: IntroTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #13
Source File: IntroTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #14
Source File: SubclassingTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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 |
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: IntroTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #17
Source File: SubclassingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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 |
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: IntroTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #20
Source File: SubclassingTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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 |
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: SubclassingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 #23
Source File: Coder.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #24
Source File: IntroTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #25
Source File: SubclassingTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #26
Source File: SubclassingTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 jdk8u60 with GNU General Public License v2.0 | 6 votes |
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: IntroTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #29
Source File: IntroTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void testCore(){ // pass security check and get ahold of a runtime (should cache this) final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); // create a funcall (should cache this) final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); // start function call fc.init(ARGS); // push an arg DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); // make the call fc.invoke(ARGS); // read the return value double ret = DoubleCoder.INST.pop(ARGS); assertEquals(1.0, ret); }
Example #30
Source File: Coder.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); }