comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@home.com>
Subject: Ada0x Enhancement? Was: Tags.Internal_Tag(String'Input(Stream)) ??
Date: Fri, 29 Dec 2000 05:29:28 GMT
Date: 2000-12-29T05:29:28+00:00	[thread overview]
Message-ID: <3A4C2098.5137C8D0@home.com> (raw)
In-Reply-To: RaT26.52882$A06.1566788@news1.frmt1.sfba.home.com

tmoran@acm.org wrote:
> 
> >This suggests that I have to define my own S'Class'Input()
> >instead. This would allow me to read the tag in, in any way I
> >please, but then how do I proceed from there? How does the
> >Ada S'Class'Input() dispatch once the external tag is known?
>   It calls A'Input() if the data indicated type A, or B'Input() if
> the data indicated type B, etc.

Yes... that is how I have been coding it. I was however, hoping
for a more automated way (without having to test for each possibility).
After all, Ada knows about all the classes and dispatches as
necessary with it's builtin tables etc.

>   So if you can use
>      for A'External_Tag use "RIFF";
> statements to cover all your tags, you needn't override S'Class'Input.

This was the idea, but it won't work for the reasons outlined earlier
(tag input).

If you try it, you'll soon discover that Ada insists on calling
upon String'Input() to read in the tag (which is the problem
here). String'Input() insists on reading dope info that describes
how long the tag string is (the array bounds actually). My external
tags only have 4 bytes period, with no dope information provided
in the file. Hence Ada ends up trying to read dope information,
and getting tag information instead (with bad array bounds I
might add ;-)

> If your external way of specifying a type is too complex for that,
> you will have to override S'Class'Input, and your code will have to
> know about all the possible external tags and it will have to call
> A'Input() or B'Input() or C'Input() as needed.

Yes, I have resigned to doing this, and have started coding it this
way this evening. As it turns out, some of the wave chunks
("fmt " for example) have special needs depending upon the format
of the sample data etc. The physical location of discrimants in
the file, and varying array sizes only make this problem worse.

Additionally, Microsoft's stupid Wave format often provides odd
length chunks, but they are padded to 16-bit boundaries (for the
start of the next chunk). At other times, different wave software
creates the file with odd length (to save a byte), and yet
still other software creates a even length file with the pad byte.
Additionally you have other nasties like zero terminated strings
in the chunk etc. (gag)

In short, all kinds of nasties in this format, seem to suggest that
I'll better off to control things with my very own
Chunk_Hdr'Class'Input() procedure.

>   Quite independently, if the external data organization doesn't
> happen to match what your compiler expects, say because bounds are
> stored differently, you'll have to override A'Input et al.

Yes, this works for types that _you_ derive, but you cannot override
the way String'Input() works for example. Hence you're back to the
initial problem of how do you modify tag reading behavior? (while
avoiding writing your own X'Class'Input procedure).

>   As has been pointed out, "For elementary types, the representation
> in terms of stream elements is implementation defined."  You may
> be unpleasantly surprised.

This has largely been deal with my lower level package Endian_Streams, 
from which the Wave_Streams package is derived. One of the goals of this
project is to create a Wave Player/Recorder that works for Big Endian
machines under Linux/FreeBSD as well as the Intel platform.

> The order of calls for a composite type
> is specified though, so if you write overrides for all the elementary
> types, and any composite types that differ in data layout order,
> you should be in good shape.

Well folks, thanks for your efforts. It looks like the Wave file
format is sufficiently messy that I am going to go with the
Chunk_Hdr'Class'Input override route. However, it would be educational
if someone did resolve this issue, for my future reference.

It seems to me that (flame suit on) that Ada0x might consider a
means to subsitute for the Tag input/output procedure. Perhaps
something like:


for Chunk_Hdr'Class'Tag_Input use My_Chunk_Hdr_Class_Tag_Input;


This would then give the programmer a way to change the Tag_Input 
and Tag_Output, without having to resort to roll your
own X'Class'Input procedure.  Currently String'Input is always
used to initiate the read of a tag.  This leaves the programmer
out of the loop :<

-- 
Warren W. Gay VE3WWG
http://members.home.net/ve3wwg



  reply	other threads:[~2000-12-29  5:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3A4AC329.9C2A311A@home.com>
2000-12-28  6:19 ` Tags.Internal_Tag(String'Input(Stream)) ?? tmoran
2000-12-28 15:06   ` Warren W. Gay VE3WWG
2000-12-28 15:02 ` In Plain Text: " Warren W. Gay VE3WWG
2000-12-28 15:54   ` Ted Dennison
2000-12-28 18:32     ` Warren W. Gay VE3WWG
2000-12-28 19:44       ` Ted Dennison
2000-12-29  2:20         ` Warren W. Gay VE3WWG
2000-12-29  3:20           ` tmoran
2000-12-29  3:04   ` tmoran
2000-12-29  5:29     ` Warren W. Gay VE3WWG [this message]
2000-12-29  7:11       ` Ada0x Enhancement? Was: " tmoran
2000-12-29 14:32         ` Warren W. Gay VE3WWG
2000-12-30  5:55       ` External_Tag: Why? was " tmoran
2000-12-31 22:17         ` Randy Brukardt
2001-01-01 16:50           ` Warren W. Gay VE3WWG
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox