Example #1
0
        private void AddReflectedUnboundMethod(MethodInfo mi)
        {
            if (!mi.IsStatic)
            {
                return;
            }

            string   name;
            NameType nt = NameConverter.TryGetName(this, mi, out name);

            if (nt == NameType.None)
            {
                return;
            }

            FunctionType funcType = FunctionType.Method;

            if (mi.DeclaringType == typeof(ArrayOps))
            {
                funcType |= FunctionType.SkipThisCheck;
            }
            if (nt == NameType.PythonMethod)
            {
                funcType |= FunctionType.PythonVisible;
            }

            RemoveNonOps(SymbolTable.StringToId(name));

            // store Python version
            StoreMethod <ReflectedUnboundMethod>(name, mi, funcType | FunctionType.OpsFunction);

            // store CLR version, if different and we don't have a clash (if we do
            // have a clash our version is still available under the python name)
            if (name != mi.Name && !ContainsNonOps(SymbolTable.StringToId(mi.Name)))
            {
                StoreMethod <ReflectedUnboundMethod>(mi.Name, mi, FunctionType.Method | FunctionType.OpsFunction);
            }
        }