[Bro-Dev] enums in modules

Seth Hall seth at icir.org
Mon Jan 24 11:50:07 PST 2011


On Jan 24, 2011, at 11:31 AM, Robin Sommer wrote:

> 
> On Sun, Jan 23, 2011 at 01:21 -0500, you wrote:
> 
>> I think that does work, it's the namespacing that messes things up
>> because the Bro and C syntaxes don't mesh.  Maybe bifcl could munge
>> namespaces from Logging::ID to _Logging__ID or something to provide
>> the transition?
> 
> I'd need to look closer at bifcl. Can you file a ticket with a small
> example demonstrating the problem? Thanks,


After taking a deeper look into this, I realized that I may be misunderstanding how enums are supposed to be used.  Does it make sense that you'd provide an enum name as a type to get static type checking?  Like this...

<code example>
type TEST_ENUM: enum { test_one, test_two, test_three };

function blah(b: TEST_ENUM)
	{
	print "did it work?";
	}

event bro_init()
	{
	local a = test_two;
	print blah(a);
	}
</code example>

I get this error from that code..

[seth at Blake build (master)]$ ./src/bro test.bro 
./test.bro, line 11 (print blah(a)): error, value of type void illegal

Before I send my example for namespaced enums, I think I need to get more of the base usage of enums clarified.  Are there any examples that you know of where enums are used as parameter values like this?

  .Seth

--
Seth Hall
International Computer Science Institute
(Bro) because everyone has a network
http://www.bro-ids.org/




More information about the bro-dev mailing list