Update list example
This commit is contained in:
parent
f3fc2d5c41
commit
7b16c7511f
@ -154,6 +154,13 @@ def test_typed_array():
|
||||
|
||||
|
||||
def test_doubly_linked_list():
|
||||
def __format_func_body(filename: Path, type_string: str):
|
||||
return load_func_body_from_file(filename).format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower(),
|
||||
)
|
||||
|
||||
datatypes: dict[CDataType, list[CInclude]] = {"Str8": [CInclude(header="str8.h", local=True)]}
|
||||
snippets_dir = Path("snippets")
|
||||
|
||||
@ -186,11 +193,7 @@ def test_doubly_linked_list():
|
||||
CArg(name="list", _type=dl_list, pointer=CPointer(CPointerType.SINGLE), qualifier=CQualifier.CONST),
|
||||
CArg(name="index", _type=CType.U64),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_get").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_get", type_string),
|
||||
pointer=CPointer(CPointerType.SINGLE),
|
||||
)
|
||||
|
||||
@ -201,11 +204,7 @@ def test_doubly_linked_list():
|
||||
CArg(name="list", _type=dl_list, pointer=CPointer(CPointerType.SINGLE)),
|
||||
CArg(name="node", _type=node, pointer=CPointer(CPointerType.SINGLE)),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_push_front").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_push_front", type_string),
|
||||
)
|
||||
|
||||
push_back_func = CFunc(
|
||||
@ -215,11 +214,7 @@ def test_doubly_linked_list():
|
||||
CArg(name="list", _type=dl_list, pointer=CPointer(CPointerType.SINGLE)),
|
||||
CArg(name="node", _type=node, pointer=CPointer(CPointerType.SINGLE)),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_push_back").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_push_back", type_string),
|
||||
)
|
||||
|
||||
insert_func = CFunc(
|
||||
@ -230,11 +225,7 @@ def test_doubly_linked_list():
|
||||
CArg(name="node", _type=node, pointer=CPointer(CPointerType.SINGLE)),
|
||||
CArg(name="index", _type=CType.U64),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_insert").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_insert", type_string),
|
||||
)
|
||||
|
||||
pop_front_func = CFunc(
|
||||
@ -243,11 +234,7 @@ def test_doubly_linked_list():
|
||||
args=[
|
||||
CArg(name="list", _type=dl_list, pointer=CPointer(CPointerType.SINGLE)),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_pop_front").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_pop_front", type_string),
|
||||
pointer=CPointer(CPointerType.SINGLE),
|
||||
)
|
||||
|
||||
@ -257,11 +244,7 @@ def test_doubly_linked_list():
|
||||
args=[
|
||||
CArg(name="list", _type=dl_list, pointer=CPointer(CPointerType.SINGLE)),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_pop_back").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_pop_back", type_string),
|
||||
pointer=CPointer(CPointerType.SINGLE),
|
||||
)
|
||||
|
||||
@ -272,11 +255,7 @@ def test_doubly_linked_list():
|
||||
CArg(name="list", _type=dl_list, pointer=CPointer(CPointerType.SINGLE)),
|
||||
CArg(name="index", _type=CType.U64),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_remove").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_remove", type_string),
|
||||
pointer=CPointer(CPointerType.SINGLE),
|
||||
)
|
||||
|
||||
@ -286,11 +265,7 @@ def test_doubly_linked_list():
|
||||
args=[
|
||||
CArg(name="list", _type=dl_list, pointer=CPointer(CPointerType.SINGLE)),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "list_empty").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower()
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "list_empty", type_string),
|
||||
)
|
||||
|
||||
node_to_list_func = CFunc(
|
||||
@ -299,11 +274,7 @@ def test_doubly_linked_list():
|
||||
args=[
|
||||
CArg(name="node", _type=node, pointer=CPointer(CPointerType.SINGLE)),
|
||||
],
|
||||
body=load_func_body_from_file(Path(__file__).parent / snippets_dir / "node_to_list").format(
|
||||
T=type_string,
|
||||
Tupper=type_string.upper(),
|
||||
Tlower=type_string.lower(),
|
||||
),
|
||||
body=__format_func_body(Path(__file__).parent / snippets_dir / "node_to_list", type_string),
|
||||
qualifiers=[CQualifier.INTERNAL],
|
||||
)
|
||||
|
||||
@ -334,9 +305,6 @@ def test_doubly_linked_list():
|
||||
header.includes.extend(includes)
|
||||
source.includes.extend(includes)
|
||||
|
||||
header.includes = sorted(header.includes, key=lambda inc: inc.local, reverse=True)
|
||||
source.includes = sorted(source.includes, key=lambda inc: inc.local, reverse=True)
|
||||
|
||||
header.save(Path("."))
|
||||
source.save(Path("."))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user