vala-extra-vapis icon indicating copy to clipboard operation
vala-extra-vapis copied to clipboard

portaudio.vapi

Open Hikawa opened this issue 12 years ago • 6 comments

I tried to use portaudio.vapi and found next problems:

  1. on my fedora package is named potraudio-2.0
  2. there was no constructor for PortAudio.Stream.Parameters and I made it struct
  3. HostApiInfo and DeviceInfo must be unowned

Hikawa avatar Sep 27 '13 21:09 Hikawa

  1. on my fedora package is named potraudio-2.0

Looks like that is the case upstream, and has been for 7 years or so, so renaming that seems reasonable.

  1. there was no constructor for PortAudio.Stream.Parameters and I made it struct

That seems reasonable, but why did you make them pointers when passed as arguments? In Vala, we try to only use pointers when there are no other options. Based on a quick look I don't think the parameters need to be anything special (only [SimpleType] structs are passed by value). Other options are making the arguments nullable, out, or ref.

  1. HostApiInfo and DeviceInfo must be unowned

Instead of making them static methods, why not instance methods ("get_info", perhaps) in HostApiIndex and DeviceIndex? If you really want to keep them where they are, something other than "get" for the name would be better ("from_index", perhaps?).

add portaudio test

In order to keep the size down we don't include test cases or examples in the vala-extra-vapis repository.

nemequ avatar Sep 27 '13 21:09 nemequ

  1. I am not expert in vala but I think we need for sturct for auto constructor and parameter must be nullable. It is good if nullable struct will be translated to C pointer.
  2. instance methods ("get_info", perhaps) in HostApiIndex - it is not usual for C#/C++ programmers to create methods in int wrapper type (ruby style) but bug must be fixed anyways.
  3. add portaudio test - I don't mean to include file in current repo. Just worked sample.

Hikawa avatar Sep 27 '13 21:09 Hikawa

  1. I am not expert in vala but I think we need for sturct for auto constructor and parameter must be nullable. It is good if nullable struct will be translated to C pointer.

Yes, nullable struct will map to a pointer. So, assuming null is a valid value, the arguments to Stream.open should be "Stream.Parameters?", not "Stream.Parameters*". If you just want a pointer but it shouldn't be nullable then "Stream.Parameters" should do the trick. The only time Vala will pass something that isn't a pointer is if the type is annotated with [SimpleType], which Stream.Parameters is not.

  1. instance methods ("get_info", perhaps) in HostApiIndex - it is not usual for C#/C++ programmers to create methods in int wrapper type (ruby style) but bug must be fixed anyways.

Not sure what you're trying to say here. I'm not suggesting you create a wrapper. I'm suggesting something like:

public class DeviceIndex {
  [CCode (cname = "Pa_GetDeviceInfo")]
  public unowned DeviceInfo get_info ();
}

which would be my preference. Or, if you prefer:

public class DeviceInfo {
  [CCode (cname = "Pa_GetDeviceInfo")]
  public unowned DeviceInfo from_index (DeviceIndex index);
}

Or both. Methods named "get" are typically used for containers in order to retrieve a child,

nemequ avatar Sep 27 '13 22:09 nemequ

we have "public struct DeviceIndex : int {}"

Hikawa avatar Sep 28 '13 04:09 Hikawa

So?

public struct DeviceIndex : int {
  [CCode (cname = "Pa_GetDeviceInfo")]
  public unowned DeviceInfo get_info ();
}

nemequ avatar Oct 05 '13 18:10 nemequ

I know that function with this signature can be naturally translated to method of DeviceIndex but I preffer to consider DeviceIndex as a synonym of type int and think that Pa_GetDeviceInfo is something about DeviceInfo object taken from system by index. But OK, writting both is good.

Hikawa avatar Oct 05 '13 20:10 Hikawa