Exemplo n.º 1
0
        // Leaves the link in the same state as when it started. The out param leafExprType will be Function if
        // the array is empty in the first bottom-level subarray: {{}, {1,2,3}}.
        internal static int determineIncomingArrayDepth(IMathLink ml /*, out ExpressionType leafExprType*/)
        {
            int       actualDepth = 0;
            ILinkMark mark        = ml.CreateMark();

//        // Initial value just to satisfy compiler; if depth of 0 is returned, then the leafExprType will be ignored by callers.
//        leafExprType = ExpressionType.Function;
            try {
                int    len;
                string head = ml.GetFunction(out len);
                actualDepth = 1;
                while (len > 0)
                {
                    ExpressionType leafExprType = ml.GetNextExpressionType();
                    if (leafExprType == ExpressionType.Function)
                    {
                        head = ml.GetFunction(out len);
                        actualDepth++;
                    }
                    else
                    {
                        break;
                    }
                }
//            // If the last sublist is empty (len == 0), we will walk off the end of the above loop with
//            // leafExprType == ExpressionType.Function, which is what we want.
            } catch (MathLinkException) {
                // Do nothing but clear it. Returning 0 is enough.
                ml.ClearError();
            } finally {
                ml.SeekMark(mark);
                ml.DestroyMark(mark);
            }
            return(actualDepth);
        }
Exemplo n.º 2
0
 public override string GetFunction(out int argCount)
 {
     return(impl.GetFunction(out argCount));
 }