public static string GetProxyName(DefClass type)
        {
            string name = type.FullNativeName;

            name = name.Substring(name.IndexOf("::") + 2);
            return(name.Replace("::", "_") + "_Proxy");
        }
        protected void AddToCorrectSubclassMethod()
        {
            _sb.AppendLine(_t.CLRName + "^ " + _t.CLRName + "::_ToCorrectSubclass(" + _t.FullNativeName + "* t)");
            _sb.AppendLine("{");
            _sb.IncreaseIndent();
            _sb.AppendLine(_t.FullNativeName + "* subptr;");

            if (_t.Derives != null)
            {
                foreach (string substr in _t.Derives)
                {
                    DefClass sub = _t.FindType <DefClass>(substr, false);
                    if (sub != null && _wrapper.TypeIsWrappable(sub))
                    {
                        _wrapper.AddTypeDependancy(sub);
                        _sb.AppendLine("subptr = dynamic_cast<" + sub.FullNativeName + "*>(t);");
                        _sb.AppendLine("if (subptr)");
                        if (sub.HasAttribute <ConvertToCorrectSubclassAttribute>())
                        {
                            _sb.AppendLine("\treturn " + sub.CLRName + "::_ToCorrectSubclass(t);");
                        }
                        else
                        {
                            _sb.AppendLine("\treturn gcnew " + sub.CLRName + "(subptr);");
                        }
                        _sb.AppendLine();
                    }
                }
            }

            _sb.AppendLine("return gcnew " + _t.CLRName + "(t);");
            _sb.DecreaseIndent();
            _sb.AppendLine("}");
        }
Beispiel #3
0
        protected void AddEventInvokerForListener(DefClass cls)
        {
            foreach (DefFunction f in cls.PublicMethods)
            {
                if (f.IsDeclarableFunction)
                {
                    _sb.AppendIndent("virtual " + GetCLRTypeName(f) + " On" + f.CLRName);
                    AddMethodParameters(f);
                    _sb.Append(" = " + GetNativeDirectorReceiverInterfaceName(cls) + "::" + f.CLRName + "\n");
                    _sb.AppendLine("{");
                    _sb.AppendIndent("\t");
                    if (f.TypeName != "void")
                    {
                        _sb.Append("return ");
                    }
                    _sb.Append(f.CLRName + "(");
                    for (int i = 0; i < f.Parameters.Count; i++)
                    {
                        DefParam param = f.Parameters[i];
                        _sb.Append(" " + param.Name);
                        if (i < f.Parameters.Count - 1)
                        {
                            _sb.Append(",");
                        }
                    }
                    _sb.Append(" );\n");
                    _sb.AppendLine("}\n");
                }
            }

            _sb.AppendLine("");
        }
Beispiel #4
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);
            }
        }
        public static void AddMethodHandlersClass(DefClass type, IndentStringBuilder sb)
        {
            if (!type.HasWrapType(WrapTypes.NativeDirector))
                throw new Exception("Unexpected");

            if (type.IsNested)
                sb.AppendIndent("public: ");
            else
                sb.AppendIndent("public ");

            sb.Append("ref class " + type.Name + " abstract sealed\n");
            sb.AppendLine("{");
            sb.AppendLine("public:");
            sb.IncreaseIndent();

            foreach (DefFunction f in type.PublicMethods)
            {
                if (f.IsDeclarableFunction && f.IsVirtual)
                {
                    sb.AppendIndent("delegate static " + f.CLRTypeName + " " + f.CLRName + "Handler(");
                    for (int i = 0; i < f.Parameters.Count; i++)
                    {
                        DefParam param = f.Parameters[i];
                        sb.Append(" " + param.Type.GetCLRParamTypeName(param) + " " + param.Name);
                        if (i < f.Parameters.Count - 1) sb.Append(",");
                    }
                    sb.Append(" );\n");
                }
            }

            sb.DecreaseIndent();
            sb.AppendLine("};");
            sb.AppendLine();
        }
 public CppClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
     //if (AllowSubclassing)
     //{
     //    _wrapper.PreClassProducers.Add(new CppNativeProtectedTypesProxy(_wrapper, _t, _sb));
     //}
 }
Beispiel #7
0
 public CppClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
     //if (AllowSubclassing)
     //{
     //    _wrapper.PreClassProducers.Add(new CppNativeProtectedTypesProxy(_wrapper, _t, _sb));
     //}
 }
