Re: [Vala] Tryout adding simple support for extension methods to valac



I'd like to jump in and say I think this is a great proposal and hope this comes to fruition.

One question (for now): will this work for generic classes as well?

-- Jim

On Mon, Oct 14, 2013 at 2:09 PM, Luca Bruno <lethalman88 gmail com> wrote:
On Mon, Oct 14, 2013 at 7:31 PM, Philip Van Hoof <philip codeminded be>wrote:

 Luca Bruno schreef op 14/10/2013 18:17:

  Thanks for your contribution :-)


np. Right now it's just an experiment of course. My yearly "trying to
 understand vala's code" project ;)


  A couple of points:
1) Patches/feature requests go to bugzilla, unless you want them to be forgotten and eaten by the darkness :) IIRC there's already a bug about
 that.


I agree. The patch is so unfinished, however, that I don't think it's
 ready for official proposal yet.


Doesn't matter, a bug is still more appropriate.


About namespacing I guess the idea would be to let the code writer add the
 namespace to the API, and generate C code that way?


It should resemble the original class namespacing in general, namespace to
namespace, class to class.



 ie.

 namespace Test {
     extend Class Object {
         public void method() {
         }
     }
 }

 Would result in a C API like:

 void test_object_method ();

 Instead of

 void object_method(); which could more easily name-clash.

 I wonder if the namespace of Object should be added?


ie. void test_g_object_method(); instead of test_object_method() ?

 For that I guess I should create a 'Object' Vala.Class in the (new)
 namespace 'Test' instead of finding GLib.Object in context.root?

For finding what to generate during code writing, I'm guessing something similar to how subclassing works needs to be added for extended classes ... (instead of just cl.add_method and let crazy magic do its work, which is what I did now and which of course doesn't work for classes that aren't in
 the same .vala file).


If one wants to tweak the namespace at C level to avoid clashes, there are
CCode attributes for that.

For what concerns Vala AST, the method should be theoretically added to the
original class, as it semantically adds the method to the class from
another file. That is: class.add_method (foo). Adding a
Method.extends_class flag is enough to discriminate.
Then you get everything for free.
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



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