mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[wpimath] Use jinja for codegen (#3574)
While not really needed for wpimath, it will make more complex codegen in the future significantly easier.
This commit is contained in:
32
wpimath/src/generate/Nat.java.jinja
Normal file
32
wpimath/src/generate/Nat.java.jinja
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.math;
|
||||
|
||||
//CHECKSTYLE.OFF: ImportOrder
|
||||
{% for num in nums %}
|
||||
import edu.wpi.first.math.numbers.N{{ num }};
|
||||
{%- endfor %}
|
||||
//CHECKSTYLE.ON
|
||||
|
||||
/**
|
||||
* A natural number expressed as a java class.
|
||||
* The counterpart to {@link Num} that should be used as a concrete value.
|
||||
*
|
||||
* @param <T> The {@link Num} this represents.
|
||||
*/
|
||||
@SuppressWarnings({"MethodName", "unused"})
|
||||
public interface Nat<T extends Num> {
|
||||
/**
|
||||
* The number this interface represents.
|
||||
*
|
||||
* @return The number backing this value.
|
||||
*/
|
||||
int getNum();
|
||||
{% for num in nums %}
|
||||
static Nat<N{{ num }}> N{{ num }}() {
|
||||
return N{{ num }}.instance;
|
||||
}
|
||||
{% endfor %}
|
||||
}
|
||||
Reference in New Issue
Block a user