Beispiel #8
0
        protected virtual string GetNativeDirectorName(DefClass type)
        {
            if (!type.HasWrapType(WrapTypes.NativeDirector))
            {
                throw new Exception("Unexpected");
            }

            string name = (type.IsNested) ? type.ParentClass.Name + "_" + type.Name : type.Name;

            return(name + "_Director");
        }
Beispiel #9
0
 protected DefClass GetTopClass(DefClass type)
 {
     if (type.BaseClass == null)
     {
         return(type);
     }
     else
     {
         return(GetTopClass(type.BaseClass));
     }
 }
Beispiel #10
0
        public override void ProcessHolder(AttributeHolder holder)
        {
            DefClass type = (DefClass)holder;

            foreach (string[] names in _interfaceNames)
            {
                List <DefClass> ifaces = new List <DefClass>();
                foreach (string ifacename in names)
                {
                    ifaces.Add(type.FindType <DefClass>(ifacename));
                }
                Interfaces.Add(ifaces.ToArray());
            }
        }
Beispiel #11
0
        public IncClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
            : base(wrapper, t, sb)
        {
            AddPreDeclarations();

            if (_t.BaseClass != null)
                AddTypeDependancy(_t.BaseClass);

            if (AllowSubclassing)
            {
                _wrapper.PreClassProducers.Add(new NativeProtectedTypesProxy(_wrapper, _t, _sb));
                _wrapper.PostClassProducers.Add(new NativeProtectedStaticsProxy(_wrapper, _t, _sb));
                //_wrapper.PreClassProducers.Add(new IncNativeProtectedTypesProxy(_wrapper, _t, _sb));
            }
        }
Beispiel #12
0
        public static void AddMethodHandlersClass(DefClass type, IndentStringBuilder sb)
        {
            if (!type.HasWrapType(WrapTypes.NativeDirector))
            {
                throw new Exception("Unexpected");
            }

            if (type.IsNested)
            {
                sb.AppendIndent("public: ");
            }
            else
            {
                sb.AppendIndent("public ");
            }

            sb.Append("ref class " + type.Name + " abstract sealed\n");
            sb.AppendLine("{");
            sb.AppendLine("public:");
            sb.IncreaseIndent();

            foreach (DefFunction f in type.PublicMethods)
            {
                if (f.IsDeclarableFunction && f.IsVirtual)
                {
                    //if (f.Parameters.Count > 0)
                    //{
                    //    AddEventArgsClass(f, sb);
                    //}

                    sb.AppendIndent("delegate static " + f.CLRTypeName + " " + f.CLRName + "Handler(");
                    for (int i = 0; i < f.Parameters.Count; i++)
                    {
                        DefParam param = f.Parameters[i];
                        sb.Append(" " + param.Type.GetCLRParamTypeName(param) + " " + param.Name);
                        if (i < f.Parameters.Count - 1)
                        {
                            sb.Append(",");
                        }
                    }
                    sb.Append(" );\n");
                }
            }

            sb.DecreaseIndent();
            sb.AppendLine("};");
            sb.AppendLine();
        }
Beispiel #13
0
        public IncClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
            : base(wrapper, t, sb)
        {
            AddPreDeclarations();

            if (_t.BaseClass != null)
            {
                AddTypeDependancy(_t.BaseClass);
            }

            if (AllowSubclassing)
            {
                _wrapper.PreClassProducers.Add(new NativeProtectedTypesProxy(_wrapper, _t, _sb));
                _wrapper.PostClassProducers.Add(new NativeProtectedStaticsProxy(_wrapper, _t, _sb));
                //_wrapper.PreClassProducers.Add(new IncNativeProtectedTypesProxy(_wrapper, _t, _sb));
            }
        }
Beispiel #14
0
        protected void AddAttributeToInheritanceChain(DefClass type, AutoWrapAttribute attr)
        {
            bool hasit = false;
            foreach (AutoWrapAttribute a in type.Attributes)
            {
                if (a.GetType() == attr.GetType())
                {
                    hasit = true;
                    break;
                }
            }

            if (!hasit)
                type.Attributes.Add(attr);

            if (type.BaseClass != null)
                AddAttributeToInheritanceChain(type.BaseClass, attr);
        }
        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);
            }
        }
Beispiel #16
0
        public override void ProcessHolder(AttributeHolder holder)
        {
            switch (WrapType)
            {
            case WrapTypes.NativePtrValueType:
            case WrapTypes.ValueType:
                if (!holder.HasAttribute <ValueTypeAttribute>())
                {
                    holder.Attributes.Add(new ValueTypeAttribute());
                }
                break;

            case WrapTypes.Overridable:
                DefClass type = (DefClass)holder;
                AddAttributeToInheritanceChain(type, new BaseForSubclassingAttribute());
                break;
            }
        }
