private bool ValidateFunction(GenericFunction term, out StyleValueFunction func)
        {
            func = StyleValueFunction.Unknown;
            if (term.Arguments.Length == 0)
            {
                m_Errors.AddSemanticError(StyleSheetImportErrorCode.MissingFunctionArgument, term.Name);
                return(false);
            }

            if (term.Name == k_VariableFunctionName)
            {
                func = StyleValueFunction.Var;
                return(ValidateVarFunction(term));
            }

            try
            {
                func = StyleValueFunctionExtension.FromUssString(term.Name);
            }
            catch (Exception)
            {
                var prop = m_Builder.currentProperty;
                m_Errors.AddValidationWarning($"Unknown function {term.Name} in declaration {prop.name}: {term.Name}", prop.line);
                return(false);
            }

            return(true);
        }
示例#2
0
        internal string ReadFunctionName(StyleValueHandle handle)
        {
            bool   flag = handle.valueType != StyleValueType.Function;
            string result;

            if (flag)
            {
                Debug.LogErrorFormat(string.Format("Trying to read value of type {0} while reading a value of type {1}", StyleValueType.Function, handle.valueType), new object[0]);
                result = string.Empty;
            }
            else
            {
                StyleValueFunction valueIndex = (StyleValueFunction)handle.valueIndex;
                result = valueIndex.ToUssString();
            }
            return(result);
        }
        public static string ToUssString(this StyleValueFunction svf)
        {
            switch (svf)
            {
            case StyleValueFunction.Var:
                return(k_Var);

            case StyleValueFunction.Env:
                return(k_Env);

            case StyleValueFunction.LinearGradient:
                return(k_LinearGradient);

            default:
                throw new ArgumentOutOfRangeException(nameof(svf), svf, $"Unknown {nameof(StyleValueFunction)}");
            }
        }
示例#4
0
        public static string ToUssString(this StyleValueFunction svf)
        {
            string result;

            switch (svf)
            {
            case StyleValueFunction.Var:
                result = "var";
                break;

            case StyleValueFunction.Env:
                result = "env";
                break;

            case StyleValueFunction.LinearGradient:
                result = "linear-gradient";
                break;

            default:
                throw new ArgumentOutOfRangeException("svf", svf, "Unknown StyleValueFunction");
            }
            return(result);
        }
示例#5
0
 public void AddValue(StyleValueFunction function)
 {
     // for function we use the index to store the enum value
     m_CurrentValues.Add(new StyleValueHandle((int)function, StyleValueType.Function));
 }
 public void AddValue(StyleValueFunction function)
 {
     this.m_CurrentValues.Add(new StyleValueHandle((int)function, StyleValueType.Function));
 }