Ejemplo n.º 1
0
            public int Compare(ScriptObject x, ScriptObject y)
            {
                ScriptNumber ret = func.Call(new ScriptObject[] { x, y }) as ScriptNumber;

                if (ret == null)
                {
                    throw new ExecutionException(script, "Sort 返回值 必须是Number类型");
                }
                return(ret.ToInt32());
            }
Ejemplo n.º 2
0
 public void Sort(ScriptFunction func)
 {
     m_listObject.Sort(new Comparison <ScriptObject>((o1, o2) => {
         ScriptNumber ret = func.Call(new ScriptObject[] { o1, o2 }) as ScriptNumber;
         if (ret == null)
         {
             throw new ExecutionException(Script, "Sort 返回值 必须是Number类型");
         }
         return(ret.ToInt32());
     }));
 }
Ejemplo n.º 3
0
            public int Compare(ScriptValue o1, ScriptValue o2)
            {
                args[0] = o1;
                args[1] = o2;
                var ret = func.Call(ScriptValue.Null, args, 2);

                if (ret.valueType == ScriptValue.doubleValueType)
                {
                    return((int)ret.doubleValue);
                }
                else if (ret.valueType == ScriptValue.longValueType)
                {
                    return((int)ret.longValue);
                }
                throw new ExecutionException("数组排序返回值必须是Number类型");
            }
Ejemplo n.º 4
0
            public int Compare(ScriptValue o1, ScriptValue o2)
            {
                ScriptValue.Parameters[0] = o1;
                ScriptValue.Parameters[1] = o2;
                var ret = func.Call(ScriptValue.Null, ScriptValue.Parameters, 2);

                switch (ret.valueType)
                {
                case ScriptValue.doubleValueType: return(Convert.ToInt32(ret.doubleValue));

                case ScriptValue.longValueType: return(Convert.ToInt32(ret.longValue));

                case ScriptValue.trueValueType: return(1);

                case ScriptValue.falseValueType: return(-1);

                default: throw new ExecutionException("数组排序返回值必须是Number或Bool类型");
                }
            }