rustorb-idl 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: rustorb-idl
3
+ Version: 0.1.0
4
+ Summary: IDL code generator for rustorb
5
+ License: GPL-3.0-or-later
6
+ Project-URL: Homepage, https://github.com/rustorb/rustorb
7
+ Project-URL: Documentation, https://github.com/rustorb/rustorb/blob/main/docs/getting-started.md
8
+ Project-URL: Changelog, https://github.com/rustorb/rustorb/blob/main/CHANGELOG.md
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: System :: Networking
11
+ Classifier: Topic :: Software Development :: Object Brokering
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: idl_parser<0.7,>=0.6.2
15
+
16
+ # rustorb-idl
17
+
18
+ The IDL compiler of [rustorb](https://github.com/rustorb/rustorb), a CORBA
19
+ ORB with its core written in Rust. It reads IDL with
20
+ [idl_parser](https://github.com/sugarsweetrobotics/idl_parser) and writes
21
+ stubs and skeletons for:
22
+
23
+ - `-bpython`: the standard IDL to Python mapping, in the layout of
24
+ omniidl -bpython (for the `rustorb` package)
25
+ - `-brust`: Rust (for `rustorb-core`; or `rustorb-codegen` in `build.rs`)
26
+ - `-bc++11`: the IDL to C++11 mapping (for the rustorb C++ binding)
27
+ - `-bjava`: the IDL to Java mapping (for the rustorb Java binding)
28
+
29
+ ```sh
30
+ pip install rustorb-idl
31
+ rustorb-idl -bpython -C gen Echo.idl
32
+ rustorb-idl -bc++11 -C gen Echo.idl "$(rustorb-idl --idl-dir)/CosNaming.idl"
33
+ ```
34
+
35
+ The options follow omniidl (`-I`, `-D`, `-C`, `-Wb...`; see
36
+ `rustorb-idl --help`). `rustorb-idl --idl-dir` prints the directory of the
37
+ standard IDL files that come with it (CosNaming.idl), which is also searched
38
+ for `#include`.
39
+
40
+ Licensed under GPL-3.0-or-later. Code produced by the generator is not
41
+ covered by this license.
@@ -0,0 +1,26 @@
1
+ # rustorb-idl
2
+
3
+ The IDL compiler of [rustorb](https://github.com/rustorb/rustorb), a CORBA
4
+ ORB with its core written in Rust. It reads IDL with
5
+ [idl_parser](https://github.com/sugarsweetrobotics/idl_parser) and writes
6
+ stubs and skeletons for:
7
+
8
+ - `-bpython`: the standard IDL to Python mapping, in the layout of
9
+ omniidl -bpython (for the `rustorb` package)
10
+ - `-brust`: Rust (for `rustorb-core`; or `rustorb-codegen` in `build.rs`)
11
+ - `-bc++11`: the IDL to C++11 mapping (for the rustorb C++ binding)
12
+ - `-bjava`: the IDL to Java mapping (for the rustorb Java binding)
13
+
14
+ ```sh
15
+ pip install rustorb-idl
16
+ rustorb-idl -bpython -C gen Echo.idl
17
+ rustorb-idl -bc++11 -C gen Echo.idl "$(rustorb-idl --idl-dir)/CosNaming.idl"
18
+ ```
19
+
20
+ The options follow omniidl (`-I`, `-D`, `-C`, `-Wb...`; see
21
+ `rustorb-idl --help`). `rustorb-idl --idl-dir` prints the directory of the
22
+ standard IDL files that come with it (CosNaming.idl), which is also searched
23
+ for `#include`.
24
+
25
+ Licensed under GPL-3.0-or-later. Code produced by the generator is not
26
+ covered by this license.
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rustorb-idl"
7
+ version = "0.1.0"
8
+ description = "IDL code generator for rustorb"
9
+ readme = "README.md"
10
+ license = { text = "GPL-3.0-or-later" }
11
+ requires-python = ">=3.9"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Topic :: System :: Networking",
15
+ "Topic :: Software Development :: Object Brokering",
16
+ ]
17
+ # idl_parser 0.6.2 is the first release with the fixes the generator needs
18
+ # (sugarsweetrobotics/idl_parser#133-#144, #159); CI checks out the same commit.
19
+ dependencies = ["idl_parser>=0.6.2,<0.7"]
20
+
21
+ [project.urls]
22
+ Homepage = "https://github.com/rustorb/rustorb"
23
+ Documentation = "https://github.com/rustorb/rustorb/blob/main/docs/getting-started.md"
24
+ Changelog = "https://github.com/rustorb/rustorb/blob/main/CHANGELOG.md"
25
+
26
+ [project.scripts]
27
+ rustorb-idl = "rustorb_idl.cli:main_exit"
28
+
29
+ [tool.setuptools]
30
+ packages = ["rustorb_idl"]
31
+
32
+ [tool.setuptools.package-data]
33
+ rustorb_idl = ["idl/*.idl"]
@@ -0,0 +1,7 @@
1
+ """rustorb-idl: the IDL code generator of rustorb.
2
+
3
+ Reads IDL with idl_parser and writes code for rustorb. Licensed under
4
+ GPL-3.0-or-later; the code it writes is not covered by this license.
5
+ """
6
+
7
+ __version__ = "0.1.0"
@@ -0,0 +1,3 @@
1
+ from .cli import main_exit
2
+
3
+ main_exit()
@@ -0,0 +1,142 @@
1
+ """Command line: ``rustorb-idl -bBACKEND [options] FILE.idl...``.
2
+
3
+ The options follow omniidl where they mean the same thing:
4
+
5
+ -bpython Python stubs and skeletons (standard Python mapping)
6
+ -bc++11 C++ stubs and skeletons (IDL to C++11 mapping); also
7
+ -bcxx11
8
+ -bjava Java stubs and skeletons (IDL to Java mapping)
9
+ -brust Rust stubs and skeletons (docs/rust-mapping.md)
10
+ -I DIR look for #include files in DIR
11
+ -D NAME[=VALUE] define a preprocessor macro
12
+ -C DIR write the output under DIR (default: the current directory)
13
+ -Wbglobal=NAME the module for definitions outside modules (_GlobalIDL)
14
+ -Wbpackage=PKG put the Python modules in the package PKG (python), or
15
+ every Java package under PKG (java)
16
+ -Wbno_stubs do not write the .pyi type stubs (python)
17
+ -Wbh=SUFFIX the header suffix (c++11, default .hh)
18
+ -Wbs=SUFFIX the source suffix (c++11, default .cc)
19
+ -Wbextern=MODULE=PATH
20
+ refer to the definitions of the IDL module MODULE under
21
+ the Rust path PATH instead of writing them (rust)
22
+ -Wbcore=PATH the path of rustorb-core (rust, default ::rustorb_core)
23
+ -Wbno_rustfmt do not pass the output through rustfmt (rust)
24
+
25
+ The standard IDL files that come with rustorb-idl (CosNaming.idl) are in the
26
+ directory `rustorb-idl --idl-dir` prints, which is also searched for
27
+ #include files after the -I directories.
28
+ """
29
+
30
+ import argparse
31
+ import os
32
+ import sys
33
+
34
+ from . import __version__
35
+ from . import cxx_backend
36
+ from . import frontend
37
+ from . import java_backend
38
+ from . import python_backend
39
+ from . import rust_backend
40
+
41
+
42
+ IDL_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "idl")
43
+
44
+
45
+ def parse_args(argv):
46
+ ap = argparse.ArgumentParser(
47
+ prog="rustorb-idl",
48
+ description="Generate code for rustorb from IDL files.",
49
+ epilog=__doc__.split("\n\n", 1)[1],
50
+ formatter_class=argparse.RawDescriptionHelpFormatter,
51
+ add_help=True,
52
+ )
53
+ ap.add_argument(
54
+ "-b", dest="backend", required=True, metavar="BACKEND", help="the backend: python, c++11, java or rust"
55
+ )
56
+ ap.add_argument("-I", dest="include", action="append", default=[], metavar="DIR")
57
+ ap.add_argument("-D", dest="define", action="append", default=[], metavar="NAME[=VALUE]")
58
+ ap.add_argument("-C", dest="outdir", default=".", metavar="DIR")
59
+ ap.add_argument("-W", dest="backend_options", action="append", default=[], metavar="bOPTION")
60
+ ap.add_argument("--encoding", default=None, help="character encoding of the IDL files")
61
+ ap.add_argument("--version", action="version", version="rustorb-idl " + __version__)
62
+ ap.add_argument(
63
+ "--idl-dir",
64
+ action="store_true",
65
+ help="print the directory of the standard IDL files (CosNaming.idl) and exit",
66
+ )
67
+ ap.add_argument("files", nargs="+", metavar="FILE.idl")
68
+ return ap.parse_args(argv)
69
+
70
+
71
+ def main(argv=None):
72
+ argv = sys.argv[1:] if argv is None else argv
73
+ if "--idl-dir" in argv:
74
+ print(IDL_DIR)
75
+ return 0
76
+ args = parse_args(argv)
77
+ if args.backend == "python":
78
+ backend, options = python_backend, python_backend.Options()
79
+ elif args.backend in ("c++11", "cxx11"):
80
+ backend, options = cxx_backend, cxx_backend.Options()
81
+ elif args.backend == "java":
82
+ backend, options = java_backend, java_backend.Options()
83
+ elif args.backend == "rust":
84
+ backend, options = rust_backend, rust_backend.Options()
85
+ else:
86
+ sys.stderr.write(
87
+ "rustorb-idl: unknown backend %r (python, c++11, java and rust are available)\n" % args.backend
88
+ )
89
+ return 2
90
+ for opt in args.backend_options:
91
+ if backend is python_backend and opt.startswith("bglobal="):
92
+ options.global_module = opt[len("bglobal=") :]
93
+ elif backend is python_backend and opt.startswith("bpackage="):
94
+ options.package = opt[len("bpackage=") :].strip(".")
95
+ elif backend is java_backend and opt.startswith("bpackage="):
96
+ options.package = opt[len("bpackage=") :].strip(".")
97
+ elif backend is python_backend and opt == "bno_stubs":
98
+ options.stubs = False
99
+ elif backend is cxx_backend and opt.startswith("bh="):
100
+ options.header_suffix = opt[len("bh=") :]
101
+ elif backend is cxx_backend and opt.startswith("bs="):
102
+ options.source_suffix = opt[len("bs=") :]
103
+ elif backend is rust_backend and opt.startswith("bextern="):
104
+ module, sep, path = opt[len("bextern=") :].partition("=")
105
+ if not sep or not module or not path:
106
+ sys.stderr.write("rustorb-idl: -Wbextern needs MODULE=PATH\n")
107
+ return 2
108
+ if not path.startswith(("::", "crate::", "super::", "self::")):
109
+ path = "::" + path
110
+ options.externs[module] = path
111
+ elif backend is rust_backend and opt.startswith("bcore="):
112
+ options.core = opt[len("bcore=") :]
113
+ elif backend is rust_backend and opt == "bno_rustfmt":
114
+ options.rustfmt = False
115
+ else:
116
+ sys.stderr.write("rustorb-idl: unknown option -W%s\n" % opt)
117
+ return 2
118
+ defines = {}
119
+ for d in args.define:
120
+ name, _, value = d.partition("=")
121
+ defines[name] = value or "1"
122
+ status = 0
123
+ for path in args.files:
124
+ try:
125
+ spec = frontend.load(path, args.include + [IDL_DIR], defines, args.encoding)
126
+ if backend is python_backend:
127
+ generator = python_backend.PythonBackend(spec, options)
128
+ elif backend is java_backend:
129
+ generator = java_backend.JavaBackend(spec, options)
130
+ elif backend is rust_backend:
131
+ generator = rust_backend.RustBackend(spec, options)
132
+ else:
133
+ generator = cxx_backend.CxxBackend(spec, options)
134
+ backend.write_outputs(generator, args.outdir)
135
+ except frontend.GeneratorError as e:
136
+ sys.stderr.write("rustorb-idl: %s\n" % e)
137
+ status = 1
138
+ return status
139
+
140
+
141
+ def main_exit():
142
+ sys.exit(main())