Exemple #1
0
        public static bool TryGetEnumByValueName(this INativeSymbolLookup lookup, string enumValueName, out NativeEnum enumeration, out NativeEnumValue value)
        {
            if (!lookup.TryGetGlobalSymbol(new NativeName(enumValueName, NativeNameKind.EnumValue), out value))
            {
                enumeration = null;
                return(false);
            }

            return(lookup.TryGetGlobalSymbol(
                       new NativeName(value.EnumName, NativeNameKind.Enum),
                       out enumeration));
        }
Exemple #2
0
        public static NativeGlobalSymbol GetGlobalSymbol(this INativeSymbolLookup lookup, NativeName name)
        {
            NativeGlobalSymbol symbol;

            if (!lookup.TryGetGlobalSymbol(name, out symbol))
            {
                throw new Exception($"Unable to get symbol {name}");
            }

            return(symbol);
        }
Exemple #3
0
        /// <summary>
        /// Do a lookup for a symbol with a specific name of the specified type.
        /// </summary>
        internal static bool TryGetGlobalSymbolExhaustive(this INativeSymbolLookup lookup, string name, out NativeGlobalSymbol symbol)
        {
            foreach (var kind in Enum.GetValues(typeof(NativeNameKind)).Cast <NativeNameKind>())
            {
                var nativeName = new NativeName(name, kind);
                if (lookup.TryGetGlobalSymbol(nativeName, out symbol))
                {
                    return(true);
                }
            }

            symbol = default(NativeGlobalSymbol);
            return(false);
        }
Exemple #4
0
        /// <summary>
        /// Do a lookup for a symbol with a specific name of the specified type.
        /// </summary>
        public static bool TryGetGlobalSymbol <T>(this INativeSymbolLookup lookup, string name, out T symbol)
            where T : NativeSymbol
        {
            NativeGlobalSymbol globalSymbol;

            if (!lookup.TryGetGlobalSymbol(name, out globalSymbol))
            {
                symbol = null;
                return(false);
            }

            symbol = globalSymbol.Symbol as T;
            return(symbol != null);
        }
Exemple #5
0
 public bool TryGetGlobalSymbol(string name, out NativeGlobalSymbol symbol) =>
 _storage.TryGetGlobalSymbol(name, out symbol) ||
 _nextSymbolLookup.TryGetGlobalSymbol(name, out symbol);
Exemple #6
0
 public static bool TryGetValue(this INativeSymbolLookup lookup, string name, out NativeSymbol symbol) =>
 lookup.TryGetGlobalSymbol(new NativeName(name, NativeNameKind.Constant), out symbol) ||
 lookup.TryGetGlobalSymbol(new NativeName(name, NativeNameKind.EnumValue), out symbol);
Exemple #7
0
 /// <summary>
 /// Try and find any global symbol with the specified name.
 /// </summary>
 public static bool TryGetType(this INativeSymbolLookup lookup, string name, out NativeType nt)
 {
     return(lookup.TryGetGlobalSymbol(name, out nt));
 }
Exemple #8
0
        public static bool Contains(this INativeSymbolLookup lookup, string name)
        {
            NativeGlobalSymbol symbol;

            return(lookup.TryGetGlobalSymbol(name, out symbol));
        }