Hi all,

while trying to compile vtg with the new 0.7.4 version I think that I
spot a bug with plugin modules C code generation.

Attached there are:

1) plugin.vala - a minimal test case
2) plugin.c - the generated wrong C code
3) type-modules.patch - a one line patch.

In a few words the problem is that the <plugin_class_name>_type_id
variable isn't declared if the class is inside a type-module plugin.

I don't know if it's desiderable to declare the type_id variable in the
declaration block or not, so check the patch ok?

Ciao,
        Andrea

P.S.
If someone is asking if vtg is dead, it's not, I'm just busy atm so
progress is very slow.
using GLib;

namespace Test
{	
	public class Plugin : GLib.Object
	{
		public Plugin () { }
	}
}

[ModuleInit]
public GLib.Type register_plugin (TypeModule module) 
{
	return typeof (Test.Plugin);
}
#include <glib.h>
#include <glib-object.h>


#define TEST_TYPE_PLUGIN (test_plugin_get_type ())
#define TEST_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_PLUGIN, TestPlugin))
#define TEST_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_PLUGIN, TestPluginClass))
#define TEST_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_PLUGIN))
#define TEST_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_PLUGIN))
#define TEST_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_PLUGIN, TestPluginClass))

typedef struct _TestPlugin TestPlugin;
typedef struct _TestPluginClass TestPluginClass;
typedef struct _TestPluginPrivate TestPluginPrivate;

struct _TestPlugin {
	GObject parent_instance;
	TestPluginPrivate * priv;
};

struct _TestPluginClass {
	GObjectClass parent_class;
};


static gpointer test_plugin_parent_class = NULL;

GType test_plugin_get_type (void);
GType test_plugin_register_type (GTypeModule * module);
enum  {
	TEST_PLUGIN_DUMMY_PROPERTY
};
TestPlugin* test_plugin_new (void);
TestPlugin* test_plugin_construct (GType object_type);
TestPlugin* test_plugin_new (void);
GType register_plugin (GTypeModule* module);



TestPlugin* test_plugin_construct (GType object_type) {
	TestPlugin * self;
	self = g_object_newv (object_type, 0, NULL);
	return self;
}


TestPlugin* test_plugin_new (void) {
	return test_plugin_construct (TEST_TYPE_PLUGIN);
}


static void test_plugin_class_init (TestPluginClass * klass) {
	test_plugin_parent_class = g_type_class_peek_parent (klass);
}


static void test_plugin_instance_init (TestPlugin * self) {
}


GType test_plugin_get_type (void) {
	return test_plugin_type_id;
}


GType test_plugin_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (TestPluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TestPlugin), 0, (GInstanceInitFunc) test_plugin_instance_init, NULL };
	test_plugin_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "TestPlugin", &g_define_type_info, 0);
	return test_plugin_type_id;
}


GType register_plugin (GTypeModule* module) {
	GType result;
	g_return_val_if_fail (module != NULL, 0UL);
	test_plugin_register_type (module);
	result = TEST_TYPE_PLUGIN;
	return result;
}




diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index 85dfcc0..81fc1fc 100644
--- a/codegen/valatyperegisterfunction.vala
+++ b/codegen/valatyperegisterfunction.vala
@@ -62,7 +62,7 @@ public abstract class Vala.TypeRegisterFunction {
 		if (!plugin) {
 			type_block.add_statement (cdecl);
 		} else {
-			definition_fragment.append (cdecl);
+			declaration_fragment.append (cdecl);
 		}
 
 		CCodeFunction fun;
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to