Re: [Vala] How to generate "inline" C functions?
- From: pancake <pancake youterm com>
- To: Luca Bruno <lethalman88 gmail com>
- Cc: Vala Mail List <vala-list gnome org>
- Subject: Re: [Vala] How to generate "inline" C functions?
- Date: Tue, 8 Nov 2011 08:40:46 +0100
Hi
On 07/11/2011, at 20:58, Luca Bruno <lethalman88 gmail com> wrote:
2011/11/7 Tal Hadad <tal_hd hotmail com>
Is there any CCode attribute to make the generated C function "inline"?
Or, is it possible to generate C macros instead of functions with vala?
For example:
class Test {
inline public void func1() {
}Vala tutorial sadly doesn't say a word about it, but it shell look
like:public inline void func1() {}This onw works currently in vala.>
[Macro]
public void func2() {
}
}
This is sound a great feature request.But I would like that the macro
could also not be function-like, butalso be able to define functon,
varibles, ...(i.e. full featured CMacro).
Vala produces static functions when possible, and gcc inlines them when
possible. So this is feature is already there.
I thought inline was already supported keyword in the past..
A way to do this is by using ccode or a define in a .h
But to be sincere... Inline is a premature optimization... Something like register does. They are properly
used by the compiler optimization correctly, so users should not use them.
It's different case for 'volatile' do vala supports this? Maybe we could add a ccode directive like cname,
but to be appended before the return type.
[CCode (ctype="inline")]
int foo() {...
This way we can let the user do those tricks without messing the syntax with stuff 99% users will missuse.
Functions defined in Macros should be forbidden by the compiler. They just mess the code and the debuggers
use to fail when stepping into them. Lines of code loss their sense and can result on weird compiler errors.
Another question is, is it possible to use bit-field in vala classes?
Like this:
class Test {
private bool b1 : 1;
private bool b2 : 1;
private bool b3 : 1;
private uint i1 : 4;
}
It's not possible. This is something that could be trivially implemented
using a CCode argument like [CCode (bitfield = 1)] or such, without adding
new syntax.
If you have a good use case, you can request the feature at
bugzilla.gnome.org .
I remembee this was discussed some years ago and it was rejected because implementation depends on C compiler
and architecture.
Bitfields are not portable. And vala code aims to be coherent everywhere.
If you want bitfields use a .h and a .vapi defining such struct. You will probably then need some ifdef
tuning depending on the endian of the target platform.
--
www.debian.org - The Universal Operating System
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]