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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e1e2bc096a996632 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 15 Dec 2004 07:39:40 -0600 From: David Botton Newsgroups: comp.lang.ada Date: Wed, 15 Dec 2004 08:39:41 -0500 Message-ID: <2004121508394116807%david@bottoncom> References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: why can't we declare unconstrained objects ? User-Agent: Unison/1.5.2 NNTP-Posting-Host: 66.176.74.83 X-Trace: sv3-iBIansJwgQLevz7Becjw1Y17LZIWt1UEMwaBM0bDKNLxpu9xNNHDpYsK37CVq8K6Jv7j+PO7lzduyAO!je+/vtZCEMvwpyjNjKSnJKbAokPWPhUohWz/LYbNcrj9lDLbcH40rBIFSj0nbA== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.20 Xref: g2news1.google.com comp.lang.ada:6962 Date: 2004-12-15T08:39:41-05:00 List-Id: Here is an example from GNATCOM (http://www.gnavi.org) of a C/C++ style union subtype Variant_Range is Positive range 1 .. 41; -- NOTE: The Which values are completely bogus and have no significance -- The type of the variant can not be determined using it -- The values bellow do NOT correspond to correct variant type -- constants! type Variant_Union (Which : Variant_Range := 1) is record case Which is when 1 => lVal : Interfaces.C.long; when 2 => bVal : Interfaces.C.unsigned_char; when 3 => iVal : Interfaces.C.short; when 4 => fltVal : Interfaces.C.C_float; when 5 => dblVal : Interfaces.C.double; when 6 => boolVal : VARIANT_BOOL; when 7 => bool : VARIANT_BOOL; when 8 => scode : Types.SCODE; when 9 => cyVal : CURRENCY; when 10 => date : Types.DATE; when 11 => bstrVal : BSTR; when 12 => punkVal : Pointer_To_IUnknown; when 13 => pdispVal : Pointer_To_IDispatch; when 14 => parray : Pointer_To_SAFEARRAY; when 15 => pbVal : Pointer_To_BYTE; when 16 => piVal : Pointer_To_short; when 17 => plVal : Pointer_To_long; when 18 => pfltVal : Pointer_To_C_float; when 19 => pdblVal : Pointer_To_double; when 20 => pboolVal : Pointer_To_VARIANT_BOOL; when 21 => pbool : Pointer_To_VARIANT_BOOL; when 22 => pscode : Pointer_To_SCODE; when 23 => pcyVal : Pointer_To_CURRENCY; when 24 => pdate : Pointer_To_DATE; when 25 => pbstrVal : Pointer_To_BSTR; when 26 => ppunkVal : Pointer_To_Pointer_To_IUnknown; when 27 => ppdispVal : Pointer_To_Pointer_To_IDispatch; when 28 => pparray : Pointer_To_Pointer_To_SAFEARRAY; when 29 => pvarVal : Pointer_To_VARIANT; when 30 => byref : Pointer_To_Void; when 31 => cVal : Interfaces.C.char; when 32 => uiVal : Interfaces.C.unsigned_short; when 33 => ulVal : Interfaces.C.unsigned_long; when 34 => intVal : Interfaces.C.int; when 35 => uintVal : Interfaces.C.unsigned; when 36 => pdecVal : Pointer_To_DECIMAL; when 37 => pcVal : Pointer_To_char; when 38 => puiVal : Pointer_To_unsigned_short; when 39 => pulVal : Pointer_To_unsigned_long; when 40 => pintVal : Pointer_To_int; when 41 => puintVal : Pointer_To_unsigned; end case; end record; pragma Convention (C_Pass_By_Copy, Variant_Union); pragma Unchecked_Union (Variant_Union); Size_Of_VARIANT : constant := 128; type VARIANT is record vt : VARTYPE; wReserved1 : Interfaces.C.unsigned_short; wReserved2 : Interfaces.C.unsigned_short; wReserved3 : Interfaces.C.unsigned_short; u : Variant_Union; end record; for VARIANT'Size use Size_Of_VARIANT; pragma Convention (C_Pass_By_Copy, VARIANT); -- The automation type VARIANT is used to create a variable that -- can contain any of the OLEAUTOMATION types. The value of vt -- indicates the type currently held in the type union in u -- Variants should be manipulated using the Variant APIs or with -- GNATCOM.Variant type Pointer_To_VARIANT_Constant is access constant VARIANT;