Created gswe-types.c for type registration
This commit is contained in:
parent
767d30f231
commit
67a2f0d074
@ -16,6 +16,7 @@ gswe_headers = gswe-timestamp.h gswe-types.h
|
|||||||
|
|
||||||
libswe_glib_1_0_la_SOURCES = \
|
libswe_glib_1_0_la_SOURCES = \
|
||||||
swe-glib.c \
|
swe-glib.c \
|
||||||
|
gswe-types.c \
|
||||||
gswe-moment.c \
|
gswe-moment.c \
|
||||||
gswe-timestamp.c \
|
gswe-timestamp.c \
|
||||||
gswe-enumtypes.c \
|
gswe-enumtypes.c \
|
||||||
|
@ -94,7 +94,6 @@ static void gswe_moment_dispose(GObject *gobject);
|
|||||||
static void gswe_moment_finalize(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_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 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);
|
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;
|
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);
|
|
||||||
|
|
||||||
|
@ -63,101 +63,6 @@ typedef enum {
|
|||||||
GSWE_MOMENT_ERROR_SWE_ERROR_FATAL
|
GSWE_MOMENT_ERROR_SWE_ERROR_FATAL
|
||||||
} GsweMomentError;
|
} 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 {
|
struct _GsweMoment {
|
||||||
/* Parent instance structure */
|
/* Parent instance structure */
|
||||||
GObject parent_instance;
|
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_all_antiscia(GsweMoment *moment, GsweAntiscionAxis axis);
|
||||||
GList *gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis, GswePlanet planet, GError **err);
|
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__ */
|
#endif /* __GSWE_MOMENT_H__ */
|
||||||
|
|
||||||
|
47
src/gswe-types.c
Normal file
47
src/gswe-types.c
Normal file
@ -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);
|
||||||
|
|
105
src/gswe-types.h
105
src/gswe-types.h
@ -20,6 +20,7 @@
|
|||||||
#define __SWE_GLIB_GSWE_PLANETS_H__
|
#define __SWE_GLIB_GSWE_PLANETS_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GswePlanet:
|
* GswePlanet:
|
||||||
@ -314,5 +315,109 @@ typedef struct {
|
|||||||
gboolean middle_axis;
|
gboolean middle_axis;
|
||||||
} GsweAntiscionInfo;
|
} 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__ */
|
#endif /* __SWE_GLIB_GSWE_PLANETS_H__ */
|
||||||
|
|
||||||
|
@ -19,10 +19,13 @@
|
|||||||
#ifndef __SWE_GLIB_PRIVATE_H__
|
#ifndef __SWE_GLIB_PRIVATE_H__
|
||||||
|
|
||||||
#include "gswe-timestamp.h"
|
#include "gswe-timestamp.h"
|
||||||
|
#include "gswe-types.h"
|
||||||
|
|
||||||
extern gchar *gswe_ephe_path;
|
extern gchar *gswe_ephe_path;
|
||||||
extern GsweTimestamp *gswe_full_moon_base_date;
|
extern GsweTimestamp *gswe_full_moon_base_date;
|
||||||
|
|
||||||
|
GsweCoordinates *gswe_coordinates_copy(GsweCoordinates *coordinates);
|
||||||
|
|
||||||
#endif /* __SWE_GLIB_PRIVATE_H__ */
|
#endif /* __SWE_GLIB_PRIVATE_H__ */
|
||||||
#else /* not defined __SWE_GLIB_BUILDING__ */
|
#else /* not defined __SWE_GLIB_BUILDING__ */
|
||||||
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
#error __FILE__ "Can not be included, unless building SWE-GLib"
|
||||||
|
Loading…
Reference in New Issue
Block a user