Skip to content
Snippets Groups Projects

Draft: C Interfacing

Open Richard Angersbach requested to merge rangersbach/c-interfacing into master
Files
7
@@ -15,6 +15,7 @@ from pystencils import (
)
from pystencils.codegen import Kernel, Lambda
from pystencils.types import create_type, UserTypeSpec, PsType
from pystencilssfg.ir import SfgSourceFileType
from ..context import SfgContext, SfgCursor
from .custom import CustomGenerator
@@ -383,6 +384,8 @@ class SfgBasicComposer(SfgIComposer):
if self._ctx.impl_file is None:
seq.inline()
if self._ctx.c_interfacing:
seq._externC = True
return seq
@@ -661,6 +664,7 @@ class SfgFunctionSequencerBase:
# Qualifiers
self._inline: bool = False
self._externC: bool = False
self._constexpr: bool = False
# Attributes
@@ -702,6 +706,10 @@ class SfgFunctionSequencer(SfgFunctionSequencerBase):
"""Sequencer for constructing functions."""
def __call__(self, *args: SequencerArg) -> None:
# check if header is in HYBRID mode for c_interfacing enabled
if self._cursor.context.c_interfacing:
assert self._cursor.context.header_file.file_type == SfgSourceFileType.HYBRID_HEADER
"""Populate the function body"""
tree = make_sequence(*args)
func = SfgFunction(
@@ -710,6 +718,7 @@ class SfgFunctionSequencer(SfgFunctionSequencerBase):
tree,
return_type=self._return_type,
inline=self._inline,
externC=self._externC,
constexpr=self._constexpr,
attributes=self._attributes,
required_params=self._params,