Skip to content

Commit

Permalink
Rename f_call, f_return to func_call, func_return
Browse files Browse the repository at this point in the history
  • Loading branch information
cogu committed Aug 27, 2023
1 parent dbba7df commit d2f0081
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ code.append(C.blank())
char_ptr_type = C.type("char", pointer=True)
code.append(C.function("main", "int").make_param("argc", "int").make_param("argv", char_ptr_type, pointer=True))
main_body = C.block()
main_body.append(C.statement(C.f_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.f_return(0)))
main_body.append(C.statement(C.func_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.func_return(0)))
code.append(main_body)
writer = cfile.Writer(cfile.StyleOptions())
print(writer.write_str(code))
Expand All @@ -28,7 +28,7 @@ print(writer.write_str(code))
{
printf("Hello World!\n");
return 0;
}
}
```
Same example again but we ser some formatting style options:
Expand All @@ -46,8 +46,8 @@ code.append(C.blank())
char_ptr_type = C.type("char", pointer=True)
code.append(C.function("main", "int").make_param("argc", "int").make_param("argv", char_ptr_type, pointer=True))
main_body = C.block()
main_body.append(C.statement(C.f_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.f_return(0)))
main_body.append(C.statement(C.func_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.func_return(0)))
code.append(main_body)
style = cfile.StyleOptions(break_before_braces=cfile.BreakBeforeBraces.ATTACH,
pointer_alignment=cfile.Alignment.RIGHT)
Expand All @@ -61,7 +61,7 @@ print(writer.write_str(code))
int main(int argc, char **argv) {
printf("Hello World!\n");
return 0;
}
}
```
## Requires
Expand Down
4 changes: 2 additions & 2 deletions examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
char_ptr_type = C.type("char", pointer=True)
code.append(C.function("main", "int").make_param("argc", "int").make_param("argv", char_ptr_type, pointer=True))
main_body = C.block()
main_body.append(C.statement(C.f_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.f_return(0)))
main_body.append(C.statement(C.func_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.func_return(0)))
code.append(main_body)
writer = cfile.Writer(cfile.StyleOptions())
print(writer.write_str(code))
4 changes: 2 additions & 2 deletions examples/hello_world2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
char_ptr_type = C.type("char", pointer=True)
code.append(C.function("main", "int").make_param("argc", "int").make_param("argv", char_ptr_type, pointer=True))
main_body = C.block()
main_body.append(C.statement(C.f_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.f_return(0)))
main_body.append(C.statement(C.func_call("printf", C.str_literal(r"Hello World\n"))))
main_body.append(C.statement(C.func_return(0)))
code.append(main_body)
style = cfile.StyleOptions(break_before_braces=cfile.BreakBeforeBraces.ATTACH,
pointer_alignment=cfile.Alignment.RIGHT)
Expand Down
4 changes: 2 additions & 2 deletions src/cfile/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def str_literal(self, text: str) -> core.StringLiteral:
"""
return core.StringLiteral(text)

def f_call(self, name: str, *args) -> core.FunctionCall:
def func_call(self, name: str, *args) -> core.FunctionCall:
"""
New function call
"""
return core.FunctionCall(name, *args)

def f_return(self, expression: int | float | str | core.Element) -> core.FunctionReturn:
def func_return(self, expression: int | float | str | core.Element) -> core.FunctionReturn:
"""
New return expression
"""
Expand Down

0 comments on commit d2f0081

Please sign in to comment.