Package webit.script.lang

Examples of webit.script.lang.MethodDeclare


            throw new ParseException(ex.getMessage(), line, column);
        }
    }

    public MethodDeclare getNativeMethodDeclare(Method method) {
        MethodDeclare declare = CACHE.get(method);
        if (declare == null) {
            declare = createNativeMethodDeclare(method);
            MethodDeclare old = CACHE.putIfAbsent(method, declare);
            if (old != null) {
                return old;
            }
        }
        return declare;
View Full Code Here


        }
        return declare;
    }

    public MethodDeclare getNativeConstructorDeclare(Constructor constructor) {
        MethodDeclare declare = CACHE.get(constructor);
        if (declare == null) {
            declare = createNativeConstructorDeclare(constructor);
            MethodDeclare old = CACHE.putIfAbsent(constructor, declare);
            if (old != null) {
                return old;
            }
        }
        return declare;
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    public void test() throws Exception {

        MethodDeclare str_toString = AsmNativeFactory.createAccessor(String.class.getMethod("toString", new Class[0]));
       
        MethodDeclare currentTimeMillis = AsmNativeFactory.createAccessor(System.class.getMethod("currentTimeMillis", new Class[0]));
        MethodDeclare newList = AsmNativeFactory.createAccessor(ArrayList.class.getConstructor());
        MethodDeclare listSize = AsmNativeFactory.createAccessor(ArrayList.class.getMethod("size", new Class[0]));
       
        MethodDeclare listAdd = AsmNativeFactory.createAccessor(List.class.getMethod("add", new Class[]{Object.class}));
        MethodDeclare newListWithInitSize = AsmNativeFactory.createAccessor(ArrayList.class.getConstructor(new Class[]{int.class}));
        MethodDeclare listAddToIndex = AsmNativeFactory.createAccessor(List.class.getMethod("add", new Class[]{int.class, Object.class}));
        MethodDeclare arraycopy = AsmNativeFactory.createAccessor(System.class.getMethod("arraycopy", new Class[]{Object.class, int.class, Object.class, int.class, int.class}));

        assertEquals("aaa", str_toString.invoke(null, new Object[]{"aaa"}));
       
        assertEquals(currentTimeMillis.invoke(null, null).getClass(), Long.class);
        assertEquals(currentTimeMillis.invoke(null, new Object[0]).getClass(), Long.class);
        assertEquals(currentTimeMillis.invoke(null, new Object[]{1, 2, 3}).getClass(), Long.class);

        int[] array1 = new int[]{1, 2, 3, 4, 6};
        int[] array2 = new int[array1.length];

        assertEquals(arraycopy.invoke(null, new Object[]{array1, 0, array2, 0, array1.length}), Context.VOID);
        assertArrayEquals(array2, array2);

        List list = (List) newList.invoke(null, null);

        List list2 = (List) newListWithInitSize.invoke(null, new Object[]{2});
View Full Code Here

    private static final String[] METHOD_DECLARE = new String[]{"webit/script/lang/MethodDeclare"};

    @Override
    protected MethodDeclare createNativeConstructorDeclare(Constructor constructor) {
        MethodDeclare accessor = createMethodDeclare(constructor);
        if (accessor != null) {
            return accessor;
        }
        return super.createNativeConstructorDeclare(constructor);
    }
View Full Code Here

        return super.createNativeConstructorDeclare(constructor);
    }

    @Override
    protected MethodDeclare createNativeMethodDeclare(Method method) {
        MethodDeclare accessor = createMethodDeclare(method);
        if (accessor != null) {
            return accessor;
        }
        return super.getNativeMethodDeclare(method);
    }
View Full Code Here

        return super.getNativeMethodDeclare(method);
    }

    protected MethodDeclare createMethodDeclare(Member member) {
        if (ClassUtil.isPublic(member.getDeclaringClass()) && ClassUtil.isPublic(member)) {
            MethodDeclare declare = CACHE.get(member);
            if (declare == null) {
                synchronized (CACHE) {
                    try {
                        declare = CACHE.get(member);
                        if (declare == null) {
View Full Code Here

TOP

Related Classes of webit.script.lang.MethodDeclare

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.