-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically Detect Template Types #191
Comments
Also, it would be nice to be able to scan additional headers to look for template usages. |
Took a stab at this. The biggest issue is getting the correct qualname for each type and I don't think that info is available. |
For the future: def extract_templated_types(atype: str):
match = re.fullmatch(r"(.*?)<(.*)>", atype)
if match:
template_type = match.group(1)
template_params = match.group(2)
yield (template_type.strip(), template_params.strip())
start = 0
in_angle_brackets = False
for i, c in enumerate(template_params):
if c == '<':
in_angle_brackets = True
elif c == '>':
in_angle_brackets = False
elif c == ',' and not in_angle_brackets:
yield from extract_templated_types(template_params[start:i])
start = i + 1
yield from extract_templated_types(template_params[start:]) |
You probably should now be able to do this pretty easily with the data from cxxheaderparser. |
When headers are scanned, the types used in a template should be cached. This can be used automatically fill in the template_params in create-gen.
For example (ctre pro),
CoreTalonFX.hpp
has a functionStatusSignalValue<units::angle::turn_t> &GetPosition();
From this, we know that
StatusSignalValue
needs aunits::angle::turn_t
template param.Then,
SignalStatusValue.hpp
has a functionSignalMeasurement<T> GetDataCopy() const {...}
From this, we can propogate all of
SignalStatusValue
's template_params includingunits::angle::turn_t
toSignalMeasurement
.This would require all headers to be scanned before yaml files are written.
The text was updated successfully, but these errors were encountered: