C++ attributes in a struct are often assigned a default value, like ImPlotSpec in ImPlot 1.0:
struct ImPlotSpec {
ImVec4 LineColor = IMPLOT_AUTO_COL;
ImU32* LineColors = nullptr;
float LineWeight = 1.0f;
ImVec4 FillColor = IMPLOT_AUTO_COL;
ImU32* FillColors = nullptr;
float FillAlpha = 1.0f;
ImPlotMarker Marker = ImPlotMarker_None;
float MarkerSize = 4;
float* MarkerSizes = nullptr;
ImVec4 MarkerLineColor = IMPLOT_AUTO_COL;
ImU32* MarkerLineColors = nullptr;
ImVec4 MarkerFillColor = IMPLOT_AUTO_COL;
ImU32* MarkerFillColors = nullptr;
float Size = 4;
int Offset = 0;
int Stride = IMPLOT_AUTO;
ImPlotItemFlags Flags = ImPlotItemFlags_None;
// [...]
};
This is a convenient way to know the default value of the different attributes, without looking in the constructor.
It would be nice if the generator could include the default value, if any, in the generated structs_and_enums.json.
For the cimplot example, that would give something like:
"ImPlotSpec": [
{
"name": "LineColor",
"type": "ImVec4",
"default": "IMPLOT_AUTO_COL"
},
{
"name": "LineColors",
"type": "ImU32*",
"default": "nullptr"
},
...
]
Having these default values in the JSON is not necessary at the moment because the ImPlotSpec_ImPlotSpec performs the initialization to the default values; but it would be nice for completeness, or to generate documentation for example.
C++ attributes in a
structare often assigned a default value, likeImPlotSpecin ImPlot 1.0:This is a convenient way to know the default value of the different attributes, without looking in the constructor.
It would be nice if the generator could include the default value, if any, in the generated
structs_and_enums.json.For the
cimplotexample, that would give something like:Having these default values in the JSON is not necessary at the moment because the
ImPlotSpec_ImPlotSpecperforms the initialization to the default values; but it would be nice for completeness, or to generate documentation for example.