Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
5bb7d991
Commit
5bb7d991
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Modify makeqstrdata to recognise better the output of CPP.
parent
49f20b84
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/makeqstrdata.py
+17
-14
17 additions, 14 deletions
py/makeqstrdata.py
with
17 additions
and
14 deletions
py/makeqstrdata.py
+
17
−
14
View file @
5bb7d991
...
...
@@ -24,10 +24,17 @@ def compute_hash(qstr):
hash
=
(
hash
*
33
)
^
ord
(
char
)
return
hash
&
0xffff
# given a list of (name,regex) pairs, find the first one that matches the given line
def
re_match
(
regexs
,
line
):
for
name
,
regex
in
regexs
:
match
=
re
.
match
(
regex
,
line
)
if
match
:
return
name
,
match
return
None
,
None
def
do_work
(
infiles
):
# read the qstrs in from the input files
qstrs
=
{}
cpp_header_blocks
=
3
for
infile
in
infiles
:
with
open
(
infile
,
'
rt
'
)
as
f
:
line_number
=
0
...
...
@@ -35,23 +42,19 @@ def do_work(infiles):
line_number
+=
1
line
=
line
.
strip
()
# ignore blank lines
and comment
s
if
len
(
line
)
==
0
or
line
.
startswith
(
'
//
'
):
# ignore blank lines
, comments and preprocessor directive
s
if
len
(
line
)
==
0
or
line
.
startswith
(
'
//
'
)
or
line
.
startswith
(
'
#
'
)
:
continue
# We'll have 3 line-number lines for py/qstrdefs.h - initial, leaving it to
# go into other headers, and returning to it.
if
line
.
startswith
(
'
#
'
)
and
'
py/qstrdefs.h
'
in
line
:
cpp_header_blocks
-=
1
continue
if
cpp_header_blocks
!=
0
:
continue
# verify line is of the correct form
match
=
re
.
match
(
r
'
Q\((.+)\)$
'
,
line
)
if
not
match
:
# work out what kind of line it is
match_kind
,
match
=
re_match
([(
'
qstr
'
,
r
'
Q\((.+)\)$
'
),
(
'
cdecl
'
,
r
'
(typedef|extern) [A-Za-z0-9_* ]+;$
'
)],
line
)
if
match_kind
is
None
:
# unknown line format
print
(
'
({}:{}) bad qstr format, got {}
'
.
format
(
infile
,
line_number
,
line
),
file
=
sys
.
stderr
)
return
False
elif
match_kind
!=
'
qstr
'
:
# not a line with a qstr
continue
# get the qstr value
qstr
=
match
.
group
(
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment