Skip to content

Commit

Permalink
Python is python
Browse files Browse the repository at this point in the history
  • Loading branch information
theHolgi committed Apr 4, 2024
1 parent 1c75c07 commit 18beda0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions hammocking/hammocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ def is_array(self) -> bool:
or self.t.kind == TypeKind.INCOMPLETEARRAY \
or self.t.kind == TypeKind.VARIABLEARRAY \
or self.t.kind == TypeKind.DEPENDENTSIZEDARRAY

@property
def is_struct(self) -> bool:
fields = list(self.t.get_canonical().get_fields())
return len(fields) > 0

def initializer(self) -> str:
if self.is_struct:
return f"({self.spelling}){{0}}"
Expand All @@ -96,9 +96,9 @@ def __init__(self, configfile: Path = None):
return
config = configparser.ConfigParser()
config.read_string(configfile.read_text())
# Read generic settings
# Read generic settings
self._scan(config.items(section=self.section))
# Read OS-specific settings
# Read OS-specific settings
self._scan(config.items(section=f"{self.section}.{sys.platform}"))

def _scan(self, items: Iterator[Tuple[str, str]]) -> None:
Expand Down Expand Up @@ -132,13 +132,13 @@ def get_definition(self, with_type: bool = True) -> str:
return self._type.render(self.name)
else:
return self.name

def is_constant(self) -> bool:
"""Is constant qualified"""
return self._type.is_constant

def initializer(self) -> str:
"""C expression to represent the value "0" according to the variable type"""
"""C expression to represent the value "0" according to the variable type"""
return self._type.initializer()

def __repr__(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tests/data/mini_c_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ add_custom_command(
BYPRODUCTS mockup.h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND_EXPAND_LISTS
COMMAND python3 ${HAMMOCK_DIR}/hammocking.py --sources ${PROD_SRC} --plink ${CMAKE_CURRENT_BINARY_DIR}/${PROD_PARTIAL_LINK} --outdir ${CMAKE_CURRENT_BINARY_DIR} "-I$<JOIN:$<TARGET_PROPERTY:prodlib,INCLUDE_DIRECTORIES>,;-I>"
COMMAND python ${HAMMOCK_DIR}/hammocking.py --sources ${PROD_SRC} --plink ${CMAKE_CURRENT_BINARY_DIR}/${PROD_PARTIAL_LINK} --outdir ${CMAKE_CURRENT_BINARY_DIR} "-I$<JOIN:$<TARGET_PROPERTY:prodlib,INCLUDE_DIRECTORIES>,;-I>"
DEPENDS
${HAMMOCK_DIR}/hammocking.py
${PROD_PARTIAL_LINK}
Expand Down

0 comments on commit 18beda0

Please sign in to comment.