Exemple #1
0
        public static int Apply(ScriptContext /*!*/ context, PHP.Core.Reflection.DTypeDesc caller, Iterator /*!*/ iterator, PhpCallback function, PhpArray args)
        {
            // check parameters:
            Debug.Assert(context != null);

            Debug.Assert(iterator != null, "Phalanger should not pass a null here.");

            if (function == null)
            {
                PhpException.ArgumentNull("function");
                return(-1);
            }

            // copy args into object array:
            object[] args_array;

            if (args != null)
            {
                args_array = new object[args.Count];
                args.Values.CopyTo(args_array, 0);
            }
            else
            {
                args_array = ArrayUtils.EmptyObjects;
            }

            // iterate through the iterator:
            int n = 0;

            iterator.rewind(context);

            while (PHP.Core.Convert.ObjectToBoolean(iterator.valid(context)))
            {
                if (!PHP.Core.Convert.ObjectToBoolean(function.Invoke(caller, args_array)))
                {
                    break;
                }
                n++;

                iterator.next(context);
            }

            // return amount of iterated elements:
            return(n);
        }
Exemple #2
0
 public static int Apply(ScriptContext /*!*/ context, PHP.Core.Reflection.DTypeDesc caller, Iterator iterator, PhpCallback function)
 {
     return(Apply(context, caller, iterator, function, null));
 }