[Vala] Too many arguments in generated code

2012-04-05 Thread tomw
Hi,

I'm about to port the Skeltrack [1] skeleton tracker to Vala. So far
everything works fine, except getting the actual joints from the joint
list. The code in C is pretty straight forward:

head = skeltrack_joint_list_get_joint (list,
   SKELTRACK_JOINT_ID_HEAD);

which in Vala is:

var head = JointList.get_joint(list, Skeltrack.JointId.HEAD);

The generated code from Vala however looks like:

skeltrack_joint_list_get_joint (list, SKELTRACK_JOINT_ID_HEAD, &_tmp2_);
head = _tmp2_;

which makes the compiler complain that there are too many arguments.

The respective part in the vapi looks like:

[CCode (cheader_filename = "skeltrack.h")]
[SimpleType]
public class JointList {
public static void free (Skeltrack.JointList list);
public static Skeltrack.Joint get_joint (Skeltrack.JointList 
list, Skeltrack.JointId id);
}


Any clue why that happens?

thanks,

--tomw

[1]  https://github.com/joaquimrocha/Skeltrack.git 

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


Re: [Vala] Too many arguments in generated code

2012-04-05 Thread PCMan
On Thu, Apr 5, 2012 at 4:53 PM, tomw  wrote:

> Hi,
>
> I'm about to port the Skeltrack [1] skeleton tracker to Vala. So far
> everything works fine, except getting the actual joints from the joint
> list. The code in C is pretty straight forward:
>
> head = skeltrack_joint_list_get_joint (list,
>   SKELTRACK_JOINT_ID_HEAD);
>
> which in Vala is:
>
> var head = JointList.get_joint(list, Skeltrack.JointId.HEAD);
>
> The generated code from Vala however looks like:
>
> skeltrack_joint_list_get_joint (list, SKELTRACK_JOINT_ID_HEAD, &_tmp2_);
> head = _tmp2_;
>
> which makes the compiler complain that there are too many arguments.
>
> The respective part in the vapi looks like:
>
> [CCode (cheader_filename = "skeltrack.h")]
>[SimpleType]
>public class JointList {
>public static void free (Skeltrack.JointList list);
>public static Skeltrack.Joint get_joint
> (Skeltrack.JointList list, Skeltrack.JointId id);
>}
>
>
> Any clue why that happens?
>

Why not do it like this?

[CCode (cheader_filename = "skeltrack.h",free_function"joint_list_free")]
[SimpleType]
public class JointList {
public Skeltrack.Joint get_joint(Skeltrack.JointId id);
}

I think this is the proper way to do it.


>
> thanks,
>
> --tomw
>
> [1]  https://github.com/joaquimrocha/Skeltrack.git
>
> ___
> 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


Re: [Vala] Too many arguments in generated code

2012-04-05 Thread tomw
On Do, 2012-04-05 at 17:52 +0800, PCMan wrote:

> Why not do it like this?
> 
> 
> [CCode (cheader_filename =
> "skeltrack.h",free_function"joint_list_free")]
> [SimpleType]
> public class JointList {
> public Skeltrack.Joint get_joint(Skeltrack.JointId id);
> }

Unfortunately that does not seem to be the point as in this case there
is one argument less, but there is an extra argument created, too. In
addition, it conflicts with the definition provided in the header files:

/usr/local/include/skeltrack-0.1/skeltrack-joint.h:84:22: note: expected
‘SkeltrackJointId’ but argument is of type ‘struct SkeltrackJoint *’

--tomw




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


Re: [Vala] Too many arguments in generated code

2012-04-05 Thread Simon Werbeck
/usr/local/include/skeltrack-0.1/skeltrack-joint.h:84:22: note: 
expected ‘SkeltrackJointId’ but argument is of type ‘struct 
SkeltrackJoint *’


I assume that you bound SkeltrackJoint as struct Skeltrack.Joint? In 
that case Vala will put the return value in the argument list:


SomeStruct foo () { return some_struct }
becomes
void foo (SomeStruct *result)
in the generated c code

So in your case I would bind Joint as
[Compact]
[CCode (copy_function="...", free_function="...")]
class Skeltrack.Joint {...}
___
vala-list mailing list
vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list