Beispiel #17
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);
            }
        }
Beispiel #18
0
        protected void AddEventForListener(DefClass cls)
        {
            _sb.AppendLine(GetNativeDirectorName(cls) + "* " + NameToPrivate(cls.Name) + ";");
            foreach (DefFunction f in cls.PublicMethods)
            {
                if (f.IsDeclarableFunction)
                {
                    _sb.AppendLine(cls.FullCLRName + "::" + f.CLRName + "Handler^ " + NameToPrivate(f.Name) + ";");
                }
                else
                {
                    continue;
                }

                if (cls.HasAttribute <StopDelegationForReturnAttribute>())
                {
                    _sb.AppendLine("array<Delegate^>^ " + NameToPrivate(f.Name) + "Delegates;");
                }
            }

            _sb.AppendLine("");
        }
        protected virtual void AddFriends(string className, DefClass type)
        {
            foreach (DefField field in type.ProtectedFields)
            {
                if (!field.IsIgnored
                    && !(field.IsStatic && type != _t) )
                {
                    _sb.AppendLine("friend ref class " + className + "::" + field.Name + ";");
                }
            }

            foreach (DefFunction func in type.Functions)
            {
                if (func.IsDeclarableFunction
                    && func.ProtectionType == ProtectionType.Protected
                    && !(func.IsStatic && type != _t)
                    && func.IsProperty
                    && !func.IsVirtual)
                {
                    _sb.AppendLine("friend ref class " + className + "::" + func.CLRName + ";");
                }
            }
        }
        protected virtual void AddFriends(string className, DefClass type)
        {
            foreach (DefField field in type.ProtectedFields)
            {
                if (!field.IsIgnored &&
                    !(field.IsStatic && type != _t))
                {
                    _sb.AppendLine("friend ref class " + className + "::" + field.Name + ";");
                }
            }

            foreach (DefFunction func in type.Functions)
            {
                if (func.IsDeclarableFunction &&
                    func.ProtectionType == ProtectionType.Protected &&
                    !(func.IsStatic && type != _t) &&
                    func.IsProperty &&
                    !func.IsVirtual)
                {
                    _sb.AppendLine("friend ref class " + className + "::" + func.CLRName + ";");
                }
            }
        }
Beispiel #21
0
        protected void AddAttributeToInheritanceChain(DefClass type, AutoWrapAttribute attr)
        {
            bool hasit = false;

            foreach (AutoWrapAttribute a in type.Attributes)
            {
                if (a.GetType() == attr.GetType())
                {
                    hasit = true;
                    break;
                }
            }

            if (!hasit)
            {
                type.Attributes.Add(attr);
            }

            if (type.BaseClass != null)
            {
                AddAttributeToInheritanceChain(type.BaseClass, attr);
            }
        }
        protected override void AddInternalConstructors()
        {
            base.AddInternalConstructors();

            if (_t.BaseClass == null)
            {
                _sb.AppendFormatIndent("{0}( " + _t.FullNativeName + "* obj ) : _native(obj), _createdByCLR(false)\n", _t.CLRName);
            }
            else
            {
                DefClass topclass = GetTopClass(_t);
                _sb.AppendFormatIndent("{0}( " + topclass.FullNativeName + "* obj ) : " + topclass.CLRName + "(obj)\n", _t.CLRName);
            }
            _sb.AppendLine("{");
            _sb.IncreaseIndent();

            //NOTE: SuppressFinalize should not be called when the class is 'wrapped' by a SharedPtr class, (i.e DataStreamPtr -> DataStream)
            //so that the SharedPtr class gets a chance to clean up. Look for a way to have SuppressFinalize without this kind of problems.
            //_sb.AppendLine("System::GC::SuppressFinalize(this);");

            base.AddConstructorBody();
            _sb.DecreaseIndent();
            _sb.AppendLine("}\n");
        }
        protected virtual bool HasProtectedStatics(DefClass type)
        {
            foreach (DefField field in type.ProtectedFields)
            {
                if (!field.IsIgnored &&
                    !(field.IsStatic && type != _t))
                {
                    return(true);
                }
            }

            foreach (DefFunction func in type.Functions)
            {
                if (func.IsDeclarableFunction &&
                    func.ProtectionType == ProtectionType.Protected &&
                    !(func.IsStatic && type != _t) &&
                    !func.IsVirtual)
                {
                    return(true);
                }
            }

            return(false);
        }
 public IncReadOnlyStructClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public CppOverridableClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
     _wrapper.PostClassProducers.Add(new CppNativeProxyClassProducer(_wrapper, _t, _sb));
 }
 public CppSubclassingClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb, DefClass[] additionalInterfaces)
     : base(wrapper, t, sb)
 {
     this._additionalInterfaces = additionalInterfaces;
 }
