Hi

Thanks for the tips. I have done some modifications acording to your tips.

The "problem" i'm facing now is with the mapping of the basic types to
the language ones. I've read dbus.vapi

270         [CCode (cname = "char", const_cname = "const char", copy_function = 
"g    _strdup", free_function = "g_free", cheader_filename = 
"stdlib.h,string.h,glib    .h", type_id = "DBUS_TYPE_G_OBJECT_PATH", 
marshaller_type_name = "BOXED", get_    value_function = "g_value_get_boxed", 
set_value_function = "g_value_set_boxed"    , type_signature = "o")]
271         public class ObjectPath : string {
272                 [CCode (cname = "g_strdup")]
273                 public ObjectPath (string path);
274         }

I understand that this code is boxing/unboxing a string type into ObjectPath 
instance,

In the example program I do:

var ret = new XmlRpc.Struct (env);
ret.set_value(env, "name", env.string_new("mynameisfoo"));
..

I would like to be able to do something like:

ret.set_value(env, "name", "mynameisfoo");

Can vala identify this casting situation and call the boxing method of the 
string type
for xmlrpc and pass the value to the method?

--

Another problem is that I want to call a method when Env struct is constructed. 
I've
tried setting body to the public Env() { .. } in the vapi file, but this is not
executed. I understand that in vapi files there's support to implement some 
code,
like in glib.vapi, but why this doesnt works?

--pancake

On Sun, 16 May 2010 15:59:42 +0100
Abderrahim Kitouni <[email protected]> wrote:

> Hi,
> 
> 2010/5/16, pancake <[email protected]>:
> > I'm working on the xmlrpc vapi, but i have some questions about what's the 
> > best
> Good luck ;-) (when I tried, I gave up before writing anything)
> 
> >  way to define such abstractions on C. Attached is the vapi file and a 
> > example
> >  program.
> 
> >  Please, tell me which things will you change, and how can I avoid using 
> > cname for
> >  each function, because looks like cprefix is ignored.
> I think you're not using it correctly:
> >     [CCode (cname ="xmlrpc_server_info", cprefix="xmlrpc_server_info_")]
> >     public class ServerInfo {
> I beleive this should be lower_case_cprefix. And
> 
> >             [CCode (cprefix="xmlrpc_")]
> >             public int array_append_item(Value a, int idx, ref Value b);
> cprefix works on name spaces, not individual symbols. you should set
> it in the class to have it apply to its methods/inner classes (but I
> think lower_case_cprefix should be used for methods)
> 
> >     [Compact]
> There is no such thing as a [Compact] struct ;-p (I understand you
> have just forgot it)
> >     [CCode (cname ="xmlrpc_env", cprefix="xmlrpc_env_", free_function="", 
> > destroy_function="")]
> no need for a free function, and I think it should be
> destroy_function="xmlrpc_env_clean"
> >     public struct Env {
> > [...]
> >             public static void init(out Env env);
> This could be simply the constructor (it's a struct).
> 
> >     [CCode (cname ="xmlrpc_value", cprefix="xmlrpc_value_", 
> > free_function="")]
> >     public class Value {
> I belive it should be ref_function="xmlrpc_INCREF",
> unref_function="xmlrpc_DECREF"
> btw, cprefix is not needed here
> 
> >  things like env.string_new() vs new XmlRpc.String(env)... are not really 
> > nice, but
> >  I would like to be able to map all this stuff in the language itself, is 
> > this possible
> >  with a vapi? like in dbus or soup does?
> Why not? I don't see the problem.
> 
> >
> >  Maybe I should write vala code inside the vapi to provide this abstraction?
> I'm not sure what's the best way is, but something I'd like to have in
> this "abstraction" is throwing errors (constantly checking for
> env.fault_occured isn't nice) but I'm afraid you would end up with a
> wrapper library rather than a vapi file :-/
> 
> HTH, (read : I hope my incoherent rambling makes sense to you)
> Abderrahim
> 
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to