Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
9d3cc8d5
Commit
9d3cc8d5
authored
1 year ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Doc comments for CFunction
parent
b80a4c7c
No related branches found
No related tags found
2 merge requests
!378
Customizability Extensions: CFunction Signatures and Code Literals
,
!374
Uniqueness of Data Type Instances
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pystencils/backend/functions.py
+17
-5
17 additions, 5 deletions
src/pystencils/backend/functions.py
with
17 additions
and
5 deletions
src/pystencils/backend/functions.py
+
17
−
5
View file @
9d3cc8d5
...
...
@@ -72,12 +72,24 @@ class PsFunction(ABC):
class
CFunction
(
PsFunction
):
"""
A concrete C function.
"""
"""
A concrete C function.
Instances of this class represent a C function by its name, parameter types, and return type.
Args:
name: Function name
param_types: Types of the function parameters
return_type: The function
'
s return type
"""
__match_args__
=
(
"
name
"
,
"
argument_types
"
,
"
return_type
"
)
@staticmethod
def
parse
(
obj
)
->
CFunction
:
"""
Parse the signature of a Python callable object to obtain a CFunction object.
The callable must be fully annotated with type-like objects convertible by `create_type`.
"""
import
inspect
from
pystencils.types
import
create_type
...
...
@@ -93,14 +105,14 @@ class CFunction(PsFunction):
return
CFunction
(
func_name
,
arg_types
,
ret_type
)
def
__init__
(
self
,
name
:
str
,
ar
g
_types
:
Sequence
[
PsType
],
return_type
:
PsType
):
super
().
__init__
(
name
,
len
(
ar
g
_types
))
def
__init__
(
self
,
name
:
str
,
p
ar
am
_types
:
Sequence
[
PsType
],
return_type
:
PsType
):
super
().
__init__
(
name
,
len
(
p
ar
am
_types
))
self
.
_arg_types
=
tuple
(
ar
g
_types
)
self
.
_arg_types
=
tuple
(
p
ar
am
_types
)
self
.
_return_type
=
return_type
@property
def
ar
gument
_types
(
self
)
->
tuple
[
PsType
,
...]:
def
p
ar
ameter
_types
(
self
)
->
tuple
[
PsType
,
...]:
return
self
.
_arg_types
@property
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment