[robotpy] Mirror most other subprojects (#8208)

GitOrigin-RevId: ac60fd3cf4a24023184376687da28373d14b781a

This mirrors the robotpy files for the following projects:
- apriltag
- datalog
- hal
- ntcore
- romiVendordep
- wpilibc
- wpimath
- xrpVendordep

This excludes cscore and the halsim wrappers for at this time.

NOTE: This does not hook these projects up to the build system, just simply mirrors the files. The building will take place in a follow up PR to make it easier to review the changes necessary to build.
This commit is contained in:
PJ Reiniger
2025-10-24 01:28:04 -04:00
committed by GitHub
parent 8992dcdc99
commit 44b9cc1398
545 changed files with 27293 additions and 38 deletions

View File

@@ -0,0 +1,64 @@
#!/usr/bin/env python3
import sphinxify
from cxxheaderparser.simple import parse_string
from cxxheaderparser.tokfmt import tokfmt
if __name__ == "__main__":
with open("ntcore/include/ntcore_cpp.h") as fp:
data = parse_string(fp.read())
for c in data.namespace.namespaces["nt"].classes:
if c.class_decl.typename.format() == "struct PubSubOptions":
params = []
docs = []
for f in c.fields:
if f.static or f.name == "structSize":
continue
if f.type.format() == "NT_Publisher":
params.append(
(
"std::optional<std::shared_ptr<nt::Publisher>>",
f.name,
f"{f.name}.has_value() ? {f.name}.value()->GetHandle() : {f.value.format()}",
"std::nullopt",
)
)
else:
v = f.value.format()
if v == "kDefaultPeriodic":
v = f"nt::PubSubOptions::{v}"
params.append((f.type, f.name, f.name, v))
if f.doxygen:
docs.append(f"@param {f.name} {f.doxygen}")
paramstr = ",\n ".join(f"{t.format()} {n}" for t, n, _, _ in params)
args = ",\n ".join(f'py::arg("{n}") = {v}' for _, n, _, v in params)
options = ",\n ".join(f".{fn} = {n}" for _, fn, n, _ in params)
doc = "\n ".join(
sphinxify.process_raw("\n".join(docs)).splitlines()
)
print(
f"""
// autogenerated by gen-pubsub.py
.def(py::init([](
{paramstr}
) -> nt::PubSubOptions {{
return nt::PubSubOptions{{
{options}
}};
}}),
py::kw_only(),
{args},
R"(
{doc}
)"
)
"""
)