Re: [Vala] How to generate inline C functions?

2011-11-07 Thread Tal Hadad

 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).
 
 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;
 }
Good feature request.Tal  ___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to generate inline C functions?

2011-11-07 Thread Luca Bruno
2011/11/7 Tal Hadad tal...@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.

 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 .

-- 
www.debian.org - The Universal Operating System
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to generate inline C functions?

2011-11-07 Thread pancake
Hi

On 07/11/2011, at 20:58, Luca Bruno lethalma...@gmail.com wrote:

 2011/11/7 Tal Hadad tal...@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
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] How to generate inline C functions?

2011-11-05 Thread PCMan
Hi list,
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() {
  }

  [Macro]
  public void func2() {
  }
}

The generated result:

inline void test_func1(Test* test) {
}

#define test_func2(test) { \
}

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;
}

These questions are mostly for performance reason.
Otherwise I'm satisfied with vala.
These features are what I frequently used in C/C++ and I hope that I can
have them in Vala.

Thanks
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list