本文整理汇总了Java中com.apple.jobjc.PrimitiveCoder.FloatCoder类的典型用法代码示例。如果您正苦于以下问题:Java FloatCoder类的具体用法?Java FloatCoder怎么用?Java FloatCoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FloatCoder类属于com.apple.jobjc.PrimitiveCoder包,在下文中一共展示了FloatCoder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoubleIntLongMethod
import com.apple.jobjc.PrimitiveCoder.FloatCoder; //导入依赖的package包/类
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);
}
示例2: getCoderAtRuntimeForType
import com.apple.jobjc.PrimitiveCoder.FloatCoder; //导入依赖的package包/类
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);
}