1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

wrlib: add explicit type definition in API to allow compiler Type Checks (1/3)

When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.

This patch adds types for the configuration fields in the RContextAttributes
structure.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-06-14 19:34:07 +02:00
committed by Carlos R. Mafra
parent 96a6e4da1e
commit eb3f0b12f8
4 changed files with 27 additions and 32 deletions

View File

@@ -1213,7 +1213,8 @@ int main(int argc, char **argv)
char *back_color = "gray20";
char *image_name = NULL;
char *domain = "WindowMaker";
int update = 0, cpc = 4, render_mode = RDitheredRendering, obey_user = 0;
int update = 0, cpc = 4, obey_user = 0;
RRenderingMode render_mode = RDitheredRendering;
char *texture = NULL;
int workspace = -1;

View File

@@ -247,7 +247,7 @@ static double Mitchell_filter(double t)
static double (*filterf)(double) = Mitchell_filter;
static double fwidth = Mitchell_support;
void wraster_change_filter(int type)
void wraster_change_filter(RScalingFilter type)
{
switch (type) {
case RBoxFilter:

View File

@@ -24,7 +24,7 @@
/*
* Function to change the smoothing filter used for image scaling (RSmoothScaleImage)
*/
void wraster_change_filter(int type);
void wraster_change_filter(RScalingFilter type);
#endif

View File

@@ -82,30 +82,43 @@ extern "C" {
/* image display modes */
typedef enum {
RDitheredRendering = 0,
RBestMatchRendering = 1
} RRenderingMode;
/* std colormap usage/creation modes */
enum {
RUseStdColormap, /* default. fallbacks to RIgnore.. if
there is none defined */
RCreateStdColormap,
RIgnoreStdColormap
};
typedef enum {
RUseStdColormap, /* default: fallbacks to RIgnore if there is none defined */
RCreateStdColormap,
RIgnoreStdColormap
} RStdColormapMode;
/* smoothed scaling filter types */
typedef enum {
RBoxFilter,
RTriangleFilter,
RBellFilter,
RBSplineFilter,
RLanczos3Filter,
RMitchellFilter
} RScalingFilter;
typedef struct RContextAttributes {
int flags;
int render_mode;
RRenderingMode render_mode;
int colors_per_channel; /* for PseudoColor */
float rgamma; /* gamma correction for red, */
float ggamma; /* green, */
float bgamma; /* and blue */
VisualID visualid; /* visual ID to use */
int use_shared_memory; /* True of False */
int scaling_filter;
int standard_colormap_mode; /* what to do with std cma */
RScalingFilter scaling_filter;
RStdColormapMode standard_colormap_mode; /* what to do with std cma */
} RContextAttributes;
@@ -211,24 +224,6 @@ typedef struct RXImage {
} RXImage;
/* image display modes */
enum {
RDitheredRendering = 0,
RBestMatchRendering = 1
};
/* smoothed scaling filter types */
enum {
RBoxFilter,
RTriangleFilter,
RBellFilter,
RBSplineFilter,
RLanczos3Filter,
RMitchellFilter
};
/* note that not all operations are supported in all functions */
enum {
RClearOperation, /* clear with 0 */
@@ -481,4 +476,3 @@ extern int RErrorCode;
#endif /* __cplusplus */
#endif