[dia] Always use inline funcs, fix some casts
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Always use inline funcs, fix some casts
- Date: Wed, 8 May 2019 12:25:55 +0000 (UTC)
commit 2c96a9401c73c42b8875b777e93c6946232385ab
Author: Zander Brown <zbrown gnome org>
Date: Wed May 8 13:24:05 2019 +0100
Always use inline funcs, fix some casts
Modern glib depends on inline funcs so it doesn't make sense to have them conditional
.gitignore | 1 +
app/app_procs.c | 2 +-
app/layer_dialog.c | 4 +-
app/menus.c | 4 +-
lib/geometry.c | 3 --
lib/geometry.h | 80 ++++++-------------------------
lib/properties.c | 3 --
plug-ins/drs/dia-render-script-renderer.c | 5 +-
plug-ins/postscript/render_eps.c | 2 +-
9 files changed, 25 insertions(+), 79 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index fbe0b161..f6bf4b1c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
build/
build-release/
.vscode
+*.pyc
\ No newline at end of file
diff --git a/app/app_procs.c b/app/app_procs.c
index aab2a590..4dbc5277 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -328,7 +328,7 @@ do_convert(const char *infname,
*/
if (size) {
if (ef == filter_export_get_by_name ("png-libart")) /* the warning we get is appropriate, don't cast */
- ef->export_func(diagdata, ctx, outfname, infname, size);
+ ef->export_func(diagdata, ctx, outfname, infname, (gpointer) size);
else {
g_warning ("--size parameter unsupported for %s filter",
ef->unique_name ? ef->unique_name : "selected");
diff --git a/app/layer_dialog.c b/app/layer_dialog.c
index 70e1384a..6ba490e4 100644
--- a/app/layer_dialog.c
+++ b/app/layer_dialog.c
@@ -1447,7 +1447,7 @@ layer_visibility_change_revert(struct LayerVisibilityChange *change,
for (i = 0; vis != NULL && i < layers->len; vis = g_list_next(vis), i++) {
Layer *layer = (Layer*) g_ptr_array_index(layers, i);
- layer->visible = (gboolean)vis->data;
+ layer->visible = GPOINTER_TO_INT (vis->data);
}
if (vis != NULL || i < layers->len) {
@@ -1484,7 +1484,7 @@ undo_layer_visibility(Diagram *dia, Layer *layer, gboolean exclusive)
for (i = 0; i < layers->len; i++) {
Layer *temp_layer = (Layer *) g_ptr_array_index(layers, i);
- visibilities = g_list_append(visibilities, (gpointer)temp_layer->visible);
+ visibilities = g_list_append(visibilities, GINT_TO_POINTER (temp_layer->visible));
}
change->original_visibility = visibilities;
diff --git a/app/menus.c b/app/menus.c
index 53f4fc33..bd4a2ad9 100644
--- a/app/menus.c
+++ b/app/menus.c
@@ -1226,7 +1226,7 @@ menus_set_recent (GtkActionGroup *actions)
const gchar* aname = gtk_action_get_name (GTK_ACTION (list->data));
id = gtk_ui_manager_new_merge_id (_ui_manager);
- recent_merge_ids = g_slist_prepend (recent_merge_ids, (gpointer) id);
+ recent_merge_ids = g_slist_prepend (recent_merge_ids, GINT_TO_POINTER (id));
gtk_ui_manager_add_ui (_ui_manager, id,
recent_path,
@@ -1246,7 +1246,7 @@ menus_clear_recent (void)
if (recent_merge_ids) {
id = recent_merge_ids;
do {
- gtk_ui_manager_remove_ui (_ui_manager, (guint) id->data);
+ gtk_ui_manager_remove_ui (_ui_manager, GPOINTER_TO_UINT (id->data));
} while (NULL != (id = id->next));
diff --git a/lib/geometry.c b/lib/geometry.c
index 8f4810c8..624d22b8 100644
--- a/lib/geometry.c
+++ b/lib/geometry.c
@@ -24,9 +24,6 @@
#include <glib.h>
/* include normal versions of the inlined functions here ... */
-#undef G_INLINE_FUNC
-#define G_INLINE_FUNC extern
-#define G_CAN_INLINE 1
#include "geometry.h"
#include "object.h"
diff --git a/lib/geometry.h b/lib/geometry.h
index 699f22dc..9b507b78 100644
--- a/lib/geometry.h
+++ b/lib/geometry.h
@@ -147,57 +147,40 @@ void dia_matrix_set_rotate_around (DiaMatrix *result, real angle, const Point *a
/* inline these functions if the platform supports it */
-G_INLINE_FUNC void point_add(Point *p1, const Point *p2);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_add(Point *p1, const Point *p2)
{
p1->x += p2->x;
p1->y += p2->y;
}
-#endif
-G_INLINE_FUNC void point_sub(Point *p1, const Point *p2);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_sub(Point *p1, const Point *p2)
{
p1->x -= p2->x;
p1->y -= p2->y;
}
-#endif
-G_INLINE_FUNC real point_dot(const Point *p1, const Point *p2);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC real
+static inline real
point_dot(const Point *p1, const Point *p2)
{
return p1->x*p2->x + p1->y*p2->y;
}
-#endif
-G_INLINE_FUNC real point_len(const Point *p);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC real
+static inline real
point_len(const Point *p)
{
return sqrt(p->x*p->x + p->y*p->y);
}
-#endif
-G_INLINE_FUNC void point_scale(Point *p, real alpha);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_scale(Point *p, real alpha)
{
p->x *= alpha;
p->y *= alpha;
}
-#endif
-G_INLINE_FUNC void point_normalize(Point *p);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_normalize(Point *p)
{
real len;
@@ -216,23 +199,16 @@ point_normalize(Point *p)
p->x = 0.0;
p->y = 0.0;
}
-
}
-#endif
-G_INLINE_FUNC void point_rotate(Point *p1, const Point *p2);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_rotate(Point *p1, const Point *p2)
{
p1->x = p1->x*p2->x - p1->y*p2->y;
p1->y = p1->x*p2->y + p1->y*p2->x;
}
-#endif
-G_INLINE_FUNC void point_get_normed(Point *dst, const Point *src);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_get_normed(Point *dst, const Point *src)
{
real len;
@@ -242,11 +218,8 @@ point_get_normed(Point *dst, const Point *src)
dst->x = src->x / len;
dst->y = src->y / len;
}
-#endif
-G_INLINE_FUNC void point_get_perp(Point *dst, const Point *src);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_get_perp(Point *dst, const Point *src)
{
/* dst = the src vector, rotated 90deg counter clowkwise. src *must* be
@@ -254,11 +227,8 @@ point_get_perp(Point *dst, const Point *src)
dst->y = src->x;
dst->x = -src->y;
}
-#endif
-G_INLINE_FUNC void point_copy(Point *dst, const Point *src);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_copy(Point *dst, const Point *src)
{
/* Unfortunately, the compiler is not clever enough. And copying using
@@ -269,24 +239,16 @@ point_copy(Point *dst, const Point *src)
dst->x = src->x;
dst->y = src->y;
}
-#endif
-G_INLINE_FUNC void point_add_scaled(Point *dst, const Point *src, real alpha);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_add_scaled(Point *dst, const Point *src, real alpha)
{
/* especially useful if src is a normed vector... */
dst->x += alpha * src->x;
dst->y += alpha * src->y;
}
-#endif
-G_INLINE_FUNC void point_copy_add_scaled(Point *dst, const Point *src,
- const Point *vct,
- real alpha);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC void
+static inline void
point_copy_add_scaled(Point *dst, const Point *src,
const Point *vct, real alpha)
{
@@ -294,7 +256,6 @@ point_copy_add_scaled(Point *dst, const Point *src,
dst->x = src->x + (alpha * vct->x);
dst->y = src->y + (alpha * vct->y);
}
-#endif
void point_convex(Point *dst, const Point *src1, const Point *src2, real alpha);
@@ -306,10 +267,7 @@ int point_in_rectangle(const Rectangle* r, const Point *p);
int rectangle_in_rectangle(const Rectangle* outer, const Rectangle *inner);
void rectangle_add_point(Rectangle *r, const Point *p);
-G_INLINE_FUNC gboolean rectangle_equals(const Rectangle *old_extents,
- const Rectangle *new_extents);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC gboolean
+static inline gboolean
rectangle_equals(const Rectangle *r1, const Rectangle *r2)
{
return ( (r2->left == r1->left) &&
@@ -317,30 +275,22 @@ rectangle_equals(const Rectangle *r1, const Rectangle *r2)
(r2->top == r1->top) &&
(r2->bottom == r1->bottom) );
}
-#endif
-G_INLINE_FUNC real distance_point_point(const Point *p1, const Point *p2);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC real
+static inline real
distance_point_point(const Point *p1, const Point *p2)
{
real dx = p1->x - p2->x;
real dy = p1->y - p2->y;
return sqrt(dx*dx + dy*dy);
}
-#endif
-G_INLINE_FUNC real distance_point_point_manhattan(const Point *p1,
- const Point *p2);
-#ifdef G_CAN_INLINE
-G_INLINE_FUNC real
+static inline real
distance_point_point_manhattan(const Point *p1, const Point *p2)
{
real dx = p1->x - p2->x;
real dy = p1->y - p2->y;
return ABS(dx) + ABS(dy);
}
-#endif
real distance_rectangle_point(const Rectangle *rect, const Point *point);
real distance_line_point(const Point *line_start, const Point *line_end,
diff --git a/lib/properties.c b/lib/properties.c
index 84eb788d..34a92bb3 100644
--- a/lib/properties.c
+++ b/lib/properties.c
@@ -29,9 +29,6 @@
#endif
#include "geometry.h"
-#undef G_INLINE_FUNC
-#define G_INLINE_FUNC extern
-#define G_CAN_INLINE 1
#include "properties.h"
#include "propinternals.h"
diff --git a/plug-ins/drs/dia-render-script-renderer.c b/plug-ins/drs/dia-render-script-renderer.c
index a381c881..44a95526 100644
--- a/plug-ins/drs/dia-render-script-renderer.c
+++ b/plug-ins/drs/dia-render-script-renderer.c
@@ -81,9 +81,10 @@ draw_object(DiaRenderer *self,
renderer->root = node = xmlNewChild(renderer->root, NULL, (const xmlChar *)"object", NULL);
xmlSetProp(node, (const xmlChar *)"type", (xmlChar *)object->type->name);
/* if it looks like intdata store it as well */
- if ((int)object->type->default_user_data > 0 && (int)object->type->default_user_data < 0xFF) {
+ if (GPOINTER_TO_INT (object->type->default_user_data) > 0 &&
+ GPOINTER_TO_INT (object->type->default_user_data) < 0xFF) {
gchar buffer[30];
- g_snprintf(buffer, sizeof(buffer), "%d", (int)object->type->default_user_data);
+ g_snprintf(buffer, sizeof(buffer), "%d", GPOINTER_TO_INT (object->type->default_user_data));
xmlSetProp(node, (const xmlChar *)"intdata", (xmlChar *)buffer);
}
if (renderer->save_props) {
diff --git a/plug-ins/postscript/render_eps.c b/plug-ins/postscript/render_eps.c
index fdedb537..f5cfb087 100644
--- a/plug-ins/postscript/render_eps.c
+++ b/plug-ins/postscript/render_eps.c
@@ -127,7 +127,7 @@ export_render_eps(DiaPsRenderer *renderer,
renderer->file = outfile;
renderer->scale = 28.346 * data->paper.scaling;
renderer->extent = data->extents;
- renderer->pstype = (guint)user_data;
+ renderer->pstype = GPOINTER_TO_UINT (user_data);
if (renderer->pstype & PSTYPE_EPSI) {
/* Must store the diagram for making a preview */
renderer->diagram = data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]