Re: [Vala] Putting vala in samba4



On Tue, 2008-07-15 at 07:55 +0100, Sam Liddicott wrote: 
I've been writing a VFS module for Samba4 for the last 9 months, and I'd 
like to start migrating the work to Vala, because I'd rather use Vala to 
write my work in.

Sounds interesting.

First: Samba makes heavy use of unions, which Vala doesn't support. Dang:

See: interfaces.h line 1666, the smb_read union
http://gitweb.samba.org/?p=samba.git;a=blob;f=source/libcli/raw/interfaces.h;h=537041c13762833287f946748fe08ea8e0386247;hb=v4-0-test#l1666

As I will be incrementally porting to Vala (not wrapping all structs in 
one go) I still need to be able to access the struct and it's different 
union members from Vala.

How can I manage this?

Using unions from Vala should work fine (assuming they don't require
complicated memory management). They are in some way just structs with a
very special layout, so you can bind them just like structs. However,
Vala doesn't support defining your own unions in Vala code.

The first struct I intend to wrap is struct ntvfs_ops, as that struct 
define my base object; see:
http://gitweb.samba.org/?p=samba.git;a=blob;f=source/ntvfs/ntvfs.h;h=5de8a8b6491cd7e0f81915907de5b4fbc8153a47;hb=v4-0-test#l43

It IS a virtual method table, which a particular module has to fill in 
with all the methods:
http://gitweb.samba.org/?p=samba.git;a=blob;f=source/ntvfs/cifs/vfs_cifs.c;h=844fa11cc5f584df597b0c791386b07354d08c98;hb=v4-0-test#l1089
but more complicatedly, along with a couple of attributes (ops.name, 
ops.type).
It is registered on line 1137

So I don't know where to start to wrap this, to be able to tell vala 
where to store the methods compatibly with samba.

That seems like you want support for virtual methods in compact classes
or maybe something like compact interfaces. Not sure to what extent we
want to support this. If you have concrete proposals, how Vala could
support this without being specifically tied to how the ntvfs_ops struct
works, we can certainly discuss this.

It should be possible to bind and use ntvfs_ops by declaring a delegate
for each vfunc type and adding a field for each vfunc to the bound
struct/class. You'd have to manually connect the delegates in some init
functions, then, just like in C, i.e. you can't use `override` like
that.

Juerg





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