Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
e9e1e7e
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
accounting
arch
bootconfig
bpf
build
certs
cgroup
counter
crypto
debugging
firewire
firmware
gpio
hv
iio
include
kvm
laptop
leds
lib
memory-model
mm
net
sunrpc/xdrgen
generators
__init__.py
constant.py
enum.py
header_bottom.py
header_top.py
pointer.py
program.py
source_top.py
struct.py
typedef.py
union.py
grammars
subcmds
templates
tests
.gitignore
README
__init__.py
xdr_ast.py
xdr_parse.py
xdrgen
ynl
objtool
pci
pcmcia
perf
power
rcu
sched_ext
scripts
sound
spi
testing
thermal
time
tracing
usb
verification
virtio
wmi
workqueue
writeback
Makefile
usr
virt
.clang-format
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
tools
/
net
/
sunrpc
/
xdrgen
/
generators
/
enum.py
Blame
Blame
Latest commit
History
History
64 lines (52 loc) · 2.56 KB
Breadcrumbs
linux
/
tools
/
net
/
sunrpc
/
xdrgen
/
generators
/
enum.py
Top
File metadata and controls
Code
Blame
64 lines (52 loc) · 2.56 KB
Raw
#!/usr/bin/env python3 # ex: set filetype=python: """Generate code to handle XDR enum types""" from generators import SourceGenerator, create_jinja2_environment from xdr_ast import _XdrEnum, public_apis, big_endian, get_header_name class XdrEnumGenerator(SourceGenerator): """Generate source code for XDR enum types""" def __init__(self, language: str, peer: str): """Initialize an instance of this class""" self.environment = create_jinja2_environment(language, "enum") self.peer = peer def emit_declaration(self, node: _XdrEnum) -> None: """Emit one declaration pair for an XDR enum type""" if node.name in public_apis: template = self.environment.get_template("declaration/enum.j2") print(template.render(name=node.name)) def emit_definition(self, node: _XdrEnum) -> None: """Emit one definition for an XDR enum type""" template = self.environment.get_template("definition/open.j2") print(template.render(name=node.name)) template = self.environment.get_template("definition/enumerator.j2") for enumerator in node.enumerators: print(template.render(name=enumerator.name, value=enumerator.value)) if node.name in big_endian: template = self.environment.get_template("definition/close_be.j2") else: template = self.environment.get_template("definition/close.j2") print(template.render(name=node.name)) def emit_decoder(self, node: _XdrEnum) -> None: """Emit one decoder function for an XDR enum type""" if node.name in big_endian: template = self.environment.get_template("decoder/enum_be.j2") else: template = self.environment.get_template("decoder/enum.j2") print(template.render(name=node.name)) def emit_encoder(self, node: _XdrEnum) -> None: """Emit one encoder function for an XDR enum type""" if node.name in big_endian: template = self.environment.get_template("encoder/enum_be.j2") else: template = self.environment.get_template("encoder/enum.j2") print(template.render(name=node.name)) def emit_maxsize(self, node: _XdrEnum) -> None: """Emit one maxsize macro for an XDR enum type""" macro_name = get_header_name().upper() + "_" + node.name + "_sz" template = self.environment.get_template("maxsize/enum.j2") print( template.render( macro=macro_name, width=" + ".join(node.symbolic_width()), ) )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
You can’t perform that action at this time.