summaryrefslogtreecommitdiff
path: root/include/grobot.h
diff options
context:
space:
mode:
authorBradley Smith2008-03-09 18:37:58 +0000
committerBradley Smith2008-03-09 18:37:58 +0000
commit1eac647d46231ec03bc9647b72d32dc093bf366d (patch)
treefbf409498759d5fcb08c44b986080a1cc6b32485 /include/grobot.h
parentModified Changelog. (diff)
downloadgnurobots-1eac647d46231ec03bc9647b72d32dc093bf366d.tar.gz
Misc cleanups and GType style conversion.
Signed-off-by: Bradley Smith <brad@brad-smith.co.uk>
Diffstat (limited to 'include/grobot.h')
-rw-r--r--include/grobot.h97
1 files changed, 45 insertions, 52 deletions
diff --git a/include/grobot.h b/include/grobot.h
index 5495e0c..6ebcca3 100644
--- a/include/grobot.h
+++ b/include/grobot.h
@@ -17,9 +17,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _G_ROBOT_H
-#define _G_ROBOT_H
-/* MACROS */
+#ifndef __G_ROBOT_H__
+#define __G_ROBOT_H__
#include <glib-object.h>
#include <glib.h>
@@ -28,72 +27,66 @@
G_BEGIN_DECLS
-extern GType _g_robot_type;
+#define G_TYPE_ROBOT g_robot_get_type()
+#define G_IS_ROBOT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
+ G_TYPE_ROBOT)
+#define G_IS_ROBOT_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE ((klass),\
+ G_TYPE_ROBOT)
+#define G_ROBOT_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS ((obj),\
+ G_TYPE_ROBOT, GRobotClass)
+#define G_ROBOT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj),\
+ G_TYPE_ROBOT, GRobot)
+#define G_ROBOT_CLASS(klass) G_TYPE_CHECK_CLASS_CAST ((klass),\
+ G_TYPE_ROBOT, GRobotClass)
typedef struct _GRobot GRobot;
+typedef struct _GRobotClass GRobotClass;
struct _GRobot {
- GObject object;
-
- gint x;
- gint y;
- gint dir;
- glong score;
- glong energy;
- glong shields;
- glong shots;
- glong units;
+ GObject object;
+
+ gint x;
+ gint y;
+ gint dir;
+ glong score;
+ glong energy;
+ glong shields;
+ glong shots;
+ glong units;
UserInterface *ui;
Map *map;
-};
-
-typedef struct _GRobotClass GRobotClass;
+};
struct _GRobotClass {
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (*death) (GRobot *robot);
+ void (*death) (GRobot *robot);
};
-#define G_TYPE_ROBOT (_g_robot_type)
-#define G_IS_ROBOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ROBOT))
-#define G_IS_ROBOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_ROBOT))
-#define G_ROBOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_ROBOT, GRobotClass))
-#define G_ROBOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ROBOT, GRobot))
-#define G_ROBOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_ROBOT, GRobotClass))
-
/* some convenient macros */
-#define G_ROBOT_POSITION_X(robot) ((robot)->x)
-#define G_ROBOT_POSITION_Y(robot) ((robot)->y)
+#define G_ROBOT_POSITION_X(robot) ((robot)->x)
+#define G_ROBOT_POSITION_Y(robot) ((robot)->y)
/* normal GObject stuff */
-GType g_robot_get_type (void);
+GType g_robot_get_type(void) G_GNUC_CONST;
/* Our object functions */
-GRobot* g_robot_new (int x,
- int y,
- int dir,
- long score,
- long energy,
- long shield,
- long units,
- long shots,
- UserInterface *ui,
- Map *map);
-
-void g_robot_turn (GRobot *robot, gint num_turns);
-gboolean g_robot_move (GRobot *robot, gint steps);
-gboolean g_robot_smell (GRobot *robot, gchar *str);
-gboolean g_robot_feel (GRobot *robot, gchar *str);
-gboolean g_robot_look (GRobot *robot, gchar *str);
-gboolean g_robot_grab (GRobot *robot);
-gboolean g_robot_zap (GRobot *robot);
-gboolean g_robot_stop (GRobot *robot);
-glong g_robot_get_shields (GRobot *robot);
-glong g_robot_get_energy (GRobot *robot);
-glong g_robot_get_score (GRobot *robot);
+GRobot* g_robot_new(int x, int y, int dir, long score, long energy,
+ long shield, long units, long shots, UserInterface *ui, Map *map);
+
+void g_robot_turn (GRobot *robot, gint num_turns);
+gboolean g_robot_move (GRobot *robot, gint steps);
+gboolean g_robot_smell (GRobot *robot, gchar *str);
+gboolean g_robot_feel (GRobot *robot, gchar *str);
+gboolean g_robot_look (GRobot *robot, gchar *str);
+gboolean g_robot_grab (GRobot *robot);
+gboolean g_robot_zap (GRobot *robot);
+gboolean g_robot_stop (GRobot *robot);
+glong g_robot_get_shields (GRobot *robot);
+glong g_robot_get_energy (GRobot *robot);
+glong g_robot_get_score (GRobot *robot);
G_END_DECLS
-#endif
+#endif /* __G_ROBOT_H__ */