Commit 1ed91801 authored by Daniel Egger's avatar Daniel Egger Committed by Daniel Egger

Convert ugly comments into named structure fields. Much cleaner and less

2001-12-02  Daniel Egger  <degger@fhm.edu>

	* app/gimprc.c: Convert ugly comments into named structure fields.
	Much cleaner and less errorprone though may cause troubles on
	older compilers and then needs to be reverted. Please report!

	* app/base/base-types.h: Add FIXME reminder.

	* app/base/gimplut.c: Use CLAMP macro instead of if-cascade.

	* app/base/temp-buf.c: Remove duplicated calculations and simplify
	checks.

	* app/base/tile-manager.c:
	- (tile_manager_get_tile_num): Return success and take an additional
	  pointer for the tilenumber.
	- Simplify logic in the rest of the file as a result.
	- Remove rotten debugging cruft.

	* app/core/gimpbrushgenerated.c: Fix two stylistic nits.

	* app/app_procs.c: Include <stdlib.h> for exit () prototype.

	* app/core/gimpdrawable-blend.c: Include <stdlib.h> for abs ()
	prototype.

	* app/display/gimpdisplay.c: Include <string.h> for memcpy ()
	prototype.

	* app/core/gimpimage-convert.c: (HIST_RGB): First parameter is
	not const. Fixes a gcc warning for a wrong return value.

	* libgimpwidgets/gimpunitmenu.c
	* app/core/gimpunit.c: Add suggested (by gcc 3.1 cvs) parentheses
	to group correct logic tests together.

	* app/paint-funcs/paint-funcs-generic.h: Fix my HAS_ALPHA macro
	to avoid gcc 3.1 cvs warning.

	* app/gimprc.h
	* pathP.h
	* base-config.h
	* app/base/boundary.h
	* app/base/gimplut.[ch]
	* app/base/pixel-region.h
	* app/base/pixel-surround.[ch]
	* app/base/temp-buf.[ch]
	* app/base/tile-manager-private.h
	* app/base/tile-manager.c
	* app/base/tile-private.h
	* app/base/tile.[ch]
	* app/core/gimp.h
	* app/core/gimpbrushgenerated.h
	* app/core/gimpbrushpipe.h
	* app/core/gimpchannel.[ch]
	* app/core/gimpcontainer.h
	* app/core/gimpcoreconfig.h
	* app/core/gimpdata.h
	* app/core/gimpdatafactory.[ch]
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable.[ch]
	* app/core/gimpimage.h
	* app/core/gimpimagefile.h
	* app/core/gimplayer.h
	* app/core/gimplayermask.h
	* app/core/gimpmoduleinfo.h
	* app/core/gimppalette.h
	* app/core/gimpundo.h
	* app/display/gimpdisplay.h
	* app/display/gimpdisplayshell-selection.h
	* app/display/gimpdisplayshell.h
	* app/gui/brush-select.h
	* app/gui/gradient-editor.h
	* app/gui/gradient-select.h
	* app/gui/info-dialog.h
	* app/gui/resize-dialog.h
	* app/tools/gimpbezierselecttool.h
	* app/tools/gimpcolorbalancetool.h
	* app/tools/gimpcolorpickertool.h
	* app/tools/gimpcurvestool.h
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimpfreeselecttool.h
	* app/tools/gimpfuzzyselecttool.h
	* app/tools/gimphuesaturationtool.h
	* app/tools/gimpinktool-blob.h
	* app/tools/gimpinktool.h
	* app/tools/gimpiscissorstool.h
	* app/tools/gimpmagnifytool.h
	* app/tools/gimpmeasuretool.h
	* app/tools/gimppainttool.h
	* app/tools/gimppathtool.h
	* app/tools/gimprectselecttool.h
	* app/tools/gimpthresholdtool.h
	* app/tools/gimptool.h
	* app/tools/gimptransformtool.h
	* app/tools/path_toolP.h
	* app/widgets/gimpbrushfactoryview.h
	* app/widgets/gimpconstrainedhwrapbox.h
	* app/widgets/gimpcontainermenu.h
	* app/widgets/gimpcontainerview.h
	* app/widgets/gimpdialogfactory.h
	* app/widgets/gimpimagedock.h
	* app/widgets/gimplistitem.h
	* app/widgets/gimpmenuitem.h
	* app/widgets/gimpnavigationpreview.h
	* app/widgets/gimppreview.h: Unsignify lots of variables and
	parameters and use bitfields in structs where possible. First
	part of a huge cleanup all over the code...
