Package nexj.core.scripting

Examples of nexj.core.scripting.Function


    */
   public static void addMembers(ClassObject classObject)
   {
      MemberObject.addMembers(classObject);

      classObject.addMethod(":initializer", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(((AttributeObject)machine.getArg(0, nArgCount)).getInitializerFunction(), nArgCount);

            return false;
         }
      });

      classObject.addMethod(":initializer", 1, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            AttributeObject attribute = (AttributeObject)machine.getArg(0, nArgCount);
            Function fun = attribute.getHolder().compile(machine.getArg(1, nArgCount),
               attribute.getName(), ":initializer", machine);

            attribute.setInitializerFunction(fun);
            machine.returnValue(fun, nArgCount);

            return false;
         }
      });

      classObject.addMethod(":setter", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(((AttributeObject)machine.getArg(0, nArgCount)).getSetterFunction(), nArgCount);

            return false;
         }
      });

      classObject.addMethod(":setter", 1, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            AttributeObject attribute = (AttributeObject)machine.getArg(0, nArgCount);
            Function fun = attribute.getHolder().compile(machine.getArg(1, nArgCount),
               attribute.getName(), ":setter", machine);

            attribute.setSetterFunction(fun);
            machine.returnValue(fun, nArgCount);

View Full Code Here


         throw new InvocationException("err.scripting.funCall");
      }

      machine.setArg(0, nArgCount, this);

      Function fun = m_class.resolveFunction((Symbol)selector, nArgCount - 1);

      if (fun != null)
      {
         return fun.invoke(nArgCount, machine);
      }

      throw new InvocationException("err.scripting.methodLookup",
         new Object[]{selector.toString(), Primitive.createInteger(nArgCount - 1), m_class.getName()});
   }
View Full Code Here

         throw new InvocationException("err.scripting.funCall");
      }

      machine.setArg(0, nArgCount, this);

      Function fun = m_class.resolveBaseFunction((Symbol)selector, nArgCount - 1);

      if (fun != null)
      {
         return fun.invoke(nArgCount, machine);
      }

      throw new InvocationException("err.scripting.baseMethodLookup",
         new Object[]{selector.toString(), Primitive.createInteger(nArgCount - 1), m_class.getName()});
   }
View Full Code Here

    * Exposes class members from ObjectException.
    * @param classObject The destination class object.
    */
   public static void addClassMembers(ClassObject classObject)
   {
      classObject.addMethod("new", 2, true, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            ObjectException e = (ObjectException)((ClassObject)machine.getArg(0, nArgCount)).createObject();
            Object err = machine.getArg(1, nArgCount);
View Full Code Here

         s_logger.dump((bAcquired) ? "Acquired" : "Not acquired");
      }

      if (bAcquired)
      {
         Function compensator = new Function()
         {
            public boolean invoke(int nArgCount, Machine machine)
            {
               int nTxState = ((Number)machine.getArg(nArgCount - 1, nArgCount)).intValue();
View Full Code Here

      super(Symbol.define("sys:GrandMetaclass"));
      m_class = null;

      ClassObject.addMembers(this);

      addMethod(":new", 1, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            Object symbol = machine.getArg(1, nArgCount);

            machine.returnValue(((MetaclassObject)machine.getArg(0, nArgCount))
               .createClass((symbol == null || symbol instanceof Symbol) ? (Symbol)symbol :
                  Symbol.define((String)symbol)), nArgCount);

            return false;
         }
      });

      addMethod(":define", 1, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            Object obj = machine.getArg(1, nArgCount);
View Full Code Here

   {
      final Binary resource = (Binary)semaphoreDef.getHead();

      release(resource); // release the resource immediately

      Function compensator = new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            int nTxState = ((Number)machine.getArg(nArgCount - 1, nArgCount)).intValue();
View Full Code Here

    *
    * @param OID oid the oid of the message that has been delivered.
    */
   public static void complete(Metaclass metaclass, final ObjectQueueDispatcher comp, final OID oid, ActionContext actx)
   {
      Function compensator = new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            int nTxState = ((Number)machine.getArg(nArgCount - 1, nArgCount)).intValue();

View Full Code Here

    * @return The function, or null if not found.
    */
   public Function resolveFunction(Symbol symbol, int nArgCount)
   {
      ClassEnvironment env = getEnvironment();
      Function function = env.findFunction(this, symbol, nArgCount);

      if (function != null)
      {
         return function;
      }
View Full Code Here

    * @return The function, or null if not found.
    */
   public Function resolveBaseFunction(Symbol symbol, int nArgCount)
   {
      ClassEnvironment env = getEnvironment();
      Function function = env.findFunction(this, symbol, -1 - nArgCount);

      if (function != null)
      {
         return function;
      }
View Full Code Here

TOP

Related Classes of nexj.core.scripting.Function

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.