• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NativeArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中jdk.nashorn.internal.objects.NativeArray的典型用法代码示例。如果您正苦于以下问题:Java NativeArray类的具体用法?Java NativeArray怎么用?Java NativeArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NativeArray类属于jdk.nashorn.internal.objects包,在下文中一共展示了NativeArray类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getArrayConverter

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
/**
 * Returns a guarded invocation that converts from a source type that is NativeArray to a Java array or List or
 * Deque type.
 * @param sourceType the source type (presumably NativeArray a superclass of it)
 * @param targetType the target type (presumably an array type, or List or Deque)
 * @return a guarded invocation that converts from the source type to the target type. null is returned if
 * either the source type is neither NativeArray, nor a superclass of it, or if the target type is not an array
 * type, List, or Deque.
 */
private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType) {
    final boolean isSourceTypeNativeArray = sourceType == NativeArray.class;
    // If source type is more generic than NativeArray class, we'll need to use a guard
    final boolean isSourceTypeGeneric = !isSourceTypeNativeArray && sourceType.isAssignableFrom(NativeArray.class);

    if (isSourceTypeNativeArray || isSourceTypeGeneric) {
        final MethodHandle guard = isSourceTypeGeneric ? IS_NATIVE_ARRAY : null;
        if(targetType.isArray()) {
            return new GuardedInvocation(ARRAY_CONVERTERS.get(targetType), guard);
        }
        if(targetType == List.class) {
            return new GuardedInvocation(JSType.TO_JAVA_LIST.methodHandle(), guard);
        }
        if(targetType == Deque.class) {
            return new GuardedInvocation(JSType.TO_JAVA_DEQUE.methodHandle(), guard);
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:NashornLinker.java


示例2: getDynamicSignature

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
/**
 * Helper function to generate a function signature based on stack contents
 * and argument count and return type
 *
 * @param returnType return type
 * @param argCount   argument count
 *
 * @return function signature for stack contents
 */
private String getDynamicSignature(final Type returnType, final int argCount) {
    final Type[]         paramTypes = new Type[argCount];

    int pos = 0;
    for (int i = argCount - 1; i >= 0; i--) {
        Type pt = stack.peek(pos++);
        // "erase" specific ScriptObject subtype info - except for NativeArray.
        // NativeArray is used for array/List/Deque conversion for Java calls.
        if (ScriptObject.class.isAssignableFrom(pt.getTypeClass()) &&
            !NativeArray.class.isAssignableFrom(pt.getTypeClass())) {
            pt = Type.SCRIPT_OBJECT;
        }
        paramTypes[i] = pt;
    }
    final String descriptor = Type.getMethodDescriptor(returnType, paramTypes);
    for (int i = 0; i < argCount; i++) {
        popType(paramTypes[argCount - i - 1]);
    }

    return descriptor;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:MethodEmitter.java


示例3: getArrayConverter

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
/**
 * Returns a guarded invocation that converts from a source type that is NativeArray to a Java array or List or
 * Queue or Deque or Collection type.
 * @param sourceType the source type (presumably NativeArray a superclass of it)
 * @param targetType the target type (presumably an array type, or List or Queue, or Deque, or Collection)
 * @return a guarded invocation that converts from the source type to the target type. null is returned if
 * either the source type is neither NativeArray, nor a superclass of it, or if the target type is not an array
 * type, List, Queue, Deque, or Collection.
 */
private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType) {
    final boolean isSourceTypeNativeArray = sourceType == NativeArray.class;
    // If source type is more generic than NativeArray class, we'll need to use a guard
    final boolean isSourceTypeGeneric = !isSourceTypeNativeArray && sourceType.isAssignableFrom(NativeArray.class);

    if (isSourceTypeNativeArray || isSourceTypeGeneric) {
        final MethodHandle guard = isSourceTypeGeneric ? IS_NATIVE_ARRAY : null;
        if(targetType.isArray()) {
            return new GuardedInvocation(ARRAY_CONVERTERS.get(targetType), guard);
        } else if(targetType == List.class) {
            return new GuardedInvocation(TO_LIST, guard);
        } else if(targetType == Deque.class) {
            return new GuardedInvocation(TO_DEQUE, guard);
        } else if(targetType == Queue.class) {
            return new GuardedInvocation(TO_QUEUE, guard);
        } else if(targetType == Collection.class) {
            return new GuardedInvocation(TO_COLLECTION, guard);
        }
    }
    return null;
}
 
开发者ID:malaporte,项目名称:kaziranga,代码行数:31,代码来源:NashornLinker.java


示例4: argsToString

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
/**
 * Joins strings by single space between and quoting args containing any space.
 * @param arr array of strings
 * @return joined quoted strings
 */
public String argsToString(NativeArray arr) {
	StringBuilder sb = new StringBuilder();

	Iterator<Object> iter = arr.valueIterator();
	while (iter.hasNext()) {
		String arg = (String) iter.next();

		if (arg.length() == 0 || arg.indexOf(' ') >= 0) {
			sb.append("\"");
			sb.append(arg);
			sb.append("\"");
		}
		else {
			sb.append(arg);
		}

		if (iter.hasNext()) {
			sb.append(' ');
		}
	}

	return sb.toString();
}
 
开发者ID:Namek,项目名称:TheConsole_POC,代码行数:29,代码来源:JsUtilsProvider.java


示例5: getArrayConverter

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
/**
 * Returns a guarded invocation that converts from a source type that is NativeArray to a Java array or List or
 * Deque type.
 * @param sourceType the source type (presumably NativeArray a superclass of it)
 * @param targetType the target type (presumably an array type, or List or Deque)
 * @return a guarded invocation that converts from the source type to the target type. null is returned if
 * either the source type is neither NativeArray, nor a superclass of it, or if the target type is not an array
 * type, List, or Deque.
 */
private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType) {
    final boolean isSourceTypeNativeArray = sourceType == NativeArray.class;
    // If source type is more generic than ScriptFunction class, we'll need to use a guard
    final boolean isSourceTypeGeneric = !isSourceTypeNativeArray && sourceType.isAssignableFrom(NativeArray.class);

    if (isSourceTypeNativeArray || isSourceTypeGeneric) {
        final MethodHandle guard = isSourceTypeGeneric ? IS_NATIVE_ARRAY : null;
        if(targetType.isArray()) {
            return new GuardedInvocation(ARRAY_CONVERTERS.get(targetType), guard);
        }
        if(targetType == List.class) {
            return new GuardedInvocation(JSType.TO_JAVA_LIST.methodHandle(), guard);
        }
        if(targetType == Deque.class) {
            return new GuardedInvocation(JSType.TO_JAVA_DEQUE.methodHandle(), guard);
        }
    }
    return null;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:29,代码来源:NashornLinker.java


示例6: compareConversion

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
@Override
public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {
    if(sourceType == NativeArray.class) {
        // Prefer lists, as they're less costly to create than arrays.
        if(isList(targetType1)) {
            if(!isList(targetType2)) {
                return Comparison.TYPE_1_BETTER;
            }
        } else if(isList(targetType2)) {
            return Comparison.TYPE_2_BETTER;
        }
        // Then prefer arrays
        if(targetType1.isArray()) {
            if(!targetType2.isArray()) {
                return Comparison.TYPE_1_BETTER;
            }
        } else if(targetType2.isArray()) {
            return Comparison.TYPE_2_BETTER;
        }
    }
    if(ScriptObject.class.isAssignableFrom(sourceType)) {
        // Prefer interfaces
        if(targetType1.isInterface()) {
            if(!targetType2.isInterface()) {
                return Comparison.TYPE_1_BETTER;
            }
        } else if(targetType2.isInterface()) {
            return Comparison.TYPE_2_BETTER;
        }
    }
    return Comparison.INDETERMINATE;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:NashornLinker.java


示例7: argConversionFilter

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
private static MethodHandle argConversionFilter(final Class<?> handleType, final Class<?> fromType) {
    if (handleType == Object.class) {
        if (fromType == Object.class) {
            return EXPORT_ARGUMENT;
        } else if (fromType == NativeArray.class) {
            return EXPORT_NATIVE_ARRAY;
        } else if (fromType == ScriptObject.class) {
            return EXPORT_SCRIPT_OBJECT;
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:NashornBeansLinker.java


示例8: compareConversion

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
@Override
public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {
    if(sourceType == NativeArray.class) {
        // Prefer those types we can convert to with just a wrapper (cheaper than Java array creation).
        if(isArrayPreferredTarget(targetType1)) {
            if(!isArrayPreferredTarget(targetType2)) {
                return Comparison.TYPE_1_BETTER;
            }
        } else if(isArrayPreferredTarget(targetType2)) {
            return Comparison.TYPE_2_BETTER;
        }
        // Then prefer Java arrays
        if(targetType1.isArray()) {
            if(!targetType2.isArray()) {
                return Comparison.TYPE_1_BETTER;
            }
        } else if(targetType2.isArray()) {
            return Comparison.TYPE_2_BETTER;
        }
    }
    if(ScriptObject.class.isAssignableFrom(sourceType)) {
        // Prefer interfaces
        if(targetType1.isInterface()) {
            if(!targetType2.isInterface()) {
                return Comparison.TYPE_1_BETTER;
            }
        } else if(targetType2.isInterface()) {
            return Comparison.TYPE_2_BETTER;
        }
    }
    return Comparison.INDETERMINATE;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:NashornLinker.java


示例9: exportNativeArray

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
@SuppressWarnings("unused")
private static Object exportNativeArray(final NativeArray arg) {
    return exportArgument(arg, MIRROR_ALWAYS);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:NashornBeansLinker.java


示例10: exportScriptArray

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
@SuppressWarnings("unused")
private static Object exportScriptArray(final NativeArray arg) {
    return exportArgument(arg, MIRROR_ALWAYS);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:NashornBeansLinker.java


示例11: getType

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
@Override
public Type getType(final Function<Symbol, Type> localVariableTypes) {
    return Type.typeFor(NativeArray.class);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:LiteralNode.java


示例12: getType

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
@Override
public Type getType() {
    return Type.typeFor(NativeArray.class);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:LiteralNode.java


示例13: testCanConvertScriptObjectSubclassToMirror

import jdk.nashorn.internal.objects.NativeArray; //导入依赖的package包/类
@Test
public void testCanConvertScriptObjectSubclassToMirror() {
    assertCanConvertToMirror(NativeArray.class);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:JDK_8078414_Test.java



注:本文中的jdk.nashorn.internal.objects.NativeArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleContext类代码示例发布时间:2022-05-21
下一篇:
Java ParseGeoPoint类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap