diff --git a/src/Makefile.am b/src/Makefile.am index 733abbb..23eebad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,7 @@ gswe_headers = gswe-timestamp.h gswe-types.h libswe_glib_1_0_la_SOURCES = \ swe-glib.c \ + gswe-types.c \ gswe-moment.c \ gswe-timestamp.c \ gswe-enumtypes.c \ diff --git a/src/gswe-moment.c b/src/gswe-moment.c index 136dc1f..8375a05 100644 --- a/src/gswe-moment.c +++ b/src/gswe-moment.c @@ -94,7 +94,6 @@ static void gswe_moment_dispose(GObject *gobject); static void gswe_moment_finalize(GObject *gobject); static void gswe_moment_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gswe_moment_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static GsweCoordinates *gswe_coordinates_copy(GsweCoordinates *coordinates); G_DEFINE_TYPE(GsweMoment, gswe_moment, G_TYPE_OBJECT); @@ -1259,60 +1258,3 @@ gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, return ret; } -static GsweMoonPhaseData * -gswe_moon_phase_data_copy(GsweMoonPhaseData *moon_phase_data) -{ - GsweMoonPhaseData *ret = g_new0(GsweMoonPhaseData, 1); - - ret->phase = moon_phase_data->phase; - ret->illumination = moon_phase_data->illumination; - - return ret; -} - -/** - * gswe_moon_phase_data_get_type: (skip) - * - * Register the #GsweMoonPhaseData struct as a #GBoxedType. It is required for - * GObject Introspection. You should never need to call this directly. - * - * Returns: the newly registered type ID - */ -GType -gswe_moon_phase_data_get_type(void) -{ - return g_boxed_type_register_static("GsweMoonPhaseData", (GBoxedCopyFunc)gswe_moon_phase_data_copy, (GBoxedFreeFunc)g_free); -} - -static GswePlanetData * -gswe_planet_data_copy(GswePlanetData *planet_data) -{ - GswePlanetData *ret = g_new0(GswePlanetData, 1); - - ret->planet_id = planet_data->planet_id; - ret->planet_info = planet_data->planet_info; - ret->position = planet_data->position; - ret->retrograde = planet_data->retrograde; - ret->house = planet_data->house; - ret->sign = planet_data->sign; - ret->revision = planet_data->revision; - - return ret; -} - -G_DEFINE_BOXED_TYPE(GswePlanetData, gswe_planet_data, (GBoxedCopyFunc)gswe_planet_data_copy, (GBoxedFreeFunc)g_free); - -static GsweCoordinates * -gswe_coordinates_copy(GsweCoordinates *coordinates) -{ - GsweCoordinates *ret = g_new0(GsweCoordinates, 1); - - ret->longitude = coordinates->longitude; - ret->latitude = coordinates->latitude; - ret->altitude = coordinates->altitude; - - return ret; -} - -G_DEFINE_BOXED_TYPE(GsweCoordinates, gswe_coordinates, (GBoxedCopyFunc)gswe_coordinates_copy, (GBoxedFreeFunc)g_free); - diff --git a/src/gswe-moment.h b/src/gswe-moment.h index ec497e9..5794696 100644 --- a/src/gswe-moment.h +++ b/src/gswe-moment.h @@ -63,101 +63,6 @@ typedef enum { GSWE_MOMENT_ERROR_SWE_ERROR_FATAL } GsweMomentError; -/** - * GsweCoordinates: - * @longitude: longitude part of the coordinates - * @latitude: latitude part of the coordinates - * @altitude: altitude relative to sea level - * - * GsweCoordinates specifies an exact point on Earth's surface - */ -typedef struct _GsweCoordinates { - gdouble longitude; - gdouble latitude; - gdouble altitude; -} GsweCoordinates; - -/** - * GswePlanetData: - * @planet_id: A GswePlanet, the identifier of the planet - * @planet_info: A GswePlanetInfo structure, holding every information about the planet - * @position: The longitude position of the planet - * @retrograde: TRUE if the planet is in retrograde motion - * @house: Number of the house in which the planet is in - * @sign: A GsweSignInfo structure, holding every information about the sign the planet is in - * @revision: An internal version number of the calculation - */ -typedef struct { - GswePlanet planet_id; - GswePlanetInfo *planet_info; - gdouble position; - gboolean retrograde; - gint house; - GsweSignInfo *sign; - guint revision; -} GswePlanetData; - -/** - * GsweHouseData: - * @house: the number of the house (usually in the range [1;12]. Sometimes may - * be [1;36]. - * @cusp_position: the position of the house's cusp on the sky - * @sign: the #GsweSignInfo structure associated with the sign in which the - * house cusp is in - */ -typedef struct { - guint house; - gdouble cusp_position; - GsweSignInfo *sign; -} GsweHouseData; - -/** - * GsweMoonPhaseData: - * @phase: the current phase of the Moon - * @illumination: the portion of the Moon that is currently illuminated - */ -typedef struct { - GsweMoonPhase phase; - gdouble illumination; -} GsweMoonPhaseData; - -/** - * GsweAspectData: - * @planet1: the first planet in the aspect - * @planet2: the second planet in the aspect - * @distance: the distance between the two planets, in degrees - * @aspect: the aspect between the two planets - * @aspect_info: the #GsweAspectInfo structure associated with the aspect - * @difference: the difference in percent between an exact aspect and this - * given aspect - */ -typedef struct { - GswePlanetData *planet1; - GswePlanetData *planet2; - gdouble distance; - GsweAspect aspect; - GsweAspectInfo *aspect_info; - gdouble difference; -} GsweAspectData; - -/** - * GsweAntiscionData: - * @planet1: the first planet in the antiscion - * @planet2: the second planet in the antiscion - * @axis: the axis on which this antiscion is - * @antiscion_info: the #GsweAntiscionInfo structure associated with this - * antiscion - * @difference: the difference in degrees between an exact antiscion and this - * given antiscion - */ -typedef struct { - GswePlanetData *planet1; - GswePlanetData *planet2; - GsweAntiscionAxis axis; - GsweAntiscionInfo *antiscion_info; - gdouble difference; -} GsweAntiscionData; - struct _GsweMoment { /* Parent instance structure */ GObject parent_instance; @@ -229,14 +134,5 @@ GList *gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet GList *gswe_moment_get_axis_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis); GList *gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, GswePlanet planet, GError **err); -GType gswe_moon_phase_data_get_type(void); -#define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type()) - -GType gswe_planet_data_get_type(void); -#define GSWE_TYPE_PLANET_DATA (gswe_planet_data_get_type()) - -GType gswe_coordinates_get_type(void); -#define GSWE_TYPE_COORDINATES (gswe_coordinates_get_type()) - #endif /* __GSWE_MOMENT_H__ */ diff --git a/src/gswe-types.c b/src/gswe-types.c new file mode 100644 index 0000000..dbb8926 --- /dev/null +++ b/src/gswe-types.c @@ -0,0 +1,47 @@ +#include "gswe-types.h" + +static GsweMoonPhaseData * +gswe_moon_phase_data_copy(GsweMoonPhaseData *moon_phase_data) +{ + GsweMoonPhaseData *ret = g_new0(GsweMoonPhaseData, 1); + + ret->phase = moon_phase_data->phase; + ret->illumination = moon_phase_data->illumination; + + return ret; +} + +G_DEFINE_BOXED_TYPE(GsweMoonPhaseData, gswe_moon_phase_data, (GBoxedCopyFunc)gswe_moon_phase_data_copy, (GBoxedFreeFunc)g_free); + +static GswePlanetData * +gswe_planet_data_copy(GswePlanetData *planet_data) +{ + GswePlanetData *ret = g_new0(GswePlanetData, 1); + + ret->planet_id = planet_data->planet_id; + ret->planet_info = planet_data->planet_info; + ret->position = planet_data->position; + ret->retrograde = planet_data->retrograde; + ret->house = planet_data->house; + ret->sign = planet_data->sign; + ret->revision = planet_data->revision; + + return ret; +} + +G_DEFINE_BOXED_TYPE(GswePlanetData, gswe_planet_data, (GBoxedCopyFunc)gswe_planet_data_copy, (GBoxedFreeFunc)g_free); + +GsweCoordinates * +gswe_coordinates_copy(GsweCoordinates *coordinates) +{ + GsweCoordinates *ret = g_new0(GsweCoordinates, 1); + + ret->longitude = coordinates->longitude; + ret->latitude = coordinates->latitude; + ret->altitude = coordinates->altitude; + + return ret; +} + +G_DEFINE_BOXED_TYPE(GsweCoordinates, gswe_coordinates, (GBoxedCopyFunc)gswe_coordinates_copy, (GBoxedFreeFunc)g_free); + diff --git a/src/gswe-types.h b/src/gswe-types.h index 89e6ece..aad3172 100644 --- a/src/gswe-types.h +++ b/src/gswe-types.h @@ -20,6 +20,7 @@ #define __SWE_GLIB_GSWE_PLANETS_H__ #include +#include /** * GswePlanet: @@ -314,5 +315,109 @@ typedef struct { gboolean middle_axis; } GsweAntiscionInfo; +/** + * GsweMoonPhaseData: + * @phase: the current phase of the Moon + * @illumination: the portion of the Moon that is currently illuminated + */ +typedef struct { + GsweMoonPhase phase; + gdouble illumination; +} GsweMoonPhaseData; + +GType gswe_moon_phase_data_get_type(void); +#define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type()) + +/** + * GswePlanetData: + * @planet_id: A GswePlanet, the identifier of the planet + * @planet_info: A GswePlanetInfo structure, holding every information about the planet + * @position: The longitude position of the planet + * @retrograde: TRUE if the planet is in retrograde motion + * @house: Number of the house in which the planet is in + * @sign: A GsweSignInfo structure, holding every information about the sign the planet is in + * @revision: An internal version number of the calculation + */ +typedef struct { + GswePlanet planet_id; + GswePlanetInfo *planet_info; + gdouble position; + gboolean retrograde; + gint house; + GsweSignInfo *sign; + guint revision; +} GswePlanetData; + +GType gswe_planet_data_get_type(void); +#define GSWE_TYPE_PLANET_DATA (gswe_planet_data_get_type()) + +/** + * GsweCoordinates: + * @longitude: longitude part of the coordinates + * @latitude: latitude part of the coordinates + * @altitude: altitude relative to sea level + * + * GsweCoordinates specifies an exact point on Earth's surface + */ +typedef struct _GsweCoordinates { + gdouble longitude; + gdouble latitude; + gdouble altitude; +} GsweCoordinates; + +GType gswe_coordinates_get_type(void); +#define GSWE_TYPE_COORDINATES (gswe_coordinates_get_type()) + +/** + * GsweHouseData: + * @house: the number of the house (usually in the range [1;12]. Sometimes may + * be [1;36]. + * @cusp_position: the position of the house's cusp on the sky + * @sign: the #GsweSignInfo structure associated with the sign in which the + * house cusp is in + */ +typedef struct { + guint house; + gdouble cusp_position; + GsweSignInfo *sign; +} GsweHouseData; + +/** + * GsweAspectData: + * @planet1: the first planet in the aspect + * @planet2: the second planet in the aspect + * @distance: the distance between the two planets, in degrees + * @aspect: the aspect between the two planets + * @aspect_info: the #GsweAspectInfo structure associated with the aspect + * @difference: the difference in percent between an exact aspect and this + * given aspect + */ +typedef struct { + GswePlanetData *planet1; + GswePlanetData *planet2; + gdouble distance; + GsweAspect aspect; + GsweAspectInfo *aspect_info; + gdouble difference; +} GsweAspectData; + +/** + * GsweAntiscionData: + * @planet1: the first planet in the antiscion + * @planet2: the second planet in the antiscion + * @axis: the axis on which this antiscion is + * @antiscion_info: the #GsweAntiscionInfo structure associated with this + * antiscion + * @difference: the difference in degrees between an exact antiscion and this + * given antiscion + */ +typedef struct { + GswePlanetData *planet1; + GswePlanetData *planet2; + GsweAntiscionAxis axis; + GsweAntiscionInfo *antiscion_info; + gdouble difference; +} GsweAntiscionData; + #endif /* __SWE_GLIB_GSWE_PLANETS_H__ */ diff --git a/src/swe-glib-private.h b/src/swe-glib-private.h index 1102d19..cfdf2c0 100644 --- a/src/swe-glib-private.h +++ b/src/swe-glib-private.h @@ -19,10 +19,13 @@ #ifndef __SWE_GLIB_PRIVATE_H__ #include "gswe-timestamp.h" +#include "gswe-types.h" extern gchar *gswe_ephe_path; extern GsweTimestamp *gswe_full_moon_base_date; +GsweCoordinates *gswe_coordinates_copy(GsweCoordinates *coordinates); + #endif /* __SWE_GLIB_PRIVATE_H__ */ #else /* not defined __SWE_GLIB_BUILDING__ */ #error __FILE__ "Can not be included, unless building SWE-GLib"