Package js.lang

Examples of js.lang.NativeFunction


            for (Method method : interfaceType.getMethods()) {
                if (!method.isDefault() && (method.getDeclaringClass() != Annotation.class || method.getName()
                        .equals("annotationType"))) {
                    ProxyFunction function = new ProxyFunction(proxy, method);
                    NativeObject.by(proxy)
                            .setProperty(((JSMethod) (Object) method).nameJS, new NativeFunction(function).bind(function));
                }
            }
        }

        // API definition
View Full Code Here


         * {@inheritDoc}
         */
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            // from user value
            NativeFunction function = object.getPropertyAs(NativeFunction.class, ((JSMethod) (Object) method).nameJS);

            if (function != null) {
                Object value = function.apply(null);
                Class type = method.getReturnType();

                if (type.isAnnotation()) {
                    return Proxy.newProxyInstance(null, new Class[] {type}, new AnnotationProxy(type, value));
                } else if (type.isArray() && type.getComponentType().isAnnotation()) {
View Full Code Here

     *             comparable</i> using the specified comparator
     * @throws IllegalArgumentException (optional) if the comparator is found to violate the
     *             {@link Comparator} contract
     */
    public static <T> void sort(T[] array, Comparator<? super T> comparator) {
        new NativeArray(array).sort(new NativeFunction(comparator).bind(comparator));
    }
View Full Code Here

     * @throws IllegalArgumentException if {@code fromIndex > toIndex} or (optional) if the
     *             comparator is found to violate the {@link Comparator} contract
     * @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or {@code toIndex > a.length}
     */
    public static <T> void sort(T[] array, int fromIndex, int toIndex, Comparator<? super T> comparator) {
        new NativeArray(array).sort(new NativeFunction(comparator).bind(comparator)); // FIXME
    }
View Full Code Here

                if (!annotations.isEmpty()) {
                    InterceptorFunction function = new InterceptorFunction(method.getName(), MethodHandles
                            .lookup()
                            .unreflect(method), annotations.toArray(new Annotation[annotations.size()]));
                    prototype.setProperty(Reflections.getPropertyName(method), new NativeFunction(function));
                }
            }
        } catch (Exception e) {
            throw I.quiet(e);
        }
View Full Code Here

                                try {
                                    name = Reflections.getPropertyName(model.type.getMethod(name, property.model.type));

                                    BindingFunction function = new BindingFunction(prototype.getPropertyAs(NativeFunction.class, name), property.name);
                                    prototype.setProperty(name, new NativeFunction(function));
                                } catch (Exception e) {
                                    throw I.quiet(e);
                                }
                            }
                        }
View Full Code Here

TOP

Related Classes of js.lang.NativeFunction

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.