Wednesday, August 19, 2009

Vala

Programming Language
Vala is a new programming language that aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C.
http://live.gnome.org/Vala


Val(a)IDE
Val(a)IDE is an Integrated Development Environment (IDE) for the Vala programming language.
http://www.valaide.org/


Example Code
class Sample : Object 
{
void run()
{
stdout.printf ("Hello World\n");
}

static void main (string[] args)
{
var sample = new Sample();
sample.run ();
}
}

Code Compilation Example

valac --pkg gtk+-2.0 main.vala


`C` Code Generation Example

valac --pkg gtk+-2.0 -C main.vala


Generated Source

#include <glib.h>
#include <glib-object.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_SAMPLE (sample_get_type ())
#define SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SAMPLE, Sample))
#define SAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SAMPLE, SampleClass))
#define IS_SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SAMPLE))
#define IS_SAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SAMPLE))
#define SAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SAMPLE, SampleClass))

typedef struct _Sample Sample;
typedef struct _SampleClass SampleClass;
typedef struct _SamplePrivate SamplePrivate;

struct _Sample {
GObject parent_instance;
SamplePrivate * priv;
};

struct _SampleClass {
GObjectClass parent_class;
};


static gpointer sample_parent_class = NULL;

GType sample_get_type (void);
enum {
SAMPLE_DUMMY_PROPERTY
};
static void sample_run (Sample* self);
Sample* sample_new (void);
Sample* sample_construct (GType object_type);
static void sample_main (char** args, int args_length1);
Sample* sample_new (void);



static void sample_run (Sample* self) {
g_return_if_fail (self != NULL);
fprintf (stdout, "Hello World\n");
}


static void sample_main (char** args, int args_length1) {
Sample* sample;
sample = sample_new ();
sample_run (sample);
(sample == NULL) ? NULL : (sample = (g_object_unref (sample), NULL));
}


int main (int argc, char ** argv) {
g_type_init ();
sample_main (argv, argc);
return 0;
}


Sample* sample_construct (GType object_type) {
Sample * self;
self = g_object_newv (object_type, 0, NULL);
return self;
}


Sample* sample_new (void) {
return sample_construct (TYPE_SAMPLE);
}


static void sample_class_init (SampleClass * klass) {
sample_parent_class = g_type_class_peek_parent (klass);
}


static void sample_instance_init (Sample * self) {
}


GType sample_get_type (void) {
static GType sample_type_id = 0;
if (sample_type_id == 0) {
static const GTypeInfo g_define_type_info = { sizeof (SampleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sample_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Sample), 0, (GInstanceInitFunc) sample_instance_init, NULL };
sample_type_id = g_type_register_static (G_TYPE_OBJECT, "Sample", &g_define_type_info, 0);
}
return sample_type_id;
}

Wednesday, August 12, 2009

Ubuntu - Restricted Extras

The following command installs flash, java and codecs for different multimedia formats on Ubuntu.

sudo apt-get install ubuntu-restricted-extras


Details: https://help.ubuntu.com/community/RestrictedFormats

DB2-AS/400 SQL - Selecting Column Details

SELECT COLUMN_NAME, COLUMN_TEXT FROM QSYS2.SYSCOLUMNS WHERE TABLE_SCHEMA = '<LIBRARY>' AND TABLE_NAME = '<TABLE>'