Re: [Vala] clutter gtkglext



great about extending a class.
valac build 2 ansi c source files, but it understand it's a only class and put all source code in file1.c. This is great because we can put signals in different vala files for examples. Extending classes itś great for me.

FILE1.vala

using GLib;

public class Sample : Object {
        public Sample () {
        }

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


}


FILE2.vala

/* Basic Vala Sample Code */
using GLib;

public class Sample : Object {


        public void run () {
                stdout.printf ("Hello World\n");
        }


}



Regards.



vala2.c file itś empty:

/* Basic Vala Sample Code */

#include "vala2.h"



All source code itś in vala1.c file :
/* Basic Vala Sample Code */

#include "vala1.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

enum {
SAMPLE_DUMMY_PROPERTY
};
static gint sample_main (int args_length1, char** args);
static gpointer sample_parent_class = NULL;


Sample* sample_new (void) {
Sample * self;
self = g_object_newv (TYPE_SAMPLE, 0, NULL);
return self;
}


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


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


void sample_run (Sample* self) {
g_return_if_fail (IS_SAMPLE (self));
fprintf (stdout, "Hello World\n");
}


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


static void sample_init (Sample * self) {
}


GType sample_get_type (void) {
static GType sample_type_id = 0;
if (G_UNLIKELY (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_init }; sample_type_id = g_type_register_static (G_TYPE_OBJECT, "Sample", &g_define_type_info, 0);
}
return sample_type_id;
}









[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]