Package org.mozilla.javascript

Examples of org.mozilla.javascript.NativeJavaObject


            String prototypeName = app.getPrototypeName(e);
            Scriptable op = getPrototype(prototypeName);

            if (op == null) {
                // no prototype found, return an unscripted wrapper
                wrapper = new NativeJavaObject(global, e, e.getClass());
            } else {
                wrapper = new JavaObject(global, e, prototypeName, op, this);
            }

            wrappercache.put(e, new WeakReference(wrapper));
View Full Code Here


        }

        if(njo == null) {
            synchronized (this) {
                if(njo == null) {
                    njo = new NativeJavaObject(start, wrapped, getStaticType());
                }
            }
        }

        return njo.get(name, start);
View Full Code Here

  public Object convert(final Object o)
  {
    if (o instanceof NativeJavaObject)
    {
      final NativeJavaObject object = (NativeJavaObject) o;
      return object.unwrap();
    }
    if (o instanceof NativeArray)
    {
      final NativeArray array = (NativeArray) o;
      final Object[] result = new Object[(int) array.getLength()];
View Full Code Here

            mainModule.defineProperty("filename", new File("tsc.js").getAbsolutePath(), ScriptableObject.READONLY);

            tscScript.exec(ctx, globalScope);
        } catch (JavaScriptException e) {
            if (e.getValue() instanceof NativeJavaObject) {
                NativeJavaObject njo = (NativeJavaObject) e.getValue();
                Object o = njo.unwrap();
                if (o instanceof ProcessExit) {
                    ProcessExit pe = (ProcessExit) o;
                    if (pe.getStatus() != 0) {
                        throw new TscInvocationException("Process Error: " + pe.getStatus());
                    }
View Full Code Here

      wrapper = initializeScope(scope);

      final Object o = context.evaluateString(scope, expression, getName(), 1, null);
      if (o instanceof NativeJavaObject)
      {
        final NativeJavaObject object = (NativeJavaObject) o;
        return object.unwrap();
      }
      return o;
    }
    finally
    {
View Full Code Here

        } else if (javaObject instanceof List) {
            return new NativeListAdapter(cx, scope, javaObject, staticType);
        } else if( scriptableJavaObjects ) {
            return new ScriptableNativeJavaObject(scope,javaObject,staticType);
        } else {
            return new NativeJavaObject(scope, javaObject, staticType);
        }
    }
View Full Code Here

        }

        public Object call(Context ctx, Scriptable scope,
                           Scriptable thisObj, Object[] args)
            throws JavaScriptException {
            NativeJavaObject  njo = (NativeJavaObject)thisObj;
            if (args[1] instanceof Function) {
                EventListener evtListener = new FunctionEventListener
                    ((Function)args[1],
                     ((RhinoInterpreter.ExtendedContext)ctx).getInterpreter());
                listenerMap.put(args[1], new SoftReference(evtListener));
                // we need to marshall args
                Class[] paramTypes = { String.class, Function.class,
                                       Boolean.TYPE };
                for (int i = 0; i < args.length; i++)
                    args[i] = Context.toType(args[i], paramTypes[i]);
                ((EventTarget)njo.unwrap()).addEventListener
                    ((String)args[0], evtListener,
                     ((Boolean)args[2]).booleanValue());
                return Undefined.instance;
            }
            if (args[1] instanceof NativeObject) {
                EventListener evtListener =
                    new HandleEventListener((Scriptable)args[1],
                                            ((RhinoInterpreter.ExtendedContext)
                                             ctx).getInterpreter());
                listenerMap.put(args[1], new SoftReference(evtListener));
                // we need to marshall args
                Class[] paramTypes = { String.class, Scriptable.class,
                                       Boolean.TYPE };
                for (int i = 0; i < args.length; i++)
                    args[i] = Context.toType(args[i], paramTypes[i]);
                ((EventTarget)njo.unwrap()).addEventListener
                    ((String)args[0], evtListener,
                     ((Boolean)args[2]).booleanValue());
                return Undefined.instance;
            }
            return delegate.call(ctx, scope, thisObj, args);
View Full Code Here

        }

        public Object call(Context ctx, Scriptable scope,
                           Scriptable thisObj, Object[] args)
            throws JavaScriptException {
            NativeJavaObject  njo = (NativeJavaObject)thisObj;
            if (args[1] instanceof Function) {
                SoftReference sr = (SoftReference)listenerMap.get(args[1]);
                if (sr == null)
                    return Undefined.instance;
                EventListener el = (EventListener)sr.get();
                if (el == null)
                    return Undefined.instance;
                // we need to marshall args
                Class[] paramTypes = { String.class, Function.class,
                                       Boolean.TYPE };
                for (int i = 0; i < args.length; i++)
                    args[i] = Context.toType(args[i], paramTypes[i]);
                ((EventTarget)njo.unwrap()).removeEventListener
                    ((String)args[0], el, ((Boolean)args[2]).booleanValue());
                return Undefined.instance;
            }
            if (args[1] instanceof NativeObject) {
                SoftReference sr = (SoftReference)listenerMap.get(args[1]);
                if (sr == null)
                    return Undefined.instance;
                EventListener el = (EventListener)sr.get();
                if (el == null)
                    return Undefined.instance;
                // we need to marshall args
                Class[] paramTypes = { String.class, Scriptable.class,
                                       Boolean.TYPE };
                for (int i = 0; i < args.length; i++)
                    args[i] = Context.toType(args[i], paramTypes[i]);

                ((EventTarget)njo.unwrap()).removeEventListener
                    ((String)args[0], el, ((Boolean)args[2]).booleanValue());
                return Undefined.instance;
            }
            return delegate.call(ctx, scope, thisObj, args);
        }
View Full Code Here

        }
       
        if(njo == null) {
            synchronized (this) {
                if(njo == null) {
                    njo = new NativeJavaObject(start, wrapped, getStaticType());
                }
            }
        }
       
        return njo.get(name, start);
View Full Code Here

        }

        public Object call(Context ctx, Scriptable scope,
                           Scriptable thisObj, Object[] args)
            throws JavaScriptException {
            NativeJavaObject  njo = (NativeJavaObject)thisObj;
            if (args[1] instanceof Function) {
                EventListener evtListener = new FunctionEventListener
                    ((Function)args[1],
                     ((RhinoInterpreter.ExtendedContext)ctx).getInterpreter());
                listenerMap.put(args[1], new SoftReference(evtListener));
                // we need to marshall args
                Class[] paramTypes = { String.class, Function.class,
                                       Boolean.TYPE };
                for (int i = 0; i < args.length; i++)
                    args[i] = Context.toType(args[i], paramTypes[i]);
                ((EventTarget)njo.unwrap()).addEventListener
                    ((String)args[0], evtListener,
                     ((Boolean)args[2]).booleanValue());
                return Undefined.instance;
            }
            if (args[1] instanceof NativeObject) {
                EventListener evtListener =
                    new HandleEventListener((Scriptable)args[1],
                                            ((RhinoInterpreter.ExtendedContext)
                                             ctx).getInterpreter());
                listenerMap.put(args[1], new SoftReference(evtListener));
                // we need to marshall args
                Class[] paramTypes = { String.class, Scriptable.class,
                                       Boolean.TYPE };
                for (int i = 0; i < args.length; i++)
                    args[i] = Context.toType(args[i], paramTypes[i]);
                ((EventTarget)njo.unwrap()).addEventListener
                    ((String)args[0], evtListener,
                     ((Boolean)args[2]).booleanValue());
                return Undefined.instance;
            }
            return delegate.call(ctx, scope, thisObj, args);
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeJavaObject

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.