parent 6d0e5c34
2001-12-02 Daniel Egger <degger@fhm.edu>
* app/gimprc.c: Convert ugly comments into named structure fields.
Much cleaner and less errorprone though may cause troubles on
older compilers and then needs to be reverted. Please report!
* app/base/base-types.h: Add FIXME reminder.
* app/base/gimplut.c: Use CLAMP macro instead of if-cascade.
* app/base/temp-buf.c: Remove duplicated calculations and simplify
checks.
* app/base/tile-manager.c:
- (tile_manager_get_tile_num): Return success and take an additional
pointer for the tilenumber.
- Simplify logic in the rest of the file as a result.
- Remove rotten debugging cruft.
* app/core/gimpbrushgenerated.c: Fix two stylistic nits.
* app/app_procs.c: Include <stdlib.h> for exit () prototype.
* app/core/gimpdrawable-blend.c: Include <stdlib.h> for abs ()
prototype.
* app/display/gimpdisplay.c: Include <string.h> for memcpy ()
prototype.
* app/core/gimpimage-convert.c: (HIST_RGB): First parameter is
not const. Fixes a gcc warning for a wrong return value.
* libgimpwidgets/gimpunitmenu.c
* app/core/gimpunit.c: Add suggested (by gcc 3.1 cvs) parentheses
to group correct logic tests together.
* app/paint-funcs/paint-funcs-generic.h: Fix my HAS_ALPHA macro
to avoid gcc 3.1 cvs warning.
* app/gimprc.h
* pathP.h
* base-config.h
* app/base/boundary.h
* app/base/gimplut.[ch]
* app/base/pixel-region.h
* app/base/pixel-surround.[ch]
* app/base/temp-buf.[ch]
* app/base/tile-manager-private.h
* app/base/tile-manager.c
* app/base/tile-private.h
* app/base/tile.[ch]
* app/core/gimp.h
* app/core/gimpbrushgenerated.h
* app/core/gimpbrushpipe.h
* app/core/gimpchannel.[ch]
* app/core/gimpcontainer.h
* app/core/gimpcoreconfig.h
* app/core/gimpdata.h
* app/core/gimpdatafactory.[ch]
* app/core/gimpdrawable-blend.c
* app/core/gimpdrawable.[ch]
* app/core/gimpimage.h
* app/core/gimpimagefile.h
* app/core/gimplayer.h
* app/core/gimplayermask.h
* app/core/gimpmoduleinfo.h
* app/core/gimppalette.h
* app/core/gimpundo.h
* app/display/gimpdisplay.h
* app/display/gimpdisplayshell-selection.h
* app/display/gimpdisplayshell.h
* app/gui/brush-select.h
* app/gui/gradient-editor.h
* app/gui/gradient-select.h
* app/gui/info-dialog.h
* app/gui/resize-dialog.h
* app/tools/gimpbezierselecttool.h
* app/tools/gimpcolorbalancetool.h
* app/tools/gimpcolorpickertool.h
* app/tools/gimpcurvestool.h
* app/tools/gimpdodgeburntool.c
* app/tools/gimpfreeselecttool.h
* app/tools/gimpfuzzyselecttool.h
* app/tools/gimphuesaturationtool.h
* app/tools/gimpinktool-blob.h
* app/tools/gimpinktool.h
* app/tools/gimpiscissorstool.h
* app/tools/gimpmagnifytool.h
* app/tools/gimpmeasuretool.h
* app/tools/gimppainttool.h
* app/tools/gimppathtool.h
* app/tools/gimprectselecttool.h
* app/tools/gimpthresholdtool.h
* app/tools/gimptool.h
* app/tools/gimptransformtool.h
* app/tools/path_toolP.h
* app/widgets/gimpbrushfactoryview.h
* app/widgets/gimpconstrainedhwrapbox.h
* app/widgets/gimpcontainermenu.h
* app/widgets/gimpcontainerview.h
* app/widgets/gimpdialogfactory.h
* app/widgets/gimpimagedock.h
* app/widgets/gimplistitem.h
* app/widgets/gimpmenuitem.h
* app/widgets/gimpnavigationpreview.h
* app/widgets/gimppreview.h: Unsignify lots of variables and
parameters and use bitfields in structs where possible. First
part of a huge cleanup all over the code...
2001-12-01 Michael Natterer <mitch@gimp.org>
* app/errors.c: forgot a "return".
......
......@@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
......
......@@ -29,7 +29,7 @@ struct _GimpBaseConfig
guint tile_cache_size;
gboolean stingy_memory_use;
InterpolationType interpolation_type;
gint num_processors;
guint num_processors;
};
......
......@@ -24,7 +24,7 @@
/* magic constants */
/* FIXME: Remove magic constants! */
#define MAX_CHANNELS 4
#define GRAY_PIX 0
......
......@@ -33,8 +33,8 @@ struct _BoundSeg
gint y1;
gint x2;
gint y2;
gboolean open;
gboolean visited;
guint open : 1;
guint visited : 1;
};
......
......@@ -67,8 +67,8 @@ struct _ColorBalanceDialog
guchar g_lookup[256];
guchar b_lookup[256];
gboolean preserve_luminosity;
gboolean preview;
guint preserve_luminosity : 1;
guint preview : 1;
GimpTransferMode application_mode;
};
......
......@@ -70,7 +70,7 @@ struct _CurvesDialog
gint color;
gint channel;
gboolean preview;
guint preview : 1;
gint grab_point;
gint last;
......
......@@ -58,9 +58,9 @@ void
gimp_lut_setup (GimpLut *lut,
GimpLutFunc func,
void *user_data,
gint nchannels)
guint nchannels)
{
gint i, v;
guint i, v;
gdouble val;
if (lut->luts)
......@@ -83,12 +83,7 @@ gimp_lut_setup (GimpLut *lut,
/* to add gamma correction use func(v ^ g) ^ 1/g instead. */
val = 255.0 * func (user_data, lut->nchannels, i, v/255.0) + 0.5;
if (val < 0.0)
lut->luts[i][v] = 0;
else if (val >= 255.0)
lut->luts[i][v] = 255;
else
lut->luts[i][v] = val;
lut->luts[i][v] = CLAMP (val, 0, 255);
}
}
}
......@@ -97,7 +92,7 @@ void
gimp_lut_setup_exact (GimpLut *lut,
GimpLutFunc func,
void *user_data,
gint nchannels)
guint nchannels)
{
gimp_lut_setup (lut, func, user_data, nchannels);
}
......@@ -107,7 +102,7 @@ gimp_lut_process (GimpLut *lut,
PixelRegion *srcPR,
PixelRegion *destPR)
{
gint h, width, src_r_i, dest_r_i;
guint h, width, src_r_i, dest_r_i;
guchar *src, *dest;
guchar *lut0 = NULL, *lut1 = NULL, *lut2 = NULL, *lut3 = NULL;
......@@ -189,7 +184,7 @@ void
gimp_lut_process_inline (GimpLut *lut,
PixelRegion *srcPR)
{
gint h, width, src_r_i;
guint h, width, src_r_i;
guchar *src;
guchar *lut0 = NULL, *lut1 = NULL, *lut2 = NULL, *lut3 = NULL;
......
......@@ -25,7 +25,7 @@
struct _GimpLut
{
guchar **luts;
gint nchannels;
guint nchannels;
};
/* TODO: the GimpLutFunc should really be passed the ColorModel of the region,
......@@ -36,18 +36,17 @@ struct _GimpLut
* and do no correction as this will be handled by gimp_lut_setup
*/
typedef gfloat (*GimpLutFunc) (gpointer user_data,
gint nchannels,
gint channel,
guint nchannels,
guint channel,
gfloat value);
GimpLut * gimp_lut_new (void);
void gimp_lut_free (GimpLut *lut);
void gimp_lut_setup (GimpLut *lut,
GimpLutFunc func,
gpointer user_data,
gint nchannels);
guint nchannels);
/* gimp_lut_setup_exact is currently identical to gimp_lut_setup. It
* however is guaranteed to never perform any interpolation or gamma
......@@ -56,7 +55,7 @@ void gimp_lut_setup (GimpLut *lut,
void gimp_lut_setup_exact (GimpLut *lut,
GimpLutFunc func,
gpointer user_data,
gint nchannels);
guint nchannels);
void gimp_lut_process (GimpLut *lut,
PixelRegion *srcPR,
......@@ -78,5 +77,4 @@ void gimp_lut_process_2 (PixelRegion *srcPR,
PixelRegion *destPR,
GimpLut *lut);
#endif /* __GIMP_LUT_H__ */
......@@ -77,7 +77,7 @@ struct _HueSaturationDialog
gdouble saturation[7];
HueRange hue_partition;
gboolean preview;
guint preview : 1;
};
......
......@@ -27,14 +27,14 @@ struct _PixelRegion
Tile *curtile; /* current tile */
gint offx; /* tile offsets */
gint offy; /* tile offsets */
gint rowstride; /* bytes per pixel row */
guint rowstride; /* bytes per pixel row */
gint x; /* origin */
gint y; /* origin */
gint w; /* width of region */
gint h; /* height of region */
gint bytes; /* bytes per pixel */
gboolean dirty; /* will this region be dirtied? */
gint process_count; /* used internally */
guint w; /* width of region */
guint h; /* height of region */
guint bytes; /* bytes per pixel */
guint dirty : 1; /* will this region be dirtied? */
guint process_count; /* used internally */
};
struct _PixelRegionHolder
......@@ -43,18 +43,18 @@ struct _PixelRegionHolder
guchar *original_data;
gint startx;
gint starty;
gint count;
guint count;
};
struct _PixelRegionIterator
{
GSList *pixel_regions;
gint dirty_tiles;
gint region_width;
gint region_height;
gint portion_width;
gint portion_height;
gint process_count;
guint dirty_tiles;
guint region_width;
guint region_height;
guint portion_width;
guint portion_height;
guint process_count;
};
......
......@@ -31,11 +31,11 @@
void
pixel_surround_init (PixelSurround *ps,
TileManager *tm,
gint w,
gint h,
guint w,
guint h,
guchar bg[MAX_CHANNELS])
{
gint i;
guint i;
for (i = 0; i < MAX_CHANNELS; ++i)
{
......@@ -55,10 +55,10 @@ pixel_surround_init (PixelSurround *ps,
guchar *
pixel_surround_lock (PixelSurround *ps,
gint x,
gint y)
guint x,
guint y)
{
gint i, j;
guint i, j;
guchar *k;
guchar *ptr;
......@@ -119,7 +119,7 @@ pixel_surround_lock (PixelSurround *ps,
return ps->buff;
}
gint
guint
pixel_surround_rowstride (PixelSurround *ps)
{
return ps->row_stride;
......
......@@ -29,19 +29,19 @@ typedef struct _PixelSurround
Tile *tile;
TileManager *mgr;
guchar *buff;
gint buff_size;
gint bpp;
gint w;
gint h;
guint buff_size;
guint bpp;
guint w;
guint h;
guchar bg[MAX_CHANNELS];
gint row_stride;
guint row_stride;
} PixelSurround;
void pixel_surround_init (PixelSurround *ps,
TileManager *tm,
gint w,
gint h,
guint w,
guint h,
guchar bg[MAX_CHANNELS]);
/* return a pointer to a buffer which contains all the surrounding pixels
......@@ -49,10 +49,10 @@ void pixel_surround_init (PixelSurround *ps,
* otherwise just copy into our own malloced buffer and return that
*/
guchar * pixel_surround_lock (PixelSurround *ps,
gint x,
gint y);
guint x,
guint y);
gint pixel_surround_rowstride (PixelSurround *ps);
guint pixel_surround_rowstride (PixelSurround *ps);
void pixel_surround_release (PixelSurround *ps);
......
......@@ -54,7 +54,7 @@ static void temp_buf_to_gray (TempBuf *src_buf,
/* Memory management */
static guchar *
static inline guchar *
temp_buf_allocate (guint size)
{
guchar *data;
......@@ -73,7 +73,7 @@ temp_buf_to_color (TempBuf *src_buf,
{
guchar *src;
guchar *dest;
glong num_bytes;
gulong num_bytes;
src = temp_buf_data (src_buf);
dest = temp_buf_data (dest_buf);
......@@ -97,7 +97,7 @@ temp_buf_to_gray (TempBuf *src_buf,
{
guchar *src;
guchar *dest;
glong num_bytes;
gulong num_bytes;
gfloat pix;
src = temp_buf_data (src_buf);
......@@ -117,19 +117,20 @@ temp_buf_to_gray (TempBuf *src_buf,
}
TempBuf *
temp_buf_new (gint width,
gint height,
gint bytes,
temp_buf_new (guint width,
guint height,
guint bytes,
gint x,
gint y,
guchar *col)
{
glong i;
gint j;
guchar *data;
TempBuf *temp;
const gulong size = width * height * bytes;
glong i;
gint j;
guchar *data;
TempBuf *temp;
g_return_val_if_fail (width > 0 && height > 0, NULL);
g_return_val_if_fail (size > 0, NULL);
temp = g_new (TempBuf, 1);
......@@ -141,7 +142,7 @@ temp_buf_new (gint width,
temp->swapped = FALSE;
temp->filename = NULL;
temp->data = data = temp_buf_allocate (width * height * bytes);
temp->data = data = temp_buf_allocate (size);
/* initialize the data */
if (col)
......@@ -197,8 +198,8 @@ temp_buf_new (gint width,
parameters into a newly allocated tempbuf */
TempBuf *
temp_buf_new_check (gint width,
gint height,
temp_buf_new_check (guint width,
guint height,
GimpCheckType check_type,
GimpCheckSize check_size)
{
......@@ -207,7 +208,7 @@ temp_buf_new_check (gint width,
guchar check_shift = 0;
guchar fg_color = 0;
guchar bg_color = 0;
gint i, j;
guint i, j;
g_return_val_if_fail (width > 0 && height > 0, NULL);
......@@ -308,18 +309,16 @@ temp_buf_copy (TempBuf *src,
TempBuf *
temp_buf_resize (TempBuf *buf,
gint bytes,
guint bytes,
gint x,
gint y,
gint width,
gint height)
guint width,
guint height)
{
gint size;
g_return_val_if_fail (width > 0 && height > 0, NULL);
/* calculate the requested size */
size = width * height * bytes;
const gulong size = width * height * bytes;
g_return_val_if_fail (size > 0, NULL);
/* First, configure the canvas buffer */
if (!buf)
......@@ -350,11 +349,11 @@ temp_buf_resize (TempBuf *buf,
TempBuf *
temp_buf_scale (TempBuf *src,
gint new_width,
gint new_height)
guint new_width,
guint new_height)
{
gint loop1;
gint loop2;
guint loop1;
guint loop2;
gdouble x_ratio;
gdouble y_ratio;
guchar *src_data;
......@@ -403,8 +402,8 @@ temp_buf_copy_area (TempBuf *src,
TempBuf *dest,
gint x,
gint y,
gint width,
gint height,
guint width,
guint height,
gint dest_x,
gint dest_y)
{
......@@ -508,8 +507,8 @@ temp_buf_data_clear (TempBuf *temp_buf)
MaskBuf *
mask_buf_new (gint width,
gint height)
mask_buf_new (guint width,
guint height)
{
static guchar empty = 0;
......
......@@ -22,48 +22,48 @@
struct _TempBuf
{
gint bytes; /* the necessary info */
gint width;
gint height;
gint x, y; /* origin of data source */
guint width;
guint height;
gint x, y; /* origin of data source */
gboolean swapped; /* flag indicating whether buf is cached to disk */
gchar *filename; /* filename of cached information */
guint bytes : 4; /* the necessary info */
guint swapped : 1; /* flag indicating whether buf is cached to disk */
gchar *filename; /* filename of cached information */
guchar *data; /* The data buffer. Do never access this field
guchar *data; /* The data buffer. Do never access this field
directly, use temp_buf_data() instead !! */
};
/* The temp buffer functions */
TempBuf * temp_buf_new (gint width,
gint height,
gint bytes,
TempBuf * temp_buf_new (guint width,
guint height,
guint bytes,
gint x,
gint y,
guchar *col);
TempBuf * temp_buf_new_check (gint width,
gint height,
TempBuf * temp_buf_new_check (guint width,
guint height,
GimpCheckType check_type,
GimpCheckSize check_size);
TempBuf * temp_buf_copy (TempBuf *src,
TempBuf *dest);
TempBuf * temp_buf_resize (TempBuf *buf,
gint bytes,
guint bytes,
gint x,
gint y,
gint width,
gint height);
guint width,
guint height);
TempBuf * temp_buf_scale (TempBuf *buf,
gint width,
gint height);
guint width,
guint height);
TempBuf * temp_buf_copy_area (TempBuf *src,
TempBuf *dest,
gint x,
gint y,
gint width,
gint height,
guint width,
guint height,
gint dest_x,
gint dest_y);
void temp_buf_free (TempBuf *buf);
......@@ -72,8 +72,8 @@ guchar * temp_buf_data_clear (TempBuf *buf);
/* The mask buffer functions */
MaskBuf * mask_buf_new (gint width,
gint height);
MaskBuf * mask_buf_new (guint width,
guint height);
void mask_buf_free (MaskBuf *mask_buf);
guchar * mask_buf_data (MaskBuf *mask_buf);
guchar * mask_buf_data_clear (MaskBuf *mask_buf);
......
......@@ -57,14 +57,14 @@ struct _ThresholdDialog
GimpHistogramView *histogram;
GimpHistogram *hist;
GimpDrawable *drawable;
ImageMap *image_map;
GimpDrawable *drawable;
ImageMap *image_map;
gint color;
gint low_threshold;
gint high_threshold;
gint color;
gint low_threshold;
gint high_threshold;
gboolean preview;
guint preview : 1;
};
......
......@@ -24,12 +24,12 @@ struct _TileManager
{
gint x, y; /* tile manager offsets */
gint width; /* the width of the tiled area */
gint height; /* the height of the tiled area */
gint bpp; /* the bpp of each tile */
guint width; /* the width of the tiled area */
guint height; /* the height of the tiled area */
guint bpp; /* the bpp of each tile */
gint ntile_rows; /* the number of tiles in each row */
gint ntile_cols; /* the number of tiles in each columns */
guint ntile_rows; /* the number of tiles in each row */
guint ntile_cols; /* the number of tiles in each columns */
Tile **tiles; /* the tiles for this level */
TileValidateProc validate_proc; /* this proc is called when an attempt
......@@ -45,11 +45,11 @@ struct _PixelDataHandlePrivate
{
PixelDataHandle public;
TileManager *tm;
gint x1, x2, y1, y2;
gboolean readable;
gboolean writeable;
gboolean local_buffer;
Tile *tile;
gint x1, x2, y1, y2;
guint readable : 1;
guint writeable : 1;
guint local_buffer : 1;
};
......
......@@ -32,15 +32,17 @@
#include "tile-swap.h"
static gint tile_manager_get_tile_num (TileManager *tm,
gint xpixel,
gint ypixel);
static inline gboolean
tile_manager_get_tile_num (TileManager *tm,
gint xpixel,
gint ypixel,
guint *tile_num);
TileManager *
tile_manager_new (gint toplevel_width,
gint toplevel_height,
gint bpp)
tile_manager_new (guint toplevel_width,
guint toplevel_height,
guint bpp)
{
TileManager *tm;
gint width;
......@@ -69,8 +71,8 @@ tile_manager_new (gint toplevel_width,
void
tile_manager_destroy (TileManager *tm)
{