diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-05-23 17:50:12 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-07-16 16:59:57 +0200 |
commit | 366590a71672106d8f8a820e79431df7f0c39337 (patch) | |
tree | af530265b03db60f5a9d5f39e7d9f4d098aa12f3 /tests/annotations | |
parent | 7c4a957606f5a5b2afc8078228f228c8f87ccce5 (diff) | |
download | vala-366590a71672106d8f8a820e79431df7f0c39337.tar.gz |
tests: Add expected generated C sources
Diffstat (limited to 'tests/annotations')
-rw-r--r-- | tests/annotations/deprecated-delegate-minimal.c-expected | 22 | ||||
-rw-r--r-- | tests/annotations/deprecated-enum-minimal.c-expected | 24 | ||||
-rw-r--r-- | tests/annotations/deprecated-method-minimal.c-expected | 36 | ||||
-rw-r--r-- | tests/annotations/deprecated-property-minimal.c-expected | 56 | ||||
-rw-r--r-- | tests/annotations/deprecated-struct-minimal.c-expected | 26 | ||||
-rw-r--r-- | tests/annotations/deprecated.c-expected | 563 | ||||
-rw-r--r-- | tests/annotations/description.c-expected | 303 |
7 files changed, 1030 insertions, 0 deletions
diff --git a/tests/annotations/deprecated-delegate-minimal.c-expected b/tests/annotations/deprecated-delegate-minimal.c-expected new file mode 100644 index 000000000..5f70e82fd --- /dev/null +++ b/tests/annotations/deprecated-delegate-minimal.c-expected @@ -0,0 +1,22 @@ +/* annotations_deprecated_delegate_minimal.c generated by valac, the Vala compiler + * generated from annotations_deprecated_delegate_minimal.vala, do not modify */ + +#include <glib.h> + +typedef void (*Foo) (void) G_GNUC_DEPRECATED ; + +static void _vala_main (void); + +static void +_vala_main (void) +{ +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/annotations/deprecated-enum-minimal.c-expected b/tests/annotations/deprecated-enum-minimal.c-expected new file mode 100644 index 000000000..c809a7aef --- /dev/null +++ b/tests/annotations/deprecated-enum-minimal.c-expected @@ -0,0 +1,24 @@ +/* annotations_deprecated_enum_minimal.c generated by valac, the Vala compiler + * generated from annotations_deprecated_enum_minimal.vala, do not modify */ + +#include <glib.h> + +typedef enum { + FOO_BAR +} Foo G_GNUC_DEPRECATED ; + +static void _vala_main (void); + +static void +_vala_main (void) +{ +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/annotations/deprecated-method-minimal.c-expected b/tests/annotations/deprecated-method-minimal.c-expected new file mode 100644 index 000000000..02168bc6c --- /dev/null +++ b/tests/annotations/deprecated-method-minimal.c-expected @@ -0,0 +1,36 @@ +/* annotations_deprecated_method_minimal.c generated by valac, the Vala compiler + * generated from annotations_deprecated_method_minimal.vala, do not modify */ + +#include <glib.h> + +#if !defined(VALA_EXTERN) +#if defined(_MSC_VER) +#define VALA_EXTERN __declspec(dllexport) extern +#elif __GNUC__ >= 4 +#define VALA_EXTERN __attribute__((visibility("default"))) extern +#else +#define VALA_EXTERN extern +#endif +#endif + +VALA_EXTERN void foo (void) G_GNUC_DEPRECATED ; +static void _vala_main (void); + +void +foo (void) +{ +} + +static void +_vala_main (void) +{ +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/annotations/deprecated-property-minimal.c-expected b/tests/annotations/deprecated-property-minimal.c-expected new file mode 100644 index 000000000..cebd8f46d --- /dev/null +++ b/tests/annotations/deprecated-property-minimal.c-expected @@ -0,0 +1,56 @@ +/* annotations_deprecated_property_minimal.c generated by valac, the Vala compiler + * generated from annotations_deprecated_property_minimal.vala, do not modify */ + +#include <glib.h> + +#if !defined(VALA_EXTERN) +#if defined(_MSC_VER) +#define VALA_EXTERN __declspec(dllexport) extern +#elif __GNUC__ >= 4 +#define VALA_EXTERN __attribute__((visibility("default"))) extern +#else +#define VALA_EXTERN extern +#endif +#endif + +typedef struct _Foo Foo; + +struct _Foo { + void* _bar; +}; + +VALA_EXTERN void* foo_get_bar (Foo self) G_GNUC_DEPRECATED ; +VALA_EXTERN void foo_set_bar (Foo self, + void* value) G_GNUC_DEPRECATED ; +static void _vala_main (void); + +void* +foo_get_bar (Foo self) +{ + void* result; + void* _tmp0_; + _tmp0_ = self._bar; + result = _tmp0_; + return result; +} + +void +foo_set_bar (Foo self, + void* value) +{ + self._bar = value; +} + +static void +_vala_main (void) +{ +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/annotations/deprecated-struct-minimal.c-expected b/tests/annotations/deprecated-struct-minimal.c-expected new file mode 100644 index 000000000..cbc9b5d9d --- /dev/null +++ b/tests/annotations/deprecated-struct-minimal.c-expected @@ -0,0 +1,26 @@ +/* annotations_deprecated_struct_minimal.c generated by valac, the Vala compiler + * generated from annotations_deprecated_struct_minimal.vala, do not modify */ + +#include <glib.h> + +typedef struct _Foo Foo; + +struct _Foo { + void* bar; +} G_GNUC_DEPRECATED ; + +static void _vala_main (void); + +static void +_vala_main (void) +{ +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/annotations/deprecated.c-expected b/tests/annotations/deprecated.c-expected new file mode 100644 index 000000000..729cd82e4 --- /dev/null +++ b/tests/annotations/deprecated.c-expected @@ -0,0 +1,563 @@ +/* annotations_deprecated.c generated by valac, the Vala compiler + * generated from annotations_deprecated.vala, do not modify */ + +#include <glib.h> +#include <glib-object.h> +#include <string.h> + +#if !defined(VALA_EXTERN) +#if defined(_MSC_VER) +#define VALA_EXTERN __declspec(dllexport) extern +#elif __GNUC__ >= 4 +#define VALA_EXTERN __attribute__((visibility("default"))) extern +#else +#define VALA_EXTERN extern +#endif +#endif + +typedef void (*FooDelegate) (gpointer user_data) G_GNUC_DEPRECATED ; + +#define TYPE_FOO_STRUCT (foo_struct_get_type ()) +typedef struct _FooStruct FooStruct; + +#define TYPE_FOOCLASS (fooclass_get_type ()) +#define FOOCLASS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOOCLASS, FooClass)) +#define FOOCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FOOCLASS, FooClassClass)) +#define IS_FOOCLASS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FOOCLASS)) +#define IS_FOOCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FOOCLASS)) +#define FOOCLASS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FOOCLASS, FooClassClass)) + +typedef struct _FooClass FooClass; +typedef struct _FooClassClass FooClassClass; +typedef struct _FooClassPrivate FooClassPrivate; +enum { + FOOCLASS_0_PROPERTY, + FOOCLASS_BAR_PROPERTY, + FOOCLASS_NUM_PROPERTIES +}; +static GParamSpec* fooclass_properties[FOOCLASS_NUM_PROPERTIES]; + +#define TYPE_AFOO (afoo_get_type ()) +#define AFOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AFOO, AFoo)) +#define AFOO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AFOO, AFooClass)) +#define IS_AFOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AFOO)) +#define IS_AFOO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AFOO)) +#define AFOO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AFOO, AFooClass)) + +typedef struct _AFoo AFoo; +typedef struct _AFooClass AFooClass; +typedef struct _AFooPrivate AFooPrivate; +enum { + AFOO_0_PROPERTY, + AFOO_NUM_PROPERTIES +}; +static GParamSpec* afoo_properties[AFOO_NUM_PROPERTIES]; + +#define TYPE_IFOO (ifoo_get_type ()) +#define IFOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IFOO, IFoo)) +#define IS_IFOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IFOO)) +#define IFOO_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_IFOO, IFooIface)) + +typedef struct _IFoo IFoo; +typedef struct _IFooIface IFooIface; +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +typedef enum { + FOO_ENUM_BAR = 0, + FOO_ENUM_FOO, + FOO_ENUM_BAZ +} FooEnum G_GNUC_DEPRECATED ; + +#define TYPE_FOO_ENUM (foo_enum_get_type ()) +#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); +#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } +#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } +#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); + +struct _FooStruct { + gint bar G_GNUC_DEPRECATED ; +} G_GNUC_DEPRECATED ; + +struct _FooClass { + GObject parent_instance; + FooClassPrivate * priv; + gint baz G_GNUC_DEPRECATED ; +}; + +struct _FooClassClass { + GObjectClass parent_class; + gint (*foov) (FooClass* self) G_GNUC_DEPRECATED ; +}; + +struct _FooClassPrivate { + gint _bar; +}; + +struct _AFoo { + GObject parent_instance; + AFooPrivate * priv; +}; + +struct _AFooClass { + GObjectClass parent_class; + gint (*fooa) (AFoo* self) G_GNUC_DEPRECATED ; +}; + +struct _IFooIface { + GTypeInterface parent_iface; + void (*fooa) (IFoo* self) G_GNUC_DEPRECATED ; +}; + +VALA_EXTERN gint bar; +gint bar = 42; +static gint FooClass_private_offset; +static gpointer fooclass_parent_class = NULL; +VALA_EXTERN gint fooclass_manam; +gint fooclass_manam = 42; +static gpointer afoo_parent_class = NULL; + +VALA_EXTERN void baz (void) G_GNUC_DEPRECATED ; +VALA_EXTERN GType foo_struct_get_type (void) G_GNUC_CONST ; +VALA_EXTERN FooStruct* foo_struct_dup (const FooStruct* self); +VALA_EXTERN void foo_struct_free (FooStruct* self); +VALA_EXTERN void test_struct_field (void); +VALA_EXTERN GType fooclass_get_type (void) G_GNUC_CONST ; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (FooClass, g_object_unref) +VALA_EXTERN gint fooclass_foov (FooClass* self) G_GNUC_DEPRECATED ; +VALA_EXTERN gint fooclass_foo (FooClass* self) G_GNUC_DEPRECATED ; +static gint fooclass_real_foov (FooClass* self) G_GNUC_DEPRECATED ; +VALA_EXTERN FooClass* fooclass_new (void); +VALA_EXTERN FooClass* fooclass_construct (GType object_type); +VALA_EXTERN gint fooclass_get_bar (FooClass* self) G_GNUC_DEPRECATED ; +VALA_EXTERN void fooclass_set_bar (FooClass* self, + gint value) G_GNUC_DEPRECATED ; +static void fooclass_finalize (GObject * obj); +static GType fooclass_get_type_once (void); +static void _vala_fooclass_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec); +static void _vala_fooclass_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec); +VALA_EXTERN GType afoo_get_type (void) G_GNUC_CONST ; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (AFoo, g_object_unref) +VALA_EXTERN gint afoo_fooa (AFoo* self) G_GNUC_DEPRECATED ; +VALA_EXTERN gint afoo_foo (AFoo* self) G_GNUC_DEPRECATED ; +static gint afoo_real_fooa (AFoo* self) G_GNUC_DEPRECATED ; +VALA_EXTERN AFoo* afoo_construct (GType object_type); +static GType afoo_get_type_once (void); +VALA_EXTERN GType ifoo_get_type (void) G_GNUC_CONST ; +VALA_EXTERN gint ifoo_foo (IFoo* self) G_GNUC_DEPRECATED ; +VALA_EXTERN void ifoo_fooa (IFoo* self) G_GNUC_DEPRECATED ; +static GType ifoo_get_type_once (void); +VALA_EXTERN void test_class_property (void); +VALA_EXTERN GType foo_enum_get_type (void) G_GNUC_CONST ; +VALA_EXTERN void test_enum (void); +static void _vala_main (void); + +void +baz (void) +{ +} + +FooStruct* +foo_struct_dup (const FooStruct* self) +{ + FooStruct* dup; + dup = g_new0 (FooStruct, 1); + memcpy (dup, self, sizeof (FooStruct)); + return dup; +} + +void +foo_struct_free (FooStruct* self) +{ + g_free (self); +} + +static GType +foo_struct_get_type_once (void) +{ + GType foo_struct_type_id; + foo_struct_type_id = g_boxed_type_register_static ("FooStruct", (GBoxedCopyFunc) foo_struct_dup, (GBoxedFreeFunc) foo_struct_free); + return foo_struct_type_id; +} + +GType +foo_struct_get_type (void) +{ + static volatile gsize foo_struct_type_id__volatile = 0; + if (g_once_init_enter (&foo_struct_type_id__volatile)) { + GType foo_struct_type_id; + foo_struct_type_id = foo_struct_get_type_once (); + g_once_init_leave (&foo_struct_type_id__volatile, foo_struct_type_id); + } + return foo_struct_type_id__volatile; +} + +void +test_struct_field (void) +{ + FooStruct foo = {0}; + FooStruct _tmp0_ = {0}; + gint i = 0; + FooStruct _tmp1_; + FooStruct _tmp2_; + _tmp0_.bar = 42; + foo = _tmp0_; + _tmp1_ = foo; + i = _tmp1_.bar; + foo.bar = i; + _tmp2_ = foo; + _vala_assert (_tmp2_.bar == 42, "foo.bar == 42"); +} + +static inline gpointer +fooclass_get_instance_private (FooClass* self) +{ + return G_STRUCT_MEMBER_P (self, FooClass_private_offset); +} + +gint +fooclass_foo (FooClass* self) +{ + gint result = 0; + g_return_val_if_fail (IS_FOOCLASS (self), 0); + result = 42; + return result; +} + +static gint +fooclass_real_foov (FooClass* self) +{ + gint result = 0; + result = 42; + return result; +} + +gint +fooclass_foov (FooClass* self) +{ + FooClassClass* _klass_; + g_return_val_if_fail (IS_FOOCLASS (self), 0); + _klass_ = FOOCLASS_GET_CLASS (self); + if (_klass_->foov) { + return _klass_->foov (self); + } + return -1; +} + +FooClass* +fooclass_construct (GType object_type) +{ + FooClass * self = NULL; + self = (FooClass*) g_object_new (object_type, NULL); + return self; +} + +FooClass* +fooclass_new (void) +{ + return fooclass_construct (TYPE_FOOCLASS); +} + +gint +fooclass_get_bar (FooClass* self) +{ + gint result; + g_return_val_if_fail (IS_FOOCLASS (self), 0); + result = self->priv->_bar; + return result; +} + +void +fooclass_set_bar (FooClass* self, + gint value) +{ + gint old_value; + g_return_if_fail (IS_FOOCLASS (self)); + old_value = fooclass_get_bar (self); + if (old_value != value) { + self->priv->_bar = value; + g_object_notify_by_pspec ((GObject *) self, fooclass_properties[FOOCLASS_BAR_PROPERTY]); + } +} + +static void +fooclass_class_init (FooClassClass * klass, + gpointer klass_data) +{ + fooclass_parent_class = g_type_class_peek_parent (klass); + g_type_class_adjust_private_offset (klass, &FooClass_private_offset); + ((FooClassClass *) klass)->foov = (gint (*) (FooClass*)) fooclass_real_foov; + G_OBJECT_CLASS (klass)->get_property = _vala_fooclass_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_fooclass_set_property; + G_OBJECT_CLASS (klass)->finalize = fooclass_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), FOOCLASS_BAR_PROPERTY, fooclass_properties[FOOCLASS_BAR_PROPERTY] = g_param_spec_int ("bar", "bar", "bar", G_MININT, G_MAXINT, 42, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_DEPRECATED)); +} + +static void +fooclass_instance_init (FooClass * self, + gpointer klass) +{ + self->priv = fooclass_get_instance_private (self); + self->priv->_bar = 42; +} + +static void +fooclass_finalize (GObject * obj) +{ + FooClass * self; + self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FOOCLASS, FooClass); + G_OBJECT_CLASS (fooclass_parent_class)->finalize (obj); +} + +static GType +fooclass_get_type_once (void) +{ + static const GTypeInfo g_define_type_info = { sizeof (FooClassClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fooclass_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FooClass), 0, (GInstanceInitFunc) fooclass_instance_init, NULL }; + GType fooclass_type_id; + fooclass_type_id = g_type_register_static (G_TYPE_OBJECT, "FooClass", &g_define_type_info, 0); + FooClass_private_offset = g_type_add_instance_private (fooclass_type_id, sizeof (FooClassPrivate)); + return fooclass_type_id; +} + +GType +fooclass_get_type (void) +{ + static volatile gsize fooclass_type_id__volatile = 0; + if (g_once_init_enter (&fooclass_type_id__volatile)) { + GType fooclass_type_id; + fooclass_type_id = fooclass_get_type_once (); + g_once_init_leave (&fooclass_type_id__volatile, fooclass_type_id); + } + return fooclass_type_id__volatile; +} + +static void +_vala_fooclass_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec) +{ + FooClass * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOOCLASS, FooClass); + switch (property_id) { + case FOOCLASS_BAR_PROPERTY: +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + g_value_set_int (value, fooclass_get_bar (self)); +G_GNUC_END_IGNORE_DEPRECATIONS + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +_vala_fooclass_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + FooClass * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOOCLASS, FooClass); + switch (property_id) { + case FOOCLASS_BAR_PROPERTY: +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + fooclass_set_bar (self, g_value_get_int (value)); +G_GNUC_END_IGNORE_DEPRECATIONS + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +gint +afoo_foo (AFoo* self) +{ + gint result = 0; + g_return_val_if_fail (IS_AFOO (self), 0); + result = 42; + return result; +} + +static gint +afoo_real_fooa (AFoo* self) +{ + gint _tmp0_ = 0; + g_critical ("Type `%s' does not implement abstract method `afoo_fooa'", g_type_name (G_TYPE_FROM_INSTANCE (self))); + return _tmp0_; +} + +gint +afoo_fooa (AFoo* self) +{ + AFooClass* _klass_; + g_return_val_if_fail (IS_AFOO (self), 0); + _klass_ = AFOO_GET_CLASS (self); + if (_klass_->fooa) { + return _klass_->fooa (self); + } + return -1; +} + +AFoo* +afoo_construct (GType object_type) +{ + AFoo * self = NULL; + self = (AFoo*) g_object_new (object_type, NULL); + return self; +} + +static void +afoo_class_init (AFooClass * klass, + gpointer klass_data) +{ + afoo_parent_class = g_type_class_peek_parent (klass); + ((AFooClass *) klass)->fooa = (gint (*) (AFoo*)) afoo_real_fooa; +} + +static void +afoo_instance_init (AFoo * self, + gpointer klass) +{ +} + +static GType +afoo_get_type_once (void) +{ + static const GTypeInfo g_define_type_info = { sizeof (AFooClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) afoo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AFoo), 0, (GInstanceInitFunc) afoo_instance_init, NULL }; + GType afoo_type_id; + afoo_type_id = g_type_register_static (G_TYPE_OBJECT, "AFoo", &g_define_type_info, G_TYPE_FLAG_ABSTRACT); + return afoo_type_id; +} + +GType +afoo_get_type (void) +{ + static volatile gsize afoo_type_id__volatile = 0; + if (g_once_init_enter (&afoo_type_id__volatile)) { + GType afoo_type_id; + afoo_type_id = afoo_get_type_once (); + g_once_init_leave (&afoo_type_id__volatile, afoo_type_id); + } + return afoo_type_id__volatile; +} + +gint +ifoo_foo (IFoo* self) +{ + gint result = 0; + result = 42; + return result; +} + +void +ifoo_fooa (IFoo* self) +{ + IFooIface* _iface_; + g_return_if_fail (IS_IFOO (self)); + _iface_ = IFOO_GET_INTERFACE (self); + if (_iface_->fooa) { + _iface_->fooa (self); + } +} + +static void +ifoo_default_init (IFooIface * iface, + gpointer iface_data) +{ +} + +static GType +ifoo_get_type_once (void) +{ + static const GTypeInfo g_define_type_info = { sizeof (IFooIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ifoo_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; + GType ifoo_type_id; + ifoo_type_id = g_type_register_static (G_TYPE_INTERFACE, "IFoo", &g_define_type_info, 0); + g_type_interface_add_prerequisite (ifoo_type_id, G_TYPE_OBJECT); + return ifoo_type_id; +} + +GType +ifoo_get_type (void) +{ + static volatile gsize ifoo_type_id__volatile = 0; + if (g_once_init_enter (&ifoo_type_id__volatile)) { + GType ifoo_type_id; + ifoo_type_id = ifoo_get_type_once (); + g_once_init_leave (&ifoo_type_id__volatile, ifoo_type_id); + } + return ifoo_type_id__volatile; +} + +void +test_class_property (void) +{ + FooClass* foo = NULL; + FooClass* _tmp0_; + gint i = 0; + gint _tmp1_; + gint _tmp2_; + gint _tmp3_; + gint _tmp4_; + _tmp0_ = fooclass_new (); + foo = _tmp0_; + _tmp1_ = fooclass_get_bar (foo); + _tmp2_ = _tmp1_; + i = _tmp2_; + fooclass_set_bar (foo, i); + _tmp3_ = fooclass_get_bar (foo); + _tmp4_ = _tmp3_; + _vala_assert (_tmp4_ == 42, "foo.bar == 42"); + _g_object_unref0 (foo); +} + +static GType +foo_enum_get_type_once (void) +{ + static const GEnumValue values[] = {{FOO_ENUM_BAR, "FOO_ENUM_BAR", "bar"}, {FOO_ENUM_FOO, "FOO_ENUM_FOO", "foo"}, {FOO_ENUM_BAZ, "FOO_ENUM_BAZ", "baz"}, {0, NULL, NULL}}; + GType foo_enum_type_id; + foo_enum_type_id = g_enum_register_static ("FooEnum", values); + return foo_enum_type_id; +} + +GType +foo_enum_get_type (void) +{ + static volatile gsize foo_enum_type_id__volatile = 0; + if (g_once_init_enter (&foo_enum_type_id__volatile)) { + GType foo_enum_type_id; + foo_enum_type_id = foo_enum_get_type_once (); + g_once_init_leave (&foo_enum_type_id__volatile, foo_enum_type_id); + } + return foo_enum_type_id__volatile; +} + +void +test_enum (void) +{ + FooEnum foo = 0; + foo = FOO_ENUM_BAR; + _vala_assert (foo == 0, "foo == 0"); +} + +static void +_vala_main (void) +{ + test_class_property (); + test_struct_field (); + test_enum (); +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + diff --git a/tests/annotations/description.c-expected b/tests/annotations/description.c-expected new file mode 100644 index 000000000..4dbb7e569 --- /dev/null +++ b/tests/annotations/description.c-expected @@ -0,0 +1,303 @@ +/* annotations_description.c generated by valac, the Vala compiler + * generated from annotations_description.vala, do not modify */ + +#include <glib-object.h> +#include <glib.h> + +#if !defined(VALA_EXTERN) +#if defined(_MSC_VER) +#define VALA_EXTERN __declspec(dllexport) extern +#elif __GNUC__ >= 4 +#define VALA_EXTERN __attribute__((visibility("default"))) extern +#else +#define VALA_EXTERN extern +#endif +#endif + +#define TYPE_FOO (foo_get_type ()) +#define FOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOO, Foo)) +#define FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FOO, FooClass)) +#define IS_FOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FOO)) +#define IS_FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FOO)) +#define FOO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FOO, FooClass)) + +typedef struct _Foo Foo; +typedef struct _FooClass FooClass; +typedef struct _FooPrivate FooPrivate; +enum { + FOO_0_PROPERTY, + FOO_FOO_PROPERTY, + FOO_NUM_PROPERTIES +}; +static GParamSpec* foo_properties[FOO_NUM_PROPERTIES]; +typedef enum { + BAR_FOO +} Bar; + +#define TYPE_BAR (bar_get_type ()) +#define _g_type_class_unref0(var) ((var == NULL) ? NULL : (var = (g_type_class_unref (var), NULL))) +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); +#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } +#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } +#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); + +struct _Foo { + GObject parent_instance; + FooPrivate * priv; +}; + +struct _FooClass { + GObjectClass parent_class; +}; + +struct _FooPrivate { + gint _foo; +}; + +static gint Foo_private_offset; +static gpointer foo_parent_class = NULL; + +VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (Foo, g_object_unref) +VALA_EXTERN Foo* foo_new (void); +VALA_EXTERN Foo* foo_construct (GType object_type); +VALA_EXTERN gint foo_get_foo (Foo* self); +VALA_EXTERN void foo_set_foo (Foo* self, + gint value); +static void foo_finalize (GObject * obj); +static GType foo_get_type_once (void); +static void _vala_foo_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec); +static void _vala_foo_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec); +VALA_EXTERN GType bar_get_type (void) G_GNUC_CONST ; +static void _vala_main (void); + +static inline gpointer +foo_get_instance_private (Foo* self) +{ + return G_STRUCT_MEMBER_P (self, Foo_private_offset); +} + +Foo* +foo_construct (GType object_type) +{ + Foo * self = NULL; + self = (Foo*) g_object_new (object_type, NULL); + return self; +} + +Foo* +foo_new (void) +{ + return foo_construct (TYPE_FOO); +} + +gint +foo_get_foo (Foo* self) +{ + gint result; + g_return_val_if_fail (IS_FOO (self), 0); + result = self->priv->_foo; + return result; +} + +void +foo_set_foo (Foo* self, + gint value) +{ + gint old_value; + g_return_if_fail (IS_FOO (self)); + old_value = foo_get_foo (self); + if (old_value != value) { + self->priv->_foo = value; + g_object_notify_by_pspec ((GObject *) self, foo_properties[FOO_FOO_PROPERTY]); + } +} + +static void +foo_class_init (FooClass * klass, + gpointer klass_data) +{ + foo_parent_class = g_type_class_peek_parent (klass); + g_type_class_adjust_private_offset (klass, &Foo_private_offset); + G_OBJECT_CLASS (klass)->get_property = _vala_foo_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_foo_set_property; + G_OBJECT_CLASS (klass)->finalize = foo_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), FOO_FOO_PROPERTY, foo_properties[FOO_FOO_PROPERTY] = g_param_spec_int ("foo", "foo's nick", "foo's blurb", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE)); +} + +static void +foo_instance_init (Foo * self, + gpointer klass) +{ + self->priv = foo_get_instance_private (self); +} + +static void +foo_finalize (GObject * obj) +{ + Foo * self; + self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FOO, Foo); + G_OBJECT_CLASS (foo_parent_class)->finalize (obj); +} + +static GType +foo_get_type_once (void) +{ + static const GTypeInfo g_define_type_info = { sizeof (FooClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) foo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Foo), 0, (GInstanceInitFunc) foo_instance_init, NULL }; + GType foo_type_id; + foo_type_id = g_type_register_static (G_TYPE_OBJECT, "Foo", &g_define_type_info, 0); + Foo_private_offset = g_type_add_instance_private (foo_type_id, sizeof (FooPrivate)); + return foo_type_id; +} + +GType +foo_get_type (void) +{ + static volatile gsize foo_type_id__volatile = 0; + if (g_once_init_enter (&foo_type_id__volatile)) { + GType foo_type_id; + foo_type_id = foo_get_type_once (); + g_once_init_leave (&foo_type_id__volatile, foo_type_id); + } + return foo_type_id__volatile; +} + +static void +_vala_foo_get_property (GObject * object, + guint property_id, + GValue * value, + GParamSpec * pspec) +{ + Foo * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOO, Foo); + switch (property_id) { + case FOO_FOO_PROPERTY: + g_value_set_int (value, foo_get_foo (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +_vala_foo_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + Foo * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOO, Foo); + switch (property_id) { + case FOO_FOO_PROPERTY: + foo_set_foo (self, g_value_get_int (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static GType +bar_get_type_once (void) +{ + static const GEnumValue values[] = {{BAR_FOO, "BAR_FOO", "foo's nick"}, {0, NULL, NULL}}; + GType bar_type_id; + bar_type_id = g_enum_register_static ("Bar", values); + return bar_type_id; +} + +GType +bar_get_type (void) +{ + static volatile gsize bar_type_id__volatile = 0; + if (g_once_init_enter (&bar_type_id__volatile)) { + GType bar_type_id; + bar_type_id = bar_get_type_once (); + g_once_init_leave (&bar_type_id__volatile, bar_type_id); + } + return bar_type_id__volatile; +} + +static void +_vala_main (void) +{ + Foo* foo = NULL; + Foo* _tmp0_; + GParamSpec** properties = NULL; + Foo* _tmp1_; + GObjectClass* _tmp2_; + guint _tmp3_ = 0; + GParamSpec** _tmp4_; + gint properties_length1; + gint _properties_size_; + GParamSpec** _tmp5_; + gint _tmp5__length1; + GTypeClass* _tmp12_; + GEnumClass* _tmp13_; + GEnumValue* _tmp14_; + const gchar* _tmp15_; + _tmp0_ = foo_new (); + foo = _tmp0_; + _tmp1_ = foo; + _tmp2_ = G_OBJECT_GET_CLASS (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, G_TYPE_OBJECT, GObject)); + _tmp4_ = g_object_class_list_properties (_tmp2_, &_tmp3_); + properties = _tmp4_; + properties_length1 = _tmp3_; + _properties_size_ = properties_length1; + _tmp5_ = properties; + _tmp5__length1 = properties_length1; + { + GParamSpec** p_collection = NULL; + gint p_collection_length1 = 0; + gint _p_collection_size_ = 0; + gint p_it = 0; + p_collection = _tmp5_; + p_collection_length1 = _tmp5__length1; + for (p_it = 0; p_it < p_collection_length1; p_it = p_it + 1) { + GParamSpec* p = NULL; + p = p_collection[p_it]; + { + GParamSpec* _tmp6_; + const gchar* _tmp7_; + GParamSpec* _tmp8_; + const gchar* _tmp9_; + GParamSpec* _tmp10_; + const gchar* _tmp11_; + _tmp6_ = p; + _tmp7_ = g_param_spec_get_name (_tmp6_); + _vala_assert (g_strcmp0 (_tmp7_, "foo") == 0, "p.get_name () == \"foo\""); + _tmp8_ = p; + _tmp9_ = g_param_spec_get_nick (_tmp8_); + _vala_assert (g_strcmp0 (_tmp9_, "foo's nick") == 0, "p.get_nick () == \"foo's nick\""); + _tmp10_ = p; + _tmp11_ = g_param_spec_get_blurb (_tmp10_); + _vala_assert (g_strcmp0 (_tmp11_, "foo's blurb") == 0, "p.get_blurb () == \"foo's blurb\""); + } + } + } + _tmp12_ = g_type_class_ref (TYPE_BAR); + _tmp13_ = (GEnumClass*) _tmp12_; + _tmp14_ = g_enum_get_value (g_type_class_ref (TYPE_BAR), BAR_FOO); + _tmp15_ = (*g_enum_get_value_by_name (_tmp13_, (_tmp14_ != NULL) ? _tmp14_->value_name : NULL)).value_nick; + _vala_assert (g_strcmp0 (_tmp15_, "foo's nick") == 0, "((EnumClass) typeof (Bar).class_ref ()).get_value_by_name (Bar.FOO.to_string ()).value_nick == \"foo's nick\""); + _g_type_class_unref0 (_tmp13_); + properties = (g_free (properties), NULL); + _g_object_unref0 (foo); +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + |