Re: [Vala] array_length_cname not working?



Il 16/04/2013 06:28, Alexander Krivács Schrøder ha scritto:
I filed the bug here: https://bugzilla.gnome.org/show_bug.cgi?id=698107
and I'm crossing my fingers that this feature could appear soon,
hopefully before my library is slated for release. :)
I don't think that's going to be fixed soon by vala developers, but if you provide a patch I'll be reviewing it for sure.

I'd try to help you implement the feature myself, but the vala code is a
little bit intimidating, and I don't know much about compilers, parsers,
etc. I wouldn't really know where to start... or how you would want to
accomplish it in the first place...
I believe the change is very simple, you can do it. It doesn't require any compiler/parser knowlede. It doesn't require deep knowledge of vala.

Vala has basically two AST. An AST is a tree representing the vala code. The Vala Tree and the CCode Tree. First code is parsed and the Vala Tree is created and analyzed in the vala/ subdir, ignore this. Then the Vala Tree is transformed into CCode Tree in the codegen/ subdir, and finally the CCode Tree is transformed into a string to be written in the .c file.

So you want to look in the codegen/ subdir, nowhere else. First of all, you want to understand how it's done for methods. There's a codegen module for methods, but don't look only in there. Most of the code is in the codegen base module. Notice that for methods, you may have multiple array parameters as well as a possible array return type. An array in vala is encoded only as type with ArrayType, which inherits from DataType.

Then for properties, get and set are PropertyAccessor which are similar to Method. PropertyAccessor accepts other CCode attributes so you want to look how attributes are fetched there, it should be trivial to follow.

The [CCode ...] Attribute is stored in PropertyAccessor if you put it on top of get and set. If you put it on top of a property then it's stored in Property.

For more questions ask in #vala on irc.gnome.org .

Best regards,


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