Add static, runtime and debug assert utilities
This commit is contained in:
@@ -2,7 +2,7 @@ from pathlib import Path
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Dict
|
||||
from codegen.constants import WAPP_SRC_ROOT
|
||||
from codegen.utils import load_func_body_from_file
|
||||
from codegen.utils import load_func_body_from_file, convert_to_relative
|
||||
from codegen.datatypes import (
|
||||
CDataType,
|
||||
CMacro,
|
||||
@@ -49,7 +49,10 @@ def make_dbl_list(user_datatypes: Dict[CDataType, DblListData] = {}):
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
common_includes: List[CInclude] = [
|
||||
CInclude(header="stdbool.h")
|
||||
CInclude(
|
||||
header=str(convert_to_relative(WAPP_SRC_ROOT / "common" / "aliases" / "aliases.h", out_dir)).replace("\\", "/"),
|
||||
local=True,
|
||||
)
|
||||
]
|
||||
|
||||
common_decl_types: List[CStruct] = []
|
||||
@@ -95,6 +98,10 @@ def make_dbl_list(user_datatypes: Dict[CDataType, DblListData] = {}):
|
||||
decl_types=[*common_decl_types],
|
||||
includes=[
|
||||
CInclude(header, local=True, same_dir=True),
|
||||
CInclude(
|
||||
header=str(convert_to_relative(WAPP_SRC_ROOT / "common" / "assert" / "assert.h", out_dir)).replace("\\", "/"),
|
||||
local=True
|
||||
),
|
||||
CInclude(header="stddef.h"),
|
||||
CInclude(header="assert.h"),
|
||||
],
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(list != NULL);
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
u64 count = list->node_count;
|
||||
for (u64 i = 0; i < count; ++i) {{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(index < list->node_count);
|
||||
wapp_runtime_assert(index < list->node_count, "`index` is out of bounds");
|
||||
|
||||
{NodeType} *output = NULL;
|
||||
{NodeType} *current = list->first;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(list != NULL && node != NULL && (node->item) != NULL);
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
if (index == 0) {{
|
||||
wapp_{Tlower}_list_push_front(list, node);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(list != NULL);
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
{NodeType} *output = NULL;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(list != NULL);
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
{NodeType} *output = NULL;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(list != NULL && node != NULL && (node->item) != NULL);
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
{ListType} node_list = {Tlower}_node_to_list(node);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(list != NULL && node != NULL && (node->item) != NULL);
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
{ListType} node_list = {Tlower}_node_to_list(node);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
assert(list != NULL);
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
{NodeType} *output = NULL;
|
||||
|
||||
|
Reference in New Issue
Block a user