From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,e5dc20115bb61aec,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!h21g2000yqa.googlegroups.com!not-for-mail From: xorque Newsgroups: comp.lang.ada Subject: Generalized serialization for enumeration types Date: Wed, 26 Aug 2009 03:22:08 -0700 (PDT) Organization: http://groups.google.com Message-ID: <249a69e5-8e21-4968-a183-64732618660a@h21g2000yqa.googlegroups.com> NNTP-Posting-Host: 62.249.247.223 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1251282128 10127 127.0.0.1 (26 Aug 2009 10:22:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 26 Aug 2009 10:22:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h21g2000yqa.googlegroups.com; posting-host=62.249.247.223; posting-account=D9GNUgoAAAAmg7CCIh9FhKHNAJmHypsp User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.0.13) Gecko/2009081019 Firefox/3.0.13,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7984 Date: 2009-08-26T03:22:08-07:00 List-Id: Hello. I'm designing a package that uses a lot of similar but distinct enumeration types. At some point, those types need to be encoded to be sent over the wire. The encoding rules are simple: The enumeration values are converted to unsigned 32 bit integers with the first value as 0 and increasing sequentially with each new value. The 32 bit value is packed into big-endian byte order. The problem is: With so many enumeration types, I now have about 300 lines of almost identical procedures (to be used as stream attributes) that just call a procedure that packs Unsigned_32 values into Storage_Element arrays. Is there some clever way I can just write ONE 'Write attribute procedure and ONE 'Read attribute procedure and have all the defined enumeration types use those? Freezing rules prevented me from writing a generic Packed_Enumeration_IO package ("representation item appears too late").