Beispiel #27
0
 public IncNonOverridableClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public static string GetProxyName(DefClass type)
 {
     string name = type.FullNativeName;
     name = name.Substring(name.IndexOf("::") + 2);
     return name.Replace("::", "_") + "_Proxy";
 }
 public IncPlainWrapperClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
        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);
        }
 public IncNonOverridableClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public IncNativePtrValueClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
Beispiel #33
0
        public string CreateIncludeCodeForOverridable(DefClass type)
        {
            UsedTypes.Clear();

            PreClassProducers.Clear();
            PostClassProducers.Clear();

            IndentStringBuilder sbTypes = new IndentStringBuilder();

            new IncSubclassingClassProducer(this, type, sbTypes, null).Add();
            if (type.HasAttribute<InterfacesForOverridableAttribute>())
            {
                List<DefClass[]> interfaces = type.GetAttribute<InterfacesForOverridableAttribute>().Interfaces;
                foreach (DefClass[] ifaces in interfaces)
                {
                    new IncSubclassingClassProducer(this, type, sbTypes, ifaces).Add();
                }
            }

            foreach (ClassProducer producer in PostClassProducers)
            {
                if (!(producer is NativeProtectedTypesProxy)
                    && !(producer is NativeProtectedStaticsProxy))
                    producer.Add();
            }

            foreach (ClassProducer producer in PreClassProducers)
            {
                if (!(producer is NativeProtectedTypesProxy)
                    && !(producer is NativeProtectedStaticsProxy))
                    producer.AddFirst();
            }

            IndentStringBuilder sb = new IndentStringBuilder();
            sb.AppendLine("#pragma once\n");

            sb.AppendFormat("namespace {0}\n{{\n", ManagedNamespace);

            sb.IncreaseIndent();
            sb.AppendLine(sbTypes.ToString());
            sb.DecreaseIndent();

            sb.AppendLine("}");

            return sb.ToString().Replace("\r", "");
        }
 public IncNativePtrValueClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public IncSingletonClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public IncCLRHandleClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
Beispiel #37
0
        protected void AddEventMethodForListener(DefClass cls, DefFunction listenerSetFunc)
        {
            if (listenerSetFunc == null)
            {
                throw new Exception("Unexpected");
            }

            foreach (DefFunction f in cls.PublicMethods)
            {
                if (f.IsDeclarableFunction)
                {
                    string handler   = cls.FullCLRName + "::" + f.CLRName + "Handler^";
                    string privField = NameToPrivate(f.Name);
                    string listener  = NameToPrivate(cls.Name);
                    _sb.AppendLine("event " + handler + " " + f.CLRName);
                    _sb.AppendLine("{");
                    _sb.IncreaseIndent();
                    _sb.AppendLine("void add(" + handler + " hnd)");
                    _sb.AppendLine("{");
                    _sb.IncreaseIndent();
                    _sb.AppendLine("if (" + privField + " == CLR_NULL)");
                    _sb.AppendLine("{");
                    _sb.IncreaseIndent();
                    _sb.AppendLine("if (" + listener + " == 0)");
                    _sb.AppendLine("{");
                    _sb.AppendLine("\t" + listener + " = new " + GetNativeDirectorName(cls) + "(this);");
                    _sb.AppendLine("\t" + GetNativeInvokationTarget(listenerSetFunc) + "(" + listener + ");");
                    _sb.AppendLine("}");
                    _sb.AppendLine(listener + "->doCallFor" + f.CLRName + " = true;");
                    _sb.DecreaseIndent();
                    _sb.AppendLine("}");
                    _sb.AppendLine(privField + " += hnd;");

                    if (cls.HasAttribute <StopDelegationForReturnAttribute>())
                    {
                        _sb.AppendLine(privField + "Delegates = " + privField + "->GetInvocationList();");
                    }

                    _sb.DecreaseIndent();
                    _sb.AppendLine("}");
                    _sb.AppendLine("void remove(" + handler + " hnd)");
                    _sb.AppendLine("{");
                    _sb.AppendLine("\t" + privField + " -= hnd;");
                    _sb.AppendLine("\tif (" + privField + " == CLR_NULL) " + listener + "->doCallFor" + f.CLRName + " = false;");

                    if (cls.HasAttribute <StopDelegationForReturnAttribute>())
                    {
                        _sb.AppendLine("\tif (" + privField + " == CLR_NULL) " + privField + "Delegates = nullptr; else " + privField + "Delegates = " + privField + "->GetInvocationList();");
                    }

                    _sb.AppendLine("}");
                    _sb.DecreaseIndent();
                    _sb.AppendLine("private:");
                    _sb.IncreaseIndent();
                    _sb.AppendIndent(GetCLRTypeName(f) + " raise");
                    AddMethodParameters(f);
                    _sb.Append("\n");
                    _sb.AppendLine("{");

                    if (cls.HasAttribute <StopDelegationForReturnAttribute>())
                    {
                        _sb.IncreaseIndent();
                        _sb.AppendLine("if (" + privField + ")");
                        _sb.AppendLine("{");
                        _sb.IncreaseIndent();
                        string list    = privField + "Delegates";
                        string stopret = cls.GetAttribute <StopDelegationForReturnAttribute>().Return;
                        _sb.AppendLine(f.Type.FullCLRName + " mp_return;");
                        _sb.AppendLine("for (int i=0; i < " + list + "->Length; i++)");
                        _sb.AppendLine("{");
                        _sb.IncreaseIndent();
                        _sb.AppendIndent("mp_return = " + "static_cast<" + handler + ">(" + list + "[i])(");
                        for (int i = 0; i < f.Parameters.Count; i++)
                        {
                            DefParam param = f.Parameters[i];
                            _sb.Append(" " + param.Name);
                            if (i < f.Parameters.Count - 1)
                            {
                                _sb.Append(",");
                            }
                        }
                        _sb.Append(" );\n");
                        _sb.AppendLine("if (mp_return == " + stopret + ") break;");
                        _sb.DecreaseIndent();
                        _sb.AppendLine("}");
                        _sb.AppendLine("return mp_return;");
                        _sb.DecreaseIndent();
                        _sb.AppendLine("}");
                        _sb.DecreaseIndent();
                    }
                    else
                    {
                        _sb.AppendLine("\tif (" + privField + ")");
                        _sb.AppendIndent("\t\t");
                        if (f.TypeName != "void")
                        {
                            _sb.Append("return ");
                        }
                        _sb.Append(privField + "->Invoke(");
                        for (int i = 0; i < f.Parameters.Count; i++)
                        {
                            DefParam param = f.Parameters[i];
                            _sb.Append(" " + param.Name);
                            if (i < f.Parameters.Count - 1)
                            {
                                _sb.Append(",");
                            }
                        }
                        _sb.Append(" );\n");
                    }

                    _sb.AppendLine("}");
                    _sb.DecreaseIndent();
                    _sb.AppendLine("}\n");
                }
            }
            _sb.AppendLine("");
        }
Beispiel #38
0
 public CppPlainWrapperClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public CppNativeProxyClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public CppSubclassingClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb, DefClass[] additionalInterfaces)
     : base(wrapper, t, sb)
 {
     this._additionalInterfaces = additionalInterfaces;
 }
Beispiel #41
0
 public IncCLRHandleClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
Beispiel #42
0
        protected virtual void AddInterfaceImplementation(DefClass iface)
        {
            _sb.AppendLine("//------------------------------------------------------------");
            _sb.AppendLine("// Implementation for " + iface.CLRName);
            _sb.AppendLine("//------------------------------------------------------------\n");

            foreach (DefProperty ip in iface.GetProperties())
            {
                DefFunction inf = ip.Function;

                if (inf.IsStatic)
                {
                    continue;
                }

                if (inf.ProtectionType == ProtectionType.Public ||
                    (AllowSubclassing && !inf.IsVirtual) ||
                    (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected))
                {
                    if (!_t.ContainsFunctionSignature(inf.Signature, true))
                    {
                        AddInterfaceProperty(ip);
                        _sb.Append("\n");
                    }
                }
            }

            foreach (DefFunction inf in iface.DeclarableMethods)
            {
                if (inf.IsStatic)
                {
                    continue;
                }

                if (inf.ProtectionType == ProtectionType.Public ||
                    (AllowSubclassing && !inf.IsVirtual) ||
                    (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected))
                {
                    if (!_t.ContainsFunctionSignature(inf.Signature, false))
                    {
                        AddInterfaceMethod(inf);
                        _sb.Append("\n");
                    }
                }
            }

            foreach (DefField field in iface.Fields)
            {
                if (!field.HasAttribute <IgnoreAttribute>())
                {
                    if (field.IsStatic)
                    {
                        continue;
                    }

                    if (field.ProtectionType == ProtectionType.Public ||
                        AllowSubclassing ||
                        (AllowProtectedMembers && field.ProtectionType == ProtectionType.Protected))
                    {
                        //if (CheckTypeMemberForGetProperty(field) == false)
                        //    AddInterfaceMethodsForField(field);
                        //else
                        AddInterfacePropertyField(field);

                        _sb.AppendLine();
                    }
                }
            }
        }
 //protected List<DefFunction> _protectedFunctions = new List<DefFunction>();
 public NativeProxyClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
     //SearchProtectedFunctions(_t);
 }
 public IncInterfaceClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
