Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--disable-qualifiers-hints flag #256

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions m2c/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ def parse_flags(flags: List[str]) -> Options:
default=52,
help="Column number to justify comments to. Set to 0 to disable justification. Default: 52",
)
group.add_argument(
"--no-qualifiers-hints",
dest="no_qualifiers_hints",
action="store_true",
help="Turns off qualifiers hints for functions and variables. externs qualifiers for data are not disabled by this flag",
)
group.add_argument(
"--no-casts",
dest="skip_casts",
Expand Down Expand Up @@ -577,6 +583,7 @@ def parse_flags(flags: List[str]) -> Options:
hex_case=args.hex_case,
comment_style=args.comment_style,
comment_column=args.comment_column,
no_qualifiers_hints=args.no_qualifiers_hints,
)

functions: List[Union[int, str]] = []
Expand Down
2 changes: 2 additions & 0 deletions m2c/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CommentStyle(ChoicesEnum):
hex_case: bool
comment_style: CommentStyle
comment_column: int
no_qualifiers_hints: bool


@dataclass
Expand Down Expand Up @@ -161,6 +162,7 @@ def formatter(self) -> "Formatter":
hex_case=False,
comment_style=CodingStyle.CommentStyle.MULTILINE,
comment_column=52,
no_qualifiers_hints=False,
)


Expand Down
11 changes: 6 additions & 5 deletions m2c/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4113,15 +4113,16 @@ def global_decls(
comments = []

# Determine type qualifier: static, extern, or neither
if is_in_file and is_global:
if not is_in_file:
qualifier = "extern"
elif is_in_file and is_global:
qualifier = ""
elif is_in_file:
elif not fmt.coding_style.no_qualifiers_hints:
qualifier = "static"
else:
qualifier = "extern"

if sym.type.is_function():
comments.append(qualifier)
if not fmt.coding_style.no_qualifiers_hints:
comments.append(qualifier)
qualifier = ""

# Try to guess if the symbol is an array (and if it is, its dimension) if
Expand Down