Skip to content

Instantly share code, notes, and snippets.

@mrdaemon
Created January 12, 2011 09:25
Show Gist options
  • Save mrdaemon/775925 to your computer and use it in GitHub Desktop.
Save mrdaemon/775925 to your computer and use it in GitHub Desktop.
/* hello.c generated by valac 0.11.1, the Vala compiler
* generated from hello.vala, do not modify */
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define TYPE_HELLO_WORLD (hello_world_get_type ())
#define HELLO_WORLD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HELLO_WORLD, HelloWorld))
#define HELLO_WORLD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HELLO_WORLD, HelloWorldClass))
#define IS_HELLO_WORLD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HELLO_WORLD))
#define IS_HELLO_WORLD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HELLO_WORLD))
#define HELLO_WORLD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HELLO_WORLD, HelloWorldClass))
typedef struct _HelloWorld HelloWorld;
typedef struct _HelloWorldClass HelloWorldClass;
typedef struct _HelloWorldPrivate HelloWorldPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
struct _HelloWorld {
GObject parent_instance;
HelloWorldPrivate * priv;
};
struct _HelloWorldClass {
GObjectClass parent_class;
};
struct _HelloWorldPrivate {
gchar* _name;
};
static gpointer hello_world_parent_class = NULL;
GType hello_world_get_type (void) G_GNUC_CONST;
#define HELLO_WORLD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_HELLO_WORLD, HelloWorldPrivate))
enum {
HELLO_WORLD_DUMMY_PROPERTY,
HELLO_WORLD_NAME
};
HelloWorld* hello_world_new (void);
HelloWorld* hello_world_construct (GType object_type);
HelloWorld* hello_world_new_with_name (const gchar* name);
HelloWorld* hello_world_construct_with_name (GType object_type, const gchar* name);
void hello_world_set_name (HelloWorld* self, const gchar* value);
void hello_world_run (HelloWorld* self);
const gchar* hello_world_get_name (HelloWorld* self);
gboolean hello_world_hasname (HelloWorld* self);
static void hello_world_finalize (GObject* obj);
static void _vala_hello_world_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_hello_world_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
gint _vala_main (gchar** args, int args_length1);
HelloWorld* hello_world_construct (GType object_type) {
HelloWorld * self = NULL;
self = (HelloWorld*) g_object_new (object_type, NULL);
return self;
}
HelloWorld* hello_world_new (void) {
return hello_world_construct (TYPE_HELLO_WORLD);
}
/**
* By the way:
* I'm doing this to toy with the language. Just so you know,
* I could very well forfeit all of this bullshit and write
* stdout.printf("Hello, %s!\n", name ?? "World");
* I'm starting to like this language.
*/
HelloWorld* hello_world_construct_with_name (GType object_type, const gchar* name) {
HelloWorld * self = NULL;
g_return_val_if_fail (name != NULL, NULL);
self = (HelloWorld*) g_object_new (object_type, NULL);
hello_world_set_name (self, name);
return self;
}
HelloWorld* hello_world_new_with_name (const gchar* name) {
return hello_world_construct_with_name (TYPE_HELLO_WORLD, name);
}
void hello_world_run (HelloWorld* self) {
g_return_if_fail (self != NULL);
fprintf (stdout, "Hello, %s\n", self->priv->_name);
}
gboolean hello_world_hasname (HelloWorld* self) {
gboolean result = FALSE;
g_return_val_if_fail (self != NULL, FALSE);
result = g_strcmp0 (self->priv->_name, "World") != 0;
return result;
}
const gchar* hello_world_get_name (HelloWorld* self) {
const gchar* result;
g_return_val_if_fail (self != NULL, NULL);
result = self->priv->_name;
return result;
}
void hello_world_set_name (HelloWorld* self, const gchar* value) {
gchar* _tmp0_;
gchar* _tmp1_;
g_return_if_fail (self != NULL);
_tmp0_ = g_strdup (value);
_tmp1_ = _tmp0_;
_g_free0 (self->priv->_name);
self->priv->_name = _tmp1_;
g_object_notify ((GObject *) self, "name");
}
static void hello_world_class_init (HelloWorldClass * klass) {
hello_world_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (HelloWorldPrivate));
G_OBJECT_CLASS (klass)->get_property = _vala_hello_world_get_property;
G_OBJECT_CLASS (klass)->set_property = _vala_hello_world_set_property;
G_OBJECT_CLASS (klass)->finalize = hello_world_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), HELLO_WORLD_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}
static void hello_world_instance_init (HelloWorld * self) {
gchar* _tmp0_;
self->priv = HELLO_WORLD_GET_PRIVATE (self);
_tmp0_ = g_strdup ("World");
self->priv->_name = _tmp0_;
}
static void hello_world_finalize (GObject* obj) {
HelloWorld * self;
self = HELLO_WORLD (obj);
_g_free0 (self->priv->_name);
G_OBJECT_CLASS (hello_world_parent_class)->finalize (obj);
}
GType hello_world_get_type (void) {
static volatile gsize hello_world_type_id__volatile = 0;
if (g_once_init_enter (&hello_world_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (HelloWorldClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) hello_world_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (HelloWorld), 0, (GInstanceInitFunc) hello_world_instance_init, NULL };
GType hello_world_type_id;
hello_world_type_id = g_type_register_static (G_TYPE_OBJECT, "HelloWorld", &g_define_type_info, 0);
g_once_init_leave (&hello_world_type_id__volatile, hello_world_type_id);
}
return hello_world_type_id__volatile;
}
static void _vala_hello_world_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
HelloWorld * self;
self = HELLO_WORLD (object);
switch (property_id) {
case HELLO_WORLD_NAME:
g_value_set_string (value, hello_world_get_name (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void _vala_hello_world_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
HelloWorld * self;
self = HELLO_WORLD (object);
switch (property_id) {
case HELLO_WORLD_NAME:
hello_world_set_name (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
gint _vala_main (gchar** args, int args_length1) {
gint result = 0;
HelloWorld* _tmp0_ = NULL;
HelloWorld* world_hello;
HelloWorld* _tmp1_ = NULL;
HelloWorld* named_hello;
gboolean _tmp2_;
_tmp0_ = hello_world_new ();
world_hello = _tmp0_;
_tmp1_ = hello_world_new_with_name ("Alex");
named_hello = _tmp1_;
hello_world_run (world_hello);
hello_world_run (named_hello);
hello_world_set_name (named_hello, "Bob McBoberton");
hello_world_run (named_hello);
_tmp2_ = hello_world_hasname (world_hello);
if (!_tmp2_) {
fprintf (stdout, "%s", "Hey, the world greeting has no name.\n" "That's kinda boring, no? Let's use it to greet " "some unpleasant person instead.\n");
hello_world_set_name (world_hello, "you nasty gormless git");
}
hello_world_run (world_hello);
result = 0;
_g_object_unref0 (named_hello);
_g_object_unref0 (world_hello);
return result;
}
int main (int argc, char ** argv) {
g_type_init ();
return _vala_main (argv, argc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment