示例#1
0
        protected virtual void SearchOverridableFunctions(DefClass type)
        {
            foreach (DefFunction func in type.Functions)
            {
                if (func.IsDeclarableFunction && func.IsVirtual)
                {
                    if (!ContainsFunction(func, _overridableFunctions))
                    {
                        _overridableFunctions.Add(func);

                        if (!func.IsAbstract)
                        {
                            _methodIndices.Add(func, _methodIndicesCount);
                            _methodIndicesCount++;
                        }
                    }
                }
            }

            foreach (DefClass iface in type.GetInterfaces())
            {
                SearchOverridableFunctions(iface);
            }

            if (type.BaseClass != null)
            {
                SearchOverridableFunctions(type.BaseClass);
            }
        }
示例#2
0
        public ClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
        {
            this._wrapper = wrapper;
            this._t       = t;
            this._sb      = sb;

            foreach (DefClass iface in _t.GetInterfaces())
            {
                AddTypeDependancy(iface);
                _interfaces.Add(iface);
            }

            if (_t.IsInterface)
            {
                // Declaring an overridable class for interface
                _interfaces.Add(_t);
            }
        }
示例#3
0
        public ClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
        {
            this._wrapper = wrapper;
            this._t = t;
            this._sb = sb;

            foreach (DefClass iface in _t.GetInterfaces())
            {
                AddTypeDependancy(iface);
                _interfaces.Add(iface);
            }

            if (_t.IsInterface)
            {
                // Declaring an overridable class for interface
                _interfaces.Add(_t);
            }
        }
示例#4
0
        protected virtual void Init()
        {
            if (_initCalled)
            {
                return;
            }

            _initCalled = true;

            foreach (DefFunction f in _t.PublicMethods)
            {
                if (f.IsListenerAdder && !f.IsIgnored)
                {
                    _listeners.Add((DefClass)f.Parameters[0].Type);
                }
            }

            foreach (DefClass iface in _t.GetInterfaces())
            {
                // Add attributes of interface methods from the interface classes
                foreach (DefFunction f in iface.Functions)
                {
                    DefFunction tf = _t.GetFunctionWithSignature(f.Signature);
                    if (tf != null)
                    {
                        tf.Attributes.AddRange(f.Attributes);
                    }
                }

                //Store properties of interface classes. They have precedence over type's properties.
                foreach (DefProperty ip in iface.GetProperties())
                {
                    if (AllowProperty(ip) &&
                        (ip.Function.ProtectionType == ProtectionType.Public ||
                         (AllowProtectedMembers && ip.Function.ProtectionType == ProtectionType.Protected)))
                    {
                        _interfaceProperties.Add(ip);
                    }
                }
            }

            foreach (DefField field in _t.Fields)
            {
                if (!field.IsIgnored && field.Type.IsSTLContainer)
                {
                    if (field.ProtectionType == ProtectionType.Public ||
                        ((AllowSubclassing || AllowProtectedMembers) && field.ProtectionType == ProtectionType.Protected))
                    {
                        MarkCachedMember(field);
                    }
                }
            }

            foreach (DefClass iface in _interfaces)
            {
                if (iface == _t)
                {
                    continue;
                }

                foreach (DefField field in iface.Fields)
                {
                    if (!field.IsIgnored && field.Type.IsSTLContainer &&
                        !field.IsStatic)
                    {
                        if (field.ProtectionType == ProtectionType.Public ||
                            ((AllowSubclassing || AllowProtectedMembers) && field.ProtectionType == ProtectionType.Protected))
                        {
                            MarkCachedMember(field);
                        }
                    }
                }
            }

            foreach (DefFunction func in _t.AbstractFunctions)
            {
                if (func.ProtectionType == ProtectionType.Public ||
                    (AllowProtectedMembers && func.ProtectionType == ProtectionType.Protected))
                {
                    if ((func.Class.IsBaseForSubclassing || (func.Class == _t && AllowSubclassing)) && !func.IsProperty)
                    {
                        _isAbstractClass = true;
                        _abstractFunctions.Add(func);
                    }
                }
            }

            foreach (DefProperty prop in _t.AbstractProperties)
            {
                if (AllowProperty(prop) && (prop.Function.Class.IsBaseForSubclassing || (prop.Function.Class == _t && AllowSubclassing)))
                {
                    if (prop.Function.ProtectionType == ProtectionType.Public ||
                        (AllowProtectedMembers && prop.Function.ProtectionType == ProtectionType.Protected))
                    {
                        _isAbstractClass = true;
                        _abstractProperties.Add(prop);
                    }
                }
            }

            SearchOverridableFunctions(_t);
            //SearchProtectedFields(_t);

            foreach (DefClass iface in _interfaces)
            {
                SearchOverridableFunctions(iface);
                //SearchProtectedFields(iface);
            }

            _overridableProperties = GetPropertiesFromFunctions(_overridableFunctions);

            //Find cached members

            foreach (DefMember m in _t.Members)
            {
                if (m.HasAttribute <CachedAttribute>())
                {
                    MarkCachedMember(m);
                }
            }

            foreach (DefClass iface in _interfaces)
            {
                if (iface == _t)
                {
                    continue;
                }

                foreach (DefMember m in iface.Members)
                {
                    if (m.HasAttribute <CachedAttribute>())
                    {
                        MarkCachedMember(m);
                    }
                }
            }
        }
示例#5
0
        protected virtual void SearchOverridableFunctions(DefClass type)
        {
            foreach (DefFunction func in type.Functions)
            {
                if (func.IsDeclarableFunction && func.IsVirtual)
                {
                    if (!ContainsFunction(func, _overridableFunctions))
                    {
                        _overridableFunctions.Add(func);

                        if (!func.IsAbstract)
                        {
                            _methodIndices.Add(func, _methodIndicesCount);
                            _methodIndicesCount++;
                        }
                    }
                }
            }

            foreach (DefClass iface in type.GetInterfaces())
                SearchOverridableFunctions(iface);

            if (type.BaseClass != null)
                SearchOverridableFunctions(type.BaseClass);
        }