Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-22 Thread Ethan Jackson
> If I fold in the following (basically dropping all the "const"s) it > compiles warning-free for me and the generated code is prettier.  What > do you think? Strange, I could have sworn I tried that when I originally wrote the patch. At any rate works for me. I'll merge it that with this Increm

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-22 Thread Ben Pfaff
On Thu, Mar 22, 2012 at 11:32:06AM -0700, Ethan Jackson wrote: > Sure here it is. (Rebased against master). Thanks a lot. If I fold in the following (basically dropping all the "const"s) it compiles warning-free for me and the generated code is prettier. What do you think? Thanks, Ben. diff -

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-22 Thread Ethan Jackson
Sure here it is. (Rebased against master). --- ovsdb/ovsdb-idlc.in | 48 vswitchd/bridge.c | 208 +-- 2 files changed, 152 insertions(+), 104 deletions(-) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 089bc23..8df11

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-22 Thread Ben Pfaff
Oh, sorry, I must have done something stupid, adding the "const" after the ** doesn't make much sense. Would you mind posting the whole revised patch again with the incremental folded in? I want to figure out where I went wrong. Thanks, Ben. On Wed, Mar 21, 2012 at 05:23:15PM -0700, Ethan Jack

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ethan Jackson
I had to jump through an awkward hoop to get through the cast as result_key needs to be char **const for the subtraction to work. If it's char **const, I need to updated it at it's definition. What do you think of this incremental? Ethan --- ovsdb/ovsdb-idlc.in | 20 +--- 1 f

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ben Pfaff
On Wed, Mar 21, 2012 at 03:57:33PM -0700, Ethan Jackson wrote: > This removes some boilerplate from the bridge. > > Signed-off-by: Ethan Jackson If you define keys, values, and result_key as 'char **const', instead of as 'const char **', then you can drop the casts: > +const char **keys = (c

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ethan Jackson
>   have_string_maps = any(is_string_map(column) >                          for column in table.columns.itervalues() >                          for schema.tables.itervalues()) I find these double list comprehensions impossible to read, so I probably won't go that way. I could use a flag, but I li

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Reid Price
On Wed, Mar 21, 2012 at 3:57 PM, Ethan Jackson wrote: > This removes some boilerplate from the bridge. > > Signed-off-by: Ethan Jackson > --- > > It actually turned out to be less difficult than I expected to do a binary > search so I went ahead and did it. > > --- > ovsdb/ovsdb-idlc.in | 50

[ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ethan Jackson
This removes some boilerplate from the bridge. Signed-off-by: Ethan Jackson --- It actually turned out to be less difficult than I expected to do a binary search so I went ahead and did it. --- ovsdb/ovsdb-idlc.in | 50 + vswitchd/bridge.c | 208 +--

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ben Pfaff
On Wed, Mar 21, 2012 at 02:29:14PM -0700, Ethan Jackson wrote: > > The keys are guaranteed to be in sorted order, so we could use binary > > search.  Do we have any string-to-string maps that tend to get big? > > (If we do implement binary search then I'd put it in a helper > > function.) > > If w

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ethan Jackson
> The keys are guaranteed to be in sorted order, so we could use binary > search.  Do we have any string-to-string maps that tend to get big? > (If we do implement binary search then I'd put it in a helper > function.) If we're going to go that route, I wonder if it makes sense to replace the stri

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Reid Price
Looks nice, thanks On Wed, Mar 21, 2012 at 1:48 PM, Ben Pfaff wrote: > On Tue, Mar 20, 2012 at 06:27:31PM -0700, Ethan Jackson wrote: > > This removes some boilerplate from the bridge. > > > > Signed-off-by: Ethan Jackson > > I like this very much. Thank you! > > The keys are guaranteed to be

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ben Pfaff
On Tue, Mar 20, 2012 at 06:27:31PM -0700, Ethan Jackson wrote: > This removes some boilerplate from the bridge. > > Signed-off-by: Ethan Jackson I like this very much. Thank you! The keys are guaranteed to be in sorted order, so we could use binary search. Do we have any string-to-string maps

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ethan Jackson
Here's an incremental. --- ovsdb/ovsdb-idlc.in | 32 +--- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 79e3d1e..2775d93 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -512,25 +512,19 @@

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-21 Thread Ben Pfaff
On Tue, Mar 20, 2012 at 07:24:46PM -0700, Reid Price wrote: > > > > +# String Map Helpers. > > +for columnName, column in sorted(table.columns.iteritems()): > > +if not is_string_map(column): > > +continue > > + > > +print > > +pri

Re: [ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-20 Thread Reid Price
> > +# String Map Helpers. > +for columnName, column in sorted(table.columns.iteritems()): > +if not is_string_map(column): > +continue > + > +print > +print "const char *" > +print "%(s)s_get_%(c)s_value(const struct %

[ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.

2012-03-20 Thread Ethan Jackson
This removes some boilerplate from the bridge. Signed-off-by: Ethan Jackson --- ovsdb/ovsdb-idlc.in | 40 ++ vswitchd/bridge.c | 208 +-- 2 files changed, 144 insertions(+), 104 deletions(-) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ov