|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN PATCH v3 1/1] build: replace get-fields.sh by a python script
On Tue, Jan 17, 2023 at 05:21:32PM +0000, Andrew Cooper wrote:
> On 16/01/2023 6:10 pm, Anthony PERARD wrote:
> > +def get_typedefs(tokens):
> > + level = 1
> > + state = 0
> > + typedefs = []
>
> I'm pretty sure typedefs actually wants to be a dict rather than a list
> (will have better "id in typedefs" performance lower down), but that
> wants matching with code changes elsewhere, and probably wants doing
> separately.
I'm not sure that going to make a difference to have "id in ()" instead
of "id in []". I just found out that `typedefs` is always empty...
I don't know what get_typedefs() is supposed to do, or at least if it
works as expected, because it always returns "" or an empty list. (even
the shell version)
So, it would actually be a bit faster to not call get_typedefs(), but I
don't know if that's safe.
> > + for token in tokens:
> > + if token == 'typedef':
> > + if level == 1:
> > + state = 1
> > + elif re.match(r'^COMPAT_HANDLE\((.*)\)$', token):
> > + if not (level != 1 or state != 1):
> > + state = 2
> > + elif token in ['[', '{']:
> > + level += 1
> > + elif token in [']', '}']:
> > + level -= 1
> > + elif token == ';':
> > + if level == 1:
> > + state = 0
> > + elif re.match(r'^[a-zA-Z_]', token):
> > + if not (level != 1 or state != 2):
> > + typedefs.append(token)
> > + return typedefs
--
Anthony PERARD
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |