Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils-sfg
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
Package registry
Model registry
Operate
Environments
Terraform modules
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-sfg
Commits
35127490
Commit
35127490
authored
1 year ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Pass project info through to context
parent
436c77f2
No related branches found
No related tags found
No related merge requests found
Pipeline
#59491
passed
1 year ago
Stage: pretest
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencilssfg/context.py
+12
-3
12 additions, 3 deletions
src/pystencilssfg/context.py
src/pystencilssfg/generator.py
+7
-3
7 additions, 3 deletions
src/pystencilssfg/generator.py
with
19 additions
and
6 deletions
src/pystencilssfg/context.py
+
12
−
3
View file @
35127490
from
typing
import
Generator
,
Sequence
from
typing
import
Generator
,
Sequence
,
Any
from
.configuration
import
SfgCodeStyle
from
.configuration
import
SfgCodeStyle
from
.source_components
import
(
from
.source_components
import
(
...
@@ -48,15 +48,19 @@ class SfgContext:
...
@@ -48,15 +48,19 @@ class SfgContext:
outer_namespace
:
str
|
None
=
None
,
outer_namespace
:
str
|
None
=
None
,
codestyle
:
SfgCodeStyle
=
SfgCodeStyle
(),
codestyle
:
SfgCodeStyle
=
SfgCodeStyle
(),
argv
:
Sequence
[
str
]
|
None
=
None
,
argv
:
Sequence
[
str
]
|
None
=
None
,
project_info
:
Any
=
None
,
):
):
"""
"""
Args:
Args:
outer_namespace: Qualified name of the outer code namespace
outer_namespace: Qualified name of the outer code namespace
codestyle: Code style that should be used by the code emitter
codestyle: Code style that should be used by the code emitter
argv: The generator script
'
s command line arguments;
argv: The generator script
'
s command line arguments.
reserved for internal use by the [SourceFileGenerator][pystencilssfg.SourceFileGenerator].
Reserved for internal use by the [SourceFileGenerator][pystencilssfg.SourceFileGenerator].
project_info: Project-specific information provided by a build system.
Reserved for internal use by the [SourceFileGenerator][pystencilssfg.SourceFileGenerator].
"""
"""
self
.
_argv
=
argv
self
.
_argv
=
argv
self
.
_project_info
=
project_info
self
.
_default_kernel_namespace
=
SfgKernelNamespace
(
self
,
"
kernels
"
)
self
.
_default_kernel_namespace
=
SfgKernelNamespace
(
self
,
"
kernels
"
)
self
.
_outer_namespace
=
outer_namespace
self
.
_outer_namespace
=
outer_namespace
...
@@ -91,6 +95,11 @@ class SfgContext:
...
@@ -91,6 +95,11 @@ class SfgContext:
raise
SfgException
(
"
This context provides no command-line arguments.
"
)
raise
SfgException
(
"
This context provides no command-line arguments.
"
)
return
self
.
_argv
return
self
.
_argv
@property
def
project_info
(
self
)
->
Any
:
"""
Project-specific information provided by a build system.
"""
return
self
.
_project_info
@property
@property
def
outer_namespace
(
self
)
->
str
|
None
:
def
outer_namespace
(
self
)
->
str
|
None
:
"""
Outer code namespace. Set by constructor argument `outer_namespace`.
"""
"""
Outer code namespace. Set by constructor argument `outer_namespace`.
"""
...
...
This diff is collapsed.
Click to expand it.
src/pystencilssfg/generator.py
+
7
−
3
View file @
35127490
...
@@ -14,8 +14,7 @@ from .context import SfgContext
...
@@ -14,8 +14,7 @@ from .context import SfgContext
class
SourceFileGenerator
:
class
SourceFileGenerator
:
"""
Context manager that controls the code generation process in generator scripts.
"""
Context manager that controls the code generation process in generator scripts.
"""
"""
def
__init__
(
self
,
sfg_config
:
SfgConfiguration
|
None
=
None
):
def
__init__
(
self
,
sfg_config
:
SfgConfiguration
|
None
=
None
):
if
sfg_config
and
not
isinstance
(
sfg_config
,
SfgConfiguration
):
if
sfg_config
and
not
isinstance
(
sfg_config
,
SfgConfiguration
):
...
@@ -31,8 +30,13 @@ class SourceFileGenerator:
...
@@ -31,8 +30,13 @@ class SourceFileGenerator:
config
=
merge_configurations
(
project_config
,
cmdline_config
,
sfg_config
)
config
=
merge_configurations
(
project_config
,
cmdline_config
,
sfg_config
)
assert
config
.
codestyle
is
not
None
self
.
_context
=
SfgContext
(
self
.
_context
=
SfgContext
(
config
.
outer_namespace
,
config
.
codestyle
,
argv
=
script_args
config
.
outer_namespace
,
config
.
codestyle
,
argv
=
script_args
,
project_info
=
config
.
project_info
,
)
)
from
.emission
import
HeaderImplPairEmitter
from
.emission
import
HeaderImplPairEmitter
...
...
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