The enum descriptor.
예제 #1
0
        /// <summary>
        /// The message descriptor proto.
        /// </summary>
        /// <param name="totalLength">
        /// The total length.
        /// </param>
        /// <param name="md">
        /// The message descriptor.
        /// </param>
        private void DescriptorProto(uint totalLength, MessageDescriptor md)
        {
            intend++;

            while (totalLength != 0)
            {
                int type, no;
                var l = GetTypeAndFieldNo(out type, out no);
                ix += l;
                totalLength -= (uint)l;

                switch (no)
                {
                    case 1: // string name
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            md.Name = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Name = {3}", type, no, length, md.Name));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 2: // FieldDescriptorProto[] field
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FieldDescriptorProto field", type, no, length));
                            var fd = new FieldDescriptor();
                            md.Fields.Add(fd);
                            FieldDescriptorProto(length, fd);
                            totalLength -= length;
                            break;
                        }

                    case 3: // DescriptorProto[] nested_type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - DescriptorProto", type, no, length));
                            var msg = new MessageDescriptor();
                            md.NestedTypes.Add(msg);
                            DescriptorProto(length, msg);
                            totalLength -= length;
                            break;
                        }

                    case 4: // EnumDescriptorProto[] enum_type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - EnumDescriptorProto", type, no, length));
                            var ed = new EnumDescriptor();
                            md.EnumTypes.Add(ed);
                            EnumDescriptorProto(length, ed);
                            totalLength -= length;
                            break;
                        }

                    case 5: // ExtensionRange[] extension_range
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - ExtensionRange", type, no, length));
                            var er = new MessageDescriptor.ExtensionRange();
                            md.ExtensionRanges.Add(er);
                            ExtensionRange(length, er);
                            totalLength -= length;
                            break;
                        }

                    case 6: // FieldDescriptorProto[] extension
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FieldDescriptorProto extension", type, no, length));
                            var fd = new FieldDescriptor();
                            md.Fields.Add(fd);
                            FieldDescriptorProto(length, fd);
                            totalLength -= length;
                            break;
                        }

                    case 7: // MessageOptions options
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - MessageOptions", type, no, length));
                            if (md.Options == null)
                            {
                                md.Options = new MessageOptions();
                            }

                            MessageOptions(length, md.Options);
                            totalLength -= length;
                            break;
                        }

                    case 8: // OneofDescriptorProto[] oneof_decl
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - OneofDescriptorProto", type, no, length));
                            var od = new OneofDescriptor();
                            md.OneofDecl.Add(od);
                            OneofDescriptorProto(length, od);
                            totalLength -= length;
                            break;
                        }
                }
            }

            intend--;
        }
예제 #2
0
        /// <summary>
        /// The file descriptor proto.
        /// </summary>
        /// <param name="totalLength">
        /// The total length.
        /// </param>
        /// <param name="fd">
        /// The file descriptor.
        /// </param>
        // ReSharper disable once FunctionComplexityOverflow
        private void FileDescriptorProto(uint totalLength, FileDescriptor fd)
        {
            intend++;

            while (totalLength != 0)
            {
                int type, no;
                var l = GetTypeAndFieldNo(out type, out no);
                ix += l;
                totalLength -= (uint)l;

                switch (no)
                {
                    case 1: // string name
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Name = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Name = {3}", type, no, length, fd.Name));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 2: // string package
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Package = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Package = {3}", type, no, length, fd.Package));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 3: // string[] dependecy
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            var value = GetString(length);
                            fd.Dependencies.Add(value);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Dependency = {3}", type, no, length, value));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 4: // DescriptorProto[] message type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - DescriptorProto", type, no, length));
                            var md = new MessageDescriptor();
                            fd.MessageTypes.Add(md);
                            DescriptorProto(length, md);
                            totalLength -= length;
                            break;
                        }

                    case 5: // EnumDescriptorProto[] enum type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - EnumDescriptorProto", type, no, length));
                            var ed = new EnumDescriptor();
                            fd.EnumTypes.Add(ed);
                            EnumDescriptorProto(length, ed);
                            totalLength -= length;
                            break;
                        }

                    case 6: // ServiceDescriptorProto[] service
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - ServiceDescriptorProto", type, no, length));
                            var sd = new ServiceDescriptor();
                            fd.Services.Add(sd);
                            ServiceDescriptorProto(length, sd);
                            totalLength -= length;
                            break;
                        }

                    case 7: // FieldDescriptorProto[] extension
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FieldDescriptorProto", type, no, length));
                            var fd2 = new FieldDescriptor();
                            fd.Extensions.Add(fd2);
                            FieldDescriptorProto(length, fd2);
                            totalLength -= length;
                            break;
                        }

                    case 8: // FileOptions options
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FileOptions", type, no, length));
                            if (fd.Options == null)
                            {
                                fd.Options = new FileOptions();
                            }

                            FileOptions(length, fd.Options);
                            totalLength -= length;
                            break;
                        }

                    case 9: // SourceCodeInfo source_code_info
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - SourceCodeInfo", type, no, length));
                            fd.SourceCodeInfo = new SourceCodeInfo();
                            ////SourceCodeInfo(length, fd.SourceCodeInfo);
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 10: // int32[] public_dependency
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.PublicDependencies.Add((int)value);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, public_dependency = {3}", type, no, ixl, value));
                            break;
                        }

                    case 11: // int32[] weak_dependency
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.WeakDependencies.Add((int)value);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, weak_dependency = {3}", type, no, ixl, value));
                            break;
                        }
                }
            }

            intend--;
        }
예제 #3
0
        /// <summary>
        /// The enum descriptor proto.
        /// </summary>
        /// <param name="totalLength">
        /// The total length.
        /// </param>
        /// <param name="ed">
        /// The enum descriptor.
        /// </param>
        private void EnumDescriptorProto(uint totalLength, EnumDescriptor ed)
        {
            intend++;

            while (totalLength != 0)
            {
                int type, no;
                var l = GetTypeAndFieldNo(out type, out no);
                ix += l;
                totalLength -= (uint)l;

                switch (no)
                {
                    case 1: // string name
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            ed.Name = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Name = {3}", type, no, length, ed.Name));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 2: // EnumValueDescriptorProto value
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - EnumValueDescriptorProto", type, no, length));
                            var evd = new EnumValueDescriptor();
                            ed.Values.Add(evd);
                            EnumValueDescriptorProto(length, evd);
                            totalLength -= length;
                            break;
                        }

                    case 3: // EnumOptions options
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - EnumOptions", type, no, length));
                            if (ed.Options == null)
                            {
                                ed.Options = new EnumOptions();
                            }

                            EnumOptions(length, ed.Options);
                            totalLength -= length;
                            break;
                        }
                }
            }

            intend--;
        }