POV-Ray : Newsgroups : povray.programming : enum { SOMETHING = 'Thing' } ? Server Time
22 Dec 2024 18:01:18 EST (-0500)
  enum { SOMETHING = 'Thing' } ? (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: AngleWyrm
Subject: enum { SOMETHING = 'Thing' } ?
Date: 31 Jan 2004 15:42:33
Message: <401c1339$1@news.povray.org>
This syntax is new to me:

/* POV-Ray Message Classes */
enum
{
 kPOVMsgClass_RenderControl   = 'Ctrl',
 kPOVMsgClass_RenderOutput   = 'Outp',
 kPOVMsgClass_IniOptions    = 'IniO',
 kPOVMsgClass_Miscellaneous   = 'Misc'
}; //           How does this work ? --^^^^^

'Ctrl' is quite a bit different from what I'm used to using for enumeration,
and also looks a bit like a four-byte char?


Post a reply to this message

From: Christoph Hormann
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 31 Jan 2004 16:16:04
Message: <muhte1-ch6.ln1@triton.imagico.de>
AngleWyrm wrote:
> This syntax is new to me:
> 
> /* POV-Ray Message Classes */
> enum
> {
>  kPOVMsgClass_RenderControl   = 'Ctrl',
>  kPOVMsgClass_RenderOutput   = 'Outp',
>  kPOVMsgClass_IniOptions    = 'IniO',
>  kPOVMsgClass_Miscellaneous   = 'Misc'
> }; //           How does this work ? --^^^^^
> 
> 'Ctrl' is quite a bit different from what I'm used to using for enumeration,
> and also looks a bit like a four-byte char?
> 

These are multicharacter character constants but they do not need to 
bother you.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 11 Jan. 2004 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: ABX
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 2 Feb 2004 05:07:56
Message: <t58s1015437i6sh8q0jv9m16sm6eomafna@4ax.com>
On Sat, 31 Jan 2004 12:42:19 -0800, "AngleWyrm"
<no_### [at] hotmailcom> wrote:
> 'Ctrl' is quite a bit different from what I'm used to using for enumeration,
> and also looks a bit like a four-byte char?

'Ctrl' is alternative notation for 32-bit integers here.

ABX


Post a reply to this message

From: Warp
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 2 Feb 2004 05:52:23
Message: <401e2be7@news.povray.org>
AngleWyrm <no_### [at] hotmailcom> wrote:
>  kPOVMsgClass_RenderControl   = 'Ctrl',

> 'Ctrl' is quite a bit different from what I'm used to using for enumeration,
> and also looks a bit like a four-byte char?

  'Ctrl' is the value 1131704940.

  (If you can't deduce why, I can explain that as well.)

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 02:14:21
Message: <4021ed4d$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:401e2be7@news.povray.org...
> AngleWyrm <no_### [at] hotmailcom> wrote:
> >  kPOVMsgClass_RenderControl   = 'Ctrl',

>   'Ctrl' is the value 1131704940.
>   (If you can't deduce why, I can explain that as well.)

'C'<<32|'t'<<16|'r'<<8|'l'

What I can't deduce is where/how the value of the enum is used.
I've seen some lines using if(cur->handledclass == hclass) type statements,
but this is just normal enum handling.


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 02:28:51
Message: <4021f0b3$1@news.povray.org>
"ABX" <abx### [at] abxartpl> wrote in message
news:t58s1015437i6sh8q0jv9m16sm6eomafna@4ax.com...
> On Sat, 31 Jan 2004 12:42:19 -0800, "AngleWyrm"
> <no_### [at] hotmailcom> wrote:
> > 'Ctrl' is quite a bit different from what I'm used to using for
enumeration,
> > and also looks a bit like a four-byte char?
>
> 'Ctrl' is alternative notation for 32-bit integers here.

So this would be saying the same thing sleightly differently:

#define CTRL 1131704940
enum { kPOVMsgClass_RenderControl   = CTRL }

Is this numerical encoding used as an error catching mechanism during code
construction? I haven't been able to find further references to 'Ctrl'
outside the enum declaration.


Post a reply to this message

From: ABX
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 02:47:31
Message: <60t320p8r7lpgepjg2nplk9ptkkgskioq9@4ax.com>
On Wed, 4 Feb 2004 23:21:28 -0800, "AngleWyrm" <no_### [at] hotmailcom>
wrote:
> Is this numerical encoding used as an error catching mechanism during code
> construction? I haven't been able to find further references to 'Ctrl'
> outside the enum declaration.

Are you looking references to 'Ctrl' or to kPOVMsgClass_RenderControl?

ABX


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 06:12:35
Message: <40222523@news.povray.org>
"ABX" <abx### [at] abxartpl> wrote in message
news:60t320p8r7lpgepjg2nplk9ptkkgskioq9@4ax.com...
> On Wed, 4 Feb 2004 23:21:28 -0800, "AngleWyrm"
<no_### [at] hotmailcom>
> wrote:
> > Is this numerical encoding used as an error catching mechanism during
code
> > construction? I haven't been able to find further references to 'Ctrl'
> > outside the enum declaration.
>
> Are you looking references to 'Ctrl' or to kPOVMsgClass_RenderControl?

'Ctrl'

If the enums were given specific values, it was my guess that at some point
in the program a comparison to, or usage of those specific values would take
place. Makes sense?

Thus I surmized that there must be more than one occurance of the term 'Ctl'
within the source files, so I went looking for this. I only found the one
occurance, and this got me wondering if it was an exception to a norm. Hey
maybe the rest of them or even just some of them are used in some
comparison.

So I did a grep search on '\(....\)' to find all single quoted four-letter
blocks. The only code (besides comments) that came back were the
enumerations themselves. (www.textpad.com, nice notepad replacement)

Thus far, it seems that my guess may be in error; perhaps those values
aren't used anywhere else?


Post a reply to this message

From: AngleWyrm
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 07:02:58
Message: <402230f2$1@news.povray.org>
Some possible reasons:
* It may have applied to old code that is no longer a part of the program

* It may have applied to an old plan that was never implemented

* It may have been a method of creating a 'sparse' enum set, to avoid
accidentally refererencing with the wrong kind--But there's a better ways to
catch that mishap:

enum animals {CAT, DOG, MOUSE};
enum colors {RED,GREEN,BLUE};
void MyAnimalFunc( animals eInput ){}; // enum type specified
int main(void)
  MyAnimalFunc( CAT ); // works fine
  MyAnimalFunc( RED ); // compiler gets it: cannot convert 'colors' to
'animals'
}

* It might apply to tools/utilities that reside outside the program

* I've overlooked something totally obvious, and should go get another cup
of coffee


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: enum { SOMETHING = 'Thing' } ?
Date: 5 Feb 2004 07:54:07
Message: <40223cef$1@news.povray.org>
In article <40222523@news.povray.org> , "AngleWyrm" 
<no_### [at] hotmailcom> wrote:

> If the enums were given specific values, it was my guess that at some point
> in the program a comparison to, or usage of those specific values would take
> place. Makes sense?

No, nobody would define enums and then not use them.  Enums are given
"names" because those mean more to a human when debugging.  Otherwise you
would always have to manually count which value you are currently dealing
with, which is insane if you are dealing with more than just a handful of
value.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.