tools/net/sunrpc/xdrgen/generators/pointer.py
Source file repositories/reference/linux-study-clean/tools/net/sunrpc/xdrgen/generators/pointer.py
File Facts
- System
- Linux kernel
- Corpus path
tools/net/sunrpc/xdrgen/generators/pointer.py- Extension
.py- Size
- 10314 bytes
- Lines
- 289
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# ex: set filetype=python:
"""Generate code to handle XDR pointer types"""
from jinja2 import Environment
from generators import SourceGenerator, kernel_c_type
from generators import create_jinja2_environment, get_jinja2_template
from xdr_ast import _XdrBasic, _XdrString
from xdr_ast import _XdrFixedLengthOpaque, _XdrVariableLengthOpaque
from xdr_ast import _XdrFixedLengthArray, _XdrVariableLengthArray
from xdr_ast import _XdrOptionalData, _XdrPointer, _XdrDeclaration
from xdr_ast import public_apis, get_header_name
def emit_pointer_declaration(environment: Environment, node: _XdrPointer) -> None:
"""Emit a declaration pair for an XDR pointer type"""
if node.name in public_apis:
template = get_jinja2_template(environment, "declaration", "close")
print(template.render(name=node.name))
def emit_pointer_member_definition(
environment: Environment, field: _XdrDeclaration
) -> None:
"""Emit a definition for one field in an XDR struct"""
if isinstance(field, _XdrBasic):
template = get_jinja2_template(environment, "definition", field.template)
print(
template.render(
name=field.name,
type=kernel_c_type(field.spec),
classifier=field.spec.c_classifier,
)
)
elif isinstance(field, _XdrFixedLengthOpaque):
template = get_jinja2_template(environment, "definition", field.template)
print(
template.render(
name=field.name,
size=field.size,
)
)
elif isinstance(field, _XdrVariableLengthOpaque):
template = get_jinja2_template(environment, "definition", field.template)
print(template.render(name=field.name))
elif isinstance(field, _XdrString):
template = get_jinja2_template(environment, "definition", field.template)
print(template.render(name=field.name))
elif isinstance(field, _XdrFixedLengthArray):
template = get_jinja2_template(environment, "definition", field.template)
print(
template.render(
name=field.name,
type=kernel_c_type(field.spec),
size=field.size,
)
)
elif isinstance(field, _XdrVariableLengthArray):
template = get_jinja2_template(environment, "definition", field.template)
print(
template.render(
name=field.name,
type=kernel_c_type(field.spec),
classifier=field.spec.c_classifier,
)
)
elif isinstance(field, _XdrOptionalData):
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.