Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romin Tomasetti
gmsh
Commits
766b1ea9
Commit
766b1ea9
authored
5 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
test variations of match finding (#813)
parent
00faa591
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
api/GenApi.py
+30
-14
30 additions, 14 deletions
api/GenApi.py
with
30 additions
and
14 deletions
api/GenApi.py
+
30
−
14
View file @
766b1ea9
...
...
@@ -1543,15 +1543,34 @@ class API:
data
.
sort
(
key
=
lambda
x
:
alphanum_key
(
x
[
0
]))
return
data
def
find_function
(
name
,
data
):
def
find_function
(
lang
,
name
,
data
):
only_unique
=
False
# only report unique matches?
in_comments
=
True
# report matches in comments?
if
lang
==
'
Python
'
:
func
=
name
.
replace
(
'
/
'
,
'
.
'
)
comment
=
'
#
'
else
:
func
=
name
.
replace
(
'
/
'
,
'
::
'
)
comment
=
'
//
'
match
=
[]
unique
=
set
()
for
file
in
data
:
l
=
0
for
line
in
file
[
1
]:
l
=
l
+
1
if
re
.
search
(
name
,
line
):
# allow white space between func name and (
if
re
.
search
(
func
+
'
\s*\(
'
,
line
):
strip
=
re
.
sub
(
r
'
\s+
'
,
''
,
line
)
# don't report matches in comments
if
not
in_comments
and
strip
.
startswith
(
comment
):
continue
# only report a given match once
if
(
not
only_unique
)
or
(
strip
not
in
unique
):
match
.
append
((
file
[
0
],
l
))
break
# keep only one match per file
unique
.
add
(
strip
)
break
# report only one match per file
else
:
unique
.
add
(
strip
)
return
match
def
write_module
(
module
,
path
,
node
,
node_next
,
node_prev
,
cpp_data
,
...
...
@@ -1576,30 +1595,27 @@ class API:
for
oarg
in
oargs
)
if
len
(
oargs
)
else
"
-
"
)
+
"
\n
"
)
f
.
write
(
"
@item
"
+
"
Return:
\n
"
+
(
rtype
.
rtexi_type
if
rtype
else
"
-
"
)
+
"
\n
"
)
cpp_name
=
path
.
replace
(
'
/
'
,
'
::
'
)
+
'
::
'
+
name
+
'
\(
'
cpp
=
find_function
(
cpp_name
,
cpp_data
)
py_name
=
path
.
replace
(
'
/
'
,
'
.
'
)
+
'
.
'
+
name
+
'
\(
'
py
=
find_function
(
py_name
,
py_data
)
def
write_matches
(
lang
,
matches
):
cpp
=
find_function
(
'
C++
'
,
path
+
'
/
'
+
name
,
cpp_data
)
py
=
find_function
(
'
Python
'
,
path
+
'
/
'
+
name
,
py_data
)
def
write_matches
(
lang
,
matches
,
max_matches
):
git
=
'
https://gitlab.onelab.info/gmsh/gmsh/tree/master/
'
f
.
write
(
lang
+
'
(
'
)
for
i
in
range
(
min
(
5
,
for
i
in
range
(
min
(
max_matches
,
len
(
matches
))):
# write max 5 matches
if
i
>
0
:
f
.
write
(
'
,
'
)
f
.
write
(
'
@url{
'
+
git
+
matches
[
i
][
0
][
3
:]
+
'
#L
'
+
str
(
matches
[
i
][
1
])
+
'
,
'
+
os
.
path
.
basename
(
matches
[
i
][
0
])
+
'
}
'
)
if
len
(
matches
)
>
5
:
f
.
write
(
'
, ...
'
)
if
len
(
matches
)
>
max_matches
:
f
.
write
(
'
, ...
'
)
f
.
write
(
'
)
'
)
if
len
(
cpp
)
or
len
(
py
):
f
.
write
(
"
@item
"
+
"
Examples:
\n
"
)
if
len
(
cpp
):
write_matches
(
"
C++
"
,
cpp
)
write_matches
(
"
C++
"
,
cpp
,
5
)
if
len
(
py
):
f
.
write
(
'
,
'
)
if
len
(
py
):
write_matches
(
"
Python
"
,
py
)
write_matches
(
"
Python
"
,
py
,
5
)
f
.
write
(
"
\n
"
)
f
.
write
(
"
@end table
\n\n
"
)
f
.
write
(
"
@end ftable
\n\n
"
)
...
...
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