Home > Archive > Dylan > June 2004 > Melange enum handling
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Melange enum handling
|
|
| Chris Page 2004-06-03, 7:08 pm |
| When an anonymous enum is encountered, why does Melange:
1. Emit a type definition.
2. Prefix each enum member with the type name?
ie.:
enum {kFoo, kBar};
emits something like:
define constant <anonymous-123> = limited(<integer>, min: 0, max: 1);
define constant $anonymous-123$kFoo :: <anonymous-123> = 0;
define constant $anonymous-123$kBar :: <anonymous-123> = 1;
I can understand the desirability of the type definition when an enum
tag is given in the C code, because it might actually be referenced, but
when it's anonymous, nobody can refer to it (unless the enum is actually
specified at point of use, of course.)
More importantly, however, is #2. Why does it emit prefices at all, even
when there is a tag? Enum values are in a single namespace, so they
can't conflict, and the prefix uglifies the code (especially in the
anonymous case.)
I've been working on Melange and I'm inclined to:
1. Eliminate emitting the type and the prefices at least in the
anonymous case.
2. Eliminate prefices in all cases, or
3. Provide some way to turn off the prefices (either on the command line
or in interface definitions.)
--
Chris Page - Software Wrangler - Dylan Pundit
Dylan + You = Code
<http://www.gwydiondylan.org/>
<http://www.cafepress.com/chrispage>
| |
| Peter S. Housel 2004-06-03, 7:08 pm |
| Chris Page <usenet@chris-page*NOSPAM*.org> writes:
> When an anonymous enum is encountered, why does Melange:
>
> 1. Emit a type definition.
Probably only because it makes anonymous enums less of a special case.
> 2. Prefix each enum member with the type name?
That's part of the "name mapping function" specified with the name-mapper:
keyword in the interface definition.
> I've been working on Melange and I'm inclined to:
>
> 1. Eliminate emitting the type and the prefices at least in the
> anonymous case.
> 2. Eliminate prefices in all cases, or
> 3. Provide some way to turn off the prefices (either on the command line
> or in interface definitions.)
There is probably a good case for eliminiating the type emission in the
anonymous case.
For the others, it seems to me like you should be using another mapper,
such as c-to-dylan.
-Peter-
| |
| Chris Page 2004-06-03, 7:08 pm |
| In article <mu9r7sy7slx.fsf@housel.dyndns.org>,
housel@cox.net (Peter S. Housel) wrote:
> For the others, it seems to me like you should be using another mapper,
> such as c-to-dylan.
We talked about this further on #dylan (freenode.net), and I now have a
better understanding of how Melange is meant to be used. Yes, it sounds
like I just need to use a different name mapper.
Apple Dylan's Creole (which is very similar to Melange) has a name
mapper MacApp-to-Dylan, which is essentially what I want, since I'm
trying to generate interfaces for the Mac OS Carbon framework. I'll
probably implement a similar name mapper for Melange.
--
Chris Page - Software Wrangler - Dylan Pundit
Dylan + You = Code
<http://www.gwydiondylan.org/>
<http://www.cafepress.com/chrispage>
| |
| Chris Page 2004-06-07, 8:57 am |
| In article <mu9r7sy7slx.fsf@housel.dyndns.org>,
housel@cox.net (Peter S. Housel) wrote:
> Chris Page <usenet@chris-page*NOSPAM*.org> writes:
>
....[color=darkred]
>
> That's part of the "name mapping function" specified with the name-mapper:
> keyword in the interface definition.
Upon further investigation, I don't think a prefix should be emitted for
enums. Melange and Creole have the same default name mapper
("minimal-name-mapping-with-structure-prefix"), but Creole's
implementation does not emit prefixes for enumerations (it only emits
them for struct and union members.)
In fact, the Melange user guide only says that prefixes will be added to
structures, and does not say "structures" includes enums:
<http://www.gwydiondylan.org/gdref/g...ng-object-names
..html>
I want to change the name mapper to match Creole's if there are no
objections. First I'll perform a survey of existing sources to see
whether and how much code would be affected by this change.
--
Chris Page - Software Wrangler - Dylan Pundit
Open Source Dylan: <http://www.gwydiondylan.org/>
Dylan Blogging: <http://homepage.mac.com/chrispage/iblog/>
|
|
|
|
|