Beispiel #45
0
        public override void ProcessHolder(AttributeHolder holder)
        {
            DefClass type = (DefClass)holder;

            AddAttributeToInheritanceChain(type, new BaseForSubclassingAttribute());
        }
 public CppOverridableClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
     _wrapper.PostClassProducers.Add(new CppNativeProxyClassProducer(_wrapper, _t, _sb));
 }
 protected DefClass GetTopClass(DefClass type)
 {
     if (type.BaseClass == null)
         return type;
     else
         return GetTopClass(type.BaseClass);
 }
Beispiel #48
0
 public IncNativeDirectorClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
Beispiel #49
0
        protected virtual string GetNativeDirectorReceiverInterfaceName(DefClass type)
        {
            if (!type.HasWrapType(WrapTypes.NativeDirector))
                throw new Exception("Unexpected");

            string name = (type.IsNested) ? type.ParentClass.Name + "_" + type.Name : type.Name;
            return "I" + name + "_Receiver";
        }
 public CppNativeDirectorClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
        protected virtual bool HasProtectedStatics(DefClass type)
        {
            foreach (DefField field in type.ProtectedFields)
            {
                if (!field.IsIgnored
                    && !(field.IsStatic && type != _t))
                {
                    return true;
                }
            }

            foreach (DefFunction func in type.Functions)
            {
                if (func.IsDeclarableFunction
                    && func.ProtectionType == ProtectionType.Protected
                    && !(func.IsStatic && type != _t)
                    && !func.IsVirtual)
                {
                    return true;
                }
            }

            return false;
        }
 public IncReadOnlyStructClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
 public NativeProtectedTypesProxy(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }
        protected virtual void AddInterfaceImplementation(DefClass iface)
        {
            _sb.AppendLine("//------------------------------------------------------------");
            _sb.AppendLine("// Implementation for " + iface.CLRName);
            _sb.AppendLine("//------------------------------------------------------------\n");

            foreach (DefProperty ip in iface.GetProperties())
            {
                DefFunction inf = ip.Function;

                if (inf.IsStatic)
                    continue;

                if (inf.ProtectionType == ProtectionType.Public
                    || (AllowSubclassing && !inf.IsVirtual)
                    || (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected))
                {
                    if (!_t.ContainsFunctionSignature(inf.Signature, true))
                    {
                        AddInterfaceProperty(ip);
                        _sb.Append("\n");
                    }
                }
            }

            foreach (DefFunction inf in iface.DeclarableMethods)
            {
                if (inf.IsStatic)
                    continue;

                if (inf.ProtectionType == ProtectionType.Public
                    || (AllowSubclassing && !inf.IsVirtual)
                    || (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected))
                {
                    if (!_t.ContainsFunctionSignature(inf.Signature, false))
                    {
                        AddInterfaceMethod(inf);
                        _sb.Append("\n");
                    }
                }
            }

            foreach (DefField field in iface.Fields)
            {
                if (!field.HasAttribute<IgnoreAttribute>())
                {
                    if (field.IsStatic)
                        continue;

                    if (field.ProtectionType == ProtectionType.Public
                        || AllowSubclassing
                        || (AllowProtectedMembers && field.ProtectionType == ProtectionType.Protected))
                    {
                        //if (CheckTypeMemberForGetProperty(field) == false)
                        //    AddInterfaceMethodsForField(field);
                        //else
                            AddInterfacePropertyField(field);

                        _sb.AppendLine();
                    }
                }
            }
        }
 public CppSingletonClassProducer(Wrapper wrapper, DefClass t, IndentStringBuilder sb)
     : base(wrapper, t, sb)
 {
 }